/* ==========================================================================
   Java 面试知识体系 — 统一样式表
   原先 105 个 HTML 各自内联一份 CSS（合计约 412 KB），现集中到这里。
   改动样式只需改这一个文件。

   布局宽度用 CSS 变量控制，靠 <body> 上的 class 切换：
     .layout-home   首页（1200px）
     .layout-index  模块首页（1100px）
     .layout-doc    内容页（900px，默认）
   ========================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
    --page-max: 900px;

    --bg:            #f4f6f9;
    --surface:       #ffffff;
    --surface-alt:   #f8fafc;
    --border:        #e2e8f0;
    --border-strong: #cbd5e1;
    --border-faint:  #f1f5f9;

    --text:        #2c3e50;
    --text-body:   #334155;
    --text-strong: #0f172a;
    --text-muted:  #5c6b80;   /* 对比度 ≥ 4.5:1（原 #64748b 在灰底上 4.4:1） */
    --text-dim:    #7b8794;   /* 卡片描述等大字号场景，原 #94a3b8 仅 2.56:1 */

    --brand:       #2563eb;
    --brand-dark:  #1d4ed8;
    --brand-ink:   #1a365d;
    --brand-soft:  #eff6ff;
    --brand-border:#bfdbfe;

    --ok:      #059669;
    --warn:    #d97706;
    --danger:  #e11d48;
    --info:    #0891b2;
    --violet:  #7c3aed;
    --indigo:  #4f46e5;
    --orange:  #ea580c;

    --code-bg:     #0f172a;
    --code-bar:    #1e293b;
    --code-text:   #e2e8f0;
    --code-kw:     #7dd3fc;
    --code-str:    #a5b4fc;
    --code-cmt:    #94a3b8;   /* 代码注释是中文讲解所在，必须够亮：6.96:1 */
    --code-cls:    #fbbf24;
    --code-in:     #6ee7b7;
    --code-out:    #fca5a5;

    --ink-code-bg:  #f1f5f9;
    --ink-code-fg:  #0f172a;

    --shadow-card: 0 8px 25px -8px rgba(0, 0, 0, 0.12);
    --radius:      12px;
}

/* ---------- 深色模式 ---------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            #0f1419;
        --surface:       #1a2129;
        --surface-alt:   #212a34;
        --border:        #2c3742;
        --border-strong: #3d4a57;
        --border-faint:  #232d37;

        --text:        #d7dee6;
        --text-body:   #c3ccd6;
        --text-strong: #f1f5f9;
        --text-muted:  #9aa8b8;
        --text-dim:    #8b98a8;

        --brand:       #60a5fa;
        --brand-dark:  #3b82f6;
        --brand-ink:   #cbd9ea;
        --brand-soft:  #17253a;
        --brand-border:#2c4058;

        --code-bg:   #0b1017;
        --code-bar:  #161d26;
        --ink-code-bg: #263341;
        --ink-code-fg: #dbeafe;

        --shadow-card: 0 8px 25px -8px rgba(0, 0, 0, 0.6);
    }
}
:root[data-theme="dark"] {
    --bg:            #0f1419;
    --surface:       #1a2129;
    --surface-alt:   #212a34;
    --border:        #2c3742;
    --border-strong: #3d4a57;
    --border-faint:  #232d37;

    --text:        #d7dee6;
    --text-body:   #c3ccd6;
    --text-strong: #f1f5f9;
    --text-muted:  #9aa8b8;
    --text-dim:    #8b98a8;

    --brand:       #60a5fa;
    --brand-dark:  #3b82f6;
    --brand-ink:   #cbd9ea;
    --brand-soft:  #17253a;
    --brand-border:#2c4058;

    --code-bg:   #0b1017;
    --code-bar:  #161d26;
    --ink-code-bg: #263341;
    --ink-code-fg: #dbeafe;

    --shadow-card: 0 8px 25px -8px rgba(0, 0, 0, 0.6);
}

/* 布局宽度 */
body.layout-home  { --page-max: 1200px; }
body.layout-index { --page-max: 1100px; }

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--brand); }

