:root,
html[data-theme="light"] {
  color-scheme: light;
  --ink: #153b32;
  --ink-soft: #5f766f;
  --muted: #73877f;
  --line: #1b534424;
  --line-strong: #1b53443d;
  --bg: #f5f3e9;
  --surface: #fffdf6e6;
  --panel: #fffdf7;
  --field: #faf9f1;
  --green: #1f765f;
  --green-soft: #dfeee5;
  --orange: #ea6543;
  --gold: #efc957;
  --violet: #776184;
  --blue: #437785;
  --cyan: var(--green);
  --amber: #d89c2d;
  --shadow: 0 18px 48px #23413612;
  --focus: #1f765f6b;
  --wash-a: #c5e5d385;
  --wash-b: #f4d7913d;
  --grid: #1f765f09;
  --grid-size: 76px;

  --paper: var(--bg);
  --green-dark: #124b40;
  --mint: var(--green-soft);
  --acid: var(--orange);
  --acid-soft: #ea65431c;
  --wrong: #a63d2c;
  --on-accent: #fffdf7;
  --on-secondary: #071920;
  --on-gold: #153b32;
  --on-accent-muted: #fffdf7b3;
  --readable-muted: #5d736c;
  --disabled-text: #a7afa9;
  --disabled-bg: #f1f2ef;
  --ion-border: #cfdbd3;
  --success-border: #b9d3c5;
  --danger-border: #ecc5bc;
  --chemistry-font: "STIX Two Text", "STIX Two Math", STIXGeneral, "Cambria Math", "Times New Roman", serif;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #effcf9;
  --ink-soft: #c2d4d3;
  --muted: #8da7ab;
  --line: #94ddd426;
  --line-strong: #94ddd43d;
  --bg: #030e13;
  --surface: #071920d1;
  --panel: #071920e0;
  --field: #020e139e;
  --green: #62e7d0;
  --green-soft: #62e7d014;
  --orange: #9a86ff;
  --gold: #ffc36d;
  --violet: #9a86ff;
  --blue: #74b9ff;
  --cyan: var(--green);
  --amber: var(--gold);
  --shadow: 0 22px 70px #00000026;
  --focus: #62e7d094;
  --wash-a: #329c9730;
  --wash-b: #6649b81f;
  --grid: #ffffff05;
  --grid-size: 64px;

  --green-dark: #c8fff5;
  --acid-soft: #9a86ff1f;
  --wrong: #ffb5a5;
  --on-accent: #032018;
  --on-secondary: #0b1015;
  --on-gold: #071920;
  --on-accent-muted: #032018b3;
  --readable-muted: var(--ink-soft);
  --disabled-text: #70858a;
  --disabled-bg: #07171d;
  --ion-border: #62e7d03d;
  --success-border: #62e7d052;
  --danger-border: #9a86ff52;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    radial-gradient(circle at 8% 8%, var(--wash-a), transparent 31rem),
    radial-gradient(circle at 86% 13%, var(--wash-b), transparent 28rem),
    var(--bg);
  background-size:
    var(--grid-size) var(--grid-size),
    var(--grid-size) var(--grid-size),
    auto,
    auto,
    auto;
  min-height: 100vh;
  transition: color 0.24s ease, background-color 0.24s ease;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 4px 0;
}

.page-toolbar-actions,
.auth-account-slot {
  display: flex;
  align-items: center;
}

.page-toolbar-actions { gap: 10px; }

.auth-account-slot {
  min-width: 0;
  gap: 12px;
  color: var(--readable-muted);
  font-size: 0.75rem;
}

.auth-account,
.auth-account-login,
.auth-account-logout {
  flex: 0 0 auto;
}

.auth-account-loading {
  color: var(--readable-muted);
  font-size: 0.7rem;
}

.auth-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
}

.auth-account-nav,
.auth-account-login.auth-account-nav {
  padding: 5px 9px 5px 6px;
  border: 1px solid color-mix(in srgb, var(--green) 22%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 5%, var(--surface));
}

.auth-account-login {
  color: var(--ink-soft);
  font-weight: 700;
  text-decoration: none;
}

.auth-account-login:hover,
.auth-account-logout:hover {
  color: var(--green);
}

