/* Langomo - learner UI */
:root {
  --paper: #F6F8FB;
  --surface: #FFFFFF;
  --ink: #14213D;
  --ink-soft: #52607A;
  --line: #DCE3EE;
  --cobalt: #2E5BFF;
  --cobalt-deep: #1D3FCC;
  --cobalt-tint: #E6ECFF;
  --sun: #FFC53D;
  --mint: #13A874;
  --mint-tint: #DDF5EC;
  --coral: #E5484D;
  --coral-tint: #FDE5E6;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Unbounded", "Onest", system-ui, sans-serif;
  --tabbar-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0E1525;
    --surface: #172136;
    --ink: #E9EEF7;
    --ink-soft: #A3AFC4;
    --line: #2A3651;
    --cobalt: #6E8BFF;
    --cobalt-deep: #9DB0FF;
    --cobalt-tint: #1F2C52;
    --mint-tint: #123A2E;
    --coral-tint: #45191C;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 16px/1.5 var(--font);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
body.is-auth:not(.is-bare) { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); }
a { color: var(--cobalt); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-size: clamp(1.55rem, 5vw, 2.1rem); }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Top bar (web) ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 960px; margin: 0 auto; padding: 14px 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 1.1rem var(--display); color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px 10px 10px 2px;
  background: var(--cobalt); color: #fff; display: grid; place-items: center; font-size: 1rem;
}
.topbar-nav { display: flex; align-items: center; gap: 14px; }
.topbar-nav > a { color: var(--ink); text-decoration: none; font-weight: 500; }
.lang-menu { position: relative; }
.lang-menu summary { cursor: pointer; list-style: none; font-weight: 600; padding: 6px 10px; border-radius: var(--radius-s); border: 1px solid var(--line); }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu-list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  min-width: 190px; padding: 6px; box-shadow: 0 10px 30px rgba(20, 33, 61, .12);
}
.lang-menu-list a { display: block; padding: 8px 10px; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; }
.lang-menu-list a:hover, .lang-menu-list a[aria-current] { background: var(--cobalt-tint); }

/* ---------- Page ---------- */
.page { max-width: 600px; margin: 0 auto; padding: 16px 18px 28px; }
.is-app .page { padding-top: calc(16px + env(safe-area-inset-top)); }
.page-bare { max-width: 640px; padding: 0; }
.flash { padding: 12px 14px; border-radius: var(--radius-m); margin-bottom: 16px; font-weight: 500; }
.flash-success { background: var(--mint-tint); color: var(--ink); }
.flash-error { background: var(--coral-tint); color: var(--ink); }
.site-footer { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; padding: 28px 16px 40px; font-size: .875rem; }
.site-footer a { color: var(--ink-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: var(--radius-m); border: 0;
  background: var(--cobalt); color: #fff; font: 600 1rem var(--font); text-decoration: none; cursor: pointer;
  box-shadow: 0 3px 0 var(--cobalt-deep);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--cobalt-deep); }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-block { width: 100%; }
