:root {
  /* Host homepage's current natural-museum palette (REQ-0052). */
  color-scheme: light;
  --ink: #303d28;
  --ink-soft: #626e5c;
  --paper: #f0ede5;
  --paper-deep: #e1e3d6;
  --white: #f9f7f0;
  --teal: #435837;
  --teal-light: #ececdf;
  --coral: #a77545;
  --coral-light: #f0e5d6;
  --gold: #8a6a2e;
  --line: #b9c0ad;
  --on-accent: #fffdf5;
  --field: #fffdf5;
  --success: #435837;
  --success-soft: #eaf0e1;
  --danger: #a13d2a;
  --danger-soft: #f8e5df;
  --warning-soft: #f4ead1;
  --radius-lg: 24px;
  --radius-md: 15px;
  --shadow: 0 20px 55px rgba(37, 53, 50, 0.10);
  /* Screen formulas: upright textbook-style serif; no downloaded font. */
  --formula-font: "Times New Roman", Times, "STIX Two Text", serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e9edde;
  --ink-soft: #b9c4b2;
  --paper: #222720;
  --paper-deep: #333d2e;
  --white: #2a3028;
  --teal: #c8d9b3;
  --teal-light: #384330;
  --coral: #d6b183;
  --coral-light: #443a2c;
  --gold: #e0c188;
  --line: #626e57;
  --on-accent: #24301d;
  --field: #222720;
  --success: #c8d9b3;
  --success-soft: #303e28;
  --danger: #ffb5a0;
  --danger-soft: #4b3029;
  --warning-soft: #453e2a;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.55;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(19, 124, 120, 0.28);
  outline-offset: 2px;
}

.page-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }

.site-header {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(18, 52, 59, 0.14);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 43px; height: 43px; display: grid; place-items: center;
  color: var(--white); background: var(--ink); border-radius: 12px;
  font-family: Georgia, serif; font-weight: 700; transform: rotate(-4deg);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: 0.04em; }
.brand small { color: var(--ink-soft); font-size: 11px; letter-spacing: 0.12em; }

.scope-badge {
  display: flex; align-items: center; gap: 8px; padding: 8px 13px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.45);
  color: var(--ink-soft); font-size: 12px; font-weight: 700;
}
.scope-badge span { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(19,124,120,.12); }

