/* Charla — mobile-first, no framework, no build step.
   Sized for a phone held one-handed in a street, because that is where a
   travel app is actually used: large tap targets, high contrast, and nothing
   that depends on hover. */

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f2ece3;
  --ink: #1c1917;
  --ink-soft: #5f5750;
  --ink-faint: #8a8078;
  --accent: #d9660a;
  --accent-soft: #fdeadb;
  --brand-blue: #0060f0;
  --line: #e5ddd2;
  --good: #2f7d4f;
  --good-soft: #e3f2e8;
  --warn: #a8531a;
  --bad: #a3302a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28,25,23,.06), 0 6px 20px rgba(28,25,23,.06);
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110f;
    --surface: #1f1b18;
    --surface-2: #2a2521;
    --ink: #f5f1ec;
    --ink-soft: #bdb3a9;
    --ink-faint: #8d8279;
    --accent: #ff9a45;
    --accent-soft: #3a2a1d;
    --line: #332c27;
    --good: #6bbd8a;
    --good-soft: #1e3227;
    --warn: #d99350;
    --bad: #e0796f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* --- chrome ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
  padding: max(.6rem, env(safe-area-inset-top)) 1rem .6rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .45rem; text-decoration: none; color: var(--ink); }
.brand-mark { height: 26px; width: auto; display: block; }
.brand-name { font-size: 1.2rem; font-weight: 650; letter-spacing: -.01em; }
.streak { font-size: .82rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.streak strong { color: var(--accent); }

.view { flex: 1; width: 100%; max-width: 42rem; margin: 0 auto; padding: 1rem; outline: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  min-height: 64px; text-decoration: none;
  color: var(--ink-faint); font-size: .7rem; font-weight: 550;
}
.tab span { font-size: 1.1rem; line-height: 1; }
.tab[aria-current="page"] { color: var(--accent); }

/* --- primitives --------------------------------------------------------- */
h1 { font-size: 1.5rem; letter-spacing: -.02em; margin: .2rem 0 .1rem; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; letter-spacing: -.01em; }
.lede { color: var(--ink-soft); margin: 0 0 1.2rem; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.tiny { font-size: .8rem; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem; margin-bottom: .75rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: .7rem 1.1rem;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: .5rem; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1rem 0; }
.stat { background: var(--surface-2); border-radius: 12px; padding: .7rem; text-align: center; }
.stat b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { font-size: .72rem; color: var(--ink-soft); }

.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: .5rem; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.pill {
  display: inline-block; padding: .12rem .5rem; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .7rem; font-weight: 650; letter-spacing: .02em;
}
.pill-good { background: var(--good-soft); color: var(--good); }

/* --- review ------------------------------------------------------------- */
.progress-line { height: 3px; background: var(--surface-2); border-radius: 99px; margin-bottom: 1rem; }
.progress-line i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .2s; }

.prompt {
  min-height: 8.5rem; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .6rem; text-align: center;
  padding: 1.25rem .75rem;
}
.prompt .es { font-size: 1.6rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.prompt .en { font-size: 1.35rem; font-weight: 550; line-height: 1.35; }
.prompt .hint { font-size: .78rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .08em; }

.answer { border-top: 1px dashed var(--line); margin-top: .9rem; padding-top: .9rem; }
.answer .primary { font-size: 1.3rem; font-weight: 600; text-align: center; }
.answer .secondary { text-align: center; color: var(--ink-soft); margin-top: .2rem; }
.note {
  background: var(--surface-2); border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; padding: .6rem .75rem; margin-top: .85rem;
  font-size: .88rem; color: var(--ink-soft);
}
.variant { margin-top: .6rem; font-size: .85rem; color: var(--ink-faint); text-align: center; }

.speak-btn {
  width: 52px; height: 52px; border-radius: 50%; padding: 0;
  font-size: 1.3rem; line-height: 1;
}

.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-top: .9rem; }
.grade { display: flex; flex-direction: column; gap: .1rem; min-height: 58px; padding: .5rem .2rem; font-size: .82rem; }
.grade small { font-weight: 500; color: var(--ink-faint); font-size: .68rem; font-variant-numeric: tabular-nums; }
.grade[data-r="0"] { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); color: var(--bad); }
.grade[data-r="5"] { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); color: var(--good); }

.mic-result { margin-top: .75rem; padding: .6rem .75rem; border-radius: 10px; font-size: .9rem; }
.mic-result.ok { background: var(--good-soft); color: var(--good); }
.mic-result.no { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }

/* --- lists -------------------------------------------------------------- */
.unit { display: block; text-decoration: none; color: inherit; }
.unit-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.unit-title { font-weight: 650; letter-spacing: -.01em; }
.unit-es { font-size: .8rem; color: var(--ink-faint); font-style: italic; }

.search {
  width: 100%; min-height: var(--tap); padding: .7rem .9rem;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit;
}
.entry { padding: .7rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .75rem; align-items: flex-start; }
.entry:last-child { border-bottom: 0; }
.entry .text { flex: 1; min-width: 0; }
.entry .es { font-weight: 600; }
.entry .en { color: var(--ink-soft); font-size: .92rem; }

