:root {
  --bg: #f4f7fb;
  --panel: #fff;
  --text: #172033;
  --muted: #687386;
  --line: #dce3ef;
  --primary: #2457d6;
  --primary-dark: #183d9a;
  --soft-primary: #e8eefc;
  --ok: #16834a;
  --ok-bg: #e7f6ed;
  --bad: #c93333;
  --bad-bg: #fdecec;
  --warn: #a26605;
  --shadow: 0 18px 48px rgba(28, 43, 75, 0.12);
}

body.dark-theme {
  --bg: #0d1422;
  --panel: #151f33;
  --text: #edf3ff;
  --muted: #bdc9dc;
  --line: #344766;
  --primary: #4f8cff;
  --primary-dark: #9fc0ff;
  --soft-primary: #1b376b;
  --ok: #39e58d;
  --ok-bg: #0f3b29;
  --bad: #ff6b7a;
  --bad-bg: #441821;
  --warn: #ffd36d;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  background: linear-gradient(180deg, #080d18 0%, var(--bg) 42%, #0a101d 100%);
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 38%, #f8fafc 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button, input, select { touch-action: manipulation; }
[hidden] { display: none !important; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
  min-width: 0;
}

.topbar, .summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; overflow-wrap: anywhere; }
h1 { margin-bottom: 0; font-size: 2.1rem; line-height: 1.15; }

.landing-view {
  display: grid;
  gap: 22px;
}

.cover-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 30px;
  align-items: center;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid #cfdcf0;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.96) 0%, rgba(245,249,255,0.9) 48%, rgba(223,235,255,0.84) 100%),
    radial-gradient(circle at 82% 18%, rgba(36,87,214,0.22), transparent 32%);
  box-shadow: var(--shadow);
  padding: 34px;
}

.cover-hero::before {
  content: "";
  position: absolute;
  inset: 18px;
  pointer-events: none;
  border: 1px solid rgba(36,87,214,0.16);
  border-radius: 8px;
}

.cover-copy {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.cover-copy h1 {
  max-width: 690px;
  margin-bottom: 16px;
  color: #0e2f65;
  font-size: clamp(2.1rem, 5vw, 4.3rem);
  letter-spacing: 0;
}

.hero-subtitle {
  max-width: 650px;
  margin-bottom: 24px;
  color: #44536c;
  font-size: 1.06rem;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.cover-mark {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 28px;
}

.badge-ring {
  display: grid;
  place-items: center;
  width: 190px;
  aspect-ratio: 1;
  border: 16px solid #1c6da5;
  border-radius: 50%;
  background: #f6fbff;
  box-shadow: inset 0 0 0 2px #b7d3e8, 0 18px 40px rgba(28, 80, 130, 0.18);
}

.badge-ring span {
  color: #1c6da5;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.4rem;
  font-weight: 900;
}

.book-stack {
  display: grid;
  gap: 8px;
  width: min(260px, 100%);
}

.book-stack span {
  display: block;
  height: 24px;
  border: 1px solid #b9cae4;
  border-radius: 8px;
  background: linear-gradient(90deg, #ffffff, #d9e7fb);
  box-shadow: 0 9px 18px rgba(20, 44, 84, 0.12);
}

.book-stack span:nth-child(2) {
  width: 88%;
  margin-left: 8%;
  background: linear-gradient(90deg, #ffffff, #d7f0ec);
}

.book-stack span:nth-child(3) {
  width: 76%;
  margin-left: 16%;
  background: linear-gradient(90deg, #ffffff, #e7e0f7);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.overview-grid > div,
.chapter-hub,
.chapter-card,
.search-panel,
.repeat-panel,
.repeat-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.94);
  box-shadow: var(--shadow);
}

.overview-grid > div {
  padding: 18px;
}

.overview-grid span {
  display: block;
  color: var(--primary-dark);
  font-size: 1.9rem;
  font-weight: 900;
}

.overview-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.chapter-hub {
  padding: 22px;
}

.hub-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 18px;
}

.hub-header h2 {
  margin-bottom: 0;
  font-size: 1.6rem;
}

.hub-header > p {
  max-width: 460px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.chapter-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 14px;
}

.chapter-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.chapter-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.chapter-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6edf7;
}

.chapter-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2457d6, #16834a);
}

.chapter-card button {
  width: fit-content;
}

.repeat-panel {
  padding: 22px;
}

.repeat-list {
  display: grid;
  gap: 12px;
}

.repeat-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  box-shadow: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #f7fbff, #eef6ff);
  border: 1px solid #cfe1f8;
}

