:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: #f5f7fb;
  color: #172033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

[hidden] {
  display: none !important;
}

button {
  border: 1px solid #c8d1df;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  cursor: pointer;
  font: inherit;
  min-height: 40px;
  padding: 8px 14px;
}

input {
  border: 1px solid #c8d1df;
  border-radius: 8px;
  color: inherit;
  font: inherit;
  min-height: 42px;
  padding: 8px 12px;
  width: 100%;
}

button:hover:not(:disabled) {
  border-color: #3b73ff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  margin: 0 auto;
  max-width: 980px;
  padding: 28px 20px 36px;
}

.auth-gate {
  align-items: center;
  display: flex;
  min-height: 100vh;
  padding: 20px;
}

.page-anchor {
  height: 0;
  overflow: hidden;
}

.auth-panel {
  background: #fff;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(27, 45, 78, 0.08);
  display: grid;
  gap: 12px;
  margin: 0 auto;
  max-width: 380px;
  padding: 24px;
  width: 100%;
}

.auth-panel h1 {
  margin-bottom: 0;
}

.auth-panel p {
  color: #60708a;
  line-height: 1.6;
}

.auth-panel label {
  color: #365380;
  font-size: 14px;
}

.auth-error {
  color: #b42318;
  min-height: 22px;
}

.topbar {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar-controls {
  align-items: flex-end;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 8px;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
  margin: 0 0 8px;
}

p {
  margin: 0;
}

#bankSummary,
#storageHint {
  color: #60708a;
  font-size: 14px;
}

.bank-tabs,
.mode-tabs {
  background: #e8edf5;
  border-radius: 8px;
  display: flex;
  gap: 4px;
  padding: 4px;
}

.bank-tabs button,
.mode-tabs button {
  background: transparent;
  border: 0;
}

.bank-tabs button.active,
.mode-tabs button.active {
  background: #fff;
  box-shadow: 0 1px 4px rgba(27, 45, 78, 0.14);
}

.stats-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.stats-row div {
  background: #fff;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  padding: 12px;
}

