/* Layout: one working column — header with shared level/topic, tabbed desk below; dictation lines read like a tape transcript */
:root{
  --bg:#E9EEF2; --surface:#FFFFFF; --sunk:#F3F6F8; --line:#D3DCE3;
  --fg:#13202B; --muted:#5A6B78;
  --accent:#0D6577; --accent-ink:#FFFFFF; --accent-soft:#D6EBEF;
  --mark:#F6DC5A; --ok:#1E7A46; --ok-soft:#DDF1E4; --err:#B4322A; --err-soft:#F8E0DD; --miss:#8A5A00; --miss-soft:#FBEBC8;
  --f-display:"Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body:"Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono:"JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r:10px;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#0E161C; --surface:#152129; --sunk:#101A21; --line:#26353F;
  --fg:#E4ECF1; --muted:#93A6B3;
  --accent:#4FB7C9; --accent-ink:#06222A; --accent-soft:#163A43;
  --mark:#C9AE2E; --ok:#5CCB8A; --ok-soft:#163626; --err:#F0857C; --err-soft:#3B1D1B; --miss:#E9B95A; --miss-soft:#3A2E14;
  color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#0E161C; --surface:#152129; --sunk:#101A21; --line:#26353F;
  --fg:#E4ECF1; --muted:#93A6B3;
  --accent:#4FB7C9; --accent-ink:#06222A; --accent-soft:#163A43;
  --mark:#C9AE2E; --ok:#5CCB8A; --ok-soft:#163626; --err:#F0857C; --err-soft:#3B1D1B; --miss:#E9B95A; --miss-soft:#3A2E14;
  color-scheme:dark}

*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
[hidden]{display:none!important}
body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.5 var(--f-body);
  padding-left:max(16px, env(safe-area-inset-left, 0px));padding-right:max(16px, env(safe-area-inset-right, 0px));padding-block:20px 48px}
.wrap{max-width:860px;margin:0 auto;display:flex;flex-direction:column;gap:18px}
h1,h2,h3{font-family:var(--f-display);text-wrap:balance;margin:0;line-height:1.15}
button,select,input,textarea{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

header.top{display:flex;flex-wrap:wrap;align-items:end;justify-content:space-between;gap:14px}
.brand h1{font-size:clamp(28px,5vw,40px);font-weight:800;letter-spacing:-.02em}
.brand h1 .amp{color:var(--accent)}
.brand p{margin:2px 0 0;color:var(--muted);font-size:15px}
.prefs{display:flex;flex-wrap:wrap;gap:10px;align-items:end}
.field{display:flex;flex-direction:column;gap:3px}
.lbl{font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted);font-weight:600}
select,input[type=text],textarea{background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:8px 10px}
select{padding-right:28px}
#topicCustom{width:180px}

nav.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);overflow-x:auto}
nav.tabs button{background:none;border:0;padding:10px 14px;font-weight:600;color:var(--muted);border-bottom:3px solid transparent;margin-bottom:-1px;cursor:pointer;white-space:nowrap}
nav.tabs button[aria-selected=true]{color:var(--fg);border-color:var(--accent)}

.desk{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:clamp(16px,3vw,26px);display:flex;flex-direction:column;gap:18px}
.row{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.spread{justify-content:space-between}
.btn{display:inline-flex;align-items:center;gap:7px;border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:8px 14px;font-weight:600;cursor:pointer;line-height:1.2}
.btn:hover{border-color:var(--accent)}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.ghost{border-color:transparent;background:transparent;color:var(--muted)}
.btn.ghost:hover{color:var(--fg)}
.btn[disabled]{opacity:.5;cursor:default}
.btn svg{width:15px;height:15px;flex:none}
.icon{width:36px;height:36px;padding:0;justify-content:center;border-radius:50%}
.seg{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden}
.seg button{border:0;background:var(--surface);padding:7px 11px;font-family:var(--f-mono);font-size:13px;cursor:pointer}
.seg button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink)}
.note{color:var(--muted);font-size:14px;margin:0}
.kbd{font-family:var(--f-mono);font-size:12px;border:1px solid var(--line);border-bottom-width:2px;border-radius:4px;padding:0 5px;background:var(--sunk)}
.chip{display:inline-block;font-size:12px;font-weight:600;padding:2px 9px;border-radius:999px;background:var(--accent-soft);color:var(--fg)}
.eyebrow{font-size:12px;text-transform:uppercase;letter-spacing:.09em;color:var(--muted);font-weight:700}