.btn-small { min-height: 36px; padding: 0 14px; font-size: .9rem; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn-danger { background: var(--coral); box-shadow: 0 3px 0 #B3363A; }
.btn-google { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.linkbtn { background: none; border: 0; color: var(--ink-soft); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

/* ---------- Forms ---------- */
label { font-weight: 600; display: block; margin-bottom: 6px; }
input[type=text], input[type=email], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px;
}
textarea { min-height: 110px; resize: vertical; }
.field { margin-bottom: 18px; }

/* ---------- Landing ---------- */
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: clamp(2rem, 8vw, 3rem); }
.hero-lede { font-size: 1.1rem; color: var(--ink-soft); max-width: 34ch; }
.phrase-demo {
  margin: 26px 0; background: var(--surface); border-radius: var(--radius-l); padding: 22px;
  border: 1.5px solid var(--line); position: relative;
}
.phrase-demo .phr { font: 700 1.5rem/1.25 var(--display); }
.phrase-demo .tr { color: var(--ink-soft); margin-top: 6px; }
.phrase-demo .tag { position: absolute; top: -12px; inset-inline-start: 18px; background: var(--sun); color: #14213D; font-weight: 700; font-size: .8rem; padding: 3px 10px; border-radius: 99px; }
.how { display: grid; gap: 12px; margin: 26px 0; padding: 0; list-style: none; counter-reset: how; }
.how li { counter-increment: how; display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.how li::before { content: counter(how); width: 36px; height: 36px; border-radius: 50%; background: var(--cobalt-tint); color: var(--cobalt); display: grid; place-items: center; font-weight: 700; }

/* ---------- Login ---------- */
.auth-card { text-align: center; padding: 40px 8px; }
.auth-card .brand-mark { width: 64px; height: 64px; font-size: 1.8rem; margin: 0 auto 18px; border-radius: 18px 18px 18px 4px; }

/* ---------- Home ---------- */
.greet { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.streak { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; background: var(--surface); border: 1.5px solid var(--line); padding: 6px 12px; border-radius: 99px; }
.streak svg { width: 18px; height: 18px; fill: var(--sun); }
.plan-card {
  display: block; background: var(--surface); border-radius: var(--radius-l); padding: 18px;
  border: 1.5px solid var(--line); color: var(--ink); text-decoration: none; margin-bottom: 14px;
  border-inline-start: 8px solid var(--c, var(--cobalt));
}
.plan-card .row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.plan-card .pair { font-weight: 600; color: var(--ink-soft); font-size: .9rem; }
.today-box { margin-top: 14px; padding: 14px; border-radius: var(--radius-m); background: var(--cobalt-tint); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.today-box strong { display: block; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.bar > span { display: block; height: 100%; background: var(--mint); border-radius: 99px; }

/* ---------- Start wizard ---------- */
.wiz-step[hidden] { display: none; }
.wiz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.wiz-back { background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.wiz-back svg { width: 22px; height: 22px; }
.wiz-dots { display: flex; gap: 6px; margin-inline-start: auto; }
.wiz-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.wiz-dots i.on { background: var(--cobalt); }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 10px; text-align: start; width: 100%;
  padding: 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-m);
  font: 600 1rem var(--font); color: var(--ink); cursor: pointer;
}
.choice .flag { font-size: 1.5rem; }
.choice[aria-pressed=true] { border-color: var(--cobalt); background: var(--cobalt-tint); }
.choice[disabled] { opacity: .4; cursor: not-allowed; }
.concept-list { display: grid; gap: 10px; }
.concept {
  display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center; text-align: start; width: 100%;
  padding: 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-m);
  font: inherit; color: var(--ink); cursor: pointer;
}
.concept .ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem; background: color-mix(in srgb, var(--c, var(--cobalt)) 16%, transparent); }
.concept strong { display: block; }
.concept span.d { color: var(--ink-soft); font-size: .9rem; }
.concept[aria-pressed=true] { border-color: var(--c, var(--cobalt)); box-shadow: inset 0 0 0 1.5px var(--c, var(--cobalt)); }
.concept[disabled] { opacity: .45; cursor: not-allowed; }
.dur-list { display: grid; gap: 10px; }
.dur { text-align: start; }
.dur b { font: 700 1.25rem var(--display); display: block; }
.wiz-foot { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); padding-top: 16px; }

/* ---------- Plan roadmap ---------- */
.plan-head { margin-bottom: 18px; }
.plan-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 22px; }
.road { list-style: none; margin: 0; padding: 0; position: relative; }
.road::before { content: ""; position: absolute; inset-inline-start: 21px; top: 10px; bottom: 10px; width: 2px; background: var(--line); }
.road li { position: relative; display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; }
.road .dot { width: 44px; height: 44px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; z-index: 1; font-size: .9rem; }
.road li.done .dot { background: var(--mint); border-color: var(--mint); color: #fff; }
.road li.now .dot { background: var(--cobalt); border-color: var(--cobalt); color: #fff; box-shadow: 0 0 0 5px var(--cobalt-tint); }
.road li.locked { opacity: .55; }
.road .t { font-weight: 600; }
.road .k { font-size: .85rem; color: var(--ink-soft); }
.road a.go { font-weight: 600; text-decoration: none; }

/* ---------- Lesson player ---------- */
.lesson { min-height: 100vh; display: flex; flex-direction: column; padding: calc(12px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom)); }
.lesson-top { display: flex; align-items: center; gap: 12px; }
.lesson-top .close { background: none; border: 0; padding: 6px; color: var(--ink-soft); cursor: pointer; }
.lesson-top .close svg { width: 24px; height: 24px; }
.lesson-top .bar { flex: 1; margin: 0; height: 12px; }
.lesson-top .bar > span { background: var(--cobalt); transition: width .3s ease; }
.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 26px 0; }
.prompt-label { color: var(--ink-soft); font-weight: 600; margin-bottom: 14px; }
.phrase-card {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-l);
  padding: 26px 22px; position: relative; overflow: hidden;
}
.phrase-card::after {
  content: ""; position: absolute; inset-inline-end: 0; top: 0; bottom: 0; width: 10px;
  background: radial-gradient(circle at 100% 50%, var(--paper) 5px, transparent 5.5px) 0 0 / 10px 18px repeat-y;
}
[dir=rtl] .phrase-card::after { transform: scaleX(-1); }
.phr-target { font: 700 clamp(1.5rem, 6.5vw, 2.1rem)/1.2 var(--display); word-break: break-word; }
.phr-translit { color: var(--ink-soft); font-style: italic; margin-top: 6px; }
.phr-native { margin-top: 14px; font-size: 1.1rem; }
.phr-alts { margin-top: 16px; padding-top: 14px; border-top: 1.5px dashed var(--line); font-size: .95rem; }
.phr-alts b { display: block; color: var(--ink-soft); font-size: .8rem; font-weight: 600; margin-bottom: 4px; }
.say-row { display: flex; gap: 10px; margin-top: 18px; }
.say {
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--cobalt); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.say.slow { background: var(--cobalt-tint); color: var(--cobalt); }
.say svg { width: 24px; height: 24px; fill: currentColor; }
.opts { display: grid; gap: 10px; margin-top: 18px; }
.opt {
  text-align: start; padding: 15px 16px; background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius-m); font: 500 1.05rem var(--font); color: var(--ink); cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
}
.opt.sel { border-color: var(--cobalt); background: var(--cobalt-tint); }
.opt.right { border-color: var(--mint); background: var(--mint-tint); }
.opt.wrong { border-color: var(--coral); background: var(--coral-tint); }
.opt[disabled] { cursor: default; }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-grid .opt { font-size: .95rem; padding: 12px; }
.match-grid .opt.gone { visibility: hidden; }
.build-line { min-height: 64px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; align-content: flex-start; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip { padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font: 500 1rem var(--font); color: var(--ink); cursor: pointer; box-shadow: 0 2px 0 var(--line); }
.chip.used { visibility: hidden; }
.dlg { display: grid; gap: 10px; }
.bubble { max-width: 85%; padding: 12px 14px; border-radius: 18px; background: var(--surface); border: 1.5px solid var(--line); }
.bubble.b { justify-self: end; background: var(--cobalt-tint); border-color: transparent; }
.bubble .n { color: var(--ink-soft); font-size: .9rem; margin-top: 4px; }
.bubble button { background: none; border: 0; color: var(--cobalt); padding: 0; cursor: pointer; font: inherit; font-weight: 600; }
.mic {
  width: 88px; height: 88px; border-radius: 50%; border: 0; margin: 26px auto 8px; display: grid; place-items: center;
  background: var(--coral); color: #fff; cursor: pointer; box-shadow: 0 5px 0 #B3363A;
}
.mic svg { width: 38px; height: 38px; fill: currentColor; }
.mic.live { animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(229,72,77,.5); } 100% { box-shadow: 0 0 0 22px rgba(229,72,77,0); } }
.heard { text-align: center; color: var(--ink-soft); min-height: 1.5em; }
.feedback {
  position: sticky; bottom: 0; margin: 0 -18px calc(-18px - env(safe-area-inset-bottom)); padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1.5px solid var(--line);
}
.feedback.ok { background: var(--mint-tint); border-color: var(--mint); }
.feedback.no { background: var(--coral-tint); border-color: var(--coral); }
.feedback .msg { font-weight: 700; margin-bottom: 4px; }
.feedback .sol { margin-bottom: 12px; }
.result { text-align: center; }
.result .big { font: 700 3.4rem var(--display); color: var(--cobalt); }
.result .stats { display: flex; justify-content: center; gap: 20px; margin: 14px 0 26px; font-weight: 600; }

