:root {
  color-scheme: light;
  --ink: #111814;
  --ink-2: #253129;
  --paper: #fbf7ef;
  --paper-2: #efe5d2;
  --line: #ded1b9;
  --muted: #6b7165;
  --teal: #0f5c58;
  --teal-2: #183f3b;
  --gold: #d8a433;
  --crimson: #b7443e;
  --mint: #4f9f86;
  --violet: #7257a5;
  --white: #ffffff;
  --shadow: 0 18px 55px rgba(17, 24, 20, 0.18);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(17, 24, 20, 0.88), rgba(17, 24, 20, 0.34) 22rem, rgba(251, 247, 239, 1) 22rem),
    var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  color: var(--paper);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
  line-height: 1.1;
}

.brand small {
  color: rgba(251, 247, 239, 0.72);
  font-size: 0.78rem;
}

.status-strip {
  display: flex;
  gap: 8px;
  overflow: auto;
  max-width: 60%;
  padding-bottom: 2px;
}

.status-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 84px;
  height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.status-pill strong {
  font-size: 0.95rem;
}

.muted {
  color: var(--muted);
}

.status-pill .muted,
.hero-band .muted {
  color: rgba(251, 247, 239, 0.66);
}

.mode-nav {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0 14px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(17, 24, 20, 0.82);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 35px rgba(17, 24, 20, 0.16);
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  color: rgba(251, 247, 239, 0.76);
  background: transparent;
  font-size: 0.88rem;
}

.nav-btn svg,
.icon-btn svg,
.tile-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.1;
}

.nav-btn.active {
  color: var(--ink);
  background: var(--paper);
}

.hero-band {
  position: relative;
  min-height: 300px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--ink-2);
  box-shadow: var(--shadow);
}

.hero-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.hero-overlay {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  min-height: 300px;
  padding: 26px;
  color: var(--paper);
  background:
    linear-gradient(90deg, rgba(17, 24, 20, 0.82), rgba(17, 24, 20, 0.28) 60%, rgba(17, 24, 20, 0.68)),
    linear-gradient(0deg, rgba(17, 24, 20, 0.72), rgba(17, 24, 20, 0.05) 55%);
}

.hero-copy {
  max-width: 650px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: 2.3rem;
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.hero-copy p:last-child {
  margin-bottom: 0;
  color: rgba(251, 247, 239, 0.82);
  max-width: 42rem;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, 88px);
  gap: 8px;
}

.hero-metrics > div {
  min-height: 86px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: var(--radius);
  background: rgba(17, 24, 20, 0.58);
  text-align: center;
}

.metric-value,
.metric-label {
  display: block;
}

.metric-value {
  color: var(--gold);
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1.1;
}

.metric-label {
  color: rgba(251, 247, 239, 0.66);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.progress-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 18px;
}

.progress-item {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 247, 239, 0.92);
}

.progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.86rem;
}

.meter {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8cbb5;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 250ms ease;
}

.meter.gold span {
  background: var(--gold);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 12px;
}

.toolbar,
.action-row,
.review-row,
.dictation-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn,
.review-btn,
.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 1px 0 rgba(17, 24, 20, 0.05);
}

.icon-btn {
  min-width: 44px;
  padding: 8px 12px;
}

.icon-btn.primary,
.review-btn.master {
  border-color: transparent;
  background: var(--gold);
  color: var(--ink);
}

.review-btn {
  min-width: 88px;
  padding: 8px 12px;
}

.review-btn.danger {
  background: #fff2f0;
  border-color: #ecc0bb;
  color: #872821;
}

.review-btn.good {
  background: #eff9f4;
  border-color: #b7dbc7;
  color: #126347;
}

.text-btn {
  min-height: 36px;
  padding: 6px 10px;
  background: transparent;
}

.segmented select {
  min-height: 40px;
  padding: 8px 30px 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
}

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

.quest-card,
.training-tile,
.flashcard,
.listen-card,
.reading-panel,
.prompt-panel,
.draft-panel,
.rank-panel,
.path-panel,
.achievement-panel,
.log-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: 0 10px 30px rgba(17, 24, 20, 0.08);
}

