/* cms components. Depends on tokens.css + base.css. Every block is rendered
   on design/components.html; screens compose them.
   Phase 1b cut the set to what a three-section app with one wizard needs:
   no sidebar, no tabs, no nested cards, no diff view, no dialog. One
   primary button per screen; status is one badge with a word. */

/* --- Top nav: brand, three links, theme toggle, user ------------------- */
.topnav { position: sticky; top: 0; z-index: var(--z-sticky); height: var(--topnav-h); display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-5); background: var(--surface); border-bottom: 1px solid var(--border); }
.topnav__brand { display: flex; align-items: center; gap: var(--space-2); margin-right: var(--space-4); font-weight: var(--weight-bold); color: var(--text); }
.topnav__brand:hover { text-decoration: none; }
.topnav__brand-mark { width: 24px; height: 24px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font-size: var(--text-sm); }
.topnav__link { padding: 6px 10px; border-radius: var(--radius-md); color: var(--muted); font-weight: var(--weight-medium); }
.topnav__link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topnav__link.is-active { color: var(--accent-hover); background: var(--accent-soft); }
.topnav__spacer { flex: 1; }
.topnav__user { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.topnav__user .avatar { width: 26px; height: 26px; font-size: var(--text-xs); }
.topnav form { margin: 0; }
.topnav__desk { display: flex; align-items: center; gap: var(--space-2); }
.topnav__title, .tabbar { display: none; }
/* Admin balance chip (partials/balance_chip.html): the link is the 44 px target, the chip is the look. */
.topnav__balance { display: inline-flex; align-items: center; min-height: 44px; flex: none; }
.topnav__balance:hover { text-decoration: none; }
.chip--balance { font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip--balance.is-over { background: var(--tone-danger-bg); color: var(--tone-danger-fg); border-color: currentColor; }
@media (max-width: 768px) {
  .topnav { padding: 0 var(--space-3); gap: 2px; }
  .topnav__brand { margin-right: var(--space-2); }
  .topnav__user span:not(.avatar) { display: none; }
}
/* Phone: a slim top bar (brand mark + section title) and a bottom tab bar for the three
   sections. The tab bar steps aside on screens with a sticky .actionbar: two bars would eat
   130px of a 740px screen, and those screens (wizard, review, forms) are a task with its own
   «Назад»; the brand mark still leads home. */
@media (max-width: 640px) {
  .topnav__link, .topnav__desk, .topnav__brand-name, .topnav__spacer { display: none; }
  .topnav__title { display: block; flex: 1; min-width: 0; font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar { display: flex; position: fixed; inset: auto 0 0; z-index: var(--z-sticky); background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar__link { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tabbar-h); font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--muted); }
  .tabbar__link:hover { text-decoration: none; color: var(--text); }
  .tabbar__link .icon { width: 22px; height: 22px; }
  .tabbar__link.is-active { color: var(--accent); }
  .tabbar__link.is-active .icon { stroke-width: 2.25; }
  .app:has(.actionbar) .tabbar { display: none; }
}
/* «Аккаунт» (partials/account.html): top of Настройки on a phone, the /account page. */
.account { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); margin-bottom: var(--space-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.account__who { display: flex; align-items: center; gap: var(--space-3); }
.account form { margin: 0; }
@media (min-width: 641px) { .account--phone { display: none; } }

/* --- Avatar, chip, badge ------------------------------------------------ */
.avatar { width: 40px; height: 40px; border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent-hover); display: inline-grid; place-items: center; font-weight: var(--weight-semibold); font-size: var(--text-sm); flex: none; overflow: hidden; }
.avatar--lg { width: 72px; height: 72px; font-size: var(--text-xl); }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px 8px; border-radius: var(--radius-full); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--text-sm); color: var(--text); line-height: 1.4; }
.lang { white-space: nowrap; }
.lang__flag { margin-inline-end: 0.25em; font-style: normal; }
.chip--lang { font-family: var(--font-mono); text-transform: uppercase; font-size: var(--text-xs); }

