/* D · 现代教材式：导航负责定位，留白与文字层级组织教学内容。 */
:root {
  color-scheme: light;
  --paper: #fcfcfa; --surface: #fff; --subtle: #f3f5f7;
  --ink: #202d40; --muted: #5c697c; --line: #dfe4eb;
  --blue: #225fd3; --blue-hover: #184baa; --blue-soft: #edf3ff;
  --warm: #f8f4ec; --success: #217149; --error: #b72b3e; --radius: 8px;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 14px; line-height: 1.65; color: var(--ink); background: var(--paper);
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #b9c4d3 transparent; }
[hidden] { display: none !important; }
body { margin: 0; }
::selection { background: #d9e6ff; color: #183c7d; }
button, input, textarea, select { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
a { color: var(--blue); text-underline-offset: 4px; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 18px; border: 1px solid transparent;
  border-radius: var(--radius); background: var(--blue); color: white;
  font-weight: 500; cursor: pointer; line-height: 1.5;
  transition: background-color 140ms ease, border-color 140ms ease;
}
button:hover:not(:disabled) { background: var(--blue-hover); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: var(--blue-soft); color: #1d50af; }
button.secondary:hover:not(:disabled) { background: #dce8ff; }
button.danger { background: #faedf0; color: var(--error); }
button.danger:hover:not(:disabled) { background: #f5dce2; }
.site-header { display: flex; align-items: center; gap: 28px; min-height: 82px; padding: 14px max(24px, calc((100vw - 1440px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { flex-shrink: 0; }
.brand-logo { display: block; width: 177px; height: auto; }
.brand-motto { color: var(--muted); font-size: 13px; }
#account { margin-left: auto; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
#account .pill { background: none; color: var(--ink); font-size: 13px; }
#account button { min-height: 36px; padding: 6px 12px; background: transparent; color: var(--muted); }
#account button:hover { background: var(--subtle); color: var(--blue); }
main { max-width: 1440px; margin: 0 auto; padding: 0 24px; }
footer { padding: 28px 24px; text-align: center; color: var(--muted); font-size: 12px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { line-height: 1.4; }
h2 { margin: 0 0 12px; font-size: 25px; font-weight: 600; letter-spacing: -.02em; }
h3 { margin: 28px 0 12px; font-size: 17px; font-weight: 600; }
p { margin: 12px 0; }
.muted, small { color: var(--muted); }
.error { color: var(--error); }
.success { color: var(--success); }
.auth-layout { display: grid; grid-template-columns: 1fr 440px; gap: 96px; max-width: 1060px; margin: 100px auto 120px; align-items: center; }
.auth-layout:has(#auth[hidden]) { display: none; }
.hero { padding: 36px 0; }
.hero h1 { margin: 0 0 28px; font-family: "STSong", "SimSun", serif; font-size: clamp(40px, 4.5vw, 62px); line-height: 1.5; font-weight: 600; }
.hero em { font-style: normal; color: var(--blue); }
.hero p { color: var(--muted); font-size: 16px; }
#auth { margin: 0; padding: 40px; border: 1px solid var(--line); border-radius: 12px; }
#auth h2 { font-size: 24px; }
#authHint { margin-bottom: 28px; }
#authForm label { margin: 18px 0; }
#authForm button { width: 100%; margin-top: 12px; }
#authError:empty { margin: 0; }
#tabs { display: flex; align-items: stretch; gap: 28px; padding: 18px 0 0; border-bottom: 1px solid var(--line); margin: 0 0 28px; }
.nav-group { min-width: 0; }
.nav-group-name { color: var(--muted); font-size: 11px; margin: 0 12px 4px; }
.nav-buttons { display: flex; gap: 4px; }
#tabs button { color: var(--muted); background: none; border-radius: 0; border-bottom: 2px solid transparent; padding: 10px 12px 14px; white-space: nowrap; min-height: 44px; }
#tabs button:hover { color: var(--blue); background: var(--blue-soft); }
#tabs button.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
#view { min-width: 0; max-width: 1120px; margin: 0 auto; min-height: 60vh; }
#view[data-page="topics"] { max-width: none; }
.panel { padding: 28px 32px; margin: 0 0 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.panel > .muted { max-width: 80ch; margin-bottom: 24px; }
.panel > h2 { font-family: "STSong", "SimSun", serif; font-size: 28px; }
.row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.row > select { flex: 0 1 220px; }
.row > input:not([type="checkbox"]):not([type="radio"]) { flex: 1 1 220px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 20px; margin-bottom: 24px; align-items: start; }
.grid > .panel { margin-bottom: 0; }
label { display: block; font-size: 13px; font-weight: 500; margin: 16px 0; }
input, textarea, select { display: block; width: 100%; max-width: 100%; min-height: 42px; padding: 9px 12px; margin-top: 6px; color: var(--ink); background: var(--surface); border: 1px solid #bdc7d5; border-radius: var(--radius); caret-color: var(--blue); }
input::placeholder, textarea::placeholder { color: #69768a; opacity: 1; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
textarea { min-height: 112px; resize: vertical; line-height: 1.8; }
input[type="radio"], input[type="checkbox"] { display: inline-block; width: 17px; height: 17px; min-height: 0; padding: 0; margin: 0 9px 0 0; vertical-align: -3px; accent-color: var(--blue); flex-shrink: 0; }
input[type="file"] { padding: 12px; background: var(--subtle); border-style: dashed; }
input::file-selector-button { font: inherit; color: var(--blue); background: white; border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px; margin-right: 12px; cursor: pointer; }
.pill, .step-tag { display: inline-block; background: var(--subtle); color: var(--muted); font-size: 12px; font-weight: 400; padding: 3px 8px; border-radius: 4px; vertical-align: middle; }
.step-tag { background: var(--warm); color: #7c572b; margin-left: 8px; }
.item { padding: 22px 0; border: 0; border-bottom: 1px solid var(--line); margin: 0; min-width: 0; }
.item:last-child { border-bottom: 0; }
.item p { line-height: 2; white-space: pre-wrap; }
details.item { padding: 0; }
details.item > :not(summary) { margin-left: 20px; margin-right: 20px; }
details.item[open] { padding-bottom: 20px; }
summary { padding: 16px 0; cursor: pointer; line-height: 1.7; }
summary::marker { color: var(--muted); font-size: 12px; }
summary:hover { color: var(--blue); }
summary .pill { margin-left: 8px; }
.choice { display: block; padding: 12px 16px; margin: 10px 0; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; font-weight: 400; cursor: pointer; background: var(--surface); line-height: 1.85; }
.choice:hover { border-color: #9bb6e5; background: #f7faff; }
.choice:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); color: #1b458c; }
.choice:has(input:disabled) { cursor: default; }
.choice + button, .step-choice + button { margin-top: 12px; }
.note { padding: 16px 20px; margin: 16px 0; background: var(--warm); border: 0; border-radius: var(--radius); line-height: 1.9; overflow-wrap: anywhere; }
.note p:first-child { margin-top: 0; }
.note p:last-child { margin-bottom: 0; }
.stat { padding: 20px 24px; background: var(--subtle); border-radius: var(--radius); color: var(--muted); }
.stat strong { display: block; color: var(--ink); font-size: 29px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-weight: 500; color: var(--muted); background: var(--subtle); white-space: nowrap; }
td { overflow-wrap: anywhere; }
tbody tr:hover { background: #f8faff; }
td button { font-size: 12px; padding: 6px 10px; min-height: 36px; }
.class-pick { display: inline-flex; align-items: center; padding: 9px 12px; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.class-pick:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.math-question { padding: 14px 0; font-size: 16px; white-space: pre-wrap; line-height: 2.1; overflow-wrap: anywhere; }
.math-question p, .solution-step p, .deep-solution p { line-height: 2.05; }
.math-question img { display: block; max-width: 100%; height: auto; object-fit: contain; margin: 12px 0; }
.katex { font-size: 1.08em; }
.katex-display { max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 6px 0; }
.step-list { padding-left: 24px; margin: 16px 0; }
.step-list li { padding: 6px 0; line-height: 2; }
.step-choice { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.step-choice label { margin: 0; }
.deep-solution { margin-top: 20px; }
.solution-step { margin: 10px 0; background: var(--subtle); }
.challenge-summary { padding: 24px; margin-top: 24px; background: var(--blue-soft); border-radius: 12px; }
.challenge-summary h3 { margin-top: 0; }
.challenge-summary button + button { margin-left: 12px; }
.template-link { display: inline-flex; align-items: center; min-height: 42px; padding: 8px 14px; color: var(--blue); background: var(--blue-soft); border-radius: var(--radius); text-decoration: none; }
.template-link:hover { background: #dce8ff; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; margin-top: 20px; }
.folder-drop { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 120px; padding: 18px; border: 1px dashed #9aaecb; border-radius: var(--radius); background: #f7f9fc; }
.folder-drop .muted { flex-basis: 100%; font-size: 12px; }
.folder-drop button { margin-left: auto; min-height: 34px; padding: 5px 10px; font-size: 12px; }
.folder-drop.drag-over { background: var(--blue-soft); border: 2px solid var(--blue); }
.item-bank { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 12px; max-height: 590px; overflow-y: auto; margin: 20px 0; }
.draggable-q { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); cursor: grab; background: white; line-height: 1.85; font-size: 13px; }
.draggable-q:hover { border-color: #9bb6e5; }
.draggable-q:active { cursor: grabbing; }
.draggable-q .muted { margin-top: 8px; }
.student-list { display: flex; flex-direction: column; max-height: 420px; overflow: auto; }
.student-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.student-row button { font-size: 12px; padding: 6px 10px; min-height: 36px; }
.account-sheet { overflow-x: auto; }
.account-table { min-width: 360px; margin: 16px 0; }
.account-table code { font-size: 14px; }
.legacy-import > summary { color: var(--muted); }
/* 目录只定位，不关闭其他知识点；原有独立展开行为保留。 */
.knowledge-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; }
.knowledge-directory { align-self: start; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 20px; background: var(--subtle); border-radius: var(--radius); }
.knowledge-directory h2 { font-size: 19px; margin-bottom: 18px; }
.knowledge-directory input, .knowledge-directory select { font-size: 13px; margin: 10px 0; }
.directory-group { margin-top: 24px; }
.directory-group h3 { margin: 0 0 8px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.directory-link { display: block; padding: 10px 12px; margin: 2px -8px; color: var(--ink); text-decoration: none; font-size: 13px; border-radius: 5px; overflow-wrap: anywhere; }
.directory-link:hover { background: #e6ebf2; }
.directory-link[aria-current="true"] { background: #e2ecff; color: #1c51b2; font-weight: 600; }
.knowledge-reading { min-width: 0; }
.knowledge-intro { color: var(--muted); margin: 0 0 24px; font-size: 13px; max-width: 78ch; }
.topic-sheet { border-bottom: 1px solid var(--line); scroll-margin-top: 24px; }
.topic-sheet > summary { display: flex; align-items: baseline; gap: 20px; padding: 22px 0; list-style: none; }
.topic-sheet > summary::-webkit-details-marker { display: none; }
.topic-sheet > summary::after { content: ''; flex-shrink: 0; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); margin-left: auto; align-self: center; }
.topic-sheet[open] > summary::after { transform: rotate(45deg); }
.topic-sheet > summary b { font-size: 18px; font-weight: 600; }
.topic-sheet[open] > summary b { font-family: "STSong", "SimSun", serif; font-size: 30px; letter-spacing: .01em; }
.topic-meta { color: var(--muted); font-size: 12px; }
.topic-body { padding: 0 0 28px; }
.concept-band { display: grid; grid-template-columns: 1.15fr 1fr; margin: 4px 0 12px; background: #f1f5fc; border-radius: var(--radius); overflow: hidden; }
.concept-block { padding: 20px 24px; }
.concept-block + .concept-block { background: #f8f5ef; }
.concept-block h3 { color: #2453a0; margin: 0 0 8px; font-size: 15px; }
.concept-block + .concept-block h3 { color: #79562e; }
.concept-block p { margin: 0; white-space: pre-wrap; line-height: 1.9; }
.textbook-hint { border-bottom: 1px solid var(--line); padding: 0 0 4px; color: var(--muted); }
.textbook-hint p { white-space: pre-wrap; color: var(--ink); line-height: 2; }
.topic-body > h3 { margin-top: 28px; font-size: 19px; }
.knowledge-folder { margin: 0; border-bottom: 1px solid var(--line); }
.knowledge-folder > summary { font-size: 15px; padding: 14px 0; }
.knowledge-folder > .item { padding: 24px 16px; }
.knowledge-folder > .item + .item { border-top: 1px solid var(--line); }
.knowledge-folder > .item { border-bottom: 0; }
.knowledge-folder .item > .pill { background: var(--blue-soft); color: #2758ae; }
.knowledge-folder .item > details > summary { font-size: 13px; color: var(--blue); }
.example-options { display: block; }
.example-options p { margin: 4px 0; max-width: 100%; overflow-x: auto; }
.topic-action { margin-top: 24px; }
.topic-action button.secondary { color: white; background: var(--blue); }
.topic-action button.secondary:hover { background: var(--blue-hover); }
/* 管理表单仅改变字段排版，长题干和解释占满整行。 */
#questionForm, #stepItemForm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
#questionForm > label:has(textarea), #questionForm > .grid, #stepItemForm > label:has(textarea), #stepItemForm > label:has([name="key_point"]) { grid-column: 1 / -1; }
#questionForm > .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
#questionForm > button, #stepItemForm > button { justify-self: start; margin-top: 12px; grid-column: 1 / -1; }
#setForm > #setQuestions { padding: 0 12px 0 0; border-bottom: 0; }
#view[data-page="bank"] .row > label { flex: 1 1 250px; }
#view[data-page="bank"] .row > button { align-self: flex-end; margin-bottom: 16px; }
@media (max-width: 1100px) {
  #tabs { gap: 12px; overflow-x: auto; }
  .nav-group { flex-shrink: 0; }
  #tabs button { padding-left: 10px; padding-right: 10px; font-size: 13px; }
  .knowledge-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 24px; }
  .topic-sheet > summary { flex-wrap: wrap; gap: 6px 12px; }
  .topic-sheet > summary::after { margin-left: auto; }
  .concept-band { grid-template-columns: 1fr; }
  .auth-layout { gap: 48px; grid-template-columns: 1fr 400px; }
}
@media (max-width: 760px) {
  .site-header { padding: 14px 16px; gap: 12px; flex-wrap: wrap; }
  .brand-logo { width: 142px; }
  .brand-motto { display: none; }
  #account { gap: 0; }
  #account .pill { padding-right: 0; }
  #account button { min-height: 40px; padding: 6px 8px; font-size: 12px; }
  main { padding: 0 16px; }
  #tabs { gap: 16px; padding-top: 12px; margin-bottom: 20px; }
  .nav-group { flex-shrink: 0; }
  .nav-group-name { margin-left: 8px; }
  #tabs button { padding: 8px 9px 12px; min-height: 44px; }
  .knowledge-layout { display: block; }
  .knowledge-directory { position: static; max-height: 270px; padding: 16px; margin-bottom: 24px; }
  .knowledge-directory h2 { margin-bottom: 12px; }
  .directory-group { margin-top: 16px; }
  .directory-link { padding: 10px 12px; min-height: 42px; }
  .knowledge-intro { font-size: 12px; margin-bottom: 8px; }
  .topic-sheet[open] > summary b { font-size: 25px; }
  .topic-sheet > summary b { font-size: 16px; }
  .topic-meta { font-size: 11px; }
  .concept-block { padding: 18px; }
  .knowledge-folder > .item { padding: 20px 0; }
  .panel { padding: 22px 18px; margin-bottom: 20px; }
  .panel > h2 { font-size: 24px; }
  .panel > .muted { font-size: 13px; margin-bottom: 20px; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  #view > .grid:has(.stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 16px; font-size: 12px; }
  .stat strong { font-size: 25px; }
  .row { gap: 12px; }
  .row > label, .row > div { flex-basis: 100% !important; width: 100% !important; }
  .row > select { flex-basis: 100%; }
  .row > input:not([type="checkbox"]):not([type="radio"]) { flex-basis: 100%; }
  .row > label.class-pick { flex-basis: auto !important; width: auto !important; }
  #questionForm, #stepItemForm, #questionForm > .grid { grid-template-columns: 1fr; }
  .auth-layout { display: block; margin: 28px auto 48px; max-width: 440px; }
  .hero { padding: 16px 8px 28px; }
  .hero h1 { font-size: 38px; margin-bottom: 12px; }
  .hero h1 br { display: none; }
  .hero p { font-size: 14px; }
  #auth { padding: 28px 24px; }
  .challenge-summary { padding: 18px; }
  .challenge-summary button { margin: 8px 0 0; }
  .challenge-summary button + button { margin-left: 0; }
  details.item > :not(summary) { margin-left: 8px; margin-right: 8px; }
  footer { font-size: 11px; padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  body.printing-accounts * { visibility: hidden; }
  body.printing-accounts .print-target, body.printing-accounts .print-target * { visibility: visible; }
  body.printing-accounts .print-target { position: absolute; left: 0; top: 0; width: 100%; overflow: visible; background: white; }
  body.printing-accounts .print-target .row, body.printing-accounts .print-target .muted { display: none; }
  .account-table { min-width: 0; }
}