/* ---------- 顶栏 ---------- */
.top-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    min-height: 56px;          /* 原为固定 height: 56px，窄屏会把内容裁掉 */
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-inner {
    max-width: var(--page-max);
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;           /* 原 104 个页面缺这一条，360px 窄屏会溢出 */
    padding: 8px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--brand-ink);
}

.logo-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
}

.logo-text {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.back-link,
.nav-links a {
    color: var(--brand);
    text-decoration: none;
    font-weight: 500;
}
.back-link { font-size: 0.85rem; }
.back-link:hover,
.nav-links a:hover { text-decoration: underline; }

.nav-links {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    align-items: center;
    flex-wrap: wrap;
}

/* 顶栏右侧的操作按钮（主题切换 / 搜索等，由 app.js 注入） */
.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.icon-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn:hover {
    background: var(--surface-alt);
    border-color: var(--border-strong);
    color: var(--brand);
}

/* ---------- Hero（首页） ---------- */
.hero {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 48px 24px 40px;
    text-align: center;
}
.hero-inner { max-width: 800px; margin: 0 auto; }
.hero h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-strong);
    margin-bottom: 10px;
    letter-spacing: -0.3px;
}
.hero .subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
}
.hero .tag-row {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.tag {
    font-size: 0.8rem;
    padding: 4px 14px;
    border-radius: 20px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    border: 1px solid var(--brand-border);
    font-weight: 500;
}

/* ---------- 主体容器 ---------- */
.main {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 32px 24px 40px;
}

/* 73 个页面原先在 .main 之外又套了一层带内联样式的容器，
   改造后统一成第二个 .main，靠这个类抹掉重复的上内边距。 */
.main--cont { padding-top: 0; }

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-body);
    margin-bottom: 20px;
    padding-left: 4px;
    letter-spacing: 0.2px;
}

/* ---------- 页头 ---------- */
.page-header { margin-bottom: 28px; }
.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-strong);
    margin-bottom: 6px;
}
.page-header .desc {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ---------- 模块卡片网格 ---------- */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 40px;
}

.module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 22px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.module-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.module-card:hover {
    box-shadow: var(--shadow-card);
    transform: translateY(-2px);
    border-color: var(--border-strong);
}
.module-card .card-icon { font-size: 2rem; margin-bottom: 14px; line-height: 1; }
.module-card .card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 6px;
}
.module-card .card-desc {
    font-size: 0.85rem;
    color: var(--text-dim);       /* 原 #94a3b8 / #fff 仅 2.56:1，不达 WCAG AA */
    line-height: 1.5;
}
.module-card .card-arrow {
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--brand);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 卡片顶部强调色 */
.accent-blue::before    { background: var(--brand); }
.accent-indigo::before  { background: var(--indigo); }
.accent-violet::before  { background: var(--violet); }
.accent-emerald::before { background: var(--ok); }
.accent-amber::before   { background: var(--warn); }
.accent-rose::before    { background: var(--danger); }
.accent-cyan::before    { background: var(--info); }
.accent-orange::before  { background: var(--orange); }

/* ---------- 问答卡片 ---------- */
.qa {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 26px 30px;
    margin-bottom: 22px;
}
.qa h2 {
    font-size: 1.08rem;
    font-weight: 600;
    color: var(--brand-dark);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-faint);
    scroll-margin-top: 80px;      /* 锚点跳转时避开 sticky 顶栏 */
}
.qa h3 {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-strong);
    margin: 16px 0 8px;
}
.qa p { margin: 10px 0; font-size: 0.94rem; color: var(--text-body); }
.qa ul, .qa ol { margin: 8px 0 8px 22px; font-size: 0.94rem; color: var(--text-body); }
.qa li { margin: 5px 0; }
.qa strong { color: var(--text-strong); }
.qa em { color: var(--text-muted); font-size: 0.9rem; }

/* 行内代码 —— 原先全站 81 个页面用了 <code> 却没有任何对应样式 */
.qa code,
.main code,
td code,
li code,
p code {
    background: var(--ink-code-bg);
    color: var(--ink-code-fg);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: Consolas, "Courier New", ui-monospace, monospace;
    font-size: 0.88em;
    border: 1px solid var(--border);
    word-break: break-word;
}

