/* ==========================================================================
   AI Workspace — дизайн-система. Описание классов и правила — docs/DESIGN.md,
   живая витрина — /styleguide. Экранные стили — aiw/static/css/<экран>.css.

   0. Шрифты        4. Каркас (сайдбар, панель, шапка страницы)
   1. Токены         5. Компоненты
   2. База           6. Наследие (классы прежних экранов)
   3. Утилиты        7. Анимации, переходы, reduced motion
   ========================================================================== */

/* ---------------------------------------------------------------- 0. Шрифты
   Inter и JetBrains Mono (SIL OFL 1.1, лицензии в static/fonts/), переменные по
   насыщенности, подмножества latin + cyrillic. Никаких внешних адресов. */
@font-face {
  font-family: "Inter AIW"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-latin-wght.woff2") format("woff2-variations"), url("fonts/inter-latin-wght.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter AIW"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-cyrillic-wght.woff2") format("woff2-variations"), url("fonts/inter-cyrillic-wght.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JetBrains Mono AIW"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("fonts/jetbrains-mono-latin-wght.woff2") format("woff2-variations"), url("fonts/jetbrains-mono-latin-wght.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono AIW"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("fonts/jetbrains-mono-cyrillic-wght.woff2") format("woff2-variations"), url("fonts/jetbrains-mono-cyrillic-wght.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ---------------------------------------------------------------- 1. Токены
   Тема — атрибут data-theme на <html> (light | dark), ставит инлайн-скрипт в <head>
   до первой отрисовки: выбор из localStorage `aiw-theme` (light | dark | system). */
:root {
  color-scheme: light;

  /* поверхности */
  --shell: #f3f3f6;            /* фон приложения за панелью (сайдбар лежит на нём) */
  --bg: #ffffff;               /* панель содержимого */
  --surface: #ffffff;          /* карточки, таблицы, поля */
  --surface-2: #f5f5f8;        /* наведение, вставки, фон второстепенного */
  --surface-3: #ececf1;        /* нажатие, выделенное, блик скелетона */
  --surface-raised: #ffffff;   /* меню, диалоги, тосты */
  --overlay: rgb(14 14 28 / 0.42);

  /* линии */
  --border-subtle: #efeff3;
  --border: #e5e5eb;
  --border-strong: #d6d6de;
  --border-stronger: #bdbdc8;

  /* текст (AA на --bg и --surface; --text-4 — только подсказки в полях и отключённое) */
  --text: #17171c;
  --text-2: #4b4b55;
  --text-3: #6b6b76;
  --text-4: #8f8f9a;

  /* фирменный акцент «ирис» */
  --accent: #4f55e0;
  --accent-hover: #454bd4;
  --accent-press: #3d42c2;
  --accent-fg: #ffffff;
  --accent-text: #4349d4;
  --accent-soft: #eef0fe;
  --accent-soft-2: #e0e3fd;
  --accent-border: #c9cdfa;
  --accent-ring: rgb(79 85 224 / 0.18);
  --focus: #5b61e6;

  /* смысловые цвета: text — надписи, solid — точки и заливки, soft — фон, border — рамка */
  --ok-text: #137a3f;   --ok: #1f9d55;   --ok-soft: #eaf7ef;   --ok-border: #c5ebd3;
  --warn-text: #965800; --warn: #d98a00; --warn-soft: #fff5e3; --warn-border: #f3d9a4;
  --bad-text: #c0262d;  --bad: #dc3a3a;  --bad-soft: #fdeeee;  --bad-border: #f6c9c9;
  --info-text: #1f5fc0; --info: #2f7bea; --info-soft: #ebf3fe; --info-border: #c7dcfa;
  --neutral-text: #4b4b55; --neutral: #9a9aa6; --neutral-soft: #f1f1f5; --neutral-border: #e2e2e8;

  /* типографика */
  --font-sans: "Inter AIW", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono AIW", "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 38px;
  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-normal: 1.55;
  --weight-regular: 420;
  --weight-medium: 520;
  --weight-semibold: 600;
  --tracking-tight: -0.015em;
  --tracking-tighter: -0.025em;

  /* отступы — сетка 4px */
  --space-0-5: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* радиусы */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  /* высоты элементов управления */
  --control-xs: 24px;
  --control-sm: 30px;
  --control-md: 36px;
  --control-lg: 44px;

  /* возвышения */
  --shadow-xs: 0 1px 2px rgb(18 18 40 / 0.05);
  --shadow-sm: 0 1px 2px rgb(18 18 40 / 0.06), 0 1px 3px rgb(18 18 40 / 0.06);
  --shadow-md: 0 4px 12px -2px rgb(18 18 40 / 0.08), 0 2px 4px -2px rgb(18 18 40 / 0.06);
  --shadow-lg: 0 12px 32px -8px rgb(18 18 40 / 0.16), 0 4px 10px -4px rgb(18 18 40 / 0.08);
  --shadow-xl: 0 28px 64px -16px rgb(18 18 40 / 0.30), 0 10px 20px -10px rgb(18 18 40 / 0.14);
  --shadow-inset: inset 0 1px 2px rgb(18 18 40 / 0.05);

  /* слои */
  --z-base: 0;
  --z-sticky: 10;
  --z-topbar: 20;
  --z-sidebar: 30;
  --z-dropdown: 40;
  --z-overlay: 50;
  --z-dialog: 60;
  --z-toast: 70;
  --z-tooltip: 80;

  /* движение */
  --dur-1: 120ms;
  --dur-2: 180ms;
  --dur-3: 240ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-emph: cubic-bezier(0.3, 1.3, 0.5, 1);

  /* каркас */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 52px;
  --container: 1120px;
  --container-narrow: 720px;
  --container-wide: 1600px;
  --gutter: var(--space-8);

  /* аватары: тон фона/текста от оттенка --h */
  --av-l-bg: 92%; --av-l-fg: 30%; --av-s-bg: 70%; --av-s-fg: 45%;

  /* прежние имена (экраны до дизайн-системы) */
  --card: var(--surface); --ink: var(--text); --muted: var(--text-3); --line: var(--border);
  --ok-bg: var(--ok-soft); --warn-bg: var(--warn-soft); --bad-bg: var(--bad-soft); --info-bg: var(--info-soft);
  --radius: var(--radius-lg);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --shell: #08080a;
  --bg: #0f0f12;
  --surface: #141418;
  --surface-2: #1b1b20;
  --surface-3: #25252c;
  --surface-raised: #1a1a1f;
  --overlay: rgb(0 0 0 / 0.62);

  --border-subtle: #1c1c22;
  --border: #25252c;
  --border-strong: #33333b;
  --border-stronger: #464650;

  --text: #ededf0;
  --text-2: #b6b6bf;
  --text-3: #8e8e99;
  --text-4: #696973;

  --accent: #5b61e6;
  --accent-hover: #6a70ee;
  --accent-press: #4d53d6;
  --accent-fg: #ffffff;
  --accent-text: #a3a7ff;
  --accent-soft: rgb(91 97 230 / 0.16);
  --accent-soft-2: rgb(91 97 230 / 0.26);
  --accent-border: rgb(124 130 255 / 0.38);
  --accent-ring: rgb(124 130 255 / 0.28);
  --focus: #8187ff;

  --ok-text: #5bd28a;   --ok: #2fb46b;   --ok-soft: rgb(47 180 107 / 0.14);  --ok-border: rgb(47 180 107 / 0.32);
  --warn-text: #f2b544; --warn: #e39b1b; --warn-soft: rgb(227 155 27 / 0.14); --warn-border: rgb(227 155 27 / 0.32);
  --bad-text: #ff8a8a;  --bad: #e5484d;  --bad-soft: rgb(229 72 77 / 0.15);   --bad-border: rgb(229 72 77 / 0.34);
  --info-text: #7cb1ff; --info: #3b82f6; --info-soft: rgb(59 130 246 / 0.15); --info-border: rgb(59 130 246 / 0.34);
  --neutral-text: #b6b6bf; --neutral: #6e6e7a; --neutral-soft: rgb(255 255 255 / 0.06); --neutral-border: rgb(255 255 255 / 0.1);

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4), 0 1px 3px rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 12px -2px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 0 0 1px rgb(255 255 255 / 0.04), 0 16px 36px -8px rgb(0 0 0 / 0.66), 0 4px 10px -4px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 0 0 1px rgb(255 255 255 / 0.05), 0 32px 72px -16px rgb(0 0 0 / 0.8), 0 10px 20px -10px rgb(0 0 0 / 0.6);
  --shadow-inset: inset 0 1px 2px rgb(0 0 0 / 0.3);

  --av-l-bg: 22%; --av-l-fg: 82%; --av-s-bg: 32%; --av-s-fg: 70%;

  /* светлый текст на тёмном кажется жирнее — чуть легче начертания */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 580;
}

/* ---------------------------------------------------------------- 2. База */
*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--shell);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--border-strong) transparent;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--shell);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  font-weight: var(--weight-regular);
  font-feature-settings: "cv05" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft-2); }