label.field { display: block; margin: .9rem 0; }
label.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
select, input[type="range"] { width: 100%; }
select {
  min-height: var(--tap); padding: .6rem .7rem; font: inherit;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
}

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-soft); }
.empty .big { font-size: 2.5rem; display: block; margin-bottom: .5rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- switches ----------------------------------------------------------- */
.switch {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: var(--tap); padding: .5rem 0;
  border-bottom: 1px solid var(--line);
}
.switch:last-of-type { border-bottom: 0; }
.switch > span { display: flex; flex-direction: column; font-weight: 600; font-size: .9rem; }
.switch small { font-weight: 400; font-size: .78rem; margin-top: .1rem; }
.switch input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 50px; height: 30px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line);
  position: relative; cursor: pointer; transition: background .15s;
}
.switch input[type="checkbox"]::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s;
}
.switch input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.switch input[type="checkbox"]:checked::after { transform: translateX(20px); }
.switch input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* two pickers side by side once there's room */
.pickers { display: grid; grid-template-columns: 1fr; gap: 0 .75rem; }
@media (min-width: 420px) { .pickers { grid-template-columns: 1fr 1fr; } }
.pickers .field { margin: .3rem 0 .9rem; }

/* --- lesson shell -------------------------------------------------------- */
.lesson-bar { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.lesson-quit { color: var(--ink-faint); text-decoration: none; font-size: 1.15rem; line-height: 1; padding: .25rem; }
.lesson-bar .progress-line { flex: 1; margin: 0; height: 12px; background: var(--surface-2); }
.lesson-bar .progress-line i { border-radius: 99px; transition: width .25s ease; }
.lesson-count { font-size: .78rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.instruction { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; margin: 0 0 1rem; }

.stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; text-align: center; min-height: 6.5rem; padding: 1rem .5rem 1.25rem;
}
.stage .sentence { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.stage .gloss { color: var(--ink-soft); font-size: .95rem; }
.blank {
  display: inline-block; min-width: 4.5rem; margin: 0 .25rem;
  border-bottom: 3px solid var(--accent); color: var(--accent);
}
.speak-btn.big { width: 76px; height: 76px; font-size: 1.7rem; }

/* options ---------------------------------------------------------------- */
.options { display: grid; gap: .55rem; }
.option {
  min-height: var(--tap); padding: .8rem 1rem; text-align: left;
  border: 1.5px solid var(--line); border-bottom-width: 3px; border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.option:active { transform: translateY(1px); border-bottom-width: 2px; }
.option.right { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.option.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }

/* word bank -------------------------------------------------------------- */
.assembled {
  min-height: 3.4rem; display: flex; flex-wrap: wrap; gap: .4rem; align-content: flex-start;
  padding: .55rem; margin-bottom: 1.1rem;
  border-bottom: 2px solid var(--line);
}
.assembled-hint { color: var(--ink-faint); font-size: .9rem; align-self: center; }
.tiles { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: center; }
.tile {
  padding: .55rem .8rem; border: 1.5px solid var(--line); border-bottom-width: 3px;
  border-radius: 10px; background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tile:active { transform: translateY(1px); border-bottom-width: 2px; }
.tile.spent { visibility: hidden; }        /* keeps the bank from reflowing as you pick */
.tile.placed { border-color: var(--accent); }

.mic { width: 100%; min-height: 64px; font-size: 1rem; }

/* feedback --------------------------------------------------------------- */
.foot { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); padding-top: 1rem; background: var(--bg); }
.feedback {
  display: flex; flex-direction: column; gap: .2rem;
  padding: .75rem .9rem; border-radius: 12px; margin-bottom: .6rem;
}
.feedback strong { font-size: 1rem; }
.feedback.ok { background: var(--good-soft); color: var(--good); }
.feedback.no { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.feedback .tiny { opacity: .85; }

/* end of lesson ---------------------------------------------------------- */
.celebrate { text-align: center; padding: 1.5rem 0 .5rem; }
.celebrate .big { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: 1.2rem; }
.ring {
  --pct: 0;
  width: 132px; height: 132px; margin: 0 auto; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--surface-2) 0);
}
.ring span {
  width: 104px; height: 104px; border-radius: 50%; background: var(--bg);
  display: grid; place-items: center; align-content: center;
  font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.ring small { display: block; font-size: .68rem; font-weight: 500; color: var(--ink-soft); letter-spacing: 0; }
.goal-hit { color: var(--good); font-weight: 650; margin-top: 1rem; }

/* --- conversación -------------------------------------------------------- */
.talk-card { border-left: 3px solid var(--accent); }
.thread { display: flex; flex-direction: column; gap: .5rem; padding: .25rem 0 1rem; }
.bubble {
  max-width: 85%; padding: .65rem .85rem; border-radius: 14px;
  font-size: .98rem; line-height: 1.45;
}
.bubble.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.bubble.me   { align-self: flex-end;   background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them .es-line { font-weight: 550; }
.bubble.them .en-line { color: var(--ink-soft); font-size: .85rem; margin-top: .2rem; }
.bubble.typing { color: var(--ink-faint); letter-spacing: .2em; }
.correction {
  align-self: flex-start; max-width: 85%;
  background: var(--surface-2); border-left: 3px solid var(--good);
  border-radius: 0 8px 8px 0; padding: .5rem .7rem; font-size: .85rem;
}
.correction strong { display: block; color: var(--good); }
.correction span { color: var(--ink-soft); }
.composer { display: flex; gap: .5rem; align-items: center; }
.composer .search { flex: 1; }
.composer .btn-primary { min-width: 56px; font-size: 1.1rem; }