.quest-card {
  display: grid;
  min-height: 170px;
  padding: 14px;
  align-content: space-between;
}

.quest-card.done {
  border-color: rgba(79, 159, 134, 0.45);
  background: #f3fbf6;
}

.quest-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.quest-card h3 {
  margin: 8px 0 6px;
  line-height: 1.22;
}

.quest-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

.reward-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f6ead0;
  color: #7a4d00;
  font-weight: 900;
  font-size: 0.78rem;
}

.training-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.training-tile {
  min-height: 120px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
}

.training-tile:hover,
.nav-btn:hover,
.icon-btn:hover,
.review-btn:hover,
.text-btn:hover {
  transform: translateY(-1px);
}

.training-tile,
.nav-btn,
.icon-btn,
.review-btn,
.text-btn {
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.tile-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: #edf6f1;
  color: var(--teal);
}

.training-tile strong,
.training-tile small {
  display: block;
}

.training-tile small {
  color: var(--muted);
}

.flashcard {
  display: grid;
  gap: 12px;
  max-width: 720px;
  min-height: 430px;
  padding: 16px;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.flash-face {
  display: grid;
  gap: 10px;
  min-height: 190px;
  padding: 24px;
  place-items: center;
  border: 1px dashed #c5b897;
  border-radius: var(--radius);
  background: #fbf6ea;
  color: var(--ink);
  text-align: center;
}

.flash-face strong {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 2rem;
  line-height: 1.18;
}

.flash-face small {
  color: var(--muted);
  font-weight: 800;
}

.answer-panel {
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8f0df;
}

.answer-panel p {
  margin-bottom: 6px;
}

.coach-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.practice-layout,
.writing-layout,
.league-layout {
  display: grid;
  gap: 10px;
}

.practice-layout {
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
}

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

.listen-line {
  min-height: 88px;
  margin: 0;
  padding: 18px;
  border-radius: var(--radius);
  background: #f6ead0;
  font-size: 1.45rem;
  font-weight: 850;
  line-height: 1.28;
}

.listen-line.hidden-text {
  color: transparent;
  text-shadow: 0 0 16px rgba(17, 24, 20, 0.36);
  user-select: none;
}

.translation {
  margin-bottom: 0;
  color: var(--muted);
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.control-strip label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

input[type="range"] {
  accent-color: var(--teal);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.switch input {
  accent-color: var(--teal);
}

.dictation-row input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.score-ring {
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
  margin: 6px auto;
  border: 10px solid #e3d6bd;
  border-top-color: var(--teal);
  border-right-color: var(--gold);
  border-radius: 999px;
  text-align: center;
}

.score-ring strong,
.score-ring span {
  display: block;
}

.score-ring strong {
  font-size: 2.1rem;
  line-height: 1;
}

.score-ring span {
  margin-top: -38px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-ring.compact {
  width: 104px;
  height: 104px;
  border-width: 8px;
}

.score-ring.compact strong {
  font-size: 1.5rem;
}

.score-ring.compact span {
  margin-top: -26px;
}

.reading-panel {
  padding: 18px;
}

.french-text {
  padding: 18px;
  border-radius: var(--radius);
  background: #f7efe0;
  font-size: 1.08rem;
  line-height: 1.75;
}

.gloss-box {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #e4cfaa;
  border-radius: var(--radius);
  background: #fff9ec;
}

.gloss-box div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(216, 164, 51, 0.22);
  padding-bottom: 5px;
}

.gloss-box div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.question-box {
  display: grid;
  gap: 10px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.choice-btn {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  text-align: left;
}

.choice-btn.correct {
  border-color: #94c9ab;
  background: #eff9f4;
}

.choice-btn.wrong {
  border-color: #e9afa8;
  background: #fff1ef;
}

.writing-layout {
  grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.15fr);
}

.prompt-panel,
.draft-panel {
  padding: 16px;
}

.target-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.target-list span,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf6f1;
  color: #17483d;
  font-size: 0.78rem;
  font-weight: 900;
}

.model-answer {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: #f7efe0;
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #fffdf8;
  color: var(--ink);
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(216, 164, 51, 0.42);
  outline-offset: 2px;
}

.writing-score {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.feedback-list {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.feedback-list div {
  padding: 7px 9px;
  border-radius: 6px;
  background: #f7efe0;
}

.league-layout {
  grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1.3fr);
}

.rank-panel,
.path-panel,
.achievement-panel,
.log-panel {
  padding: 16px;
}

.rank-panel {
  display: flex;
  align-items: center;
  gap: 14px;
}

.rank-emblem {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--gold);
  font-size: 1.8rem;
  font-weight: 950;
}

.path-panel {
  grid-row: span 2;
}

.path-track {
  display: grid;
  gap: 8px;
}

.path-node {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
}

.path-node.active {
  border-color: rgba(216, 164, 51, 0.72);
  background: #fff8e8;
}

.path-node.done {
  border-color: rgba(79, 159, 134, 0.55);
  background: #f1faf5;
}

.node-rank {
  display: grid;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--gold);
  font-weight: 950;
}

.node-copy strong,
.node-copy small {
  display: block;
}

.node-copy small {
  color: var(--muted);
}

.badge-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge.locked {
  background: #eee7dc;
  color: #897f6e;
}

.log-panel {
  max-height: 220px;
  overflow: auto;
}

.log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.log-row strong {
  color: var(--ink);
}

.toast-zone {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100% - 32px));
}