h1, h2, h3, h4 { color: var(--text); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
h1 { font-size: var(--text-2xl); line-height: var(--lh-tight); margin: var(--space-2) 0 var(--space-4); letter-spacing: var(--tracking-tighter); }
h2 { font-size: var(--text-md); line-height: var(--lh-snug); margin: var(--space-8) 0 var(--space-3); }
h3 { font-size: var(--text-base); line-height: var(--lh-snug); margin: var(--space-5) 0 var(--space-2); }
p { margin: 0 0 var(--space-3); }

a { color: var(--accent-text); text-decoration: none; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }

code, kbd, pre, samp, .mono { font-family: var(--font-mono); font-feature-settings: "calt" 0, "liga" 0; }
code { font-size: 0.88em; padding: 0.1em 0.38em; border-radius: var(--radius-xs); background: var(--surface-2); border: 1px solid var(--border-subtle); color: var(--text); }
pre { font-size: var(--text-sm); }
pre code { padding: 0; border: 0; background: none; }

img, svg { vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-6) 0; }
table { font-variant-numeric: tabular-nums; }
summary { cursor: pointer; }
[hidden] { display: none !important; }

:where(a, button, input, select, textarea, summary, [tabindex], .btn):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
:where(a, button, summary):focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: fixed; left: var(--space-3); top: var(--space-3); z-index: var(--z-tooltip);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  background: var(--surface-raised); color: var(--text); box-shadow: none;
  transform: translateY(-200%); transition: transform var(--dur-2) var(--ease-out);
}
.skip-link:focus { transform: none; box-shadow: var(--shadow-lg); }

/* ---------------------------------------------------------------- 3. Утилиты */
.muted, .text-3 { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.text-1 { color: var(--text); }
.small, .text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.strong { font-weight: var(--weight-semibold); }
.medium { font-weight: var(--weight-medium); }
.mono { font-size: 0.92em; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.hidden { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.hstack { display: flex; align-items: center; gap: var(--space-2); }
.vstack { display: flex; flex-direction: column; gap: var(--space-2); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.ml-auto { margin-left: auto; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); } .gap-6 { gap: var(--space-6); }
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); } .mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); }
.grid { display: grid; gap: var(--space-4); }
:is(.grid, .grid-2, .grid-3, .grid-auto) { margin-bottom: var(--space-4); }
:is(.grid, .grid-2, .grid-3, .grid-auto) > :is(.card, .empty-state) { margin-bottom: 0; }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-auto { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--space-4) 0; }
.eyebrow {
  font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3);
}
.section-title { font-size: var(--text-md); font-weight: var(--weight-semibold); margin: var(--space-8) 0 var(--space-3); }
.section-title:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- 4. Каркас */

/* Приложение: сайдбар + панель содержимого (на телефоне — верхняя полоса и выдвижное меню). */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
:root[data-sidebar="collapsed"] .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