.repeat-entry span {
  display: block;
  margin-bottom: 5px;
  color: var(--primary-dark);
  font-size: 0.84rem;
  font-weight: 850;
}

.repeat-entry p {
  margin-bottom: 0;
  color: var(--text);
  line-height: 1.45;
}

.repeat-entry button {
  white-space: nowrap;
}

.search-panel {
  padding: 22px;
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.search-box input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 87, 214, 0.14);
}

.search-results {
  margin-top: 14px;
}

.search-count {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.search-result-list {
  display: grid;
  gap: 10px;
  max-height: 390px;
  overflow: auto;
  padding-right: 4px;
}

.search-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
}

.exam-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 20px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.94);
  box-shadow: var(--shadow);
  padding: 22px;
}

.exam-panel h2 {
  margin-bottom: 8px;
  font-size: 1.6rem;
}

.exam-panel p {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.exam-controls {
  display: grid;
  gap: 8px;
}

.exam-controls label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.theme-toggle {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 20;
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  border: 1px solid rgba(36,87,214,0.2);
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  color: var(--primary-dark);
  padding: 0;
  box-shadow: 0 10px 24px rgba(28, 43, 75, 0.12);
  font-size: 1rem;
  line-height: 1;
  opacity: 0.78;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.theme-toggle:hover {
  border-color: var(--primary);
  background: var(--soft-primary);
  color: var(--primary-dark);
  opacity: 1;
}

.exam-source {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft-primary);
  color: var(--primary-dark);
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 850;
}

.exam-result {
  margin-top: 18px;
  border: 1px solid #9fb4ea;
  border-radius: 8px;
  background: #f7f9ff;
  padding: 16px;
}

.exam-result h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.exam-result p {
  margin-bottom: 8px;
  color: var(--muted);
}

.exam-result strong {
  color: var(--primary-dark);
}

.app-footer {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding: 18px 4px 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: center;
}

.app-footer p {
  margin-bottom: 4px;
}

.chapter-select { display: grid; gap: 6px; min-width: 240px; }
.chapter-select label { color: var(--muted); font-size: 0.88rem; font-weight: 700; }

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 11px 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0;
}

.stats-grid > div, .question-map, .quiz-card, .summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.stats-grid > div { padding: 16px; }
.stats-grid span { display: block; font-size: 1.8rem; font-weight: 850; }
.stats-grid p, .summary p { margin-bottom: 0; color: var(--muted); }

.quiz-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.question-map {
  position: static;
  padding: 14px;
  overflow: hidden;
}
.quiz-card { min-width: 0; }
.map-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 800;
}
.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 8px;
  width: 100%;
}