/* Badge = status: one word, one colour, a marker shape as second channel.
   Modifier names = state names from architecture.md §3. */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1.4; white-space: nowrap; border: 1px solid transparent; background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--draft        { background: var(--status-draft-bg); color: var(--status-draft-fg); }
.badge--planning     { background: var(--status-planning-bg); color: var(--status-planning-fg); }
.badge--topics_ready { background: var(--status-topics_ready-bg); color: var(--status-topics_ready-fg); }
.badge--generating   { background: var(--status-generating-bg); color: var(--status-generating-fg); }
.badge--review       { background: var(--status-review-bg); color: var(--status-review-fg); }
.badge--failed       { background: var(--status-failed-bg); color: var(--status-failed-fg); }
.badge--paused       { background: var(--status-paused-bg); color: var(--status-paused-fg); }
.badge--done         { background: var(--status-done-bg); color: var(--status-done-fg); }
.badge--pending      { background: var(--status-pending-bg); color: var(--status-pending-fg); }
.badge--item_draft   { background: var(--status-item_draft-bg); color: var(--status-item_draft-fg); }
.badge--approved     { background: var(--status-approved-bg); color: var(--status-approved-fg); }
.badge--rejected     { background: var(--status-rejected-bg); color: var(--status-rejected-fg); }
.badge--upload       { background: var(--status-upload-bg); color: var(--status-upload-fg); }
.badge--not_supported{ background: var(--status-not_supported-bg); color: var(--status-not_supported-fg); border-color: var(--status-not_supported-fg); border-style: dashed; }
.badge--queued       { background: var(--status-queued-bg); color: var(--status-queued-fg); }
.badge--running      { background: var(--status-running-bg); color: var(--status-running-fg); }
.badge--succeeded    { background: var(--status-succeeded-bg); color: var(--status-succeeded-fg); }
.badge--cancelled    { background: var(--status-cancelled-bg); color: var(--status-cancelled-fg); border-color: var(--status-cancelled-fg); border-style: dashed; }
.badge--planning::before, .badge--generating::before, .badge--running::before { background: transparent; border: 2px solid currentColor; animation: pulse 1.2s ease-in-out infinite; }
.badge--not_supported::before, .badge--cancelled::before { background: transparent; border: 1px solid currentColor; }
.badge--approved::before, .badge--done::before, .badge--succeeded::before { border-radius: 1px; }
.badge--rejected::before, .badge--failed::before { border-radius: 1px; transform: rotate(45deg); }
.badge--paused::before { width: 7px; border-radius: 0; background: linear-gradient(90deg, currentColor 35%, transparent 35% 65%, currentColor 65%); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* --- Buttons: primary (one per screen), default, ghost; sm and lg ------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: var(--weight-medium); line-height: 1.4; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--text); background: var(--surface-2); }
.btn--sm { padding: 3px 8px; font-size: var(--text-sm); }
.btn--lg { padding: 12px 24px; font-size: var(--text-lg); border-radius: var(--radius-lg); }
.btn--icon { padding: 6px; }
.btn:disabled, .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
/* "Назад" and other secondary navigation are text links, not buttons. */
.link-back { color: var(--muted); }
.link-back:hover { color: var(--text); }
/* Phone: every tap target ≥ 44×44 px (the brief's acceptance rule 3). */
@media (max-width: 640px) {
  .btn, .chip--select { min-height: 44px; }
  .btn--icon { min-width: 44px; }
  .link-back { display: inline-flex; align-items: center; min-height: 44px; }
}
/* htmx: an element with .htmx-indicator shows only while its request runs. */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Forms -------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field__label { font-weight: var(--weight-medium); font-size: var(--text-sm); }
.field__hint { font-size: var(--text-sm); color: var(--muted); }
.field__error { font-size: var(--text-sm); color: var(--danger); }
.field.is-invalid .input { border-color: var(--danger); }
.input, .select, .textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--text); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--accent); }
.textarea { min-height: 96px; resize: vertical; line-height: var(--leading-relaxed); }
/* Grows with its text (topics): without field-sizing it is two lines tall and resizable. */
.textarea--grow { min-height: 0; max-height: 14lh; }
@supports (field-sizing: content) { .textarea--grow { field-sizing: content; min-height: 44px; resize: none; } }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 32px; }
/* Phone: 16px stops iOS from zooming into a focused field; 44px tall to hit with a thumb. */
@media (max-width: 640px) {
  .input, .select, .textarea, .review__editor { font-size: var(--text-lg); }
  .input, .select { min-height: 44px; }
}
/* Text counter under a textarea; the server sets is-near / is-over. */
.counter { font-size: var(--text-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.is-near { color: var(--warning); }
.counter.is-over { color: var(--danger); font-weight: var(--weight-semibold); }

/* Choice: a big radio card (wizard step 1, type). The input stays in the
   DOM so the form posts without JS; :checked draws the selection. */
.choice { position: relative; display: block; padding: var(--space-4) var(--space-5); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); cursor: pointer; }
.choice:hover { border-color: var(--accent); }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.choice:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.choice__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.choice__hint { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--muted); }
.choices { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
/* Chip radio (platform). Same trick as .choice. */
.chip--select { cursor: pointer; padding: 6px 14px; font-size: var(--text-md); }
.chip--select:hover { border-color: var(--accent); }
.chip--select input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip--select:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip--select:has(input:focus-visible) { box-shadow: var(--focus-ring); }

/* --- Card and empty state ----------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-5); }
.card--flat { box-shadow: none; }
.empty { text-align: center; padding: var(--space-10) var(--space-4); color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.empty__title { color: var(--text); font-weight: var(--weight-semibold); margin-bottom: var(--space-1); }
.empty .btn { margin-top: var(--space-4); }

/* --- Rows: the one list shape for inbox, experts, packages, topics ------
   A row = optional avatar, main text (title + meta), one action on the
   right. Never more than one button per row. */
.rows { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); min-height: 56px; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: var(--weight-medium); }
.row__title a { color: inherit; }
.row__meta { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }
.row__aside { flex: none; display: flex; align-items: center; gap: var(--space-3); }
.row__aside .progress { width: 140px; }
.row .input { background: transparent; border-color: transparent; padding: 5px 8px; margin: -5px -8px; }
.row .input:hover { border-color: var(--border-strong); }
.row .input:focus-visible { background: var(--surface); border-color: var(--accent); }
@media (max-width: 768px) {
  .row { flex-wrap: wrap; }
  .row__aside .progress { width: 100px; }
}
/* A row that leads to one place is tappable as a whole: the title link stretches over it. */
.row--link { position: relative; }
.row--link .row__title a::after { content: ""; position: absolute; inset: 0; }
.row--link .row__aside { position: relative; z-index: 1; }
/* Phone: text first and full width, then the badge, then the action full width under it. */
@media (max-width: 640px) {
  .row { align-items: flex-start; gap: var(--space-2) var(--space-3); padding: var(--space-3); }
  .row__title, .row__meta { overflow-wrap: anywhere; }
  .row__aside { flex-basis: 100%; flex-wrap: wrap; gap: var(--space-2); }
  .row__aside > .btn, .row__aside > form, .row__aside > form .btn { flex: 1 1 100%; }
  .row__aside .progress-row { flex: 1; }
  .row__aside .progress { width: auto; }
}
/* Inbox groups: heading with a count, then rows. */
.inbox__group { margin-top: var(--space-8); }
.inbox__group:first-child { margin-top: 0; }
.inbox__head { display: flex; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-3); }
.inbox__count { color: var(--muted); font-weight: var(--weight-normal); }

