/* Traffic Orchestra — cabinet design system (D-091 / D-092).
   One file: tokens first (dark is the default, light under [data-theme="light"] or the system
   scheme), then layout (sidebar / topbar / main), then components. Every colour, radius and size
   is a custom property; change --accent to re-skin. tests/test_cabinet_palette.py reads the
   hex tokens of both themes and checks WCAG contrast, so keep the tested tokens plain hex. */

/* ---------------------------------------------------------------- tokens: dark (default) */
:root {
  color-scheme: dark;
  --bg: #0d0f17;
  --surface: #151826;
  --surface-2: #1c2033;
  --border: #262a3d;
  --text: #e8eaf2;
  --text-muted: #9ba1b8;

  --accent: #6d4aff;
  --accent-hover: color-mix(in srgb, var(--accent) 85%, #ffffff);
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-contrast: #ffffff;

  --success: #2fbf71;
  --success-text: #5fe09a;
  --success-soft: color-mix(in srgb, var(--success) 18%, transparent);
  --warning: #e0a62a;
  --warning-text: #f2c35c;
  --warning-soft: color-mix(in srgb, var(--warning) 18%, transparent);
  --danger: #ef5a6f;
  --danger-text: #ff8a9a;
  --danger-soft: color-mix(in srgb, var(--danger) 18%, transparent);
  --info: #3b9cf0;
  --info-text: #6fb8ff;
  --info-soft: color-mix(in srgb, var(--info) 18%, transparent);
  /* badges laid over an image (library cards): opaque plaque, tone text on it */
  --overlay-badge-bg: #151826;
  --overlay-badge-border: #343950;
  --overlay-badge-text: #e8eaf2;
  --overlay-badge-accent: #a596ff;
  --overlay-badge-info: #6fb8ff;
  --overlay-badge-warning: #f2c35c;
  --overlay-badge-danger: #ff8a9a;
  --overlay-badge-muted: #9ba1b8;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 64px;
  /* P1 (v0.4): the content column fills the window between the sidebar and the right edge —
     no page-level cap; long-text pages cap their own wrapper (.prose / .digest-body) */
  --page-pad: var(--space-5);
  --content-max: none;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-title: 1.75rem;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --focus: 0 0 0 3px var(--accent-soft);
}

/* ---------------------------------------------------------------- tokens: light */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f5fa;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --border: #d9dce8;
    --text: #171a26;
    --text-muted: #5b6075;
    --accent: #5b3df5;
    --accent-hover: color-mix(in srgb, var(--accent) 85%, #000000);
    --accent-contrast: #ffffff;
    --success: #1f9d5a;
    --success-text: #13784a;
    --warning: #b7791f;
    --warning-text: #8a5a12;
    --danger: #d6375c;
    --danger-text: #b4254a;
    --info: #1d7ed6;
    --info-text: #1664ad;
    --overlay-badge-bg: #ffffff;
    --overlay-badge-border: #d9dce8;
    --overlay-badge-text: #171a26;
    --overlay-badge-accent: #5b3df5;
    --overlay-badge-info: #1664ad;
    --overlay-badge-warning: #8a5a12;
    --overlay-badge-danger: #b4254a;
    --overlay-badge-muted: #5b6075;
    --shadow: 0 8px 24px rgba(23, 26, 38, 0.12);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --border: #d9dce8;
  --text: #171a26;
  --text-muted: #5b6075;
  --accent: #5b3df5;
  --accent-hover: color-mix(in srgb, var(--accent) 85%, #000000);
  --accent-contrast: #ffffff;
  --success: #1f9d5a;
  --success-text: #13784a;
  --warning: #b7791f;
  --warning-text: #8a5a12;
  --danger: #d6375c;
  --danger-text: #b4254a;
  --info: #1d7ed6;
  --info-text: #1664ad;
  --overlay-badge-bg: #ffffff;
  --overlay-badge-border: #d9dce8;
  --overlay-badge-text: #171a26;
  --overlay-badge-accent: #5b3df5;
  --overlay-badge-info: #1664ad;
  --overlay-badge-warning: #8a5a12;
  --overlay-badge-danger: #b4254a;
  --overlay-badge-muted: #5b6075;
  --shadow: 0 8px 24px rgba(23, 26, 38, 0.12);
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3, h4, h5 { line-height: 1.25; margin: 0 0 var(--space-3); font-weight: 650; }
h2 { font-size: var(--fs-title); letter-spacing: -0.01em; }
h3 { font-size: var(--fs-xl); margin-top: var(--space-4); }
h4 { font-size: var(--fs-lg); margin-top: var(--space-3); }
h5 { font-size: var(--fs-md); margin-top: var(--space-2); }
p { margin: 0 0 var(--space-3); }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.925em; }
code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: var(--radius-sm); }
pre { background: var(--surface-2); padding: var(--space-3); border-radius: var(--radius-md); overflow: auto; }
pre.excerpt { white-space: pre-wrap; font-family: inherit; color: var(--text-muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }
img, video { max-width: 100%; height: auto; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); font-size: var(--fs-sm); }
.error { color: var(--danger-text); }
.inactive { opacity: 0.6; }
.env { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------------------------------------------------------------- icons */
.icon {
  width: 1.25em;
  height: 1.25em;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.3em;
  flex: 0 0 auto;
}

/* ---------------------------------------------------------------- app layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
/* P2: the collapsed rules match `html[data-sidebar-collapsed="1"]` too — shell_boot.js sets it in
   <head> from localStorage before the first paint, so a collapsed sidebar never flashes open;
   cabinet.js keeps the class and the attribute in step on toggle. */
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.app-main { display: flex; flex-direction: column; min-width: 0; }

/* Sidebar: the <aside> stretches the whole grid row (its background runs the full page height,
   also in full-page screenshots); .sidebar-inner is the sticky, viewport-high flex column with the
   brand pinned at the top, the collapse button / env pinned at the bottom and the nav scrolling on
   its own in between. */
.sidebar {
  position: relative;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 30;
}
.sidebar-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.thin-scroll, .sidebar-nav { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.thin-scroll::-webkit-scrollbar, .sidebar-nav::-webkit-scrollbar { width: 6px; height: 6px; }
.thin-scroll::-webkit-scrollbar-thumb, .sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.thin-scroll::-webkit-scrollbar-track, .sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-brand { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-4) var(--space-3); flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: var(--space-3); color: var(--text); min-width: 0; flex: 1; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  font-size: var(--fs-sm);
  flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-caption { font-size: var(--fs-xs); color: var(--text-muted); text-transform: capitalize; }
/* drawer-only buttons; two classes so the later .btn rule does not win */
.sidebar .sidebar-close { display: none; }

.workspace-switch { padding: 0 var(--space-4) var(--space-3); display: grid; gap: var(--space-1); flex: 0 0 auto; }
.workspace-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.workspace-select { width: 100%; }

.sidebar-nav { flex: 1 1 auto; min-height: 0; overflow: hidden auto; scroll-behavior: auto; padding: 0 var(--space-3) var(--space-3); display: grid; gap: var(--space-3); align-content: start; }
.nav-group { display: grid; gap: 2px; }
.nav-heading {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-3) var(--space-1);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.3;
  min-height: 38px;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.nav-icon { width: 20px; height: 20px; color: var(--text-muted); }
.nav-item[aria-current="page"] .nav-icon { color: var(--accent); }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge, #unread-badge { margin-left: auto; }
#unread-badge { background: var(--danger); color: #ffffff; }

.sidebar-foot { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); background: var(--surface); }
.sidebar-collapse .collapse-icon { transition: transform 0.15s; }
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .sidebar-collapse .collapse-icon { transform: rotate(180deg); }
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .brand-text,
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .workspace-switch,
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .nav-heading,
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .nav-label,
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .env { display: none; }
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .sidebar-brand,
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .sidebar-foot { justify-content: center; padding-left: var(--space-2); padding-right: var(--space-2); }
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .nav-item { justify-content: center; padding: var(--space-2); }
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .nav-badge,
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) #unread-badge { position: absolute; transform: translate(14px, -12px); }
:is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .nav-item { position: relative; }

/* topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--topbar-h);
  padding: var(--space-2) var(--space-5);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: var(--fs-xl); font-weight: 700; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .topbar-menu { display: none; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: nowrap; }
.topbar-bell { position: relative; }
/* topbar search (W8, D-111): the input + icon button, the live dropdown under it */
.topbar-search { position: relative; display: flex; align-items: center; gap: var(--space-1); margin: 0; flex: 0 1 auto; min-width: 0; }
.topbar-search input[type="search"] { width: 16rem; max-width: 100%; }
/* P8: at laptop widths the fixed 16rem search truncated the section title («Очередь прове…»,
   «Библио…» with the long spend badge); narrower search, the title keeps its words. */
@media (max-width: 1400px) { .topbar-search input[type="search"] { width: 11rem; } }
.topbar-search .search-results { left: 0; right: auto; top: calc(100% + 4px); width: max(100%, 24rem); max-width: calc(100vw - 2 * var(--space-4)); max-height: 70vh; overflow: auto; display: block; padding: var(--space-1) 0; }
.topbar-search .search-results[hidden] { display: none; }
.search-group { padding: var(--space-1) 0; }
.search-group + .search-group { border-top: 1px solid var(--border); }
.search-group-title { display: flex; align-items: center; gap: var(--space-2); margin: 0; padding: var(--space-2) var(--space-3) var(--space-1); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.search-list { list-style: none; margin: 0; padding: 0; }
.search-hit { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--text); min-width: 0; }
.search-hit:hover, .search-hit:focus-visible { background: var(--surface-2); text-decoration: none; color: var(--text); }
.search-hit .icon { width: 16px; height: 16px; color: var(--text-muted); flex: 0 0 auto; }
.search-hit-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hit-sub { flex: 0 0 auto; font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.search-hint, .search-empty { margin: 0; padding: var(--space-3); }
.search-all { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-1); padding: var(--space-2) var(--space-3); border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.search-all .icon { width: 16px; height: 16px; }
.search-page .search-group { padding: var(--space-2) 0; }
.search-page .search-group-title { padding-left: 0; padding-right: 0; }
.search-page .search-hit { padding-left: var(--space-2); padding-right: var(--space-2); }
.search-page .search-hint, .search-page .search-empty { padding: var(--space-2) 0; }
.topbar-bell-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #ffffff;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.spend-chip { white-space: nowrap; }
.theme-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--surface); }
.theme-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 30px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.theme-btn:hover { color: var(--text); }
.theme-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }
.user-summary { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1); list-style: none; cursor: pointer; }
.user-summary::-webkit-details-marker { display: none; }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: var(--fs-sm); }
.user-name { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-login { font-size: var(--fs-sm); font-weight: 600; }
.menu-caret { color: var(--text-muted); }

/* page */
.page { padding: var(--page-pad); max-width: var(--content-max); width: 100%; min-width: 0; }
.page-head { margin-bottom: var(--space-4); }
.page-head h2, .page > h2 { font-size: var(--fs-title); margin-bottom: var(--space-3); }
.page-title { font-size: var(--fs-title); font-weight: 700; margin: 0 0 var(--space-3); }
section.block { margin: var(--space-5) 0; }
section.block > h3:first-child { margin-top: 0; }

/* auth layout (login, no shell) */
.auth-body { display: grid; place-items: center; padding: var(--space-4); }
.auth-layout { width: 100%; max-width: 420px; }
.auth-card { padding: var(--space-6) var(--space-5); }
.auth-brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); font-weight: 700; font-size: var(--fs-lg); }
.auth-card form { display: grid; gap: var(--space-3); }
.auth-card label { display: grid; gap: var(--space-1); font-size: var(--fs-sm); color: var(--text-muted); }
.auth-card input { font-size: var(--fs-md); }
.auth-card button[type="submit"] { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

/* drawer (≤ 900px) */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 25; }
@media (max-width: 900px) {
  .app, :is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: none;
  }
  .app.drawer-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .sidebar-inner { position: static; height: 100%; }
  .sidebar .sidebar-collapse { display: none; }
  .sidebar .sidebar-close { display: inline-flex; }
  .topbar .topbar-menu { display: inline-flex; }
  .topbar { padding: var(--space-2) var(--space-4); }
  .page { padding: var(--space-4); }
  .topbar-search input[type="search"] { width: 8rem; transition: width 0.15s ease; }
  .topbar-search:focus-within input[type="search"] { width: 14rem; }
  .topbar-search .search-results { width: min(24rem, calc(100vw - 2 * var(--space-4))); }
  .spend-chip { display: none; }
  .user-name { display: none; }
  :is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .brand-text,
  :is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .workspace-switch,
  :is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .nav-heading,
  :is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .nav-label,
  :is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .env { display: initial; }
  :is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .nav-item { justify-content: flex-start; padding: var(--space-2) var(--space-3); }
  :is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) .nav-badge, :is(.app.sidebar-collapsed, html[data-sidebar-collapsed="1"] .app) #unread-badge { position: static; transform: none; }
}
@media (max-width: 480px) {
  .theme-switch { display: none; }
  .topbar-title { font-size: var(--fs-lg); }
  .topbar-search input[type="search"] { width: 6rem; }
  .topbar-search:focus-within input[type="search"] { width: 11rem; }
  .topbar-search .topbar-search-btn { display: none; }
  /* the dropdown spans the viewport under the top bar instead of overflowing it to the right */
  .topbar-search .search-results { position: fixed; left: var(--space-3); right: var(--space-3); top: var(--topbar-h); width: auto; max-width: calc(100vw - 2 * var(--space-3)); }
}

