/* ===== 主题变量：低饱和克制配色，默认墨黑（主题强调色为黑色系，纸面保持白色）===== */
:root,
body[data-theme="ocean"] {
    --sheet-bg: #FFFFFF;
    --body: #3D434A;
    --primary: #2F6B8F;
    --primary-dark: #24546F;
    --primary-soft: #E3EDF4;
    --primary-border: #C9DAE3;
    --accent: #B0643C;
    --bg: #F3F4F5;
    --surface: #FFFFFF;
    --tint: #F6F7F8;
    --preview-bg: #E8EBED;
    --text: #2B2F33;
    --muted: #6B7380;
    --border: #E2E5E8;
    --danger-bg: #FCE8E6;
    --danger-text: #C2413B;
    --danger-hover: #F9D9D7;
    --danger-border: #F0CBC8;
    --focus-ring: rgba(47, 107, 143, 0.20);
    --shadow-border: 0 1px 2px rgba(15, 23, 42, 0.05), 0 0 0 1px rgba(15, 23, 42, 0.03);
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-sheet: 0 2px 4px rgba(15, 23, 42, 0.07), 0 14px 34px rgba(15, 23, 42, 0.14);
    --toolbar-h: 62px;
    --radius-sm: 6px;
    --radius-md: 10px;
}

body[data-theme="forest"] {
    --primary: #3C5F50;
    --primary-dark: #2E4A3E;
    --primary-soft: #E5EBE7;
    --primary-border: #CBD8D0;
    --accent: #8A6D3B;
    --preview-bg: #E9EBE7;
    --focus-ring: rgba(60, 95, 80, 0.20);
}

body[data-theme="sunset"] {
    --primary: #B0643C;
    --primary-dark: #8F4F2F;
    --primary-soft: #F4E9E1;
    --primary-border: #E4D2C4;
    --accent: #3F6D8C;
    --preview-bg: #EFEAE4;
    --focus-ring: rgba(176, 100, 60, 0.20);
}

body[data-theme="violet"] {
    --primary: #5B5D9E;
    --primary-dark: #47497E;
    --primary-soft: #ECEDF5;
    --primary-border: #D6D8E6;
    --accent: #6D8C4A;
    --preview-bg: #EAEAEF;
    --focus-ring: rgba(91, 93, 158, 0.20);
}

/* 墨黑主题（默认）：界面保持常规亮色，简历纸面白色，主题强调色（区块标题、分隔线、列表标记、标签等）为黑色系 */
body[data-theme="dark"] {
    --primary: #1B1E23;
    --primary-dark: #0D1013;
    --primary-soft: #EDEFF0;
    --primary-border: #C2C7CC;
    --accent: #565C63;
    --bg: #F3F4F5;
    --surface: #FFFFFF;
    --tint: #F6F7F8;
    --preview-bg: #E8EBED;
    --text: #2B2F33;
    --muted: #6B7380;
    --border: #E2E5E8;
    --danger-bg: #FCE8E6;
    --danger-text: #C2413B;
    --danger-hover: #F9D9D7;
    --danger-border: #F0CBC8;
    --focus-ring: rgba(27, 30, 35, 0.18);
    --shadow-border: 0 1px 2px rgba(15, 23, 42, 0.05), 0 0 0 1px rgba(15, 23, 42, 0.03);
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-sheet: 0 2px 4px rgba(15, 23, 42, 0.07), 0 14px 34px rgba(15, 23, 42, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    font-family: "Noto Sans SC", "HarmonyOS Sans SC", "HarmonyOS Sans", "MiSans", "Alibaba PuHuiTi 3.0", "Alibaba PuHuiTi", "PingFang SC", "Source Han Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ===== 顶部工具栏 ===== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--toolbar-h);
    padding: 0 28px;
    background: var(--surface);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    position: relative;
    z-index: 20;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.toolbar-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--primary-dark);
    white-space: nowrap;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
}

/* 主题切换器 */
.theme-switcher {
    display: flex;
    gap: 6px;
}

.theme-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    padding: 5px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    color: var(--muted);
    min-height: 40px;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.08s ease;
}

.theme-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

.theme-btn:active {
    transform: scale(0.96);
}

.theme-btn.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
}

.theme-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.theme-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex: none;
}

/* ===== 按钮 ===== */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 550;
    cursor: pointer;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.18s ease, transform 0.08s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.icon {
    width: 1em;
    height: 1em;
    flex: none;
}

