:root {
  color-scheme: light;
  --ink: #20211d;
  --muted: #696c63;
  --paper: #f7f3ec;
  --surface: #fffdf9;
  --sage: #a8b9a3;
  --sage-dark: #496150;
  --coral: #ee8b73;
  --coral-dark: #9b4635;
  --plum: #6e536c;
  --lavender: #ddd1e2;
  --sun: #f1c66f;
  --line: rgba(32, 33, 29, 0.12);
  --shadow: 0 18px 60px rgba(53, 48, 42, 0.1);
  --font-scale: 1;
  --line-spacing: 1.65;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 86% -5%, rgba(238, 139, 115, 0.18), transparent 28rem),
    radial-gradient(circle at -10% 45%, rgba(168, 185, 163, 0.22), transparent 25rem),
    var(--paper);
}

body {
  min-height: 100dvh;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(110, 83, 108, 0.32);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 780px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 13px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
  letter-spacing: -0.08em;
}

.brand-word {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.profile-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.75);
  padding: 6px 7px 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--lavender);
  color: var(--plum);
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--sage-dark);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.035em;
}

h1 {
  max-width: 620px;
  margin-bottom: 12px;
  font-size: clamp(2.3rem, 9vw, 4.4rem);
  line-height: 0.98;
  font-weight: 500;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  line-height: 1.08;
  font-weight: 500;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.02rem;
}

.lede,
.muted {
  color: var(--muted);
  line-height: 1.55;
}

.lede {
  max-width: 580px;
  font-size: 1.03rem;
}

.hero {
  margin: 10px 0 28px;
}

.hero-row,
.section-heading,
.stat-row,
.voucher-row,
.mission-meta,
.inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading {
  margin: 30px 0 14px;
}

.section-heading h2,
.section-heading h3,
.section-heading p {
  margin: 0;
}

.status-pills,
.chips,
.choice-grid,
.stats-grid,
.dashboard-grid,
.feedback-grid {
  display: grid;
  gap: 10px;
}

.status-pills {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 22px;
}

.pill-stat,
.mini-stat {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.7);
  padding: 14px;
}

.pill-stat strong,
.mini-stat strong {
  display: block;
  margin-bottom: 3px;
  font-size: 1.18rem;
}

.pill-stat span,
.mini-stat span {
  color: var(--muted);
  font-size: 0.76rem;
}

.choice-grid {
  grid-template-columns: 1fr;
}

.lesson-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 172px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  padding: 20px;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.lesson-card::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -48px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: var(--accent, var(--sage));
  opacity: 0.28;
}

.lesson-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 70px rgba(53, 48, 42, 0.14);
}

.lesson-card h3 {
  max-width: 85%;
  margin: 16px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
  line-height: 1.1;
}

.card-number {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: rgba(32, 33, 29, 0.06);
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 700;
}

.primary,
.secondary,
.text-button,
.icon-button,
.feedback-button {
  min-height: 48px;
  border-radius: 15px;
  padding: 12px 17px;
  font-weight: 750;
}

.primary {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
}

.primary.coral {
  border-color: var(--coral-dark);
  background: var(--coral);
  color: var(--ink);
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.text-button,
.icon-button {
  border: 0;
  background: transparent;
  color: var(--plum);
}

.icon-button {
  display: grid;
  width: 48px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
}

.full-width {
  width: 100%;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 780px);
  margin: 0 auto;
  border-top: 1px solid var(--line);
  background: rgba(247, 243, 236, 0.92);
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  backdrop-filter: blur(18px);
}

.nav-button {
  min-height: 55px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.nav-button span {
  display: block;
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.nav-button.active {
  background: var(--surface);
  color: var(--ink);
}

.panel,
.callout,
.upload-zone,
.question-card,
.voucher-card,
.reading-panel,
.result-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  padding: 20px;
}

.panel + .panel,
.voucher-card + .voucher-card {
  margin-top: 12px;
}

.callout {
  border-color: rgba(73, 97, 80, 0.25);
  background: rgba(168, 185, 163, 0.18);
}

.callout.coral {
  border-color: rgba(155, 70, 53, 0.22);
  background: rgba(238, 139, 115, 0.14);
}

.progress-track {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: rgba(32, 33, 29, 0.08);
}

.progress-track > span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
  transition: width 280ms ease;
}

.mission-screen {
  min-height: calc(100dvh - 48px);
}

.mission-header {
  position: sticky;
  z-index: 10;
  top: 0;
  margin: -18px -18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 243, 236, 0.94);
  padding: max(18px, env(safe-area-inset-top)) 18px 13px;
  backdrop-filter: blur(18px);
}