/* ---------------------------------------------------------------- buttons */
.btn, button, input[type="submit"], input[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover, button:hover { background: color-mix(in srgb, var(--surface-2) 80%, var(--text) 8%); text-decoration: none; color: var(--text); }
.btn:disabled, button:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover, button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger-text); }
.btn-danger:hover { background: var(--danger); color: #ffffff; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: var(--fs-xs); }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.btn-icon .icon { width: 20px; height: 20px; }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-start; }
.actions form { margin: 0; }
.actions form.stack { flex: 1 1 18rem; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.card-sm { padding: var(--space-3); border-radius: var(--radius-md); }
.card > :last-child { margin-bottom: 0; }
.stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  color: var(--text);
}
a.stat-card:hover { border-color: var(--accent); text-decoration: none; color: var(--text); }
.stat-card-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent); }
.stat-card-icon .icon { width: 22px; height: 22px; }
.stat-card-success .stat-card-icon { background: var(--success-soft); color: var(--success-text); }
.stat-card-warning .stat-card-icon { background: var(--warning-soft); color: var(--warning-text); }
.stat-card-danger .stat-card-icon { background: var(--danger-soft); color: var(--danger-text); }
.stat-card-info .stat-card-icon { background: var(--info-soft); color: var(--info-text); }
.stat-card-body { display: flex; flex-direction: column; min-width: 0; }
.stat-card-value { font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; }
.stat-card-label { font-size: var(--fs-sm); color: var(--text-muted); }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* home («Главная»): blocks stacked with one gap; stat cards in equal columns chosen by the
   role's card count (data-count) so no row is left with a lonely card: n ≤ 5 -> n columns,
   6 -> 3, 7 / 8 -> 4 (≥ 1100px); 2 columns from 640px, 1 below. */