.btn:active {
    transform: scale(0.96);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    font-weight: 650;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:focus-visible {
    outline-color: #fff;
}

.btn-ghost {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--tint);
    color: var(--text);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-file {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border: 1px solid var(--primary-border);
}

.btn-file:hover {
    background: var(--primary-border);
}

.btn-add {
    width: 100%;
    margin-top: 10px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    border: 1px dashed var(--primary-border);
    font-weight: 550;
    transition: background 0.18s ease, border-color 0.18s ease, border-style 0.18s ease, transform 0.08s ease;
}

.btn-add:hover {
    background: var(--primary-border);
    border-style: solid;
    border-color: var(--primary);
}

.btn-del {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    min-height: 40px;
    transition: background 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.btn-del .icon {
    width: 15px;
    height: 15px;
}

.btn-del:hover {
    background: var(--danger-hover);
}

.kv-row .btn-del {
    min-height: 40px;
    min-width: 40px;
}

.kv-row .btn-del .icon {
    width: 16px;
    height: 16px;
}

/* ===== 主布局：左右独立滚动（左 4 / 右 6）===== */
.layout {
    display: flex;
    height: calc(100vh - var(--toolbar-h));
    overflow: hidden;
}

/* 左侧输入栏：独立滚动 */
.sidebar {
    flex: 0 0 44%;
    min-width: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 22px 20px 40px;
    background: var(--bg);
    border-right: 1px solid var(--border);
}

/* 右侧预览：独立滚动 */
.preview-wrap {
    flex: 1 1 56%;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
    overscroll-behavior: contain;
    background: var(--preview-bg);
}

.preview-scroll {
    min-height: 100%;
    display: flex;
    justify-content: safe center;
    padding: 28px 24px 48px;
}

.preview-wrap::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 10px;
}

.preview-wrap::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.preview-wrap::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: #C3C9CF;
    border-radius: 999px;
    border: 2px solid var(--preview-bg);
}

.preview-wrap::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #A7AFB7;
}

/* ===== 表单 ===== */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px 18px 20px;
    margin-bottom: 14px;
    transition: border-color 0.2s ease;
}

.form-section:hover {
    border-color: var(--primary-border);
}

/* 区块标题：图标徽标 + 标题文字 + 条目计数 */
.form-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--primary-dark);
}

.form-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    color: var(--muted);
}

.form-icon .icon {
    width: 15px;
    height: 15px;
}

.form-count {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 1px 9px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--tint);
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.form-count:empty {
    display: none;
}

.form-subtitle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0 8px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 650;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
}

.field {
    display: block;
    margin-bottom: 12px;
}

.form-grid .field {
    margin-bottom: 0;
}

.field-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.field-hint {
    display: block;
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 5px;
    line-height: 1.5;
}

.field-hint code {
    background: var(--tint);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 4px;
    font-size: 11px;
    font-family: inherit;
    color: var(--accent);
}

.field input,
.field textarea,
.kv-row input,
.entry-card input,
.entry-card textarea,
.resume-name-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:hover,
.field textarea:hover,
.kv-row input:hover,
.entry-card input:hover,
.entry-card textarea:hover,
.resume-name-input:hover {
    border-color: var(--primary-border);
}

.field input:focus,
.field textarea:focus,
.kv-row input:focus,
.entry-card input:focus,
.entry-card textarea:focus,
.resume-name-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.field textarea,
.entry-card textarea {
    resize: vertical;
    min-height: 64px;
}

.sidebar-hint {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    margin: 8px 0 0;
}

/* 简历管理 */
.resume-name-input {
    font-weight: 550;
}

.resume-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.resume-chip {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    min-height: 40px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.08s ease;
}

.resume-chip:hover {
    border-color: var(--primary);
    color: var(--text);
}

.resume-chip:active {
    transform: scale(0.96);
}

.resume-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.resume-chip:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.resume-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

/* 头像上传区 */
.avatar-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 18px 16px;
    background: var(--tint);
    border: 1px dashed var(--primary-border);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.avatar-zone:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.avatar-preview {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    overflow: hidden;
    flex: none;
    background: var(--surface);
    border: 2px solid var(--primary-border);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease;
}

.avatar-zone:hover .avatar-preview {
    border-color: var(--primary);
}

.avatar-preview svg {
    width: 38px;
    height: 38px;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.avatar-hint {
    margin: 0;
    font-size: 11px;
    color: var(--muted);
    text-align: center;
}

/* 个人信息键值行 */
.kv-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kv-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background 0.18s ease;
}

.kv-row:hover {
    background: var(--tint);
}

.kv-row .kv-label {
    flex: 1;
}

.kv-row .kv-value {
    flex: 2;
}

/* 删除按钮：悬停行时才显现，键盘聚焦始终可见 */
@media (hover: hover) {
    .kv-row .btn-del {
        opacity: 0;
    }

    .kv-row:hover .btn-del {
        opacity: 1;
    }
}

.kv-row .btn-del:focus-visible {
    opacity: 1;
}

/* 可增删卡片（工作/教育/项目/证书） */
.entry-card {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px 12px;
    margin-bottom: 12px;
    background: var(--surface);
    transition: border-color 0.2s ease;
}

.entry-card:hover {
    border-color: var(--primary-border);
}

.entry-card:focus-within {
    border-color: var(--primary);
}

