:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  color: #17332a;
  background: #f3f7f5;
  font-synthesis: none;
  --primary: #16785b;
  --primary-dark: #0f5c45;
  --surface: #ffffff;
  --surface-soft: #eaf4f0;
  --border: #cfe0da;
  --muted: #62766f;
  --danger: #bd3030;
  --warning: #b45f06;
  --shadow: 0 14px 40px rgb(24 70 55 / 10%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f3f7f5;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at top right, rgb(22 120 91 / 12%), transparent 34rem),
    #f3f7f5;
}

button,
input,
select {
  font: inherit;
}

button,
.button {
  min-height: 44px;
  min-width: 44px;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #f0a43a;
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(24px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(32px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.welcome-card {
  margin-top: clamp(40px, 14vh, 120px);
  padding: clamp(24px, 6vw, 48px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 1.08;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}

.button:hover {
  background: var(--primary-dark);
}

.button.secondary {
  color: var(--primary-dark);
  background: var(--surface-soft);
}

.button.danger {
  background: var(--danger);
}

.confirm-dialog {
  width: min(calc(100% - 32px), 420px);
  padding: 24px;
  border: 0;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgb(10 34 27 / 52%);
}

.confirm-dialog h2 {
  margin-top: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.notice {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  z-index: 20;
  width: min(calc(100% - 32px), 560px);
  margin-inline: auto;
}

@media (min-width: 720px) {
  .app-shell {
    padding-inline: 24px;
  }
}

.home-header,
.page-header,
.quiz-topbar,
.section-heading,
.wrong-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.home-header {
  align-items: flex-start;
  margin-bottom: 24px;
}

.bank-switcher {
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(24 70 55 / 6%);
}

.bank-switcher > summary {
  padding: 14px 16px;
  color: var(--primary-dark);
  font-weight: 750;
  cursor: pointer;
}

.bank-choice-list {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.bank-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: inherit;
  text-align: left;
  background: #fbfdfc;
}

.bank-choice > span:first-child {
  display: grid;
  gap: 3px;
}

.bank-choice small {
  color: var(--muted);
}

.bank-choice.selected {
  border-color: var(--primary);
  background: var(--surface-soft);
}

.home-header h1,
.page-header h1 {
  margin: 0;
}

.home-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}

.offline-badge,
.count-badge,
.type-badge,
.wrong-count,
.frequent-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.importance-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.importance-badge.important {
  color: #8a3f00;
  background: #ffe3bd;
}

.importance-badge.overview {
  color: #2f5d7a;
  background: #e2f0f8;
}

.offline-badge {
  color: var(--primary-dark);
  background: #dff1ea;
}

.summary-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 28px;
  padding: 18px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-card div {
  display: grid;
  gap: 4px;
  padding: 0 8px;
  text-align: center;
}

.summary-card div + div {
  border-left: 1px solid var(--border);
}

.summary-card strong {
  font-size: clamp(1.2rem, 5vw, 1.65rem);
}

.summary-card span,
.section-heading span {
  color: var(--muted);
  font-size: 0.78rem;
}

.section-heading {
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.12rem;
}

.module-list {
  display: grid;
  gap: 12px;
}

.module-card {
  display: grid;
  grid-template-columns: 48px 1fr auto 20px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: inherit;
  text-align: left;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(24 70 55 / 6%);
  cursor: pointer;
}

.module-card:hover {
  border-color: #86baa9;
  transform: translateY(-1px);
}

.module-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  background: var(--primary);
}

.module-card.blue .module-icon {
  background: #2f6bb2;
}

.module-card.red .module-icon {
  background: #b74747;
}

.module-card.orange .module-icon {
  background: #b66a18;
}

.module-copy {
  display: grid;
  gap: 4px;
}

.module-copy strong {
  font-size: 1rem;
}

.module-copy small,
.module-progress {
  color: var(--muted);
}

.module-progress {
  font-size: 0.82rem;
  font-weight: 700;
}

.module-arrow {
  color: #8aa098;
  font-size: 1.6rem;
}

.home-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.text-button,
.icon-button {
  border: 0;
  color: var(--primary-dark);
  background: transparent;
  cursor: pointer;
}

.text-button {
  padding: 8px;
  font-size: 0.86rem;
  font-weight: 700;
}

.danger-text {
  color: var(--danger);
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgb(24 70 55 / 8%);
  font-size: 1.35rem;
}

.page-header {
  margin-bottom: 24px;
}

.page-header > div {
  flex: 1;
}

.page-header .eyebrow {
  margin-bottom: 2px;
}

.quiz-topbar {
  position: sticky;
  top: max(0px, env(safe-area-inset-top));
  z-index: 10;
  margin: calc(-1 * max(24px, env(safe-area-inset-top))) -16px 14px;
  padding:
    max(12px, env(safe-area-inset-top))
    16px
    12px;
  border-bottom: 1px solid var(--border);
  background: rgb(243 247 245 / 94%);
  backdrop-filter: blur(12px);
}

.quiz-title {
  display: grid;
  flex: 1;
  text-align: center;
}

.quiz-title span {
  color: var(--muted);
  font-size: 0.78rem;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 12px;
  padding: 12px 6px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.stats-strip div {
  display: grid;
  gap: 2px;
  text-align: center;
}

.stats-strip strong {
  font-size: 1rem;
}

.stats-strip span {
  color: var(--muted);
  font-size: 0.72rem;
}

.coverage-line {
  margin-bottom: 12px;
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.question-card,
.wrong-card,
.state-card {
  padding: clamp(18px, 5vw, 28px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.question-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.type-badge {
  color: var(--primary-dark);
  background: #dff1ea;
}

.wrong-count {
  color: #775332;
  background: #f6eadc;
}

.frequent-badge {
  color: #8a3f00;
  background: #ffe3bd;
}

.question-text {
  margin: 0 0 22px;
  font-size: clamp(1.15rem, 4.8vw, 1.45rem);
  line-height: 1.58;
}

.option-list {
  display: grid;
  gap: 12px;
}

.option {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: inherit;
  text-align: left;
  background: #fbfdfc;
  cursor: pointer;
}

.option:not(:disabled):hover {
  border-color: #75ac99;
  background: var(--surface-soft);
}

.option:disabled {
  opacity: 1;
  cursor: default;
}

.option-key {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  color: var(--primary-dark);
  background: var(--surface-soft);
  font-weight: 800;
}

.option.correct {
  border-color: #4f9b75;
  background: #e5f6ed;
}

.option.correct .option-key {
  color: #fff;
  background: #27825b;
}

.option.wrong {
  border-color: #d36565;
  background: #fff0f0;
}

.option.wrong .option-key {
  color: #fff;
  background: var(--danger);
}

.option-result {
  font-size: 0.75rem;
  font-weight: 800;
}

.option.correct .option-result {
  color: #17663f;
}

.option.wrong .option-result {
  color: var(--danger);
}

.answer-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.explanation {
  margin-top: 20px;
  padding: 16px;
  border-radius: 15px;
  line-height: 1.7;
}

.explanation.success {
  color: #185d3d;
  background: #e7f5ed;
}

.explanation.error {
  color: #7c2727;
  background: #fff0f0;
}

.explanation p {
  margin: 8px 0 0;
}

.reveal-button {
  width: 100%;
}

.study-answer {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 1rem;
  line-height: 1.85;
}

.study-answer > h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

.answer-section + .answer-section {
  margin-top: 24px;
}

.answer-section h3 {
  margin: 0 0 12px;
  color: var(--primary-dark);
  font-size: 1.05rem;
}

.answer-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
}

.answer-item + .answer-item {
  margin-top: 14px;
}

.answer-item p {
  margin: 0;
}

.answer-number {
  min-width: 28px;
  color: var(--primary-dark);
  font-weight: 800;
}

.answer-lead {
  color: #17332a;
}

.answer-media {
  margin: 0 0 22px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fbfa;
}

.answer-media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
}

.answer-media figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.media-error {
  margin: 0;
  padding: 14px;
  color: var(--danger);
  text-align: center;
}

.mastery-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.mastered-button {
  background: var(--primary);
}

.unmastered-button {
  background: var(--warning);
}

.evaluation-result {
  margin: 18px 0 0;
  padding: 12px;
  border-radius: 12px;
  font-weight: 750;
  text-align: center;
}

.evaluation-result.mastered {
  color: #17663f;
  background: #e5f6ed;
}

.evaluation-result.unmastered {
  color: #8a3f00;
  background: #fff0d8;
}

.jump-dot.mastered {
  color: #17663f;
  background: #e5f6ed;
}

.jump-dot.unmastered {
  color: #8a3f00;
  background: #fff0d8;
}

.jump-panel {
  margin: 14px 0 92px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.jump-panel summary,
.wrong-explanation summary {
  color: var(--primary-dark);
  font-weight: 750;
  cursor: pointer;
}

.jump-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.jump-dot {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: #f7faf9;
}

.jump-dot.correct {
  color: #17663f;
  background: #e5f6ed;
}

.jump-dot.wrong {
  color: #8e2626;
  background: #fff0f0;
}

.jump-dot.current {
  outline: 3px solid #e7a84f;
  outline-offset: 1px;
}

.jump-dot:disabled {
  opacity: 0.4;
}

.quiz-actions {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: 0;
  left: max(16px, env(safe-area-inset-left));
  z-index: 8;
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 12px;
  width: min(calc(100% - 32px), 728px);
  margin-inline: auto;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, #f3f7f5 22%);
}

.quiz-actions .button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wrong-list {
  display: grid;
  gap: 16px;
}

.unmastered-list {
  display: grid;
  gap: 16px;
}

.wrong-card h2 {
  margin: 14px 0;
  font-size: 1.05rem;
  line-height: 1.55;
}

.correct-answer {
  padding: 12px;
  border-radius: 12px;
  color: #17663f;
  background: #e5f6ed;
  font-weight: 750;
}

.wrong-options {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.wrong-options li {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-left: 4px solid #d36565;
  border-radius: 8px;
  background: #fff5f5;
}

.wrong-options span,
.wrong-time {
  color: var(--muted);
  font-size: 0.8rem;
}

.wrong-explanation {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #f4f8f6;
}

.wrong-explanation p {
  line-height: 1.7;
}

.wrong-time {
  margin: 14px 0 0;
}

.state-card {
  margin-top: 40px;
  text-align: center;
}

.empty-state > span {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  font-size: 2rem;
}

.error-state {
  border-color: #efbaba;
}

.notice.visible {
  padding: 13px 16px;
  border-radius: 13px;
  color: #fff;
  background: #264f42;
  box-shadow: var(--shadow);
}

.notice.error {
  background: #8f3030;
}

.notice.success {
  background: #17663f;
}

@media (max-width: 480px) {
  .module-card {
    grid-template-columns: 44px 1fr 20px;
  }

  .module-progress {
    grid-column: 2;
    grid-row: 2;
  }

  .module-arrow {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .option {
    grid-template-columns: 36px 1fr;
  }

  .option-result {
    grid-column: 2;
  }

  .mastery-actions {
    grid-template-columns: 1fr;
  }

  .answer-item {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