.home-stack { display: grid; gap: var(--space-5); align-content: start; }
.home-stack > .card > h3:first-child { margin-top: 0; }
.stat-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-grid > div { display: grid; }
@media (min-width: 1100px) {
  .stat-grid[data-count="1"] { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .stat-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid[data-count="3"], .stat-grid[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid[data-count="4"], .stat-grid[data-count="7"], .stat-grid[data-count="8"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid[data-count="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 639px) { .stat-grid { grid-template-columns: minmax(0, 1fr); } }

.empty-state { padding: var(--space-6) var(--space-4); text-align: center; color: var(--text-muted); border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.empty-state p { margin-bottom: var(--space-3); }
.empty-state-action { display: flex; justify-content: center; }

/* ---------------------------------------------------------------- badges, chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  min-width: 1.5em;
  padding: 0.1em 0.55em;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  vertical-align: middle;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge:empty { display: none; }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-info { background: var(--info-soft); color: var(--info-text); }
/* legacy tones used by the templates (status / level / role) */
.badge.role { background: var(--surface-2); color: var(--text-muted); }
.badge.level { text-transform: uppercase; }
.badge.level.info, .badge.status.new, .badge.status.draft, .badge.status.sent, .badge.status.published, .badge.status.active, .badge.status.generating, .badge.status.in_review, .badge.status.review { background: var(--info-soft); color: var(--info-text); }
.badge.level.warning, .badge.status.researching, .badge.status.warn, .badge.status.warning, .badge.status.pending { background: var(--warning-soft); color: var(--warning-text); }
.badge.level.error, .badge.status.rejected, .badge.status.failed, .badge.status.error, .badge.status.not_working, .badge.status.inactive, .badge.status.banned { background: var(--danger-soft); color: var(--danger-text); }
.badge.status.ready, .badge.status.approved, .badge.status.done, .badge.status.pass, .badge.status.working, .badge.status.launched, .badge.status.ok { background: var(--success-soft); color: var(--success-text); }
.badge.status.used, .badge.status.archived, .badge.status.muted { background: var(--surface-2); color: var(--text-muted); }
.status { border: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text);
}
.chip .icon { color: var(--text-muted); }

/* ---------------------------------------------------------------- tabs, toolbar, filters */
.tabs, nav.tabs {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin: var(--space-2) 0 var(--space-4);
}
.tabs a, .tabs .tab {
  padding: var(--space-2) 0;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current], .tabs a.active, .tabs a.current { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.counts { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: var(--space-2) 0 var(--space-3); }
.counts a { color: var(--text-muted); }
.counts a.active { color: var(--text); font-weight: 600; }

.toolbar, .filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  margin: var(--space-3) 0 var(--space-4);
}
.toolbar label, .filters label { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); color: var(--text-muted); max-width: 100%; min-width: 0; } /* X8.3: a select with a long option shrinks on a phone */
.toolbar input, .toolbar select, .filters input, .filters select { width: auto; }

/* ---------------------------------------------------------------- forms */
input, select, textarea {
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  max-width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input[type="checkbox"], input[type="radio"] { width: 1rem; height: 1rem; padding: 0; accent-color: var(--accent); vertical-align: -0.15em; }
input[type="range"] { padding: 0; accent-color: var(--accent); background: transparent; border: 0; }
input[type="file"] { padding: 0.3rem; }
input[readonly] { color: var(--text-muted); }
textarea { width: 100%; max-width: 40rem; min-height: 3rem; resize: vertical; }
select { padding-right: 1.6rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-3); min-width: 0; }
legend { padding: 0 var(--space-2); color: var(--text-muted); font-size: var(--fs-sm); }
label { font-size: var(--fs-sm); }
form.stack, .form-stack { display: grid; gap: var(--space-3); max-width: 28rem; }
form.stack label, .form-stack label, .field { display: grid; gap: var(--space-1); }
form.stack label > input[type="checkbox"], form.stack label > input[type="radio"] { justify-self: start; }
form.stack button, .form-stack button { justify-self: start; }
/* P8: checkboxes in one wrapping row, label text to the right of each box (auto-mode channels). */
.check-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.check, form.stack label.check, .form-stack label.check { display: inline-flex; align-items: flex-start; gap: var(--space-2); cursor: pointer; line-height: 1.35; }
.check input[type="checkbox"] { margin: 0.15em 0 0; flex: 0 0 auto; }
form.stack button[type="submit"], .form-stack button[type="submit"], #generate-form button[type="submit"] { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
form.stack button[type="submit"]:hover, .form-stack button[type="submit"]:hover { background: var(--accent-hover); }
.copy-field { width: 100%; font-family: var(--font-mono); }
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.range-row { display: flex; align-items: center; gap: var(--space-3); }
.range-row output { min-width: 3ch; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tables */
/* `position: relative` (V13): a wide table scrolls INSIDE the wrap only when absolutely positioned
   descendants (`.sr-only` headings in a far column) are contained by it — otherwise they sit at
   their static x far right of the viewport and the whole page scrolls horizontally. */
.table-wrap { position: relative; overflow: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); margin: var(--space-3) 0; }
table, .table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.col-thumb { width: 12rem; }
td.col-actions { width: 8rem; white-space: nowrap; }
@media (max-width: 640px) {
  .table-cards thead { display: none; }
  .table-cards tr { display: block; border-bottom: 1px solid var(--border); padding: var(--space-2) 0; }
  .table-cards td { display: grid; grid-template-columns: 9rem 1fr; gap: var(--space-2); border: 0; padding: var(--space-1) var(--space-3); }
  .table-cards td::before { content: attr(data-label); color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; }
}

/* ---------------------------------------------------------------- lists, kv, pager, feed */
dl.kv, .kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: 0 0 var(--space-3); }
dl.kv dt, .kv dt { font-weight: 600; color: var(--text-muted); font-size: var(--fs-sm); }
dl.kv dd, .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { dl.kv, .kv { grid-template-columns: 1fr; gap: var(--space-1); } dl.kv dd, .kv dd { margin-bottom: var(--space-2); } }
.pager { margin-top: var(--space-4); display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.pager a { padding: 0.35rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text); }
.pager a:hover { background: var(--surface-2); text-decoration: none; }
ul.feed { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
ul.feed li { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
ul.feed li:last-child { border-bottom: 0; }
ul.feed li.unread { border-left: 3px solid var(--accent); font-weight: 600; }
ul.feed li.unread p { font-weight: 400; }
ul.feed li p { margin: var(--space-1) 0; }
ul.quick-links { columns: 2; padding-left: 1.2rem; }
@media (max-width: 640px) { ul.quick-links { columns: 1; } }
ul, ol { padding-left: 1.25rem; }

/* ---------------------------------------------------------------- flash */
.flash { padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); }
.flash:empty { display: none; }
.flash.info { border-color: var(--info); background: var(--info-soft); color: var(--info-text); }
.flash.warning { border-color: var(--warning); background: var(--warning-soft); color: var(--warning-text); }
.flash.error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger-text); }
.flash a { color: inherit; text-decoration: underline; }

/* ---------------------------------------------------------------- menu (details) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: var(--space-1);
  z-index: 40;
  display: grid;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  font-size: var(--fs-sm);
  justify-content: flex-start;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.menu-item[aria-current="page"] { font-weight: 600; }
.menu-form { margin: 0; display: block; }

/* ---------------------------------------------------------------- media */
.thumb { max-width: 11rem; max-height: 11rem; border-radius: var(--radius-sm); }
.media-preview { max-width: 100%; max-height: 12rem; border-radius: var(--radius-sm); display: block; }
.media-full { max-width: 100%; max-height: 28rem; border-radius: var(--radius-md); display: block; }
.preview-strip { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: var(--space-2); }
.preview-strip img, .preview-strip video { height: 6rem; width: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
details > summary { cursor: pointer; }
details.block { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); background: var(--surface); margin: var(--space-2) 0; }
details.block[open] { padding-bottom: var(--space-3); }
/* text pages (knowledge base sections, ideas digest): readable measure, nothing else is capped */
.prose, .page--text, .digest-body { max-width: 80ch; }
.digest-body h1 { font-size: var(--fs-xl); }
.digest-body h2 { font-size: var(--fs-lg); margin-top: var(--space-4); }

/* ---------------------------------------------------------------- htmx (indicator styles live here: CSP forbids the injected tag) */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request button[type="submit"] { opacity: 0.7; cursor: progress; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ==== Photo/Video lab ==== (D-093: /photo and /video — form · results · materials panel) */
/* P1 (v0.4): three EQUAL columns «форма — результаты — материалы». Breakpoints are viewport
   media queries in CSS px — browser zoom changes the CSS viewport (a 2560 px window at 50 % is
   5120 CSS px, a 1280 px window at 200 % is 640 CSS px), which is what «масштаб 50–200 %» means:
     ≥ 1280 px  — repeat(3, minmax(0, 1fr)); the materials panel collapsed to its 44 px rail
                  (`.lab.panel-collapsed`, state in localStorage — cabinet.js) gives
                  minmax(0, 1fr) minmax(0, 1fr) 44px, so form and results share the width;
     900–1279   — two columns (form | results), the materials panel spans both below them;
     < 900      — one column (form, results, materials).
   The results column is itself a responsive card grid (auto-fill, minmax(260px, 1fr)). */
.lab-wrap { min-width: 0; }
.lab { --lab-rail-w: 44px; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; min-width: 0; }
.lab > * { min-width: 0; }
.lab-form { max-width: 100%; }
@media (min-width: 900px) {
  .lab, .lab.panel-collapsed { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lab-panel { grid-column: 1 / -1; }
}
@media (min-width: 1500px) {
  .lab { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lab.panel-collapsed { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--lab-rail-w); }
  .lab-panel { grid-column: auto; position: sticky; top: calc(var(--topbar-h) + var(--space-3)); max-height: calc(100vh - var(--topbar-h) - var(--space-5)); overflow: auto; }
}
.lab-form form { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); max-width: none; }
.lab-hint { margin-top: calc(-1 * var(--space-2)); }
.lab-workspace { display: grid; gap: 2px; margin: calc(-1 * var(--space-1)) 0 0; }
.lab-workspace p { margin: 0; font-size: var(--fs-sm); }
.lab-workspace strong { color: var(--text); font-weight: 600; }
.lab-workspace-hint { font-size: var(--fs-xs); }
.prompt-hint { margin: calc(-1 * var(--space-2)) 0 0; font-size: var(--fs-sm); }
.clipboard-shim { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }
.lab textarea.is-invalid { border-color: var(--danger); }
.field-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}
.field-label .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.lab .field { display: grid; gap: var(--space-1); min-width: 0; }
.lab .field select, .lab .field input[type="text"], .lab .field input[type="search"], .lab .field input[type="number"], .lab .field textarea { width: 100%; max-width: none; }
.field-row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.field-row select { flex: 1 1 10rem; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: var(--space-3); }
/* P3 (v0.4): the model parameters sit inside the «Модель и параметры» group — no box of their own */
.lab-fieldset { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: var(--space-3); }
.format-row select { flex: 1 1 7rem; min-width: 0; }

/* P3 (v0.4): collapsible groups «Модель и параметры» / «Референсы» / «Дополнительно»
   (<details class="lab-group" data-group>; the open state per user + lab is in localStorage,
   cabinet.js). Short labels; every explanation is a «?» hint (.hint) with a pure-CSS tooltip. */
.lab-group { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); min-width: 0; }
.lab-group > summary { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); margin: 0; cursor: pointer; list-style: none; font-size: var(--fs-sm); font-weight: 600; }
.lab-group > summary::-webkit-details-marker { display: none; }
.lab-group > summary .icon { width: 16px; height: 16px; flex: none; }
.lab-group > summary .lab-group-caret { margin-left: auto; color: var(--text-muted); transition: transform 0.15s ease; }
.lab-group[open] > summary .lab-group-caret { transform: rotate(180deg); }
.lab-group-body { display: grid; gap: var(--space-3); padding: var(--space-1) var(--space-3) var(--space-3); min-width: 0; }
.lab-subgroup { display: grid; gap: var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--border); }
.lab-subgroup:first-child { padding-top: 0; border-top: 0; }
.lab-subgroup-title { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--fs-sm); font-weight: 600; }
.lab-subgroup-title .icon { width: 16px; height: 16px; }
.hint { position: relative; display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; margin: 0 0 0 2px; border: 0; border-radius: 50%; background: none; color: var(--text-muted); cursor: help; vertical-align: middle; font: inherit; }
.hint .icon { width: 14px; height: 14px; }
.hint:hover, .hint:focus-visible { color: var(--accent); }
.hint::after {
  content: attr(data-hint);
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30;
  width: max-content; max-width: min(320px, 70vw);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: var(--fs-sm); font-weight: 400; letter-spacing: 0; text-transform: none; white-space: normal; text-align: left; line-height: 1.4;
  /* X8.3 (D-211): a hidden tooltip takes no room — with visibility alone it still widened the
     page (on a phone «Фото» / «Видео» were up to 42 px wider than the screen). */
  display: none; pointer-events: none;
}
.hint:hover::after, .hint:focus-visible::after { display: block; }
@media (max-width: 600px) {
  /* on a phone the open tooltip is a strip at the bottom of the screen, never past its edge */
  .hint::after { position: fixed; left: var(--space-4); right: var(--space-4); top: auto; bottom: var(--space-4); width: auto; max-width: none; }
}
.lab-group > summary .hint { margin-left: 0; }

/* pills (radio groups) */
.pill-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pill { position: relative; display: inline-flex; }
form.stack .pill, .form-stack .pill { display: inline-flex; gap: 0; } /* beats the grid rule for form labels */
.pill input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.pill span {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.pill input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.pill input:focus-visible + span { box-shadow: var(--focus); }
.pill input:disabled + span { opacity: 0.55; cursor: not-allowed; }

/* toggle («Генерировать звук») */
.toggle { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--fs-sm); }
.toggle input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.toggle-track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--border); transition: background 0.15s; flex: 0 0 auto; }
.toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { box-shadow: var(--focus); }

/* range slider (duration) — P6: the track on --surface-2 with the filled part in --accent
   (`--range-progress` is set by cabinet.js on input), the thumb an accent circle with a 2 px
   --surface border; min / max labels and the number box on one row at every width */
.lab .range-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 4.5rem; gap: var(--space-2); align-items: center; }
.lab .range-row input[type="range"] { width: 100%; height: 22px; margin: 0; }
.lab .range-min, .lab .range-max { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.lab .range-number { width: 100%; text-align: center; font-variant-numeric: tabular-nums; }
.lab input[type="range"] { --range-progress: 0%; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
.lab input[type="range"]:focus { outline: none; }
.lab input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; border: 1px solid var(--border); background: linear-gradient(to right, var(--accent) 0, var(--accent) var(--range-progress), var(--surface-2) var(--range-progress), var(--surface-2) 100%); }
.lab input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface-2); }
.lab input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.lab input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); cursor: pointer; }
.lab input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); cursor: pointer; }
.lab input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus); }
.lab input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: var(--focus); }

