/* Reading first: restrained navigation, open lists, a steady prose measure. */
:root {
  --ink: #283137;
  --muted: #626d74;
  --blue: #345e75;
  --navy: #2d4959;
  --line: #e1e5e7;
  --surface: #f5f7f8;
  --bg: #fcfdfd;
  --green: #28634e;
  --red: #a53c3c;
  --radius: 12px;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  scrollbar-color: #bac3c9 #f4f6f7;
  scrollbar-width: thin;
}
* { box-sizing: border-box; }
body { margin: 0; }
::selection { background: #dce8ef; color: #203d4d; }
button, input, select, textarea { font: inherit; }
input, textarea { caret-color: var(--blue); }
input::placeholder, textarea::placeholder { color: #68757c; opacity: 1; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { color: #6c767d; background: #eceff1; border-color: #e1e5e7; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid #376f92; outline-offset: 4px; }
a { color: var(--blue); text-decoration: none; text-underline-offset: .22em; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { text-wrap: balance; font-weight: 600; }
h1 { font-size: 1.6rem; line-height: 1.45; margin-bottom: 10px; }
h2 { font-size: 1.15rem; line-height: 1.55; }
h3 { font-size: 1rem; line-height: 1.6; }
small, .tiny { font-size: .875rem; }
.muted, .reading-meta { color: var(--muted); }
.reading-meta { font-size: .875rem; }

/* Stable navigation; the reading surface stays visually quiet. */
.sidebar { width: 218px; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 32px 20px 24px; background: #f3f5f6; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.125rem; font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-size: .8rem; font-weight: 400; color: var(--muted); margin-top: 3px; }
.brand-mark { display: block; width: 25px; height: 31px; color: var(--blue); }
.brand-mark svg { width: 100%; height: 100%; }
.side-label { margin: 42px 12px 12px; color: var(--muted); font-size: .875rem; }
nav a { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 10px 12px; margin-bottom: 4px; color: #59646c; font-size: .9375rem; border-radius: 5px; }
nav a:hover { background: #e9eef1; text-decoration: none; }
nav a.active { color: #244d64; background: #e3eaee; font-weight: 600; }
nav svg { width: 19px; height: 19px; flex-shrink: 0; }
.side-note { margin-top: auto; padding: 20px 10px 0; border-top: 1px solid #dce2e5; }
.side-note strong { font-size: .9375rem; font-weight: 500; }
.side-note p { color: var(--muted); font-size: .8125rem; margin: 8px 0 12px; line-height: 1.8; }
.side-note span { font-size: .75rem; color: var(--muted); }
.workspace { margin-left: 218px; }
.topbar { height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 0 44px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.text-button { min-height: 44px; border: 0; background: transparent; color: var(--blue); padding: 8px 0; font-size: .875rem; }
.text-button:hover { text-decoration: underline; text-underline-offset: .2em; }
main:focus { outline: none; }
main { max-width: 1260px; padding: 40px 44px 48px; margin: auto; min-height: calc(100vh - 145px); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-head p { max-width: 70ch; color: var(--muted); font-size: .9375rem; margin-bottom: 0; }
.year-label { color: var(--muted); font-size: .875rem; padding-top: 7px; white-space: nowrap; }
footer { color: var(--muted); font-size: .8125rem; text-align: center; padding: 20px 24px 30px; }
.mobile-nav { display: none; }

/* Home is a reading index, not a dashboard of statistic cards. */
.reading-start { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 10px 0 34px; border-bottom: 1px solid var(--line); }
.reading-start > div { max-width: 70ch; }
.reading-start h2 { font-size: 1.375rem; margin-bottom: 12px; }
.reading-start p { color: #505e67; margin-bottom: 12px; font-size: .9375rem; line-height: 1.85; }
.reading-start .button { flex-shrink: 0; }
.home-content { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(230px, 1fr); gap: 44px; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 34px 0 12px; }
.section-head h2 { margin: 0; }
.section-head a, .subtle-link { font-size: .875rem; }
.subject-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 19px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.subject-card:hover { text-decoration: none; }
.subject-card:hover h3 { color: var(--blue); text-decoration: underline; text-underline-offset: .22em; }
.subject-card h3 { margin: 0 0 4px; }
.subject-card p { color: var(--muted); font-size: .875rem; margin: 0; }
.study-progress { color: #435765; text-align: right; font-size: .875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.study-progress small { display: block; font-size: .75rem; color: var(--muted); }
.review-sidebar { padding-left: 28px; border-left: 1px solid var(--line); margin-top: 34px; }
.review-sidebar .section-head { margin-top: 0; }
.review-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 16px 0; }
.review-row h3 { margin: 0 0 3px; }
.review-row p { margin: 0; color: var(--muted); font-size: .875rem; }
.review-row a { flex-shrink: 0; font-size: .875rem; padding: 10px 0 10px 8px; }
.progress-summary { color: var(--muted); border-top: 1px solid var(--line); margin-top: 16px; padding-top: 20px; font-size: .875rem; }
.progress-summary a { display: inline-block; margin-top: 5px; }
.topic-row { display: flex; justify-content: space-between; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.topic-row:last-child { border-bottom: 0; }
.topic-row h3 { margin-bottom: 6px; }
.topic-row h3 a { color: var(--ink); }
.topic-row p { color: var(--muted); margin-bottom: 8px; font-size: .875rem; }
.row-link { flex-shrink: 0; align-self: center; font-size: .875rem; padding: 10px 0; }
.home-scope { margin-top: 36px; color: var(--muted); font-size: .875rem; }
.home-scope summary { font-weight: 400; }
.home-scope p { max-width: 72ch; }

/* Controls retain visible boundaries; static text doesn't need a box. */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 17px; border: 1px solid transparent; border-radius: 5px; background: var(--blue); color: #fff; font-size: .875rem; font-weight: 500; text-align: center; text-decoration: none; }
.button:hover { background: #294e64; text-decoration: none; }
.button:active { background: #1f4053; }
.button.secondary { background: transparent; color: var(--blue); border-color: #c8d3da; }
.button.secondary:hover { background: #edf2f5; }
.button.danger { background: #fff1f0; color: var(--red); border-color: #e7c6c4; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.badge, .tag { display: inline-flex; align-items: center; font-size: .8125rem; line-height: 1.7; padding: 2px 0; color: #647078; }
.button-row > .tag + .tag::before { content: '·'; padding: 0 9px 0 0; color: #8b959c; }
.tag.blue { color: #345e75; }
.tag.green { color: #28634e; }
.tag.amber { color: #825b18; }
.tag.red { color: var(--red); }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search input { width: 100%; min-height: 48px; padding: 10px 14px 10px 42px; border: 1px solid #bdc8cf; border-radius: 5px; color: var(--ink); background: #fff; }
.search svg { position: absolute; left: 14px; top: 16px; width: 18px; height: 18px; color: var(--muted); }
select { max-width: 100%; min-height: 48px; padding: 10px 34px 10px 12px; border: 1px solid #bdc8cf; border-radius: 5px; background: #fff; color: var(--ink); font-size: .9375rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 4px 0 22px; border-bottom: 1px solid var(--line); }
.chip { min-height: 44px; padding: 8px 0 11px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: .9375rem; }
.chip:hover { color: var(--blue); }
.chip.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
label.field-label { display: block; font-size: .9375rem; font-weight: 500; margin: 20px 0 8px; }
textarea { resize: vertical; width: 100%; min-height: 140px; padding: 12px; border: 1px solid #bdc8cf; border-radius: 5px; background: #fff; color: var(--ink); line-height: 1.9; }
.inline-check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.inline-check input, .rubric input { width: 18px; height: 18px; accent-color: var(--blue); flex-shrink: 0; }
.data-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-button:focus-within { outline: 2px solid #376f92; outline-offset: 4px; }
.notice { border: 1px solid #e5d7bd; background: #fdfaf4; padding: 14px 16px; color: #6c562f; font-size: .875rem; line-height: 1.85; border-radius: 5px; }
.notice.info { border-color: #d9e3e8; background: #f2f6f8; color: #456170; }

/* Lists, reading pages and marginal notes. */
.grid { display: grid; gap: 24px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { background: transparent; min-width: 0; padding: 24px 0; }
.grid.two > .panel { border-top: 1px solid var(--line); }
#library-results, #source-results { grid-template-columns: minmax(0, 1fr); gap: 0; }
.knowledge-card { min-width: 0; padding: 24px 0; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.knowledge-card h3 { font-size: 1.0625rem; margin: 0; }
.knowledge-card p { color: var(--muted); font-size: .9375rem; line-height: 1.85; margin: 0; max-width: 72ch; }
.knowledge-card .title-link { color: var(--ink); }
.knowledge-card .card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: auto; padding-top: 4px; }
.card-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .8125rem; }
.source-card { overflow-wrap: anywhere; border-bottom: 1px solid var(--line); max-width: 82ch; }
.source-card .source-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; color: var(--muted); font-size: .875rem; margin: 10px 0; }
.source-card p { max-width: 72ch; font-size: .9375rem; }
.reading-back { margin: 0 0 30px; font-size: .875rem; }
.reading-layout { display: grid; grid-template-columns: minmax(0, 72ch) minmax(200px, 240px); gap: 40px; align-items: start; }
.article { max-width: 72ch; padding: 0; font-size: 1.0625rem; }
.article h1 { font-size: 1.65rem; line-height: 1.55; margin-bottom: 14px; }
.article > .reading-meta { margin-bottom: 0; }
.article h2 { font-size: 1.125rem; margin: 34px 0 12px; font-weight: 600; }
.article p, .article li { line-height: 2; }
.article p { margin-bottom: 20px; }
.article ul, .article ol { padding-left: 24px; }
.article .source-block { margin-top: 32px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.source-block p { margin: 12px 0; }
.reading-aside { position: sticky; top: 26px; padding: 0 0 0 24px; border-left: 1px solid var(--line); }
.reading-aside .panel { padding: 0; }
.reading-aside h3 { margin-bottom: 14px; }
.reading-aside .button { width: 100%; margin: 0 0 10px; }
.reading-aside label, .reading-aside textarea, .reading-aside li { font-size: .875rem; }
.reading-aside textarea { min-height: 220px; }
.reading-aside small { display: block; font-size: .75rem; padding-top: 7px; }
.reading-aside ol { padding-left: 20px; color: var(--muted); }
.empty { padding: 38px 0; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 8px; font-size: 1.0625rem; }
.empty p { max-width: 65ch; }

/* Practice uses familiar paper-like spacing and explicit selected states. */
.question-title { font-size: 1.125rem; font-weight: 500; line-height: 1.9; margin: 20px 0; max-width: 72ch; }
.question-options { display: grid; gap: 12px; margin: 22px 0; }
.option { display: flex; align-items: flex-start; gap: 12px; border: 1px solid #cbd4da; border-radius: 5px; padding: 15px; background: #fff; cursor: pointer; line-height: 1.8; }
.option:hover { background: #f4f7f9; }
.option input { margin-top: 6px; width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--blue); }
.option:has(input:checked) { border-color: #517b94; background: #edf3f7; }
.option.correct { border-color: #76a08c; background: #f0f7f3; }
.option.incorrect { border-color: #c59090; background: #fdf3f2; }
.explanation { padding: 22px; background: #f1f5f7; border-radius: 5px; margin-top: 22px; line-height: 1.9; }
.explanation p:last-child { margin-bottom: 0; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 36px; }
.exam-layout > section { padding-top: 0; }
.answer-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; margin: 16px 0; }
.answer-grid button { min-height: 38px; padding: 6px 2px; border: 1px solid #c4d0d8; border-radius: 4px; background: #fff; color: #5e6e78; font-size: .875rem; font-variant-numeric: tabular-nums; }
.answer-grid button.done { background: #e3edf4; color: #305d78; border-color: #90b1c7; }
.answer-grid button.current { box-shadow: inset 0 0 0 1px var(--navy); color: var(--navy); border-color: var(--navy); font-weight: 600; }
.timer { font-size: 1.75rem; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; }
.timer.urgent { color: var(--red); }
.score { font-size: 2.25rem; line-height: 1.3; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.score small { font-size: 1rem; color: var(--muted); }
.stats { display: flex; flex-wrap: wrap; gap: 30px; }
.stat strong { display: block; font-size: 1.25rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .875rem; }
.stat .unit { margin-left: 5px; }
details { border-top: 1px solid var(--line); padding: 18px 0; }
summary { cursor: pointer; font-weight: 500; line-height: 1.8; }
details p { margin-top: 14px; }
.rubric { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: .9375rem; }
.rubric input { margin-top: 7px; }
.diagram-wrap { overflow: auto; margin: 18px 0; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: #f8fbff; }
.diagram-wrap svg { display: block; width: 100%; min-width: 520px; height: auto; }
.diagram-wrap.zoomed svg { min-width: 1000px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; font-variant-numeric: tabular-nums; }
td, th { text-align: left; border-bottom: 1px solid var(--line); padding: 14px 12px; }
th { font-size: .875rem; font-weight: 500; color: var(--muted); background: #f5f7f8; }

/* Feedback and native dialog preserve keyboard and touch affordances. */
.skip { position: fixed; top: -100px; left: 16px; z-index: 40; padding: 12px; background: #fff; }
.skip:focus { top: 12px; }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); max-width: 90vw; padding: 12px 20px; color: #fff; background: #2d4959; border-radius: 5px; font-size: .9375rem; z-index: 30; box-shadow: 0 6px 24px #182b3920; }
dialog { max-width: min(480px, 90vw); padding: 28px; border: 0; border-radius: 12px; color: var(--ink); background: #fff; box-shadow: 0 16px 64px #152c3d30; }
dialog::backdrop { background: #24344266; }
dialog .button-row { justify-content: flex-end; margin-top: 24px; }
.large-text { font-size: 19px; }
[hidden] { display: none !important; }
.personal-entry { margin-bottom: 24px; }
.paper-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.paper-row > div { min-width: 0; }
.paper-row h3 { margin: 4px 0 8px; font-size: 1rem; line-height: 1.8; overflow-wrap: anywhere; }
.paper-row p { margin: 0; color: var(--muted); }
.paper-row > a, .paper-row > button { flex-shrink: 0; }
.paper-start { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin: 24px 0 18px; }
.paper-start select { max-width: 100%; }
.personal-original { margin-top: 20px; }
.personal-image { overflow: auto; max-width: 100%; margin-top: 12px; border: 1px solid var(--line); }
.personal-image img { display: block; width: 100%; height: auto; }
.personal-image.zoomed img { width: 1600px; max-width: none; }
.question-title, .option span { overflow-wrap: anywhere; }

@media (max-width: 1180px) {
  main { padding: 32px; }
  .topbar { padding: 0 32px; }
  .home-content { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .review-sidebar { padding: 0; border-left: 0; margin-top: 8px; }
  .review-sidebar .section-head { margin-top: 24px; }
  .review-row { border-bottom: 1px solid var(--line); }
  .progress-summary { border: 0; padding-top: 8px; }
  .reading-layout { grid-template-columns: minmax(0, 1fr); }
  .reading-aside { position: static; border-left: 0; border-top: 1px solid var(--line); padding: 24px 0 0; }
  .reading-aside .button { width: auto; margin: 0 8px 8px 0; }
  .reading-aside textarea { min-height: 150px; }
  .exam-layout { grid-template-columns: minmax(0, 1fr) 190px; gap: 26px; }
  .exam-layout .reading-aside { border-top: 0; border-left: 1px solid var(--line); padding: 0 0 0 20px; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  body { padding-bottom: 78px; }
  .topbar { height: 58px; padding: 0 20px; }
  main { padding: 28px 20px 32px; min-height: calc(100vh - 210px); }
  h1 { font-size: 1.4rem; }
  .page-head { gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
  .page-head p { font-size: .875rem; }
  .reading-start { align-items: flex-start; flex-direction: column; gap: 18px; padding: 0 0 26px; }
  .reading-start h2 { font-size: 1.2rem; }
  .reading-start p { font-size: .9375rem; margin-bottom: 8px; }
  .subject-card { padding: 18px 0; gap: 16px; }
  .subject-card h3 { font-size: 1rem; }
  .subject-card p { font-size: .875rem; }
  .study-progress small { font-size: .75rem; }
  .section-head { margin-top: 28px; }
  .topic-row .row-link { display: none; }
  .grid.two { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .panel { padding: 20px 0; }
  .knowledge-card { padding: 22px 0; }
  .knowledge-card .card-bottom { flex-wrap: wrap; gap: 4px 16px; }
  .toolbar { gap: 10px; }
  .search { flex-basis: 100%; }
  .toolbar select { flex: 1; min-width: 0; }
  .chips { gap: 0 18px; }
  .chip { font-size: .875rem; }
  .article { padding: 0; font-size: 1.0625rem; }
  .article h1 { font-size: 1.45rem; }
  .article h2 { font-size: 1.1rem; margin-top: 32px; }
  .article p { line-height: 1.95; }
  .reading-back { margin-bottom: 26px; }
  .reading-layout { gap: 28px; }
  .reading-aside { padding-top: 22px; }
  .reading-aside .button { width: auto; }
  .exam-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .exam-layout > aside { grid-row: 1; }
  .exam-layout .reading-aside { padding: 0 0 20px; border-left: 0; border-bottom: 1px solid var(--line); }
  .exam-layout aside .answer-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
  .exam-layout .timer { font-size: 1.5rem; }
  .question-title { font-size: 1.0625rem; }
  .option { padding: 13px; }
  .explanation { padding: 18px; }
  .notice { padding: 12px 14px; }
  .button { padding: 10px 14px; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; justify-content: space-around; padding: 5px 4px max(7px, env(safe-area-inset-bottom)); background: #fcfdfd; border-top: 1px solid #d7dee3; }
  .mobile-nav a { flex-direction: column; gap: 2px; padding: 6px 8px; margin: 0; min-width: 54px; min-height: 52px; font-size: .75rem; border-radius: 5px; }
  .mobile-nav svg { width: 19px; height: 19px; }
  .mobile-nav a.active { background: transparent; color: #234f68; }
  .toast { bottom: 88px; }
  footer { padding: 14px 20px 24px; font-size: .75rem; }
  .stats { gap: 24px; }
}
@media (max-width: 370px) {
  main { padding-left: 17px; padding-right: 17px; }
  .subject-card { gap: 10px; }
  .mobile-nav a { padding-left: 5px; padding-right: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

.option-crop { display: inline-block; max-width: 100%; max-height: 80px; width: auto; vertical-align: middle; }

.answer-card { margin: 12px 0; border: 0; padding: 0; }
.answer-card summary { margin-bottom: 12px; font-size: .875rem; }