.auth-account-avatar {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  color: var(--on-accent);
  background: var(--green);
  font: 750 10px/1 ui-monospace, monospace;
}

.auth-account-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.auth-account-copy strong {
  max-width: 112px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-account-copy small {
  color: var(--muted);
  font: 500 8px/1 ui-monospace, monospace;
}

.auth-account-logout {
  min-width: 32px;
  min-height: 24px;
  padding: 0;
  border: 0;
  color: var(--readable-muted);
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.auth-account-logout:disabled {
  cursor: wait;
  opacity: 0.55;
}

.auth-account-slot [hidden] { display: none; }

.theme-caption {
  color: var(--readable-muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.theme-switcher {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 5%, transparent);
}

.theme-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 54px;
  height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  color: var(--readable-muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  transition: color 160ms ease, background-color 160ms ease;
}

.theme-option:hover {
  color: var(--green);
}

html[data-theme-mode="auto"] .theme-option[data-theme-option="auto"],
html[data-theme-mode="light"] .theme-option[data-theme-option="light"],
html[data-theme-mode="dark"] .theme-option[data-theme-option="dark"] {
  color: var(--on-accent);
  background: var(--green);
}

.theme-option > span:first-child {
  font: 700 11px/1 ui-monospace, monospace;
}

.theme-option-label {
  font-size: 9px;
  font-weight: 700;
}

.hero {
  margin-top: 14px;
  padding: 28px 34px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: clamp(2.2rem, 4.6vw, 3.6rem);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.control-panel,
.learning-panel,
.worksheet-section {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.control-panel {
  margin-top: 14px;
  padding: 28px 32px;
}

.learning-panel {
  margin-top: 14px;
  padding: 24px 32px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

h2 {
  margin-bottom: 0;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  line-height: 1.05;
}

.progress-pill {
  flex: none;
  margin: 0;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--readable-muted);
  background: var(--panel);
  font-size: 0.82rem;
  font-weight: 700;
}

.section-heading-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 0;
}

.control-block {
  padding: 0 0 22px;
}

.control-block + .control-block {
  padding: 22px 0 0;
  border-top: 1px solid var(--line);
}

.control-label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.84rem;
  font-weight: 800;
}

.segmented,
.count-picker {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: repeat(3, 1fr);
}

.feature-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.feature-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.feature-card.is-active {
  border-color: color-mix(in srgb, var(--green) 74%, var(--line));
  box-shadow: 0 12px 28px color-mix(in srgb, var(--green) 10%, transparent);
}

.feature-card.is-locked {
  border-style: dashed;
}

.feature-card-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 70px;
  padding: 14px 16px;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.feature-card-toggle:hover {
  background: color-mix(in srgb, var(--green) 5%, transparent);
}

.feature-card-toggle > span:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.feature-card-toggle strong {
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 1.08rem;
}

.feature-card-toggle small {
  color: var(--readable-muted);
  font-size: 0.67rem;
  line-height: 1.35;
}

.feature-card-mark {
  color: var(--green);
  font: 800 0.72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
}

.feature-card.is-active .feature-card-toggle {
  color: var(--green-dark);
  background: color-mix(in srgb, var(--green) 7%, transparent);
}

.feature-card > .segmented {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.basic-mode-picker {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.advanced-mode-picker {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.display-mode-picker {
  grid-template-columns: repeat(2, 1fr);
}

.segmented button,
.count-picker button {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.segmented button:hover,
.count-picker button:hover {
  transform: translateY(-1px);
  border-color: var(--green);
}

.segmented button:disabled,
.count-picker button:disabled {
  color: var(--disabled-text);
  border-color: var(--line);
  background: var(--disabled-bg);
  cursor: not-allowed;
  transform: none;
}

.segmented button {
  min-height: 54px;
  padding: 10px 14px;
  text-align: center;
}

.segmented strong,
.segmented small {
  display: block;
}

.segmented strong { margin-bottom: 0; }
.segmented small { margin-top: 2px; font-size: 0.68rem; }
.segmented small { color: var(--readable-muted); }

.segmented button.is-active,
.count-picker button.is-active {
  color: var(--on-accent);
  border-color: var(--green);
  background: var(--green);
}

.segmented button.is-active small { color: var(--on-accent-muted); }

.count-picker {
  grid-template-columns: repeat(4, 1fr);
}

.count-picker button {
  min-height: 48px;
  padding: 8px;
  font-weight: 800;
}

.custom-count-row {
  display: grid;
  grid-template-columns: auto 82px 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  color: var(--readable-muted);
  font-size: 0.8rem;
}

.custom-count-row[hidden] {
  display: none;
}

.custom-count-row input {
  width: 82px;
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--field);
  text-align: center;
}

.custom-count-row input:disabled {
  color: var(--disabled-text);
  background: var(--disabled-bg);
}

.custom-count-row input[aria-invalid="true"] {
  border-color: var(--wrong);
}

.primary-button,
.secondary-button {
  min-height: 54px;
  padding: 0 24px;
  border-radius: 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  color: var(--on-accent);
  background: var(--green);
  box-shadow: 0 10px 25px color-mix(in srgb, var(--green) 22%, transparent);
}

#generate-button {
  margin-top: 24px;
}

.learning-heading,
.learning-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.learning-heading h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.learning-kicker {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.learning-scope {
  margin: 7px 0 0;
  color: var(--readable-muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.learning-login-button {
  min-height: 40px;
  padding: 0 17px;
  border-radius: 12px;
}

.learning-login-button[hidden] {
  display: none;
}

.learning-toolbar {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.learning-windows {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--field);
}

.learning-windows button {
  min-height: 34px;
  padding: 5px 12px;
  border: 0;
  border-radius: 9px;
  color: var(--readable-muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
}

.learning-windows button.is-active {
  color: var(--on-accent);
  background: var(--green);
}

.learning-sync-status {
  margin: 0;
  color: var(--readable-muted);
  font-size: 0.76rem;
  font-weight: 750;
  text-align: right;
}

.learning-status-stack {
  display: grid;
  justify-items: end;
  gap: 5px;
  max-width: min(100%, 540px);
}

.learning-queue-status {
  margin: 0;
  color: var(--readable-muted);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: right;
}

.learning-sync-status.is-warning,
.learning-queue-status.is-warning {
  color: var(--orange);
}

.learning-recovery-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.learning-history-note {
  margin: 0;
  color: var(--readable-muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.learning-trust-note {
  margin: 10px 0 0;
  color: var(--readable-muted);
  font-size: 0.68rem;
  line-height: 1.5;
}

.learning-history-note[hidden],
.learning-retry-button[hidden] {
  display: none;
}

.learning-retry-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--panel);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 850;
}

.learning-retry-button:disabled {
  color: var(--disabled-text);
  background: var(--disabled-bg);
  cursor: wait;
}

.learning-points {
  display: grid;
  gap: 7px;
  margin-top: 16px;
  max-height: 360px;
  padding-right: 3px;
  overflow-y: auto;
}

.learning-point {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.learning-point-rank {
  color: var(--readable-muted);
  font: 800 0.7rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}

.learning-point-name {
  min-width: 0;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 0.94rem;
  font-weight: 700;
}

.learning-point-count {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  color: var(--green-dark);
  white-space: nowrap;
}

.learning-point-count strong {
  font: 800 1.08rem/1 Georgia, serif;
}

.learning-point-count span {
  color: var(--readable-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.learning-empty {
  margin: 0;
  padding: 10px 2px 2px;
  color: var(--readable-muted);
  font-size: 0.82rem;
}

.learning-expand-button {
  display: block;
  min-height: 34px;
  margin: 10px auto 0;
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--readable-muted);
  background: var(--panel);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
}

.learning-expand-button[hidden] {
  display: none;
}

.primary-button:hover { background: color-mix(in srgb, var(--green) 88%, var(--ink)); }

.primary-button.compact {
  width: auto;
  min-width: 210px;
  justify-content: center;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel);
}

.worksheet-section {
  margin-top: 30px;
  padding: 34px 38px;
  scroll-margin-top: 10px;
}

.worksheet-section[hidden] {
  display: none;
}

.section-heading {
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.section-heading > p {
  max-width: 350px;
  margin: 8px 0 0;
  color: var(--readable-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  text-align: right;
}

.empty-state {
  padding: 70px 20px 58px;
  color: var(--readable-muted);
  text-align: center;
}

.empty-symbol {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: 0 auto 22px;
  border-radius: 24px;
  color: var(--on-accent);
  background: var(--green);
  font-family: Georgia, serif;
  font-size: 2.2rem;
  transform: rotate(-5deg);
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--ink);
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 1.5rem;
}

.worksheet-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.card-navigation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.card-navigation[hidden] {
  display: none;
}

.card-nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
  font-weight: 800;
}

.card-nav-button:first-child {
  justify-self: start;
}

.card-nav-button:last-child {
  justify-self: end;
}

.card-nav-button:disabled {
  color: var(--disabled-text);
  background: var(--disabled-bg);
  cursor: not-allowed;
}

.card-position {
  min-width: 72px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--readable-muted);
  background: var(--panel);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.worksheet-list[data-display-mode="card"] {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.worksheet-list[data-display-mode="card"]::-webkit-scrollbar {
  display: none;
}

.worksheet-list[data-display-mode="card"] .question-card {
  flex: 0 0 100%;
  grid-template-columns: 46px minmax(0, 1fr);
  align-content: center;
  align-items: start;
  min-width: 0;
  min-height: clamp(320px, 48vh, 470px);
  padding: 34px 38px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
}

.worksheet-list[data-display-mode="card"] .judgement,
.worksheet-list[data-display-mode="card"] .answer-feedback {
  grid-column: 2;
  justify-content: flex-start;
}

.question-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 22px;
  padding: 22px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.question-number {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
  border-right: 1px solid var(--line-strong);
  color: var(--readable-muted);
  font: 800 0.8rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.06em;
}

.question-main {
  min-width: 0;
}

.question-stem {
  margin: 0;
  color: var(--ink);
  font-family: SimSun, "宋体", "Songti SC", "STSong", serif;
  font-size: clamp(1rem, 1.6vw, 1.16rem);
  font-weight: 400;
  line-height: 2.2;
  letter-spacing: 0.012em;
}

.stem-condition {
  color: var(--green-dark);
  font-family: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--gold) 82%, transparent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.chem-expression,
.chem-formula,
.chem-label,
.chem-number,
.chem-unit {
  display: inline-block;
  white-space: nowrap;
  font-family: var(--chemistry-font);
  font-style: normal;
  font-weight: 400;
  font-kerning: normal;
  font-variant-numeric: lining-nums;
  letter-spacing: 0;
  line-height: 1;
}

.chem-expression var {
  font-family: inherit;
  font-style: italic;
}

.chem-expression sub,
.chem-formula sub,
.chem-formula sup,
.chem-number sup,
.chem-unit sup {
  display: inline-block;
  position: relative;
  margin: 0;
  font-family: inherit;
  font-size: 0.72em;
  font-style: normal;
  font-weight: 500;
  line-height: 0;
  vertical-align: baseline;
}

.chem-expression sub,
.chem-formula sub {
  bottom: -0.24em;
}

.chem-formula sup,
.chem-number sup,
.chem-unit sup {
  top: -0.5em;
  margin-left: 0.025em;
}

.chem-label-sub {
  margin-left: 0.025em !important;
}

.stem-ion-list {
  white-space: normal;
}

.ion-chip {
  display: inline-block;
  min-width: 2.25em;
  min-height: 1.9em;
  margin: 0 0.08em;
  padding: 0.24em 0.38em 0.18em;
  border: 1px solid var(--ion-border);
  border-radius: 0.5em;
  color: var(--green-dark);
  background: var(--mint);
  font-family: var(--chemistry-font);
  font-size: 1.06em;
  font-weight: 600;
  font-kerning: normal;
  font-variant-numeric: lining-nums;
  letter-spacing: 0;
  line-height: 1.25;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.ion-chip sub,
.ion-chip sup {
  display: inline-block;
  position: relative;
  margin: 0;
  font-family: inherit;
  font-size: 0.72em;
  font-style: normal;
  font-weight: 600;
  line-height: 0;
  vertical-align: baseline;
}

.ion-chip sub {
  bottom: -0.24em;
}

.ion-chip sup {
  top: -0.5em;
  margin-left: 0.055em;
}

.ion-separator {
  color: var(--ink-soft);
  font-family: SimSun, "宋体", "Songti SC", "STSong", serif;
}

.judgement {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  min-width: 0;
  padding: 0;
  border: 0;
}

.judge-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 750;
  transition: color 150ms ease;
}

.judge-copy {
  display: inline-flex;
  align-items: baseline;
  gap: 0.16em;
  line-height: 1.1;
  white-space: nowrap;
}

.judge-copy strong {
  font-size: 1.14em;
  font-weight: 900;
  letter-spacing: 0.025em;
}

.judge-copy > span {
  color: var(--ink-soft);
  font-size: 0.94em;
  font-weight: 700;
}

.judge-box.is-positive .judge-copy strong {
  color: var(--green-dark);
}

.judge-box.is-negative .judge-copy strong {
  color: var(--orange);
}

.judge-box:hover {
  color: var(--green-dark);
}

.judge-box input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.box-mark {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
}

.judge-box:has(input:checked) {
  color: var(--green-dark);
}

.judge-box:has(input:checked) .box-mark {
  border-color: var(--green);
  background: var(--green);
  box-shadow: inset 0 0 0 4px var(--panel);
}

.judgement:disabled .judge-box {
  cursor: default;
  opacity: 0.8;
}

.answer-feedback {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  padding: 13px 15px;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.55;
}

.answer-feedback.is-correct {
  color: var(--green-dark);
  background: var(--mint);
}

.answer-feedback.is-wrong {
  color: var(--wrong);
  background: var(--acid-soft);
}

.worksheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.worksheet-actions[hidden] { display: none; }

.pdf-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
}

.primary-button:disabled,
.secondary-button:disabled {
  color: var(--disabled-text);
  background: var(--disabled-bg);
  box-shadow: none;
  cursor: not-allowed;
}

.print-sheet-header {
  display: none;
}

.summary {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-top: 22px;
  padding: 18px 20px;
  border: 1px solid var(--success-border);
  border-radius: 16px;
  color: var(--green-dark);
  background: var(--mint);
}

.summary[hidden] {
  display: none;
}

.summary strong {
  font-family: Georgia, serif;
  font-size: 1.8rem;
}

.summary.is-error {
  color: var(--wrong);
  border-color: var(--danger-border);
  background: var(--acid-soft);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 38px 4px 46px;
  color: var(--readable-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .hero {
    padding: 24px 28px;
  }

  .question-card {
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: stretch;
  }

  .judgement,
  .answer-feedback {
    grid-column: 2;
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 16px, 1180px); }
  .page-toolbar { gap: 8px; padding: 8px 2px 0; }
  .page-toolbar-actions { gap: 4px; }
  .auth-account-slot { gap: 7px; }
  .auth-account-loading { font-size: 0.62rem; }
  .auth-account-nav,
  .auth-account-login.auth-account-nav { padding-right: 7px; }
  .auth-account-copy strong { max-width: 64px; }
  .auth-account-copy small { display: none; }
  .auth-account-login { font-size: 0.69rem; }
  .auth-account-logout { font-size: 0.68rem; }
  .theme-caption { display: none; }
  .theme-option {
    width: 33px;
    min-width: 33px;
    height: 29px;
    padding: 0;
  }
  .theme-option-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  .hero {
    margin-top: 8px;
    padding: 17px 18px;
    border-radius: 18px;
  }
  h1 {
    white-space: nowrap;
    font-size: clamp(1.78rem, 8.7vw, 2.35rem);
    line-height: 1;
  }
  .control-panel {
    margin-top: 10px;
    padding: 18px 14px;
    border-radius: 18px;
  }
  .learning-panel {
    margin-top: 10px;
    padding: 17px 14px;
    border-radius: 18px;
  }
  .worksheet-section { padding: 18px 12px; border-radius: 18px; }
  .section-heading { align-items: center; gap: 10px; padding-bottom: 16px; }
  .section-heading h2 { font-size: 1.55rem; }
  .section-heading-side { display: flex; align-items: center; gap: 8px; }
  .progress-pill { margin: 0; padding: 7px 9px; font-size: 0.7rem; }
  .pdf-button { min-height: 36px; padding: 0 10px; font-size: 0.74rem; }
  .control-block { padding-bottom: 18px; }
  .control-block + .control-block { padding-top: 18px; }
  .control-label { margin-bottom: 10px; font-size: 0.75rem; }
  .segmented { gap: 6px; }
  .feature-picker { grid-template-columns: 1fr; gap: 9px; }
  .feature-card { border-radius: 14px; }
  .feature-card-toggle { min-height: 57px; padding: 10px 12px; }
  .feature-card-toggle strong { font-size: 0.98rem; }
  .feature-card-toggle small { font-size: 0.61rem; }
  .feature-card > .segmented { padding: 8px; }
  .segmented button {
    min-height: 46px;
    padding: 8px 3px;
    border-radius: 11px;
    font-size: 0.82rem;
  }
  .segmented small { font-size: 0.6rem; }
  .count-picker { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .count-picker button {
    min-height: 42px;
    padding: 6px 2px;
    border-radius: 11px;
    font-size: 0.78rem;
  }
  .custom-count-row { grid-template-columns: auto 68px 1fr; margin-top: 12px; }
  .custom-count-row input { width: 68px; padding: 7px 6px; }
  #generate-button { min-height: 48px; margin-top: 18px; border-radius: 13px; }

  .learning-heading h2 { font-size: 1.42rem; }
  .learning-kicker { font-size: 0.62rem; }
  .learning-scope { margin-top: 5px; font-size: 0.68rem; }
  .learning-login-button { min-height: 36px; padding: 0 13px; font-size: 0.75rem; }
  .learning-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
    margin-top: 14px;
    padding-top: 14px;
  }
  .learning-windows {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .learning-windows button { padding-inline: 4px; font-size: 0.72rem; }
  .learning-status-stack { justify-items: start; max-width: none; }
  .learning-sync-status,
  .learning-queue-status { text-align: left; }
  .learning-recovery-row { align-items: stretch; flex-direction: column; gap: 8px; }
  .learning-retry-button { align-self: flex-start; max-width: 100%; white-space: normal; }
  .learning-points { max-height: 260px; margin-top: 12px; }
  .learning-point { grid-template-columns: 22px minmax(0, 1fr) auto; padding: 7px 9px; }
  .learning-point-name { font-size: 0.86rem; }
  .learning-expand-button { margin-top: 8px; }

  .card-navigation { gap: 8px; margin-top: 14px; }
  .card-nav-button {
    min-height: 38px;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 0.76rem;
  }
  .card-position { min-width: 62px; padding: 7px 9px; font-size: 0.74rem; }

  .worksheet-list[data-display-mode="card"] {
    gap: 10px;
    margin-top: 14px;
  }

  .worksheet-list[data-display-mode="card"] .question-card {
    grid-template-columns: 24px minmax(0, 1fr);
    min-height: clamp(330px, 58vh, 470px);
    padding: 24px 12px;
    border-radius: 16px;
  }

  .question-card {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 9px 8px;
    padding: 16px 0;
  }

  .question-number {
    align-items: flex-start;
    padding-top: 3px;
    font-size: 0.68rem;
  }

  .question-stem {
    font-size: 0.92rem;
    line-height: 1.78;
  }

  .stem-intro,
  .stem-prompt {
    display: block;
  }

  .stem-ion-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
    margin: 7px 0 5px;
  }

  .ion-separator {
    display: none;
  }

  .ion-chip {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 1.82em;
    margin: 0;
    padding: 0.22em 0.08em 0.16em;
    border-radius: 0.42em;
    font-size: clamp(0.72rem, 3.55vw, 0.9rem);
  }

  .ion-chip[data-ion="aloh4"] {
    font-size: clamp(0.61rem, 3vw, 0.74rem);
  }

  .judgement,
  .answer-feedback { grid-column: 2; }
  .judgement {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }
  .judge-box {
    justify-content: flex-start;
    gap: 7px;
    min-height: 40px;
    font-size: 0.82rem;
  }
  .box-mark {
    width: 18px;
    height: 18px;
  }
  .answer-feedback { grid-template-columns: 1fr; }
  .worksheet-actions { flex-direction: column-reverse; }
  .primary-button.compact { width: 100%; }
}

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

@media (forced-colors: active) {
  .theme-switcher,
  .theme-option,
  .auth-account-nav,
  .feature-card,
  .feature-card-toggle,
  .segmented button,
  .count-picker button,
  .learning-windows button,
  .learning-expand-button,
  .card-nav-button,
  .judge-box {
    border: 1px solid ButtonText;
  }

  .theme-option[aria-pressed="true"],
  .segmented button.is-active,
  .count-picker button.is-active,
  .learning-windows button.is-active,
  .judge-box:has(input:checked) {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 13mm 12mm 15mm;
  }

  :root,
  html[data-theme="dark"] {
    color-scheme: light;
    --ink: #153b32;
    --ink-soft: #5f766f;
    --muted: #73877f;
    --line: #1b534424;
    --line-strong: #1b53443d;
    --bg: #f5f3e9;
    --surface: #fffdf6e6;
    --panel: #fffdf7;
    --field: #faf9f1;
    --green: #1f765f;
    --green-soft: #dfeee5;
    --orange: #ea6543;
    --gold: #efc957;
    --shadow: none;
    --green-dark: #124b40;
    --acid-soft: #ea65431c;
    --wrong: #a63d2c;
    --on-accent: #fffdf7;
    --on-secondary: #071920;
    --on-gold: #153b32;
    --on-accent-muted: #fffdf7b3;
    --readable-muted: #5d736c;
    --ion-border: #cfdbd3;
    --success-border: #b9d3c5;
    --danger-border: #ecc5bc;
  }
  *,
  *::before,
  *::after {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body {
    min-width: 0;
    background: #fff;
  }

  .page-shell {
    width: 100%;
    margin: 0;
  }

  .page-toolbar,
  .hero,
  .control-panel,
  .learning-panel,
  .card-navigation,
  .worksheet-actions,
  footer { display: none !important; }

  .worksheet-section {
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  .section-heading,
  .progress-pill,
  .summary,
  .answer-feedback {
    display: none !important;
  }

  .print-sheet-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10mm;
    margin: 0 0 5mm;
    padding: 0 0 4mm;
    border-bottom: 1.2pt solid #153b32;
  }

  .print-sheet-header p {
    margin: 0 0 1.5mm;
    color: #5d736c;
    font-size: 8.5pt;
    font-weight: 700;
    letter-spacing: 0.12em;
  }

  .print-sheet-header h2 {
    margin: 0;
    color: #153b32;
    font-family: SimSun, "宋体", "Songti SC", "STSong", serif;
    font-size: 20pt;
    line-height: 1;
  }

  .print-sheet-meta {
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: 5mm;
    color: #153b32;
    font-size: 8.5pt;
    white-space: nowrap;
  }

  .worksheet-instruction {
    margin: 0 0 3mm;
    padding: 2.2mm 3mm;
    border-radius: 0;
    background: #fff;
    font-size: 8.5pt;
    line-height: 1.45;
  }

  .worksheet-list {
    margin: 0;
  }

  .worksheet-list[data-display-mode="card"] {
    display: grid;
    gap: 0;
    overflow: visible;
    scroll-snap-type: none;
  }

  .question-card {
    grid-template-columns: 8mm minmax(0, 1fr);
    gap: 1.5mm 3mm;
    padding: 3mm 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .worksheet-list[data-display-mode="card"] .question-card {
    display: grid;
    grid-template-columns: 8mm minmax(0, 1fr);
    min-height: 0;
    padding: 3mm 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    overflow: visible;
  }

  .question-number {
    padding-top: 1mm;
    font-size: 8.5pt;
  }

  .question-stem {
    font-size: 10.5pt;
    line-height: 1.75;
    letter-spacing: 0;
  }

  .ion-chip {
    min-height: 0;
    padding: 0.14em 0.28em 0.1em;
    border-color: #aebdb5;
    background: #fff;
  }

  .judgement {
    grid-column: 2;
    justify-content: flex-start;
    gap: 9mm;
  }

  .judge-box,
  .judgement:disabled .judge-box {
    min-height: 0;
    padding: 0;
    color: #153b32;
    font-size: 9pt;
    opacity: 1;
  }

  .box-mark,
  .judge-box:has(input:checked) .box-mark {
    width: 4mm;
    height: 4mm;
    border: 1pt solid #73877f;
    background: #fff;
    box-shadow: none;
  }
}
