:root {
  color-scheme: light dark;
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f4f5f9;
  --surface-3: #eceef5;
  --text: #191b23;
  --text-2: #565b6b;
  --muted: #8a8fa0;
  --line: #e7e9f0;
  --line-strong: #d5d8e4;
  --brand: #5b5bd6;
  --brand-2: #7c5ce0;
  --brand-strong: #4b4bc7;
  --brand-soft: #ededfc;
  --ok: #0c9b6b;
  --ok-soft: #e7f8f0;
  --ok-line: #b9e9d5;
  --bad: #df3f55;
  --bad-soft: #fdecef;
  --bad-line: #f7c9d0;
  --ring: #e9ebf3;
  --shadow-sm: 0 1px 2px rgba(23, 25, 35, 0.04), 0 6px 18px rgba(23, 25, 35, 0.04);
  --shadow-lg: 0 24px 60px rgba(23, 25, 35, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system,
    "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1015;
    --surface: #181a21;
    --surface-2: #20232c;
    --surface-3: #272b36;
    --text: #f0f2f7;
    --text-2: #b4b9c7;
    --muted: #858b9d;
    --line: #292d39;
    --line-strong: #3a4050;
    --brand: #8d8df6;
    --brand-2: #a17cf0;
    --brand-strong: #a3a3ff;
    --brand-soft: #262641;
    --ok: #3bd6a0;
    --ok-soft: #102a22;
    --ok-line: #1d4d3d;
    --bad: #fb7185;
    --bad-soft: #34141c;
    --bad-line: #5a2530;
    --ring: #242834;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  background-color: var(--bg);
  background-image: radial-gradient(1100px 560px at 88% -8%, rgba(91, 91, 214, 0.1), transparent 62%),
    radial-gradient(900px 480px at -12% 2%, rgba(124, 92, 224, 0.08), transparent 58%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-x: none;
}

@media (prefers-color-scheme: dark) {
  body {
    background-image: radial-gradient(1100px 560px at 88% -8%, rgba(141, 141, 246, 0.1), transparent 62%),
      radial-gradient(900px 480px at -12% 2%, rgba(161, 124, 240, 0.07), transparent 58%);
  }
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

svg {
  display: block;
}

.no-scroll {
  overflow: hidden;
}

.muted {
  color: var(--muted);
}

/* -------------------------------- 按钮 -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  background: transparent;
  cursor: pointer;
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease,
    opacity 0.16s ease, filter 0.16s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(91, 91, 214, 0.24);
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.04);
}

.btn.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-2);
}

.btn.ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn.danger {
  background: var(--bad);
  color: #ffffff;
}

.btn.danger-ghost {
  background: var(--bad-soft);
  color: var(--bad);
}

.btn.text {
  min-height: 44px;
  background: transparent;
  color: var(--muted);
}

.btn.block {
  width: 100%;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

/* -------------------------------- 启动页 -------------------------------- */

.splash {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}

.splash-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #ffffff;
  box-shadow: 0 16px 30px rgba(91, 91, 214, 0.3);
}

.splash-mark svg {
  width: 32px;
  height: 32px;
}

.splash-mark.is-error {
  background: var(--bad-soft);
  color: var(--bad);
  box-shadow: none;
}

.splash-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

.splash-text {
  max-width: 300px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.splash-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.splash-hint code,
.empty code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
}

.error-screen h1 {
  margin: 6px 0 0;
  font-size: 20px;
}

.error-screen .btn {
  min-width: 160px;
  margin-top: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------------------------------- 登录页 -------------------------------- */

.auth-screen {
  position: relative;
  isolation: isolate;
  display: flex;
  width: min(100%, 440px);
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: flex-start;
  margin: 0 auto;
  padding: 40px 22px calc(26px + var(--safe-bottom));
  overflow: clip;
}

.auth-screen::before {
  position: absolute;
  z-index: -1;
  top: -110px;
  right: -130px;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 91, 214, 0.22), transparent 66%);
  content: "";
  pointer-events: none;
}

.auth-screen::after {
  position: absolute;
  z-index: -1;
  bottom: -130px;
  left: -140px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 157, 122, 0.13), transparent 68%);
  content: "";
  pointer-events: none;
}

.auth-brand {
  margin-top: auto;
  margin-bottom: 28px;
  text-align: center;
}

