:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --panel: #ffffff;
  --panel-strong: #eef6f1;
  --ink: #17201d;
  --muted: #66736f;
  --line: #dbe4df;
  --primary: #1f5d50;
  --primary-strong: #123f37;
  --accent: #df6f52;
  --gold: #c9971f;
  --blue: #4169a8;
  --danger: #b94747;
  --ok: #22734f;
  --shadow: 0 14px 40px rgba(23, 32, 29, 0.08);
  --radius: 8px;
  font-family:
    "Hannotate SC", "HanziPen SC", "Yuppy SC", "Comic Sans MS", "Marker Felt", "Kaiti SC",
    "STKaiti", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: #fbf1d9;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 14px 14px, rgba(23, 32, 29, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, #fff9e9 0, #fbf0d8 52%, #f7e7c7 100%);
  background-size: 28px 28px, auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  max-width: 920px;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 16px 16px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: none;
  display: grid;
  grid-template-columns: 48px 1fr 44px;
  gap: 12px;
  align-items: center;
  padding: 10px 0 18px;
}

main {
  flex: 1;
  min-height: 0;
  padding-bottom: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

main::-webkit-scrollbar {
  display: none;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 3px solid #17201d;
  border-radius: 15px 12px 17px 11px;
  color: #ffffff;
  background: var(--primary);
  box-shadow: 4px 5px 0 rgba(23, 32, 29, 0.18);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: 0;
}

.icon-button,
.nav-item,
.choice,
.task-row,
.pill-button,
.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--primary);
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: 13px 10px 15px 11px;
  box-shadow: 3px 4px 0 rgba(23, 32, 29, 0.12);
}

.icon-button svg,
.nav-item svg,
.button-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.band {
  margin-bottom: 14px;
  padding: 16px;
  background: #fffaf0;
  border: 2px solid var(--ink);
  border-radius: 16px 12px 18px 13px;
  box-shadow: 5px 7px 0 rgba(23, 32, 29, 0.12);
}

.band.soft {
  background: #eef7ef;
  box-shadow: 4px 5px 0 rgba(23, 32, 29, 0.09);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
}

.countdown-box {
  display: grid;
  min-height: 132px;
  align-content: space-between;
  padding: 16px;
  color: #ffffff;
  background: var(--primary);
  border: 2px solid var(--ink);
  border-radius: 16px 12px 18px 13px;
  box-shadow: 5px 6px 0 rgba(23, 32, 29, 0.16);
}

.countdown-box .big {
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.countdown-box .sub {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.45;
}

.goal-box {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 16px;
  background: #fff7eb;
  border: 2px solid var(--ink);
  border-radius: 14px 18px 12px 16px;
}

.goal-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(201, 151, 31, 0.2);
  color: #593f0d;
}

.goal-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title p,
.muted {
  color: var(--muted);
}

.muted,
.section-title p {
  margin-bottom: 0;
  line-height: 1.5;
}

.focus-list,
.recite-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.focus-list li,
.recite-list li {
  padding: 10px 12px;
  background: #f8fbfa;
  border: 2px solid rgba(23, 32, 29, 0.55);
  border-radius: 12px 10px 14px 9px;
  line-height: 1.45;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  text-align: left;
  color: var(--ink);
  background: #ffffff;
  border: 2px solid rgba(23, 32, 29, 0.65);
  border-radius: 13px 11px 15px 10px;
}

.task-row.done {
  border-color: rgba(34, 115, 79, 0.35);
  background: #f0faf3;
}

.task-check {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #ffffff;
  background: #c5d0cb;
  border: 2px solid rgba(23, 32, 29, 0.25);
  border-radius: 10px 8px 11px 7px;
}

.task-row.done .task-check {
  background: var(--ok);
}

.task-minutes {
  color: var(--muted);
  white-space: nowrap;
}

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

.metric {
  padding: 12px;
  background: #f8fbfa;
  border: 2px solid rgba(23, 32, 29, 0.45);
  border-radius: 12px 10px 14px 9px;
}

.metric strong {
  display: block;
  margin-bottom: 4px;
  font-size: 22px;
}

.module-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 74px 1fr 52px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  background: #e5ece8;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.bar-fill.blue {
  background: var(--blue);
}

.bar-fill.gold {
  background: var(--gold);
}

.reminder-row,
.filter-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.reminder-row input,
.filter-row select,
.subjective-select {
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.primary-button,
.secondary-button,
.danger-button,
.pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 2px 3px 0 rgba(23, 32, 29, 0.13);
  line-height: 1;
}

.primary-button {
  color: #ffffff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  color: var(--primary);
  background: #ffffff;
  border: 2px solid var(--ink);
}

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

.pill-button {
  min-height: 36px;
  color: var(--primary);
  background: #edf7f2;
  border: 1px solid #cde1d8;
}

.flashcard {
  display: grid;
  gap: 14px;
  min-height: 280px;
  padding: 18px;
  background: #ffffff;
  border: 2px solid var(--ink);
  border-radius: 18px 13px 20px 12px;
  box-shadow: 5px 6px 0 rgba(23, 32, 29, 0.12);
}

