/* Paso a Paso: warm cream, Spanish red and saffron. Phone first, light and dark. */
:root {
  --bg: #faf6f0; --card: #fff; --ink: #1e1a16; --muted: #6e665c; --line: #ece4d9;
  --brand: #c23a2b; --brand-ink: #fff; --brand-soft: #fbe9e5; --sun: #f1b51c; --sun-soft: #fdf3d7;
  --ok: #23804a; --ok-soft: #e2f3e8; --bad: #b3261e; --bad-soft: #fbe4e2; --her: #fff; --me: #c23a2b;
  --shadow: 0 1px 2px rgb(60 40 20 / .05), 0 6px 20px rgb(60 40 20 / .06); --r: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110e; --card: #1f1b17; --ink: #f4eee6; --muted: #a69d91; --line: #342e27;
    --brand: #e2533f; --brand-soft: #3a1d18; --sun: #f5c33b; --sun-soft: #3a2f12;
    --ok: #5cc386; --ok-soft: #16301f; --bad: #ff8a80; --bad-soft: #3b1a17; --her: #26211c; --me: #c8412f;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.err { color: var(--bad); font-size: 14px; min-height: 0; }
.err:empty { display: none; }

/* layout */
.page { padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 32px); display: flex; flex-direction: column; gap: 16px; }
.page > .top { margin: calc(-16px - env(safe-area-inset-top)) -16px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--sun); display: grid; place-items: center; font-size: 22px; font-weight: 800; line-height: 1; }
.home-top { display: flex; justify-content: space-between; align-items: center; }

/* buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.big { min-height: 54px; font-size: 17px; width: 100%; }
.btn.bad { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:active { background: var(--line); }
.icon-btn.ghost { visibility: hidden; }
label { font-size: 14px; font-weight: 650; margin-top: 4px; }
input, textarea, select { width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
input:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible, b.es:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; font-weight: 650; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); outline: 1px solid var(--line); }

/* welcome */
.welcome { gap: 20px; padding-top: calc(env(safe-area-inset-top) + 24px); }
.hero h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.hero h1 em { color: var(--brand); font-style: normal; }
.lead { margin-top: 10px; color: var(--muted); font-size: 17px; }
.features { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.features li { display: flex; gap: 10px; align-items: center; font-weight: 550; }
.features svg { color: var(--brand); flex: none; }
.resume summary { cursor: pointer; font-weight: 650; }
.resume form { margin-top: 12px; }

/* home */
.hello { font-size: 30px; font-weight: 800; margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.stat .n { font-size: 24px; font-weight: 800; display: flex; align-items: center; gap: 4px; }
.stat .n svg { color: var(--brand); }
.stat .k { font-size: 12.5px; color: var(--muted); }
.now { display: flex; flex-direction: column; gap: 8px; border-top: 4px solid var(--brand); }
.now h2 { font-size: 24px; font-weight: 800; }
.now .row { margin-top: 8px; }
.bar { height: 10px; border-radius: 99px; background: var(--sun-soft); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--sun); border-radius: inherit; transition: width .4s; }
.review-cta { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.cta-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--sun-soft); color: #9a6b00; display: grid; place-items: center; flex: none; }
@media (prefers-color-scheme: dark) { .cta-icon { color: var(--sun); } }
.review-cta > div:nth-child(2) { flex: 1; }
.badge { background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: 14px; min-width: 28px; height: 28px; border-radius: 99px; display: grid; place-items: center; padding: 0 8px; }
.course h3 { font-size: 20px; font-weight: 800; margin: 8px 0 4px; }
.unit { margin-top: 14px; }
.unit h4 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.lessons { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.lessons li + li { border-top: 1px solid var(--line); }
.lessons button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; min-height: 52px; }
.lessons .dot { width: 28px; height: 28px; border-radius: 99px; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 800; background: var(--line); color: var(--muted); }
.lessons .done .dot { background: var(--ok-soft); color: var(--ok); }
.lessons .current .dot { background: var(--brand); color: var(--brand-ink); }
.lessons .current button { font-weight: 700; background: var(--brand-soft); }
.lessons .locked button { color: var(--muted); }
.l-n { display: none; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 10px 8px; background: color-mix(in srgb, var(--bg) 90%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.top-title strong { font-size: 17px; }
.top-title .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring-btn { color: var(--brand); background: var(--brand-soft); }

/* avatar */
.avatar { width: 40px; height: 40px; border-radius: 99px; background: linear-gradient(135deg, var(--brand), var(--sun)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: 15px; }
.avatar.xl { width: 120px; height: 120px; font-size: 52px; }

/* chat */
.chat-page { display: flex; flex-direction: column; height: 100dvh; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.msg p + p, .msg p + ul, .msg ul + p, .msg blockquote + p, .msg p + blockquote { margin-top: 8px; }
.msg ul { margin: 0; padding-left: 20px; }
.msg blockquote { margin: 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); font-size: 14px; }
.msg blockquote p + p { margin-top: 4px; }
.msg.me { align-self: flex-end; background: var(--me); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg-wrap { display: flex; gap: 8px; align-items: flex-start; max-width: 100%; }
.msg-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: calc(100% - 40px); }
.msg.her { max-width: 100%; background: var(--her); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--shadow); }
b.es { color: var(--brand); font-weight: 750; cursor: pointer; border-bottom: 1.5px dotted color-mix(in srgb, var(--brand) 50%, transparent); }
b.es:active { background: var(--brand-soft); border-radius: 4px; }
.msg-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hear { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 99px; padding: 5px 11px; font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; }
.hear svg { color: var(--brand); }
.hear.busy, b.es.busy { opacity: .55; animation: blink 1s infinite; }
.tag { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 4px 10px; font-size: 12.5px; font-weight: 650; }
.tag.new { background: var(--sun-soft); color: #7a5500; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
@media (prefers-color-scheme: dark) { .tag.new { color: var(--sun); } }
.done-banner { background: var(--ok-soft); color: var(--ok); border-radius: 14px; padding: 10px 14px; font-weight: 700; }
.typing { display: flex; gap: 5px; padding: 14px 16px; }
.typing span, .loading span { width: 7px; height: 7px; border-radius: 99px; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2), .loading span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3), .loading span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.loading { display: flex; gap: 6px; justify-content: center; padding: 40px 0; }
.dock { border-top: 1px solid var(--line); background: var(--bg); padding: 8px 10px calc(env(safe-area-inset-bottom) + 10px); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 140px; border-radius: 22px; padding: 11px 16px; line-height: 1.35; background: var(--card); }
.send, .mic { width: 44px; height: 44px; border-radius: 99px; border: 0; display: grid; place-items: center; flex: none; cursor: pointer; }
.send { background: var(--brand); color: #fff; }
.send:disabled { opacity: .5; }
.mic { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.mic.on { background: var(--brand); color: #fff; border-color: var(--brand); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 45%, transparent); } 50% { box-shadow: 0 0 0 8px transparent; } }

/* review */
.review-stage { display: flex; flex-direction: column; gap: 14px; }
.progress-row { display: flex; align-items: center; gap: 10px; }
.progress { flex: 1; height: 8px; border-radius: 99px; background: var(--line); position: relative; overflow: hidden; }
.progress::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); background: var(--sun); border-radius: inherit; }
.flash { min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.q-text { font-size: 28px; font-weight: 800; line-height: 1.25; }
.answer { display: flex; flex-direction: column; align-items: center; gap: 10px; border-top: 1px dashed var(--line); padding-top: 14px; width: 100%; }
.a-text { font-size: 24px; font-weight: 750; color: var(--brand); }
.grade .btn { min-height: 54px; }
.big-num { font-size: 52px; font-weight: 800; color: var(--brand); }

/* settings */
.code-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.code { flex: 1; font: 700 18px/1.4 ui-monospace, Menlo, monospace; letter-spacing: .06em; background: var(--bg); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; text-align: center; min-width: 220px; }
.card h3 { font-size: 17px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 14.5px; font-weight: 600; max-width: calc(100% - 32px); width: max-content; z-index: 50; box-shadow: 0 8px 30px rgb(0 0 0 / .2); transition: opacity .3s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; }

/* call */
.call { position: fixed; inset: 0; z-index: 40; background: linear-gradient(180deg, #2a1410, #120d0a); color: #fff; display: flex; justify-content: center; animation: fade .2s; }
.call.closing { opacity: 0; transition: opacity .2s; }
@keyframes fade { from { opacity: 0; } }
.call-inner { width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 48px) 20px calc(env(safe-area-inset-bottom) + 28px); text-align: center; }
.call .muted { color: #cdbfb3; }
.call h2 { font-size: 28px; margin-top: 12px; }
.call-face { border-radius: 99px; padding: 6px; transition: box-shadow .2s; }
.call-face.talking { box-shadow: 0 0 0 8px rgb(241 181 28 / .25), 0 0 0 18px rgb(241 181 28 / .1); }
.call-status { margin-top: 8px; font-weight: 650; }
.call-clock { font-variant-numeric: tabular-nums; color: #cdbfb3; min-height: 1.5em; }
.call-learned { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.call-learned .chip { background: rgb(241 181 28 / .18); color: #ffd877; border: 0; border-radius: 99px; padding: 4px 10px; font-size: 14px; }
.call-caps { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; text-align: left; font-size: 15px; overflow: hidden; padding: 12px 4px; }
.call-caps p { color: #eadfd6; }
.call-caps strong { color: #ffd877; }
.call-caps p[data-who="you"] strong { color: #fff; }
.call-actions { display: flex; gap: 40px; }
.call-btn { width: 72px; height: 72px; border-radius: 99px; border: 0; background: rgb(255 255 255 / .14); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; }
.call-btn[aria-pressed="true"] { background: #fff; color: #120d0a; }
.call-btn.end { background: #e0352b; }
.call-btn.end svg { transform: rotate(135deg); }

@media (min-width: 600px) {
  .page { padding-top: 32px; }
  .chat-page { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* phone setup page */
.steps { margin: 0; padding-left: 22px; display: grid; gap: 12px; }
.steps .btn { margin: 4px 0; min-height: 40px; }
.setup h3 { font-size: 18px; }

/* level picker */
.levels { display: grid; gap: 8px; }
.levels button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; cursor: pointer; }
.levels button span { font-size: 13.5px; color: var(--muted); }
.levels button.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
select { appearance: auto; min-height: 46px; }

/* lesson player */
.lesson-bar { height: 4px; background: var(--line); }
.lesson-bar i { display: block; height: 100%; width: 0; background: var(--sun); transition: width .3s; }
.lesson-dock { display: flex; flex-direction: column; gap: 8px; }
.lesson-dock .composer input { border-radius: 22px; padding: 11px 16px; background: var(--card); }
.show-box { text-align: center; font-size: 22px; font-weight: 800; padding: 8px 12px; border-radius: 14px; background: var(--sun-soft); }
.choices { display: grid; gap: 8px; }
.choices .btn { justify-content: flex-start; min-height: 50px; text-align: left; }
.bigmic { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 96px; border-radius: 20px; border: 2px dashed var(--brand); background: var(--brand-soft); color: var(--brand); font: inherit; font-weight: 750; cursor: pointer; }
.bigmic.on { border-style: solid; animation: pulse 1.2s infinite; }
.row-links { display: flex; justify-content: center; gap: 18px; }
.linkbtn { border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 6px; }
.msg.fb-right { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: var(--ok-soft); }
.msg.fb-wrong { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); background: var(--bad-soft); }
