/* 🚀 SpeakSlava · ВІДЛУ́ННЯ look v1 (Echo · Shadow · Record & compare) · 🔁🌊🇺🇦 ВІДЛУ́ННЯ · 2026-09-26
   Two looks: gold (family) and stone (stone + soft blue). Fonts come from the engine kit (e-Ukraine, Charis SIL). */
:root, :root[data-look="gold"] {
  --bg: #F4EEDF; --surface: #FFFCF4; --ink: #16223A; --stone: #6A6252; --ghost: #6E6655;
  --rule: #E1D6BF; --outline: #8F8163; --mark: #F1D98E; --mark-soft: #F6E7BA;
  --primary: #E2B84F; --on-primary: #16223A; --w1: #2B55C7; --w2: #9C7418; --track: #E6DCC6; --medal: #2C3A56; --rec: #A3262A;
}
:root[data-look="stone"] {
  --bg: #EAE5DB; --surface: #F9F6EF; --ink: #1E2531; --stone: #5C584F; --ghost: #6B665C;
  --rule: #D6CFC1; --outline: #857D6E; --mark: #C9DAF0; --mark-soft: #DCE7F5;
  --primary: #3E5F8A; --on-primary: #F9F6EF; --w1: #2F5E9E; --w2: #1E2531; --track: #D8D1C3; --medal: #3A4254; --rec: #A3262A;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "e-Ukraine", "Noto Sans", system-ui, sans-serif; }
button { font-family: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--w1); outline-offset: 2px; border-radius: 8px; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 0 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.view { display: flex; flex-direction: column; flex: 1 1 auto; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; height: 72px; flex: 0 0 auto; }
.wordmark { font-size: 19px; font-weight: 700; letter-spacing: -0.2px; }
.wordmark .w1 { color: var(--w1); } .wordmark .w2 { color: var(--w2); }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--outline); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }

/* title row + medals */
.titlerow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.progname .uk { font-size: 24px; font-weight: 700; line-height: 1.15; }
.en-serif, .progname .en, .pt-en, .en-line, .gloss, .row-en, .set-en { font-family: "Charis SIL", Georgia, serif; font-style: italic; }
.progname .en { font-size: 16px; color: var(--stone); }
.medals { display: flex; gap: 2px; }
.medal { width: 40px; height: 52px; border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; color: var(--stone); font-size: 11px; }
.medal .disc { width: 28px; height: 28px; border-radius: 14px; background: var(--medal); display: flex; align-items: center; justify-content: center; }
.medal .disc svg { width: 14px; height: 14px; }
.medal[aria-pressed="true"] { color: var(--ink); font-weight: 700; }
.medal[aria-pressed="true"] .disc { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary); }
.medal:disabled { opacity: .35; cursor: default; }
.rule { height: 1px; border: 0; background: var(--rule); margin: 14px 0 18px; width: 100%; }

/* pattern title */
.pattern-title { align-self: flex-start; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.pt-row { display: flex; align-items: center; gap: 10px; }
.pt-uk { white-space: nowrap; font-size: 38px; font-weight: 700; line-height: 1.1; letter-spacing: -0.5px; }
.pt-en { font-size: 17px; color: var(--stone); }
.pt-row svg { width: 22px; height: 22px; flex: 0 0 auto; }
mark { background: var(--mark); color: inherit; border-radius: 5px; padding: 0 2px; }
.ghostrow mark { background: var(--mark-soft); }
.no-mark mark { background: none; padding: 0; }

/* KWIC stack: left context right-aligned, verb right-aligned (endings stack), right context left-aligned */
.kwic { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, max-content); justify-content: center; column-gap: 0; align-items: baseline; }
.kwic .c1 { text-align: right; }
.kwic .c2 { text-align: left; }
.wrow { display: flex; flex-wrap: wrap; column-gap: .3em; row-gap: 4px; align-items: flex-start; align-self: start; }
.c1.wrow { justify-content: flex-end; }
.c2.wrow { justify-content: flex-start; column-gap: 0; }
.c2.wrow > .wb.rest { margin-left: .3em; }
.wb { display: inline-flex; flex-direction: column; align-items: center; }
.wb.stem { align-items: flex-end; }
.wb.end, .wb.post { align-items: flex-start; }
.wu { white-space: nowrap; }
.wg { font-family: "Charis SIL", Georgia, serif; font-style: italic; font-size: 15px; color: var(--stone); line-height: 1.3; white-space: nowrap; margin-top: 2px; font-weight: 400; }
.stack { margin-top: 26px; row-gap: 8px; }
.ghostrow { font-size: 19px; color: var(--ghost); }

.currow { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: start; border: 0; background: none; padding: 4px 0; cursor: pointer; font-size: 30px; line-height: 1.2; color: var(--ink); }
.currow.long { font-size: 25px; }

.glossrow { font-size: 15px; color: var(--stone); }
.hiddenline { border: 0; background: none; cursor: pointer; font-family: inherit; grid-column: 1 / -1; text-align: center; font-size: 30px; color: var(--ghost); letter-spacing: 6px; padding: 4px 0; }
.w4w-line { grid-column: 1 / -1; text-align: center; }