.brand-mark {
  display: grid;
  width: 68px;
  height: 68px;
  margin: 0 auto;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #ffffff;
  box-shadow: 0 18px 36px rgba(91, 91, 214, 0.32);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
}

.auth-brand h1 {
  margin: 18px 0 6px;
  font-size: 30px;
  font-weight: 750;
  letter-spacing: 1px;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  letter-spacing: 0.3px;
}

.auth-card {
  padding: 24px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
}

.auth-tab {
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(23, 25, 35, 0.08);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin: 0 0 7px 2px;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.field input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  font-size: 16px;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.field input::placeholder {
  color: var(--muted);
  font-size: 14px;
}

.field input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.form-error {
  margin: 0 0 13px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 12.5px;
  line-height: 1.5;
}

.auth-switch {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.auth-switch button {
  padding: 4px;
  border: 0;
  background: none;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.auth-foot {
  margin: 22px 0 auto;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.2px;
  text-align: center;
}

/* -------------------------------- 首页 -------------------------------- */

.page {
  width: min(100%, 600px);
  margin: 0 auto;
  padding: calc(20px + var(--safe-top)) 20px calc(36px + var(--safe-bottom));
}

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.home-hello {
  min-width: 0;
}

.date {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.6px;
}

.home-hello h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: 0.2px;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.home-hello h1 span {
  color: var(--brand);
}

.expiry-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.expiry-note.is-bad {
  color: var(--bad);
}

.account-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.avatar {
  display: grid;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #ffffff;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(91, 91, 214, 0.22);
  cursor: pointer;
}

.avatar-lg {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border-radius: 20px;
  font-size: 22px;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f3dfb6;
  border-radius: 14px;
  background: #fff8e8;
  color: #8a5a12;
  font-size: 12.5px;
}

.alert summary {
  font-weight: 600;
  cursor: pointer;
}

.alert ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.alert li {
  margin: 4px 0;
  line-height: 1.5;
}

.alert p {
  margin: 8px 0 0;
}

.alert code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.06);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 20px 20px 18px;
  border-radius: 26px;
  background: linear-gradient(135deg, #5b5bd6 0%, #6f5ae0 52%, #8a63e8 100%);
  color: #ffffff;
  box-shadow: 0 18px 38px rgba(72, 64, 190, 0.28);
}

.hero::before {
  position: absolute;
  top: -100px;
  right: -80px;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  content: "";
}

.hero::after {
  position: absolute;
  right: -40px;
  bottom: -90px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  content: "";
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  letter-spacing: 0.4px;
  opacity: 0.8;
}

.hero-body {
  margin: 14px 0 12px;
}

.hero-number {
  font-size: 44px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  line-height: 1;
}

.hero-number span {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0;
  opacity: 0.65;
}

.hero-caption {
  margin-top: 6px;
  font-size: 11.5px;
  letter-spacing: 0.5px;
  opacity: 0.75;
}

.hero-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
}

.hero-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #ffffff;
  transition: width 0.5s ease;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.hero-stats div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hero-stats div + div {
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.hero-stats b {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.hero-stats span {
  font-size: 10.5px;
  letter-spacing: 0.4px;
  opacity: 0.72;
}

.home-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 22px 0 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
}

.home-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.home-tabs button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.home-tabs button span {
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 19px;
  text-align: center;
}

.home-tabs button.is-active span {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.home-tabs button span.is-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 28px 2px 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.section-head > span {
  color: var(--muted);
  font-size: 11.5px;
}

.module-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.module-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.module-row .module-card {
  min-width: 0;
  width: 100%;
}

.module-reset {
  display: inline-flex;
  align-self: flex-end;
  height: 30px;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.16s ease;
}

.module-reset svg {
  width: 14px;
  height: 14px;
}

.module-reset:hover {
  background: transparent;
  color: var(--bad);
}

.module-reset:active {
  transform: scale(0.97);
}

.module-reset.is-danger {
  color: var(--bad);
  opacity: 0.78;
}

.module-reset.is-danger:hover {
  opacity: 1;
}

.home-tabs + .section-head {
  margin-top: 18px;
}

.module-card {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.module-card:hover {
  border-color: var(--surface-3);
  box-shadow: 0 10px 24px rgba(23, 25, 35, 0.07);
}

.module-card:active {
  transform: scale(0.99);
}

.module-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 15px;
  font-size: 19px;
  font-weight: 700;
}

.tone-0 {
  background: var(--brand-soft);
  color: var(--brand);
}

.tone-1 {
  background: #e2f8f1;
  color: #0d9b7a;
}

.tone-2 {
  background: #fdf2dc;
  color: #b9770e;
}

.tone-3 {
  background: #fdeaf0;
  color: #d24a70;
}

.tone-4 {
  background: #e5f2fe;
  color: #2b7fd4;
}

.module-info {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 4px;
}

.module-title-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.module-title {
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: 0.1px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.chip.is-wrong {
  background: var(--bad-soft);
  color: var(--bad);
}

.module-meta {
  color: var(--muted);
  font-size: 11.8px;
}

.mini-progress {
  display: block;
  width: 100%;
  height: 4px;
  margin-top: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-2);
}

.mini-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  opacity: 0.68;
  transition: width 0.4s ease;
}

.module-side {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 3px;
  color: var(--muted);
}

.module-pct {
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

.module-pct.is-bad {
  color: var(--bad);
  font-size: 13px;
}

.module-side svg {
  width: 16px;
  height: 16px;
}

.module-card.is-completed .module-pct {
  color: var(--ok);
}

.empty {
  padding: 36px 24px;
  border: 1.5px dashed var(--line);
  border-radius: 20px;
  background: var(--surface);
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  place-items: center;
  border-radius: 16px;
  background: var(--brand-soft);
  color: var(--brand);
}

.empty-icon svg {
  width: 24px;
  height: 24px;
}

.empty h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.empty p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}

.empty .btn {
  margin-top: 16px;
}

.home-foot {
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.2px;
  text-align: center;
}

/* -------------------------------- 刷题页 -------------------------------- */

.quiz-screen {
  width: min(100%, 600px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

.quiz-head {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + var(--safe-top)) 14px 8px;
  background: var(--bg);
}

@supports (backdrop-filter: blur(1px)) {
  .quiz-head {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
  }
}

.quiz-head-text {
  min-width: 0;
  flex: 1;
  text-align: center;
}

.quiz-head-text h1 {
  overflow: hidden;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.2px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiz-head-text p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  display: grid;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: transform 0.14s ease, color 0.14s ease;
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.quiz-bar {
  height: 3px;
  margin: 0 20px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--line);
}

.quiz-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width 0.3s ease;
}

.quiz-content {
  padding: 20px 20px calc(120px + var(--safe-bottom));
}

/* 资料分析材料：可折叠，正文在卡片内上下滚动，表格可左右滚动 */
.material-card {
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.material-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--brand-soft), transparent);
}