.mission-meta {
  margin-bottom: 10px;
}

.stage-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reading-panel {
  font-size: calc(1.05rem * var(--font-scale));
  line-height: var(--line-spacing);
}

.reading-panel p {
  margin-bottom: 1.3em;
}

.vocab-word {
  border-bottom: 2px solid var(--sun);
  background: rgba(241, 198, 111, 0.15);
}

.vocab-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.vocab-card:last-child {
  border: 0;
}

.vocab-index {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 13px;
  background: var(--lavender);
  color: var(--plum);
  font-weight: 800;
}

.question-card {
  margin-bottom: 14px;
}

.answer-option {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 11px 13px;
  color: var(--ink);
  text-align: left;
}

.answer-option.selected {
  border-color: var(--plum);
  background: rgba(221, 209, 226, 0.38);
}

.answer-letter {
  display: grid;
  flex: 0 0 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: rgba(32, 33, 29, 0.06);
  font-size: 0.78rem;
  font-weight: 800;
}

label {
  display: block;
  margin-bottom: 15px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 13px 14px;
  color: var(--ink);
}

textarea {
  min-height: 118px;
  resize: vertical;
}

.chips {
  display: flex;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 9px 13px;
  color: var(--muted);
}

.chip.selected {
  border-color: var(--sage-dark);
  background: rgba(168, 185, 163, 0.28);
  color: var(--ink);
}

.timer-orb {
  display: grid;
  width: 150px;
  height: 150px;
  margin: 26px auto;
  place-items: center;
  border: 12px solid rgba(238, 139, 115, 0.25);
  border-top-color: var(--coral);
  border-radius: 50%;
  text-align: center;
}

.timer-orb strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
}

.wave {
  display: flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.wave span {
  width: 4px;
  height: 8px;
  border-radius: 99px;
  background: var(--coral);
}

.recording .wave span {
  animation: pulse 900ms ease-in-out infinite alternate;
}

.wave span:nth-child(2) { animation-delay: 120ms; }
.wave span:nth-child(3) { animation-delay: 240ms; }
.wave span:nth-child(4) { animation-delay: 360ms; }
.wave span:nth-child(5) { animation-delay: 480ms; }

@keyframes pulse {
  to { height: 30px; }
}

.feedback-grid {
  grid-template-columns: repeat(2, 1fr);
}

.feedback-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.feedback-button.selected {
  border-color: var(--coral-dark);
  background: rgba(238, 139, 115, 0.18);
}

.result-card {
  overflow: hidden;
  background:
    radial-gradient(circle at 100% 0, rgba(241, 198, 111, 0.35), transparent 42%),
    var(--surface);
  text-align: center;
}

.result-score {
  display: grid;
  width: 142px;
  height: 142px;
  margin: 24px auto;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.5rem;
}

.stats-grid {
  grid-template-columns: repeat(2, 1fr);
}

.dashboard-grid {
  grid-template-columns: repeat(2, 1fr);
}

.bar-chart {
  display: flex;
  min-height: 128px;
  align-items: end;
  gap: 8px;
  padding-top: 14px;
}

.bar {
  flex: 1;
  min-height: 4px;
  border-radius: 8px 8px 3px 3px;
  background: var(--sage);
}

.bar.today {
  background: var(--coral);
}

.week-dots {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
}

.day-dot {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: rgba(32, 33, 29, 0.06);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.day-dot.done {
  background: var(--sage-dark);
  color: white;
}

.voucher-card {
  border-left: 5px solid var(--sun);
}

.voucher-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.upload-zone {
  border-style: dashed;
  padding: 28px 20px;
  text-align: center;
}

.file-meta {
  display: none;
  margin-top: 10px;
  color: var(--sage-dark);
}

.file-meta.visible {
  display: block;
}

.notice {
  border-radius: 14px;
  background: rgba(241, 198, 111, 0.2);
  padding: 12px 14px;
  color: #6b551f;
  font-size: 0.83rem;
  line-height: 1.45;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 18px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 18px;
  width: min(calc(100% - 36px), 520px);
  margin: auto;
  border-radius: 15px;
  background: var(--ink);
  padding: 14px 18px;
  color: white;
  box-shadow: var(--shadow);
  text-align: center;
}

.empty-state {
  padding: 42px 20px;
  color: var(--muted);
  text-align: center;
}

.install-tip {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (min-width: 640px) {
  .app-shell {
    padding-right: 28px;
    padding-left: 28px;
  }

  .choice-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .lesson-card {
    min-height: 228px;
  }

  .lesson-card h3 {
    font-size: 1.55rem;
  }

  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