.meaning { display: flex; flex-direction: column; gap: 6px; margin-top: 22px; text-align: center; }
.en-line { font-size: 21px; line-height: 1.3; }
.say-line { font-family: "Charis SIL", Georgia, serif; font-size: 15px; color: var(--stone); letter-spacing: .2px; }
.ipa-line { font-family: "Charis SIL", "Doulos SIL", Georgia, serif; font-size: 15px; color: var(--stone); }
.tier { align-self: center; font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--stone); border: 1px solid var(--outline); border-radius: 10px; padding: 2px 8px; margin-top: 4px; }

.spacer { flex: 1 1 auto; min-height: 16px; }

/* your-turn ring */
.turn { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.ring { width: 128px; height: 128px; position: relative; display: flex; align-items: center; justify-content: center; }
.ring svg.track { position: absolute; inset: 0; width: 128px; height: 128px; }
.ring .icon { position: relative; width: 38px; height: 38px; color: var(--ink); }
.turn-label { font-size: 21px; font-weight: 700; }

.progress { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 13px; color: var(--stone); }
.progress .bar { flex: 1 1 auto; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.progress .bar > span { display: block; height: 100%; background: var(--primary); }

/* controls */
.controls { display: flex; align-items: center; justify-content: center; gap: 16px; }
.round { width: 56px; height: 56px; border-radius: 28px; border: 1px solid var(--outline); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.round svg { width: 22px; height: 22px; }
.round:disabled { opacity: .35; cursor: default; }
.primary { min-width: 180px; height: 68px; border-radius: 34px; border: 0; background: var(--primary); color: var(--on-primary); font-size: 22px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; padding: 0 28px; }
.primary svg { width: 22px; height: 22px; }
.pill { height: 52px; border-radius: 26px; border: 1px solid var(--outline); background: var(--surface); font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; padding: 0 22px; cursor: pointer; }
.pill svg { width: 16px; height: 16px; }
.subrow { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 12px; }
.text-btn { min-height: 44px; border: 0; background: none; padding: 0 12px; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; border-radius: 22px; }
.text-btn svg { width: 18px; height: 18px; }
.text-btn[aria-pressed="true"] svg path { fill: var(--primary); }

/* pattern view */
.back { align-self: flex-start; min-height: 44px; border: 0; background: none; padding: 0 12px 0 0; font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.back svg { width: 22px; height: 22px; }
.pattern-h1 { white-space: nowrap; margin: 6px 0 0; font-size: 42px; font-weight: 700; line-height: 1.1; letter-spacing: -0.5px; }
.list { margin-top: 18px; border-top: 1px solid var(--rule); row-gap: 0; }
.listrow { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: baseline; row-gap: 3px; border: 0; border-bottom: 1px solid var(--rule); background: none; padding: 10px 0; text-align: left; cursor: pointer; font-size: 21px; color: var(--ink); }

.listrow .row-en { grid-column: 1 / -1; text-align: center; font-size: 14px; color: var(--stone); }
.listrow.playing { background: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 16px; }
.chip { min-height: 44px; border-radius: 22px; border: 1px solid var(--outline); background: var(--surface); padding: 0 16px; font-size: 16px; font-weight: 700; cursor: pointer; }
.wide { width: 100%; }

/* done */
.done { margin-top: 28px; background: var(--surface); border: 1px solid var(--rule); border-radius: 22px; padding: 30px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.done .check { width: 72px; height: 72px; border-radius: 36px; background: var(--primary); color: var(--on-primary); display: flex; align-items: center; justify-content: center; }
.done .big { font-size: 28px; font-weight: 700; }
.done .small { font-size: 15px; color: var(--stone); }
.stackbtns { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }

/* dialogs (settings + pattern picker) */
dialog { border: 0; padding: 0; width: 100%; max-width: 480px; max-height: 100dvh; height: 100%; margin: 0 auto; background: var(--bg); color: var(--ink); }
dialog::backdrop { background: rgba(22, 34, 58, .45); }
.sheet { padding: 0 20px 28px; }
.sheet-head { position: sticky; top: 0; z-index: 1; background: var(--bg); display: flex; align-items: center; justify-content: space-between; height: 72px; }
.sheet-head h2 { margin: 0; font-size: 24px; }
.group { padding: 14px 0 20px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 12px; }
.group h3 { margin: 0; font-size: 17px; }
.field-label { font-size: 14px; color: var(--stone); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 44px; border-radius: 22px; border: 1px solid var(--outline); background: var(--surface); padding: 0 14px; font-size: 15px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 700; }
.seg button:disabled { opacity: .4; cursor: default; }
.switchrow { display: flex; align-items: center; justify-content: space-between; min-height: 44px; font-size: 16px; }
.switch { width: 52px; height: 30px; border-radius: 15px; border: 0; background: var(--outline); padding: 3px; display: flex; justify-content: flex-start; cursor: pointer; }
.switch span { width: 24px; height: 24px; border-radius: 12px; background: var(--surface); }
.switch[aria-checked="true"] { background: var(--ink); justify-content: flex-end; }
.switch[aria-checked="true"] span { background: var(--mark); }
.looks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lookbtn { height: 72px; border-radius: 16px; border: 1px solid var(--outline); background: var(--surface); font-size: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.lookbtn[aria-pressed="true"] { border: 2px solid var(--ink); font-weight: 700; }
.dots { display: flex; gap: 4px; } .dots span { width: 16px; height: 16px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.setlist { display: flex; flex-direction: column; }
.setrow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-height: 64px; border: 0; border-bottom: 1px solid var(--rule); background: none; padding: 10px 0; text-align: left; cursor: pointer; }
.setrow[aria-current="true"] .set-uk { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.set-uk { font-size: 23px; font-weight: 700; white-space: nowrap; }
.set-en { font-size: 15px; color: var(--stone); display: block; }
.set-count { font-size: 14px; color: var(--stone); white-space: nowrap; }
.foot { font-size: 12px; color: var(--stone); padding-top: 14px; text-align: center; }

@media (min-width: 700px) { .app { padding-top: 12px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* browsers without subgrid: rows keep working, columns may not line up */
@supports not (grid-template-columns: subgrid) { .currow, .listrow { display: contents; } .listrow .row-en { padding-bottom: 10px; border-bottom: 1px solid var(--rule); } }

/* small phones: medals a little narrower so the title row never spills */
@media (max-width: 380px) { .medal { width: 34px; } .progname .uk { font-size: 22px; } }

/* context lines above and below: sized by the current line, never wider than it allows */
.stack:not(.nocur) .ghostrow { contain: inline-size; white-space: nowrap; overflow: hidden; }
.stack .c1.ghostrow { direction: rtl; }
.stack .c1.ghostrow > .in { direction: ltr; unicode-bidi: isolate; }
.stack .c1.ghostrow.clip { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 32px); mask-image: linear-gradient(to right, transparent 0, #000 32px); }
.stack .c2.ghostrow.clip { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 32px); mask-image: linear-gradient(to left, transparent 0, #000 32px); }

/* ---------- v1 family additions ---------- */
.stack.q, .list.q { grid-template-columns: minmax(2.4em, max-content) minmax(0, max-content); }
.set-group { margin: 18px 0 2px; font-size: 13px; font-weight: 700; color: var(--stone); letter-spacing: .2px; }
.setlist .set-group:first-child { margin-top: 0; }
.wb.end.whole .wg { align-self: flex-start; }

/* Shadow */
.shadow-now { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 18px; }
.shadow-now .big { font-size: 21px; font-weight: 700; }
.shadow-now .small { font-size: 15px; color: var(--stone); }
.clipbar { height: 6px; border-radius: 3px; background: var(--track); margin-top: 22px; overflow: hidden; }
.clipbar > span { display: block; height: 100%; width: 0; background: var(--primary); }

/* Record & compare */
.panel { margin-top: 20px; background: var(--surface); border: 1px solid var(--rule); border-radius: 18px; padding: 6px 14px; display: flex; flex-direction: column; transition: opacity .2s; }
.panel.dim { opacity: .45; pointer-events: none; }
.track { display: flex; align-items: center; gap: 12px; min-height: 62px; }
.track + .track { border-top: 1px solid var(--rule); }
.play-sm { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--ink); color: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; padding: 0; }
.play-sm.you { background: var(--primary); color: var(--on-primary); }
.play-sm svg { width: 16px; height: 16px; }
.play-sm:disabled { opacity: .35; cursor: default; }
.play-sm.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--w2); }
.track-body { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-width: 0; }
.track-name { font-size: 14px; font-weight: 700; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; min-height: 22px; align-self: flex-start; }
canvas.wave { width: 100%; height: 26px; display: block; }
.toggles { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.toggle { min-height: 44px; border-radius: 22px; border: 1px solid var(--outline); background: var(--surface); padding: 0 16px; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toggle svg { width: 16px; height: 16px; }
.toggle[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.recrow { display: flex; align-items: center; justify-content: center; gap: 14px; }
.recbtn { width: 80px; height: 80px; border-radius: 40px; border: 4px solid var(--primary); background: var(--surface); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.recbtn .dot { width: 28px; height: 28px; border-radius: 14px; background: var(--rec); }
.recbtn.recording { border-color: var(--rec); }
.recbtn.recording .dot { border-radius: 6px; }
.reclabel { font-size: 13px; font-weight: 700; margin-top: 6px; text-align: center; }
.rec-timer { text-align: center; font-size: 18px; font-weight: 700; color: var(--rec); margin-bottom: 8px; }
.rec-note { text-align: center; font-size: 14px; color: var(--stone); min-height: 20px; margin-top: 10px; }
.sidebtn { min-height: 52px; border-radius: 26px; border: 1px solid var(--outline); background: var(--surface); font-size: 15px; font-weight: 700; padding: 0 14px; cursor: pointer; max-width: 118px; line-height: 1.15; }
.sidebtn:disabled { opacity: .35; cursor: default; }
.sidebtn.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--w2); }
.privacy { text-align: center; font-size: 13px; color: var(--stone); margin-top: 8px; }
.kwic .c1.lead { padding-right: .3em; }
