/* B2 Trainer — mobile-first shell. Tokens first; dark theme via prefers-color-scheme or data-theme. */
:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #eef1f6; --border: #dde2ea;
  --text: #1b2430; --muted: #5d6a7c; --primary: #1f5fbf; --primary-ink: #fff; --primary-soft: #e3edfb;
  --ok: #1d8a4e; --ok-soft: #e1f4e9; --err: #c73636; --err-soft: #fbe5e5; --warn: #b26a00; --warn-soft: #fdf0d9;
  --topbar: #1f3a5f; --topbar-ink: #fff;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 2px 8px rgba(16,24,40,.06);
  --sidebar-w: 18rem; --topbar-h: 3.5rem;
  --fs-scale: 1;              /* per-device text size (A− / A+), set from JS */
  --fs-base: 16px;            /* grows with the screen, see media queries below */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #171e27; --surface-2: #1e2732; --border: #2b3644;
    --text: #e6ebf2; --muted: #9aa7b8; --primary: #5b9cf5; --primary-ink: #0b1220; --primary-soft: #1b2b44;
    --ok: #4cc283; --ok-soft: #14301f; --err: #f07272; --err-soft: #3a1a1a; --warn: #f0b049; --warn-soft: #3a2a10;
    --topbar: #131b26; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #171e27; --surface-2: #1e2732; --border: #2b3644;
  --text: #e6ebf2; --muted: #9aa7b8; --primary: #5b9cf5; --primary-ink: #0b1220; --primary-soft: #1b2b44;
  --ok: #4cc283; --ok-soft: #14301f; --err: #f07272; --err-soft: #3a1a1a; --warn: #f0b049; --warn-soft: #3a2a10;
  --topbar: #131b26; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { font-size: calc(var(--fs-base) * var(--fs-scale)); }
@media (min-width: 1280px) { :root { --fs-base: 17px; } }
@media (min-width: 1600px) { :root { --fs-base: 18.5px; } }
@media (min-width: 2200px) { :root { --fs-base: 21px; } }
body { background: var(--bg); color: var(--text); font: 1rem/1.55 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 8px; padding: 0 8px 0 4px;
  padding-top: env(safe-area-inset-top);
  background: var(--topbar); color: var(--topbar-ink);
}
.topbar .title { flex: 1; min-width: 0; line-height: 1.2; }
.topbar .title b { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { display: block; font-size: .8rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 2.75rem; height: 2.75rem; display: inline-grid; place-items: center; flex: none;
  background: transparent; border: 0; border-radius: 10px; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn svg { width: 1.5rem; height: 1.5rem; }
.topbar-slot { display: flex; align-items: center; gap: 6px; }

/* ---------- layout + drawer ---------- */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(86vw, var(--sidebar-w));
  background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-100%); transition: transform .22s ease; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(10,15,25,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.side-head img { width: 32px; height: 32px; }
.side-head .who { flex: 1; min-width: 0; }
.side-head .who b { display: block; }
.side-head .who span { font-size: .8rem; color: var(--muted); }
.side-head .icon-btn:hover { background: var(--surface-2); }
.nav { flex: 1; overflow-y: auto; padding: 8px; overscroll-behavior: contain; }
.nav-group-title { margin: 14px 10px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav a, .nav button.nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 2.75rem; padding: 8px 10px;
  border: 0; background: none; border-radius: 10px; color: var(--text); text-decoration: none; text-align: left; cursor: pointer;
}
.nav a:hover, .nav button.nav-link:hover { background: var(--surface-2); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav .ico { width: 22px; text-align: center; flex: none; }
.nav .lbl { flex: 1; min-width: 0; }
.nav .badge { font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.nav .chev { transition: transform .2s; color: var(--muted); }
.nav details[open] > summary .chev { transform: rotate(90deg); }
.nav details > summary { list-style: none; }
.nav details > summary::-webkit-details-marker { display: none; }
.nav .sub { padding-left: 22px; }
.nav .sub a { min-height: 40px; font-size: .95rem; }
.nav .sub a small { display: block; color: var(--muted); font-size: .78rem; font-weight: 400; }
.side-foot { border-top: 1px solid var(--border); padding: 8px; display: flex; gap: 4px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.side-foot .btn { flex: 1; }

/* bottom padding clears the fixed action bar (button 2.75rem + 20px padding), scales with A−/A+ */
.main { flex: 1; min-width: 0; padding: 16px; padding-bottom: calc(2.75rem + 20px + 2.5rem + env(safe-area-inset-bottom)); }
.container { max-width: 62rem; margin: 0 auto; }
/* task screens use the full width on big monitors: text | items side by side */
.container.wide { max-width: 90rem; }

@media (min-width: 1024px) {
  .sidebar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); transform: none; z-index: 1; padding-top: 0; }
  .sidebar .side-head .close { display: none; }
  .scrim { display: none; }
  .burger { display: none; }
  .main { padding: 24px 32px calc(2.75rem + 20px + 3rem); }
}

/* ---------- components ---------- */
h1 { font-size: 1.5rem; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 24px 0 10px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } .grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 2.75rem; padding: .5rem 1rem;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.sm { min-height: 2.25rem; padding: .25rem .75rem; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .875rem; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: 2.75rem; padding: .5rem .75rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.input:focus, .btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 1px; }

.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.primary { background: var(--primary-soft); color: var(--primary); }

.section-card { display: flex; flex-direction: column; gap: 8px; }
.section-card .head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section-card .head b { font-size: 1.05rem; }
.part-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text); text-decoration: none; }
.part-link:hover { background: var(--primary-soft); }
.part-link .t { flex: 1; min-width: 0; }
.part-link .t small { display: block; color: var(--muted); }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--primary); }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
@media (max-width: 639px) {
  table.list.stack thead { display: none; }
  table.list.stack tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.list.stack td { display: block; border: 0; padding: 2px 0; }
}