/* reference blocks */
.ref-blocks { display: grid; gap: var(--space-3); }
.ref-block { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3) var(--space-3); display: grid; gap: var(--space-2); background: var(--surface); }
.ref-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.ref-head .field-label { margin: 0; }
.ref-counter { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ref-counter.is-full { color: var(--warning-text); font-weight: 600; }
.ref-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.ref-list:empty { display: none; }
.ref-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: var(--space-2); align-items: center; padding: var(--space-1); border-radius: var(--radius-sm); background: var(--surface-2); }
.ref-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.ref-thumb-icon { display: inline-grid; place-items: center; color: var(--text-muted); background: var(--surface); }
.ref-label { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-type { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.ref-remove { padding: 0.2rem; width: 28px; height: 28px; }
.ref-add { justify-self: start; }
.ref-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-self: start; }
.ref-hint { margin: 0; }

/* bottom row: variants · cost · generate */
/* P3 (v0.4): the cost + «Сгенерировать» stick to the bottom of the viewport while the (page-
   scrolled) form column is longer than the screen; negative margins let the bar cover the card
   padding so the form content slides under it. The form column never sets overflow (the «?»
   tooltips must not be clipped). */
.lab-actions { position: sticky; bottom: 0; z-index: 5; display: grid; gap: var(--space-3); margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-4)) calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-4) var(--space-4); background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.cost-box { display: grid; gap: 2px; }
.cost-box p { margin: 0; }
/* R5: the line under «Сгенерировать» (refusal / queued) and «Очистить форму» (R6) */
.generate-message { margin: 0; font-size: var(--fs-sm); }
.lab-actions .draft-clear { justify-self: start; }
#generate-form button.draft-clear, form.stack button.draft-clear, button.draft-clear { background: transparent; border-color: transparent; color: var(--text-muted); }
#generate-form button.draft-clear:hover, form.stack button.draft-clear:hover, button.draft-clear:hover { background: var(--surface-2); color: var(--text); }
.cost-line { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.cost-value { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.btn-lg { padding: 0.7rem 1.2rem; font-size: var(--fs-md); font-weight: 600; width: 100%; }

/* results */
.lab-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); align-content: start; }
.lab-results-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.lab-results-head h3 { margin: 0; }
.repeat-select { max-width: 100%; flex: 1 1 14rem; }
.result-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: var(--space-3); align-items: start; }
.result-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); min-width: 0; }
.result-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.result-model { font-weight: 600; font-size: var(--fs-sm); }
.result-time { margin-left: auto; font-size: var(--fs-xs); }
.result-title { margin: 0; font-weight: 600; overflow-wrap: anywhere; } /* X8.3: a title / error without spaces wraps */
.result-prompt { margin: 0; overflow-wrap: anywhere; }
.result-error { margin: 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
/* R3: elapsed / total generation time and «обычно ~…» of the model (gen_timer.js ticks it) */
.result-timing { margin: 0; font-size: var(--fs-sm); }
.gen-elapsed { font-variant-numeric: tabular-nums; }
.gen-dur { white-space: nowrap; }
/* P3: the preview fills the card width, letterboxed up to ~70vh */
.result-preview { overflow: hidden; min-width: 0; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-2); }
.result-preview img, .result-preview video { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
/* P4: one uniform grid of .btn.btn-sm actions (2 columns ≥ 480 px), «В воронку» is a details.menu
   whose summary is styled like the other buttons */
.result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--space-2); align-items: stretch; }
.result-actions > * { min-width: 0; }
.result-actions .btn { width: 100%; height: 100%; min-height: 2.25rem; box-sizing: border-box; justify-content: flex-start; white-space: normal; text-align: left; line-height: 1.2; }
.result-actions .btn .icon { flex: none; width: 16px; height: 16px; }
.result-funnel { display: grid; }
.result-funnel > summary { list-style: none; }
.result-funnel .menu-list { left: 0; right: auto; top: calc(100% + 4px); max-height: 18rem; overflow: auto; }

