/* Layout: one calm reading column. Colour codes the three kinds of point (mistake, more native, vocabulary);
   the accent ink marks what you can act on. Mobile gets a bottom tab bar, wider screens a top nav. */
:root {
  --paper: #f5f6fa;
  --surface: #ffffff;
  --sunk: #eef0f6;
  --ink: #1b2340;
  --muted: #5b6482;
  --line: #dde1ec;
  --pen: #2a3ccf;
  --pen-soft: #e6e9fb;
  --on-pen: #ffffff;
  --erro: #c2352a;
  --erro-soft: #fbe9e7;
  --nat: #0b7566;
  --nat-soft: #e1f3ef;
  --voc: #9a5b00;
  --voc-soft: #fbf0dc;
  --f-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --r: 12px;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #11141d; --surface: #191d29; --sunk: #141824; --ink: #e5e8f2; --muted: #98a0bb; --line: #2b3144;
    --pen: #8f9dff; --pen-soft: #23284a; --on-pen: #11141d;
    --erro: #ff8074; --erro-soft: #3a1f1f; --nat: #52d2bb; --nat-soft: #15302c; --voc: #f2b55a; --voc-soft: #352a16;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.55;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
.app { max-width: 720px; margin: 0 auto; padding-block: 0 48px; }

/* ---------- header and navigation ---------- */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding-block: 12px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--f-display); font-weight: 800; font-size: 1.35rem; letter-spacing: -0.02em; background: none; border: 0; color: var(--ink); cursor: pointer; padding: 0; margin-right: auto; }
.brand img { display: block; border-radius: 7px; }
.nav-top { display: flex; gap: 2px; }
.nav-top button { font: inherit; font-size: 0.95rem; border: 0; background: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.nav-top button svg { width: 18px; height: 18px; }
.nav-top button[aria-current="true"] { background: var(--pen-soft); color: var(--pen); font-weight: 700; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.lang button { font: inherit; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; border: 0; background: none; color: var(--muted); padding: 4px 9px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.nav-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: none; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
}
.nav-bottom button { font: inherit; font-size: 0.75rem; border: 0; background: none; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 16px; border-radius: 10px; min-width: 72px; }
.nav-bottom button svg { width: 24px; height: 24px; }
.nav-bottom button[aria-current="true"] { color: var(--pen); font-weight: 700; }
@media (max-width: 640px) {
  .nav-top { display: none; }
  .nav-bottom:not([hidden]) { display: flex; }
  body.has-tabbar .app { padding-bottom: calc(var(--tabbar) + 32px); }
  body.has-tabbar .toast { bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(1.7rem, 6vw, 2.2rem); line-height: 1.1; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 600; line-height: 1.25; }
p { margin: 0; }
.lede { color: var(--muted); max-width: 60ch; }
.hint { font-size: 0.85rem; color: var(--muted); }
.eyebrow { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
/* Small label in front of a line ("You said", "Example"). */
.lab { display: block; font-family: var(--f-body); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 8px; }
.stack.loose { gap: 28px; }
.section { display: flex; flex-direction: column; gap: 22px; padding-top: 24px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.row.spread { justify-content: space-between; }
.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.head-row > div { min-width: 0; flex: 1 1 280px; }

/* ---------- controls ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 16px; border-radius: var(--r); white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
}
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--pen); border-color: var(--pen); color: var(--on-pen); }
.btn.big { padding: 14px 22px; font-size: 1.02rem; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); padding-inline: 4px; }
.section > .btn.ghost { align-self: flex-start; }
.btn.danger { color: var(--erro); }
.btn.small { font-size: 0.88rem; padding: 6px 12px; min-height: 36px; }
.btn:disabled { opacity: 0.55; cursor: progress; }
:is(.btn, .mastery, .nav-top button, .nav-bottom button, .lang button, textarea, input, select, .chip, .lesson, .listen, .mic, .seg button, .link):focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }
.link { font: inherit; background: none; border: 0; color: var(--pen); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; align-self: flex-start; }

.listen {
  font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px;
  border: 1px solid var(--line); background: var(--surface); color: var(--pen); border-radius: 999px; padding: 2px 11px 2px 9px;
}
.listen svg { width: 14px; height: 14px; }
.with-listen { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.with-listen > :first-child { min-width: 0; }

.mic {
  font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 10px 18px; min-height: 48px;
  background: var(--erro); color: #fff;
}
.mic svg { width: 20px; height: 20px; }
.mic.on { background: var(--ink); color: var(--paper); }
.mic.on .rec { width: 12px; height: 12px; border-radius: 50%; background: var(--erro); animation: pulse 1s ease-in-out infinite; }
.mic.round { width: 56px; height: 56px; padding: 0; }
.answer-row { display: flex; gap: 10px; align-items: center; }
.answer-row textarea { flex: 1; }

label.field, .field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 0.95rem; }
textarea, input[type="text"], input[type="date"], input[type="time"], input[type="email"], input[type="password"], select {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; width: 100%;
}
textarea { min-height: 220px; resize: vertical; font-size: 0.95rem; line-height: 1.5; }
.answer-row textarea, .composer textarea { min-height: 56px; }
textarea:disabled { opacity: 0.6; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.chips, .filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font: inherit; font-size: 0.88rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--pen); background: var(--pen-soft); color: var(--pen); font-weight: 700; }
.chip small { color: var(--muted); font-weight: 400; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); padding: 3px; gap: 3px; align-self: flex-start; }
.seg button { font: inherit; font-size: 0.92rem; border: 0; background: none; color: var(--muted); padding: 7px 14px; border-radius: 9px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 0.92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--pen); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.note { border: 1px dashed var(--line); border-radius: var(--r); padding: 12px 14px; color: var(--muted); font-size: 0.92rem; }
.note.warn { border-style: solid; border-color: var(--voc); color: var(--ink); background: var(--voc-soft); }
.empty { text-align: center; padding: 28px 16px; }
.busy { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.95rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pen); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }
@media (prefers-reduced-motion: reduce) { .dot, .mic.on .rec { animation: none; } }
.err { color: var(--erro); font-size: 0.95rem; }

/* ---------- auth ---------- */
.auth { max-width: 400px; display: flex; flex-direction: column; gap: 16px; padding-top: 40px; }
.auth form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- home ---------- */
.today { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--pen-soft); border-radius: 18px; padding: 20px; }
.today-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 220px; }
.today h2 { color: var(--pen); font-size: 1.3rem; }
.today-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stats b { font-family: var(--f-display); font-size: 1.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stats span { font-size: 0.8rem; color: var(--muted); line-height: 1.3; }

.lessons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lesson {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; width: 100%;
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px;
}
.lesson:hover { border-color: var(--pen); }
.date-tile { text-align: center; line-height: 1.05; font-family: var(--f-display); }
.date-tile b { display: block; font-size: 1.5rem; font-weight: 800; }
.date-tile span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.lesson-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.lesson-title { font-weight: 700; font-size: 1.05rem; }
.chev { color: var(--muted); font-size: 1.6rem; line-height: 1; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; }
.count { font-size: 0.78rem; padding: 1px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.count.erro { background: var(--erro-soft); color: var(--erro); }
.count.natural { background: var(--nat-soft); color: var(--nat); }
.count.vocab { background: var(--voc-soft); color: var(--voc); }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--nat); border-radius: 3px; transition: width 0.3s; }
.bar.big { height: 8px; }
.bar.big i { background: var(--pen); }

/* ---------- lesson ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { font: inherit; font-weight: 700; font-size: 0.95rem; border: 0; background: none; color: var(--muted); padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--pen); }
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }

/* Kind chips name what a card is. */
.kind { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; align-self: flex-start; }
.kind-erro { background: var(--erro-soft); color: var(--erro); }
.kind-natural { background: var(--nat-soft); color: var(--nat); }
.kind-vocab { background: var(--voc-soft); color: var(--voc); }
.kind-ex, .kind-sample { background: var(--pen-soft); color: var(--pen); }
.lesson-title .kind { margin-left: 6px; vertical-align: 2px; }

.group { display: flex; flex-direction: column; gap: 12px; }
.group-title { display: flex; align-items: baseline; gap: 10px; }
.group-title span { color: var(--muted); font-size: 0.9rem; }
.pt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.pt-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.said-text { color: var(--muted); }
.pt.erro .said-text { text-decoration: line-through; text-decoration-color: var(--erro); text-decoration-thickness: 2px; }
.better { font-size: 1.12rem; font-weight: 700; }
.why { font-size: 0.95rem; }
.ex { font-size: 0.95rem; color: var(--ink); }
.pt-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.pt-from { font-size: 0.8rem; color: var(--muted); min-width: 0; text-align: right; }

.mastery { font: inherit; display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); background: none; border: 0; padding: 4px 0; cursor: pointer; text-align: left; min-width: 0; }
.mastery .dots { display: inline-flex; gap: 4px; flex: none; }
.mastery i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--nat); display: inline-block; }
.mastery i.on { background: var(--nat); }
.mastery .q { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); font-size: 0.72rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.mastery.done { color: var(--nat); font-weight: 700; }
.mastery.locked { color: var(--pen); }
.mastery.locked i { background: var(--pen); border-color: var(--pen); }
.help { font-size: 0.9rem; background: var(--sunk); border-radius: 10px; padding: 10px 12px; }