.sidebar:focus { outline: none; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; z-index: var(--z-sidebar);
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-3) var(--space-3) var(--space-3);
  background: var(--shell);
  view-transition-name: aiw-sidebar;
}
.sidebar-head { display: flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-1) 0 var(--space-1); margin-bottom: var(--space-2); }
.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
  color: var(--text); text-decoration: none !important; border-radius: var(--radius-md);
}
.brand-mark { flex: none; display: block; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { font-weight: var(--weight-semibold); font-size: var(--text-base); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-org { font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-collapse { flex: none; color: var(--text-3); }

.sidebar .sidebar-new { justify-content: flex-start; margin: 0 0 var(--space-3); width: 100%; padding: 0 12px; }
.sidebar .sidebar-new kbd { margin-left: auto; }

.nav { display: flex; flex-direction: column; gap: 1px; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.nav-section {
  margin: var(--space-4) var(--space-2) var(--space-1); font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); white-space: nowrap;
}
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 var(--space-2) 0 10px; border-radius: var(--radius-md);
  color: var(--text-2); font-weight: var(--weight-medium); text-decoration: none !important; white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.nav-item .icon { width: 18px; height: 18px; color: var(--text-3); flex: none; transition: color var(--dur-1) var(--ease-out); }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item[aria-current="page"] {
  background: var(--bg); color: var(--text);
  box-shadow: var(--shadow-xs), 0 0 0 1px var(--border);
}
.nav-item[aria-current="page"] .icon { color: var(--accent-text); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full);
  display: inline-grid; place-items: center; font-size: var(--text-xs); font-weight: var(--weight-semibold);
  background: var(--accent); color: var(--accent-fg); font-variant-numeric: tabular-nums;
}
.sidebar-foot { margin-top: auto; padding-top: var(--space-2); }
.sidebar-foot > .menu { display: block; }
.sidebar-foot .menu-panel { width: 272px; }
.user-button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px var(--space-2) 6px 6px;
  border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); text-align: left;
  font: inherit; cursor: pointer; transition: background-color var(--dur-1) var(--ease-out);
}
.user-button:hover, .menu.is-open > .user-button { background: var(--surface-3); }
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.user-name { font-weight: var(--weight-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-button > .icon { color: var(--text-3); flex: none; }

/* свёрнутый сайдбар: только иконки, подписи — подсказками */
:root[data-sidebar="collapsed"] .sidebar { padding-left: 10px; padding-right: 10px; }
:root[data-sidebar="collapsed"] .sidebar-head { flex-direction: column; gap: var(--space-2); padding: 0; }
:root[data-sidebar="collapsed"] .brand { justify-content: center; flex: none; }
:root[data-sidebar="collapsed"] :is(.brand-text, .nav-label, .nav-section, .sidebar-new kbd, .sidebar-new .btn-label, .user-meta, .user-button > .icon) { display: none; }
:root[data-sidebar="collapsed"] .sidebar-collapse .icon { transform: scaleX(-1); }
:root[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 0; }
:root[data-sidebar="collapsed"] .nav-item .nav-count {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px;
}
:root[data-sidebar="collapsed"] .nav-section-gap { display: block; height: 1px; background: var(--border); margin: var(--space-3) var(--space-2); }
.nav-section-gap { display: none; }
:root[data-sidebar="collapsed"] .sidebar .sidebar-new { justify-content: center; padding: 0; width: var(--control-md); align-self: center; }
:root[data-sidebar="collapsed"] .user-button { justify-content: center; padding: 6px 0; }

/* панель содержимого */
.main {
  display: flow-root;   /* поля первого блока не «выпадают» за панель */
  min-width: 0; min-height: calc(100dvh - 16px);
  margin: var(--space-2) var(--space-2) var(--space-2) 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  view-transition-name: aiw-main;
}
.main-bare { display: flow-root; min-height: 100dvh; }
.container { max-width: calc(var(--container) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter) var(--space-16); }
.container-narrow { max-width: calc(var(--container-narrow) + 2 * var(--gutter)); }
.container-wide { max-width: calc(var(--container-wide) + 2 * var(--gutter)); }
.container-full { max-width: none; }
.container-bare { max-width: none; padding: 0; }
.container > :first-child:not(.page-header) { margin-top: var(--space-8); }

/* шапка страницы: заголовок + действия */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4) var(--space-6);
  flex-wrap: wrap; padding: var(--space-8) 0 var(--space-6);
}
.page-heading { min-width: 0; flex: 1 1 320px; }
.page-eyebrow { display: flex; align-items: center; gap: var(--space-1-5); margin-bottom: var(--space-2); font-size: var(--text-sm); color: var(--text-3); }
.page-eyebrow a { color: var(--text-3); }
.page-eyebrow a:hover { color: var(--text); text-decoration: none; }
.page-title { margin: 0; font-size: var(--text-2xl); line-height: var(--lh-tight); letter-spacing: var(--tracking-tighter); font-weight: var(--weight-semibold); }
.page-subtitle { margin: var(--space-1-5) 0 0; color: var(--text-3); font-size: var(--text-base); max-width: 72ch; }
.page-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* верхняя полоса — только телефон и узкие окна */
.topbar { display: none; }
.sidebar-scrim { display: none; }
.sidebar .sidebar-close { display: none; }

@media (max-width: 900px) {
  :root { --gutter: var(--space-4); }
  .app, :root[data-sidebar="collapsed"] .app { display: block; }
  .topbar {
    position: sticky; top: 0; z-index: var(--z-topbar);
    display: flex; align-items: center; gap: var(--space-2); height: var(--topbar-h);
    padding: 0 var(--space-2) 0 var(--space-2);
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand { flex: 1; justify-content: center; margin-right: var(--control-md); }
  .topbar .brand-text { align-items: center; }
  .topbar-new { flex: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100dvh;
    background: var(--bg); border-right: 1px solid var(--border); box-shadow: var(--shadow-xl);
    transform: translateX(-104%); visibility: hidden;
    transition: transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
    view-transition-name: none; padding: var(--space-3);
  }
  :root[data-sidebar="collapsed"] .sidebar { padding: var(--space-3); }
  :root[data-sidebar="collapsed"] :is(.brand-text, .nav-label, .nav-section, .sidebar-new kbd, .sidebar-new .btn-label, .user-meta, .user-button > .icon) { display: revert; }
  :root[data-sidebar="collapsed"] .brand-text, :root[data-sidebar="collapsed"] .user-meta { display: flex; }
  :root[data-sidebar="collapsed"] .nav-item { justify-content: flex-start; padding: 0 var(--space-2) 0 10px; }
  :root[data-sidebar="collapsed"] .nav-item .nav-count { position: static; min-width: 20px; height: 20px; font-size: var(--text-xs); }
  :root[data-sidebar="collapsed"] .nav-section-gap { display: none; }
  :root[data-sidebar="collapsed"] .sidebar-head { flex-direction: row; }
  :root[data-sidebar="collapsed"] .sidebar .sidebar-new { width: 100%; justify-content: flex-start; padding: 0 12px; align-self: stretch; }
  :root[data-sidebar="collapsed"] .user-button { justify-content: flex-start; padding: 6px var(--space-2) 6px 6px; }
  .sidebar .sidebar-collapse { display: none; }
  .sidebar .sidebar-close { display: inline-flex; }
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform var(--dur-3) var(--ease-out); }
  .sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1);
    background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity var(--dur-3) var(--ease-out);
  }
  body.nav-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .main { margin: 0; border: 0; border-radius: 0; box-shadow: none; min-height: calc(100dvh - var(--topbar-h)); }
  .page-header { padding: var(--space-6) 0 var(--space-5); align-items: flex-start; }
  .page-title { font-size: var(--text-xl); }
  .container > :first-child:not(.page-header) { margin-top: var(--space-6); }
}

/* ---------------------------------------------------------------- 5. Компоненты */

/* --- иконка: <svg class="icon"><use href=".../icons.svg#name"/></svg>, макрос ui.icon() */
.icon {
  width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -0.2em;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icon-xs { width: 12px; height: 12px; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 24px; height: 24px; stroke-width: 1.6; }

/* --- кнопки: .btn + вид (.btn-primary | .btn-secondary | .btn-ghost | .btn-danger | .btn-soft)
       + размер (.btn-xs | .btn-sm | .btn-lg) + .btn-icon (квадратная) + .is-loading */
.btn, :where(button, .button) {
  --btn-fg: var(--text);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-md); padding: 0 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--btn-fg);
  font: var(--weight-medium) var(--text-base)/1 var(--font-sans); letter-spacing: -0.005em;
  white-space: nowrap; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  text-decoration: none !important; box-shadow: var(--shadow-xs);
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out),
    opacity var(--dur-1) var(--ease-out);
}
.btn:hover, :where(button, .button):hover { background: var(--surface-2); border-color: var(--border-stronger); }
.btn:active, :where(button, .button):active { transform: translateY(0.5px) scale(0.985); background: var(--surface-3); }
.btn .icon { width: 16px; height: 16px; }
.btn-secondary { --btn-fg: var(--text); }

