/* Accent Trainer's own look, after the shell every tool shares (../shell/shell.css: the colours and fonts, the brand,
   the score, the settings and their "i", the windows, the phone sheets). What is here is its own layout (the course
   down the left, the recording and the paragraph in the middle, the settings and this set on the right) and its
   subject: the cards in the middle (class acard: .acard is the shell's windows), the player, the answers, the cues. */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 80% at 50% 30%, #121e28 0%, #0d151c 45%, var(--bg) 78%) fixed, var(--bg);
  line-height: 1.45;
  overflow: auto;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }

/* ---------- frame ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 322px;   /* (the settings as wide as in every tool) */
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px 16px;
  padding-block: calc(env(safe-area-inset-top, 0px) + 14px) calc(env(safe-area-inset-bottom, 0px) + 14px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- brand, score ---------- */
/* (the shell's pieces placed in this tool's own grid: .app > …; never restyled here) */
.app > .brand, .app > .stats { align-self: center; }
.stat small { white-space: nowrap; }
/* ---------- shared pieces ---------- */
.btn.big { padding: 10px 18px; font-size: 14px; }
.btn.quiet { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.quiet:hover { color: var(--fg); border-color: var(--line-strong); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
kbd { font-family: var(--f-mono); font-size: 11px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 4px; color: var(--fg); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.meter { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--scan); border-radius: 2px; transition: width .35s ease; }
.meter.done i { background: var(--ok); }
a { color: var(--scan); text-underline-offset: 2px; }

/* ---------- left: the course ---------- */
.app > .rail { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; align-self: start; max-height: 100%; min-height: 0; }
.rail-level { margin: 10px 6px 4px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rail-level:first-child { margin-top: 2px; }
.rail-level em { font-style: normal; font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.rail-level .label { letter-spacing: 0.1em; }
.rail .meter { height: 2px; }
.rail button.set {
  color: var(--fg); background: transparent; border: 1px solid transparent; border-radius: 7px; cursor: pointer; text-align: start;
  padding: 6px 9px 7px; display: grid; gap: 5px; font-size: 13.5px; font-weight: 650;
}
.rail button.set .top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rail button.set em { font-style: normal; font-family: var(--f-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.rail button.set:hover { background: var(--bg-lift); }
.rail button.set[aria-pressed="true"] { border-color: var(--scan); background: #13232c; }
.rail button.set[aria-pressed="true"] em { color: var(--scan); }
.rail .close-sheet { display: none; align-self: flex-end; }

/* ---------- right: settings and this set ---------- */
.app > .panel { width: auto; justify-self: stretch; }   /* (as wide as its column, which is the settings' width) */
.accent-rows { display: grid; gap: 2px; }
.accent-row { background: transparent; border: 0; border-radius: 6px; padding: 5px 6px; cursor: pointer; text-align: start; display: grid; gap: 4px; }
.accent-row:hover { background: var(--bg-lift); }
.accent-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.accent-row .top span:last-child { font-family: var(--f-mono); font-size: 11px; color: var(--muted); }

/* ---------- centre: the stage ---------- */
.stage { grid-column: 2; grid-row: 2; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; outline: none; padding-bottom: 8px; }
.stage > * { width: min(100%, 780px); margin-inline: auto; }
.stage > * + * { margin-top: 12px; }
.acard {
  background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong); border-radius: var(--r); padding: 18px 20px; display: grid; gap: 12px;
}
.acard.is-ok { border-color: var(--ok); }
.acard.is-bad { border-color: var(--bad); }
.acard h1 { font-weight: 750; font-stretch: 112%; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.12; color: var(--bone); text-wrap: balance; }
.acard h2 { font-weight: 700; font-stretch: 108%; font-size: 17px; color: var(--bone); }
.acard p { color: var(--muted); max-width: 68ch; text-wrap: pretty; }
.acard p b, .acard li b { color: var(--fg); font-weight: 600; }
.lede { font-size: 15px; color: var(--fg) !important; }
.crumbs { font-size: 12px; color: var(--muted); }
.meta { font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.start { text-align: start; }
.facts { display: flex; gap: 22px; flex-wrap: wrap; }
.facts div { display: grid; gap: 1px; }
.facts b { font-family: var(--f-mono); font-size: 18px; font-weight: 600; color: var(--bone); }
.facts small { font-size: 11px; color: var(--muted); }

/* the recording */
.listen { display: flex; align-items: center; gap: 16px; }
.play {
  --p: 0; flex: none; width: 68px; height: 68px; border-radius: 50%; border: 0; cursor: pointer; position: relative;
  background: conic-gradient(var(--scan) calc(var(--p) * 1turn), var(--line-strong) 0);
  display: grid; place-items: center;
}
.play::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--bg-lift); }
.play:hover::before { background: #16222c; }
.play svg { position: relative; width: 24px; height: 24px; fill: var(--bone); }
.play .i-pause, .play .i-load, .play .i-warn { display: none; }
.play[data-status="playing"] .i-play, .play[data-status="loading"] .i-play, .play[data-status="error"] .i-play { display: none; }
.play[data-status="playing"] .i-pause { display: block; }
.play[data-status="loading"] .i-load { display: block; animation: spin 0.9s linear infinite; }
.play[data-status="error"] .i-warn { display: block; fill: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }
.play.small { width: 34px; height: 34px; }
.play.small::before { inset: 2px; }
.play.small svg { width: 13px; height: 13px; }
.listen-text { display: grid; gap: 3px; min-width: 0; }
.listen-actions { margin-inline-start: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.listen-text .who { font-size: 14.5px; color: var(--fg); }
.apill { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-lift); border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 12px 3px 3px; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.apill:hover { border-color: var(--scan); }

/* answers */
.answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 7px; }
.answer {
  text-align: start; background: var(--bg-lift); border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 12px; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: baseline;
}
.answer kbd { grid-row: 1; align-self: center; }
.answer b { font-weight: 650; font-size: 14.5px; }
.answer small { grid-column: 2; color: var(--muted); font-size: 12px; line-height: 1.4; }
.answer:hover:not(:disabled) { border-color: var(--scan); }
.answer:disabled { cursor: default; opacity: .5; }
.answer.is-right { border-color: var(--ok); opacity: 1; background: rgba(95, 211, 154, 0.08); }
.answer.is-wrong { border-color: var(--bad); opacity: 1; background: rgba(255, 122, 107, 0.08); }
.answer.is-picked { border-color: var(--scan); opacity: 1; }

/* feedback */
.acard h1.verdict.ok { color: var(--ok); }
.acard h1.verdict.bad { color: var(--bad); }
kbd.on-primary { color: inherit; border-color: rgba(0, 0, 0, 0.35); }
.field.flag { margin-inline-start: auto; color: var(--muted); max-width: 110px; }
.tip { border-inline-start: 2px solid var(--close); padding: 2px 0 2px 12px; color: var(--fg) !important; }
.tip .label { display: block; margin-bottom: 2px; color: var(--close); }

/* cues: what to listen for */
.cues { display: grid; gap: 4px; list-style: none; margin: 0; padding: 0; }
.cue { display: grid; grid-template-columns: 112px 1fr; gap: 2px 12px; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 7px 9px; cursor: pointer; text-align: start; width: 100%; }
.cue:hover { background: var(--bg-lift); }
.cue[aria-pressed="true"] { border-color: var(--scan); background: rgba(111, 208, 232, 0.07); }
.cue .kind { font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); padding-top: 3px; }
.cue b { font-weight: 650; font-size: 14px; color: var(--fg); }
.cue span.d { grid-column: 2; color: var(--muted); font-size: 13px; line-height: 1.45; }
.cue[aria-pressed="true"] .kind { color: var(--scan); }
.cue.shared b { font-weight: 600; }
.cues-from { margin: 8px 0 0 9px; }

/* the paragraph every speaker reads */
.passage { font-size: 18px; line-height: 1.75; font-stretch: 96%; color: #6f7f8c; display: grid; gap: 2px; }
.passage span.w { border-radius: 3px; padding: 1px 1px; transition: color .15s, background .15s; }
.passage span.w.hit { color: var(--bone); background: rgba(111, 208, 232, 0.14); box-shadow: inset 0 -2px 0 var(--scan); }
.passage.plain { color: var(--fg); }
.passage-note { font-size: 12px; color: var(--muted); }

/* learn */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 13px; font-weight: 600; color: var(--fg); background: var(--bg-lift); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed="true"] { border-color: var(--scan); color: var(--scan); background: rgba(111, 208, 232, 0.09); }
.chip.sub { font-weight: 500; color: var(--muted); }
.picker { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; }
.picker select { width: 100%; }
.picker select, .field { font-size: 13px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 10px; max-width: 100%; }
.picker select:focus, .field:focus { outline: none; border-color: var(--scan); }
.voices { display: grid; gap: 10px; }
.voices.two { grid-template-columns: 1fr 1fr; gap: 16px; }
.voices.two .listen { flex-wrap: wrap; }
.voices.two .listen-text { flex: 1; }
.voices.two .listen-actions { margin-inline-start: 0; width: 100%; justify-content: flex-start; }
.voice h3 { font-size: 15px; font-weight: 700; color: var(--bone); margin-bottom: 8px; }
.duo { display: grid; grid-template-columns: 96px 1fr 1fr; gap: 0 14px; }
.duo > div { padding: 7px 0; border-top: 1px solid var(--line); min-width: 0; }
.duo > .kind { font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); padding-top: 16px; }
.duo > .head { border-top: 0; font-weight: 700; color: var(--bone); padding-top: 0; }
.duo > .none { color: var(--line-strong); padding-top: 14px; }
.duo .cue { grid-template-columns: 1fr; padding: 6px 8px; }
.duo .cue .kind { display: none; }
.duo .cue span.d { grid-column: 1; }

/* results and progress */
/* a test's result: the shell's result block (.review, .res-*, .pill) in the first card */
.acard.result { position: relative; }
.acard.result > .pill { position: absolute; top: 14px; inset-inline-end: 18px; }
.acard.result > .pill ~ .review { margin-top: 0; }
.acard.result:has(> .pill) > .eyebrow { padding-inline-end: 104px; }   /* (the pill never covers it) */
.table { display: grid; gap: 0; }
.trow { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(60px, 1fr) 64px 84px; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.trow.head { border-top: 0; padding-top: 0; }
.trow .num { font-family: var(--f-mono); font-size: 12px; color: var(--muted); text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trow .label.num { font-family: var(--f-display); font-size: 10.5px; }
.trow button.link { background: none; border: 0; padding: 0; cursor: pointer; text-align: start; color: var(--fg); font-weight: 600; }
.trow button.link:hover { color: var(--scan); }
.misses { display: grid; gap: 6px; list-style: none; margin: 0; padding: 0; }
.misses li { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.misses li > div { display: grid; gap: 1px; min-width: 0; flex: 1; }
.misses .said { color: var(--muted); font-size: 12.5px; }
.mix { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.mix:first-of-type { border-top: 0; }
.mix div { display: grid; gap: 1px; }
.mix small { color: var(--muted); font-size: 12px; }

/* ---------- the tool's own dialogs (in the shell's .overlay) ---------- */
.dialog { width: min(480px, 100%); max-height: 86vh; overflow-y: auto; background: var(--bg-lift); border: 1px solid var(--line-strong); border-radius: 14px; padding: 22px; display: grid; gap: 14px; }
.dialog.wide { width: min(640px, 100%); }
.dialog h2 { font-weight: 800; font-stretch: 118%; font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--scan); }
.dialog p { color: var(--muted); }
.dialog .actions { justify-content: flex-end; }
.tree { display: grid; gap: 1px; }
.tree label { display: flex; align-items: center; gap: 9px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.tree label:hover { background: var(--bg); }
.tree label.off { color: var(--muted); cursor: default; }
.tree label em { margin-inline-start: auto; font-style: normal; font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.tree input { accent-color: var(--scan); margin: 0; }
/* ---------- dock (phones, clean view) ---------- */
.dock { display: none; }
#cleanExit { display: none; }

/* ---------- clean view, for recording ---------- */
body.clean .rail, body.clean .panel, body.clean .brand .sub, body.clean .stats { display: none; }
body.clean .app { grid-template-columns: minmax(0, 1fr); }
body.clean .brand, body.clean .stage { grid-column: 1; }
body.clean .brand { justify-self: center; }
body.clean .app { grid-template-rows: auto minmax(0, 1fr) auto; }
body.clean .stage { grid-row: 2; }
body.clean .stage > * { width: min(100%, 900px); }
body.clean .dock { display: flex; grid-row: 3; justify-content: center; }
body.clean .dock .btn { display: none; }
body.clean #cleanExit { display: inline-block; opacity: .55; }
body.clean .passage { font-size: 22px; }

/* ---------- medium screens: settings move under the course ---------- */
@media (max-width: 1280px) and (min-width: 901px) {
  .app { grid-template-columns: 300px minmax(0, 1fr); }
  .app > .stats { grid-column: 2; justify-self: end; }
  .stats .stat:last-child { display: none; }
  .app > .rail { max-height: 52%; }
  .app > .panel { grid-column: 1; grid-row: 2; align-self: end; max-height: 46%; }
}

/* ---------- phones ---------- */
@media (max-width: 900px) {
  html, body { height: auto; }
  .app { height: auto; min-height: 100dvh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; align-content: start; gap: 10px; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 70px); }
  .app > .brand, .app > .stats, .stage { grid-column: 1; grid-row: auto; }
  .app > .stats { justify-self: center; }
  .stage { overflow: visible; }
  .acard { padding: 14px; }
  .passage { font-size: 16px; line-height: 1.7; }
  .cue { grid-template-columns: 1fr; }
  .cue span.d { grid-column: 1; }
  .answers { grid-template-columns: 1fr 1fr; }
  .answer { padding: 9px 10px; }
  .answer kbd { display: none; }
  .answer { grid-template-columns: 1fr; }
  .answer small { grid-column: 1; }
  .voices.two { grid-template-columns: 1fr; }
  .picker { grid-template-columns: auto minmax(0, 1fr); }
  .listen { flex-wrap: wrap; }
  .listen-actions { margin-inline-start: 0; width: 100%; justify-content: flex-start; }
  .field.flag { margin-inline-start: 0; }
  .duo { grid-template-columns: 1fr 1fr; gap: 0 8px; }
  .duo > .kind { grid-column: 1 / -1; padding-bottom: 0; }
  .duo > .kind + div, .duo > .kind + div + div { border-top: 0; padding-top: 2px; }
  .duo > .head.kind { display: none; }
  .trow { grid-template-columns: minmax(0, 1.4fr) minmax(40px, 1fr) 48px 64px; gap: 8px; font-size: 13px; }
  /* the course is a bottom sheet like the settings (the settings' sheet is the shell's: body.sheet-open) */
  .app > .rail {
    position: fixed; left: 0; right: 0; bottom: 0; max-height: 76vh; z-index: 15; align-self: auto;
    border-radius: 16px 16px 0 0; border-bottom: 0; background: var(--bg-lift);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    transform: translateY(105%); transition: transform .25s ease; visibility: hidden;
  }
  body.sheet-rail .app > .rail { transform: none; visibility: visible; }
  .rail .close-sheet { display: inline-block; }
  .dock {
    display: flex; gap: 6px; justify-content: center; position: fixed; left: 0; right: 0; z-index: 10;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  }
  body.clean .dock { position: fixed; }
}
@media (max-width: 420px) { .answers { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Right to left (Arabic, Persian, Hebrew), the course itself stays English: each piece of it (a set's name and blurb,
   an accent's name, hint and cues, the paragraph) takes its direction from its own first letter, so "Which part of
   the world?" keeps its question mark at the end. A translated line there starts with a word of its language. */
[dir="rtl"] :is(.rail button.set, .rail-level .label, .acard h1, .acard h2, .lede, .cue, .passage, .passage-note, .listen-text, .answer b, .answer small, .voice h3),
[dir="rtl"] :is(.rail button.set, .cue, .passage, .passage-note) * {
  unicode-bidi: plaintext;
}