.toast {
  padding: 12px 14px;
  border: 1px solid rgba(216, 164, 51, 0.55);
  border-radius: var(--radius);
  background: rgba(17, 24, 20, 0.94);
  color: var(--paper);
  box-shadow: var(--shadow);
}

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

@media (max-width: 920px) {
  .app-shell {
    width: min(100% - 24px, 760px);
    padding-bottom: 86px;
  }

  .status-strip {
    max-width: 52%;
  }

  .hero-overlay,
  .progress-band,
  .practice-layout,
  .writing-layout,
  .league-layout {
    grid-template-columns: 1fr;
  }

  .hero-overlay {
    align-items: end;
  }

  .hero-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quest-grid,
  .training-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .path-panel {
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  body {
    background:
      linear-gradient(180deg, rgba(17, 24, 20, 0.92), rgba(17, 24, 20, 0.42) 18rem, rgba(251, 247, 239, 1) 18rem),
      var(--paper);
  }

  .app-shell {
    width: 100%;
    padding: 10px 10px 92px;
  }

  .topbar {
    min-height: 50px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand strong {
    font-size: 0.94rem;
  }

  .status-strip {
    max-width: 48%;
  }

  .status-pill {
    min-width: 76px;
    height: 36px;
    padding: 7px 8px;
  }

  .mode-nav {
    position: fixed;
    inset: auto 10px calc(10px + env(safe-area-inset-bottom)) 10px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin: 0;
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(17, 24, 20, 0.92);
  }

  .nav-btn {
    min-height: 50px;
    padding: 6px 2px;
    gap: 2px;
    flex-direction: column;
    font-size: 0.68rem;
  }

  .nav-btn svg {
    width: 17px;
    height: 17px;
  }

  .hero-band,
  .hero-overlay {
    min-height: 330px;
  }

  .hero-overlay {
    padding: 18px;
  }

  h1 {
    font-size: 1.85rem;
  }

  .hero-metrics {
    gap: 6px;
  }

  .hero-metrics > div {
    min-height: 74px;
    padding: 10px 6px;
  }

  .metric-value {
    font-size: 1.35rem;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

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

  .flashcard {
    min-height: 0;
  }

  .flash-face strong {
    font-size: 1.55rem;
  }

  .review-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-btn {
    width: 100%;
    min-width: 0;
  }

  .control-strip {
    grid-template-columns: 1fr;
  }

  .listen-line {
    font-size: 1.16rem;
  }

  .writing-score {
    grid-template-columns: 1fr;
  }

  .score-ring.compact {
    margin-left: 0;
  }

  .path-node {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .path-node .reward-chip {
    grid-column: 1 / -1;
  }
}