.card-meta,
.question-meta,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  color: var(--primary);
  background: #eef7f2;
  border: 2px solid rgba(31, 93, 80, 0.4);
  border-radius: 999px;
  font-size: 12px;
}

.badge.gold {
  color: #66480a;
  background: #fff6df;
  border-color: #ecd28d;
}

.badge.red {
  color: #7c2e2e;
  background: #fff1ef;
  border-color: #efc7c0;
}

.flashcard h3 {
  margin-bottom: 0;
  font-size: 22px;
}

.flashcard .front,
.flashcard .back {
  margin-bottom: 0;
  line-height: 1.65;
}

.flashcard .back {
  padding: 12px;
  background: #f8fbfa;
  border: 2px dashed #7c958a;
  border-radius: 14px 10px 13px 12px;
}

.question-panel {
  display: grid;
  gap: 14px;
}

.question-stem {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.55;
}

.choices {
  display: grid;
  gap: 10px;
}

.choice {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
  background: #ffffff;
  border: 2px solid var(--ink);
  border-radius: 14px 12px 15px 10px;
  box-shadow: 2px 3px 0 rgba(23, 32, 29, 0.08);
}

.choice.selected {
  border-color: var(--primary);
  background: #fff1bc;
}

.choice.correct {
  border-color: #22734f;
  background: #dff5e7;
}

.choice.wrong {
  border-color: #b94747;
  background: #ffe0dc;
}

.choice-key {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--primary);
  background: #eef7f2;
  border-radius: 8px;
  font-weight: 700;
}

.explanation {
  padding: 12px;
  background: #f7faf8;
  border: 2px dashed var(--primary);
  border-left-width: 5px;
  border-radius: 12px 10px 14px 9px;
  line-height: 1.6;
}

.textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 12px;
  color: var(--ink);
  background: #ffffff;
  border: 2px solid var(--ink);
  border-radius: 14px 11px 16px 12px;
  line-height: 1.65;
}

.score-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #f8fbfa;
  border: 2px dashed var(--primary);
  border-radius: 14px 11px 16px 12px;
}

.result-banner {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 38px;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-weight: 800;
  transform: rotate(-1deg);
  box-shadow: 3px 4px 0 rgba(23, 32, 29, 0.12);
}

.result-banner.right {
  color: #174d35;
  background: #cfeedd;
}

.result-banner.wrong {
  color: #7b2e2e;
  background: #ffd7d2;
}

.option-analysis,
.distinction-list,
.drill-list {
  display: grid;
  gap: 10px;
}

.analysis-row,
.distinction-item,
.drill-item {
  padding: 10px 12px;
  background: #fffaf0;
  border: 2px solid rgba(23, 32, 29, 0.45);
  border-radius: 13px 10px 15px 9px;
}

.analysis-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: start;
}

.analysis-row strong {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.analysis-row p,
.distinction-item span,
.distinction-item em,
.drill-item p {
  margin: 0;
  line-height: 1.55;
}

.analysis-row.correct,
.analysis-row.correct-selected {
  background: #e3f6e9;
  border-color: #2e7351;
}

.analysis-row.wrong {
  background: #ffe3df;
  border-color: #b94747;
}

.recite-detail {
  display: grid;
  gap: 12px;
}

.recite-detail[hidden] {
  display: none;
}

.recite-detail > p {
  margin-bottom: 0;
  line-height: 1.65;
}

.distinction-item {
  display: grid;
  gap: 5px;
}

.distinction-item strong {
  color: var(--primary);
}

.distinction-item em {
  color: #7a5531;
  font-style: normal;
}

.drill-item summary {
  cursor: pointer;
  font-weight: 800;
  line-height: 1.45;
}

.bottom-nav {
  flex: none;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid var(--ink);
  border-radius: 18px 14px 17px 13px;
  box-shadow: 5px 7px 0 rgba(23, 32, 29, 0.14);
  backdrop-filter: blur(14px);
}

.nav-item {
  display: grid;
  gap: 4px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: 12px 10px 14px 9px;
  font-size: 12px;
}

.nav-item.active {
  color: #ffffff;
  background: var(--primary);
}

.empty {
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
  background: #f8fbfa;
  border: 1px dashed #bdcbc5;
  border-radius: var(--radius);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 680px) {
  .app-shell {
    padding: 12px 12px max(8px, env(safe-area-inset-bottom));
  }

  .hero-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 68px 1fr 46px;
  }

  .task-row {
    grid-template-columns: 26px 1fr;
  }

  .task-minutes {
    grid-column: 2;
  }

  .bottom-nav {
    gap: 4px;
    padding: 6px;
  }

  .nav-item {
    min-height: 40px;
    gap: 2px;
    font-size: 11px;
  }

  .nav-item svg {
    width: 18px;
    height: 18px;
  }

}

@media (min-width: 760px) {
  .two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}