.notice { padding: 12px 14px; border-radius: 10px; background: var(--primary-soft); color: var(--text); }
.notice.warn { background: var(--warn-soft); }
.notice.err { background: var(--err-soft); }

/* bottom action bar (task screens) */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: 8px; justify-content: flex-end;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border);
}
@media (min-width: 1024px) { .actionbar { left: var(--sidebar-w); } }

/* modal */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center; background: rgba(10,15,25,.5); }
.modal { width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-wrap { place-items: center; } .modal { border-radius: 16px; padding: 22px; } }
.modal h3 { margin: 0 0 12px; }

/* access tree */
.tree { display: grid; gap: 6px; }
.tree label { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.tree input[type=checkbox] { width: 20px; height: 20px; }
.tree .lvl1 { padding-left: 26px; }
.tree .lvl2 { padding-left: 52px; }

/* toast */
.toasts { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { padding: 12px 14px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); }
.toast.err { background: var(--err); color: #fff; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 24px; }
.login .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login .brand img { width: 44px; height: 44px; }

/* ---------- task screens ---------- */
.task-head { margin-bottom: 14px; }
.task-head h1 { margin-top: 4px; }
details.instr { margin-top: 10px; }
details.instr summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details.instr p { margin: 8px 0 0; }
.timer { font-variant-numeric: tabular-nums; font-size: .9rem; opacity: .85; padding: 0 4px; }
.ru-btn { font-weight: 700; font-size: .85rem; }
.ru-btn[aria-pressed="true"] { background: rgba(255,255,255,.18); }
.ru { display: none; color: var(--muted); font-size: .92em; border-left: 3px solid var(--border); padding-left: 10px; margin-top: 6px; }
body.show-ru .ru { display: block; }
span.ru { padding-left: 6px; }
body.show-ru span .ru, body.show-ru li .ru { display: block; }
.text p { margin: 0 0 .7em; }
.text p:last-child { margin-bottom: 0; }
.text { line-height: 1.65; }
.text p { max-width: 75ch; }

.split { display: grid; gap: 12px; }
.pane-items { display: grid; gap: 12px; }
.sticky-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.sticky-box h3 { margin: 0 0 8px; font-size: 1rem; }
.opt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .95rem; }
.opt-list li { padding: 4px 6px; border-radius: 6px; }
.opt-list li.used { opacity: .45; text-decoration: line-through; }
.opts-tab, .opts-scrim, .opts-close { display: none; }
.opts-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
@media (max-width: 1023px) {
  /* option list = drawer from the right, opened by an edge tab; the text gets the whole screen */
  .pane-opts { position: fixed; z-index: 45; top: 0; right: 0; bottom: 0; width: min(88vw, 26rem);
    transform: translateX(105%); transition: transform .22s ease; padding-top: env(safe-area-inset-top); }
  .pane-opts.open { transform: none; box-shadow: -10px 0 40px rgba(0,0,0,.25); }
  .pane-opts .sticky-box { height: 100%; overflow: auto; border-radius: 0; border: 0; border-left: 1px solid var(--border); padding-bottom: 5rem; }
  .opts-scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(10,15,25,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .opts-scrim.open { opacity: 1; pointer-events: auto; }
  .opts-close { display: inline-grid; color: var(--muted); }
  /* barely visible edge handle; tap or swipe left from the right edge to open */
  .opts-tab { display: grid; place-items: center; position: fixed; z-index: 25; right: 0; top: 45%;
    width: 14px; height: 64px; padding: 0; border: 0; border-radius: 8px 0 0 8px;
    background: color-mix(in srgb, var(--primary) 55%, transparent); color: var(--primary-ink);
    opacity: .7; cursor: pointer; font: inherit; }
  .opts-tab span { font-size: 1rem; line-height: 1; font-weight: 700; }
  .opts-tab:active, .opts-tab:focus-visible { opacity: 1; width: 22px; }
  .opts-tab::before { content: ""; position: absolute; inset: -12px -2px -12px -18px; }   /* bigger tap area, invisible */
  .wide-text .pane-text { position: static; }
}
@media (min-width: 1024px) {
  .split { grid-template-columns: minmax(0, 1fr) 24rem; align-items: start; gap: 1.25rem; }
  .split .pane-opts { order: 2; position: sticky; top: calc(var(--topbar-h) + 16px); }
  .split .pane-opts .sticky-box { max-height: calc(100vh - var(--topbar-h) - 40px); overflow: auto; }
  .split.wide-text { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .split.wide-text .pane-text { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 40px); overflow: auto; }
}

.item { scroll-margin-top: calc(var(--topbar-h) + 50vh); }
.item-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.item-head .num { flex: none; min-width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.item-head select { flex: 1; min-width: 0; }
.item-head .q { flex: 1; }
.item-head .q p { margin: 4px 0 0; font-weight: 600; }
.item.is-ok { border-color: var(--ok); }
.item.is-err { border-color: var(--err); }

.chips { display: grid; gap: 6px; }
.chip { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.chip input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.chip.key { border-color: var(--ok); background: var(--ok-soft); }

.verdict { margin-top: 10px; padding: 10px 12px; border-radius: 10px; }
.verdict.ok { background: var(--ok-soft); }
.verdict.err { background: var(--err-soft); }
.verdict .explain { margin-top: 6px; display: grid; gap: 4px; font-size: .95rem; }
.evidence { font-style: italic; }

.gap-text p { margin: 0 0 .8em; }
.gap { display: inline-block; white-space: nowrap; }
.gap-sel { min-height: 34px; max-width: 46vw; padding: 2px 6px; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary-soft); color: var(--text); font-weight: 600; }
.gap.is-ok .gap-sel { border-color: var(--ok); background: var(--ok-soft); }
.gap.is-err .gap-sel { border-color: var(--err); background: var(--err-soft); text-decoration: line-through; }
.gap-key { color: var(--ok); font-weight: 700; }
.abc-list li { display: flex; gap: 8px; align-items: baseline; padding: 6px 4px; border-bottom: 1px solid var(--border); border-radius: 0; }
.abc-list li:last-child { border-bottom: 0; }
.abc-list .abc-n { flex: none; min-width: 28px; text-align: center; padding: 2px 4px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); font-weight: 700; text-decoration: none; }
.abc-list li.done .abc-n { background: var(--primary); color: var(--primary-ink); }
.abc-opts { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.abc-opt { font: inherit; font-size: .95rem; padding: 3px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-align: left; }
.abc-opt.on { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.abc-opt.key { border-color: var(--ok); background: var(--ok-soft); }
.abc-opt.wrong { border-color: var(--err); background: var(--err-soft); text-decoration: line-through; }
.abc-opt:disabled { cursor: default; color: var(--text); }
.gap-heading { margin: 0 0 .6em; font-size: 1.15em; line-height: 1.3; }
@media (min-width: 1024px) { .split .bank-list { grid-template-columns: 1fr 1fr; } }

/* ---------- прогресс и повторение ---------- */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { display: grid; gap: 6px; align-content: start; }
.tile b { font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .85rem; }
.tile.ok b { color: var(--ok); }
.tile.err b { color: var(--err); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.bars i { flex: 1; min-width: 0; background: var(--surface-2); border-radius: 4px 4px 0 0; }
.bars i.on { background: var(--primary); }
.bars-x { display: flex; gap: 4px; margin: 4px 0 8px; }
.bars-x span { flex: 1; min-width: 0; text-align: center; font-size: .7rem; color: var(--muted); }

.err-card { display: grid; gap: 10px; }
.err-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; justify-content: space-between; }
.err-item { display: flex; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.err-n { flex: none; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 999px;
  background: var(--err-soft); color: var(--err); font-weight: 700; font-size: .85rem; }
.err-body { flex: 1; min-width: 0; }
.err-prompt { overflow-wrap: anywhere; }
.err-prompt p { margin: 0 0 4px; }
.err-answers { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-top: 6px; }

.score { margin-top: 16px; text-align: center; }
.score.ok { border-color: var(--ok); background: var(--ok-soft); }
.score.err { border-color: var(--err); background: var(--err-soft); }
.score-num { font-size: 2rem; font-weight: 800; }

.task-list { display: grid; gap: 8px; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.task-row:hover { border-color: var(--primary); }
.task-row .idx { width: 28px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.task-row .t { flex: 1; min-width: 0; }
.task-row .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .t small { color: var(--muted); }
ul.plain, ol.plain { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.card h3 { margin: 0 0 8px; font-size: 1rem; }
.card.pro h3 { color: var(--ok); }
.card.contra h3 { color: var(--err); }
.dialog p { margin: 6px 0; }
details > summary { cursor: pointer; }
.model-part { margin: 8px 0 12px; }
.model-part p { margin: 2px 0; }
details.hint summary { font-size: .85rem; color: var(--muted); }
details.card > summary { list-style: revert; }
@media (min-width: 1024px) { .topbar { padding-left: 16px; } }
.chip > span { flex: 1; }
.chip .ru, .opt-list .ru { display: none; }
body.show-ru .chip .ru, body.show-ru .opt-list .ru { display: block; padding-left: 0; border: 0; margin-top: 2px; }

/* listening player */
.player { margin-bottom: 12px; }
.yt-wrap { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden; }
.yt-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.yt-cover { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 4px; background: linear-gradient(135deg, #1f3a5f, #0f1d30); color: #fff; }
.yt-cover span { font-size: 3rem; }
.pl-controls { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pl-controls .pl-time { margin-left: auto; }
/* шкала — отдельной строкой во всю ширину: пальцем на телефоне попасть куда проще */
.pl-bar { height: 8px; margin-top: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.pl-bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .25s linear; }
.pl-bar.seek { height: 14px; cursor: pointer; touch-action: none; overflow: visible; }
.pl-bar.seek i { border-radius: 999px 0 0 999px; position: relative; }
.pl-bar.seek i::after {                     /* ползунок: его видно и под пальцем */
  content: ""; position: absolute; right: -11px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 50%; background: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pl-bar.dragging i { transition: none; }    /* пока тянут, шкала не должна догонять палец */
.pl-bar.dragging i::after { transform: translateY(-50%) scale(1.15); }
.pl-bar.seek:hover { outline: 1px solid var(--primary); outline-offset: 2px; }
.pl-time { font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--muted); white-space: nowrap; }
.pl-info { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pl-mark { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.chips.row { grid-template-columns: 1fr 1fr; }
@media (min-width: 1024px) { .player { max-width: 720px; } }

/* text size control */
.fs-ctl { display: flex; gap: 4px; }
.fs-ctl .btn { flex: 1; min-width: 0; padding: .25rem .5rem; }
.side-foot { flex-wrap: wrap; }

/* matching picker (Lesen T1/T3) */
.pick-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 2.75rem; padding: .45rem .75rem;
  text-align: left; border: 1px solid var(--primary); background: var(--primary-soft); color: var(--text); border-radius: 10px; cursor: pointer; }
.pick-btn.empty { border-style: dashed; background: var(--surface); color: var(--muted); }
.pick-btn .pick-label { flex: 1; min-width: 0; }
.pick-btn .pick-arrow { color: var(--muted); }
.pick-btn:disabled { cursor: default; opacity: .9; }
.item.is-ok .pick-btn { border-color: var(--ok); background: var(--ok-soft); }
.item.is-err .pick-btn { border-color: var(--err); background: var(--err-soft); }
.pick-clear { width: 2.5rem; height: 2.5rem; color: var(--muted); }
.pick-clear:hover { background: var(--surface-2); }
.opt-list li { display: flex; gap: 8px; align-items: flex-start; }
.opt-list li .opt-main { flex: 1; }
.opt-list li.used { opacity: 1; text-decoration: none; background: var(--surface-2); }
.opt-list li.used .opt-main { color: var(--muted); }
.owner-badge { flex: none; font-size: .78rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--primary); color: var(--primary-ink); text-decoration: none; }
.sheet-wrap { position: fixed; inset: 0; z-index: 70; background: rgba(10,15,25,.5); display: grid; place-items: end center; }
.sheet { width: 100%; max-width: 40rem; max-height: 85vh; display: flex; flex-direction: column; background: var(--surface);
  border-radius: 16px 16px 0 0; padding: .75rem .75rem calc(.75rem + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
@media (min-width: 640px) { .sheet-wrap { place-items: center; } .sheet { border-radius: 16px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 .25rem .5rem; }
.sheet-head .icon-btn:hover { background: var(--surface-2); }
.sheet-list { overflow: auto; display: grid; gap: 6px; padding: 2px; }
.sheet-opt { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; padding: .65rem .75rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.sheet-opt:hover, .sheet-opt:focus-visible { border-color: var(--primary); outline: none; background: var(--primary-soft); }
.sheet-opt.current { border-color: var(--primary); background: var(--primary-soft); }
.sheet-opt.taken .sheet-text { color: var(--muted); }
.sheet-letter { font-weight: 700; flex: none; min-width: 1.5rem; }
.sheet-text { flex: 1; }
.sheet-clear { margin-top: .5rem; }

/* task list: grid items must not grow to the longest (nowrap) title */
.task-list { grid-template-columns: minmax(0, 1fr); }
.task-row { min-width: 0; }
.task-row .t b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.task-row .t small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .pill { flex: none; }
.grid > * { min-width: 0; }
.theme-btn { font-size: 1.15rem; }

/* task row as a grid: index | title (wraps, max 2 lines) | badge — no reliance on flex min-content
   (iOS Safari sizes -webkit-box line-clamp by its unwrapped width) */
.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .75rem; }
.task-row .t { overflow: hidden; }
.task-row .t b { overflow: hidden; overflow-wrap: anywhere; }
.task-row .badge-col { justify-self: end; }
.task-row .idx { width: auto; min-width: 1.5rem; }
details.drafts { margin-top: 1.5rem; }
details.drafts > summary { cursor: pointer; color: var(--muted); padding: .5rem 0; }
details.drafts .task-list { margin-top: .5rem; opacity: .85; }

/* text size presets (Aa in the task top bar) */
.fs-pop-wrap { position: relative; }
.fs-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 13rem; display: grid; gap: 2px; padding: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.fs-pop button { text-align: left; padding: .55rem .75rem; border: 0; border-radius: 8px; background: none; color: inherit; cursor: pointer; font-family: inherit; }
.fs-pop button:hover { background: var(--surface-2); }
.fs-pop button[aria-checked="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
/* phones: reading text a bit larger by default */
@media (max-width: 640px) { .text, .item .q, .chip, .gap-text { font-size: 1.0625rem; } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* staff review panel on the task screen */
.review { margin-bottom: 16px; padding: 12px 14px; }
.review summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.review .rv-block { margin-top: 10px; font-size: .9rem; }
.review .rv-block ul { margin: 4px 0 0; padding-left: 20px; }
.review .rv-block.err b { color: var(--err); }
.review .rv-block.warn b { color: var(--warn); }
.review .rv-block.muted { color: var(--muted); }
.review .rv-checks { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.review textarea { width: 100%; margin-top: 12px; font: inherit; padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-sizing: border-box; }
.review .rv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- симулятор экзамена ---------- */
.ex-current { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  border-color: var(--warn); background: var(--warn-soft); }
.ex-card { display: grid; gap: 4px; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.ex-card b { font-size: 1.05rem; }
.ex-card .meta { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ex-card .go { color: var(--primary); font-weight: 600; font-size: .9rem; margin-top: 4px; }
.ex-card:hover { border-color: var(--primary); }
.ex-card.primary { border-color: var(--primary); background: var(--primary-soft); }
.ex-more { margin-top: 12px; }
button.task-row { font: inherit; text-align: left; cursor: pointer; width: 100%; }

.ex-bar { display: grid; gap: 10px; margin-bottom: 14px; }
.ex-blocks { display: flex; flex-wrap: wrap; gap: 6px; }
.ex-bl { display: grid; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .8rem; }
.ex-bl small { font-size: .7rem; }
.ex-bl.on { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.ex-bl.done { background: var(--ok-soft); color: var(--ok); }
.ex-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.ex-tab { flex: none; display: grid; gap: 2px; padding: 8px 12px; min-height: 44px; font: inherit; font-size: .85rem;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
.ex-tab small { color: var(--muted); font-variant-numeric: tabular-nums; }
.ex-tab.on { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.instr-p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.timer.warn { color: var(--err); font-weight: 700; opacity: 1; }
.err-item.is-ok .err-n { background: var(--ok-soft); color: var(--ok); }
.part-link.static { cursor: default; }
.part-link.static:hover { background: var(--surface-2); }

/* синонимы и ловушки */
.trick .trick-text { display: grid; gap: 4px; margin: 8px 0; font-size: .95rem; }
.trick .trick-text b { color: var(--muted); font-weight: 600; }
.trick-more:not(:empty) { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 8px; }
.trick-more h3 { font-size: 1rem; margin: 10px 0 6px; }
.lex-bar { display: flex; gap: 8px; margin: 12px 0; }
.lex-bar input { flex: 1; min-width: 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-btn { border: 1px solid var(--border); background: var(--surface); color: inherit; border-radius: 999px;
  padding: 4px 10px; font: inherit; font-size: .85rem; cursor: pointer; }
.chip-btn.on { border-color: var(--primary); color: var(--primary); }
.lex-list { display: grid; gap: 8px; }
.lex-row { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface); }
.lex-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.lex-ru { color: var(--muted); }
.err-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.pill.tag { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.yt-probe { position: fixed; left: -9999px; top: 0; width: 320px; height: 180px; }
.vid .task-list { margin-top: 8px; }
/* «Начало» и «Конец» — одинаковые блоки: подпись + время + ±1 с, под ними две широкие кнопки */
/* поля разметки живут в .mk-body: у опубликованного задания он скрыт до кнопки «Изменить отрезок» */
.mk-body { flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mk-field { flex: 1 0 100%; display: grid; gap: 6px; }
.mk-top { display: grid; grid-template-columns: 4.6em auto minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.mk-field label { color: var(--muted); font-size: .85rem; }
.mk-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
/* min-width: 0 — иначе поле ввода держит свою «естественную» ширину и выдавливает «+1 с» за край */
.mk-time { width: 100%; min-width: 0; padding: 8px 6px; font-size: 1.05rem; font-variant-numeric: tabular-nums; text-align: center; }
.mk-field .btn.sm { padding: 8px 9px; }
.mk-hint { flex: 1 0 100%; line-height: 1.45; }
.mk-hint summary { cursor: pointer; padding: 2px 0; }
.mk-act { flex: 1 0 100%; margin-top: 2px; }

/* drill */
.drill-q .drill-de { font-size: 1.15rem; margin: 6px 0 10px; line-height: 1.5; }
.drill-q .gap { display: inline-block; min-width: 3.5em; border-bottom: 2px solid var(--primary); font-style: normal; }
.drill-q .chips { display: grid; gap: 8px; margin-top: 10px; }
.chip-btn.opt { text-align: left; padding: 10px 12px; border-radius: 10px; min-height: 44px; font-size: 1rem; }
.chip-btn.opt:disabled { opacity: 1; cursor: default; }
.chip-btn.opt.key { border-color: var(--ok); color: var(--ok); font-weight: 600; }
.chip-btn.opt.bad { border-color: var(--err); color: var(--err); text-decoration: line-through; }
.drill-q .res:not(:empty) { margin-top: 10px; display: grid; gap: 4px; }
.ex-bl.bad { border-color: var(--err); color: var(--err); }
.drill-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

/* админка контента */
.ct-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.ct-filters label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); flex: 1 1 10rem; }
.ct-filters select, .ct-filters input { width: 100%; }
.ct-head { margin: 12px 0 8px; }
.ct-row .idx { width: auto; }
/* в строке списка — и статус, и кнопка в само задание (название ведёт в правку полей) */
.ct-row .badge-col { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ct-row .t a { color: inherit; text-decoration: none; }
.ct-row .t a:hover b { color: var(--primary); }
.ct-row .t small.ct-bad { color: var(--err); white-space: normal; }
.ct-row .t small.ct-warn { color: var(--warn); white-space: normal; }
.ct-bulk-in { display: grid; gap: 8px; position: sticky; top: 8px; z-index: 3; }
.ct-bulk-in input[type="text"], .ct-bulk-in #b-comment { width: 100%; }
.ct-io .btn-row { flex-wrap: wrap; align-items: center; }
.rv-block { margin-top: 10px; font-size: .9rem; }
.rv-block ul { margin: 4px 0 0; padding-left: 20px; }
.rv-block.err b { color: var(--err); }
.rv-block.warn b { color: var(--warn); }
.rv-block.muted { color: var(--muted); }
.ct-state { display: grid; gap: 8px; justify-items: start; }
.ct-state .btn-row { flex-wrap: wrap; }
.ct-form { display: grid; gap: 12px; margin-top: 16px; }
.ct-group > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
/* короткие поля (слова банка, варианты) становятся в несколько колонок, длинные — во всю ширину.
   Сетка — на обёртке: у <details> содержимое лежит в одном блоке, сеткой его не разложить. */
.ct-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0 12px; align-items: start; }
.ct-fields > .ct-field.wide { grid-column: 1 / -1; }
.ct-group[open] > summary { margin-bottom: 8px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.ct-field { display: grid; gap: 4px; margin-bottom: 10px; }
.ct-field > span { font-size: .8rem; color: var(--muted); }
.ct-field input, .ct-field select, .ct-field textarea { width: 100%; font: inherit; }
.ct-field textarea { line-height: 1.5; resize: vertical; }
.ct-field [lang="de"] { font-weight: 500; }
textarea.mono { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; resize: vertical; }
.ct-sticky { position: sticky; bottom: 0; padding: 10px 0; background: var(--bg); border-top: 1px solid var(--border); }

/* таймкод Hören в разборе: где звучит опора */
.cue { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin-top: 6px; }
.cue .evidence { flex: 1 1 14rem; min-width: 0; }
.cue .pill { white-space: nowrap; }

/* Schreiben: пункты задания как отметки, поле письма */
.pts .pt { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.pts .pt input { margin-top: 4px; flex: none; }
.pts li { margin-bottom: 8px; }
#letter { width: 100%; box-sizing: border-box; min-height: 180px; }
.rede-g h3 { margin: 14px 0 6px; }
.rede summary { cursor: pointer; padding: 4px 0; }
.rede ul { margin: 4px 0 10px; }
/* каркас письма: шаг — название, фраза, варианты «если INFO / если жалоба» */
.mus li { margin-bottom: 12px; }
.mus-t { font-size: .8rem; color: var(--muted); }
.mus-a { margin-top: 4px; padding-left: 10px; border-left: 2px solid var(--border); }
