:root {
  --teal: #0f766e;
  --teal-dark: #0d5f59;
  --teal-soft: #e3f4f1;
  --ink: #173238;
  --muted: #6d8287;
  --line: #dfeae8;
  --bg: #f3f7f6;
  --card: #ffffff;
  --amber: #d97706;
  --amber-soft: #fff5df;
  --red: #c94b45;
  --red-soft: #fff0ef;
  --green: #23825f;
  --shadow: 0 12px 32px rgba(24, 69, 71, .09);
  --question-font-size: 18px;
  --question-line-height: 1.78;
  --option-font-size: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
body[data-theme="eye"] { --bg: #f1f0e5; --card: #fbfaf2; --ink: #303b37; --muted: #708079; --line: #dedfd2; }
body[data-theme="light"] { --bg: #f3f7f6; --card: #ffffff; --ink: #173238; --muted: #6d8287; --line: #dfeae8; }
body[data-font-size="small"] { --question-font-size: 16px; --question-line-height: 1.68; --option-font-size: 13px; }
body[data-font-size="medium"] { --question-font-size: 18px; --question-line-height: 1.78; --option-font-size: 14px; }
body[data-font-size="large"] { --question-font-size: 20px; --question-line-height: 1.88; --option-font-size: 16px; }
button, input { font: inherit; }
button { border: 0; cursor: pointer; touch-action: manipulation; }

.app-shell { width: 100%; max-width: 760px; min-height: 100vh; margin: auto; padding-bottom: 78px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: max(20px, env(safe-area-inset-top)) 18px 14px;
  color: #fff;
  background: linear-gradient(135deg, #0d6861, #159487);
}
.topbar h1 { margin: 4px 0 0; font-size: 24px; letter-spacing: .3px; }
.eyebrow { font-size: 12px; opacity: .82; }
.icon-btn {
  width: 39px; height: 39px; display: grid; place-items: center;
  border-radius: 13px; color: #fff; background: rgba(255, 255, 255, .16); font-size: 20px;
}
.page { padding: 17px 15px 22px; }

.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 19px; border-radius: 20px; color: #fff;
  background: linear-gradient(135deg, #164e63, #0f766e 70%, #149287);
  box-shadow: 0 12px 28px rgba(15, 118, 110, .17);
}
.hero h2 { margin: 3px 0 6px; font-size: 21px; }
.hero p { margin: 0; max-width: 220px; opacity: .84; font-size: 13px; line-height: 1.55; }
.hero-kicker { font-size: 11px; opacity: .72; letter-spacing: 1px; }
.hero-score { flex: 0 0 76px; padding-left: 13px; text-align: center; border-left: 1px solid rgba(255, 255, 255, .28); }
.hero-score strong { display: block; font-size: 27px; }
.hero-score span { font-size: 11px; opacity: .82; }
.compact-hero { margin-bottom: 19px; }

.stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 11px; padding: 13px 6px; border: 1px solid var(--line); border-radius: 16px; background: var(--card);
}
.stats-row div { text-align: center; border-right: 1px solid var(--line); }
.stats-row div:last-child { border-right: 0; }
.stats-row strong { display: block; font-size: 17px; }
.stats-row span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { margin: 0; font-size: 16px; }
.section-title button { padding: 4px 0; color: var(--teal); background: transparent; font-size: 13px; }
.count-note { color: var(--muted); font-size: 12px; }

.subject-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.subject-card {
  min-height: 142px; padding: 15px 13px; text-align: left; color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: 0 5px 15px rgba(24, 60, 64, .04);
}
.subject-card:active, .mode-card:active, .chapter-chip:active { transform: scale(.985); }
.subject-icon {
  display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 11px;
  border-radius: 11px; color: var(--teal); background: var(--teal-soft); font-weight: 750;
}
.subject-card h3 { margin: 0 0 5px; font-size: 15px; }
.subject-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.progress-track { height: 5px; margin-top: 12px; overflow: hidden; border-radius: 20px; background: #edf3f2; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: var(--teal); }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  display: grid; grid-template-columns: 31px 1fr; grid-template-rows: auto auto; column-gap: 9px;
  min-height: 83px; padding: 14px; color: var(--ink); text-align: left;
  border: 1px solid var(--line); border-radius: 15px; background: var(--card);
}
.mode-card > span { grid-row: 1 / 3; align-self: center; color: var(--teal); font-size: 24px; }
.mode-card strong { align-self: end; font-size: 13px; }
.mode-card small { align-self: start; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.mode-card.accent { border-color: #b7dfd9; background: linear-gradient(145deg, #edf9f7, #fff); }
.type-mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.type-mode-card { min-height: 82px; padding: 11px 7px; color: var(--ink); text-align: center; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.type-mode-card > span { width: 28px; height: 28px; display: grid; place-items: center; margin: 0 auto 6px; color: var(--teal); background: var(--teal-soft); border-radius: 9px; font-size: 12px; font-weight: 800; }
.type-mode-card strong, .type-mode-card small { display: block; }
.type-mode-card strong { font-size: 12px; }
.type-mode-card small { margin-top: 3px; color: var(--muted); font-size: 9px; }

.back-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.back-btn { padding: 7px 3px; color: var(--teal); background: transparent; font-size: 14px; }
.page-title { flex: 1; margin: 0; font-size: 21px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.65; }
.chapter-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 15px 0 5px; }
.subject-type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.subject-type-grid button { padding: 10px 6px; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.subject-type-grid strong, .subject-type-grid span { display: block; }
.subject-type-grid strong { font-size: 11px; }
.subject-type-grid span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.subject-type-grid button:disabled { opacity: .42; cursor: default; }
.chapter-cloud { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.chapter-chip {
  min-height: 70px; padding: 13px; text-align: left; color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
}
.chapter-chip strong { display: block; font-size: 13px; line-height: 1.4; }
.chapter-chip span { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }

.primary, .secondary, .danger { min-height: 44px; padding: 11px 15px; border-radius: 12px; font-weight: 680; }
.primary { color: #fff; background: var(--teal); }
.secondary { color: var(--teal-dark); background: var(--teal-soft); }
.danger { color: #a63d38; background: var(--red-soft); }
.wide { width: 100%; }
.primary.small { min-height: 38px; padding: 8px 13px; }

.quiz-topline { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.quiz-topline .back-btn { justify-self: start; }
.bookmark { justify-self: end; padding: 4px 2px; color: var(--amber); background: transparent; font-size: 24px; }

.flashcard { width: 100%; height: min(540px, calc(100vh - 300px)); min-height: 410px; perspective: 1400px; }
.flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform .48s cubic-bezier(.2, .68, .25, 1); transform-style: preserve-3d; -webkit-transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: var(--shadow);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.card-front { pointer-events: auto; }
.card-back { transform: rotateY(180deg); pointer-events: none; background: var(--card); }
.flashcard.flipped .card-front { pointer-events: none; }
.flashcard.flipped .card-back { pointer-events: auto; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 15px 15px 12px; border-bottom: 1px solid #edf3f2; }
.tag-row span { padding: 5px 8px; border-radius: 999px; color: var(--teal-dark); background: var(--teal-soft); font-size: 10px; font-weight: 650; }
.tag-row span:nth-child(2) { color: #9a5b0d; background: var(--amber-soft); }
.tag-row span:nth-child(3) { color: #4f6570; background: #edf2f4; }
.back-tags span:first-child { color: #fff; background: var(--teal); }
.card-scroll { flex: 1; min-height: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.card-side-label { margin: 0 0 9px; color: var(--muted); font-size: 10px; letter-spacing: 1px; }
.question { margin: 0 0 18px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--question-font-size); line-height: var(--question-line-height); font-weight: 700; }
.question-eye { padding: 0 3px; color: #9a4e0b; background: #ffedbd; border-radius: 4px; font-weight: 850; }
.sentence-break { display: block; height: .48em; }
.flash-options { display: grid; gap: 9px; padding-bottom: 6px; }
.flash-option { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 12px; color: var(--ink); text-align: left; border: 1px solid var(--line); border-radius: 13px; background: var(--card); }
.flash-option > span { flex: 0 0 27px; height: 27px; display: grid; place-items: center; color: var(--teal); background: #edf5f3; border-radius: 50%; font-size: 12px; font-weight: 750; }
.flash-option p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--option-font-size); line-height: 1.62; }
.flash-option.selected { border-color: var(--teal); background: #edf9f7; box-shadow: inset 0 0 0 1px var(--teal); }
.flash-option.selected > span { color: #fff; background: var(--teal); }
.subjective-hint { padding: 14px; color: var(--muted); background: #f5f8f8; border-radius: 13px; font-size: 13px; line-height: 1.7; }
.card-actions { flex: 0 0 auto; padding: 9px 13px 13px; border-top: 1px solid var(--line); background: var(--card); }
.question-nav-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.back-grade-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.self-grade { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

body.quiz-active .app-shell { padding-bottom: calc(54px + env(safe-area-inset-bottom)); }
body.quiz-active .topbar { min-height: 56px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; }
body.quiz-active .topbar .eyebrow { display: none; }
body.quiz-active .topbar h1 { margin: 0; font-size: 18px; }
body.quiz-active .topbar .icon-btn { width: 33px; height: 33px; border-radius: 10px; font-size: 17px; }
body.quiz-active .page { padding: 6px 10px 8px; }
body.quiz-active .quiz-topline { min-height: 28px; margin-bottom: 4px; }
body.quiz-active .flashcard { min-height: 430px; max-height: none; height: calc(100vh - 158px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); height: calc(100dvh - 158px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
body.quiz-active .tag-row { gap: 5px; padding: 8px 10px 7px; }
body.quiz-active .tag-row span { padding: 4px 7px; }
body.quiz-active .card-scroll { padding: 11px 12px; }
body.quiz-active .card-actions { padding: 6px 9px 8px; }
body.quiz-active .card-actions .primary,
body.quiz-active .card-actions .secondary,
body.quiz-active .card-actions .danger { min-height: 36px; padding: 7px 8px; border-radius: 10px; font-size: 12px; }
body.quiz-active .question-nav-actions { gap: 7px; }
body.quiz-active .bottom-nav { height: calc(48px + env(safe-area-inset-bottom)); }
body.quiz-active .nav-item { gap: 1px; }
body.quiz-active .nav-item span { font-size: 17px; }
body.quiz-active .nav-item small { font-size: 9px; }
body.quiz-active .badge { top: 3px; }
body.quiz-active.focus-mode .topbar,
body.quiz-active.focus-mode .bottom-nav { display: none; }
body.quiz-active.focus-mode .app-shell { padding-bottom: env(safe-area-inset-bottom); }
body.quiz-active.focus-mode .page { padding-top: max(5px, env(safe-area-inset-top)); }
body.quiz-active.focus-mode .flashcard { height: calc(100vh - 53px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); height: calc(100dvh - 53px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }

.result-banner { margin-bottom: 12px; padding: 11px 12px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.result-banner.correct { color: #166646; background: #e7f7ef; }
.result-banner.wrong { color: #a23d38; background: var(--red-soft); }
.question-review { margin-bottom: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.question-review summary { color: var(--teal-dark); cursor: pointer; font-size: 12px; font-weight: 750; }
.question-review[open] summary { margin-bottom: 11px; }
.question-review h3 { margin: 0 0 11px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: calc(var(--question-font-size) - 3px); line-height: var(--question-line-height); }
.review-options { display: grid; gap: 7px; }
.review-option { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; align-items: start; gap: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.review-option > span { width: 25px; height: 25px; display: grid; place-items: center; color: var(--muted); background: #eef3f2; border-radius: 50%; font-size: 11px; font-weight: 750; }
.review-option p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: calc(var(--option-font-size) - 2px); line-height: 1.58; }
.review-option strong { align-self: center; padding: 3px 6px; color: #166646; background: #e2f5ec; border-radius: 7px; font-size: 9px; }
.review-option.correct-answer { border-color: #9fd2bd; background: #f0faf5; }
.review-option.correct-answer > span { color: #fff; background: var(--green); }
.review-option.user-selected { box-shadow: inset 0 0 0 1px var(--amber); }
.back-block { margin-bottom: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.back-block h3 { margin: 0 0 7px; color: var(--teal-dark); font-size: 12px; }
.back-block p, .full-analysis p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.68; }
.answer-block { border-color: #b9ded8; background: #edf9f7; }
.answer-block p { color: #0b5e55; font-weight: 700; }
.core-block { background: #f5f8fa; }
.memory-block { border-color: #f2ddb7; background: var(--amber-soft); }
.formula-block { border-color: #bad7e7; background: #eff7fb; }
.warning-block { border-color: #f0cfca; background: #fff5f3; }
.keyword-list { display: flex; flex-wrap: wrap; gap: 6px; }
.keyword-list span { padding: 5px 8px; border-radius: 8px; color: #5d4b83; background: #f2eefb; font-size: 11px; }
.full-analysis { margin: 4px 0 10px; padding: 12px; border: 1px dashed #ccdcd9; border-radius: 12px; }
.full-analysis summary { color: var(--teal); cursor: pointer; font-size: 12px; font-weight: 650; }
.full-analysis p { margin-top: 10px; color: #425a60; }

.filter-tabs { display: flex; gap: 7px; margin: 12px 0 15px; padding-bottom: 2px; overflow-x: auto; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tabs button { flex: 0 0 auto; padding: 8px 11px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; font-size: 11px; }
.filter-tabs button.active { color: #fff; border-color: var(--teal); background: var(--teal); }
.wrong-list { display: grid; gap: 9px; }
.wrong-item { padding: 13px; color: var(--ink); text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.tag-row.compact { padding: 0 0 9px; border: 0; }
.tag-row.compact span { padding: 4px 6px; font-size: 9px; }
.wrong-item strong { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; font-size: 13px; line-height: 1.55; }
.wrong-item small { display: block; margin-top: 8px; color: var(--teal); }

.record-list { display: grid; gap: 9px; }
.record-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.record-item strong { display: block; font-size: 14px; }
.record-item small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.record-value { color: var(--teal); font-weight: 750; }
.empty { padding: 38px 18px; color: var(--muted); text-align: center; }
.empty-icon { margin-bottom: 8px; font-size: 37px; }

.bottom-nav {
  position: fixed; z-index: 8; bottom: 0; left: 50%; display: flex;
  width: 100%; max-width: 760px; height: calc(66px + env(safe-area-inset-bottom));
  transform: translateX(-50%); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.nav-item { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #84969a; background: transparent; }
.nav-item span { font-size: 20px; line-height: 1; }
.nav-item small { font-size: 10px; }
.nav-item.active { color: var(--teal); font-weight: 700; }
.badge { position: absolute; top: 7px; margin-left: 28px; min-width: 17px; padding: 2px 4px; color: #fff; background: var(--red); border-radius: 9px; font-size: 9px; }
.hidden { display: none !important; }

.modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: end center; padding: 14px; background: rgba(18, 44, 48, .42); }
.modal-card { width: min(100%, 620px); max-height: min(88vh, 760px); padding: 19px; overflow-y: auto; border-radius: 21px 21px 14px 14px; background: var(--card); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head .icon-btn { color: var(--muted); background: #eef4f3; }
.modal-card label { display: block; margin: 15px 0 7px; font-size: 12px; font-weight: 700; }
.settings-section { margin-top: 17px; padding-top: 16px; border-top: 1px solid var(--line); }
.settings-section h3 { margin: 0 0 12px; font-size: 14px; }
.setting-label { display: block; margin: 12px 0 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.setting-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.setting-choices.four { grid-template-columns: repeat(4, 1fr); }
.setting-choices button { min-height: 37px; padding: 7px 5px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 11px; }
.setting-choices button.active { color: #fff; border-color: var(--teal); background: var(--teal); font-weight: 750; }
.setting-switch { display: flex !important; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 0 !important; padding: 11px 0 0; border-top: 1px dashed var(--line); }
.setting-switch span { min-width: 0; }
.setting-switch strong, .setting-switch small { display: block; }
.setting-switch strong { font-size: 12px; }
.setting-switch small { margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 400; }
.setting-switch input { width: 42px; height: 24px; accent-color: var(--teal); }
.data-settings > .muted { margin-top: 0; }
.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; min-width: 0; padding: 10px 11px; border: 1px solid #ccddda; border-radius: 10px; outline: none; }
.url-row input:focus { border-color: var(--teal); }
.hint { color: var(--muted); word-break: break-word; font-size: 10px; line-height: 1.6; }
.modal-actions { display: flex; gap: 9px; margin-top: 16px; }
.modal-actions button { flex: 1; }
.break-card { max-width: 430px; text-align: center; }
.break-card h2 { margin: 8px 0; font-size: 19px; }
.break-card .muted { margin: 0; }
.break-icon { font-size: 38px; }
.toast { position: fixed; z-index: 30; bottom: calc(82px + env(safe-area-inset-bottom)); left: 50%; max-width: 90%; padding: 10px 15px; color: #fff; background: #173f43; border-radius: 10px; opacity: 0; pointer-events: none; transform: translate(-50%, 14px); transition: .2s; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

body[data-theme="eye"] .bottom-nav { background: rgba(251, 250, 242, .97); }
body[data-theme="eye"] .mode-card.accent { background: linear-gradient(145deg, #e9f4ec, var(--card)); }

body.dark-theme {
  --bg: #11191a;
  --card: #1c2728;
  --ink: #e4ece9;
  --muted: #9bb0ab;
  --line: #344546;
  --teal: #43ae9f;
  --teal-dark: #72c9bd;
  --teal-soft: #173b37;
  --amber: #e6a44c;
  --amber-soft: #3a3020;
  --red: #dc7770;
  --red-soft: #3c2727;
  --green: #58b58d;
  --shadow: 0 12px 32px rgba(0, 0, 0, .24);
}
body.dark-theme .topbar { background: linear-gradient(135deg, #143f3c, #1f655f); }
body.dark-theme .bottom-nav { background: rgba(24, 35, 36, .97); }
body.dark-theme .mode-card.accent { border-color: #315d58; background: linear-gradient(145deg, #173b37, var(--card)); }
body.dark-theme .hero { background: linear-gradient(135deg, #193d47, #1c5b55 72%, #276e67); }
body.dark-theme .flash-option.selected { border-color: var(--teal); background: #173b37; }
body.dark-theme .subjective-hint,
body.dark-theme .core-block { background: #222f31; }
body.dark-theme .answer-block { border-color: #3d756c; background: #183b37; }
body.dark-theme .answer-block p { color: #8bd6ca; }
body.dark-theme .memory-block { border-color: #695735; background: #3a3020; }
body.dark-theme .formula-block { border-color: #355c70; background: #1d3440; }
body.dark-theme .warning-block { border-color: #6c4642; background: #3c2927; }
body.dark-theme .keyword-list span { color: #c0abe5; background: #342d46; }
body.dark-theme .review-option.correct-answer { border-color: #3f7560; background: #1c3a2f; }
body.dark-theme .result-banner.correct { color: #8bd6b7; background: #1b392d; }
body.dark-theme .result-banner.wrong { color: #efaaa5; background: #3c2727; }
body.dark-theme .question-eye { color: #ffd18a; background: #593b16; }
body.dark-theme .modal-head .icon-btn { background: #2b3a3b; }
body.dark-theme .url-row input { color: var(--ink); border-color: var(--line); background: #152021; }
body.dark-theme .toast { background: #315653; }

@media (min-width: 560px) {
  .page { padding: 23px 22px; }
  .subject-grid { grid-template-columns: repeat(3, 1fr); }
  .chapter-cloud { grid-template-columns: repeat(3, 1fr); }
  .modal { place-items: center; }
  .modal-card { border-radius: 21px; }
}

@media (max-height: 700px) {
  .flashcard { min-height: 370px; height: min(460px, calc(100vh - 260px)); }
  .topbar { min-height: 76px; padding-top: max(13px, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 21px; }
  body.quiz-active .topbar { min-height: 50px; padding-top: max(6px, env(safe-area-inset-top)); }
  body.quiz-active .topbar h1 { font-size: 17px; }
  body.quiz-active .flashcard { min-height: 350px; height: calc(100dvh - 144px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .flashcard-inner { transition: none; }
}