/* materials panel */
.lab-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); align-content: start; }
.lab-panel h3 { margin: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.panel-toggle { flex: none; width: 32px; height: 32px; color: var(--text-muted); }
.panel-toggle .icon { width: 18px; height: 18px; transition: transform 0.15s; }
.panel-collapsed-hint { margin: 0; writing-mode: vertical-rl; font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: uppercase; justify-self: center; }
/* collapsed: ≥ 1280 px a 44 px rail with the expand button and a vertical caption; narrower
   viewports keep the head row and hide the body (see the media block below) */
.lab.panel-collapsed .lab-panel { padding: var(--space-2) 0; gap: var(--space-2); }
.lab.panel-collapsed .panel-head { flex-direction: column; justify-content: center; }
.lab.panel-collapsed .panel-head h3 { display: none; }
.lab.panel-collapsed .panel-toggle .icon { transform: rotate(180deg); }
.lab.panel-collapsed .panel-tabs, .lab.panel-collapsed .panel-pane { display: none; }
.lab.panel-collapsed .panel-collapsed-hint { display: block; }
.panel-tab-input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.panel-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); }
.panel-tab { padding: var(--space-2) var(--space-2); font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.panel-tab:hover { color: var(--text); }
#tab-character:checked ~ .panel-tabs [for="tab-character"],
#tab-library:checked ~ .panel-tabs [for="tab-library"],
#tab-upload:checked ~ .panel-tabs [for="tab-upload"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.panel-pane { display: none; gap: var(--space-3); }
/* V13: the id selectors outrank `.lab.panel-collapsed .panel-pane`, so the active pane
   leaked into the 44 px rail (clipped by overflow) — show a pane only while the panel is open */
.lab:not(.panel-collapsed) #tab-character:checked ~ #pane-character, .lab:not(.panel-collapsed) #tab-library:checked ~ #pane-library, .lab:not(.panel-collapsed) #tab-upload:checked ~ #pane-upload { display: grid; }
.panel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.panel-item { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: var(--space-2); align-items: center; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.panel-item .panel-add { grid-column: 1 / -1; justify-self: start; }
.panel-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.panel-thumb-icon { display: inline-grid; place-items: center; color: var(--text-muted); background: var(--surface); }
.panel-item-body { display: grid; gap: 2px; min-width: 0; }
.panel-item-title { font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-item .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-item.is-added { border-color: var(--accent); }
.lab-panel .dropzone { display: grid; gap: var(--space-2); place-items: center; cursor: pointer; padding: var(--space-4); }
.lab-panel .dropzone .icon { width: 28px; height: 28px; }
.lab-panel .dropzone input[type="file"] { width: 100%; font-size: var(--fs-xs); }
#upload-previews { flex-wrap: wrap; }
#upload-previews:empty { display: none; }
.upload-preview { position: relative; display: inline-grid; place-items: center; width: 6rem; height: 6rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); overflow: hidden; }
.upload-preview img, .upload-preview video { width: 100%; height: 100%; object-fit: cover; }
.upload-preview .upload-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; font-size: var(--fs-xs); background: rgba(0, 0, 0, 0.6); color: #ffffff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-preview .upload-icon { color: var(--text-muted); }

/* responsive (CSS viewport, see the breakpoints at the top of this section): three columns
   (form / results / materials) from 1500 px, two columns from 900 px (Q0-A). Below 1500 px the
   panel sits under the form / results as a full-width card: the collapsed state keeps the head
   row and hides the body, the chevron points down / up instead of right / left. */
@media (max-width: 1499px) {
  .lab-panel { position: static; max-height: none; }
  .lab.panel-collapsed .lab-panel { padding: var(--space-2) var(--space-3); }
  .lab.panel-collapsed .panel-head { flex-direction: row; justify-content: space-between; }
  .lab.panel-collapsed .panel-head h3 { display: block; }
  .lab.panel-collapsed .panel-toggle .icon { transform: rotate(90deg); }
  .lab.panel-collapsed .panel-collapsed-hint { display: none; }
  .panel-toggle .icon { transform: rotate(-90deg); }
}
@media (max-width: 899px) {
  .result-preview img, .result-preview video { max-height: 60vh; }
}
@media (max-width: 479px) {
  .result-actions { grid-template-columns: minmax(0, 1fr); }
  .ref-item { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .ref-type { display: none; }
}

/* ==== Characters ==== */
/* generic additions (dashboard + references, V5) */
.card > h3:first-child { margin-top: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2) var(--space-3); flex-wrap: wrap; }
.section-head > h3, .section-head > h2 { margin: 0; min-width: 0; }
.section-head h3 .icon { width: 18px; height: 18px; vertical-align: -0.2em; margin-right: var(--space-1); }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-top: 1px solid var(--border); min-width: 0; }
.list-item:first-child { border-top: 0; }
.list-item > * { min-width: 0; }
.grid > .stat-card, .grid > a.stat-card, a.stat-card { height: 100%; box-sizing: border-box; align-self: stretch; }
.page-head.section-head { align-items: flex-start; }
.page-head-text { min-width: 0; flex: 1 1 24rem; }
.page-head-text p:last-child { margin-bottom: 0; }
.page-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.page-actions .btn .icon, .menu-item .icon { width: 16px; height: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.toolbar-search { position: relative; }
.toolbar-search .icon { position: absolute; left: 0.6rem; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.toolbar-search input[type="search"] { padding-left: 2rem; width: 16rem; max-width: 100%; }
details.details-card > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-lg); list-style: none; display: flex; align-items: center; gap: var(--space-2); }
details.details-card > summary::-webkit-details-marker { display: none; }
details.details-card > summary::after { content: "+"; margin-left: auto; font-weight: 600; color: var(--text-muted); }
details.details-card[open] > summary::after { content: "–"; }
details.details-card[open] > summary { margin-bottom: var(--space-3); }

/* list: character cards */
.char-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.char-card { padding: 0; overflow: visible; display: flex; flex-direction: column; min-width: 0; }
.char-card.inactive { opacity: 0.7; }
.char-cover { display: block; aspect-ratio: 4 / 3; background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; overflow: hidden; }
.char-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.char-cover-placeholder { display: grid; place-items: center; height: 100%; color: var(--text-muted); }
.char-cover-placeholder .icon { width: 44px; height: 44px; }
.char-body { padding: var(--space-3) var(--space-4) var(--space-4); display: grid; gap: var(--space-2); min-width: 0; }
.char-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); }
.char-name { font-size: var(--fs-lg); margin: 0; min-width: 0; overflow-wrap: anywhere; }
.char-name a { color: var(--text); }
.char-menu > summary { flex: none; }
.char-type { margin: 0; overflow-wrap: anywhere; }
.char-tags { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.char-counters { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.char-counters .icon { width: 14px; height: 14px; }
.char-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: var(--fs-sm); }
.char-meta .muted { margin: 0; }

/* card: header + sections */
.char-head-main { display: flex; gap: var(--space-4); align-items: center; min-width: 0; flex: 1 1 20rem; }
.char-head-text { min-width: 0; display: grid; gap: var(--space-2); }
.char-head-text .page-title { margin: 0; overflow-wrap: anywhere; }
.char-avatar { display: grid; place-items: center; flex: none; width: 72px; height: 72px; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.char-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.char-avatar .icon { width: 32px; height: 32px; }
.char-sections { display: grid; gap: var(--space-4); }
.char-section > p.muted { margin-bottom: var(--space-3); }
.material-list { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: grid; gap: var(--space-3); }
.material-item { display: grid; grid-template-columns: 9rem minmax(0, 1fr) auto; gap: var(--space-3); align-items: start; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); min-width: 0; }
.material-media { min-width: 0; }
.material-thumb { width: 100%; max-height: 9rem; object-fit: cover; display: block; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.material-item audio { width: 100%; max-width: 100%; display: block; }
.material-item video { width: 100%; max-height: 9rem; display: block; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #000; }
.material-item[data-kind="voice"] { grid-template-columns: minmax(0, 1fr) auto; }
.material-item[data-kind="voice"] .material-media { grid-column: 1 / -1; }
.material-body { display: grid; gap: var(--space-1); min-width: 0; overflow-wrap: anywhere; }
.material-badges { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.material-badges .badge { white-space: normal; }
.material-badges .icon { width: 12px; height: 12px; }
.material-actions { margin: 0; }
.upload-block { border: 1px dashed var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); margin-top: var(--space-3); background: var(--surface); }
.upload-block[open] { padding-bottom: var(--space-3); }
.upload-block > summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); list-style: none; display: flex; align-items: center; gap: var(--space-2); }
.upload-block > summary::-webkit-details-marker { display: none; }
.upload-block > summary .icon { width: 16px; height: 16px; }
.upload-block[open] > summary { color: var(--text); margin-bottom: var(--space-3); }
.upload-block form.stack { max-width: 36rem; }
.upload-block form.stack label > .muted { font-size: var(--fs-xs); }

/* card: creatives with this character */
.char-creatives { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }
.creative-tile { display: grid; gap: var(--space-1); color: var(--text); min-width: 0; }
.creative-tile:hover { text-decoration: none; color: var(--text); }
.creative-tile img, .creative-tile-icon { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); }
.creative-tile:hover img, .creative-tile:hover .creative-tile-icon { border-color: var(--accent); }
.creative-tile-icon .icon { width: 28px; height: 28px; }
.creative-tile-meta { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.creative-tile-title { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 640px) {
  .material-item { grid-template-columns: minmax(0, 1fr); }
  .material-thumb { max-height: 14rem; }
  .char-head-main { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn-primary { flex: 1 1 auto; justify-content: center; }
  .toolbar-search input[type="search"] { width: 100%; }
  .toolbar-search { flex: 1 1 100%; }
}
@media (max-width: 480px) {
  .char-grid { grid-template-columns: minmax(0, 1fr); }
  .char-creatives { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* shell fix found while checking 390 px: `.chip { display: inline-flex }` (declared later) beat
   the drawer rule `.spend-chip { display: none }`, so the spend chip stayed and pushed the top bar
   12 px past the viewport. */
@media (max-width: 900px) { .chip.spend-chip { display: none; } }

/* ==== Library ==== */
/* «Библиотека» cards (templates/library/list.html): card on --surface with a 1px border and
   --radius-lg, the preview edge to edge with the type badge, the checkbox and the «…» menu over
   it; title / meta / tags below. */
.library-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2) var(--space-3); flex-wrap: wrap; }
.library-head > p { flex: 1 1 24rem; min-width: 0; margin: 0; }
.library-head > .btn { flex: none; }
.bulk-bar { position: sticky; top: calc(var(--topbar-h) + var(--space-2)); z-index: 10; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); margin: var(--space-3) 0; }
.bulk-bar input[type="text"] { width: 12rem; max-width: 100%; }
.media-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.media-card { padding: 0; overflow: visible; display: flex; flex-direction: column; min-width: 0; }
.media-card > :last-child { padding-bottom: var(--space-3); }
.media-card-preview { position: relative; aspect-ratio: 4 / 5; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.media-card-preview > a { display: block; width: 100%; height: 100%; }
.media-card-preview img, .media-card-preview video, .media-card-preview .media-preview { width: 100%; height: 100%; max-height: none; object-fit: cover; display: block; border-radius: 0; }
.media-card-badges { position: absolute; top: var(--space-2); left: var(--space-2); display: flex; gap: var(--space-1); flex-wrap: wrap; max-width: calc(100% - 3.5rem); pointer-events: none; }
/* over an image the translucent -soft tints are unreadable (18 % accent over a white photo is
   white), so every badge on the preview gets the opaque --overlay-badge-* plaque in both themes;
   the 1px border keeps a white plaque visible on a white image. */
.media-card-badges .badge { background: var(--overlay-badge-bg); color: var(--overlay-badge-text); border-color: var(--overlay-badge-border); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }
.media-card-badges .badge-accent { background: var(--overlay-badge-bg); color: var(--overlay-badge-accent); }
.media-card-badges .badge-info { background: var(--overlay-badge-bg); color: var(--overlay-badge-info); }
.media-card-badges .badge-warning { background: var(--overlay-badge-bg); color: var(--overlay-badge-warning); }
.media-card-badges .badge-danger { background: var(--overlay-badge-bg); color: var(--overlay-badge-danger); }
.media-card-badges .badge-muted { background: var(--overlay-badge-bg); color: var(--overlay-badge-muted); }
.media-card-check { position: absolute; left: var(--space-2); bottom: var(--space-2); display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 999px; background: rgba(0, 0, 0, 0.6); cursor: pointer; }
.media-card-check input[type="checkbox"] { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.media-card-menu { position: absolute; top: var(--space-2); right: var(--space-2); }
.media-card-menu > summary { width: 32px; height: 32px; padding: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #ffffff; border-color: transparent; display: inline-grid; place-items: center; }
.media-card-menu > summary:hover { background: rgba(0, 0, 0, 0.75); color: #ffffff; }
.media-card-menu .menu-list { right: 0; left: auto; }
.media-card-title { padding: var(--space-3) var(--space-3) 0; margin: 0 0 var(--space-1); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card-title a { color: var(--text); }
.media-card-meta { padding: 0 var(--space-3); margin: 0 0 var(--space-1); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card-tags { padding: 0 var(--space-3); margin: 0; display: flex; gap: var(--space-1); flex-wrap: wrap; }
.media-card-tags .chip { font-size: var(--fs-xs); padding: 0.1em 0.5em; }
.menu-item.btn-danger { background: transparent; color: var(--danger-text); }
.menu-item.btn-danger:hover { background: var(--danger-soft); color: var(--danger-text); }
@media (max-width: 480px) {
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bulk-bar { position: static; }
}

/* ==== Packs & funnels ==== */
/* V7: pack cards («Мои паки», «Очередь проверки»), the funnel page step bar and section cards.
   Everything is on the shared tokens; the preview strip scrolls inside its own box so a card
   never widens the page at 390 px. */
.btn-success { background: var(--success-soft); border-color: transparent; color: var(--success-text); }
.btn-success:hover { background: var(--success); color: #ffffff; }
.back-link { margin-bottom: var(--space-2); font-size: var(--fs-sm); }
.back-link a { display: inline-flex; align-items: center; gap: var(--space-1); }
.back-link .icon { width: 16px; height: 16px; }

/* notes: tinted blocks with an icon (reviewer comment, blockers) */
.note { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-2); margin: 0 0 var(--space-3); min-width: 0; }
.note > .icon { flex: none; width: 20px; height: 20px; margin-top: 2px; }
.note-body { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.note-body p { margin: 0; }
.note-body ul { margin: var(--space-1) 0 0; padding-left: 1.2em; }
.note-title { font-size: var(--fs-sm); font-weight: 600; margin-bottom: 2px; }
.note-text { white-space: pre-line; }
.note-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger-text); }
.note-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 40%, transparent); color: var(--info-text); }
.note-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 40%, transparent); color: var(--warning-text); }
.note a { color: inherit; text-decoration: underline; }

/* pack card */
.pack-list { display: grid; gap: var(--space-4); min-width: 0; }
.pack-card { display: grid; gap: var(--space-3); min-width: 0; }
.pack-card > .note { margin: 0; }
.pack-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2) var(--space-3); flex-wrap: wrap; min-width: 0; }
.pack-head-text { min-width: 0; flex: 1 1 18rem; }
.pack-title { margin: 0 0 var(--space-1); font-size: var(--fs-lg); overflow-wrap: anywhere; }
.pack-title a { color: var(--text); }
.pack-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 0 var(--space-1); min-width: 0; overflow-wrap: anywhere; }
.pack-meta .icon { width: 14px; height: 14px; vertical-align: -0.15em; }
.pack-badges { display: flex; gap: var(--space-1); flex-wrap: wrap; flex: none; max-width: 100%; }
.pack-badges .icon { width: 12px; height: 12px; }
.pack-strip { padding-bottom: var(--space-1); max-width: 100%; }
.pack-thumb { display: inline-grid; place-items: center; flex: none; width: 6rem; height: 6rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); overflow: hidden; }
.pack-thumb img { width: 100%; height: 100%; max-width: none; object-fit: cover; display: block; border: 0; border-radius: 0; }
.pack-thumb:hover { border-color: var(--accent); text-decoration: none; }
.pack-thumb-icon .icon { width: 28px; height: 28px; }
.pack-thumb-more { font-weight: 700; font-size: var(--fs-lg); color: var(--text); }
.pack-marks { margin: 0; display: flex; gap: var(--space-1); flex-wrap: wrap; }
.pack-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2) var(--space-3); flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: var(--space-3); }
.pack-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.pack-actions form { margin: 0; }
.pack-actions .btn .icon, .reject-details > summary .icon { width: 16px; height: 16px; }
.reject-details { flex: 1 1 100%; min-width: 0; }
.reject-details > summary { list-style: none; display: inline-flex; }
.reject-details > summary::-webkit-details-marker { display: none; }
.reject-details[open] > summary { margin-bottom: var(--space-3); }
.reject-details form.stack { max-width: 36rem; }
.approve-blockers { margin: 0; }

