/* ─── Setswana Learning App — Earth-tone palette ───────────────────────
   Sage green + terracotta, warm neutral backgrounds. Mobile-first.     */

:root {
  --sage-900: #1B4F72;
  --sage-700: #1B4F72;
  --sage-500: #5DADE2;
  --sage-200: #B3D9EE;
  --sage-100: #E8F2FB;
  --terracotta: #F1C40F;
  --terracotta-dark: #D35400;
  --cream: #FDFBF7;
  --sand: #F5EFE6;
  --ink: #3a3530;
  --muted: #8D6E63;
  --white: #ffffff;
  --danger: #c0392b;
  --success: #4a8a5d;

  --radius: 16px;
  --shadow: 0 4px 16px rgba(27, 79, 114, 0.12);
  --shadow-lg: 0 8px 28px rgba(27, 79, 114, 0.18);
  --nav-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* ─── Auth screen ─────────────────────────────────────────────────── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(160deg, var(--sage-700) 0%, var(--sage-500) 100%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-logo { font-size: 48px; line-height: 1; }
.auth-title { margin: 8px 0 4px; color: var(--sage-700); font-size: 22px; }
.auth-subtitle { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

.auth-tabs {
  display: flex;
  background: var(--sand);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.auth-tab.active { background: var(--white); color: var(--sage-700); box-shadow: var(--shadow); }

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  padding: 14px;
  border: 1px solid var(--sand);
  border-radius: 10px;
  font-size: 15px;
  background: var(--cream);
  outline: none;
}
.auth-form input:focus { border-color: var(--sage-500); background: var(--white); }

.auth-error {
  margin-top: 12px;
  padding: 10px;
  background: #fdecea;
  color: var(--danger);
  border-radius: 8px;
  font-size: 13px;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  transition: transform .1s, background .15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--sage-700); color: var(--white); }
.btn-primary:hover { background: var(--sage-900); }
.btn-terracotta { background: var(--terracotta); color: var(--white); }
.btn-terracotta:hover { background: var(--terracotta-dark); }
.btn-outline { background: transparent; color: var(--sage-700); border: 2px solid var(--sage-500); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ─── App shell ───────────────────────────────────────────────────── */
.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

.view { padding: 20px 16px 24px; }

/* ─── Bottom navigation ───────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--white);
  border-top: 1px solid var(--sand);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 12px rgba(46, 66, 54, 0.08);
  z-index: 50;
  max-width: 640px;
  margin: 0 auto;
}
.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 20px;
  color: var(--muted);
  padding: 4px 12px;
}
.nav-item span { font-size: 11px; font-weight: 600; }
.nav-item.active { color: var(--sage-700); }

/* ─── Headers ─────────────────────────────────────────────────────── */
.page-title { font-size: 24px; margin: 0 0 4px; color: var(--sage-900); }
.page-subtitle { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.section-title { font-size: 16px; color: var(--sage-700); margin: 24px 0 12px; font-weight: 700; }

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ─── Learn / skill tree ──────────────────────────────────────────── */
.unit-list { display: flex; flex-direction: column; gap: 12px; }
.unit-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--sand);
}
.unit-row.locked { opacity: 0.55; filter: grayscale(0.6); }
.unit-row.in_progress { border-left-color: var(--terracotta); }
.unit-row.unlocked { border-left-color: var(--sage-500); }
.unit-row.completed { border-left-color: var(--success); }

.unit-node {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.unit-node.locked { background: var(--sand); }
.unit-node.unlocked { background: var(--sage-200); }
.unit-node.completed { background: var(--success); color: var(--white); }
.unit-node.in_progress { background: var(--terracotta); color: var(--white); }

.unit-row-info { flex: 1; }
.unit-row-info h3 { margin: 0 0 2px; font-size: 15px; color: var(--ink); }
.unit-row-info p { margin: 0; font-size: 12px; color: var(--muted); }
.unit-xp { font-size: 12px; color: var(--sage-700); font-weight: 700; white-space: nowrap; }

/* Locked unit CTA */
.lock-note {
  margin-top: 16px;
  padding: 12px;
  background: var(--sand);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* Unit detail lessons */
.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.lesson-index {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sage-100);
  color: var(--sage-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.lesson-item h4 { margin: 0; font-size: 14px; }
.lesson-item small { color: var(--muted); }

/* ─── Flashcards ──────────────────────────────────────────────────── */
.flashcard {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px 24px;
  text-align: center;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: pointer;
  user-select: none;
}
.flashcard-image {
  width: 130px;
  height: 130px;
  border-radius: 12px;
  background: var(--sage-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
}
.flashcard .english {
  font-size: 20px;
  color: var(--ink);
}
.flashcard .reveal { font-size: 26px; color: var(--sage-700); font-weight: 700; }
.flashcard .noun-class { font-size: 12px; color: var(--terracotta); letter-spacing: 1px; text-transform: uppercase; }

.fc-controls { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.fc-audio-row { display: flex; justify-content: center; gap: 10px; }
.rate-row { display: flex; justify-content: space-between; gap: 8px; }
.rate-btn {
  flex: 1;
  padding: 14px 0;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  background: var(--sage-100);
  color: var(--sage-900);
}
.rate-btn:hover { background: var(--sage-200); }
.rate-btn.r1 { background: #f2d7cf; color: #9c3b28; }
.rate-btn.r2 { background: #f5e3cf; color: #a85a2a; }
.rate-btn.r3 { background: #efe8cd; color: #7a6a1f; }
.rate-btn.r4 { background: #dce8d6; color: #3f6b45; }
.rate-btn.r5 { background: #c9e3d2; color: #2a5c3a; }

.fc-progress-bar {
  height: 6px;
  background: var(--sand);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 16px;
}
.fc-progress-fill {
  height: 100%;
  background: var(--terracotta);
  transition: width .3s;
}

/* ─── Stats ───────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--sage-700); }
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.daily-progress {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.daily-progress .dp-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.dp-fill { height: 12px; background: var(--sand); border-radius: 6px; overflow: hidden; }
.dp-fill > div { height: 100%; background: linear-gradient(90deg, var(--terracotta), var(--sage-500)); border-radius: 6px; transition: width .4s; }

.badge-list { display: flex; flex-wrap: wrap; gap: 10px; }
.badge-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border-radius: 30px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.badge-pill.locked { opacity: 0.5; filter: grayscale(1); }
.badge-pill .b-icon { font-size: 20px; }

/* ─── Settings ────────────────────────────────────────────────────── */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 4px;
  border-bottom: 1px solid var(--sand);
}
.settings-row:last-child { border-bottom: none; }
.settings-row .label { font-size: 14px; }
.settings-row .value { font-size: 13px; color: var(--muted); }

/* ─── Toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--sage-900);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: toast-in .25s ease;
  max-width: 90vw;
  text-align: center;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ─── Loading / empty states ──────────────────────────────────────── */
.loading {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: 14px;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px 16px;
  font-size: 14px;
}

/* ════════════════════════════════════════════════════════════════════
   PHASE 1 COMPONENTS
   ════════════════════════════════════════════════════════════════════ */

/* ─── XP ribbon ────────────────────────────────────────────────────── */
.xp-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(120deg, var(--sage-700), var(--sage-500));
  color: var(--white);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.xp-ribbon-label { font-size: 13px; opacity: 0.9; }
.xp-ribbon-value { font-size: 26px; font-weight: 800; }

/* ─── Skill tree (vertical path) ──────────────────────────────────── */
.skill-path { display: flex; flex-direction: column; }
.skill-path-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.skill-node-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 64px;
  flex-shrink: 0;
}
.skill-unit-node {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  border: 3px solid var(--sand);
  cursor: pointer;
  transition: transform .15s;
  box-shadow: var(--shadow);
}
.skill-unit-node:active { transform: scale(0.94); }
.skill-unit-node.locked { background: var(--sand); color: var(--muted); }
.skill-unit-node.unlocked { background: var(--sage-500); color: var(--white); animation: pulse-border 2s infinite; }
.skill-unit-node.in_progress { background: var(--terracotta); color: var(--white); }
.skill-unit-node.completed { background: var(--success); color: var(--white); }
@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(92, 122, 102, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(92, 122, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(92, 122, 102, 0); }
}

/* dashed connector going down */
.skill-connector {
  width: 2px;
  height: 44px;
  border-left: 3px dashed var(--sage-200);
  margin-top: 2px;
}
.skill-connector.conn-done { border-left-color: var(--success); border-left-style: solid; }

.skill-unit-label {
  flex: 1;
  padding: 12px 0;
  cursor: pointer;
}
.skill-unit-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.skill-unit-title.locked { color: var(--muted); }
.skill-unit-title.completed { color: var(--success); }
.skill-unit-title.in_progress { color: var(--terracotta); }
.skill-unit-xp { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ─── Lesson track (horizontal circles) ───────────────────────────── */
.lesson-track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 2px 12px;
  margin-bottom: 4px;
}
.lesson-circle-wrap {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 64px;
  cursor: pointer;
}
.lesson-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--sage-100);
  color: var(--sage-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border: 2px solid var(--sage-200);
  box-shadow: var(--shadow);
  transition: transform .15s;
}
.lesson-circle-wrap:active .lesson-circle { transform: scale(0.93); }
.lesson-circle-label { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ─── Flashcard flip ──────────────────────────────────────────────── */
.flip { perspective: 1000px; cursor: pointer; user-select: none; }
.flip-inner {
  position: relative;
  width: 100%;
  min-height: 300px;
  transition: transform .5s;
  transform-style: preserve-3d;
  transform-origin: center;
}
.flip-inner.flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
}
.flip-front { z-index: 2; }
.flip-back { transform: rotateY(180deg); }
.flashcard-media {
  width: 140px;
  height: 140px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--sage-100);
}
.flashcard-media img { width: 100%; height: 100%; object-fit: cover; }
.fc-photo-btn {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  z-index: 3;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}
.fc-photo-btn:hover { background: rgba(0,0,0,0.7); }
.fc-photo-btn:disabled { opacity: 0.6; cursor: default; }
.flip-front { position: relative; }
.flashcard-placeholder-letter { font-size: 60px; color: var(--white); font-weight: 800; }
.fc-word { font-size: 30px; font-weight: 800; color: var(--sage-700); }
.fc-noun-class { font-size: 11px; color: var(--terracotta); letter-spacing: 1px; text-transform: uppercase; }
.fc-en-row { display: flex; align-items: center; gap: 10px; }
.fc-english { font-size: 17px; color: var(--ink); }
.fc-audio-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--sage-100);
  font-size: 16px;
  cursor: pointer;
}
.fc-count { font-size: 14px; font-weight: 700; color: var(--muted); margin: 4px 0 6px; text-align: center; }
.fc-no-audio { font-size: 12px; color: var(--muted); text-align: center; padding: 4px; }
.fc-rate-label { font-size: 13px; color: var(--muted); text-align: center; }

/* ─── Completion screen ───────────────────────────────────────────── */
.completion { text-align: center; padding: 40px 16px; }
.completion-icon { font-size: 64px; }
.completion-title { font-size: 22px; color: var(--sage-900); margin: 12px 0 6px; }
.completion-xp {
  display: inline-block;
  background: linear-gradient(120deg, var(--terracotta), var(--sage-500));
  color: var(--white);
  font-size: 22px;
  font-weight: 800;
  padding: 10px 22px;
  border-radius: 30px;
  margin-bottom: 24px;
}

/* ─── Phrase builder ──────────────────────────────────────────────── */
.pb-progress { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.pb-target {
  font-size: 20px;
  font-weight: 700;
  color: var(--sage-700);
  background: var(--sage-100);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}
.pb-built-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pb-answer {
  min-height: 52px;
  border: 2px dashed var(--sage-200);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  margin-bottom: 16px;
}
.pb-chip {
  background: var(--sage-700);
  color: var(--white);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
}
.pb-tiles { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.pb-tile {
  background: var(--white);
  border: 2px solid var(--sage-500);
  color: var(--sage-800);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.pb-tile:disabled, .pb-tile.used { opacity: 0.35; cursor: default; }
.pb-actions { display: flex; gap: 10px; }
.pb-actions .btn { flex: 1; }
.pb-feedback { margin-top: 16px; padding: 12px; border-radius: 10px; font-weight: 600; text-align: center; }
.pb-feedback.incorrect { background: #fdecea; color: var(--danger); }
.shake { animation: shake .5s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.pb-correct-flash { animation: pb-green .6s; }
@keyframes pb-green { 0%,100% { background: transparent; } 50% { background: #e3f2e6; } }

/* ─── Matching practice ───────────────────────────────────────────── */
.match-timer { text-align: center; font-size: 16px; font-weight: 700; color: var(--terracotta); margin-bottom: 16px; }
.match-columns { display: flex; gap: 12px; }
.match-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.match-cell {
  background: var(--white);
  border: 2px solid var(--sage-200);
  border-radius: 12px;
  padding: 14px 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background .15s, transform .1s;
}
.match-cell:active { transform: scale(0.96); }
.match-cell.selected { border-color: var(--sage-500); background: var(--sage-100); }
.match-cell.matched { background: var(--success); color: var(--white); border-color: var(--success); cursor: default; }
.match-cell.wrong-flash { background: var(--danger); color: var(--white); border-color: var(--danger); }

/* ─── Dialogue ────────────────────────────────────────────────────── */
.dialog-line { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-start; }
.dialog-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--sage-700);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}
.dialog-body {
  flex: 1;
  background: var(--white);
  border-radius: 12px 12px 12px 4px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.dialog-speaker { font-size: 12px; color: var(--terracotta); font-weight: 700; margin-bottom: 2px; }
.dialog-text-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-st { font-size: 16px; font-weight: 600; }
.dialog-audio {
  border: none; background: none; font-size: 16px; cursor: pointer;
}
.dialog-trans-btn { margin-top: 8px; font-size: 12px; }
.dialog-en { margin-top: 6px; font-size: 13px; color: var(--muted); font-style: italic; }
.dialog-divider { height: 1px; background: var(--sand); margin: 20px 0; }
.dialog-review-prompt { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.dialog-review-st { font-size: 20px; font-weight: 700; color: var(--sage-700); }

/* ─── Singular / plural drill ─────────────────────────────────────── */
.sp-progress { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.sp-prompt { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.sp-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.sp-options .btn { text-align: center; }
.sp-correct { background: var(--success) !important; color: var(--white) !important; border-color: var(--success) !important; }
.sp-wrong { background: var(--danger) !important; color: var(--white) !important; border-color: var(--danger) !important; }
.sp-score { font-size: 14px; color: var(--muted); font-weight: 700; }

/* ─── Audio recording ─────────────────────────────────────────────── */
.rec-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fdecea;
  border: 2px solid var(--danger);
  margin-bottom: 16px;
  padding: 12px 16px;
}
.rec-timer { font-size: 18px; font-weight: 800; color: var(--danger); }
.rec-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.rec-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.rec-item-info { flex: 1; }
.rec-word { font-size: 16px; font-weight: 700; }
.rec-english { font-size: 12px; color: var(--muted); }

/* ─── Stats hero + badges ─────────────────────────────────────────── */
.stats-hero {
  background: linear-gradient(150deg, var(--sage-700), var(--sage-500));
  color: var(--white);
  border-radius: var(--radius);
  text-align: center;
  padding: 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
}
.stats-level {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}
.stats-xp { font-size: 52px; font-weight: 800; line-height: 1; }
.stats-xp-label { font-size: 12px; letter-spacing: 2px; opacity: 0.85; margin-top: 4px; }
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-card {
  background: var(--white);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.badge-card .badge-icon { font-size: 28px; }
.badge-card .badge-name { font-size: 11px; font-weight: 700; margin-top: 4px; }
.badge-card .badge-desc { font-size: 9px; color: var(--muted); }
.badge-card.earned { border: 2px solid var(--sage-200); }
.badge-card.locked { opacity: 0.55; filter: grayscale(1); }

@media (min-width: 600px) {
  .badge-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ─── 5-item bottom nav (adds Record) ─────────────────────────────── */
.bottom-nav { justify-content: space-around; gap: 0; }
.nav-item { padding: 4px 2px; }
@media (max-width: 420px) {
  .nav-item span { font-size: 10px; }
}

/* ════════════════════════════════════════════════════════════════════
   PHASE 2 COMPONENTS (Noun classes)
   ════════════════════════════════════════════════════════════════════ */

/* ─── Noun class reference cards ──────────────────────────────────── */
.nc-ref-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.nc-ref-card {
  background: var(--white);
  border: 2px solid var(--sand);
  border-top: 5px solid var(--nc-color, var(--sage-500));
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.nc-ref-card:active { transform: scale(0.97); }
.nc-ref-card:hover { border-color: var(--nc-color, var(--sage-500)); }
.nc-ref-card.nc-active {
  border-color: var(--nc-color, var(--sage-500));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--nc-color, var(--sage-500)) 35%, transparent);
}
.nc-ref-num { font-size: 15px; font-weight: 800; color: var(--sage-900); }
.nc-ref-prefix { font-size: 16px; font-weight: 800; color: var(--nc-color, var(--sage-700)); letter-spacing: .5px; }
.nc-ref-name { font-size: 12px; font-weight: 600; color: var(--muted); }
.nc-ref-examples { font-size: 11px; color: var(--muted); font-style: italic; line-height: 1.35; }
.nc-ref-count { font-size: 12px; font-weight: 700; color: var(--sage-700); margin-top: 2px; }

/* ─── Vocabulary bank (Classes view) ──────────────────────────────── */
.nc-bank-header { display: flex; align-items: baseline; justify-content: space-between; }
.nc-search-row { margin-bottom: 10px; }
.nc-search {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--sand);
  border-radius: 12px;
  background: var(--white);
  font-size: 14px;
  outline: none;
}
.nc-search:focus { border-color: var(--sage-500); }
.nc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.nc-chip {
  border: 1px solid var(--sage-200);
  background: var(--white);
  color: var(--sage-700);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.nc-chip-active { background: var(--sage-700); color: var(--white); border-color: var(--sage-700); }

/* Phase 4: category filter chips (slightly distinct from class chips) */
.nc-cat-chips { margin-top: 2px; }
.nc-chip-cat {
  border-color: var(--sage-300);
  background: var(--sage-50, #f4f7f5);
  color: var(--ink);
}

/* Phase 4: Cultural Note info card shown at the top of a unit's lesson path */
.cultural-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: linear-gradient(135deg, var(--sage-50, #f0f5f1), #eef2fb);
  border: 1px solid var(--sage-200);
  border-left: 5px solid var(--sage-600, #4a7a5c);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 14px 0 4px;
  box-shadow: var(--shadow);
}
.cultural-note-icon { font-size: 26px; line-height: 1; }
.cultural-note-body { flex: 1; }
.cultural-note-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--sage-700);
  margin-bottom: 4px;
}
.cultural-note-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
}
.nc-bank { display: flex; flex-direction: column; gap: 8px; }
.nc-vocab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--white);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.nc-vocab-info { flex: 1; }
.nc-vocab-word { font-size: 16px; font-weight: 700; color: var(--ink); }
.nc-vocab-en { font-size: 12px; color: var(--muted); }
.nc-vocab-sgpl { font-size: 12px; color: var(--terracotta); font-weight: 600; margin-top: 2px; }
.nc-vocab-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.nc-badge {
  background: color-mix(in srgb, var(--nc-color, var(--sage-500)) 18%, var(--white));
  color: var(--sage-900);
  border: 1px solid var(--nc-color, var(--sage-500));
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}
.nc-learned { font-size: 11px; color: var(--success); font-weight: 700; }

/* ─── Noun class trainer ──────────────────────────────────────────── */
.nct-word-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  text-align: center;
  margin: 16px 0;
}
.nct-word { font-size: 30px; font-weight: 800; color: var(--sage-700); }
.nct-english { font-size: 15px; color: var(--muted); margin-top: 6px; }
.nct-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.nct-class-btn {
  background: var(--white);
  border: 2px solid var(--nc-color, var(--sage-200));
  border-radius: 14px;
  color: var(--sage-900);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  box-shadow: var(--shadow);
  font-size: 12px;
}
.nct-class-btn:nth-child(even) { grid-column: 2; }
.nct-class-num { font-weight: 800; font-size: 14px; }
.nct-class-prefix { font-weight: 700; color: var(--nc-color, var(--sage-700)); font-size: 13px; }
.nct-class-name { font-size: 10px; color: var(--muted); }
.nct-class-btn.nct-correct {
  background: var(--success) !important;
  color: var(--white) !important;
  border-color: var(--success) !important;
}
.nct-class-btn.nct-correct .nct-class-name,
.nct-class-btn.nct-correct .nct-class-prefix { color: var(--white) !important; }
.nct-class-btn.nct-wrong {
  background: var(--danger) !important;
  color: var(--white) !important;
  border-color: var(--danger) !important;
  animation: shake .4s;
}
.nct-feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  text-align: center;
  font-size: 15px;
}
.nct-fb-correct { background: #e3f2e6; color: var(--success); }
.nct-fb-wrong { background: #fdecea; color: var(--danger); }

@media (min-width: 600px) {
  .nc-ref-grid { grid-template-columns: repeat(3, 1fr); }
  .nct-grid { grid-template-columns: repeat(3, 1fr); }
  .nct-class-btn:nth-child(even) { grid-column: auto; }
}

/* ════════════════════════════════════════════════════════════════════
   PHASE 3 COMPONENTS (Sentence building)
   ════════════════════════════════════════════════════════════════════ */

/* ─── Enhanced phrase builder ─────────────────────────────────────── */
.pb-answer-tap { min-height: 64px; }
.pb-chip-tap {
  background: var(--terracotta);
  color: var(--white);
  border: none;
  padding: 8px 16px;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s, opacity .15s;
}
.pb-chip-tap:active { transform: scale(0.94); }
.pb-feedback.correct { background: #e3f2e6; color: var(--success); }
.pb-feedback.correct, .pb-feedback.incorrect { margin-top: 12px; padding: 12px; border-radius: 10px; font-weight: 600; text-align: center; font-size: 14px; line-height: 1.4; }
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.pb-tile { transition: transform .1s, opacity .15s; }
.pb-tile:active { transform: scale(0.9); }
.pb-tile.used { opacity: 0.3; transform: scale(0.96); }

/* ─── Chat-style dialogue ─────────────────────────────────────────── */
.dialog-chat {
  display: flex;
  flex-direction: column;
  background: var(--sand);
  border-radius: var(--radius);
  padding: 12px;
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 16px;
  gap: 10px;
}
.dialog-line { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.dialog-left { align-self: flex-start; }
.dialog-right { align-self: flex-end; flex-direction: row-reverse; }
.dialog-left .dialog-body { border-radius: 14px 14px 14px 4px; background: var(--white); }
.dialog-right .dialog-body { border-radius: 14px 14px 4px 14px; background: var(--sage-100); }
.dialog-right .dialog-speaker { text-align: right; color: var(--sage-700); }
.dialog-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--sage-700); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.dialog-body { flex: 1; padding: 8px 12px; box-shadow: var(--shadow); }
.dialog-speaker { font-size: 11px; color: var(--terracotta); font-weight: 700; margin-bottom: 2px; }
.dialog-text-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-st { font-size: 15px; font-weight: 600; }
.dialog-audio { border: none; background: none; font-size: 15px; cursor: pointer; opacity: 0.8; }
.dialog-en { margin-top: 4px; font-size: 12px; color: var(--muted); font-style: italic; }
.dialog-review-head { text-align: center; font-weight: 700; color: var(--sage-700); padding: 6px 0 2px; }
.dialog-prompt-wrap { margin-top: 10px; }
.dialog-opt { text-align: left; }

/* ─── Concord reference table ─────────────────────────────────────── */
.concord-table {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}
.concord-row { display: flex; align-items: center; border-bottom: 1px solid var(--sand); }
.concord-row:last-child { border-bottom: none; }
.concord-head { background: var(--sage-700); color: var(--white); }
.concord-cell {
  flex: 0 0 14%;
  padding: 9px 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border-right: 1px solid var(--sand);
}
.concord-cell:last-child { border-right: none; }
.concord-head .concord-cell { color: var(--white); border-right-color: rgba(255,255,255,0.15); }
.concord-cl { flex-basis: 22%; font-weight: 800; color: var(--sage-700); text-align: left; }
.concord-example { flex: 1; text-align: left; font-size: 11px; color: var(--muted); font-style: italic; }
.concord-subj, .concord-adj, .concord-poss { font-weight: 700; }

/* ════════════════════════════════════════════════════════════════════
   PHASE 5 COMPONENTS (Conversation Simulator)
   ════════════════════════════════════════════════════════════════════ */

/* ─── Scenario list (Talk tab) ────────────────────────────────────── */
.scenario-list { display: flex; flex-direction: column; gap: 12px; }
.scenario-card {
  background: var(--white);
  border: none;
  border-left: 5px solid var(--sage-500);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  width: 100%;
}
.scenario-card:active { transform: scale(0.98); box-shadow: var(--shadow-lg); }
.scenario-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.scenario-diff {
  font-size: 11px; font-weight: 800; letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--scn-diff, var(--sage-500));
  background: color-mix(in srgb, var(--scn-diff, var(--sage-500)) 16%, var(--white));
  border: 1px solid color-mix(in srgb, var(--scn-diff, var(--sage-500)) 40%, transparent);
  padding: 3px 10px; border-radius: 20px;
}
.scenario-status { font-size: 12px; font-weight: 700; }
.scn-not_started { color: var(--muted); }
.scn-in_progress { color: var(--terracotta); }
.scn-completed { color: var(--success); }
.scn-locked { color: var(--muted); }
.scenario-title { font-size: 18px; font-weight: 800; color: var(--sage-900); }
.scenario-setting { font-size: 12px; color: var(--terracotta); margin-top: 4px; margin-bottom: 6px; }
.scenario-desc { font-size: 13px; color: var(--muted); line-height: 1.4; }

/* ─── Conversation chat ───────────────────────────────────────────── */
.conv-wrap { display: flex; flex-direction: column; }
.conv-progress {
  height: 8px; background: var(--sand); border-radius: 5px;
  overflow: hidden; margin-bottom: 6px;
}
.conv-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--terracotta), var(--sage-500));
  transition: width .35s; border-radius: 5px;
}
.conv-progress-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 12px; text-align: center; }

.conv-chat {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--sand);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 45vh;
  max-height: 62vh;
  overflow-y: auto;
  margin-bottom: 14px;
}
.conv-line { display: flex; gap: 8px; align-items: flex-end; max-width: 92%; }
.conv-left { align-self: flex-start; }
.conv-right { align-self: flex-end; flex-direction: row-reverse; }
.conv-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--sage-700); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.conv-body { flex: 1; padding: 9px 12px; box-shadow: var(--shadow); background: var(--white); border-radius: 14px 14px 14px 4px; }
.conv-right .conv-body { background: var(--sage-100); border-radius: 14px 14px 4px 14px; }
.conv-speaker { font-size: 11px; color: var(--terracotta); font-weight: 700; margin-bottom: 3px; }
.conv-speaker-right { text-align: right; color: var(--sage-700); }
.conv-text-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-st { font-size: 15px; font-weight: 600; line-height: 1.35; }
.conv-audio { border: none; background: none; font-size: 15px; cursor: pointer; opacity: 0.8; }
.conv-en { margin-top: 4px; font-size: 12px; color: var(--muted); font-style: italic; }
.conv-correct .conv-body { background: #e3f2e6; border: 1px solid var(--success); }
.conv-wrong .conv-body { background: #fdecea; border: 1px solid var(--danger); }

/* Typing indicator */
.conv-typing { display: flex; align-items: center; justify-content: center; min-width: 60px; }
.conv-typing-dots {
  font-size: 20px; color: var(--muted); letter-spacing: 3px;
  animation: conv-blink 1s infinite;
}
@keyframes conv-blink { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

/* Choice options */
.conv-options { display: flex; flex-direction: column; gap: 10px; }
.conv-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  text-align: left; line-height: 1.3;
}
.conv-option-en { font-size: 12px; color: var(--muted); font-style: italic; font-weight: 500; }
.conv-opt-correct { background: var(--success) !important; color: var(--white) !important; border-color: var(--success) !important; }

/* Narrator resolution note */
.conv-narrator {
  background: var(--sage-100);
  border-left: 4px solid var(--sage-500);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--sage-900);
  font-style: italic;
  align-self: center;
  max-width: 95%;
  text-align: center;
}

/* Final result screen */
.conv-result { text-align: center; padding: 26px 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.conv-success { background: #e3f2e6; border: 2px solid var(--success); }
.conv-fail { background: #fff0ea; border: 2px solid var(--terracotta); }
.conv-result-icon { font-size: 52px; }
.conv-result-title { font-size: 20px; font-weight: 800; color: var(--sage-900); margin: 10px 0 6px; }
.conv-result-summary { font-size: 14px; color: var(--muted); margin-bottom: 16px; line-height: 1.4; }
.conv-result-meta { display: flex; flex-direction: column; gap: 8px; }
.conv-result-xp {
  display: inline-block; align-self: center;
  background: linear-gradient(120deg, var(--terracotta), var(--sage-500));
  color: var(--white); font-size: 20px; font-weight: 800;
  padding: 10px 22px; border-radius: 30px;
}

/* 7-item bottom nav stays compact on small screens */
.bottom-nav .nav-item span { display: block; }
@media (max-width: 420px) {
  .nav-item { padding: 4px 0; }
  .nav-item span { font-size: 9px; }
}

/* ═══════════════════════════════════════════════════════════════════
   Phase 6 — Dark mode
   Theme is applied via an attribute on <html> (data-theme="dark").
   Smooth transitions are guarded so first paint doesn't flash.
   ═══════════════════════════════════════════════════════════════════ */
:root,
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --sage-900: #B3D9EE;
  --sage-700: #5DADE2;
  --sage-500: #2E86C1;
  --sage-200: #1B2A3A;
  --sage-100: #16202E;
  --terracotta: #F1C40F;
  --terracotta-dark: #D35400;
  --cream: #0D1B2A;
  --sand: #16202E;
  --ink: #E0E0E0;
  --muted: #8AB4D8;
  --white: #162738;
  --danger: #E07A6D;
  --success: #6FBF8C;
  --border-dark: #1B3A52;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.5);
}

/* Smooth theme transition — applied only for user-initiated toggles.
   The `no-transition` class is used during first load to avoid a flash. */
html:not(.no-transition) body,
html:not(.no-transition) .card,
html:not(.no-transition) .auth-card,
html:not(.no-transition) input,
html:not(.no-transition) .bottom-nav,
html:not(.no-transition) .skill-path-item,
html:not(.no-transition) .conv-line,
html:not(.no-transition) .scenario-card {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* ─── Dark-mode border + surface harmonisation ────────────────────── */
:root[data-theme="dark"] .bottom-nav,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .unit-row,
:root[data-theme="dark"] .skill-path-item,
:root[data-theme="dark"] .auth-card,
:root[data-theme="dark"] .scenario-card,
:root[data-theme="dark"] .conv-line,
:root[data-theme="dark"] .badge-card,
:root[data-theme="dark"] .settings-section {
  border-color: var(--border-dark);
}
:root[data-theme="dark"] .auth-form input {
  background: #1f2840;
  border-color: var(--border-dark);
  color: var(--ink);
}

/* Hardcoded-light backgrounds that must flip in dark mode */
:root[data-theme="dark"] .conv-success { background: rgba(111, 191, 140, 0.15); border-color: var(--success); }
:root[data-theme="dark"] .conv-fail { background: rgba(201, 123, 74, 0.15); border-color: var(--terracotta); }
:root[data-theme="dark"] .auth-error { background: rgba(224, 122, 109, 0.15); color: #ffb3ab; }

/* ─── Offline indicator (top bar) ─────────────────────────────────── */
.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: var(--terracotta);
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 8px;
  letter-spacing: 0.3px;
}

/* ─── Loading spinner ─────────────────────────────────────────────── */
.spinner-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px; gap: 12px; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--sage-200); border-top-color: var(--sage-700); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton shimmer for lesson/tab lists */
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--sand) 25%, var(--sage-100) 37%, var(--sand) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ─── Error / empty / retry states ────────────────────────────────── */
.error-state { text-align: center; padding: 32px 16px; color: var(--muted); }
.error-state .error-icon { font-size: 44px; }
.error-state .error-title { font-weight: 700; color: var(--sage-900); margin: 8px 0; font-size: 17px; }
.error-state .btn { margin-top: 12px; max-width: 220px; }

/* ─── Badges grid (badges view) ───────────────────────────────────── */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.badge-card {
  position: relative;
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
  background: var(--white);
  border: 2px solid var(--sand);
  cursor: pointer;
  transition: transform .12s ease, border-color .2s ease, box-shadow .2s ease;
}
.badge-card:active { transform: scale(0.96); }
.badge-card.earned {
  border-color: var(--sage-500);
  box-shadow: 0 0 12px rgba(74, 157, 124, 0.45);
}
.badge-card.locked { filter: grayscale(1); opacity: 0.72; }
.badge-card.locked .badge-icon { opacity: 0.6; }
.badge-icon { font-size: 34px; line-height: 1; }
.badge-name { font-size: 11px; font-weight: 700; margin: 8px 0 2px; color: var(--sage-900); }
.badge-desc { font-size: 10px; color: var(--muted); line-height: 1.25; }
.badge-hint { font-size: 9.5px; color: var(--terracotta); margin-top: 4px; font-weight: 600; }
.badge-lock { position: absolute; top: 6px; right: 6px; font-size: 14px; opacity: 0.85; }

/* ─── Badge detail modal ──────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10, 12, 20, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--white);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 26px 20px;
  max-width: 340px; width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.modal .badge-icon { font-size: 60px; }
.modal h3 { margin: 12px 0 6px; color: var(--sage-900); font-size: 20px; }
.modal .modal-desc { color: var(--muted); font-size: 14px; line-height: 1.45; }
.modal .modal-date { color: var(--sage-500); font-size: 13px; font-weight: 700; margin-top: 12px; }
.modal .modal-close { margin-top: 18px; }

/* ─── Toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(var(--nav-height) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--sage-900); color: var(--cream);
  padding: 12px 20px; border-radius: 30px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 300; max-width: 90vw;
}

/* ─── Settings cards / rows ───────────────────────────────────────── */
.settings-section {
  background: var(--white);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.settings-section-title { font-size: 13px; font-weight: 800; color: var(--sage-700); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--sand); }
.settings-row:last-child { border-bottom: none; }
.settings-row .label { font-size: 14px; color: var(--ink); }
.settings-row .value { font-size: 14px; color: var(--muted); }
.settings-control { display: flex; align-items: center; gap: 8px; }

/* Toggle switch */
.toggle { position: relative; width: 48px; height: 28px; border-radius: 20px; background: var(--sand); border: none; cursor: pointer; transition: background .2s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle.on { background: var(--sage-500); }
.toggle.on::after { transform: translateX(20px); }

/* Speed button group */
.segmented { display: flex; gap: 6px; }
.segmented .seg-btn { border: 2px solid var(--sand); background: transparent; color: var(--muted); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 700; }
.segmented .seg-btn.active { border-color: var(--sage-500); color: var(--sage-700); background: var(--sage-100); }
select.field, input.field { padding: 10px; border: 1px solid var(--sand); border-radius: 10px; background: var(--cream); color: var(--ink); font-size: 14px; }
