:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --text: #1f2937;
    --text-2: #4b5563;
    --muted: #8a919c;
    --line: #e7e9ee;
    --line-2: #f0f1f4;
    --primary: #4263eb;
    --primary-2: #364fc7;
    --primary-soft: #eef2ff;
    --ok: #2f9e44;
    --ok-soft: #ebfbee;
    --warn-soft: #fff8db;
    --warn: #9a6b00;
    --choice: #1c7ed6;
    --choice-soft: #e7f5ff;
    --blank: #ae3ec9;
    --blank-soft: #f8f0fc;
    --solve: #f76707;
    --solve-soft: #fff4e6;
    --judge: #0c8599;
    --judge-soft: #e3fafc;
    --short: #2f9e44;
    --short-soft: #ebfbee;
    --calc: #f76707;
    --calc-soft: #fff4e6;
    --proof: #c2255c;
    --proof-soft: #fff0f6;
    --radius: 12px;
    --topbar-h: 60px;
    --sidebar-w: 272px;
    --aside-w: 300px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 4px rgba(16, 24, 40, .05);
    font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font: inherit; cursor: pointer; color: inherit; }

/* ---------- 按钮与标签 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid var(--line); background: var(--panel); color: var(--text);
    border-radius: 8px; padding: 7px 14px; line-height: 1.3; font-size: 14px;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: #cfd4dc; background: #fafbfc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #eef0f3; border-color: transparent; }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn-soft:hover { background: #e0e7ff; border-color: transparent; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn.is-done { background: var(--ok-soft); border-color: #b2f2bb; color: var(--ok); }

.icon-btn { border: none; background: transparent; font-size: 20px; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: #eef0f3; }

.tag {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; line-height: 1.6; padding: 1px 8px; border-radius: 6px;
    background: #f1f3f5; color: var(--text-2); white-space: nowrap;
}
.tag-choice { background: var(--choice-soft); color: var(--choice); }
.tag-blank { background: var(--blank-soft); color: var(--blank); }
.tag-solve { background: var(--solve-soft); color: var(--solve); }
.tag-judge { background: var(--judge-soft); color: var(--judge); }
.tag-short { background: var(--short-soft); color: var(--short); }
.tag-calc { background: var(--calc-soft); color: var(--calc); }
.tag-proof { background: var(--proof-soft); color: var(--proof); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-primary { background: var(--primary-soft); color: var(--primary); }
.tag-same { background: var(--line-2); color: var(--muted); cursor: help; }

/* ---------- 顶栏 ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 20px;
    padding: 0 20px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--line);
}
.subject-tabs { display: flex; gap: 2px; padding: 3px; background: #f1f3f5; border-radius: 10px; }
.subject-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 14px; border-radius: 8px; color: var(--text-2); white-space: nowrap; font-size: 14px;
}
.subject-tab:hover { color: var(--text); }
.subject-tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.subject-tab .soon { font-size: 11px; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search { position: relative; }
.search::before {
    content: ""; position: absolute; left: 11px; top: 50%; width: 13px; height: 13px; margin-top: -8px;
    border: 2px solid #9aa1ab; border-radius: 50%;
}
.search::after {
    content: ""; position: absolute; left: 23px; top: 50%; width: 6px; height: 2px; margin-top: 4px;
    background: #9aa1ab; transform: rotate(45deg); border-radius: 1px;
}
.search input {
    width: 280px; padding: 8px 12px 8px 34px;
    border: 1px solid transparent; border-radius: 9px; background: #f1f3f5; font: inherit; font-size: 14px; color: var(--text);
    transition: background .15s, border-color .15s, width .2s;
}
.search input:focus { outline: none; border-color: #bac8ff; background: #fff; width: 340px; }
.logout-form { display: flex; align-items: center; margin: 0; }
.logout-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: 9px; background: #fff;
    color: var(--text-2); font: inherit; font-size: 13.5px; white-space: nowrap; cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.logout-btn:hover { color: #c92a2a; border-color: #ffc9c9; background: #fff5f5; }
.search-toggle {
    display: none; place-items: center; width: 36px; height: 36px; padding: 0;
    border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text-2); cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.search-toggle:hover, body.search-open .search-toggle { color: var(--primary); border-color: #bac8ff; background: #edf2ff; }

/* ---------- 确认框 ---------- */
.modal-mask {
    position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
    background: rgba(15, 23, 42, .38); animation: modal-fade .15s ease-out;
}
.modal {
    width: min(380px, 100%); background: #fff; border-radius: 14px; padding: 22px 22px 18px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .2); animation: modal-pop .18s ease-out;
}
.modal-head { display: flex; gap: 12px; align-items: flex-start; }
.modal-icon {
    flex: 0 0 auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
    background: #fff5f5; color: #e03131;
}
.modal h3 { margin: 2px 0 4px; font-size: 16.5px; }
.modal p { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal-actions .btn { min-width: 84px; justify-content: center; }
.btn-danger { background: #e03131; border-color: #e03131; color: #fff; }
.btn-danger:hover { background: #c92a2a; border-color: #c92a2a; }
@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------- 整体布局 ---------- */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
    position: sticky; top: var(--topbar-h);
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 18px 12px 48px;
    font-size: 14px;
    scrollbar-width: thin;
}
body.no-sidebar .sidebar, body.no-sidebar #menuBtn { display: none; }
.content { flex: 1; min-width: 0; padding: 28px 36px 80px; }
.content-inner { max-width: 1180px; margin: 0 auto; }
body.no-sidebar .content-inner { max-width: 1040px; }
.loading, .empty { color: var(--muted); padding: 48px 0; text-align: center; }
.sidebar-mask { display: none; }
.only-mobile { display: none; }

/* ---------- 侧栏 ---------- */
.side-head { padding: 2px 10px 14px; border-bottom: 1px solid var(--line-2); margin-bottom: 10px; }
.side-head h2 { margin: 0; font-size: 17px; }
.side-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.side-progress { margin-top: 10px; }
.side-progress .bar { height: 5px; }
.side-progress small { color: var(--muted); font-size: 12px; }
.side-nav { list-style: none; margin: 0 0 6px; padding: 0; }
.side-nav a {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 8px; color: var(--text-2);
}
.side-nav a:hover { background: #f3f4f6; }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.side-nav .ico { width: 18px; text-align: center; opacity: .8; }
.side-part-title {
    font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .06em;
    padding: 14px 10px 6px;
}
.side-chapter > button {
    width: 100%; display: flex; align-items: center; gap: 8px;
    border: none; background: transparent; text-align: left;
    padding: 7px 10px; border-radius: 8px; color: var(--text);
}
.side-chapter > button:hover { background: #f3f4f6; }
.side-chapter .caret { transition: transform .15s; font-size: 9px; color: var(--muted); width: 10px; }
.side-chapter.open .caret { transform: rotate(90deg); }
.side-chapter.has-active > button { color: var(--primary); font-weight: 600; }
.side-chapter .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.side-types { display: none; list-style: none; margin: 2px 0 6px 15px; padding: 0 0 0 8px; border-left: 1px solid var(--line); }
.side-chapter.open .side-types { display: block; }
.side-types a {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px; border-radius: 7px; color: var(--text-2); line-height: 1.5;
}
.side-types a:hover { background: #f3f4f6; color: var(--text); }
.side-types a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.side-types .done-mark { margin-left: auto; color: var(--ok); font-size: 12px; }

/* ---------- 通用 ---------- */
.card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 22px 24px; margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-title .sub { font-weight: 400; color: var(--muted); font-size: 13px; }
.card-title .right { margin-left: auto; }
.page-head { margin-bottom: 22px; }
.page-title { margin: 0; font-size: 26px; line-height: 1.35; letter-spacing: -.01em; }
.page-sub { margin: 6px 0 0; color: var(--text-2); font-size: 15px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { opacity: .5; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 12px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head span { color: var(--muted); font-size: 13px; }
.bar { height: 6px; background: #eef0f3; border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.bar.ok > i { background: var(--ok); }

.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.stat-card b { display: block; font-size: 24px; line-height: 1.3; }
.stat-card span { font-size: 13px; color: var(--muted); }
.stats-inline { display: flex; gap: 22px; flex-wrap: wrap; }
.stats-inline div b { font-size: 20px; display: block; line-height: 1.3; }
.stats-inline div span { font-size: 12px; color: var(--muted); }

.notice {
    display: flex; gap: 10px; align-items: flex-start;
    background: #f8f9fb; border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 14px; font-size: 13px; color: var(--text-2); margin: 16px 0 0;
}
.notice summary { cursor: pointer; color: var(--text-2); }
.notice summary::marker { color: var(--muted); }
.notice .rich { margin-top: 6px; }

.seg { display: inline-flex; background: #eef0f3; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 4px 12px; font-size: 13px; color: var(--text-2); border-radius: 7px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .label { color: var(--muted); font-size: 13px; white-space: nowrap; flex: 0 0 auto; }
.toolbar .spacer { flex: 1; }
.filter-group { display: inline-flex; align-items: center; gap: 8px; }
.filter-group + .filter-group { margin-left: 8px; padding-left: 18px; border-left: 1px solid var(--line); }

/* ---------- 首页 ---------- */
.hero { padding: 18px 0 8px; }
.hero h1 { margin: 0; font-size: 30px; letter-spacing: -.01em; }
.hero p { margin: 8px 0 0; color: var(--text-2); max-width: 680px; }
.group-label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 30px 0 12px; letter-spacing: .04em; }
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 18px; }
.subject-card {
    display: flex; flex-direction: column; gap: 14px; color: var(--text); margin: 0;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.subject-card:hover { border-color: #bac8ff; box-shadow: 0 6px 20px rgba(66, 99, 235, .08); transform: translateY(-1px); }
.subject-card .sc-head { display: flex; align-items: center; gap: 12px; }
.subject-card .sc-icon {
    width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
    font-size: 20px; font-weight: 800; color: #fff; background: linear-gradient(135deg, #4c6ef5, #364fc7);
}
.subject-card.planned .sc-icon { background: linear-gradient(135deg, #adb5bd, #868e96); }
.subject-card h3 { margin: 0; font-size: 19px; }
.subject-card p { margin: 0; color: var(--text-2); font-size: 14px; }
.subject-card .sc-go { margin-left: auto; color: var(--primary); font-size: 14px; white-space: nowrap; flex: 0 0 auto; }
.subject-card.planned { cursor: default; }
.subject-card.planned:hover { transform: none; box-shadow: var(--shadow); border-color: var(--line); }
.chapter-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; font-size: 13px; color: var(--text-2); }
.chapter-mini div { display: grid; grid-template-columns: 8.5em minmax(0, 1fr) 2.5em; gap: 8px; align-items: center; }
.chapter-mini span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-mini span:last-child { text-align: right; color: var(--muted); }
.chapter-mini .bar { height: 5px; }
.sc-foot { display: flex; align-items: center; gap: 22px; border-top: 1px solid var(--line-2); padding-top: 14px; }

/* ---------- 总览 ---------- */
.overview-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.chapter-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.chapter-card .type-rows li a { grid-template-columns: minmax(0, 1fr) 160px 44px; }
.chapter-card { margin: 0; padding: 18px 20px 12px; }
.chapter-card .card-title { margin-bottom: 8px; }
.type-rows { list-style: none; margin: 0; padding: 0; }
.type-rows li a {
    display: grid; grid-template-columns: minmax(0, 1fr) 90px 44px; gap: 12px; align-items: center;
    padding: 7px 8px; margin: 0 -8px; border-radius: 8px; color: var(--text); font-size: 14.5px;
}
.type-rows li a:hover { background: #f5f7ff; }
.type-rows .t-name { display: flex; align-items: center; min-width: 0; overflow: hidden; white-space: nowrap; }
.type-rows .t-main { display: flex; align-items: center; min-width: 0; overflow: hidden; }
.type-rows .t-name .nm { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.type-rows .t-name .tag { margin-left: 6px; flex: 0 100 auto; min-width: 0; overflow: hidden; }
.type-rows .done .t-name::after { content: "✓"; color: var(--ok); margin-left: 6px; font-size: 13px; }
.type-rows .num { text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.rank-card .type-rows li a { grid-template-columns: 28px minmax(0, 1fr) 140px 44px; }
.rank-no { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 复习优先度 ---------- */
.prio {
    display: inline-grid; place-items: center; flex: 0 0 auto;
    width: 18px; height: 18px; border-radius: 5px; margin-right: 7px; vertical-align: -3px;
    font-size: 11px; font-weight: 700; line-height: 1;
}
.prio-S { background: #ffe3e3; color: #c92a2a; }
.prio-A { background: #ffe8cc; color: #d9480f; }
.prio-B { background: #e7f5ff; color: #1971c2; }
.prio-C { background: #f1f3f5; color: #868e96; }
.side-types .prio, .sibling-list .prio { margin-right: 0; margin-top: 2px; align-self: flex-start; }
.tag-diff-1 { background: var(--ok-soft); color: var(--ok); }
.tag-diff-2 { background: #fff4e6; color: #d9480f; }
.tag-diff-3 { background: #fff5f5; color: #c92a2a; }
.prio-note { margin: 0 0 16px; }
.prio-note .rich { margin: 0; }
.prio-card { margin-bottom: 14px; }
.prio-card .card-title .prio { width: 22px; height: 22px; font-size: 13px; margin-right: 0; }
.prio-box { display: flex; gap: 14px; align-items: flex-start; padding: 16px 20px; }
.prio-box .prio-lg { width: 40px; height: 40px; border-radius: 10px; font-size: 20px; margin: 0; }
.prio-body { min-width: 0; flex: 1; }
.prio-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 15px; }
.prio-title .prio-link { margin-left: auto; font-weight: 400; font-size: 13px; }
.prio-body p { margin: 6px 0 4px; color: var(--text); font-size: 14.5px; }
.prio-body small { color: var(--muted); font-size: 12.5px; }

/* ---------- 题型详情 ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) var(--aside-w); gap: 22px; align-items: start; }
.detail-aside { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 14px; }
.detail-aside .card { margin: 0; padding: 18px; }
.type-header { margin-bottom: 18px; }
.type-header .hint { color: var(--text-2); font-size: 15px; margin-top: 4px; }
.type-title-row { display: flex; align-items: flex-start; gap: 14px; }
.type-title-row .page-title { flex: 1; min-width: 0; }
.done-toggle {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
    height: 34px; padding: 0 14px; margin-top: 1px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--panel); box-shadow: var(--shadow);
    color: var(--text-2); font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
    transition: color .15s, background .15s, border-color .15s;
}
.done-toggle:hover { color: var(--ok); border-color: #b2f2bb; }
.done-toggle.is-done { color: var(--ok); background: var(--ok-soft); border-color: #b2f2bb; }
.done-toggle.is-done:hover { background: #d3f9d8; }
.done-toggle:disabled { cursor: progress; opacity: .75; }
.done-toggle .spinner { width: 12px; height: 12px; border-color: #d3f9d8; border-top-color: var(--ok); }
.occ-stats { display: none; margin: -4px 0 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.occ-stats .kind-bar { margin-top: 0; }
.points { font-size: 15.5px; color: var(--text); }

.example-card { padding: 0; overflow: hidden; }
.example-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 12px 22px; border-bottom: 1px solid var(--line-2); background: #fafbfc; font-size: 14px;
}
.example-bar .src { font-weight: 700; }
.example-bar .idx { color: var(--muted); font-size: 13px; margin-left: auto; }
.example-body { padding: 18px 22px 20px; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 14px 0 0; padding: 0; list-style: none; }
.options.long { grid-template-columns: 1fr; }
.options li { display: flex; gap: 8px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: #fcfcfd; }
.options li > b { color: var(--muted); font-weight: 600; flex: 0 0 auto; }
.options li.correct { border-color: #b2f2bb; background: var(--ok-soft); }
.options li.correct > b { color: var(--ok); }
.figure { margin: 14px 0 0; text-align: center; }
.figure img { max-width: min(100%, 360px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.figure figcaption { font-size: 12px; color: var(--muted); }
.reveal-bar { margin-top: 16px; }
.answer-box { display: none; border-top: 1px dashed var(--line); background: #fbfcfe; }
.answer-box.show { display: block; }
.answer-box > section { padding: 16px 22px; }
.answer-box > section + section { border-top: 1px solid var(--line-2); }
.answer-box h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.answer-final { color: var(--ok); font-weight: 600; }

.method .rich ul { padding-left: 0; list-style: none; counter-reset: m; }
.method .rich li { position: relative; padding: 8px 0 8px 34px; border-top: 1px dashed var(--line-2); margin: 0; }
.method .rich li:first-child { border-top: none; }
.method .rich li::before {
    counter-increment: m; content: counter(m);
    position: absolute; left: 0; top: 10px; width: 22px; height: 22px; border-radius: 6px;
    background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700;
    display: grid; place-items: center; line-height: 1;
}

.occ-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.occ-table td { padding: 8px 6px; border-top: 1px solid var(--line-2); vertical-align: top; }
.occ-table tr:first-child td { border-top: none; }
.occ-table td.y { white-space: nowrap; width: 1%; font-weight: 600; font-variant-numeric: tabular-nums; }
.occ-table td.n { white-space: nowrap; width: 1%; color: var(--muted); }
.occ-table td.k { width: 1%; }
.occ-table tr.is-example td.y { color: var(--primary); }
.occ-table.wide-src td.y { font-weight: 500; font-size: 13px; color: var(--text-2); }
.occ-table tr.flash td { background: #fff9db; transition: background 1s; }

.aside-stat { display: flex; justify-content: space-between; align-items: baseline; }
.aside-stat b { font-size: 28px; line-height: 1.2; }
.aside-stat span { color: var(--muted); font-size: 13px; }
.kind-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #eef0f3; margin: 12px 0 8px; }
.kind-bar i { display: block; height: 100%; }
.kind-legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.kind-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }
.heat-title { font-size: 12px; color: var(--muted); margin: 16px 0 6px; display: flex; justify-content: space-between; }
.heatmap { display: grid; grid-template-columns: 34px repeat(10, 1fr); gap: 3px; align-items: center; }
.heatmap em { font-style: normal; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.heatmap span {
    aspect-ratio: 1; border-radius: 3px; background: #eef0f3; cursor: default;
}
.heatmap span.none { background: transparent; }
.heatmap span.on { cursor: pointer; }
.heatmap span.k-choice { background: var(--choice); }
.heatmap span.k-blank { background: var(--blank); }
.heatmap span.k-solve { background: var(--solve); }
.heatmap span.multi { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .25); }
.sibling-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.sibling-list a { display: flex; gap: 8px; padding: 5px 8px; margin: 0 -8px; border-radius: 7px; color: var(--text-2); }
.sibling-list a:hover { background: #f3f4f6; color: var(--text); }
.sibling-list a.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.sibling-list .num { margin-left: auto; color: var(--muted); font-size: 12px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.pager a { padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); font-size: 14px; }
.pager a:hover { border-color: #bac8ff; }
.pager a small { display: block; color: var(--muted); font-size: 12px; }
.pager a.next { text-align: right; grid-column: 2; }

/* ---------- 富文本 ---------- */
.rich p { margin: 0 0 10px; }
.rich p:last-child { margin-bottom: 0; }
.rich ul, .rich ol { margin: 4px 0 10px; padding-left: 22px; }
.rich li { margin: 3px 0; }
.rich strong { color: #111827; }
.rich .katex { font-size: 1.06em; }
.rich .katex-display { margin: 8px 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.math-error { color: #c92a2a; font-family: monospace; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- 按年份 ---------- */
.year-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.year-picker { position: sticky; top: calc(var(--topbar-h) + 20px); margin: 0; padding: 16px; }
.decade { margin-bottom: 12px; }
.decade:last-child { margin-bottom: 0; }
.decade-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.decade-years { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.decade-years a { text-align: center; font-size: 13px; padding: 4px 0; border-radius: 6px; color: var(--text-2); background: #f5f6f8; font-variant-numeric: tabular-nums; }
.decade-years a:hover { background: #e9ecef; }
.decade-years a.active { background: var(--primary); color: #fff; font-weight: 600; }
.paper-layout { grid-template-columns: 280px minmax(0, 1fr); }
.paper-year { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 8px 0 3px; }
.paper-links { display: flex; flex-direction: column; gap: 2px; }
.paper-links a { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 4px 8px; border-radius: 6px; color: var(--text-2); }
.paper-links a small { color: var(--muted); font-variant-numeric: tabular-nums; }
.paper-links a:hover { background: #f1f3f5; }
.paper-links a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.src-list { list-style: none; margin: 0; padding: 0; }
.src-list li { display: flex; justify-content: space-between; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.src-list li:hover { background: #f5f6f8; }
.src-list li small { display: block; color: var(--muted); font-size: 11px; }
.src-list li b { font-size: 16px; font-variant-numeric: tabular-nums; }
.paper-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.paper-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 0 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.paper-table td { padding: 10px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.paper-table td.no { white-space: nowrap; font-weight: 600; width: 1%; }
.paper-table td.kind { width: 1%; }
.paper-table .tname { font-weight: 600; color: var(--text); }
.paper-table .tname:hover { color: var(--primary); }
.paper-table .sum { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.paper-table td.ch { white-space: nowrap; color: var(--muted); font-size: 13px; width: 1%; }

/* ---------- 搜索 ---------- */
.result { display: block; padding: 14px 4px; border-top: 1px solid var(--line-2); color: var(--text); }
.result:first-child { border-top: none; }
.result:hover .result-title b { color: var(--primary); }
.result-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.result-title b { font-size: 15.5px; }
.result-snippet { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }
mark { background: #fff3bf; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ---------- 登录页 ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, #e0e7ff, transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 40px rgba(66, 99, 235, .08); padding: 32px 30px; }
.login-title { font-size: 20px; margin: 0 0 24px; }
.login-card label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 16px; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; color: var(--text); background: #fbfbfc; }
.login-card input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.login-error { color: #c92a2a; font-size: 13px; margin: -6px 0 14px; }

/* ---------- AI 练习 ---------- */
.ai-panel { padding: 16px 20px; }
.ai-opts { gap: 10px 0; }
.ai-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.ai-actions .btn-primary { padding: 9px 18px; font-size: 14.5px; }
.ai-actions .btn-primary:disabled { opacity: .55; cursor: wait; }
.ai-progress { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13.5px; }
.ai-err { color: #c92a2a; }
.ai-tip { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }
.ai-off { color: var(--muted); font-size: 14px; }
.spinner {
    width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto;
    border: 2px solid #dbe4ff; border-top-color: var(--primary); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ai-list { margin-top: 18px; }
.ai-list-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ai-list-head:empty { display: none; }
.ai-list-head .title { font-weight: 700; font-size: 15px; }
.ai-list-head .seg { margin-left: auto; }
.ai-list-head .seg small { margin-left: 4px; color: var(--muted); font-weight: 400; }
.ai-card { scroll-margin-top: calc(var(--topbar-h) + 14px); transition: box-shadow .3s; }
.ai-card.st-right { border-left: 3px solid var(--ok); }
.ai-card.st-wrong { border-left: 3px solid #e03131; }
.ai-more { text-align: center; }
.ai-more:empty { display: none; }
.ai-card.flash { box-shadow: 0 0 0 3px #ffe066; }
.ai-card .example-bar a.src { color: var(--text); }
.ai-card .example-bar a.src:hover { color: var(--primary); }
.ai-foot { display: flex; align-items: center; gap: 8px; padding: 10px 22px; border-top: 1px solid var(--line-2); background: #fafbfc; }
.ai-mark, .ai-del {
    border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 3px 12px;
    font-size: 13px; color: var(--text-2); transition: color .15s, border-color .15s, background .15s;
}
.ai-mark[data-mark="right"]:hover, .ai-mark[data-mark="right"].on { color: var(--ok); border-color: #b2f2bb; background: var(--ok-soft); }
.ai-mark[data-mark="wrong"]:hover, .ai-mark[data-mark="wrong"].on { color: #c92a2a; border-color: #ffc9c9; background: #fff5f5; }
.ai-mark.on { font-weight: 600; }
.ai-del { margin-left: auto; border-color: transparent; background: transparent; color: var(--muted); }
.ai-del:hover { color: #c92a2a; background: #fff5f5; }
.toast {
    position: fixed; left: 50%; bottom: 28px; z-index: 110; transform: translateX(-50%);
    max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
    background: rgba(33, 37, 41, .92); color: #fff; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    animation: modal-fade .15s ease-out; transition: opacity .3s;
}
.toast.hide { opacity: 0; }

/* ---------- 响应式 ---------- */
/* 题型页三栏放不下时，先把左侧目录收进抽屉，保留右侧统计栏 */
@media (max-width: 1280px) {
    body.has-aside #menuBtn { display: inline-block; }
    body.has-aside .sidebar {
        position: fixed; left: 0; top: var(--topbar-h); z-index: 25;
        transform: translateX(-100%); transition: transform .2s;
        box-shadow: 4px 0 24px rgba(0, 0, 0, .1);
    }
    body.has-aside.sidebar-open .sidebar { transform: none; }
    body.has-aside.sidebar-open .sidebar-mask { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0, 0, 0, .25); z-index: 20; }
}
@media (max-width: 1100px) {
    :root { --aside-w: 264px; }
    .chapter-grid, .subject-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .only-mobile { display: inline-block; }
    body.no-sidebar .only-mobile { display: none; }
    :root { --topbar-h: 56px; }
    body.search-open { --topbar-h: 104px; }
    .topbar { align-items: flex-start; gap: 8px; padding: 10px 12px 0; overflow: hidden; transition: height .22s ease; }
    .topbar-right { display: contents; }
    #menuBtn { height: 36px; line-height: 1; }
    .subject-tabs { flex: 1; min-width: 0; height: 36px; overflow-x: auto; scrollbar-width: none; }
    .subject-tab { flex: 1; justify-content: center; padding: 0 10px; }
    .search-toggle { display: grid; flex: 0 0 auto; }
    .logout-btn { height: 36px; }
    .search {
        position: absolute; left: 12px; right: 12px; top: 56px;
        opacity: 0; visibility: hidden; transform: translateY(-8px);
        transition: opacity .18s ease, transform .22s ease, visibility 0s .22s;
    }
    body.search-open .search { opacity: 1; visibility: visible; transform: none; transition: opacity .18s ease .04s, transform .22s ease; }
    .search input, .search input:focus { width: 100%; height: 38px; font-size: 16px; }
    .sidebar {
        position: fixed; left: 0; top: var(--topbar-h); z-index: 25;
        transform: translateX(-100%); transition: transform .2s;
        box-shadow: 4px 0 24px rgba(0, 0, 0, .1);
    }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-mask { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0, 0, 0, .25); z-index: 20; }
    .content { padding: 18px 14px 60px; }
    .card { padding: 16px; }
    .card.example-card { padding: 0; }
    .example-bar, .example-body, .answer-box > section, .ai-foot { padding-left: 16px; padding-right: 16px; }
    .ai-panel { padding: 14px 16px; }
    .ai-opts .filter-group { width: 100%; }
    .ai-list-head .seg { margin-left: 0; }
    .options { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .year-layout { grid-template-columns: minmax(0, 1fr); }
    .paper-table th { white-space: normal; }
    .year-picker { position: static; }
    .paper-layout .year-picker { max-height: 240px; overflow-y: auto; }
    .paper-table td.ch { display: none; }
    .filter-group + .filter-group { margin-left: 0; padding-left: 0; border-left: none; }
    .filter-group { max-width: 100%; }
    .toolbar .seg { flex-wrap: wrap; }
    .seg button { padding: 4px 10px; }
    .paper-table td:nth-child(3) { width: 100%; max-width: 0; }
    .paper-table .sum { overflow-x: auto; overflow-y: hidden; }
    .occ-table.wide-src, .occ-table.wide-src tbody, .occ-table.wide-src tr { display: block; }
    .occ-table.wide-src tr { padding: 9px 0; border-top: 1px solid var(--line-2); }
    .occ-table.wide-src tr:first-child { border-top: none; }
    .occ-table.wide-src td { display: inline; border: none; padding: 0 6px 0 0; }
    .occ-table.wide-src td:last-child { display: block; padding: 3px 0 0; overflow-x: auto; overflow-y: hidden; }
    .chapter-mini { grid-template-columns: 1fr; }
    .page-title { font-size: 22px; }
    .detail { grid-template-columns: minmax(0, 1fr); }
    .detail-aside { display: none; }
    .occ-stats { display: block; }
    .type-title-row { gap: 10px; }
    .done-toggle { height: 32px; padding: 0 12px; margin-top: 0; font-size: 13px; }
    .type-rows li a, .chapter-card .type-rows li a { grid-template-columns: minmax(0, 1fr) 60px 40px; }
    .rank-card .type-rows li a { grid-template-columns: 24px minmax(0, 1fr) 60px 40px; }
    .prio-card .type-rows .t-name { white-space: normal; align-items: flex-start; line-height: 22px; }
    .prio-card .type-rows .t-name .prio { margin-top: 2px; }
    .prio-card .type-rows .t-main { flex-wrap: wrap; row-gap: 3px; }
    .prio-card .type-rows .t-name .tag { flex: 0 0 auto; line-height: 1.6; }
    .prio-card .card-title { flex-wrap: wrap; }
    .prio-card .card-title .sub { flex-basis: 100%; }
    .prio-box { padding: 14px; gap: 12px; }
    .prio-box .prio-lg { width: 34px; height: 34px; font-size: 17px; }
    .prio-title .prio-link { margin-left: 0; }
}

@media print {
    .topbar, .sidebar, .reveal-bar, .pager, .detail-aside { display: none !important; }
    .detail { display: block; }
    .answer-box { display: block !important; }
    .content { padding: 0; }
    .card { box-shadow: none; break-inside: avoid; }
}
