:root {
  color-scheme: light;
  --canvas: #f4f6f9;
  --surface: #fff;
  --soft: #f7f9fc;
  --line: #e2e8f0;
  --ink: #192b42;
  --muted: #51657d;
  --faint: #687a8e;
  --navy: #14253b;
  --navy-line: #314058;
  --accent: #245bb2;
  --accent-soft: #eaf2ff;
  --mint: #80e1cb;
  --green: #086c51;
  --green-soft: #e9f8f1;
  --red: #a62e40;
  --red-soft: #fff0f2;
  --gold: #946000;
  --gold-soft: #fff5d9;
  --shadow: 0 6px 22px #1b365408;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0e1725; --surface: #152235; --soft: #192a40; --line: #2d4058;
  --ink: #eef3fa; --muted: #b5c3d4; --faint: #a1b1c6;
  --navy: #111f32; --navy-line: #354862;
  --accent: #92baff; --accent-soft: #263c60;
  --green: #8ee7bb; --green-soft: #193d37; --red: #ffb4bd; --red-soft: #472834;
  --gold: #ffce7a; --gold-soft: #443523; --shadow: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 15px; line-height: 1.65; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible { outline: 3px solid #639af0; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(29px, 4vw, 42px); line-height: 1.23; letter-spacing: -.04em; }
h2 { font-size: 20px; line-height: 1.4; }
h3 { font-size: 16px; }
svg { flex: none; vertical-align: middle; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { background: var(--navy); color: #e4edf8; height: 100dvh; position: sticky; top: 0; padding: 31px 19px 20px; display: flex; flex-direction: column; gap: 33px; z-index: 5; }
.brand { display: flex; gap: 11px; align-items: center; border: 0; background: none; color: #fff; text-align: left; padding: 0 3px; width: 100%; }
.brand-logo { width: 40px; height: 40px; border-radius: 11px; background: #c0f6e9; color: #15394b; display: grid; place-items: center; flex: none; }
.brand strong, .brand small { display: block; line-height: 1.4; }
.brand strong { font-size: 16px; letter-spacing: .06em; white-space: nowrap; }
.brand small { font-size: 11px; color: #aebdd0; margin-top: 3px; white-space: nowrap; }
.nav { display: grid; gap: 6px; }
.nav-label { padding-left: 13px; color: #9aacc3; font-size: 11px; letter-spacing: .13em; margin-bottom: 5px; }
.nav button, .sidebar-footer button { display: flex; align-items: center; gap: 12px; border: 0; border-radius: 9px; background: none; color: #c1cee0; padding: 11px 13px; text-align: left; white-space: nowrap; }
.nav button:hover, .sidebar-footer button:hover { background: #24364f; color: #fff; }
.nav button.active { color: #fff; background: #2a405f; box-shadow: inset 3px 0 #86e3cf; }
.nav-count { margin-left: auto; color: #bcefe3; font-size: 11px; background: #3d5675; border-radius: 9px; padding: 0 6px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--navy-line); padding-top: 13px; }
.sidebar-footer button { width: 100%; font-size: 13px; padding: 7px 8px; }
.workspace { min-width: 0; }
.topbar { height: 76px; border-bottom: 1px solid var(--line); background: var(--surface); padding: 0 clamp(20px, 4.1vw, 58px); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.crumb { display: flex; gap: 10px; align-items: center; color: var(--faint); font-size: 13px; }
.crumb strong { color: var(--ink); font-weight: 650; }
.theme { display: flex; background: var(--soft); padding: 3px; border: 1px solid var(--line); border-radius: 24px; }
.theme button { border: 0; background: transparent; color: var(--muted); border-radius: 20px; width: 33px; height: 29px; display: grid; place-items: center; }
.theme button.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px #11284922; }
.mobile-title { display: none; }
.main { max-width: 1360px; margin: auto; padding: 31px clamp(20px, 4.1vw, 58px) 44px; }
.page-head { margin-bottom: 25px; display: flex; justify-content: space-between; align-items: end; gap: 15px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 8px; }
.hero { position: relative; isolation: isolate; overflow: hidden; min-height: 244px; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 34px 39px; color: #f3f8ff; background: radial-gradient(ellipse at 80% 30%, #2a517c, transparent 70%), #152944; border-radius: 18px; }
.hero::before { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(90deg, #152944 0%, transparent 75%), repeating-linear-gradient(90deg, #a4c5ed16 0 1px, transparent 1px 42px), repeating-linear-gradient(0deg, #a4c5ed16 0 1px, transparent 1px 42px); }
.hero h1 { margin-top: 8px; }
.hero p { color: #ccdbed; margin-top: 10px; }
.hero .button { margin-top: 22px; min-width: 125px; }
.hero .primary { background: #c1f5e6; color: #133b42; border-color: #c1f5e6; }
.hero .secondary { background: #244467; color: #f3f8ff; border-color: #567594; }
.hero-label { color: #99e5d4; font-size: 12px; letter-spacing: .10em; }
.ring { width: 154px; height: 154px; display: grid; place-items: center; flex: none; border-radius: 50%; position: relative; margin-right: 14px; }
.ring svg { width: 100%; height: 100%; position: absolute; inset: 0; transform: rotate(-90deg); }
.ring div { text-align: center; }
.ring strong { display: block; font: 650 35px/1.15 ui-monospace, monospace; }
.ring small { color: #c9d9ee; font-size: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 17px 0 20px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 14px 16px; box-shadow: var(--shadow); }
.metric-title { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.metric-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.metric-icon.green { background: var(--green-soft); color: var(--green); }
.metric-icon.red { background: var(--red-soft); color: var(--red); }
.metric-icon.gold { background: var(--gold-soft); color: var(--gold); }
.metric strong { display: block; font: 650 clamp(22px, 3vw, 31px)/1.18 ui-monospace, monospace; margin-top: 8px; white-space: nowrap; }
.metric small { color: var(--faint); font-size: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 23px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 15px; }
.topic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.topic-card { text-align: left; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; }
.topic-card:hover { border-color: var(--accent); }
.topic-card strong, .detail-row strong { font-size: 14px; font-weight: 650; }
.topic-card .row { justify-content: space-between; }
.topic-card small, .detail-row small { display: block; font-size: 12px; color: var(--faint); }
.track { height: 5px; background: var(--line); border-radius: 5px; overflow: hidden; margin: 8px 0 6px; }
.track span { display: block; background: var(--accent); height: 100%; border-radius: inherit; }
.button { display: inline-flex; gap: 7px; align-items: center; justify-content: center; min-height: 41px; padding: 7px 14px; border: 1px solid transparent; border-radius: 8px; font-size: 14px; font-weight: 650; text-align: center; text-decoration: none; }
.button:hover:not(:disabled), .chip:hover:not(:disabled) { filter: brightness(.94); }
.button.primary { background: #245bb2; border-color: #245bb2; color: #fff; }
.button.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.button.quiet { background: transparent; color: var(--accent); padding: 3px 4px; }
.button.danger { background: #a62e40; color: #fff; }
.button.icon-only { width: 38px; min-height: 38px; padding: 0; }
.button.active { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface); border: 1px solid var(--line); padding: 6px 12px; min-height: 38px; border-radius: 8px; font-size: 14px; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 650; }
.chip small { color: var(--faint); margin-left: 6px; font-size: 11px; }
.filter-row + .filter-row { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.filter-row h2 { font-size: 14px; margin-bottom: 8px; }
.filter-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 13px; margin-top: 20px; }
.filter-footer strong { color: var(--accent); }
.exam-setup { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.exam-setup > .panel { margin: 0; }
.exam-big { color: var(--accent); font: 700 48px/1.2 ui-monospace, monospace; }
.exam-big span { font: 650 15px system-ui, sans-serif; }
.info-list { list-style: none; padding: 0; margin: 13px 0 0; color: var(--muted); }
.info-list li { display: flex; align-items: start; gap: 10px; padding: 9px 0; }
.info-list li + li { border-top: 1px solid var(--line); }
.info-list svg { margin-top: 4px; color: var(--accent); }
.notice { border: 1px solid var(--line); background: var(--soft); padding: 12px 14px; border-radius: 10px; margin: 0 0 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.session-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.session-head .row { gap: 13px; }
.session-head h1 { font-size: 24px; }
.timebar { position: sticky; top: 5px; z-index: 3; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; display: flex; justify-content: space-between; align-items: center; gap: 9px; margin-bottom: 14px; box-shadow: var(--shadow); }
.timer-pair { display: flex; gap: clamp(12px, 3vw, 28px); }
.timer-pair > div { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 7px; }
.timer-pair strong { font: 650 clamp(17px, 2.2vw, 25px)/1.1 ui-monospace, monospace; color: var(--ink); }
.timer-pair strong.urgent { color: var(--red); }
.timer-pair small { color: var(--muted); white-space: nowrap; }
.session-layout { display: grid; grid-template-columns: minmax(0, 1fr) 246px; gap: 15px; align-items: start; }
.answer-sheet { position: sticky; top: 70px; }
.answer-sheet summary { display: flex; align-items: center; justify-content: space-between; gap: 7px; font-weight: 700; cursor: pointer; }
.answer-sheet summary::-webkit-details-marker { display: none; }
.answer-sheet summary small { color: var(--muted); font-weight: 500; font-size: 11px; }
.sheet-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; max-height: min(41vh, 350px); overflow: auto; padding: 3px; margin: 11px -3px 8px; }
.sheet-grid button { position: relative; min-width: 0; min-height: 32px; padding: 0; border-radius: 6px; border: 1px solid var(--line); background: var(--soft); font: 600 12px ui-monospace, monospace; }
.sheet-grid button.answered { background: var(--accent-soft); color: var(--accent); }
.sheet-grid button.right { background: var(--green-soft); color: var(--green); }
.sheet-grid button.wrong { background: var(--red-soft); color: var(--red); }
.sheet-grid button.current { border: 2px solid var(--accent); }
.sheet-grid button.marked::after { content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; top: 3px; right: 3px; background: var(--gold); }
.legend { display: flex; gap: 8px; color: var(--faint); font-size: 11px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 4px; background: var(--line); border-radius: 50%; }
.legend .answered::before { background: var(--accent); }
.legend .right::before { background: var(--green); }
.legend .wrong::before { background: var(--red); }
.legend .marked::before { background: var(--gold); }
.question-panel { min-width: 0; }
.question-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.question-no { color: var(--muted); font: 600 13px/1.5 ui-monospace, monospace; }
.question-stem { font-size: clamp(16px, 2.1vw, 21px); line-height: 1.65; font-weight: 650; margin: 13px 0 16px; overflow-wrap: anywhere; }
.tags { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-block; background: var(--soft); color: var(--muted); padding: 2px 7px; font-size: 12px; line-height: 1.6; border-radius: 5px; }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.options { display: grid; gap: 9px; }
.option { width: 100%; min-height: 49px; text-align: left; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: var(--surface); color: var(--ink); display: flex; gap: 10px; align-items: center; overflow-wrap: anywhere; }
button.option:hover:not(:disabled) { border-color: var(--accent); background: var(--soft); }
.option:disabled { opacity: 1; }
.option span:first-child { display: grid; place-items: center; width: 26px; height: 26px; flex: none; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; font: 650 13px ui-monospace, monospace; }
.option.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.option.correct { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.option.incorrect { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.session-actions { display: flex; justify-content: space-between; gap: 7px; margin-top: 19px; }
.answer-note { border-radius: 9px; padding: 13px; background: var(--soft); margin-top: 14px; overflow-wrap: anywhere; }
.answer-note h3 { margin-bottom: 3px; }
.answer-note p { margin-top: 2px; color: var(--muted); }
.answer-note .note-ref { font-size: 13px; }
.answer-note .source { font-size: 11px; color: var(--faint); margin-top: 6px; }
.right-text { color: var(--green); }
.wrong-text { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; padding: 49px 18px; }
.empty .metric-icon { margin: 0 auto 12px; width: 43px; height: 43px; }
.empty p { margin: 7px 0 16px; color: var(--muted); }
.review-list { display: grid; gap: 13px; }
.review-list > .panel { margin: 0; }
.review-card h3.question-stem { font-size: 16px; margin: 5px 0 12px; }
.review-card .option { min-height: 38px; padding: 5px 8px; font-size: 13px; }
.review-card .option span:first-child { height: 23px; width: 23px; }
.review-card .row { margin-top: 10px; }
.result-top { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; margin-bottom: 18px; }
.score { display: grid; place-items: center; text-align: center; min-width: 99px; min-height: 99px; padding: 9px; border: 5px solid var(--line); border-radius: 50%; }
.score strong { display: block; font: 650 30px ui-monospace, monospace; }
.score small { color: var(--muted); }
.result-counts { margin: 9px 0 3px; gap: 12px; }
.stats-layout { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 14px; align-items: start; }
.stats-layout > .panel { margin: 0; }
.radar { width: min(100%, 395px); display: block; margin: auto; }
.radar text { fill: var(--muted); font-size: 11px; }
.radar .radar-grid { fill: none; stroke: var(--line); }
.radar .radar-value { fill: var(--accent); fill-opacity: .22; stroke: var(--accent); stroke-width: 2; }
.detail-row + .detail-row { border-top: 1px solid var(--line); margin-top: 11px; padding-top: 11px; }
.detail-row .row { justify-content: space-between; }
.stats-reset { margin-top: 16px; }
dialog { max-width: min(420px, calc(100vw - 28px)); width: 100%; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
dialog::backdrop { background: #101c2bb0; }
dialog p { color: var(--muted); margin: 9px 0 17px; }
.confirm-actions { justify-content: flex-end; }
.status { display: none; position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 9px 15px; border-radius: 8px; background: #18324a; color: #fff; z-index: 10; white-space: nowrap; }
.status.visible { display: block; }
@media (max-width: 1050px) {
  .shell { grid-template-columns: 178px minmax(0, 1fr); }
  .sidebar { padding-left: 13px; padding-right: 13px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 14px; }
  .session-layout { grid-template-columns: minmax(0, 1fr) 190px; }
  .session-layout .panel { padding: 16px; }
}
@media (max-width: 760px) {
  .shell { display: flex; flex-direction: column; }
  .sidebar { position: static; height: auto; padding: 0; display: contents; }
  .sidebar > .brand, .sidebar-footer, .nav-label, .crumb { display: none; }
  .topbar { height: 56px; padding: 0 14px; }
  .mobile-title { display: flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 700; }
  .mobile-title .brand-logo { width: 29px; height: 29px; border-radius: 7px; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; padding: 5px 3px calc(5px + env(safe-area-inset-bottom)); background: var(--navy); }
  .nav button { position: relative; flex-direction: column; justify-content: center; gap: 3px; padding: 7px 1px; font-size: 11px; line-height: 1.25; }
  .nav button.active { box-shadow: inset 0 2px #86e3cf; }
  .nav-count { position: absolute; margin: 0; top: 2px; right: 3px; padding: 0 3px; font-size: 9px; }
  .main { padding: 16px 12px calc(77px + env(safe-area-inset-bottom)); }
  .hero { padding: 22px 16px; gap: 6px; min-height: 206px; }
  .hero h1 { font-size: clamp(22px, 5.5vw, 33px); }
  .hero p { font-size: 12px; max-width: 250px; }
  .hero .button { min-width: 0; margin-top: 15px; padding: 6px 8px; min-height: 36px; font-size: 13px; }
  .ring { width: min(25vw, 110px); height: min(25vw, 110px); margin: 0; }
  .ring strong { font-size: 24px; }
  .ring small { font-size: 10px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 10px 0; }
  .metric { padding: 10px 11px; }
  .metric strong { margin-top: 5px; }
  .panel { padding: 15px; }
  .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .topic-card { padding: 9px 8px; }
  .topic-card strong { font-size: 12px; }
  .exam-setup, .stats-layout { grid-template-columns: minmax(0, 1fr); }
  .session-layout { grid-template-columns: minmax(0, 1fr); }
  .answer-sheet { position: static; order: -1; }
  .sheet-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; max-height: 132px; }
  .session-layout .answer-sheet { padding: 10px 13px; }
  .timebar { top: 0; }
  .timer-pair > div { grid-template-columns: 1fr; gap: 4px; }
  .result-top { gap: 11px; grid-template-columns: auto 1fr; }
  .result-top > button { grid-column: 1 / -1; }
  .status { bottom: 68px; }
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions > .button { min-height: 35px; padding: 4px 9px; font-size: 13px; }
.sync-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sync-heading .button { min-height: 34px; padding: 4px 9px; }
#device-sync [hidden] { display: none !important; }
#device-sync .sync-state { background: var(--soft); border-radius: 8px; padding: 8px 10px; color: var(--accent); }
#device-sync label { display: block; font-weight: 650; margin-bottom: 5px; }
#device-sync input { width: 100%; color: var(--ink); background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: inherit; }
.sync-join { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.sync-join .button { margin-top: 8px; }
@media (max-width: 380px) {
  .topbar-actions { gap: 5px; }
  .topbar-actions > .button { padding: 4px 6px; }
  .mobile-title { font-size: 14px; }
}