/* ---------- 代码块 ---------- */
.code-block {
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--code-bar);
    position: relative;
}
.code-block .code-title {
    background: var(--code-bar);
    color: var(--code-cmt);
    font-size: 0.75rem;
    padding: 6px 14px;
    letter-spacing: 0.5px;
    padding-right: 76px;          /* 给右上角复制按钮留位 */
}
.code-block pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 14px 16px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.65;
    font-family: Consolas, "Courier New", ui-monospace, monospace;
    -webkit-overflow-scrolling: touch;
}
.code-block code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }
.code-block .kw  { color: var(--code-kw); }
.code-block .st  { color: var(--code-str); }
.code-block .cm  { color: var(--code-cmt); font-style: italic; }
.code-block .cn  { color: var(--code-cls); }
.code-block .in  { color: var(--code-in); }    /* 原先 synchronized.html 用了但没定义 */
.code-block .out { color: var(--code-out); }
.code-block .err { color: var(--code-out); }

/* 复制按钮（app.js 注入） */
.copy-btn {
    position: absolute;
    top: 4px;
    right: 8px;
    background: rgba(148, 163, 184, 0.16);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: var(--code-text);
    font-size: 0.7rem;
    padding: 2px 9px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.6;
    transition: background 0.15s;
}
.copy-btn:hover { background: rgba(148, 163, 184, 0.32); }
.copy-btn.done { background: rgba(5, 150, 105, 0.85); border-color: transparent; color: #fff; }

/* ---------- 面试要点 ---------- */
.key-points {
    background: var(--brand-soft);
    border: 1px solid var(--brand-border);
    border-radius: 8px;
    padding: 14px 18px;
    margin-top: 14px;
}
.key-points h3 {
    font-size: 0.85rem;
    color: var(--brand-dark);
    margin-bottom: 8px;
    margin-top: 0;
    padding: 0;
    border: none;
}
.key-points ul, .key-points ol { margin: 0 0 0 20px; }
.key-points li { margin: 4px 0; font-size: 0.9rem; color: var(--text-body); }
.key-points code { background: rgba(37, 99, 235, 0.1); border-color: transparent; }

/* ---------- 表格 ---------- */
/* 原先每个 <td> 都内联一份 style，全站 1782 处；表格没有统一的类 */
.main table,
.term-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    margin: 12px 0;
}
.main table th,
.main table td,
.term-table th,
.term-table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}
.main table th,
.term-table th {
    background: var(--border-faint);
    font-weight: 600;
    color: var(--text-strong);
}
.main table tr:hover td { background: var(--surface-alt); }

/* ---------- 练习页 / 类比块 ---------- */
.practice { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 26px 30px; margin-bottom: 22px; }
.practice h3 { font-size: 1rem; color: var(--brand-dark); margin: 18px 0 8px; }
.practice li { margin: 6px 0; font-size: 0.94rem; color: var(--text-body); }

.analogy {
    background: var(--surface-alt);
    border-left: 3px solid var(--brand-border);
    border-radius: 6px;
    padding: 12px 16px;
    margin: 12px 0;
    font-size: 0.92rem;
    color: var(--text-muted);
}
.analogy strong { color: var(--text-strong); }

/* ---------- 页内目录（app.js 生成） ---------- */
.toc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 22px;
    font-size: 0.88rem;
}
.toc-title {
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.toc-toggle {
    background: none;
    border: none;
    color: var(--brand);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    padding: 2px 4px;
}
.toc ol { margin: 0 0 0 20px; }
.toc li { margin: 3px 0; }
.toc a { color: var(--text-body); text-decoration: none; }
.toc a:hover { color: var(--brand); text-decoration: underline; }
.toc a.current { color: var(--brand); font-weight: 600; }
.toc.collapsed ol { display: none; }

/* ---------- 底部上/下一页 ---------- */
.page-nav {
    display: flex;
    gap: 12px;
    margin: 28px 0 8px;
    max-width: var(--page-max);
    margin-left: auto;
    margin-right: auto;
}
.page-nav a {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-body);
    font-size: 0.85rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: block;
}
.page-nav a:hover { border-color: var(--brand-border); box-shadow: var(--shadow-card); }
.page-nav a.next { text-align: right; }
.page-nav .pn-label { color: var(--text-muted); font-size: 0.75rem; display: block; margin-bottom: 2px; }
.page-nav .pn-title { color: var(--brand); font-weight: 600; }
.page-nav .pn-empty { visibility: hidden; }