/* ---------- Mastery bar ---------- */
.mwrap { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: 18px; }
.mlabel { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.mbar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.mbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--sun), var(--mint)); border-radius: 99px; transition: width .5s ease; }
.mpct { font-size: .85rem; min-width: 3ch; text-align: end; }
.book-item .mbar { height: 6px; margin-top: 6px; max-width: 160px; }

/* ---------- Phrasebook ---------- */
.book-unit { margin-bottom: 24px; }
.book-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.book-item .tx { font-weight: 600; font-size: 1.05rem; }
.book-item .nv { color: var(--ink-soft); font-size: .92rem; }
.book-item .say { width: 42px; height: 42px; }
.book-search { margin-bottom: 18px; }

/* ---------- Settings ---------- */
.set-group { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-l); padding: 18px; margin-bottom: 16px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; }
.set-row + .set-row { border-top: 1px solid var(--line); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-soft); text-decoration: none; font-size: .75rem; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--cobalt); }
.tabbar { max-width: 600px; margin: 0 auto; }
@media (min-width: 640px) { .tabbar { border-inline: 1px solid var(--line); border-radius: var(--radius-l) var(--radius-l) 0 0; } }

/* ---------- Legal / misc ---------- */
.prose h2 { margin-top: 1.6em; }
.prose { max-width: 70ch; }
.empty { text-align: center; padding: 40px 10px; }