/* step bar */
.steps { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: flex; gap: var(--space-2); flex-wrap: wrap; counter-reset: step; }
.step { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1); border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; }
.step-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 700; flex: none; }
.step-mark .icon { width: 14px; height: 14px; }
.step.is-done { color: var(--text); }
.step.is-done .step-mark { background: var(--success-soft); color: var(--success-text); }
.step.is-current { color: var(--text); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.step.is-current .step-mark { background: var(--accent); color: var(--accent-contrast); }
.step.is-danger { border-color: var(--danger); background: var(--danger-soft); color: var(--danger-text); }
.step.is-danger .step-mark { background: var(--danger); color: #ffffff; }

/* funnel page */
.funnel-head { align-items: flex-start; }
.funnel-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1); overflow-wrap: anywhere; }
.funnel-title .badge .icon { width: 12px; height: 12px; }
.funnel-meta-line { margin: 0; overflow-wrap: anywhere; }
.funnel-blockers { margin-bottom: var(--space-4); }
.funnel-blockers ul { margin-top: var(--space-1); }
.funnel-sections { display: grid; gap: var(--space-4); min-width: 0; }
.funnel-section { min-width: 0; }
.funnel-section > .section-head { margin-bottom: var(--space-3); }
.funnel-section > .section-head h3 { margin: 0; }
.funnel-section > .section-head h3 .icon { color: var(--accent); }
.edit-block { margin-top: var(--space-3); }
.edit-block > summary { font-size: var(--fs-md); }
.edit-block form.stack { max-width: 36rem; }
.lander-form { margin-bottom: 0; }
.composition-row { display: grid; gap: var(--space-2); padding: var(--space-3) 0; border-top: 1px solid var(--border); min-width: 0; }
.composition-row:first-of-type { border-top: 0; padding-top: 0; }
.composition-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.composition-head a.muted { margin-left: auto; }
.composition-row .preview-strip { padding-bottom: 0; }
.text-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); font-size: var(--fs-sm); }
.text-list li { display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; min-width: 0; }
.text-preview { flex: 1 1 14rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reason-list { margin: 0 0 var(--space-3); padding-left: 1.2em; font-size: var(--fs-sm); }
.channel-panel { display: grid; gap: var(--space-3); min-width: 0; }
.channel-head { margin: 0; }
.channel-head h4 { margin: 0; }
.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.channel-block { background: var(--surface-2); min-width: 0; }
.channel-block h5 { margin: 0 0 var(--space-3); display: flex; align-items: center; gap: var(--space-2); }
.channel-block h5 .icon { width: 16px; height: 16px; color: var(--accent); }
.channel-block h5 .muted { font-weight: 400; }
.channel-block form.stack { max-width: 36rem; }
.channel-block .table-wrap { background: var(--surface); }
.channel-block .table-wrap .pack-thumb { width: 3.5rem; height: 3.5rem; }
.text-items .text-item { display: grid; gap: var(--space-2); padding: var(--space-3) 0; border-top: 1px solid var(--border); min-width: 0; }
.text-items .text-item:first-child { border-top: 0; padding-top: 0; }
.text-item-head { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.text-item p { margin: 0; overflow-wrap: anywhere; }
.text-edit { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); align-items: start; }
.text-edit textarea { width: 100%; max-width: none; }
.review-actions { margin-bottom: var(--space-3); align-items: center; }
.review-actions .reject-details { flex: 1 1 100%; }
.comments { border-top: 1px solid var(--border); padding-top: var(--space-3); margin-top: var(--space-3); }
.comments h4 { margin-top: 0; }
.comment-list { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: grid; gap: var(--space-2); }
.comment-list li { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--surface-2); min-width: 0; }
.comment-list li p { margin: var(--space-1) 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.comment-form { max-width: 36rem; }
.form-card { max-width: 40rem; }
.form-card form.stack { max-width: none; }
.funnels-table td { vertical-align: middle; }

@media (max-width: 900px) {
  .channel-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .pack-thumb { width: 4.5rem; height: 4.5rem; }
  .pack-foot .pack-actions, .pack-actions .btn, .pack-actions form { flex: 1 1 auto; }
  .pack-actions .btn { justify-content: center; }
  .step { font-size: var(--fs-xs); padding-right: var(--space-2); }
  .steps { gap: var(--space-1); }
  .text-edit { grid-template-columns: minmax(0, 1fr); }
  .table-cards td.col-thumb, .table-cards td.col-actions { width: auto; }
  .table-cards td[data-label=""]::before { content: none; }
  .table-cards td[data-label=""] { grid-template-columns: 1fr; }
  /* .table-cards fix found at 390 px: the table kept its table layout (min-content width) and a
     long <code> name pushed the rows past the card — block layout + wrapping keep it inside. */
  .table-cards, .table-cards tbody { display: block; width: 100%; min-width: 0; }
  .table-cards td { min-width: 0; overflow-wrap: anywhere; }
  .table-cards td code { white-space: normal; overflow-wrap: anywhere; }
  .table-cards td > * { min-width: 0; max-width: 100%; }
  /* toolbar forms inside section cards (lander / attach): the select shrinks, never the page */
  .funnel-section .actions > form.toolbar, .funnel-section .actions > form { flex: 1 1 100%; min-width: 0; max-width: 100%; }
  .funnel-section .toolbar label { max-width: 100%; min-width: 0; flex: 1 1 100%; }
  .funnel-section .toolbar select { flex: 1 1 8rem; min-width: 0; max-width: 100%; }
  .funnel-section .toolbar input[type="text"] { flex: 1 1 8rem; min-width: 0; max-width: 100%; }
}
@media (max-width: 480px) {
  .table-cards td { grid-template-columns: 6rem 1fr; }
}

/* ==== V8-a: ideas, landers, knowledge ==== */
/* lander page: chat + versions on the left, sticky live preview on the right (one column ≤ 1100px) */
/* `minmax(0, 1fr)` (V13): the implicit `auto` track took the min-content width of the versions
   table, so the left column grew under the sticky preview at 1280 px — now the table scrolls in
   its wrap instead. */
.lander-left { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-content: start; }
.lander-preview { position: sticky; top: calc(var(--topbar-h) + var(--space-3)); align-self: start; }
@media (max-width: 1100px) {
  .lander-layout { grid-template-columns: minmax(0, 1fr); }
  .lander-preview { position: static; }
}
.preview-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #ffffff;
  margin: var(--space-3) auto 0;
  max-width: 100%;
}
.preview-frame iframe { display: block; width: 100%; max-width: 100%; height: 70vh; border: 0; }
#preview-mobile:checked ~ .preview-frame { max-width: min(390px, 100%); }
#preview-mobile:checked ~ .section-head [for="preview-mobile"],
#preview-desktop:checked ~ .section-head [for="preview-desktop"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.preview-tabs { border-bottom: 0; }
/* chat with the model */
.chat-thread { list-style: none; padding: 0; margin: 0 0 var(--space-4); display: grid; gap: var(--space-2); min-width: 0; }
.chat-thread > li { min-width: 0; }
.chat-msg {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  max-width: 92%;
  min-width: 0;
  overflow-wrap: anywhere;
}
/* long unbroken strings (``<img src="/l-media/...">`` pasted into the chat) must wrap, not scroll */
.chat-msg code, .chat-msg pre, .chat-msg .excerpt { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; max-width: 100%; }
.chat-msg-user { justify-self: end; background: var(--accent-soft); }
.chat-msg-assistant { justify-self: start; }
.chat-msg-system { justify-self: center; color: var(--text-muted); font-size: var(--fs-sm); }
.chat-msg-meta { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-1); }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg-pending { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; }
.chat-msg-error { margin: 0; }
/* row menus inside tables must not be clipped by the scrolling wrapper */
.table-wrap:has(details.menu[open]) { overflow: visible; }
.idea-title { min-width: 16rem; }
/* knowledge */
.knowledge-card { display: block; color: var(--text); }
.knowledge-card:hover { border-color: var(--accent); text-decoration: none; }
.knowledge-card h3 { margin: 0 0 var(--space-2); font-size: var(--fs-lg); }
.knowledge-toc ol { margin: 0; padding-left: 1.5rem; }
.knowledge-toc .toc-level-3 { margin-left: 1rem; font-size: var(--fs-sm); }
.digest-item h4 { margin: 0 0 var(--space-2); }
.page-head h2 .icon { width: 22px; height: 22px; vertical-align: -0.25em; margin-right: var(--space-1); }

/* ---- «Склейка и формат» (W2, D-105) ------------------------------------------------------------ */
form.stack.media-form { max-width: none; } /* beats form.stack's 28rem: the clip table needs the card width */
.clip-table .input-sm { width: 6rem; }
.clip-title { display: inline-block; max-width: 24rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.placement-list { display: grid; gap: var(--space-2); }
.placement { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2); align-items: start; }
.placement-text { display: grid; gap: 2px; }
.placement-text .badge { margin-left: var(--space-1); }
#focus .range-row { display: grid; grid-template-columns: 9rem minmax(0, 1fr) 4rem; gap: var(--space-2); align-items: center; }
#results-table .badge { white-space: normal; text-align: left; }