/* --- Table (settings only) + pagination ----------------------------------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--surface-2); font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--muted); white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.u-actions { text-align: right; white-space: nowrap; }
.table tfoot td { background: var(--surface-2); font-weight: var(--weight-semibold); }
/* Phone: tables become label/value rows (`data-label` on each value cell); first cell = title. */
@media (max-width: 640px) {
  .table--stack thead { display: none; }
  .table--stack tr { display: block; padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
  .table--stack td { display: flex; justify-content: space-between; gap: var(--space-3); padding: 2px var(--space-4); border: 0; text-align: right; }
  .table--stack td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .table--stack td:first-child { font-weight: var(--weight-semibold); text-align: left; }
  .table--stack td:first-child::before { content: none; }
  .grid--tiles { grid-template-columns: 1fr 1fr; gap: var(--space-2); }
  .grid--tiles .card { padding: var(--space-3); }
  .grid--tiles .stat { font-size: var(--text-2xl); }
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; font-size: var(--text-sm); color: var(--muted); }
.pager__pages { display: flex; gap: 2px; }
.pager__page { min-width: 28px; padding: 3px 6px; text-align: center; border-radius: var(--radius-sm); color: var(--text); }
.pager__page:hover { background: var(--surface-2); text-decoration: none; }
.pager__page.is-active { background: var(--accent); color: var(--accent-fg); }
.pager__page.is-disabled { opacity: .4; pointer-events: none; }
@media (max-width: 640px) {
  .pager { flex-wrap: wrap; }
  .pager__page { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; }
}
/* Settings sub-navigation: plain links in one line, current one is bold. */
.subnav { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--space-2); }
.subnav a { color: var(--muted); }
.subnav a:hover { color: var(--text); }
.subnav a[aria-current] { color: var(--text); font-weight: var(--weight-semibold); }