.material-card.is-collapsed .material-head {
  border-bottom: 0;
}

.material-title {
  min-width: 0;
}

.material-kicker {
  display: block;
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.material-title h2 {
  margin: 3px 0 0;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
}

.material-toggle {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 2px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.material-toggle svg {
  width: 14px;
  height: 14px;
  transform: rotate(180deg);
  transition: transform 0.18s ease;
}

.material-card.is-collapsed .material-toggle svg {
  transform: rotate(0);
}

.material-body-wrap {
  position: relative;
}

.material-body {
  max-height: min(46vh, 460px);
  overflow-y: auto;
  padding: 14px 16px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.85;
  overscroll-behavior: contain;
  scrollbar-color: var(--line) transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.material-body::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.material-body::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}

.material-body::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.material-more {
  display: none;
  padding: 5px 16px 7px;
  border-top: 1px dashed var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.material-body-wrap.has-overflow .material-more {
  display: block;
}

.material-body p {
  margin: 0 0 10px;
  text-align: justify;
}

.material-body p:last-child {
  margin-bottom: 0;
}

.table-scroll {
  margin: 10px 0 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.table-scroll:last-child {
  margin-bottom: 0;
}

.data-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  color: var(--text-2);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.data-table td {
  padding: 7px 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table td:last-child {
  border-right: 0;
}

.data-table tr:first-child td {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 600;
}

.quiz-figure {
  margin: 12px 0;
}

.quiz-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.question-assets .table-scroll {
  margin: 14px 0 18px;
}

.q-source {
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.q-top .q-state {
  margin-left: auto;
}

.sheet-filters {
  display: flex;
  gap: 7px;
  margin: 14px 0 2px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.sheet-filters::-webkit-scrollbar {
  display: none;
}

.sheet-filters button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
}

.sheet-filters button span {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.sheet-filters button.is-active {
  border-color: transparent;
  background: var(--brand);
  color: #fff;
}

.sheet-filters button.is-active span {
  color: rgba(255, 255, 255, 0.72);
}

.q-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.q-num {
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.q-type {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: 10.5px;
}

.q-kind {
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 650;
}

.q-state {
  margin-left: auto;
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.q-state.is-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.q-state.is-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.stem {
  margin: 16px 0 22px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: 0.2px;
  line-height: 1.62;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(23, 25, 35, 0.03);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.12s ease,
    opacity 0.18s ease;
}

.option:active:not(.is-locked) {
  transform: scale(0.992);
}

@media (hover: hover) {
  .option:not(.is-locked):hover {
    border-color: var(--brand);
  }
}

.option-letter {
  display: grid;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  place-items: center;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.option-text {
  min-width: 0;
  flex: 1;
  padding-top: 4px;
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.option-mark {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 5px;
  color: transparent;
}

.option-mark svg {
  width: 20px;
  height: 20px;
}

.option.is-pending {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.option.is-pending .option-letter {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.option.is-correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.option.is-correct .option-letter {
  border-color: var(--ok);
  background: var(--ok);
  color: #ffffff;
}

.option.is-correct .option-mark {
  color: var(--ok);
}

.option.is-wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.option.is-wrong .option-letter {
  border-color: var(--bad);
  background: var(--bad);
  color: #ffffff;
}

.option.is-wrong .option-mark {
  color: var(--bad);
}

.option.is-dim {
  opacity: 0.62;
}

.options.is-locked .option {
  cursor: default;
}

.answer-hint {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.draft-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.option.is-locked {
  cursor: default;
}

.multi-submit {
  margin-top: 14px;
}

.fill-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.fill-box label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.fill-box input {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.fill-box input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.fill-box .btn {
  margin-top: 4px;
}

.fill-note {
  margin: -2px 0 0;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.5;
}

.exp-answer.is-long {
  width: 100%;
  margin-left: 0;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.explanation {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--ok-line);
  border-radius: 18px;
  background: var(--ok-soft);
  animation: rise 0.26s ease;
}

.explanation.is-bad {
  border-color: var(--bad-line);
  background: var(--bad-soft);
}

.exp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ok);
  font-size: 13px;
  font-weight: 700;
}

.explanation.is-bad .result-badge {
  color: var(--bad);
}

.result-badge svg {
  width: 17px;
  height: 17px;
}

.exp-answer {
  margin-left: auto;
  color: var(--text-2);
  font-size: 11.5px;
}

.exp-answer b {
  color: var(--text);
  font-size: 12.5px;
}

.exp-answer b.is-wrong {
  color: var(--bad);
}

.exp-text {
  margin: 12px 0 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.8;
  overflow-wrap: break-word;
}

.exp-text b {
  color: var(--text);
}

.exp-images {
  position: relative;
  margin-top: 12px;
  max-height: min(58vh, 520px);
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.exp-images img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 8px;
  border-radius: 10px;
}

.exp-images img:last-of-type {
  margin-bottom: 0;
}

.exp-images-hint {
  position: sticky;
  bottom: 0;
  display: block;
  padding: 8px 0 4px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  background: linear-gradient(transparent, var(--surface) 40%);
}

@media (max-width: 380px) {
  .exp-images {
    max-height: 46vh;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.quiz-foot {
  position: fixed;
  z-index: 40;
  bottom: 0;
  left: 50%;
  display: grid;
  width: min(100%, 600px);
  grid-template-columns: 1fr 1.7fr;
  gap: 10px;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
  transform: translateX(-50%);
}

.quiz-foot.has-skip {
  grid-template-columns: 1fr 0.72fr 1.45fr;
}

.quiz-foot.has-skip .btn {
  padding: 0 10px;
  font-size: 14px;
}

.btn.btn-skip {
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 14px;
}

.btn.btn-skip:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

/* -------------------------------- 弹层 -------------------------------- */

.sheet-layer {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 25, 0.48);
  animation: fade 0.2s ease;
}

.sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 600px);
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 8px 20px calc(20px + var(--safe-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.18);
  animation: slideUp 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  overscroll-behavior: contain;
}

.sheet-grip {
  width: 38px;
  height: 4px;
  margin: 2px auto 16px;
  border-radius: 99px;
  background: var(--line);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sheet-head h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.3px;
}

.sheet-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.legend {
  display: flex;
  gap: 16px;
  margin: 16px 0 14px;
  color: var(--muted);
  font-size: 11px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-3);
}

.dot.is-ok {
  background: var(--ok);
}

.dot.is-bad {
  background: var(--bad);
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
  margin-bottom: 18px;
}

.answer-cell {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.answer-cell:active {
  transform: scale(0.95);
}

.answer-cell.is-ok {
  border-color: var(--ok-line);
  background: var(--ok-soft);
  color: var(--ok);
}

.answer-cell.is-bad {
  border-color: var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad);
}

.answer-cell.is-current {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--brand);
}

.account-head {
  padding: 6px 0 20px;
  text-align: center;
}

.account-head h3 {
  margin: 12px 0 4px;
  font-size: 19px;
}

.account-head p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
}

.account-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* -------------------------------- 成绩页 -------------------------------- */

.summary-hero {
  margin: 8px 0 4px;
  text-align: center;
}

.summary-mark {
  display: grid;
  width: 62px;
  height: 62px;
  margin: 0 auto;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(91, 91, 214, 0.28);
}

.summary-mark svg {
  width: 30px;
  height: 30px;
}

.eyebrow {
  margin: 18px 0 5px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1.4px;
}

.summary-hero h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: 0.3px;
}

.summary-sub {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.score-ring {
  position: relative;
  display: grid;
  width: 164px;
  height: 164px;
  margin: 24px auto 20px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--brand)) calc(var(--value) * 1%), var(--ring) 0);
}

.score-inner {
  display: flex;
  width: 132px;
  height: 132px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.score-inner strong {
  font-size: 36px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1.5px;
  line-height: 1;
}

.score-inner small {
  margin-left: 1px;
  font-size: 15px;
  font-weight: 600;
}

.score-inner span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.8px;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 14px 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.summary-stats div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.summary-stats div + div {
  border-left: 1px solid var(--line);
}

.summary-stats b {
  font-size: 21px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.summary-stats b.is-ok {
  color: var(--ok);
}

.summary-stats b.is-bad {
  color: var(--bad);
}

.summary-stats span {
  color: var(--muted);
  font-size: 11px;
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 22px;
}

.review-section {
  margin-top: 30px;
}

.review-section .section-head {
  margin-top: 0;
}

.review-item {
  margin-bottom: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.review-item summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  list-style: none;
  cursor: pointer;
}

.review-item summary::-webkit-details-marker {
  display: none;
}

.review-item summary > svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 3px;
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.review-item[open] summary > svg {
  transform: rotate(90deg);
}

.review-num {
  display: grid;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  place-items: center;
  margin-top: 1px;
  border-radius: 7px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 11px;
  font-weight: 700;
}

.review-stem {
  flex: 1;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.55;
}

.review-body {
  padding: 0 14px 15px 46px;
}

.review-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 600;
}

.tag.is-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.tag.is-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.tag.is-long {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.review-line {
  margin: 6px 0;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.review-line span {
  display: inline-block;
  min-width: 56px;
  margin-right: 6px;
  color: var(--muted);
  font-size: 11px;
}

.review-exp {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.75;
}

.perfect {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  padding: 15px;
  border: 1px solid var(--ok-line);
  border-radius: 16px;
  background: var(--ok-soft);
}

.perfect-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 11px;
  background: var(--ok);
  color: #ffffff;
}

.perfect-icon svg {
  width: 20px;
  height: 20px;
}

.perfect b {
  display: block;
  font-size: 13.5px;
}

.perfect div > span {
  display: block;
  margin-top: 3px;
  color: var(--text-2);
  font-size: 11.5px;
}

/* -------------------------------- 对话框 -------------------------------- */

.dialog-layer {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 25, 0.5);
  animation: fade 0.18s ease;
}

.dialog {
  position: relative;
  width: min(100%, 360px);
  padding: 24px 22px 20px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.dialog h3 {
  margin: 0;
  font-size: 18px;
}

.dialog p {
  margin: 9px 0 20px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.7;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -------------------------------- Toast -------------------------------- */

.toast {
  position: fixed;
  z-index: 400;
  bottom: calc(26px + var(--safe-bottom));
  left: 50%;
  max-width: calc(100% - 40px);
  padding: 11px 18px;
  border-radius: 99px;
  background: rgba(24, 26, 33, 0.92);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  color: #ffffff;
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  background: rgba(190, 45, 65, 0.96);
}

body:has(.quiz-foot) .toast {
  bottom: calc(94px + var(--safe-bottom));
}

/* -------------------------------- 深色适配 -------------------------------- */

@media (prefers-color-scheme: dark) {
  .tone-0 {
    background: #26264a;
    color: #a5a5ff;
  }

  .tone-1 {
    background: #0f2f28;
    color: #43d6ae;
  }

  .tone-2 {
    background: #33280f;
    color: #e8b45a;
  }

  .tone-3 {
    background: #341823;
    color: #f08aa6;
  }

  .tone-4 {
    background: #12283d;
    color: #6fb6f5;
  }

  .alert {
    border-color: #4a3a1c;
    background: #2a2113;
    color: #e5bf7a;
  }
}

/* -------------------------------- 小屏与动效 -------------------------------- */

/* -------------------------------- 平板 / iPad -------------------------------- */

@media (min-width: 700px) {
  .page {
    width: min(100%, 760px);
    padding-right: 32px;
    padding-left: 32px;
  }

  .quiz-screen {
    width: min(100%, 900px);
  }

  .quiz-head {
    padding-right: 24px;
    padding-left: 24px;
  }

  .quiz-head-text h1 {
    font-size: 17px;
  }

  .quiz-head-text p {
    font-size: 12px;
  }

  .quiz-bar {
    margin: 0 24px;
  }

  .quiz-content {
    padding: 28px 36px calc(120px + var(--safe-bottom));
  }

  .stem {
    margin: 20px 0 26px;
    font-size: 22px;
    line-height: 1.65;
  }

  .options {
    gap: 12px;
  }

  .option {
    gap: 14px;
    padding: 16px 18px;
  }

  .option-letter {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 14px;
  }

  .option-text {
    padding-top: 5px;
    font-size: 17px;
    line-height: 1.6;
  }

  .option-mark {
    width: 22px;
    height: 22px;
    margin-top: 6px;
  }

  .material-body {
    max-height: min(52vh, 560px);
    padding: 18px 20px;
    font-size: 15px;
  }

  .exp-text {
    font-size: 16px;
  }

  .quiz-foot {
    width: min(100%, 900px);
    padding-right: 36px;
    padding-left: 36px;
  }

  .sheet {
    width: min(100%, 760px);
    padding-right: 28px;
    padding-left: 28px;
  }

  .answer-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (max-width: 360px) {
  .page,
  .quiz-content {
    padding-right: 16px;
    padding-left: 16px;
  }

  .module-row {
    flex-direction: column;
    gap: 4px;
  }

  .module-title-row {
    flex-wrap: wrap;
    row-gap: 5px;
  }

  .module-title {
    flex-basis: 100%;
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
  }

  .quiz-bar {
    margin: 0 16px;
  }

  .stem {
    font-size: 18px;
  }

  .option {
    gap: 10px;
    padding: 12px;
  }

  .answer-grid {
    gap: 7px;
  }

  .material-head {
    padding: 12px;
  }

  .material-body {
    max-height: 44vh;
    padding: 12px;
    font-size: 13px;
  }

  .data-table {
    min-width: 360px;
    font-size: 11px;
  }

  .hero-number {
    font-size: 40px;
  }

  .module-card {
    gap: 11px;
    padding: 13px;
  }
}

@media (max-height: 700px) {
  .material-body {
    max-height: 34vh;
  }

  .material-head {
    padding: 10px 12px;
  }

  .material-title h2 {
    font-size: 13px;
  }

  .material-more {
    padding: 3px 12px 5px;
    font-size: 9.5px;
  }

  .quiz-content {
    padding-top: 12px;
  }

  .auth-screen {
    padding-top: 24px;
  }

  .brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 18px;
  }

  .brand-mark svg {
    width: 28px;
    height: 28px;
  }

  .auth-brand {
    margin-bottom: 20px;
  }

  .auth-brand h1 {
    margin-top: 14px;
    font-size: 26px;
  }

  .auth-card {
    padding: 18px 16px 16px;
  }

  .auth-tabs {
    margin-bottom: 14px;
  }

  .auth-tab {
    padding: 8px;
  }

  .field {
    margin-bottom: 12px;
  }

  .field input {
    height: 46px;
  }

  .auth-switch {
    margin-top: 12px;
  }

  .auth-foot {
    margin-top: 16px;
  }
}

.q-tools {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0 10px;
}

.scratch-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.scratch-toggle:active {
  background: var(--surface-2);
}

body.scratch-open {
  /* No overflow:hidden here on purpose: the question page stays scrollable so the
     scratch rail can move it. Gestures are still blocked (touch-action + the
     touchmove guard in app.js), which is what protects the Pencil pointer. */
  overscroll-behavior: none;
  touch-action: none;
}

body.scratch-open .quiz-head,
body.scratch-open .scratch-toggle,
body.scratch-open .quiz-foot {
  opacity: 0;
  pointer-events: none;
}

/* Feedback such as "草纸已清空" must stay readable while the paper is open;
   only its hit area is disabled so strokes pass through. */
body.scratch-open .toast {
  pointer-events: none;
  z-index: 400;
}

.scratch {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: transparent;
  color: #1f2328;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.scratch * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.scratch-head {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 10px 28px rgba(20, 22, 40, 0.14);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.scratch-head strong {
  font-size: 15px;
}

.scratch-close,
.scratch-clear {
  border: 0;
  background: transparent;
  color: #4d5bd6;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 4px;
  cursor: pointer;
}

.scratch-clear {
  color: #c33b34;
}

.scratch-tools {
  position: absolute;
  top: calc(68px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(20, 22, 40, 0.1);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.scratch-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.scratch-widths {
  padding-left: 8px;
  border-left: 1px solid #dfe1ea;
}

.scratch-width {
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d9dbe4;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.scratch-width i {
  display: block;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: #4b4f5b;
}

.scratch-width.is-active {
  border-color: #4d5bd6;
  background: #f0f2ff;
}

.scratch-width.is-active i {
  background: #4d5bd6;
}

.scratch-color {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  outline: 2px solid transparent;
  background: var(--ink);
  cursor: pointer;
}

.scratch-color.is-active {
  outline-color: var(--ink);
}

.scratch-eraser {
  border: 1px solid #d9dbe4;
  border-radius: 999px;
  background: #fff;
  color: #4b4f5b;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.scratch-eraser.is-active {
  border-color: #4d5bd6;
  color: #4d5bd6;
  background: #f0f2ff;
}

.scratch-hint {
  margin-left: auto;
  color: #8b8f9c;
  font-size: 12px;
}

.scratch-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: transparent;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
}

.scratch-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* 草纸里的滚动条：手掌防误触把页面手势全关了，长题干就只能靠这条滑轨上下翻。
   轨道贴着右边缘（命中区 26px，视觉只有 4px），拖一下页面就走。 */
.scratch-scroll {
  position: absolute;
  top: calc(122px + env(safe-area-inset-top));
  /* 离右边缘留 6px：iPad 从屏幕最边上滑会触发分屏/切换 App，别把起点放那么外面 */
  right: 6px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 2;
  width: 24px;
  touch-action: none;
  opacity: 0.62;
  transition: opacity 0.16s ease;
}

.scratch-scroll.is-idle {
  opacity: 0;
  pointer-events: none;
}

.scratch-scroll.is-dragging {
  opacity: 1;
}

.scratch-scroll::before {
  content: '';
  position: absolute;
  top: 0;
  right: 4px;
  bottom: 0;
  width: 4px;
  border-radius: 4px;
  background: rgba(31, 35, 40, 0.11);
}

.scratch-scroll-thumb {
  position: absolute;
  top: 0;
  right: 3px;
  width: 6px;
  height: 40px;
  border-radius: 6px;
  background: rgba(31, 35, 40, 0.4);
  transition: background 0.16s ease;
}

.scratch-scroll.is-dragging .scratch-scroll-thumb {
  background: rgba(31, 35, 40, 0.58);
}

@media (max-width: 560px) {
  .scratch-hint {
    display: none;
  }
}

@media (max-width: 380px) {
  .scratch-tools {
    gap: 6px;
    padding: 7px 8px;
  }

  .scratch-color,
  .scratch-width {
    width: 24px;
    height: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