.btn-primary, :where(button.primary, .button.primary) {
  --btn-fg: var(--accent-fg);
  background: var(--accent); border-color: var(--accent-press);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18), 0 1px 2px rgb(30 32 120 / 0.24);
}
.btn-primary:hover, :where(button.primary, .button.primary):hover { background: var(--accent-hover); border-color: var(--accent-press); }
.btn-primary:active, :where(button.primary, .button.primary):active { background: var(--accent-press); }

.btn-soft { --btn-fg: var(--accent-text); background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.btn-soft:hover { background: var(--accent-soft-2); border-color: transparent; }
.btn-soft:active { background: var(--accent-soft-2); }

.btn-ghost { --btn-fg: var(--text-2); background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { --btn-fg: var(--text); background: var(--surface-2); border-color: transparent; }
.btn-ghost:active { background: var(--surface-3); }

.btn-danger, :where(button.danger) {
  --btn-fg: #fff; background: var(--bad); border-color: color-mix(in srgb, var(--bad) 80%, #000);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.16), 0 1px 2px rgb(120 20 20 / 0.2);
}
.btn-danger:hover, :where(button.danger):hover { background: color-mix(in srgb, var(--bad) 90%, #000); border-color: color-mix(in srgb, var(--bad) 75%, #000); }
.btn-danger-ghost { --btn-fg: var(--bad-text); background: transparent; border-color: transparent; box-shadow: none; }
.btn-danger-ghost:hover { background: var(--bad-soft); border-color: transparent; }

.btn-ok, :where(button.ok) {
  --btn-fg: #fff; background: var(--ok); border-color: color-mix(in srgb, var(--ok) 80%, #000);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.16), 0 1px 2px rgb(10 80 40 / 0.2);
}
.btn-ok:hover, :where(button.ok):hover { background: color-mix(in srgb, var(--ok) 90%, #000); border-color: color-mix(in srgb, var(--ok) 75%, #000); }

.btn-link, :where(button.link) {
  --btn-fg: var(--accent-text); height: auto; padding: 0; border: 0; background: none; box-shadow: none;
  font-weight: var(--weight-medium); border-radius: var(--radius-xs);
}
.btn-link:hover, :where(button.link):hover { background: none; text-decoration: underline !important; }
.btn-link:active, :where(button.link):active { transform: none; background: none; }

.btn-xs { height: var(--control-xs); padding: 0 var(--space-2); font-size: var(--text-xs); gap: var(--space-1); border-radius: var(--radius-sm); }
.btn-xs .icon { width: 14px; height: 14px; }
.btn-sm, :where(button.small, .button.small) { height: var(--control-sm); padding: 0 10px; font-size: var(--text-sm); gap: 6px; border-radius: var(--radius-sm); }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { height: var(--control-lg); padding: 0 18px; font-size: var(--text-md); border-radius: 10px; }
.btn-lg .icon { width: 18px; height: 18px; }
.btn-icon { width: var(--control-md); padding: 0; }
.btn-icon.btn-xs { width: var(--control-xs); }
.btn-icon.btn-sm { width: var(--control-sm); }
.btn-icon.btn-lg { width: var(--control-lg); }
.btn-block { width: 100%; }
@media (hover: none), (max-width: 900px) { .btn kbd, .tasks-search-kbd { display: none !important; } }
.btn kbd { height: 18px; min-width: 18px; font-size: 11px; margin-left: var(--space-1); background: transparent; border-color: currentColor; opacity: 0.55; color: inherit; box-shadow: none; }

.btn:disabled, .btn[aria-disabled="true"], :where(button):disabled {
  opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none;
}
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border-radius: 50%; border: 2px solid var(--btn-fg); border-right-color: transparent; opacity: 0.9;
  animation: aiw-spin 0.7s linear infinite;
}
.btn-group { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* --- поля: .field > .field-label + контрол (.input | .textarea | .select) + .field-hint | .field-error */
.field { display: flex; flex-direction: column; gap: var(--space-1-5); margin: 0 0 var(--space-5); min-width: 0; }
.field-label { margin: 0; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); display: flex; align-items: baseline; gap: var(--space-1-5); }
.field-label .optional { font-weight: var(--weight-regular); color: var(--text-3); }
.field-hint { font-size: var(--text-xs); color: var(--text-3); line-height: 1.45; }
.field-error { font-size: var(--text-xs); color: var(--bad-text); display: flex; align-items: flex-start; gap: 6px; line-height: 1.45; }
.field-error .icon { width: 14px; height: 14px; margin-top: 1px; }
.form-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-2); }

.input, .textarea, .select,
:where(input[type="text"], input:not([type]), input[type="password"], input[type="email"], input[type="search"],
  input[type="url"], input[type="number"], input[type="tel"], input[type="date"], input[type="month"], textarea, select) {
  width: 100%; min-width: 0; height: var(--control-md); padding: 0 var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs);
  font: var(--weight-regular) var(--text-base)/1.4 var(--font-sans);
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.textarea, :where(textarea) { height: auto; min-height: 88px; padding: 9px var(--space-3); line-height: var(--lh-normal); resize: vertical; }
.input:hover, .textarea:hover, .select:hover,
:where(input[type="text"], input:not([type]), input[type="password"], input[type="email"], input[type="search"],
  input[type="url"], input[type="number"], textarea, select):hover { border-color: var(--border-stronger); }
.input:focus, .textarea:focus, .select:focus,
:where(input[type="text"], input:not([type]), input[type="password"], input[type="email"], input[type="search"],
  input[type="url"], input[type="number"], input[type="tel"], input[type="date"], input[type="month"], textarea, select):focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
::placeholder { color: var(--text-4); opacity: 1; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"],
:where(input, textarea, select)[aria-invalid="true"] { border-color: var(--bad); }
:where(input, textarea, select)[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.input:disabled, .textarea:disabled, .select:disabled, :where(input, textarea, select):disabled {
  background: var(--surface-2); color: var(--text-3); cursor: not-allowed; box-shadow: none;
}
.select, :where(select) {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f8f9a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.input-sm { height: var(--control-sm); font-size: var(--text-sm); padding: 0 10px; border-radius: var(--radius-sm); }
.input-lg { height: var(--control-lg); font-size: var(--text-md); border-radius: 10px; }
.input-mono { font-family: var(--font-mono); font-size: var(--text-sm); }

/* поле с иконкой/приставкой: .input-group > .input-icon? + .input + .input-addon? */
.input-group { position: relative; display: flex; align-items: stretch; min-width: 0; }
.input-group > .input-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none;
}
.input-group > .input-icon ~ .input { padding-left: 36px; }
.input-group > .input-action { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-group > .input-action ~ .input, .input-group > .input:has(~ .input-action) { padding-right: 40px; }
.input-group > .input-addon {
  display: inline-flex; align-items: center; padding: 0 var(--space-3); border: 1px solid var(--border-strong);
  border-left: 0; border-radius: 0 var(--radius-md) var(--radius-md) 0; background: var(--surface-2);
  color: var(--text-3); font-size: var(--text-sm); white-space: nowrap;
}
.input-group > .input:has(+ .input-addon) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* флажки и переключатели: input[type=checkbox|radio] оформлены везде; .switch — тумблер */
input[type="checkbox"], input[type="radio"] {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 16px; height: 16px; display: inline-grid; place-items: center; vertical-align: -3px;
  border: 1px solid var(--border-stronger); background: var(--surface); box-shadow: var(--shadow-xs);
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
input[type="checkbox"] { border-radius: 4px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::before {
  content: ""; width: 10px; height: 10px; background: var(--accent-fg); transform: scale(0);
  transition: transform var(--dur-1) var(--ease-emph);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
input[type="radio"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-fg); transform: scale(0); transition: transform var(--dur-1) var(--ease-emph); }
input[type="checkbox"]:checked, input[type="radio"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::before, input[type="radio"]:checked::before { transform: scale(1); }
input[type="checkbox"]:hover:not(:checked):not(:disabled), input[type="radio"]:hover:not(:checked):not(:disabled) { border-color: var(--text-3); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); border-color: var(--accent); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="checkbox"].switch {
  width: 32px; height: 18px; border-radius: var(--radius-full); border: 0; padding: 2px;
  background: var(--border-stronger); box-shadow: var(--shadow-inset); place-items: center start;
}
input[type="checkbox"].switch::before {
  width: 14px; height: 14px; border-radius: 50%; background: #fff; -webkit-mask: none; mask: none; transform: none;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform var(--dur-2) var(--ease-emph);
}
input[type="checkbox"].switch:checked { background: var(--accent); }
input[type="checkbox"].switch:checked::before { transform: translateX(14px); }

.choice { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 var(--space-3); cursor: pointer; font-weight: var(--weight-regular); font-size: var(--text-base); }
.choice > input { margin-top: 2px; }
.choice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice-label { font-weight: var(--weight-medium); color: var(--text); }
.choice-hint { font-size: var(--text-sm); color: var(--text-3); }
/* выбор карточкой: label.choice-card > input + .choice-body */
.choice-card {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); cursor: pointer;
  margin: 0; font-weight: var(--weight-regular); font-size: var(--text-base);
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.choice-card:hover { border-color: var(--border-strong); }
.choice-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.choice-card > input { margin-top: 2px; }
fieldset { border: 0; padding: 0; margin: 0 0 var(--space-5); min-width: 0; }
legend { padding: 0; margin-bottom: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-medium); }

/* --- карточки */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-5); margin-bottom: var(--space-4); box-shadow: var(--shadow-xs);
}
.card-flush { padding: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-flush > .card-header { margin: 0; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.card-title { margin: 0; font-size: var(--text-md); font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
.card-subtitle { margin: 2px 0 0; font-size: var(--text-sm); color: var(--text-3); }
.card-section { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); }
.card-section:first-child { border-top: 0; }
.card-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2);
  margin: var(--space-5) calc(-1 * var(--space-5)) calc(-1 * var(--space-5)); padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.card-interactive { transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.card-interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
/* показатель: .stat > .stat-label + .stat-value + .stat-meta */
.stat { display: flex; flex-direction: column; gap: var(--space-1); }
.stat-label { font-size: var(--text-sm); color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tighter); font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-meta { font-size: var(--text-xs); color: var(--text-3); }

/* --- таблицы: .table-card > table.table (+ .table-hover | .table-sticky | .table-dense)
       на телефоне .table-stack превращает строки в карточки (td[data-label]) */
.table-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs); overflow: clip; margin-bottom: var(--space-4);
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-base); }
.table th {
  text-align: left; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-3);
  padding: 9px var(--space-3); border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 11px var(--space-3); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table tr:last-child > td { border-bottom: 0; }
.table :is(th, td):first-child { padding-left: var(--space-4); }
.table :is(th, td):last-child { padding-right: var(--space-4); }
.table .num { text-align: right; }
.table-dense td { padding-top: 7px; padding-bottom: 7px; }
.table-dense th { padding-top: 7px; padding-bottom: 7px; }
.table-hover tbody tr { transition: background-color var(--dur-1) var(--ease-out); }
.table-hover tbody tr:hover > td { background: var(--surface-2); }
.table-sticky th { position: sticky; top: 0; z-index: 1; }
.table-card > .table th:first-child { border-top-left-radius: var(--radius-lg); }
.table-card > .table th:last-child { border-top-right-radius: var(--radius-lg); }
.table tr.is-off > td { color: var(--text-3); }
.table .row-link { color: var(--text); font-weight: var(--weight-medium); }
.table .row-link::after { content: ""; position: absolute; inset: 0; }
.table tr:has(.row-link) { position: relative; cursor: pointer; }
.table tr:has(.row-link:focus-visible) > td { background: var(--accent-soft); }
.table .row-link:focus-visible { outline: none; }
.table .actions { text-align: right; white-space: nowrap; }
.table td.actions form { display: inline; margin: 0; }
@media (max-width: 700px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); position: relative; }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { padding: 2px 0 !important; border: 0 !important; text-align: left !important; }
  .table-stack td[data-label]::before {
    content: attr(data-label); display: inline-block; min-width: 40%; color: var(--text-3); font-size: var(--text-xs);
  }
}

/* --- статусы: точка + текст. ui.status(код) — единый словарь статусов задач (web.STATUS) */
.status {
  --tone: var(--neutral); --tone-text: var(--text-2);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--tone-text); line-height: 1.3;
}
.status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent);
}
.status-pill, .badge {
  --tone: var(--neutral); --tone-text: var(--neutral-text); --tone-soft: var(--neutral-soft);
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 8px;
  border-radius: var(--radius-full); background: var(--tone-soft); color: var(--tone-text);
  font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: nowrap; line-height: 1;
}
.status-pill::before, .badge[class*="s-"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tone); flex: none; }
.status-pill.status::before { box-shadow: none; }
.tone-neutral { --tone: var(--neutral); --tone-text: var(--neutral-text); --tone-soft: var(--neutral-soft); --tone-border: var(--neutral-border); }
.tone-accent { --tone: var(--accent); --tone-text: var(--accent-text); --tone-soft: var(--accent-soft); --tone-border: var(--accent-border); }
.tone-ok { --tone: var(--ok); --tone-text: var(--ok-text); --tone-soft: var(--ok-soft); --tone-border: var(--ok-border); }
.tone-warn { --tone: var(--warn); --tone-text: var(--warn-text); --tone-soft: var(--warn-soft); --tone-border: var(--warn-border); }
.tone-bad { --tone: var(--bad); --tone-text: var(--bad-text); --tone-soft: var(--bad-soft); --tone-border: var(--bad-border); }
.tone-info { --tone: var(--info); --tone-text: var(--info-text); --tone-soft: var(--info-soft); --tone-border: var(--info-border); }
/* статусы задач → тон (то же, что web.STATUS) */
.s-new, .s-queued { --tone: var(--neutral); --tone-text: var(--neutral-text); --tone-soft: var(--neutral-soft); }
.s-running { --tone: var(--accent); --tone-text: var(--accent-text); --tone-soft: var(--accent-soft); }
.s-needs_input { --tone: var(--warn); --tone-text: var(--warn-text); --tone-soft: var(--warn-soft); }
.s-ready { --tone: var(--ok); --tone-text: var(--ok-text); --tone-soft: var(--ok-soft); }
.s-done { --tone: var(--neutral); --tone-text: var(--text-3); --tone-soft: var(--neutral-soft); }
.s-failed { --tone: var(--bad); --tone-text: var(--bad-text); --tone-soft: var(--bad-soft); }
.s-interrupted { --tone: var(--warn); --tone-text: var(--warn-text); --tone-soft: var(--warn-soft); }
.status.s-done { color: var(--text-3); }
.status.s-queued::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--neutral); }
.status.s-running::before, .badge.s-running::before, .status-pill.s-running::before { animation: aiw-pulse 1.6s var(--ease-out) infinite; }