/* --- Wizard: step indicator + one primary action per step ---------------- */
.steps { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--space-4); }
.steps__bar { display: flex; gap: 4px; }
.steps__bar span { width: 28px; height: 4px; border-radius: var(--radius-full); background: var(--surface-2); }
.steps__bar span.is-done { background: var(--accent); }
.wizard-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); margin-top: var(--space-6); }
.wizard-foot__hint { flex: 1; font-size: var(--text-sm); color: var(--muted); }
/* Price tag and the funds shortfall (topics step): unlike the hint they stay on a phone. */
.wizard-foot__cost { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.wizard-foot__note { flex-basis: 100%; order: 9; display: flex; gap: var(--space-2); margin: 0; font-size: var(--text-sm); color: var(--danger); }
.wizard-foot__note .btn--link { padding: 0; font-size: inherit; }
@media (max-width: 768px) {
  .wizard-foot__hint { flex-basis: 100%; order: 3; }
}
/* Phone: bars collapse to «Шаг 2 из 5 · Темы»; the foot is primary full width, then «Назад»
   and at most one secondary. `.actionbar` pins it to the bottom (tab bar hides, see .tabbar). */
@media (max-width: 640px) {
  .steps__bar, .wizard-foot__hint { display: none; }
  .wizard-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-3); align-items: center; }
  .wizard-foot > .btn--primary { grid-column: 1 / -1; order: -1; }
  .wizard-foot > .link-back { order: 1; }
  .wizard-foot > :not(.btn--primary, .link-back) { order: 2; }
  .wizard-foot > .wizard-foot__cost, .wizard-foot > .wizard-foot__note { grid-column: 1 / -1; order: -2; }
  .actionbar { position: sticky; bottom: 0; z-index: var(--z-sticky); margin: var(--space-6) calc(-1 * var(--space-4)) 0; padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: var(--shadow-md); }
}