.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 56px;
  align-items: end; padding: 62px 2px 46px;
}
.eyebrow { margin: 0 0 12px; color: var(--coral); font: 700 11px/1.2 ui-monospace, SFMono-Regular, monospace; letter-spacing: .23em; }
h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(42px, 5vw, 67px); line-height: 1.08; letter-spacing: -.035em; font-weight: 600; }
h1 em { color: var(--teal); font-style: normal; }
.hero-copy { max-width: 680px; margin: 22px 0 0; color: var(--ink-soft); font-size: 16px; }
.bank-total { margin: 12px 0 0; color: var(--teal); font-size: 12px; font-weight: 700; }
.control-help { margin: 9px 0 0; color: rgba(238,246,242,.66); font-size: 10px; line-height: 1.65; }
.order-label { margin-top: 19px; }
.bank-status { margin: 12px 0 0; color: #bfe1dc; font-size: 11px; overflow-wrap: anywhere; }
.bank-status.has-repeat-warning { color: #ffb19e; }
.practice-boundary { margin: 14px 0 0; color: var(--ink-soft); font-size: 12px; font-weight: 400; line-height: 1.8; }

.score-card {
  display: grid; grid-template-columns: repeat(3, 84px); position: relative;
  padding: 18px 20px; border: 1px solid rgba(18,52,59,.14); border-radius: var(--radius-md);
  background: rgba(255,253,248,.72); box-shadow: 0 8px 30px rgba(37,53,50,.06);
}
.score-card div { text-align: center; border-right: 1px solid var(--line); }
.score-card div:nth-child(3) { border-right: 0; }
.score-card span, .score-card small { display: block; }
.score-card span { font: 600 28px/1.1 Georgia, serif; }
.score-card small { margin-top: 4px; color: var(--ink-soft); font-size: 10px; }
.text-button { position: absolute; right: 8px; top: -27px; border: 0; background: transparent; color: var(--ink-soft); font-size: 11px; }
.text-button:hover { color: var(--coral); }

.workspace {
  display: grid; grid-template-columns: 285px minmax(0, 1fr); min-height: 595px;
  overflow: hidden; background: var(--white); border: 1px solid rgba(18,52,59,.12);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}

.control-panel { padding: 30px 24px; color: #eef6f2; background: var(--ink); }
.control-block + .control-block { margin-top: 32px; }
.control-label {
  display: flex; align-items: center; gap: 9px; margin: 0 0 12px;
  color: rgba(238,246,242,.66); font-size: 11px; font-weight: 700; letter-spacing: .1em;
}
.control-label span { color: #74bcb5; font: 700 10px ui-monospace, monospace; }

.practice-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.practice-tab {
  min-height: 65px; padding: 10px 8px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px;
  color: rgba(255,255,255,.68); background: rgba(255,255,255,.045); text-align: left;
}
.practice-tab strong, .practice-tab small { display: block; }
.practice-tab strong { font-size: 12px; }
.practice-tab small { margin-top: 4px; color: rgba(255,255,255,.42); font-size: 9px; }
.practice-tab:hover { border-color: rgba(255,255,255,.3); }
.practice-tab.is-active { border-color: #87d0c8; color: white; background: rgba(19,124,120,.3); box-shadow: inset 0 0 0 1px rgba(135,208,200,.16); }
.practice-tab.is-active small { color: #9dd3cd; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; background: rgba(255,255,255,.06); }
.segment { min-height: 42px; border: 0; border-radius: 9px; color: rgba(255,255,255,.65); background: transparent; font-size: 12px; font-weight: 700; }
.segment.is-active { color: var(--ink); background: var(--paper); box-shadow: 0 3px 12px rgba(0,0,0,.16); }

.mode-list { display: grid; gap: 9px; }
.mode-card {
  display: grid; grid-template-columns: 34px 1fr 12px; align-items: center; gap: 10px;
  width: 100%; min-height: 66px; padding: 10px 12px; text-align: left;
  border: 1px solid rgba(255,255,255,.11); border-radius: 13px; color: rgba(255,255,255,.76); background: rgba(255,255,255,.045);
}
.mode-card:hover { border-color: rgba(255,255,255,.28); }
.mode-card.is-active { border-color: rgba(116,188,181,.75); background: rgba(19,124,120,.28); color: white; }
.mode-icon { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; color: #9bd2cc; background: rgba(255,255,255,.08); font-size: 15px; }
.mode-card strong, .mode-card small { display: block; }
.mode-card strong { font-size: 13px; }
.mode-card small { margin-top: 2px; color: rgba(255,255,255,.50); font-size: 10px; }
.mode-card i { width: 9px; height: 9px; border: 2px solid rgba(255,255,255,.28); border-radius: 50%; }
.mode-card.is-active i { border-color: #87d0c8; background: #87d0c8; box-shadow: inset 0 0 0 2px var(--ink); }

.difficulty-control select {
  width: 100%; min-height: 43px; padding: 0 12px; color: white; border: 1px solid rgba(255,255,255,.14); border-radius: 11px; background: #1e4850;
}

.count-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.count-button {
  min-height: 39px; padding: 0 6px; border: 1px solid rgba(255,255,255,.14); border-radius: 10px;
  color: rgba(255,255,255,.72); background: rgba(255,255,255,.05); font-size: 12px; font-weight: 800;
}
.count-button:hover { border-color: rgba(255,255,255,.32); }
.count-button.is-active { border-color: #87d0c8; color: var(--ink); background: #bfe1dc; }
.custom-count-button { grid-column: 1 / -1; }
.custom-count-wrap { margin-top: 9px; padding: 10px; border-radius: 11px; background: rgba(255,255,255,.06); }
.custom-count-wrap > label { display: block; margin-bottom: 6px; color: rgba(255,255,255,.62); font-size: 10px; }
.custom-count-wrap > div { display: grid; grid-template-columns: 1fr 54px; gap: 6px; }
.custom-count-wrap input {
  width: 100%; min-width: 0; height: 36px; padding: 0 8px; border: 1px solid rgba(255,255,255,.2); border-radius: 8px;
  color: white; background: #1e4850;
}
.custom-count-wrap input::placeholder { color: rgba(255,255,255,.35); }
.custom-count-wrap button { border: 0; border-radius: 8px; color: var(--ink); background: #bfe1dc; font-size: 11px; font-weight: 800; }
.count-error { min-height: 16px; margin: 5px 0 0; color: #ffb19e; font-size: 10px; }
.regenerate-button {
  width: 100%; min-height: 37px; margin-top: 9px; border: 1px solid rgba(255,255,255,.15); border-radius: 9px;
  color: rgba(255,255,255,.72); background: transparent; font-size: 11px; font-weight: 700;
}
.regenerate-button:hover { border-color: #87d0c8; color: white; }
.document-button {
  width: 100%; min-height: 41px; margin-top: 8px; border: 0; border-radius: 10px;
  color: var(--ink); background: #bfe1dc; font-size: 11px; font-weight: 900;
}
.document-button:hover { background: #d4ebe7; transform: translateY(-1px); }

.study-note { margin-top: 38px; padding: 16px; border-left: 3px solid var(--coral); background: rgba(255,255,255,.055); border-radius: 0 10px 10px 0; }
.study-note strong { font-size: 12px; }
.study-note p { margin: 6px 0 0; color: rgba(255,255,255,.58); font-size: 11px; line-height: 1.7; }

.question-panel { min-width: 0; padding: 32px clamp(25px, 5vw, 70px) 38px; display: flex; flex-direction: column; }
.question-topline { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.question-meta { display: flex; flex-wrap: wrap; gap: 7px; }
.question-meta span { padding: 5px 10px; border-radius: 999px; color: var(--teal); background: var(--teal-light); font-size: 10px; font-weight: 800; }
.question-meta span:nth-child(2) { color: #a24e36; background: var(--coral-light); }
.question-meta span:nth-child(3) { color: #7d621e; background: #f2e9cd; }
.paper-progress { margin: 9px 0 0; color: var(--ink-soft); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.question-actions { display: flex; align-items: center; }
.paper-navigation { display: flex; gap: 7px; }
.paper-navigation button {
  min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink-soft); background: transparent; font-size: 11px; font-weight: 700;
}
.paper-navigation button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.paper-navigation button:disabled { cursor: not-allowed; opacity: .35; }
.shuffle-button { min-height: 36px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-soft); background: transparent; font-size: 11px; font-weight: 700; }
.shuffle-button:hover { border-color: var(--teal); color: var(--teal); }
.shuffle-button span { display: inline-block; margin-right: 4px; font-size: 17px; transition: transform .2s ease; }
.shuffle-button:hover span { transform: rotate(90deg); }

.question-heading { margin-top: 30px; }
.question-heading p { margin: 0; color: var(--ink-soft); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.question-heading h2 { margin: 5px 0 0; font: 600 clamp(23px, 3vw, 34px)/1.25 Georgia, "Songti SC", serif; }
.condition-line { min-height: 24px; margin-top: 7px; color: var(--ink-soft); font-size: 12px; }
.condition-line span { margin-right: 7px; color: var(--coral); font-weight: 800; }

.equation {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 17px;
  min-height: 148px; margin: 26px 0 14px; padding: 30px 20px;
  border: 1px dashed #cabfae; border-radius: 18px; background: #fbf8f1;
}
.equation-side { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; }
.term { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.formula { font: normal 400 21px/1.5 var(--formula-font); color: #172f34; }
.formula sub { font-size: .67em; }
.formula sup { font-size: .64em; }
.plus { color: #9b968c; font-size: 18px; }
.reaction-arrow { position: relative; padding-top: 9px; color: var(--coral); font: 500 34px/1 Georgia, serif; }
.reaction-arrow i { position: absolute; bottom: 31px; left: 50%; max-width: 120px; transform: translateX(-50%); color: var(--ink-soft); font: normal 9px/1.1 sans-serif; white-space: nowrap; }

.coefficient-input, .species-input {
  height: 38px; border: 1px solid #bcb5aa; border-radius: 6px; color: var(--ink); background: white; text-align: center;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.coefficient-input { width: 38px; font-size: 17px; font-weight: 500; }
.species-input { width: 100px; padding: 0 7px; font-family: var(--formula-font); font-size: 18px; }
.species-input::placeholder { font-family: "PingFang SC", sans-serif; font-size: 11px; color: #aaa399; }
.coefficient-input:hover, .species-input:hover { border-color: var(--teal); }
.coefficient-input.is-right, .species-input.is-right { border-color: var(--success); background: #eff8f3; }
.coefficient-input.is-wrong, .species-input.is-wrong { border-color: var(--danger); background: #fff1ed; }
.coefficient-input.is-warning, .species-input.is-warning { border-color: var(--gold); background: #fff8e5; }

.hint-row { min-height: 48px; display: flex; align-items: flex-start; gap: 15px; }
.hint-button { flex: 0 0 auto; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-soft); background: transparent; font-size: 11px; }
.hint-button:hover { color: var(--teal); border-color: var(--teal); }
.hint { margin: 5px 0 0; color: var(--ink-soft); font-size: 12px; }

.feedback { display: grid; grid-template-columns: 38px 1fr; gap: 12px; margin: 8px 0 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: #f7f5ef; }
.feedback-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-weight: 900; }
.feedback-icon::before { content: "!"; }
.feedback.is-correct { border-color: #b9d8c9; background: #eff8f3; }
.feedback.is-correct .feedback-icon { color: white; background: var(--success); }
.feedback.is-correct .feedback-icon::before { content: "✓"; }
.feedback.is-incorrect { border-color: #e7b9ac; background: #fff3ef; }
.feedback.is-incorrect .feedback-icon { color: white; background: var(--danger); }
.feedback.is-not-simplest { border-color: #e3ce8f; background: #fff8e6; }
.feedback.is-not-simplest .feedback-icon { color: white; background: var(--gold); }
.feedback.is-incomplete .feedback-icon { color: white; background: var(--ink-soft); }
.feedback strong { font-size: 13px; }
.feedback p { margin: 2px 0 0; color: var(--ink-soft); font-size: 12px; }
.standard-answer { margin-top: 10px; }
.standard-answer small { display: block; margin-bottom: 4px; color: var(--ink-soft); font-size: 9px; letter-spacing: .12em; }
.standard-answer div { font-family: var(--formula-font); font-size: 18px; font-weight: 400; line-height: 1.8; }
.standard-answer span b { margin-right: 2px; color: var(--coral); font-weight: 500; }

.action-row { display: flex; gap: 10px; margin-top: auto; padding-top: 12px; }
.primary-button, .secondary-button { min-height: 48px; padding: 0 22px; border-radius: 12px; font-weight: 800; }
.primary-button { flex: 1; border: 0; color: white; background: var(--teal); box-shadow: 0 8px 20px rgba(19,124,120,.2); }
.primary-button:hover { background: #0d6b68; transform: translateY(-1px); }
.primary-button span { margin-left: 9px; color: rgba(255,255,255,.64); font-size: 10px; }
.secondary-button { border: 1px solid var(--line); color: var(--ink-soft); background: transparent; }
.secondary-button:hover { border-color: var(--ink-soft); color: var(--ink); }

.method-strip {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; align-items: center; gap: 18px;
  margin: 26px 0; padding: 22px 28px; border: 1px solid rgba(18,52,59,.12); border-radius: 17px; background: rgba(255,253,248,.64);
}
.method-strip > div { display: flex; align-items: center; gap: 12px; }
.method-strip > div > span { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: var(--teal); background: var(--teal-light); font: 700 13px Georgia, serif; }
.method-strip p { margin: 0; }
.method-strip strong, .method-strip small { display: block; }
.method-strip strong { font-size: 12px; }
.method-strip small { color: var(--ink-soft); font-size: 10px; }
.method-strip b { color: #b8b1a5; font-weight: 400; }

footer { padding: 8px 0 30px; color: var(--ink-soft); text-align: center; font-size: 10px; letter-spacing: .05em; }

body.is-document-open { overflow: hidden; }
.document-modal {
  position: fixed; inset: 0; z-index: 100; padding: 22px;
  overflow: auto; background: rgba(9, 31, 36, .82); backdrop-filter: blur(8px);
}
.document-modal-shell { width: min(920px, 100%); margin: 0 auto; }
.document-toolbar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 70px; padding: 12px 18px; border-radius: 14px 14px 0 0; color: white; background: #183f46; box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.document-toolbar strong, .document-toolbar small { display: block; }
.document-toolbar strong { font-size: 14px; }
.document-toolbar small { margin-top: 2px; color: rgba(255,255,255,.58); font-size: 10px; }
.document-toolbar > div:last-child { display: flex; gap: 8px; }
.document-toolbar button { min-height: 38px; padding: 0 15px; border-radius: 9px; font-size: 11px; font-weight: 800; }
.document-close { border: 1px solid rgba(255,255,255,.2); color: white; background: transparent; }
.document-download { border: 0; color: var(--ink); background: #bfe1dc; }
.document-download:disabled { cursor: wait; opacity: .72; }

.paper-document {
  display: grid; gap: 10mm; width: 210mm; margin: 0;
  color: #172f34; background: transparent;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.paper-preview-viewport { position: relative; width: min(210mm, 100%); margin: 0 auto 30px; overflow: hidden; }
.paper-document:not(.is-exporting) { position: absolute; top: 0; left: 0; transform: scale(var(--paper-preview-scale, 1)); transform-origin: top left; }
.paper-document.is-exporting { display: block; position: static; width: 210mm; margin: 0; transform: none; }
.print-page {
  display: flex; flex-direction: column; width: 210mm; height: 297mm; padding: 14mm 15mm 11mm;
  overflow: hidden; color: #172f34; background: white; box-shadow: 0 22px 60px rgba(0,0,0,.24);
}
.paper-document.is-exporting .print-page {
  height: 296.5mm; box-shadow: none;
}
.paper-document.is-exporting .print-page + .print-page { margin-top: .5mm; }
.pdf-export-stage {
  position: absolute; top: 0; left: 0; z-index: -1000;
  width: 210mm; overflow: visible; pointer-events: none; background: white;
}
.print-measure-stage {
  position: absolute; top: 0; left: -10000px; z-index: -1000;
  width: 210mm; visibility: hidden; pointer-events: none;
  color: #172f34; font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.print-measure-stage .print-page { box-shadow: none; }
.print-question-measurer { width: 210mm; padding: 0 15mm; background: white; }
.print-header { padding-bottom: 7mm; border-bottom: 2px solid #173a40; text-align: left; }
.print-header > p:first-child { margin: 0 0 2mm; color: #4d696e; font-size: 9pt; font-weight: 800; letter-spacing: .12em; }
.print-header h2 { margin: 0; font: 600 23pt/1.25 Georgia, "Songti SC", serif; letter-spacing: .04em; }
.print-fields { display: flex; gap: 10mm; margin-top: 7mm; font-size: 10pt; }
.print-fields span { display: inline-flex; align-items: flex-end; gap: 2mm; white-space: nowrap; }
.print-fields i { display: inline-block; width: 32mm; border-bottom: 1px solid #789096; }
.print-meta { display: flex; flex-wrap: wrap; gap: 2mm 5mm; margin-top: 5mm; padding: 3mm 4mm; border-radius: 2mm; background: #eef5f3; font-size: 8.5pt; }
.print-meta b { color: #176d69; }
.print-instruction { margin: 4mm 0 0; color: #465e63; font-size: 8.5pt; }
.print-continuation-header {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8mm;
  min-height: 12mm; padding-bottom: 3mm; border-bottom: 1.5px solid #173a40;
}
.print-continuation-header strong { font: 600 13pt/1.2 Georgia, "Songti SC", serif; }
.print-continuation-header span { color: #5f7377; font-size: 8pt; }
.print-question-list {
  display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; padding-top: 4mm;
}
.print-question {
  display: grid; grid-template-columns: 9mm minmax(0, 1fr); gap: 1mm;
  flex: 0 0 auto; padding: 3.6mm 0; border-bottom: 1px solid #d8e0de; break-inside: avoid; page-break-inside: avoid;
}
.print-question-number { padding-top: .5mm; font: 700 12pt/1.2 Georgia, serif; color: #176d69; }
.print-question-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2mm; margin-bottom: 2.6mm; }
.print-question-title strong { font-size: 10pt; }
.print-question-title span { color: #64777b; font-size: 7.5pt; }
.print-equation {
  display: flex; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: 1.4mm;
  font: 600 10.8pt/1.6 Georgia, "Times New Roman", serif;
}
.print-equation-side {
  display: contents;
}
.print-reaction-step { display: inline-flex; align-items: center; gap: .8mm; white-space: nowrap; }
.print-joined-term { display: inline-flex; align-items: center; gap: 1.4mm; white-space: nowrap; }
.print-term { display: inline-flex; align-items: center; gap: .8mm; white-space: nowrap; }
.print-plus { color: #6e7d80; }
.print-arrow {
  position: relative; display: inline-block; flex: 0 0 8mm; width: 8mm;
  color: #c55d45; text-align: center; font-size: 16pt;
}
.print-arrow small { display: none; }
.print-coeff-box { display: inline-block; width: 6.5mm; height: 6.5mm; border: 1.2px solid #64777b; border-radius: 1.5mm; }
.print-species-box { display: inline-block; width: 20mm; height: 6.5mm; border-bottom: 1.2px solid #64777b; }
.print-equation sub { font-size: .68em; }
.print-equation sup { font-size: .64em; }
.print-answer-header { padding-bottom: 5mm; }
.print-answer-list {
  display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; padding-top: 4mm;
}
.print-answer-item {
  display: grid; grid-template-columns: 7mm minmax(0, 1fr); gap: 2mm;
  flex: 0 0 auto; padding: 1.8mm 0; border-bottom: 1px solid #d8e0de;
  break-inside: avoid; page-break-inside: avoid;
}
.print-answer-number { padding-top: .8mm; color: #435837; font: 500 10pt/1.4 "Times New Roman", Times, serif; }
.print-answer-equation {
  display: flex; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: 1.4mm;
  color: #303d28; font: normal 400 10.8pt/1.65 "Times New Roman", Times, serif;
}
.print-answer-term { display: inline-flex; align-items: baseline; gap: .5mm; white-space: nowrap; }
.print-answer-term b { font-weight: 500; }
.print-answer-equation sub { font-size: .68em; }
.print-answer-equation sup { font-size: .64em; }
.print-page-fill {
  position: relative; flex: 1 1 auto; min-height: 0; margin-top: 3mm;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 8.5mm, rgba(113,129,133,.18) 8.5mm, rgba(113,129,133,.18) 8.75mm);
}
.print-page-fill span {
  position: absolute; right: 0; top: 1mm; padding-left: 2mm; color: #9aa8aa; background: white; font-size: 6.5pt; letter-spacing: .12em;
}
.print-footer {
  display: flex; flex: 0 0 auto; align-items: flex-end; justify-content: space-between;
  height: 8mm; padding: 2.5mm 0 0; border-top: 1px solid #b9c7c4; color: #718185; font-size: 7.5pt;
}

/* Screen colors are scoped separately; printed pages always remain light. */
button:focus-visible, input:focus-visible, select:focus-visible { outline-color: var(--teal); }
.site-header, .score-card, .workspace, .method-strip { border-color: var(--line); }
.score-card, .method-strip, .scope-badge { background: var(--white); }
.header-options { display: flex; align-items: center; gap: 14px; }
.theme-label { display: flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 12px; }
.theme-label select { min-height: 38px; padding: 0 8px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--white); }
.brand-mark { background: var(--teal); color: var(--on-accent); }
.scope-badge span { box-shadow: none; }
.control-panel { color: var(--ink); background: var(--paper-deep); border-right: 1px solid var(--line); }
.control-label, .control-help, .study-note p, .practice-tab, .practice-tab small, .mode-card, .mode-card small, .segment, .count-button { color: var(--ink-soft); }
.control-label span, .bank-status, .practice-tab.is-active small, .mode-icon { color: var(--teal); }
.bank-status.has-repeat-warning, .count-error { color: var(--danger); }
.practice-tab, .segmented, .mode-card, .count-button, .difficulty-control select { background: var(--white); border-color: var(--line); color: var(--ink); }
.practice-tab:hover, .mode-card:hover, .count-button:hover { border-color: var(--teal); }
.practice-tab.is-active, .mode-card.is-active, .count-button.is-active, .segment.is-active { border-color: var(--teal); color: var(--ink); background: var(--teal-light); box-shadow: inset 0 0 0 1px var(--teal); }
.mode-icon, .study-note { background: var(--teal-light); }
.mode-card i { border-color: var(--line); }
.mode-card.is-active i { border-color: var(--teal); background: var(--teal); box-shadow: inset 0 0 0 2px var(--white); }
.custom-count-wrap > label, .regenerate-button { color: var(--ink-soft); }
.custom-count-wrap input { color: var(--ink); background: var(--field); border-color: var(--line); }
.custom-count-wrap input::placeholder { color: var(--ink-soft); }
.custom-count-wrap button, .document-button { color: var(--on-accent); background: var(--teal); }
.regenerate-button { border-color: var(--line); }
.regenerate-button:hover { border-color: var(--teal); color: var(--teal); }
.document-button:hover { background: var(--teal); filter: brightness(.94); }
.coefficient-input::placeholder, .species-input::placeholder { color: var(--ink-soft); }
.question-meta span:nth-child(2) { color: var(--coral); }
.question-meta span:nth-child(3) { color: var(--gold); background: var(--warning-soft); }
.equation { border-color: var(--line); background: var(--field); }
.formula { color: var(--ink); }
.coefficient-input, .species-input { border-color: var(--line); background: var(--field); }
.coefficient-input.is-right, .species-input.is-right, .feedback.is-correct { background: var(--success-soft); border-color: var(--success); }
.coefficient-input.is-wrong, .species-input.is-wrong, .feedback.is-incorrect { background: var(--danger-soft); border-color: var(--danger); }
.coefficient-input.is-warning, .species-input.is-warning, .feedback.is-not-simplest { background: var(--warning-soft); border-color: var(--gold); }
.feedback { background: var(--paper); }
.feedback.is-correct .feedback-icon { color: var(--on-accent); }
.primary-button { background: var(--teal); color: var(--on-accent); box-shadow: none; }
.primary-button:hover { background: var(--teal); filter: brightness(.94); }
.primary-button span { color: inherit; opacity: .75; }
.document-modal { background: rgba(24, 31, 21, .88); }
.document-toolbar { color: var(--ink); background: var(--white); }
.document-toolbar small { color: var(--ink-soft); }
.document-close { border-color: var(--line); color: var(--ink); }
.document-download { color: var(--on-accent); background: var(--teal); }

.paper-practice { min-width: 0; padding: 32px 28px; }
.whole-paper-header { border-bottom: 2px solid var(--teal); padding-bottom: 18px; }
.whole-paper-header h2 { margin: 0; font: 600 29px/1.35 "Songti SC", Georgia, serif; }
.whole-paper-header p:not(.eyebrow) { margin: 10px 0 0; font-size: 12px; color: var(--ink-soft); }
#whole-paper-progress { font-weight: 700; color: var(--teal); }
.paper-question { --question-inset: 40px; padding: 30px 0; border-bottom: 1px solid var(--line); }
.paper-question-heading { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; }
.paper-question-number { color: var(--teal); font: normal 400 19px/1.6 var(--formula-font); }
.paper-question h3 { margin: 0; font-size: 17px; font-weight: 500; line-height: 1.6; }
.paper-question-meta, .paper-condition { font-size: 12px; font-weight: 400; line-height: 1.8; color: var(--ink-soft); overflow-wrap: anywhere; }
.paper-question-meta { margin: 8px 0 0; }
.paper-condition { margin: 6px 0 0; }
.paper-question > .practice-boundary { margin-left: var(--question-inset); }
.paper-equation { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 18px 9px; margin-left: var(--question-inset); padding: 24px 0 22px; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.paper-scroll-note { display: none; }
.paper-equation .formula { font-size: 20px; }
.paper-equation .term { gap: 7px; }
.paper-equation .coefficient-input { width: 34px; height: 34px; font-size: 16px; }
.paper-equation .species-input { height: 34px; }
.paper-joined-term, .paper-reaction-step { display: inline-flex; gap: 9px; align-items: center; white-space: nowrap; }
.paper-arrow { color: var(--coral); font: normal 400 26px/1 var(--formula-font); }
.paper-item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: var(--question-inset); }
.paper-item-actions .hint-button { min-height: 36px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.paper-clear { position: static; min-height: 36px; margin-left: auto; font-size: 12px; font-weight: 400; }
.paper-question > .hint { margin: 12px 0 0 var(--question-inset); line-height: 1.8; }
.paper-feedback { margin-top: 16px; margin-left: var(--question-inset); }
.paper-feedback > div:last-child { min-width: 0; }
.standard-answer div { overflow-wrap: anywhere; }
.whole-paper-actions { display: flex; gap: 10px; margin-top: 24px; }
#whole-paper-summary { padding: 14px; background: var(--teal-light); border-radius: 10px; font-size: 13px; }

.print-page, .print-measure-stage { color: #303d28; color-scheme: light; }
.print-header, .print-continuation-header { border-color: #435837; }
.print-header > p:first-child, .print-instruction, .print-question-title span, .print-continuation-header span { color: #626e5c; }
.print-question-number, .print-meta b { color: #435837; }
.print-meta { background: #ececdf; }
.print-arrow { color: #a77545; }
.print-question-title { overflow-wrap: anywhere; }

[hidden] { display: none !important; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 35px; }
  .score-card { width: 310px; }
  .workspace { grid-template-columns: 1fr; }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
  .control-block + .control-block { margin-top: 0; }
  .study-note { grid-column: 1 / -1; margin-top: 0; }
  .method-strip { grid-template-columns: 1fr 1fr; }
  .method-strip > b { display: none; }
}

@media (max-width: 640px) {
  .page-shell { width: min(100% - 22px, 1240px); }
  .site-header { min-height: 76px; }
  .scope-badge { display: none; }
  .hero { padding: 40px 3px 32px; }
  h1 { font-size: 40px; }
  .hero-copy { font-size: 14px; }
  .score-card { width: 100%; grid-template-columns: repeat(3, 1fr); }
  .control-panel { grid-template-columns: 1fr; padding: 24px 18px; }
  .study-note { grid-column: auto; }
  .question-panel { padding: 24px 16px 27px; }
  .question-topline { align-items: flex-start; }
  .paper-navigation { flex-direction: column; }
  .paper-navigation button { min-height: 34px; }
  .question-heading { margin-top: 23px; }
  .equation { min-height: 180px; gap: 11px; padding: 25px 10px; }
  .equation-side { gap: 8px; }
  .formula { font-size: 18px; }
  .coefficient-input { width: 37px; height: 44px; }
  .species-input { width: 88px; height: 44px; }
  .reaction-arrow { width: 100%; text-align: center; transform: rotate(90deg); margin: -4px 0; }
  .reaction-arrow i { display: none; }
  .hint-row { display: block; }
  .hint { margin: 9px 3px; }
  .action-row { flex-direction: column; }
  .method-strip { grid-template-columns: 1fr; padding: 19px; }
  .document-modal { padding: 0; }
  .document-toolbar { border-radius: 0; align-items: flex-start; }
  .document-toolbar { flex-direction: column; gap: 10px; padding: 12px 14px; }
  .document-toolbar small { max-width: none; }
  .document-toolbar > div:last-child { width: 100%; }
  .document-toolbar button { min-height: 44px; }
  .document-download { flex: 1; }
  .document-toolbar button { padding: 0 11px; }
  .paper-document { margin-bottom: 0; }
  .paper-preview-viewport { margin-bottom: 0; }
  .paper-practice { padding: 24px 14px; }
  .whole-paper-header h2 { font-size: 23px; }
  .whole-paper-header .paper-scroll-note { display: block; font-size: 10px; }
  .paper-question { --question-inset: 30px; padding: 26px 0; }
  .paper-question-heading { grid-template-columns: 22px minmax(0, 1fr); gap: 8px; }
  .paper-question h3 { font-size: 16px; }
  .paper-equation { gap: 16px 7px; padding: 22px 0; }
  .paper-equation .formula { font-size: 17px; }
  .paper-equation .coefficient-input { width: 34px; height: 44px; }
  .paper-equation .species-input { width: 90px; height: 44px; font-size: 17px; }
  .paper-joined-term, .paper-reaction-step { gap: 7px; }
  .paper-item-actions .hint-button, .paper-clear { min-height: 44px; }
  .whole-paper-actions { flex-direction: column; }
}

@media print {
  @page { size: A4; margin: 13mm 12mm 14mm; }
  body { background: white !important; }
  .page-shell { width: 100%; margin: 0; }
  .page-shell > .site-header, .page-shell > main, .page-shell > footer { display: none !important; }
  body * { visibility: hidden !important; }
  #paper-document-modal, #paper-document-modal *, #paper-document { visibility: visible !important; }
  #paper-document-modal {
    position: static; display: block !important; padding: 0; overflow: visible;
    background: none; backdrop-filter: none;
  }
  .document-modal-shell { width: auto; margin: 0; }
  .document-toolbar { display: none !important; }
  .paper-document {
    display: block; position: static !important; width: 210mm; margin: 0; transform: none !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .paper-preview-viewport { width: 210mm; height: auto !important; overflow: visible; }
  .print-page { box-shadow: none; break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