/* --- метки: .pill (+ .pill-ok | -warn | -bad | -info | -accent); прежнее имя — .tag */
.pill, .tag {
  --tone-text: var(--text-2); --tone-soft: var(--surface-2); --tone-border: var(--border);
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: 1; white-space: nowrap; vertical-align: 1px;
  background: var(--tone-soft); color: var(--tone-text); border: 1px solid var(--tone-border);
}
.pill .icon, .tag .icon { width: 12px; height: 12px; }
.pill-ok, .tag.ok { --tone-text: var(--ok-text); --tone-soft: var(--ok-soft); --tone-border: var(--ok-border); }
.pill-warn, .tag.warn { --tone-text: var(--warn-text); --tone-soft: var(--warn-soft); --tone-border: var(--warn-border); }
.pill-bad, .tag.bad { --tone-text: var(--bad-text); --tone-soft: var(--bad-soft); --tone-border: var(--bad-border); }
.pill-info, .tag.info { --tone-text: var(--info-text); --tone-soft: var(--info-soft); --tone-border: var(--info-border); }
.pill-accent { --tone-text: var(--accent-text); --tone-soft: var(--accent-soft); --tone-border: var(--accent-border); }
.pill-mono { font-family: var(--font-mono); font-size: 11.5px; }
.count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: var(--weight-semibold); background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums;
}