/* ---------- 相关推荐（跨模块） ---------- */
.related {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 22px;
    margin-bottom: 22px;
}
.related h3 {
    font-size: 0.9rem;
    color: var(--text-strong);
    margin-bottom: 10px;
}
.related ul { list-style: none; margin: 0; }
.related li { margin: 6px 0; font-size: 0.88rem; }
.related a { color: var(--brand); text-decoration: none; }
.related a:hover { text-decoration: underline; }
.related .rel-mod {
    font-size: 0.72rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 5px;
    margin-right: 6px;
    white-space: nowrap;
}

/* ---------- 学习进度工具栏（app.js 注入） ---------- */
.study-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 20px;
    font-size: 0.82rem;
}
.study-bar .sb-label { color: var(--text-muted); margin-right: 2px; }
.study-btn {
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--text-muted);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    line-height: 1.6;
}
.study-btn:hover { border-color: var(--border-strong); color: var(--text-strong); }
.study-btn.active[data-state="done"]    { background: rgba(5,150,105,0.13);  border-color: var(--ok);     color: var(--ok);     font-weight: 600; }
.study-btn.active[data-state="review"]  { background: rgba(217,119,6,0.13);  border-color: var(--warn);   color: var(--warn);   font-weight: 600; }
.study-btn.active[data-state="confused"]{ background: rgba(225,29,72,0.13);  border-color: var(--danger); color: var(--danger); font-weight: 600; }
.study-bar .sb-spacer { flex: 1; }

/* 首页进度条 */
.progress-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 22px;
    margin-bottom: 32px;
}
.progress-panel h2 { font-size: 1rem; color: var(--text-strong); margin-bottom: 12px; }
.progress-track {
    height: 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
}
.progress-seg { height: 100%; transition: width 0.3s; }
.progress-seg.done     { background: var(--ok); }
.progress-seg.review   { background: var(--warn); }
.progress-seg.confused { background: var(--danger); }
.progress-legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.progress-legend .dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    margin-right: 5px;
}
.dot.done     { background: var(--ok); }
.dot.review   { background: var(--warn); }
.dot.confused { background: var(--danger); }
.progress-actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.resume-link {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border-radius: 8px;
    padding: 7px 16px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}
.resume-link:hover { background: var(--brand-dark); }

/* ---------- 自测模式（答案折叠） ---------- */
.qa h2 .selftest-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    float: right;
    padding-top: 4px;
}
body.selftest .qa > *:not(h2):not(.qa-answer-toggle) { display: none; }
body.selftest .qa.revealed > * { display: revert; }
.qa-answer-toggle {
    display: none;
    background: var(--surface-alt);
    border: 1px dashed var(--border-strong);
    color: var(--brand);
    border-radius: 8px;
    padding: 10px;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    margin-top: 4px;
}
body.selftest .qa-answer-toggle { display: block; }
body.selftest .qa.revealed .qa-answer-toggle { display: none; }