.entry-card .entry-delete {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

/* ===== A4 预览 ===== */
.sheet {
    width: 210mm;
    min-height: 297mm;
    flex: 0 0 auto;
    background: var(--sheet-bg, #fff);
    box-shadow: var(--shadow-sheet);
    border-radius: 2px;
    /* 导出 PDF 时保留黑色纸面背景 */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.sheet-inner {
    position: relative;
    padding: 12mm 14mm;
}

/* 简历顶部横幅 */
.resume-header {
    display: flex;
    align-items: center;
    gap: 16px;
    background: transparent;
    color: var(--primary-dark);
    border: none;
    border-radius: 0;
    margin-bottom: 14px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.r-head-text {
    flex: 1;
    min-width: 0;
}

.resume-header .r-name {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text);
    text-wrap: balance;
}

.resume-header .r-target {
    margin-top: 2px;
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
}

.resume-header .r-summary {
    margin: 6px 0 0;
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--body);
}

/* 预览区头像 */
.avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    flex: none;
    background: var(--primary);
    color: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    outline: 1px solid rgba(255, 255, 255, 0.85);
}

.avatar svg {
    width: 30px;
    height: 30px;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 预览区加粗关键字 */
.resume-preview strong {
    font-weight: 700;
    color: var(--text);
}

/* 区块 */
.section {
    margin-bottom: 12px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--primary-dark);
    border-bottom: 1px solid var(--primary);
    padding-bottom: 5px;
}

/* 个人信息键值网格 */
.kv-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 20px;
    font-size: 12px;
}

.kv-item {
    display: flex;
    gap: 6px;
    line-height: 1.7;
}

.kv-item .kv-key {
    color: var(--muted);
    flex: none;
    font-weight: 500;
}

.kv-item .kv-val {
    color: var(--text);
    word-break: break-all;
}

/* 工作/教育/项目条目 */
.entry {
    margin-bottom: 10px;
    break-inside: avoid;
}

.entry-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.entry-name {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
}

.entry-role {
    font-size: 11.5px;
    color: var(--accent);
    font-weight: 600;
}

.entry-period {
    margin-left: auto;
    font-size: 11px;
    color: var(--muted);
    flex: none;
    font-variant-numeric: tabular-nums;
}

.entry-list {
    margin: 2px 0 0;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--body);
    word-break: break-word;
}

.entry-list li {
    margin: 0 0 1px;
}

.entry-list li::marker {
    color: var(--primary);
}

.entry-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}

/* 技能标签 */
.skill-list {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--text);
    word-break: break-word;
}

.skill-list li {
    margin: 0 0 1px;
}

.skill-list li::marker {
    color: var(--primary);
}

.tag {
    background: var(--tint);
    color: var(--muted);
    border: 1px solid var(--primary-border);
    border-radius: 6px;
    padding: 1px 8px;
    font-size: 9px;
    letter-spacing: 0.02em;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* 证书 */
.certs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 20px;
    font-size: 12px;
}

.cert-item {
    line-height: 1.7;
    break-inside: avoid;
}

.cert-item .cert-name {
    font-weight: 600;
    color: var(--text);
}

.cert-item .cert-meta {
    color: var(--muted);
}

/* 空状态提示 */
.empty-hint {
    font-size: 12px;
    color: var(--muted);
    padding: 6px 0;
}

/* ===== 导出引导弹窗 ===== */
.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.modal-mask[hidden] {
    display: none;
}

.modal-card {
    width: min(420px, 100%);
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sheet);
    padding: 24px;
}

.modal-title {
    margin: 0 0 8px;
    font-size: 17px;
    color: var(--text);
}

.modal-text {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--muted);
}

.modal-steps {
    margin: 0 0 20px;
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
}

.modal-steps li {
    margin-bottom: 4px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== 打印：还原文档流，保证 A4 多页正确 ===== */
@page {
    size: A4;
    margin: 12mm 14mm;
}

@media print {

    html,
    body {
        height: auto;
        overflow: visible;
    }

    body {
        background: #fff;
    }

    .toolbar,
    .sidebar,
    .sidebar-hint,
    .modal-mask {
        display: none !important;
    }

    .layout {
        display: block;
        height: auto;
        overflow: visible;
        padding: 0;
        gap: 0;
    }

    .preview-wrap {
        height: auto;
        overflow: visible;
    }

    .preview-scroll {
        height: auto;
        overflow: visible;
        min-height: 0;
        display: block;
        padding: 0;
    }

    .sheet {
        width: 182mm;
        min-height: 0;
        box-shadow: none;
        border-radius: 0;
    }

    .sheet-inner {
        padding: 0;
    }

    .entry,
    .cert-item,
    .tag,
    .resume-header,
    .section {
        break-inside: avoid;
    }

    .resume-header,
    .tag {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ===== 动效偏好：减少动画 ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }

    .btn:active,
    .theme-btn:active,
    .resume-chip:active {
        transform: none;
    }
}