/* --- вкладки (ссылки между страницами раздела): nav.tabs > a.tab[aria-current=page] */
.tabs {
  display: flex; gap: var(--space-1); flex-wrap: wrap; border-bottom: 1px solid var(--border);
  margin: 0 0 var(--space-6);
}
.tab, .tabs > a {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 10px;
  color: var(--text-3); font: var(--weight-medium) var(--text-base)/1 var(--font-sans); text-decoration: none !important; white-space: nowrap;
  border: 0; background: transparent; box-shadow: none; cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color var(--dur-1) var(--ease-out);
}
.tab .icon, .tabs > a .icon { width: 16px; height: 16px; }
.tab:hover, .tabs > a:hover { color: var(--text); background: transparent; }
.tab:active { transform: none; background: transparent; }
.tab::before, .tabs > a::before {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0;
  background: var(--text); transform: scaleX(0); transition: transform var(--dur-2) var(--ease-out);
}
.tab[aria-current="page"], .tab.is-active, .tabs > a.on, .tabs > a[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"]::before, .tab.is-active::before, .tabs > a.on::before, .tabs > a[aria-current="page"]::before { transform: none; }
.tab[aria-current="page"]::before, .tabs > a.on::before { view-transition-name: aiw-tab-indicator; }
.tab .count { background: var(--surface-2); color: var(--text-3); }
.tab[aria-current="page"] .count, .tab.is-active .count { background: var(--surface-3); color: var(--text); }
@media (max-width: 700px) {
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
}
/* вкладки внутри страницы (без перехода): [role=tablist] > [role=tab][aria-selected] + [role=tabpanel] — ui.js */
[role="tabpanel"] { animation: aiw-fade-up var(--dur-2) var(--ease-out); }

/* --- сегменты: .segmented > (a | button).segment[aria-current|aria-pressed] */
.segmented {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segment {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 7px; border: 0;
  background: transparent; color: var(--text-3); font: var(--weight-medium) var(--text-sm)/1 var(--font-sans);
  white-space: nowrap; cursor: pointer; text-decoration: none !important; box-shadow: none;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.segment .icon { width: 15px; height: 15px; }
.segment:hover { color: var(--text); background: transparent; }
.segment:active { transform: none; background: transparent; }
.segment[aria-current="page"], .segment[aria-pressed="true"], .segment[aria-checked="true"], .segment.is-active {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}
:root[data-theme="dark"] .segment[aria-current="page"], :root[data-theme="dark"] .segment[aria-pressed="true"],
:root[data-theme="dark"] .segment[aria-checked="true"], :root[data-theme="dark"] .segment.is-active { background: var(--surface-3); }
.segment .count { min-width: 16px; height: 16px; font-size: 10.5px; background: var(--surface-3); color: var(--text-3); }
.segment[aria-current="page"] .count, .segment.is-active .count { background: var(--accent-soft); color: var(--accent-text); }
.segmented-sm .segment { height: 24px; padding: 0 9px; font-size: var(--text-xs); }

/* --- пустое состояние: ui.empty(заголовок, текст, иконка) + действия через caller */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--space-12) var(--space-6); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface);
}
.empty-icon {
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; color: var(--text-2);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm), inset 0 -1px 0 var(--border-subtle);
}
.empty-icon .icon { width: 22px; height: 22px; }
.empty-title { margin: var(--space-4) 0 0; font-size: var(--text-md); font-weight: var(--weight-semibold); }
.empty-text { margin: var(--space-1-5) auto 0; max-width: 46ch; color: var(--text-3); }
.empty-actions { margin-top: var(--space-5); display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }
.empty-state.is-compact { padding: var(--space-8) var(--space-4); }

/* --- скелетоны: .skeleton (+ .skeleton-text | .skeleton-title | .skeleton-circle | .skeleton-block) */
.skeleton {
  display: block; border-radius: var(--radius-sm); height: 12px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%);
  background-size: 300% 100%; animation: aiw-shimmer 1.6s ease-in-out infinite;
}
.skeleton-text { height: 12px; margin: 6px 0; }
.skeleton-title { height: 20px; width: 40%; margin-bottom: var(--space-3); }
.skeleton-circle { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.skeleton-block { height: 96px; border-radius: var(--radius-lg); }

/* --- тосты: AIW.toast(текст, вид) → .toast-region > .toast.toast-<вид> */
.toast-region {
  position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--space-2); width: min(380px, calc(100vw - 2 * var(--space-4)));
  pointer-events: none;
}
.toast {
  --tone: var(--accent-text);
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 10px 12px 14px; border-radius: var(--radius-lg);
  background: var(--surface-raised); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: var(--text-sm); line-height: 1.45;
  animation: aiw-toast-in var(--dur-3) var(--ease-emph) both;
}
.toast.is-leaving { animation: aiw-toast-out var(--dur-2) var(--ease-out) both; }
.toast > .icon { width: 18px; height: 18px; color: var(--tone); margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; padding-top: 1px; }
.toast-title { font-weight: var(--weight-semibold); }
.toast-close { margin: -4px -2px -4px 0; }
.toast-ok { --tone: var(--ok-text); }
.toast-warn { --tone: var(--warn-text); }
.toast-bad { --tone: var(--bad-text); }
.toast-info { --tone: var(--info-text); }
@media (max-width: 600px) { .toast-region { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); width: auto; } }