.say { display: flex; flex-direction: column; gap: 12px; background: var(--pen-soft); border-radius: var(--r); padding: 14px; }
.say-label { font-size: 0.9rem; font-weight: 700; color: var(--pen); }
.say .target { font-weight: 700; font-size: 1.25rem; line-height: 1.35; }
.say mark { background: var(--erro-soft); color: var(--erro); border-radius: 3px; padding: 0 2px; }
.result { font-size: 0.95rem; }
.result b { font-family: var(--f-display); font-size: 1.1rem; margin-right: 4px; }
.result.ok b { color: var(--nat); }
.result.miss { color: var(--voc); font-weight: 700; }

/* ---------- practice and exercises ---------- */
.ex-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ex-prompt { font-size: 1.2rem; font-weight: 700; line-height: 1.4; }
.locked { background: var(--sunk); border-radius: 10px; padding: 10px 12px; }
.feedback { border-radius: 10px; padding: 12px 14px; font-size: 0.95rem; display: flex; flex-direction: column; gap: 8px; }
.feedback.certo { background: var(--nat-soft); }
.feedback.quase { background: var(--voc-soft); }
.feedback.errado { background: var(--erro-soft); }
.verdict { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; align-self: flex-start; padding: 3px 9px; border-radius: 999px; background: var(--surface); }
.verdict.certo { color: var(--nat); } .verdict.quase { color: var(--voc); } .verdict.errado { color: var(--erro); }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.results li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.results .verdict { background: var(--sunk); }
.results .ex-prompt { font-size: 1rem; }
.done-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- conversation ---------- */
.chat-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.steps { display: flex; gap: 4px; }
.steps i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); display: inline-block; }
.steps i.done { background: var(--nat); }
.steps i.miss { background: var(--voc); }
.steps i.now { background: var(--pen); }
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; }
.msg.ai { background: var(--surface); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; display: flex; flex-direction: column; gap: 8px; }
.msg.ai .listen { align-self: flex-start; }
.msg.me { background: var(--pen); color: var(--on-pen); align-self: flex-end; border-bottom-right-radius: 4px; }
.fix { align-self: flex-end; max-width: 85%; background: var(--nat-soft); border-radius: 12px; padding: 10px 12px; font-size: 0.92rem; display: flex; flex-direction: column; gap: 2px; }
.fix .lab { color: var(--nat); }
.fix s { color: var(--muted); text-decoration-color: var(--erro); }
.hit { align-self: flex-end; font-size: 0.82rem; font-weight: 700; color: var(--nat); }
.target-hint { background: var(--pen-soft); color: var(--pen); border-radius: 10px; padding: 8px 12px; font-size: 0.92rem; }
.composer { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.composer textarea { flex: 1 1 200px; }

/* ---------- profile ---------- */
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.field.inline input { width: auto; }
.ok-line { color: var(--nat); font-weight: 700; }
.install-card { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.install-card img { border-radius: 10px; }
.install-card .row { grid-column: 1 / -1; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.panel .stats > div { background: var(--sunk); border-color: transparent; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); font-size: 0.92rem; z-index: 20; max-width: calc(100% - 32px); }

/* Conversation report */
.chat-report { display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.chat-report h2 { font-size: 1.25rem; }
.rep-group { display: flex; flex-direction: column; gap: 8px; }
.rep-group h3 { font-size: 0.8rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.rep-group.ok h3 { color: var(--nat); }
.rep-group.miss h3 { color: var(--erro); }
.rep-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rep-group li { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--sunk); min-width: 0; overflow-wrap: anywhere; }
.rep-group li s { color: var(--muted); text-decoration-color: var(--erro); }
.rep-said { font-size: 0.9rem; color: var(--muted); }
.rep-note { font-size: 0.85rem; color: var(--muted); }
.rep-group.ok .rep-note { color: var(--nat); font-weight: 700; }