/* ---- «Тексты объявлений» (W4, D-107) ---------------------------------------------------------- */
.ad-kind { margin-top: var(--space-3); }
.ad-kind h4 { margin: 0 0 var(--space-2); display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; }
.ad-kind-limit { font-weight: 400; }
.ad-variants { display: grid; gap: var(--space-2); padding: 0; margin: 0; list-style: none; }
.ad-variant { display: grid; gap: var(--space-1); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.ad-variant-head { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.ad-variant-pick { display: inline-flex; gap: var(--space-1); align-items: center; font-size: var(--fs-sm); }
.ad-variant-text { max-width: none; min-height: 2.4rem; }
.char-counter { margin-left: auto; font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.char-counter.over-limit { color: var(--danger-text); font-weight: 600; }
textarea.over-limit { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.ad-variant.is-over-limit { border-color: var(--danger); }
.ad-to-funnel { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; margin-top: var(--space-3); }
.ad-to-funnel label { max-width: 100%; min-width: 0; } /* X8.3: a long funnel name in the select */
/* Q2: free-form request, attachments, request cards with 3 variant columns */
#ad-texts-request { min-height: 7rem; max-width: none; }
.ad-attach > summary { cursor: pointer; }
.ad-attach-body { display: grid; gap: var(--space-3); margin-top: var(--space-2); }
.ad-library-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--space-2); padding: 0; margin: 0; list-style: none; max-height: 18rem; overflow: auto; }
.ad-library-item label { display: grid; grid-template-columns: auto 3rem minmax(0, 1fr); gap: var(--space-2); align-items: center; padding: var(--space-1); border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; }
.ad-library-item label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ad-library-thumb { width: 3rem; height: 3rem; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.ad-library-thumb-icon { display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); }
.ad-library-body { display: grid; min-width: 0; font-size: var(--fs-sm); }
.ad-library-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-request { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.ad-request-head { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.ad-request-head time { margin-left: auto; }
.ad-request-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ad-request-raw pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.ad-variant-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); gap: var(--space-3); }
.ad-variant-grid > .ad-variant { min-width: 0; grid-template-columns: minmax(0, 1fr); } /* X8.3: the «Воронка» select never widens the card */
.ad-variant-head h4 { margin: 0; }
.ad-field { display: grid; gap: var(--space-1); }
.ad-field-head { display: flex; gap: var(--space-2); align-items: center; }
.ad-field-label { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ad-field-head .char-counter { margin-left: auto; }
.ad-field-text { margin: 0; padding: var(--space-1) var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ad-field-text.over-limit { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.ad-variant .ad-to-funnel { margin-top: var(--space-2); }

/* ---- «Надписи» (W3, D-106) ------------------------------------------------------------------- */
.caption-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem); gap: var(--space-4); align-items: start; }
.caption-preview { position: sticky; top: var(--space-3); display: grid; gap: var(--space-2); }
.caption-preview-frame { display: flex; justify-content: center; align-items: center; min-height: 12rem; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.caption-preview-frame img { max-width: 100%; max-height: 70vh; width: auto; height: auto; border-radius: var(--radius-sm); }
.caption-preview-frame img[hidden] { display: none; }
.caption-preview-frame.is-loading img { opacity: 0.6; }
#caption-preview-error:empty { display: none; }
.caption-form textarea { min-height: 7rem; font-family: var(--font-mono, ui-monospace, monospace); font-size: var(--fs-sm); }
.caption-form .range-row { display: grid; grid-template-columns: 9rem minmax(0, 1fr) 4rem; gap: var(--space-2); align-items: center; }
.caption-form label > .muted { font-size: var(--fs-xs); }
@media (max-width: 60rem) { .caption-layout { grid-template-columns: minmax(0, 1fr); } .caption-preview { position: static; } }

/* ---- «Варианты» (W5, D-108) ------------------------------------------------------------------ */
.variants-hint { padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-md); background: var(--surface); }
.axis-list { display: grid; gap: var(--space-3); }
.axis { margin: 0; }
.axis[hidden] { display: none; }
.axis legend { display: inline-flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.axis legend > label { display: inline-flex; align-items: center; gap: var(--space-1); } /* beats the grid rule for form labels: checkbox + text on one line */
.axis legend .badge { font-weight: 400; }
.axis-body { display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.axis-body textarea { min-height: 6rem; font-size: var(--fs-sm); }
.axis-body .range-row { display: grid; grid-template-columns: 9rem minmax(0, 1fr) 4rem; gap: var(--space-2); align-items: center; }
.axis-count { font-size: var(--fs-xs); color: var(--text-muted); }
.variant-outcome .badge { white-space: normal; text-align: left; }
.variant-value { max-width: 28rem; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- upload zone (P4, v0.4) */
/* templates/partials/_upload_zone.html + static/upload_zone.js: one drag-and-drop component for
   every file upload. The real <input type="file"> stays in the DOM (visually hidden, focusable
   for scripts; the zone is the keyboard stop). Tokens only, so both themes work. */
.upload-zone {
  position: relative;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.upload-zone:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.upload-zone:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--accent); }
.upload-zone.is-dragover { border-color: var(--accent); border-style: solid; background: var(--accent-soft); color: var(--text); }
.upload-zone.has-error { border-color: var(--danger); }
.upload-zone.is-uploading { cursor: progress; }
.upload-zone-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; opacity: 0; }
.upload-zone-body { display: grid; gap: var(--space-1); justify-items: center; text-align: center; }
.upload-zone-icon { width: 28px; height: 28px; color: var(--accent); }
.upload-zone-text { margin: 0; font-size: var(--fs-sm); color: var(--text); }
.upload-zone-text .btn { vertical-align: baseline; }
.upload-zone-label { font-weight: 600; }
.upload-zone-hint { margin: 0; font-size: var(--fs-xs); }
.upload-zone-files { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); cursor: default; }
.upload-zone-files:empty { display: none; }
.upload-zone-file { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: var(--fs-sm); min-width: 0; }
.upload-zone-file-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-zone-file-size { flex: 0 0 auto; color: var(--text-muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.upload-zone-file-field { flex: 0 0 auto; max-width: 10rem; font-size: var(--fs-sm); padding: 0 var(--space-1); min-height: 1.75rem; }
.upload-zone-remove { flex: 0 0 auto; padding: 0 var(--space-2); line-height: 1.4; font-size: var(--fs-md); }
.upload-zone-progress { width: 100%; height: 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.upload-zone-progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 3px; }
.upload-zone-progress::-webkit-progress-value { background: var(--accent); border-radius: 3px; transition: width 0.1s linear; }
.upload-zone-progress::-moz-progress-bar { background: var(--accent); border-radius: 3px; }
.upload-zone-progress:indeterminate::-webkit-progress-bar { background: linear-gradient(90deg, var(--surface-2), var(--accent-soft), var(--surface-2)); }
.upload-zone-progress:indeterminate::-moz-progress-bar { background: var(--accent-soft); }
.upload-zone-error { margin: 0; font-size: var(--fs-sm); color: var(--danger-text); }
.upload-zone-error:empty { display: none; }
/* compact variant (the «Замечание» dialog): one row, smaller padding */
.upload-zone--compact { padding: var(--space-2) var(--space-3); gap: var(--space-1); }
.upload-zone--compact .upload-zone-body { grid-template-columns: auto 1fr; justify-items: start; text-align: left; column-gap: var(--space-2); }
.upload-zone--compact .upload-zone-icon { width: 20px; height: 20px; grid-row: span 2; align-self: center; }
.upload-zone--compact .upload-zone-text { font-size: var(--fs-xs); }
.upload-zone--compact .upload-zone-hint { grid-column: 2; }
/* managed zone (creatives lab): previews and counters live in the page's own ref list */
.lab-panel .upload-zone { padding: var(--space-3); }
form.stack .upload-zone, .form-stack .upload-zone { max-width: 100%; }

/* ==== Lab: placement fit hint (Q5) ==== (/photo, /video — `creatives/_fit_hint.html` under the
   «Формат» row: what the placement recommends vs what the model gives; the fallback sentence
   with the «Приведение к формату» link is highlighted. `#prompt-chat-hint` is the one-line
   pointer under the prompt field to «Генерация промпта».) */
.fit-hint { margin: var(--space-1) 0 0; font-size: var(--fs-sm); line-height: 1.4; }
.fit-hint[hidden] { display: none; }
.fit-hint-fallback { color: var(--warning-text, var(--text)); }
.fit-hint-fallback a { color: inherit; text-decoration: underline; }
.field-hint { margin: var(--space-1) 0 0; font-size: var(--fs-sm); }
#placement-field select[disabled] { opacity: 0.7; }

/* v0.4 part 2 screenshots: in a .field-grid the grid labels are stretched to the tallest cell
   (the «Плейсмент» label carries a hint line), and `form.stack label { display: grid }` then
   spreads that extra height over its rows — the «Канал» select on /ad-texts grew ~3x tall.
   Pack the rows at the top instead. */
.field-grid > label { align-content: start; }

/* T1: lander review — the «Вернуть» / «Опубликовать» disclosure forms on the card and in the queue. */
.publish-details { flex: 1 1 100%; min-width: 0; }
.publish-details > summary { list-style: none; display: inline-flex; }
.publish-details > summary::-webkit-details-marker { display: none; }
.publish-details[open] > summary { margin-bottom: var(--space-3); }
.publish-details form.stack { max-width: 36rem; }
.lander-review-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-start; width: 100%; }
/* Closed disclosures sit in one row with «Одобрить»; an opened one takes the full row for its form. */
.lander-review-actions > details:not([open]) { flex: 0 0 auto; }
/* T6 report mapping: a two-line label in one column must not stretch the select next to it. */
#report-mapping-form .grid > label { align-content: start; }
.status-history { margin: 0; padding-left: 1.2rem; display: grid; gap: var(--space-1); }
.lander-queue { display: grid; gap: var(--space-3); }
.lander-queue-card .preview-frame { margin-top: var(--space-2); }

/* ---------------------------------------------------------------- Library hub (T3): tabs, lander / character cards */
.tabs-sub { margin-top: 0; border-bottom: 0; gap: var(--space-3); }
.tabs-sub a { font-size: var(--fs-sm); }
.lander-card .lander-thumb { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; color: var(--text-muted); }
.lander-thumb-placeholder { display: grid; place-items: center; align-content: center; gap: var(--space-1); height: 100%; padding: var(--space-3); text-align: center; }
.lander-thumb-placeholder .icon { width: 36px; height: 36px; }
.lander-thumb-name { font-size: var(--fs-sm); font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.lander-card .media-card-badges { pointer-events: none; }
.lander-address, .lander-leads { display: flex; align-items: center; gap: var(--space-1); white-space: normal; overflow-wrap: anywhere; }
.lander-address .icon, .lander-leads .icon { width: 14px; height: 14px; flex: none; color: var(--text-muted); }
.media-card-actions { padding: var(--space-2) var(--space-3) 0; margin: 0; }
.char-counts { margin: 0; font-size: var(--fs-sm); }
.char-card .media-card-actions { padding: 0; }

/* ---------------------------------------------------------------- Library picker (T3): component + dialog */
.library-picker { display: grid; gap: var(--space-2); min-width: 0; }
.lp-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.lp-chips:empty, .lp-chips:not(:has(.lp-chip)) { display: none; }
.lp-chip { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2) 2px 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: var(--fs-sm); max-width: 100%; min-width: 0; }
.lp-chip:not(:has(.lp-chip-thumb)) { padding-left: var(--space-2); }
.lp-chip-thumb { width: 24px; height: 24px; object-fit: cover; border-radius: 50%; flex: none; }
.lp-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-chip-remove { border: 0; background: transparent; cursor: pointer; color: var(--text-muted); padding: 0 2px; line-height: 1; font-size: var(--fs-md); display: inline-grid; place-items: center; }
.lp-chip-remove .icon { width: 14px; height: 14px; }
.lp-chip-remove:hover { color: var(--danger-text); }
.lp-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.lp-dialog { width: min(56rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg, 0 12px 40px rgba(0, 0, 0, 0.35)); }
.lp-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.lp-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.lp-dialog-title { margin: 0; font-size: var(--fs-lg); font-weight: 600; }
.lp-dialog-body { padding: var(--space-3) var(--space-4) var(--space-4); max-height: calc(100vh - 8rem); overflow: auto; }
.lp { display: grid; gap: var(--space-3); }
.lp-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: 0; }
.lp-filters input, .lp-filters select { width: auto; }
.lp-search input[type="search"] { width: 16rem; max-width: 100%; }
.lp-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--space-2); }
.lp-item label { display: grid; grid-template-columns: auto 3rem minmax(0, 1fr); gap: var(--space-2); align-items: center; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; background: var(--surface-2); }
.lp-item label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.lp-item.is-disabled label { cursor: not-allowed; opacity: 0.6; }
.lp-item input { margin: 0; }
.lp-thumb { width: 3rem; height: 3rem; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); display: block; }
.lp-thumb-icon { display: inline-grid; place-items: center; color: var(--text-muted); }
.lp-item-body { display: grid; gap: 2px; min-width: 0; font-size: var(--fs-sm); }
.lp-item-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-item-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); }
.lp-item-status { display: flex; gap: var(--space-1); align-items: center; flex-wrap: wrap; font-size: var(--fs-xs); }
.lp-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding-top: var(--space-2); border-top: 1px solid var(--border); }
.lp-foot-actions { display: flex; gap: var(--space-2); }
.lp-message { margin: 0; }
.lp-empty, .lp-loading { margin: 0; }