/* --- диалог: <dialog class="dialog"> + AIW.confirm({...}) */
.dialog {
  width: min(440px, calc(100vw - 2 * var(--space-4))); max-height: calc(100dvh - 2 * var(--space-8));
  padding: 0; border: 1px solid var(--border); border-radius: 14px; overflow: auto;
  background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-xl);
}
.dialog[open] { animation: aiw-dialog-in var(--dur-3) var(--ease-emph); }
.dialog[open]::backdrop { background: var(--overlay); backdrop-filter: blur(2px); animation: aiw-fade-in var(--dur-2) var(--ease-out); }
.dialog.is-closing { animation: aiw-dialog-out var(--dur-1) var(--ease-out) forwards; }
.dialog.is-closing::backdrop { animation: aiw-fade-out var(--dur-1) var(--ease-out) forwards; }
.dialog-lg { width: min(640px, calc(100vw - 2 * var(--space-4))); }
.dialog-body { padding: var(--space-6) var(--space-6) 0; }
.dialog-head { display: flex; gap: var(--space-3); align-items: flex-start; }
.dialog-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-text); }
.dialog-icon.is-danger { background: var(--bad-soft); color: var(--bad-text); }
.dialog-icon .icon { width: 18px; height: 18px; }
.dialog-title { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-semibold); letter-spacing: -0.01em; line-height: 1.3; }
.dialog-text { margin: var(--space-1-5) 0 0; color: var(--text-2); }
.dialog-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-6); flex-wrap: wrap; }
@media (max-width: 520px) { .dialog-footer > .btn { flex: 1; } }

/* --- выпадающее меню: .menu[data-menu] > button[aria-haspopup=menu] + .menu-panel[role=menu] */
.menu { position: relative; display: inline-block; }
.menu-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--z-dropdown);
  min-width: 220px; padding: var(--space-1); border-radius: 10px;
  background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-4px) scale(0.98); transform-origin: top left;
  transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility 0s linear var(--dur-2);
}
.menu-panel.is-end { left: auto; right: 0; transform-origin: top right; }
.menu-panel.is-top { top: auto; bottom: calc(100% + 6px); transform-origin: bottom left; transform: translateY(4px) scale(0.98); }
.menu.is-open > .menu-panel { opacity: 1; visibility: visible; transform: none; transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-2) var(--ease-out); }
.menu-item {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; height: 32px; padding: 0 10px; margin: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); box-shadow: none;
  font: var(--weight-regular) var(--text-base)/1 var(--font-sans); text-align: left; text-decoration: none !important; cursor: pointer;
}
.menu-item .icon { color: var(--text-3); width: 16px; height: 16px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; border-color: transparent; }
.menu-item:active { transform: none; background: var(--surface-3); }
.menu-item kbd { margin-left: auto; }
.menu-item-danger { color: var(--bad-text); }
.menu-item-danger .icon { color: var(--bad-text); }
.menu-sep { height: 1px; background: var(--border); margin: var(--space-1) calc(-1 * var(--space-1)); }
.menu-label { padding: 8px 10px 4px; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-3); }
.menu-head { padding: 8px 10px; display: flex; gap: 10px; align-items: center; }
.menu-head .user-meta { line-height: 1.3; }
.menu form { margin: 0; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 4px 4px 4px 10px; color: var(--text-2); font-size: var(--text-sm); }

/* --- подсказка: атрибут data-tip="текст" (ui.js рисует .tooltip у края экрана) */
.tooltip {
  position: fixed; z-index: var(--z-tooltip); max-width: 280px; padding: 5px 8px; border-radius: var(--radius-sm);
  background: #17171c; color: #f3f3f6; font-size: var(--text-xs); line-height: 1.4; font-weight: var(--weight-medium);
  box-shadow: var(--shadow-md); pointer-events: none; opacity: 0; transform: translateY(2px);
  transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
:root[data-theme="dark"] .tooltip { background: #f0f0f3; color: #17171c; }
.tooltip.is-visible { opacity: 1; transform: none; }
.tooltip kbd { background: transparent; color: inherit; border-color: currentColor; opacity: 0.7; margin-left: 6px; box-shadow: none; }

/* --- аватар: ui.avatar(имя) → инициалы на цвете от имени */
.avatar {
  --h: 240;
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  font-size: 11px; font-weight: var(--weight-semibold); letter-spacing: 0.02em; line-height: 1;
  background: hsl(var(--h) var(--av-s-bg) var(--av-l-bg)); color: hsl(var(--h) var(--av-s-fg) var(--av-l-fg));
  box-shadow: inset 0 0 0 1px hsl(var(--h) 40% 50% / 0.14); user-select: none;
}
.avatar-xs { width: 20px; height: 20px; font-size: 9px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 36px; height: 36px; font-size: 13px; }
.avatar-xl { width: 48px; height: 48px; font-size: 16px; }
.avatar-stack { display: inline-flex; }
.avatar-stack > .avatar { box-shadow: 0 0 0 2px var(--bg); }
.avatar-stack > .avatar + .avatar { margin-left: -6px; }

/* --- клавиши */
kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface);
  color: var(--text-2); font: var(--weight-medium) 11px/1 var(--font-sans); vertical-align: 1px; white-space: nowrap;
}

/* --- спиннер и полоса прогресса */
.spinner {
  display: inline-block; width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; color: var(--accent-text);
  animation: aiw-spin 0.7s linear infinite; vertical-align: -3px;
}
.spinner-sm { width: 12px; height: 12px; border-width: 1.5px; }
.spinner-lg { width: 24px; height: 24px; border-width: 2.5px; }
.progressbar { height: 6px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.progressbar > span {
  display: block; height: 100%; width: var(--value, 0%); border-radius: inherit; background: var(--accent);
  transition: width var(--dur-3) var(--ease-out);
}
.progressbar.is-indeterminate > span { width: 35%; animation: aiw-indeterminate 1.3s var(--ease-in-out) infinite; }

/* --- баннер-алерт: .alert.alert-<тон> > svg.icon + .alert-body (.alert-title) */
.alert {
  --tone-text: var(--info-text); --tone-soft: var(--info-soft); --tone-border: var(--info-border);
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin: 0 0 var(--space-4);
  border-radius: var(--radius-lg); background: var(--tone-soft); border: 1px solid var(--tone-border); color: var(--text);
  font-size: var(--text-base); line-height: 1.5;
}
.alert > .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--tone-text); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: var(--weight-semibold); color: var(--text); }
.alert-body > p { margin: 2px 0 0; color: var(--text-2); }
.alert-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.alert-ok { --tone-text: var(--ok-text); --tone-soft: var(--ok-soft); --tone-border: var(--ok-border); }
.alert-warn { --tone-text: var(--warn-text); --tone-soft: var(--warn-soft); --tone-border: var(--warn-border); }
.alert-bad { --tone-text: var(--bad-text); --tone-soft: var(--bad-soft); --tone-border: var(--bad-border); }
.alert-accent { --tone-text: var(--accent-text); --tone-soft: var(--accent-soft); --tone-border: var(--accent-border); }