.map-btn {
  min-width: 0;
  min-height: 38px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.map-btn.active { border-color: var(--primary); background: var(--soft-primary); color: var(--primary-dark); }
.map-btn.answered { border-color: #b7c7e5; background: #eef3fb; color: var(--primary-dark); }
.map-btn.correct { border-color: #9bd9b5; background: var(--ok-bg); color: var(--ok); }
.map-btn.wrong { border-color: #f1b6b6; background: var(--bad-bg); color: var(--bad); }
.map-btn.marked { box-shadow: inset 0 -3px 0 #f0b429; }

.quiz-card { min-height: 560px; padding: 24px; }
.progress-wrap { margin-bottom: 24px; }
.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: #e6edf7; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width 180ms ease; }

#questionText { margin-bottom: 10px; font-size: 1.35rem; line-height: 1.35; overflow-wrap: anywhere; }
.hint { min-height: 22px; margin-bottom: 14px; color: var(--warn); font-weight: 700; }
.answers { display: grid; gap: 10px; }

.answer-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: #fff;
  cursor: pointer;
  min-width: 0;
  overflow-wrap: anywhere;
}

.answer-option:hover { border-color: #9fb4ea; }
.answer-option input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }
.answer-option.correct { border-color: #76c998; background: var(--ok-bg); }
.answer-option.wrong { border-color: #ef9f9f; background: var(--bad-bg); }
.letter { font-weight: 850; }

.feedback {
  min-height: 48px;
  margin-top: 18px;
  border-radius: 8px;
  padding: 0;
  font-weight: 800;
}

.feedback.show { padding: 12px 14px; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }

.knowledge-panel {
  margin-top: 16px;
  border: 1px solid #cbd8f4;
  border-radius: 8px;
  background: #f7f9ff;
  padding: 14px;
  line-height: 1.55;
}

.knowledge-panel h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.knowledge-panel p {
  margin: 0 0 10px;
}

.knowledge-panel p:last-child {
  margin-bottom: 0;
}

.knowledge-panel strong {
  color: var(--primary-dark);
}

.actions, .summary-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

button {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 850;
  min-height: 44px;
}

button:hover { background: var(--primary-dark); }
button.secondary { border: 1px solid var(--line); background: #fff; color: var(--text); }
button.secondary:hover { border-color: #9fb4ea; background: #f7f9ff; }
button.danger { background: var(--bad); }
button.danger:hover { background: #9f2424; }
.mark-btn.active {
  border-color: #e7ad21;
  background: #fff7df;
  color: #8a5c00;
}
button:disabled { cursor: not-allowed; opacity: 0.55; }
button:disabled:hover {
  background: var(--primary);
}
button.secondary:disabled:hover {
  border-color: var(--line);
  background: #fff;
}

.search-result {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 0;
  border: 1px solid #d7e2f2;
  background: #fff;
  color: var(--text);
  padding: 14px;
  text-align: left;
  box-shadow: none;
}

.search-result:hover {
  border-color: #9fb4ea;
  background: #f7faff;
}

.search-result span {
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 850;
}

.search-result strong {
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.4;
}

.search-result small {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

body.dark-theme .cover-hero,
body.dark-theme .overview-grid > div,
body.dark-theme .chapter-hub,
body.dark-theme .chapter-card,
body.dark-theme .search-panel,
body.dark-theme .repeat-panel,
body.dark-theme .repeat-entry,
body.dark-theme .exam-panel,
body.dark-theme .stats-grid > div,
body.dark-theme .question-map,
body.dark-theme .quiz-card,
body.dark-theme .summary {
  background: rgba(21,31,51,0.96);
}

body.dark-theme .cover-hero {
  border-color: #3b5a89;
  background:
    linear-gradient(135deg, rgba(19,30,50,0.99) 0%, rgba(14,25,43,0.96) 48%, rgba(18,42,78,0.92) 100%),
    radial-gradient(circle at 82% 18%, rgba(79,140,255,0.32), transparent 32%);
}

body.dark-theme .cover-copy h1 {
  color: #edf3ff;
}

body.dark-theme .hero-subtitle {
  color: var(--muted);
}

body.dark-theme .badge-ring,
body.dark-theme .map-btn,
body.dark-theme .answer-option,
body.dark-theme .search-box input,
body.dark-theme select {
  background: #101827;
  color: var(--text);
}

body.dark-theme .search-box input {
  border-color: #40577a;
}

body.dark-theme .search-box input:focus {
  border-color: #7fb0ff;
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.2);
}

body.dark-theme .search-result {
  border-color: #31486a;
  background: #111b2e;
  color: var(--text);
}

body.dark-theme .search-result:hover {
  border-color: #7fb0ff;
  background: #172642;
}

body.dark-theme .search-result span {
  color: #9fc0ff;
}

body.dark-theme .search-result strong {
  color: #edf3ff;
}

body.dark-theme button {
  background: linear-gradient(135deg, #3478ff 0%, #5b9bff 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(52, 120, 255, 0.22);
}

body.dark-theme button:hover {
  background: linear-gradient(135deg, #5f9eff 0%, #86b8ff 100%);
}

body.dark-theme button.secondary {
  border-color: #40577a;
  background: #111b2e;
  color: #edf3ff;
  box-shadow: none;
}

body.dark-theme button.danger {
  background: linear-gradient(135deg, #e83f56 0%, #ff6b7a 100%);
}

body.dark-theme .theme-toggle {
  border-color: #415b82;
  background: rgba(19,31,52,0.78);
  color: #f6cf74;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26), inset 0 0 0 1px rgba(255,255,255,0.04);
}

body.dark-theme .theme-toggle:hover {
  border-color: #ffd36d;
  background: #203250;
  color: #ffe6a3;
}

body.dark-theme .map-btn.answered {
  border-color: #5571a6;
  background: #203251;
  color: #dbe6ff;
}

body.dark-theme .map-btn.active {
  border-color: #7fb0ff;
  background: #21447e;
  color: #ffffff;
}

body.dark-theme .map-btn.correct {
  border-color: #39e58d;
  background: #123f2b;
  color: #58f3a2;
}

body.dark-theme .map-btn.wrong {
  border-color: #ff6b7a;
  background: #4b1a25;
  color: #ff8b96;
}

body.dark-theme .map-btn.marked {
  box-shadow: inset 0 -3px 0 #ffd36d;
}

body.dark-theme .repeat-entry {
  background: linear-gradient(135deg, #162234, #111a28);
  border-color: #2a4566;
}

body.dark-theme .repeat-entry span {
  color: #9fc0ff;
}

body.dark-theme .mark-btn.active {
  border-color: #ffd36d;
  background: #36280d;
  color: #ffe6a3;
}

body.dark-theme .answer-option:hover {
  border-color: #6fa2ff;
}

body.dark-theme .answer-option.correct,
body.dark-theme .feedback.ok {
  border-color: #39e58d;
  background: #123f2b;
  color: #69f5ab;
}

body.dark-theme .answer-option.wrong,
body.dark-theme .feedback.bad {
  border-color: #ff6b7a;
  background: #4b1a25;
  color: #ff98a1;
}

body.dark-theme .book-stack span {
  background: linear-gradient(90deg, #162033, #223b60);
}

body.dark-theme .knowledge-panel,
body.dark-theme .exam-result {
  border-color: #47679b;
  background: #111f36;
}

body.dark-theme button.secondary:hover {
  border-color: #6fa2ff;
  background: #1a2a45;
}

body.dark-theme button.secondary:disabled:hover {
  background: #111b2e;
}

.summary { margin-top: 18px; padding: 20px; }
.summary h2 { margin-bottom: 6px; font-size: 1.18rem; }

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
    padding: 22px 0 32px;
  }

  .cover-hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 26px;
  }

  .exam-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .search-box {
    grid-template-columns: 1fr;
  }

  .cover-mark {
    justify-items: start;
  }

  .badge-ring {
    width: 140px;
    border-width: 12px;
  }

  .hub-header,
  .topbar, .summary {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .chapter-select {
    min-width: 0;
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0;
  }

  .map-grid {
    grid-template-columns: repeat(auto-fit, minmax(38px, 1fr));
  }

  .quiz-card {
    min-height: 0;
    padding: 20px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 16px;
    padding-bottom: 24px;
  }

  h1 {
    font-size: 1.55rem;
  }

  .cover-hero {
    padding: 20px;
  }

  .cover-hero::before {
    inset: 10px;
  }

  .cover-copy h1 {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 0.98rem;
  }

  .hero-actions,
  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .overview-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .overview-grid > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .chapter-hub {
    padding: 14px;
  }

  .chapter-cards {
    grid-template-columns: 1fr;
  }

  .repeat-entry {
    grid-template-columns: 1fr;
  }

  .repeat-entry button {
    width: 100%;
  }

  .eyebrow {
    font-size: 0.74rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stats-grid > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .stats-grid span {
    font-size: 1.45rem;
  }

  .stats-grid > div, .quiz-card, .question-map, .summary {
    padding: 14px;
  }

  .map-grid { grid-template-columns: repeat(auto-fit, minmax(36px, 1fr)); gap: 6px; }
  .map-btn { min-height: 34px; font-size: 0.9rem; }

  .progress-label {
    font-size: 0.84rem;
  }

  #questionText {
    font-size: 1.12rem;
  }

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

  .answer-option input {
    width: 20px;
    height: 20px;
  }

  .actions, .summary-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
    padding: 12px 14px;
  }

  .theme-toggle {
    width: 36px;
    padding: 0;
  }

  .knowledge-panel {
    padding: 12px;
  }
}

@media (max-width: 380px) {
  .app-shell {
    width: min(100% - 12px, 1180px);
  }

  .map-grid {
    grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
    gap: 5px;
  }

  .map-btn {
    min-height: 32px;
    border-radius: 7px;
    font-size: 0.82rem;
  }
}

@media (max-width: 760px) {
  body {
    background-attachment: fixed;
  }

  .landing-view,
  .quiz-view {
    gap: 14px;
  }

  .topbar {
    gap: 14px;
  }

  .topbar h1,
  .cover-copy h1 {
    overflow-wrap: break-word;
  }

  .quiz-layout {
    gap: 12px;
  }

  .question-map {
    max-height: 178px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .map-grid {
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  }

  .quiz-card {
    padding: 18px;
  }

  .progress-wrap {
    margin-bottom: 16px;
  }

  .answer-option {
    min-height: 50px;
  }

  .knowledge-panel,
  .feedback {
    font-size: 0.95rem;
  }

  .app-footer {
    text-align: left;
  }
}

@media (max-width: 460px) {
  .app-shell {
    width: calc(100% - 12px);
    padding-top: 10px;
  }

  .cover-hero,
  .search-panel,
  .exam-panel,
  .repeat-panel,
  .chapter-hub {
    padding: 14px;
  }

  .cover-hero {
    gap: 18px;
  }

  .cover-copy h1 {
    font-size: 1.75rem;
    line-height: 1.12;
  }

  .hero-subtitle,
  .exam-panel p,
  .hub-header > p {
    font-size: 0.94rem;
    line-height: 1.52;
  }

  .cover-mark {
    grid-template-columns: auto 1fr;
    justify-items: start;
    align-items: center;
    gap: 12px;
  }

  .badge-ring {
    width: 76px;
    border-width: 7px;
  }

  .badge-ring span {
    font-size: 1.08rem;
  }

  .book-stack {
    width: min(128px, 100%);
    gap: 5px;
  }

  .book-stack span {
    height: 14px;
    border-radius: 6px;
  }

  .hub-header h2,
  .exam-panel h2,
  .summary h2 {
    font-size: 1.22rem;
  }

  .chapter-card,
  .search-result {
    padding: 12px;
  }

  .question-map {
    max-height: 154px;
    padding: 10px;
  }

  .map-grid {
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 5px;
  }

  .map-btn {
    min-height: 34px;
    padding: 7px 4px;
  }

  .quiz-card {
    padding: 14px;
  }

  #questionText {
    font-size: 1.06rem;
    line-height: 1.42;
  }

  .answer-option {
    grid-template-columns: 24px 1fr;
    gap: 9px;
    padding: 11px;
  }

  .actions {
    gap: 8px;
  }

  .theme-toggle {
    left: 10px;
    bottom: 10px;
  }
}

@media (max-width: 340px) {
  .map-grid {
    grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  }

  .map-btn {
    min-height: 30px;
    font-size: 0.78rem;
  }

  .answer-option {
    padding: 10px;
  }
}