.stats-row span {
  color: #60708a;
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.stats-row strong {
  font-size: 24px;
}

.coverage-panel {
  background: #fff;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 14px;
}

.coverage-header,
.coverage-detail {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.coverage-header {
  margin-bottom: 10px;
}

.coverage-header span {
  color: #265ff5;
  font-weight: 700;
}

.coverage-track {
  background: #e8edf5;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.coverage-bar {
  background: #265ff5;
  border-radius: inherit;
  height: 100%;
  transition: width 160ms ease;
  width: 0%;
}

.coverage-detail {
  color: #60708a;
  font-size: 13px;
  margin-top: 8px;
}

.quiz-card,
.empty-state {
  background: #fff;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(27, 45, 78, 0.08);
  padding: 22px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.question-meta span {
  background: #eef3ff;
  border-radius: 999px;
  color: #365380;
  font-size: 13px;
  padding: 4px 10px;
}

#questionText {
  font-size: 22px;
  font-weight: 650;
  line-height: 1.55;
  margin: 0 0 20px;
  overflow-wrap: anywhere;
}

.answer-area {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.answer-input {
  border: 1px solid #c8d1df;
  border-radius: 8px;
  font: inherit;
  min-height: 92px;
  padding: 12px;
  resize: vertical;
  width: 100%;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.answer-box,
.feedback {
  border-radius: 8px;
  line-height: 1.6;
  padding: 12px;
  white-space: pre-wrap;
}

.answer-box {
  background: #f8fafc;
  border: 1px solid #dfe5ee;
  height: 84px;
  overflow: auto;
}

.feedback {
  background: #fff7e6;
  border: 1px solid #f4d58d;
  height: 72px;
  margin-bottom: 14px;
  overflow: auto;
  overflow-wrap: anywhere;
}

.is-placeholder {
  visibility: hidden;
}

.feedback.correct {
  background: #edf8ef;
  border-color: #9ad5a5;
}

.feedback.wrong {
  background: #fff0f0;
  border-color: #eca3a3;
}

.actions,
.footer-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auto-next-toggle {
  align-items: center;
  color: #365380;
  display: inline-flex;
  gap: 6px;
  min-height: 40px;
  padding: 0 4px;
}

.auto-next-toggle input {
  height: 16px;
  width: 16px;
}

.primary {
  background: #265ff5;
  border-color: #265ff5;
  color: #fff;
}

.footer-actions {
  margin-top: 16px;
}

.empty-state h2 {
  margin: 0 0 10px;
}

.empty-state p {
  color: #60708a;
  line-height: 1.7;
  margin-bottom: 16px;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px 12px 28px;
  }

  .topbar {
    display: block;
  }

  .topbar-controls {
    align-items: stretch;
    margin-top: 14px;
  }

  .mode-tabs {
    width: 100%;
  }

  .mode-tabs button {
    flex: 1;
  }

  .stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .coverage-detail {
    align-items: flex-start;
    flex-direction: column;
  }

  #questionText {
    font-size: 19px;
  }
}

/* Retain the original layout and controls, with larger reading and touch targets. */
:root { font-size: 19px; }
.app-shell { max-width: 1240px; padding: 30px 24px 40px; }
.topbar { display: block; }
.topbar-controls { align-items: flex-start; margin-top: 20px; margin-bottom: 22px; gap: 12px; }
.bank-tabs, .mode-tabs { flex-wrap: wrap; }
.bank-tabs button, .mode-tabs button { font-size: 17px; min-height: 46px; padding: 10px 14px; }
.bank-tabs small { color: #60708a; font-size: 14px; margin-left: 7px; }
h1 { font-size: 36px; }
#bankSummary, #storageHint { font-size: 17px; line-height: 1.8; }
.stats-row { gap: 12px; margin-bottom: 20px; }
.stats-row div { padding: 16px; }
.stats-row span { font-size: 17px; }
.stats-row strong { font-size: 30px; }
.coverage-panel { padding: 18px; margin-bottom: 20px; }
.coverage-detail { font-size: 16px; }
.quiz-card, .empty-state { padding: 28px; }
.question-meta span { font-size: 16px; padding: 5px 12px; }
#questionText { font-size: 27px; line-height: 1.65; white-space: pre-wrap; }
button { min-height: 48px; padding: 10px 18px; }
.choice-row button { font-size: 22px; min-width: 130px; min-height: 56px; }
.question-options { display: grid; gap: 10px; margin-bottom: 4px; }
.question-option { padding: 12px 16px; border: 1px solid #dfe5ee; border-radius: 8px; font-size: 21px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-input { font-size: 19px; min-height: 100px; }
.answer-box { height: 130px; font-size: 19px; }
.feedback { height: 120px; font-size: 19px; }
.auto-next-toggle { font-size: 17px; min-height: 44px; }
.auto-next-toggle input { height: 19px; width: 19px; min-height: 19px; accent-color: #265ff5; }
.footer-actions button { font-size: 17px; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #9db9ff; outline-offset: 3px; }
@media (max-width: 720px) {
  :root { font-size: 17px; }
  .app-shell { padding: 20px 12px 30px; }
  h1 { font-size: 29px; }
  .topbar-controls { align-items: stretch; }
  .bank-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bank-tabs button, .mode-tabs button { font-size: 15px; padding: 9px 10px; min-height: 44px; }
  .mode-tabs button { flex: 1 1 auto; }
  .stats-row div { padding: 13px; }
  .stats-row strong { font-size: 28px; }
  #bankSummary, #storageHint { font-size: 16px; }
  .coverage-detail { font-size: 15px; }
  .quiz-card, .empty-state { padding: 20px 16px; }
  #questionText { font-size: 23px; }
  .question-meta span { font-size: 14px; }
  .question-option { font-size: 19px; padding: 10px 12px; }
  .answer-input, .answer-box, .feedback { font-size: 17px; }
  .actions { gap: 10px; }
  .actions button { font-size: 17px; min-height: 46px; padding: 9px 13px; }
  .auto-next-toggle { font-size: 16px; }
  .footer-actions button { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.choice-hint { color: #60708a; font-size: 16px; }
button.question-option { width: 100%; text-align: left; display: flex; align-items: flex-start; gap: 12px; }
button.question-option::before { content: '○'; flex: 0 0 auto; color: #60708a; }
button.question-option[aria-pressed="true"] { background: #eef3ff; border-color: #265ff5; }
button.question-option[aria-pressed="true"]::before { content: '●'; color: #265ff5; }
.question-options:has(button) { min-width: 0; }
button.question-option:disabled { opacity: 1; }
button.question-option.is-correct { border-color: #45985a; background: #edf8ef; }
button.question-option.is-correct::before { content: '✓'; color: #26703a; }
button.question-option.is-wrong { border-color: #d85a5a; background: #fff0f0; }
button.question-option.is-wrong::before { content: '✕'; color: #b42318; }
.feedback:not(.is-placeholder) { height: auto; min-height: 120px; }

.multiple button.question-option::before { content: "□"; }
.multiple button.question-option[aria-pressed="true"]::before { content: "☑"; }
.multiple button.question-option.is-correct::before { content: "✓"; }
.multiple button.question-option.is-wrong::before { content: "✕"; }