/* --- «живой» индикатор работы агента: .live (точка с волной) и .shimmer-text (бегущий блик по тексту) */
.live { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--accent-text); font-weight: var(--weight-medium); font-size: var(--text-sm); }
.live-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.live-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent);
  animation: aiw-ping 1.6s var(--ease-out) infinite;
}
.shimmer-text {
  background: linear-gradient(90deg, var(--text-3) 0%, var(--text-3) 35%, var(--text) 50%, var(--text-3) 65%, var(--text-3) 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: aiw-text-shimmer 2.4s linear infinite;
}

/* --- описание (ключ — значение) */
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-2) var(--space-6); margin: 0; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* --- код и пути файлов */
.codeblock {
  margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border); overflow: auto;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; color: var(--text);
}
.path { font-family: var(--font-mono); font-size: 0.86em; color: var(--text-2); overflow-wrap: anywhere; }

/* --- бренд-знак: ui.mark(размер) — SVG, не картинка */
.mark { display: block; flex: none; border-radius: 28%; }

/* ---------------------------------------------------------------- 6. Наследие
   Классы экранов до дизайн-системы. Новые экраны их не используют — см. docs/DESIGN.md. */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.between { justify-content: space-between; }
.error { color: var(--bad-text); }
:where(label) { display: block; margin-bottom: var(--space-4); font-weight: var(--weight-medium); font-size: var(--text-sm); }
:where(label) > :where(input:not([type="checkbox"]):not([type="radio"]), textarea, select) { margin-top: 6px; font-weight: var(--weight-regular); }
.card .label {
  font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: var(--space-2);
}
.empty:not(.empty-state) {
  text-align: center; padding: var(--space-12) var(--space-5); background: var(--surface);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--text-2);
}
table.list {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: clip; box-shadow: var(--shadow-xs);
  margin-bottom: var(--space-2);
}
table.list th, table.list td { text-align: left; padding: 10px var(--space-3); border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
table.list th { font-size: var(--text-xs); color: var(--text-3); font-weight: var(--weight-medium); background: var(--surface-2); border-bottom-color: var(--border); white-space: nowrap; }
table.list tr:last-child > td { border-bottom: 0; }
table.list :is(th, td):first-child { padding-left: var(--space-4); }
table.list :is(th, td):last-child { padding-right: var(--space-4); }
table.list tbody tr { cursor: pointer; transition: background-color var(--dur-1) var(--ease-out); }
table.list tbody tr:hover > td { background: var(--surface-2); }
table.list.static tbody tr { cursor: default; }
table.list.static tbody tr:hover > td { background: transparent; }
table.list tr.off td { color: var(--text-3); }
table.list.small { font-size: var(--text-sm); }
table.list td.actions form { margin: 0 0 4px; }
td.wrap { overflow-wrap: anywhere; max-width: 320px; }
.note { display: block; padding: 11px 14px; border-radius: var(--radius-lg); margin: 0 0 var(--space-4); border: 1px solid transparent; }
.note.good { background: var(--ok-soft); color: var(--ok-text); border-color: var(--ok-border); }
.note.bad { background: var(--bad-soft); color: var(--bad-text); border-color: var(--bad-border); }
.note.warn { background: var(--warn-soft); color: var(--warn-text); border-color: var(--warn-border); }
.note.secret { background: var(--surface); border: 1px solid var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
code.pw { font-size: var(--text-md); padding: 3px 9px; background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-border); border-radius: var(--radius-sm); user-select: all; }
label.check { display: inline-flex; gap: var(--space-2); align-items: center; font-weight: var(--weight-regular); margin: 4px 14px 4px 0; font-size: var(--text-base); }
form.stack { display: flex; flex-direction: column; gap: 4px; margin-top: var(--space-2); }
form.stack .row { gap: 0; }
.narrow-form { max-width: 640px; }
details.card > summary { margin: -4px 0; }
details.card[open] > summary { margin-bottom: var(--space-3); }
input.num { width: 7.5em; }
h2.flush { margin: 0; }
pre.diff {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4);
  overflow: auto; font-size: 12.5px; line-height: 1.6; max-height: 60vh;
}
.skill p { margin: 6px 0; }
.agent-pick { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); }
.agent-pick .radio, label.radio { display: flex; gap: 10px; font-weight: var(--weight-regular); margin: var(--space-2) 0; align-items: flex-start; }
.agent-pick .radio > input, label.radio > input { margin-top: 3px; }
select.model-pick { width: auto; max-width: 220px; margin: 0; height: var(--control-sm); font-size: var(--text-sm); }
@media (max-width: 700px) { table.list { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; } }

/* ---------------------------------------------------------------- 7. Анимации и переходы */
@keyframes aiw-spin { to { transform: rotate(360deg); } }
@keyframes aiw-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tone) 45%, transparent); }
  70% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--tone) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tone) 0%, transparent); }
}
@keyframes aiw-ping { 0% { transform: scale(1); opacity: 0.55; } 80%, 100% { transform: scale(2.6); opacity: 0; } }
@keyframes aiw-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes aiw-text-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -150% 0; } }
@keyframes aiw-indeterminate { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }
@keyframes aiw-fade-in { from { opacity: 0; } }
@keyframes aiw-fade-out { to { opacity: 0; } }
@keyframes aiw-fade-up { from { opacity: 0; transform: translateY(4px); } }
@keyframes aiw-toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes aiw-toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes aiw-dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
@keyframes aiw-dialog-out { to { opacity: 0; transform: translateY(4px) scale(0.98); } }

/* переходы между страницами (Chrome, Edge, Safari 18+): сайдбар неподвижен, содержимое — мягко */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: var(--dur-2); animation-timing-function: var(--ease-out); }
::view-transition-old(aiw-main) { animation: var(--dur-1) var(--ease-out) both aiw-fade-out; }
::view-transition-new(aiw-main) { animation: var(--dur-2) var(--ease-out) both aiw-fade-up; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--dur-1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important;
  }
  .shimmer-text { animation: none !important; background-position: 40% 0; }
  .spinner, .btn.is-loading::after { animation: aiw-spin 1.6s linear infinite !important; }
  @view-transition { navigation: none; }
}