/* --- Progress ----------------------------------------------------------- */
.progress { display: flex; height: 8px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.progress--lg { height: 14px; }
.progress__seg { height: 100%; }
.progress__seg--approved { background: var(--success); }
.progress__seg--draft { background: var(--warning); }
.progress__seg--generating { background: var(--info); }
.progress__seg--rejected, .progress__seg--failed { background: var(--danger); }
.progress-row { display: flex; align-items: center; gap: var(--space-2); }
.progress-row .progress { flex: 1; }
.progress-row__label { font-size: var(--text-sm); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Big number: cost on the settings page, "9 из 9" on download. */
.stat { font-size: var(--text-3xl); font-weight: var(--weight-bold); line-height: var(--leading-tight); font-variant-numeric: tabular-nums; }
.stat__label { font-size: var(--text-sm); color: var(--muted); }

/* --- Images ------------------------------------------------------------- */
.ratio { position: relative; aspect-ratio: var(--ratio, 1 / 1); border-radius: var(--radius-md); overflow: hidden; background: var(--surface-2); }
.ratio--1-1 { --ratio: 1 / 1; } .ratio--4-5 { --ratio: 4 / 5; } .ratio--9-16 { --ratio: 9 / 16; } .ratio--16-9 { --ratio: 16 / 9; } .ratio--3-1 { --ratio: 3 / 1; }
.ratio > img { width: 100%; height: 100%; object-fit: cover; }
/* Placeholder: mockups and "no image yet"; a real <img> replaces it. */
.ratio--placeholder { background: linear-gradient(135deg, var(--placeholder-a), var(--placeholder-b)); display: grid; place-items: center; color: var(--muted); }
.ratio--placeholder .icon { width: 28px; height: 28px; stroke-width: 1.25; opacity: .7; }
.ratio__ratio { position: absolute; right: 6px; top: 6px; padding: 1px 6px; border-radius: var(--radius-sm); background: var(--overlay); color: #fff; font-size: var(--text-xs); font-family: var(--font-mono); }

/* --- Review: summary strip + one item at a time --------------------------
   The strip lists slot groups as counts; video and upload groups live here
   only and never enter the item stream. Clicking a group jumps to it. */
.strip { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.strip__group { display: inline-flex; align-items: center; gap: var(--space-2); padding: 5px 12px; border-radius: var(--radius-full); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: var(--text-sm); }
.strip__group:hover { border-color: var(--accent); text-decoration: none; }
.strip__group.is-current { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); }
.strip__group.is-done { color: var(--success); }
.strip__group.is-muted { color: var(--muted); border-style: dashed; }
.strip__count { font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); }
/* Phone: one row that scrolls sideways inside itself (the page does not), snapping per group.
   The row opens on the current group: it and everything after it move to the front, the groups
   before it follow (a rotation, so "what comes next" stays to the right). Desktop wraps, keeps
   slot order. */
@media (max-width: 640px) {
  .strip { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; scroll-padding-inline: var(--space-4); scrollbar-width: none; margin-inline: calc(-1 * var(--space-4)); padding-inline: var(--space-4); }
  .strip > * { flex: none; scroll-snap-align: start; }
  .strip > .is-current, .strip > .is-current ~ * { order: -1; }
  .strip__group { min-height: 44px; }
  .strip--chips { padding-block: var(--space-1); } /* room for the focus ring the scroller would clip */
}
/* Radio chips as a strip (experts list languages): the form's stack already spaces them. */
.strip--chips { margin-bottom: 0; }
/* Experts list filters (Phase 8b): language chips, sort to their right; on a phone the sort gets
   its own row above the chips (it comes first in the markup), never a third strip. */
.filters { display: flex; align-items: center; gap: var(--space-3); }
.filters > .strip { flex: 1; min-width: 0; }
.filters > .seg { order: 1; }
/* Segmented choice: radios in one bordered pill; the checked one is filled. */
.seg { display: inline-flex; flex: none; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--surface-2); }
.seg__opt { position: relative; display: inline-flex; align-items: center; padding: 4px 12px; border-radius: var(--radius-full); font-size: var(--text-sm); color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg__opt:hover { color: var(--text); }
.seg__opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg__opt:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg__opt:has(input:focus-visible) { box-shadow: var(--focus-ring); }
@media (max-width: 640px) {
  .filters { flex-direction: column; align-items: stretch; gap: var(--space-2); }
  .filters > .seg { order: 0; align-self: flex-start; }
  .seg__opt { min-height: 44px; }
}
/* Language chips: full name on desktop; flag + code on a phone so the strip fits without much
   scrolling. The full name stays in the accessibility tree (visually hidden, not display:none). */
.chip__short { display: none; }
@media (max-width: 640px) {
  .chip__long { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .chip__short { display: inline; }
}
.review { display: grid; gap: var(--space-6); grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); align-items: start; }
.review__text { line-height: var(--leading-relaxed); white-space: pre-wrap; overflow-wrap: anywhere; }
.review__tools { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.review__actions, .review__more { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-5); }
.review__more { margin-top: var(--space-3); }
.review__next { margin-left: auto; }
/* Secondary actions open inline with native <details>: the summary looks
   like a button, the form appears under the actions row. */
.reveal > summary { list-style: none; }
.reveal > summary::-webkit-details-marker { display: none; }
.reveal[open] > summary .btn { background: var(--surface-2); }
.reveal__body { margin-top: var(--space-3); padding: var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); }
.review__editor { width: 100%; min-height: 280px; padding: var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); line-height: var(--leading-relaxed); resize: vertical; }
@media (max-width: 1024px) {
  .review { grid-template-columns: minmax(0, 1fr); }
  .review__image { max-width: 340px; }
}