/* ==== Launch-template cards (T5 v0.4 part 3) ==== */
.launch-blocks { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.launch-block { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); background: var(--surface); min-width: 0; }
.launch-block .section-head { margin-bottom: var(--space-1); }
.launch-block h4 { margin: 0; font-size: var(--fs-sm); }
.launch-block-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; min-height: 1.5em; }
.launch-block.is-empty .launch-block-text { display: none; }
.launch-card-head { margin: 0 0 var(--space-2); }
.interest-group { border: 1px dashed var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-2); }
.interest-group .toolbar .grow { flex: 1 1 auto; }
button[data-copied] { color: var(--success, inherit); }
.lander-address { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.lander-address code { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- R8: reference previews */
/* static/ref_preview.js + partials/_ref_preview.html: picture / video frame (play mark +
   duration) / small audio player; image and video open the viewer (R9). */
.ref-preview { position: relative; display: block; width: 40px; height: 40px; flex: none; overflow: hidden; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: zoom-in; }
.ref-preview:focus-visible { outline: none; box-shadow: var(--focus); }
.ref-preview img, .ref-preview video { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.ref-preview-play, .media-thumb-play { position: absolute; inset: 0; display: grid; place-items: center; color: #ffffff; pointer-events: none; }
.ref-preview-play .icon { width: 16px; height: 16px; filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8)); }
.ref-preview-duration, .media-thumb-duration { position: absolute; right: 2px; bottom: 2px; padding: 0 3px; border-radius: 4px; background: rgba(0, 0, 0, 0.7); color: #ffffff; font-size: 10px; line-height: 1.4; font-variant-numeric: tabular-nums; pointer-events: none; }
.ref-preview-duration:empty, .media-thumb-duration:empty { display: none; }
/* 40–48 px thumbnails: the play mark sits in the top-left corner so it never covers the
   duration badge; the 6rem upload preview keeps it centred. */
.ref-preview--video .ref-preview-play { place-items: start; padding: 3px; }
.ref-preview--video .ref-preview-play .icon { width: 12px; height: 12px; }
.upload-preview .ref-preview--video .ref-preview-play { place-items: center; padding: 0; }
.upload-preview .ref-preview--video .ref-preview-play .icon { width: 16px; height: 16px; }
.ref-preview--audio { cursor: default; display: inline-flex; align-items: center; gap: var(--space-1); width: auto; height: auto; min-height: 40px; overflow: visible; border: 0; background: transparent; }
.ref-preview-audio-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.ref-preview--audio audio { height: 32px; width: 12rem; max-width: 100%; }
/* in a lab reference row the player takes its own line under the row */
.ref-item .ref-preview--audio { display: contents; }
.ref-item .ref-preview--audio audio { grid-column: 1 / -1; order: 1; width: 100%; }
/* Library picker chips with a preview: a rounded square instead of the round dot */
.lp-chip.has-preview { padding: 2px var(--space-2) 2px 2px; border-radius: var(--radius-md); }
.lp-chip.has-preview .ref-preview { width: 40px; height: 40px; }
/* upload zone files with a preview (data-preview="1") */
.upload-zone-file.has-preview { padding-left: var(--space-1); }
.upload-zone-file .ref-preview { width: 48px; height: 48px; }
.upload-preview .ref-preview { width: 100%; height: 100%; border: 0; border-radius: 0; }

/* ---------------------------------------------------------------- R9: clickable media */
.media-thumb { position: relative; display: block; cursor: zoom-in; color: inherit; }
.media-thumb:focus-visible { outline: none; box-shadow: var(--focus); }
.media-thumb-play .icon { width: 36px; height: 36px; filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.8)); }
.media-thumb-duration { right: var(--space-2); bottom: var(--space-2); padding: 1px 6px; font-size: var(--fs-xs); }
.result-open { display: block; }
.result-open video { pointer-events: none; }
.queue-creative { min-width: 10rem; }
.queue-thumb { display: inline-block; width: 48px; height: 48px; margin-right: var(--space-2); vertical-align: middle; overflow: hidden; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.queue-thumb img, .queue-thumb video { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.queue-thumb .media-thumb-play .icon { width: 16px; height: 16px; }
.queue-thumb .media-thumb-duration { right: 2px; bottom: 2px; padding: 0 3px; font-size: 10px; }

/* the viewer (static/viewer.js): one native <dialog> over the page */
html.viewer-open { overflow: hidden; }
.viewer { width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0; background: transparent; color: #ffffff; display: none; }
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer::backdrop { background: rgba(5, 6, 12, 0.94); }
.viewer-head, .viewer-foot { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); min-width: 0; }
.viewer-foot { justify-content: center; flex-wrap: wrap; }
.viewer-title { margin: 0; flex: 1 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-counter { color: rgba(255, 255, 255, 0.75); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.viewer-stage { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); padding: 0 var(--space-3); min-height: 0; }
.viewer-media { display: grid; place-items: center; height: 100%; min-height: 0; min-width: 0; }
.viewer-image, .viewer-video { display: block; max-width: 100%; max-height: calc(100dvh - 9rem); object-fit: contain; border-radius: var(--radius-sm); background: #000000; }
.viewer .btn { color: var(--text); }
.viewer .viewer-close { color: #ffffff; }
.viewer .viewer-close:hover { background: rgba(255, 255, 255, 0.12); }
.viewer-nav { width: 44px; height: 44px; border-radius: 50%; }
.viewer-nav[hidden] { display: none; }
.viewer-status { color: rgba(255, 255, 255, 0.85); min-width: 8rem; }
.viewer-download[hidden], .viewer-copy[hidden] { display: none; }
@media (max-width: 599px) {
  .viewer-stage { padding: 0 var(--space-1); gap: var(--space-1); }
  .viewer-nav { width: 36px; height: 36px; }
}

/* ---------------------------------------------------------------- R10: keyboard hints */
.hotkey-hint { font-size: var(--fs-xs); }
.hotkey-hint kbd, kbd.kbd { display: inline-block; padding: 0 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); color: var(--text); font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.5; }
.lab-actions .hotkey-hint { justify-self: start; margin-top: calc(-1 * var(--space-2)); }
.upload-progress { width: 100%; height: 6px; }
.upload-progress[hidden] { display: none; }

/* ---------------------------------------------------------------- D-193: prompt length policy */
.prompt-limit { display: grid; gap: 0; }
.prompt-limit .field-hint { margin-top: var(--space-1); }
.prompt-counter { font-variant-numeric: tabular-nums; }
.prompt-counter.is-over { color: var(--warning-text); }
.prompt-length-error[hidden], .prompt-words-hint[hidden] { display: none; }
.prompt-confirm-dialog {
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  margin: auto;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.prompt-confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.prompt-confirm-question { margin: 0 0 var(--space-2); font-size: var(--fs-lg); font-weight: 600; }
.prompt-confirm-detail { margin: 0 0 var(--space-4); font-size: var(--fs-sm); }
.prompt-confirm-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }

/* ---------------------------------------------------------------- X1 / X2: frame and audio */
.viewer-frame[hidden], .viewer-audio[hidden] { display: none; }
.viewer-status a { color: inherit; text-decoration: underline; }
.frame-tool {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
}
.frame-tool::backdrop { background: rgba(0, 0, 0, 0.6); }
.frame-tool[open] { display: grid; gap: var(--space-3); }
.frame-tool-head { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.frame-tool-title { margin: 0; flex: 1 1 auto; min-width: 0; font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame-tool-video { display: block; width: 100%; max-height: calc(100dvh - 18rem); background: #000000; border-radius: var(--radius-sm); object-fit: contain; }
.frame-tool-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-2); }
.frame-tool-range { width: 100%; min-width: 0; }
.frame-tool-time, .frame-tool-total { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: var(--fs-sm); }
.frame-tool-hint { margin: 0; font-size: var(--fs-sm); }
.frame-tool-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.frame-tool-status { margin: 0; min-height: 1.4em; font-size: var(--fs-sm); }
.media-thumb--audio { display: grid; place-items: center; align-content: center; gap: var(--space-3); width: 100%; height: 100%; padding: var(--space-3); cursor: default; }
.media-thumb-audio-icon .icon { width: 40px; height: 40px; color: var(--text-muted, currentColor); }
.media-audio { width: 100%; max-width: 100%; }
.media-card-preview .media-audio { height: 2.5rem; object-fit: initial; }
@media (max-width: 599px) {
  .frame-tool { padding: var(--space-3); }
  .frame-tool-controls { grid-template-columns: minmax(0, 1fr) auto; }
  .frame-tool-total { display: none; }
}
.spend-detail-total { margin: var(--space-3) 0; }
/* X7.2 «Убрать с экрана» (D-207): the cross on a result card, «Очистить ленту», the undo toast */
.result-hide { margin: 0; }
.result-hide-btn { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; padding: 0; border: 1px solid transparent; border-radius: var(--radius-md); background: transparent; color: var(--text-muted); cursor: pointer; }
.result-hide-btn:hover, .result-hide-btn:focus-visible { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.lab-results-head .clear-feed { margin: 0; }
/* X8.2 «Показать убранные» (D-210): the toggle, «Вернуть всё», a hidden card dimmed with «Вернуть» */
.lab-results-head .unhide-all, .result-unhide { margin: 0; }
.feed-hidden-toggle.is-on { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.result-card.is-feed-hidden { border-style: dashed; }
.result-card.is-feed-hidden > :not(.result-head) { opacity: .5; }
.result-card.is-feed-hidden .result-head > :not(.result-unhide):not(.result-hidden-mark) { opacity: .5; }
.toast { position: fixed; left: 50%; bottom: var(--space-5); transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); max-width: calc(100vw - 32px); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