/* ---------- 搜索结果 ---------- */
.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: none;
    z-index: 200;
    padding: 60px 16px 16px;
    overflow-y: auto;
}
.search-overlay.open { display: block; }
.search-box {
    max-width: 680px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 50px -12px rgba(0,0,0,0.35);
}
.search-input-wrap { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.search-input-wrap input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-strong);
    font-size: 1rem;
    font-family: inherit;
}
.search-input-wrap .esc { font-size: 0.7rem; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.search-results { max-height: 60vh; overflow-y: auto; }
.search-result {
    display: block;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-faint);
    text-decoration: none;
    color: inherit;
}
.search-result:hover, .search-result.active { background: var(--surface-alt); }
.search-result .sr-mod { font-size: 0.7rem; color: var(--text-muted); }
.search-result .sr-title { color: var(--brand); font-weight: 600; font-size: 0.92rem; margin: 2px 0; }
.search-result .sr-snippet { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }
.search-result mark { background: rgba(251, 191, 36, 0.4); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-empty { padding: 24px 18px; text-align: center; color: var(--text-muted); font-size: 0.88rem; }

/* ---------- 免责声明 ---------- */
.disclaimer {
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    color: #92400e;
    text-align: center;
    padding: 10px 24px;
    font-size: 0.8rem;
}
:root[data-theme="dark"] .disclaimer {
    background: #2a2312;
    border-top-color: #4d3f16;
    color: #fcd34d;
}

/* ---------- 页脚 ---------- */
.footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 20px 24px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.footer-inner {
    max-width: var(--page-max);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px 20px;
}
.footer span { margin: 0 2px; }
.footer a { color: var(--brand); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-divider { color: var(--border-strong); }
.footer-inner .beian a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
}
.footer-inner .beian a:hover { color: var(--brand-dark); }
.footer-inner .beian .beian-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #1e40af;
    color: #fff;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
}

/* ---------- 回到顶部 ---------- */
.to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: var(--shadow-card);
    z-index: 60;
}
.to-top.show { display: flex; }
.to-top:hover { color: var(--brand); border-color: var(--brand-border); }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 640px) {
    .main { padding: 20px 16px; }
    body.layout-doc .main { padding: 16px 12px; }
    body.layout-home .main { padding: 24px 16px; }

    .hero { padding: 32px 16px 28px; }
    .hero h1 { font-size: 1.4rem; }
    .hero .subtitle { font-size: 0.9rem; }

    .module-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .module-card { padding: 18px 16px; }
    .module-card .card-icon { font-size: 1.6rem; margin-bottom: 10px; }

    .page-header h1 { font-size: 1.3rem; }
    .page-header .desc { font-size: 0.88rem; }

    .qa { padding: 16px 14px; }
    .qa h2 { font-size: 1rem; }
    .qa p, .qa ul, .qa ol, .qa li { font-size: 0.9rem; }

    .code-block pre { font-size: 0.78rem; padding: 12px; }
    .key-points { padding: 12px 14px; }
    .practice { padding: 16px 14px; }

    .nav-links { gap: 10px; font-size: 0.78rem; }
    .top-bar { padding: 0 14px; }

    /* 表格：允许横向滚动，但不再 nowrap —— 原先 white-space: nowrap 会让
       392 个装了长中文解释的单元格变成一整行超长横向滚动，几乎无法阅读 */
    .main table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .page-nav { flex-direction: column; }
    .page-nav a.next { text-align: left; }

    .footer-inner { flex-direction: column; gap: 8px; }
    .progress-legend { gap: 12px; }
    .to-top { right: 12px; bottom: 12px; }
}

@media (max-width: 400px) {
    .module-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   打印：面试前想把「速查表」打出来时，去掉导航与交互元素
   ========================================================================== */
@media print {
    .top-bar, .footer, .disclaimer, .page-nav, .toc, .study-bar,
    .to-top, .copy-btn, .search-overlay, .related, .progress-panel { display: none !important; }
    body { background: #fff; color: #000; line-height: 1.5; }
    .main { max-width: none; padding: 0; }
    .qa, .code-block, .key-points { break-inside: avoid; page-break-inside: avoid; }
    .qa { border: 1px solid #ccc; box-shadow: none; margin-bottom: 12px; }
    .code-block pre { background: #f8f8f8; color: #000; border: 1px solid #ddd; }
    .code-block .code-title { background: #eee; color: #333; }
    .code-block .kw, .code-block .st, .code-block .cm,
    .code-block .cn, .code-block .in, .code-block .out { color: #000 !important; }
    body.selftest .qa > * { display: revert !important; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.75em; color: #666; }
}

/* 尊重系统的减少动效设置 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