/* --- Upload page ---------------------------------------------------------- */
.dropzone { display: grid; place-items: center; gap: var(--space-2); padding: var(--space-10) var(--space-6); border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); text-align: center; color: var(--muted); background: var(--surface); cursor: pointer; }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); }
.dropzone .icon { width: 32px; height: 32px; stroke-width: 1.25; }
.dropzone__title { color: var(--text); font-weight: var(--weight-semibold); }
.file-list { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.file-list__item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border); font-size: var(--text-sm); }
.file-list__item:last-child { border-bottom: 0; }
.file-list__name { flex: 1; min-width: 0; }
.file-list__meta { color: var(--muted); white-space: nowrap; }
/* Phone: name + date on the first line, badge + action on the second. */
@media (max-width: 640px) {
  .dropzone { padding: var(--space-6) var(--space-4); }
  .file-list__item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); padding: var(--space-3) var(--space-4); }
  .file-list__item > .icon { grid-row: span 2; }
  .file-list__item > .badge { justify-self: start; }
}

/* --- Login (screens/login.html): one centred column, brand over the card --- */
.login { width: min(400px, 100%); margin: 0 auto; padding-top: 15vh; }
.login__brand { justify-content: center; }
.login__mark { width: 40px; height: 40px; font-size: var(--text-lg); border-radius: var(--radius-md); }

/* --- Flash (one line of feedback after an action) -------------------------- */
.flash { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); }
.flash--success { background: var(--tone-success-bg); color: var(--tone-success-fg); }
.flash--danger { background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.flash--warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.flash--info { background: var(--tone-info-bg); color: var(--tone-info-fg); }
.flash .icon { margin-top: 2px; }

/* --- Skeleton (step 3 while the poll waits) ------------------------------ */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--radius-sm); min-height: 12px; }
.skeleton--text { height: 12px; width: 100%; }
.skeleton--text.is-short { width: 55%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- Day chip (topics list) ----------------------------------------------- */
.day { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--surface-2); font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; color: var(--muted); flex: none; }