/* dictation */
.dhead h2{font-size:24px}
.dhead p{margin:4px 0 0;color:var(--muted)}
.lines{display:flex;flex-direction:column;gap:2px;counter-reset:ln}
.line{display:grid;grid-template-columns:auto auto 1fr;gap:6px 12px;align-items:center;padding:10px 8px;border-radius:var(--r);border-left:3px solid transparent}
.line.playing{background:var(--accent-soft);border-left-color:var(--accent)}
.who{font-family:var(--f-mono);font-size:12px;width:92px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.who b{display:inline-grid;place-items:center;width:20px;height:20px;border-radius:5px;background:var(--fg);color:var(--bg);font-size:11px;margin-right:6px}
.who.B b{background:var(--accent);color:var(--accent-ink)}
.ctrls{display:flex;gap:4px}
.ctrls .btn{width:36px;height:36px;padding:0;justify-content:center;border-radius:50%}
.line input{width:100%;min-width:0;font-family:var(--f-mono);font-size:16px;padding:9px 11px}
.result{grid-column:3;min-width:0;font-family:var(--f-mono);font-size:14px;line-height:1.9;word-wrap:break-word}
.result .sc{font-family:var(--f-body);font-weight:700;font-size:12px;margin-right:8px;padding:1px 7px;border-radius:5px}
.sc.good{background:var(--ok-soft);color:var(--ok)} .sc.mid{background:var(--miss-soft);color:var(--miss)} .sc.bad{background:var(--err-soft);color:var(--err)}
.w-ok{color:var(--ok)}
del.w{color:var(--err);background:var(--err-soft);text-decoration:line-through;border-radius:3px;padding:0 2px}
ins.w{color:var(--fg);background:var(--mark);text-decoration:none;border-radius:3px;padding:0 3px;font-weight:500}
:root[data-theme="dark"] ins.w{color:#111}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]) ins.w{color:#111}}
ins.w.miss{background:var(--miss-soft);color:var(--miss);border:1px dashed var(--miss)}
.reveal{grid-column:3;font-family:var(--f-mono);font-size:14px;color:var(--muted)}
@media (max-width:560px){
  .line{grid-template-columns:auto 1fr;padding:10px 4px}
  .who{grid-column:1/-1;width:auto}
  .result,.reveal{grid-column:1/-1}
  .line input{font-size:17px;padding:11px 12px}
  .ctrls .btn{width:44px;height:44px}
  .btn{min-height:44px}
  .seg button{min-height:40px;padding:8px 13px}
  #dKeys{display:none}
}
.line.cur{background:var(--sunk)}
.line.cur.playing{background:var(--accent-soft)}
.summary{display:flex;flex-wrap:wrap;gap:18px;align-items:center;padding:14px 16px;background:var(--sunk);border-radius:var(--r)}
.big{font-family:var(--f-display);font-size:40px;font-weight:800;line-height:1;font-variant-numeric:tabular-nums}
.vocab{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:6px 18px;margin:0;padding:0;list-style:none}
.vocab li{font-size:15px;border-bottom:1px dotted var(--line);padding:4px 0}
.vocab b{font-weight:600}
.ai-out{white-space:pre-wrap;background:var(--sunk);border-radius:var(--r);padding:14px 16px;font-size:15px;line-height:1.6}
.voices{display:flex;flex-wrap:wrap;gap:10px}
.voices select{max-width:230px}
details.settings summary{cursor:pointer;color:var(--muted);font-weight:600;font-size:14px}
details.settings[open] summary{margin-bottom:10px}

/* translation */
.ru{font-family:var(--f-display);font-size:clamp(22px,3.6vw,30px);font-weight:700;letter-spacing:-.01em;line-height:1.25}
.counter{font-family:var(--f-mono);font-size:13px;color:var(--muted)}
textarea#trIn{width:100%;min-height:96px;resize:vertical;font-size:17px;line-height:1.5;padding:12px 14px}
.verdict{display:grid;grid-template-columns:auto 1fr;gap:16px;align-items:center;padding:14px 16px;background:var(--sunk);border-radius:var(--r)}
.verdict p{margin:2px 0 0}
.versions{display:grid;gap:10px}
.ver{border:1px solid var(--line);border-radius:var(--r);padding:12px 14px;display:flex;flex-direction:column;gap:4px;min-width:0}
.ver .en{font-size:18px;line-height:1.45}
.ver.natural{border-color:var(--accent);background:var(--accent-soft)}
.mlist{display:flex;flex-direction:column;gap:10px;margin:0;padding:0;list-style:none}
.mist{border-left:3px solid var(--err);background:var(--sunk);border-radius:0 var(--r) var(--r) 0;padding:10px 14px;display:flex;flex-direction:column;gap:4px}
.mist .pair{font-size:16px;display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.mist .rule{font-size:14px;color:var(--muted)}
.alts{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:6px}
.status{font-size:14px;color:var(--muted);display:flex;gap:8px;align-items:center}
.spin{width:14px;height:14px;border:2px solid var(--line);border-top-color:var(--accent);border-radius:50%;animation:sp 0.8s linear infinite}
@keyframes sp{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion: reduce){.spin{animation-duration:3s}}
.err-msg{color:var(--err);font-size:14px}

/* progress */
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:10px}
.stat{background:var(--sunk);border-radius:var(--r);padding:12px 14px}
.stat .big{font-size:32px}
.bars{display:flex;align-items:end;gap:3px;height:56px;padding-top:4px}
.bars span{flex:1;max-width:14px;background:var(--accent);border-radius:2px 2px 0 0;min-height:2px;opacity:.85}
.bars span.lo{background:var(--err)}
table.mt{width:100%;border-collapse:collapse;font-size:15px}
.tbl{overflow-x:auto}
table.mt th{text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:var(--muted);padding:6px 8px;border-bottom:1px solid var(--line)}
table.mt td{padding:8px;border-bottom:1px solid var(--line);vertical-align:top}
.empty{color:var(--muted);text-align:center;padding:24px}

/* ---------- app chrome: account, install, offline, update ---------- */
.top-actions{display:flex;gap:8px;align-items:center;margin-left:auto}
.acct{display:inline-flex;align-items:center;gap:8px;border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:5px 12px 5px 5px;font-weight:600;cursor:pointer;min-height:40px}
.acct .av{display:grid;place-items:center;width:30px;height:30px;border-radius:50%;background:var(--accent);color:var(--accent-ink);font-family:var(--f-display);font-weight:800;font-size:14px}
.acct.out .av{background:var(--sunk);color:var(--muted)}
.acct .st{font-size:13px;color:var(--muted);font-weight:500}
.banner{display:flex;gap:10px;align-items:center;padding:10px 14px;border-radius:var(--r);background:var(--miss-soft);color:var(--fg);font-size:15px}
.banner b{color:var(--miss)}
dialog.sheet{border:0;border-radius:16px;padding:0;background:var(--surface);color:var(--fg);width:min(440px, calc(100% - 24px));max-height:calc(100% - 24px);box-shadow:0 20px 60px rgba(0,0,0,.3)}
dialog.sheet::backdrop{background:rgba(10,20,28,.45)}
.sheet-in{padding:22px;display:flex;flex-direction:column;gap:14px}
.sheet-in h2{font-size:22px}
.sheet-in form{display:flex;flex-direction:column;gap:10px}
.sheet-in input[type=email],.sheet-in input[type=password]{width:100%;font-size:16px;padding:11px 12px}
.sheet-in .btn{justify-content:center;min-height:44px}
.gbtn{background:var(--surface)}
.gbtn svg{width:18px;height:18px}
.or{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:13px}
.or::before,.or::after{content:"";flex:1;height:1px;background:var(--line)}
.linkbtn{background:none;border:0;padding:0;color:var(--accent);font:inherit;font-size:14px;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
.steps{margin:0;padding-left:20px;display:flex;flex-direction:column;gap:8px}
.ok-msg{color:var(--ok);font-size:14px}
.toastbtn{margin-left:10px;background:var(--accent);color:var(--accent-ink);border:0;border-radius:6px;padding:4px 10px;font-weight:700;cursor:pointer}

/* ---------- phone dictation bar: sits above the on-screen keyboard ---------- */
#mbar{position:fixed;left:0;right:0;bottom:0;z-index:15;background:var(--surface);border-top:1px solid var(--line);
  padding:8px max(12px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  display:flex;gap:8px;align-items:center;box-shadow:0 -6px 20px rgba(0,0,0,.08)}
#mbar .btn{min-height:48px;flex:1;justify-content:center;padding:8px 6px;font-size:15px}
#mbar .btn.primary{flex:1.4}
#mbar .pos{font-family:var(--f-mono);font-size:13px;color:var(--muted);min-width:42px;text-align:center}
body.has-mbar{padding-bottom:calc(88px + env(safe-area-inset-bottom, 0px))}
@media (min-width:561px) and (pointer:fine){#mbar{display:none!important} body.has-mbar{padding-bottom:48px}}
@media (display-mode: standalone){body{padding-block-start:max(12px, env(safe-area-inset-top, 0px))}}