/* Phase 3c: a photo inside .avatar (experts list and card) and the card header of the expert page. */
.avatar > img { width: 100%; height: 100%; object-fit: cover; }
.card--profile { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-5); }
/* Phone: profile stacks, «Создать контент» full width; photos 3 across; forms end on a sticky bar. */
@media (max-width: 640px) {
  .card--profile { flex-direction: column; align-items: stretch; gap: var(--space-3); }
  .card--profile > .btn, .actionbar > .btn--primary { flex: 1; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery > .card { padding: var(--space-1); }
  .gallery .cluster { flex-direction: column; align-items: stretch; }
  .gallery .btn { width: 100%; white-space: normal; padding-inline: var(--space-1); }
}
/* Long read-only text of a card (persona, profile) as <details class="fold">: the heading is the
   summary, 44px tall with a chevron. Folded on a phone; from 641px, where ::details-content exists,
   it reads as a plain section whatever the open state (older browsers keep the toggle). */
.fold > summary { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; list-style: none; cursor: pointer; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary > h2 { margin: 0; }
.fold__icon { color: var(--muted); transition: transform .15s; }
.fold[open] .fold__icon { transform: rotate(90deg); }
.fold > summary + * { margin-top: var(--space-3); }
@media (max-width: 640px) { .fold + .fold { margin-top: var(--space-2); } }
@media (min-width: 641px) {
  @supports selector(::details-content) {
    .fold::details-content { content-visibility: visible; }
    .fold > summary { min-height: 0; cursor: auto; pointer-events: none; }
    .fold__icon { display: none; }
  }
}
.chip.is-muted { color: var(--muted); border-style: dashed; }

/* Phase 5: wizard, review and upload pages (design-system.md › Jinja mapping). */
.btn--link { border-color: transparent; background: transparent; color: var(--muted); padding-left: 0; padding-right: 0; text-decoration: underline; text-underline-offset: 3px; }
.btn--link:hover { background: transparent; color: var(--danger); }
.field--short { max-width: 260px; }
.card--center { text-align: center; padding: var(--space-10) var(--space-6); }
.card--center form { display: inline-flex; }
.row--group { background: var(--surface-2); min-height: 40px; padding-top: var(--space-2); padding-bottom: var(--space-2); }
.row--group:hover { background: var(--surface-2); }
.row .row__main .input + .input { margin-top: 4px; }
/* Phone: topic fields look like fields and take the row's full width (the day moves to meta). */
@media (max-width: 640px) {
  .row .input { margin: 0; border-color: var(--border); }
  .row .row__main .input + .input { margin-top: var(--space-2); }
  .row__main > .row__meta:last-child { margin-top: var(--space-1); }
}
.progress-row__name { width: 160px; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.strip__group.is-failed { color: var(--danger); border-color: var(--danger); }
.strip form { display: inline-flex; }
.review__body { min-width: 0; }
.review__text { max-height: 60vh; overflow: auto; }
.review__more .reveal[open] { flex-basis: 100%; }
.review__more .reveal[open] > summary { display: inline-block; }
/* Phone: the image fits in 45vh (letterboxed, tap opens the file); the text is not a second
   scroll area; the bar is «Отклонить» · «Принять» · «→», one thumb-reach row. */
@media (max-width: 640px) {
  .review { gap: var(--space-2); }
  .review__body { display: contents; }  /* the bar's sticky range becomes the whole item, not the text column */
  .review__image { max-width: none; margin-bottom: var(--space-2); }
  .review__image .ratio { display: block; max-height: 45vh; margin-inline: auto; }
  .review__image .ratio > img { object-fit: contain; }
  .review__text { max-height: none; }
  .review__actions { flex-wrap: nowrap; gap: var(--space-2); }
  .review__actions > form { flex: 1; display: flex; }
  .review__actions > form .btn { flex: 1; }
  .review__actions > .review__approve { flex-grow: 1.6; }
  .review__reject { order: -1; }
  .review__actions .btn--link { border-color: var(--border-strong); text-decoration: none; color: var(--text); }
  .review__next { margin-left: 0; min-width: 44px; }
  .review__more > .reveal:not([open]) { flex: 1; }
  .review__more summary .btn { width: 100%; }
}
.file-list__item .badge { flex: none; }
[data-copy].is-copied { color: var(--success); }
