@import url("tokens.css");
@import url("dash.css");

/* ── База ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--backdrop);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: var(--weight-bold); }
p { margin: 0; }
a { color: inherit; }
svg { flex: none; display: block; }
button { font: inherit; color: inherit; }

:focus-visible {
  outline: var(--stroke-2) solid var(--focus);
  outline-offset: var(--stroke-2);
  border-radius: var(--radius-sm);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.is-hidden { display: none !important; }

/* ── Кнопки: default, hover, focus, active, disabled, loading, selected ─ */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--target);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { background: var(--surface-3); transform: translateY(var(--press)); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[aria-pressed="true"], .btn.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:active:not(:disabled) { background: var(--accent-hover); }

.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.btn--ghost:active:not(:disabled) { background: var(--line); }

.btn--danger { color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn--danger-solid:hover:not(:disabled) { filter: brightness(0.94); }

.btn--sm { min-height: var(--size-sm); padding: 0 var(--sp-3); font-size: var(--text-xs); }
.btn--icon { width: var(--target); padding: 0; }
.btn--icon.btn--sm { width: var(--size-sm); }
.btn--xs { width: var(--size-xs-btn); min-height: var(--size-xs-btn); padding: 0; }
.btn--block { width: 100%; }

.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: var(--size-icon-sm); height: var(--size-icon-sm);
  border: var(--stroke-2) solid var(--ink-3);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin var(--dur-spin) linear infinite;
}
.btn--primary.is-loading::after { border-color: var(--on-accent); border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Поля: default, hover, focus, disabled, error ────────────────────── */
.field { display: block; margin-bottom: var(--sp-4); }
.field > span {
  display: block;
  margin-bottom: var(--sp-2);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.input, .select, .textarea {
  width: 100%;
  min-height: var(--target);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-body);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:hover:not(:disabled), .select:hover:not(:disabled), .textarea:hover:not(:disabled) {
  border-color: var(--ink-3);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 var(--ring) color-mix(in srgb, var(--focus) 20%, transparent);
}
.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--surface-2);
  color: var(--ink-3);
  cursor: not-allowed;
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: var(--size-area); resize: vertical; }
.error-text { min-height: 20px; margin: 0; color: var(--danger); font-size: var(--text-sm); }

/* ── Каркас ──────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100dvh; }

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.sidebar__top { padding: var(--sp-4) var(--sp-3) var(--sp-2); }

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  padding: var(--sp-1) var(--sp-2) var(--sp-4);
  text-decoration: none;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: var(--size-sm); height: var(--size-sm);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
}
.brand__text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.brand__name {
  font-size: var(--text-title);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-title);
  line-height: 1.2;
}
.brand__org {
  display: block;
  overflow: hidden;
  color: var(--ink-3);
  font-size: var(--text-xs);
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav { display: grid; gap: 2px; padding: var(--sp-3) 0 0; }
.nav__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--size-nav);
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav__item:hover { background: var(--surface-3); color: var(--ink); }
.nav__item:active { background: var(--line); }
.nav__item[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
}
.nav__item svg { color: var(--ink-3); }
.nav__item[aria-current="page"] svg { color: var(--accent); }
.nav__label { flex: 1; }
.nav__count {
  min-width: var(--size-badge);
  padding: 1px var(--badge-x);
  border-radius: var(--radius-pill);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.nav__count--danger { background: var(--danger-soft); color: var(--danger); }

.sidebar__label {
  padding: var(--sp-5) var(--sp-5) var(--sp-2);
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.recent { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--sp-3) var(--sp-4); }
.recent__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--size-md);
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.recent__item:hover { background: var(--surface-3); color: var(--ink); }
.recent__item[aria-current="page"] { background: var(--surface-3); color: var(--ink); font-weight: var(--weight-medium); }
.recent__title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent__empty { padding: var(--sp-2) var(--sp-3); color: var(--ink-3); font-size: var(--text-sm); }

.dot {
  width: var(--dot); height: var(--dot);
  border-radius: 50%;
  background: var(--warn);
  animation: pulse var(--dur-pulse) var(--ease) infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

.sidebar__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-top: 1px solid var(--line);
}
.avatar {
  display: grid;
  place-items: center;
  width: var(--size-avatar); height: var(--size-avatar);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  flex: none;
}
.who { flex: 1; min-width: 0; }
.who__name { overflow: hidden; font-size: var(--text-sm); font-weight: var(--weight-medium); text-overflow: ellipsis; white-space: nowrap; }
.who__pos { overflow: hidden; color: var(--ink-3); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }

.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.mobilebar {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.mobilebar__title { flex: 1; overflow: hidden; font-weight: var(--weight-bold); text-overflow: ellipsis; white-space: nowrap; }

.view { flex: 1; min-height: 0; overflow-y: auto; }

/* ── Страница ────────────────────────────────────────────────────────── */
.page { max-width: var(--page-w); margin: 0 auto; padding: var(--sp-6) var(--sp-6) var(--sp-7); }
.page-head { margin-bottom: var(--sp-5); }
.page-head__row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.page-title {
  font-size: var(--text-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
}
.page-sub { margin-top: var(--sp-3); max-width: 62ch; color: var(--ink-2); font-size: var(--text-body); }

.section { margin-top: var(--sp-6); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.section__title { font-size: var(--text-h2); font-weight: var(--weight-bold); letter-spacing: var(--tracking-title); }
.section__link {
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
}
.section__link:hover { text-decoration: underline; text-underline-offset: var(--ring); }

.split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--sp-7); }

/* ── Списки строк ────────────────────────────────────────────────────── */
.list { border-top: 1px solid var(--line); }
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--size-row);
  padding: var(--sp-3) var(--sp-2);
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease);
}
a.row:hover, button.row:hover { background: var(--surface-2); }
a.row:active, button.row:active { background: var(--surface-3); }
button.row { width: 100%; border-top: 0; border-left: 0; border-right: 0; background: none; text-align: left; cursor: pointer; }
.row__icon {
  display: grid;
  place-items: center;
  width: var(--size-md); height: var(--size-md);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-2);
  flex: none;
}
.row__body { flex: 1; min-width: 0; }
.row__title { display: block; overflow: hidden; font-weight: var(--weight-medium); text-overflow: ellipsis; white-space: nowrap; }
.row__meta { display: block; overflow: hidden; color: var(--ink-3); font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; }
.row__side { display: flex; align-items: center; gap: var(--sp-2); flex: none; color: var(--ink-3); font-size: var(--text-sm); }
.row__meta--wrap { white-space: normal; }

.empty-note {
  padding: var(--sp-6) var(--sp-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--ink-3);
  font-size: var(--text-sm);
  text-align: center;
}

/* ── Метки статуса: всегда иконка плюс текст ─────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-xs);
  padding: var(--pill-y) var(--pill-x);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  white-space: nowrap;
}
.pill--accent { background: var(--accent-soft); color: var(--accent); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--danger { background: var(--danger-soft); color: var(--danger); }
.pill--ok { background: var(--ok-soft); color: var(--ok); }

/* ── Поле вопроса ────────────────────────────────────────────────────── */
.composer {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.composer:focus-within {
  border-color: var(--focus);
  box-shadow: var(--shadow), 0 0 0 var(--ring) color-mix(in srgb, var(--focus) 16%, transparent);
}
.composer.is-drop { border-color: var(--accent); background: var(--accent-soft); }
.composer__input {
  display: block;
  width: 100%;
  min-height: var(--size-row);
  max-height: var(--h-composer);
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: var(--text-body);
  line-height: 1.55;
  resize: none;
}
.composer__input::placeholder { color: var(--ink-3); }
.composer__input:focus { outline: none; }
.composer--hero .composer__input { min-height: var(--size-area); font-size: var(--text-title); }
.composer__files { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: 0 var(--sp-3); }
.composer__files:empty { display: none; }
.composer__bar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) var(--sp-3); }
.composer__spacer { flex: 1; }
.composer__hint { color: var(--ink-3); font-size: var(--text-xs); }

.chipfile {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: var(--w-chip);
  min-height: var(--size-sm);
  padding: 0 var(--sp-1) 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: var(--text-xs);
}
.chipfile__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chipfile__meta { color: var(--ink-3); white-space: nowrap; }
.chipfile.is-pending { color: var(--ink-3); padding-right: var(--sp-3); }

/* Выбор специалиста */
.picker { position: relative; min-width: 0; }
.picker__btn { max-width: 100%; overflow: hidden; }
.picker__btn > span:last-of-type { overflow: hidden; text-overflow: ellipsis; }
.picker__btn { gap: var(--gap-xs); }
.picker__btn .picker__label { color: var(--ink-3); font-weight: var(--weight-normal); }
.picker__menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + var(--sp-2));
  z-index: 30;
  width: var(--w-menu);
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  animation: rise var(--dur) var(--ease-out);
}
.picker__menu--down { top: calc(100% + var(--sp-2)); bottom: auto; }
@keyframes rise { from { opacity: 0; transform: translateY(var(--sp-1)); } }
.picker__opt {
  display: block;
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--radius);
  background: none;
  text-align: left;
  cursor: pointer;
}
.picker__opt:hover, .picker__opt:focus-visible { background: var(--surface-2); outline: none; }
.picker__opt[aria-checked="true"] { background: var(--accent-soft); }
.picker__opt-title { display: flex; align-items: center; justify-content: space-between; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.picker__opt[aria-checked="true"] .picker__opt-title { color: var(--accent); }
.picker__opt-hint { color: var(--ink-3); font-size: var(--text-xs); line-height: 1.4; }

/* ── Главная ─────────────────────────────────────────────────────────── */
.home-ask { margin-bottom: var(--sp-5); }
.tasks { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.task {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--size-md);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink-2);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.task:hover { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.task:active { background: var(--surface-2); }
.task svg { color: var(--ink-3); }

.attention { display: grid; gap: var(--sp-2); }
.alert {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}
.alert__icon { color: var(--ink-3); padding-top: 2px; }
.alert--danger .alert__icon { color: var(--danger); }
.alert--warn .alert__icon { color: var(--warn); }
.alert__title { font-weight: var(--weight-medium); line-height: var(--leading-snug); }
.alert__meta { margin-top: 2px; color: var(--ink-3); font-size: var(--text-sm); }

/* ── Вопрос ──────────────────────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; height: 100%; }
.thread__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.thread__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-title);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-title);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread__scroll { flex: 1; min-height: 0; overflow-y: auto; }
.thread__inner { max-width: var(--reading-w); margin: 0 auto; padding: var(--sp-5) var(--sp-5) var(--sp-4); }
.thread__foot { padding: 0 var(--sp-5) var(--sp-4); background: linear-gradient(to bottom, transparent, var(--paper) 24px); }
.thread__foot-inner { max-width: var(--reading-w); margin: 0 auto; }

.q { display: flex; justify-content: flex-end; margin-bottom: var(--sp-6); }
.q__bubble {
  max-width: 86%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-sm) var(--radius-xl);
  background: var(--surface-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.a { margin-bottom: var(--sp-7); }
.a__who { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); color: var(--ink-3); font-size: var(--text-sm); }
.a__mark {
  display: grid;
  place-items: center;
  width: var(--size-xs); height: var(--size-xs);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
}
.a__name { color: var(--ink); font-weight: var(--weight-medium); }
.a__tools { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }

/* Текст ответа: читается как документ */
.doc { font-size: var(--text-body); line-height: 1.6; overflow-wrap: anywhere; }
.doc > * + * { margin-top: var(--sp-3); }
.doc h2, .doc h3, .doc h4 { margin-top: var(--sp-6); letter-spacing: var(--tracking-title); line-height: var(--leading-snug); }
.doc h2 { font-size: var(--text-h2); }
.doc h3, .doc h4 { font-size: var(--text-title); }
.doc > h2:first-child, .doc > h3:first-child { margin-top: 0; }
.doc ul, .doc ol { padding-left: var(--sp-5); }
.doc li + li { margin-top: var(--sp-1); }
.doc strong { font-weight: var(--weight-bold); }
.doc code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); font-family: var(--font-mono); font-size: 0.9em; }
.doc pre { overflow-x: auto; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--surface-2); }
.doc pre code { padding: 0; background: none; }
.doc .table-wrap { overflow-x: auto; margin: var(--sp-4) 0; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.doc table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: 1.5; }
/* Таблица не сжимается до обрывков слов: лучше горизонтальная прокрутка */
.doc table { min-width: 34em; }
.doc th, .doc td { overflow-wrap: break-word; word-break: normal; hyphens: manual; }
.doc th:first-child, .doc td:first-child { min-width: 9em; }
.doc th, .doc td { padding: var(--sp-3); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.doc tr:last-child td { border-bottom: 0; }
.doc th { background: var(--surface-2); color: var(--ink-2); font-weight: var(--weight-bold); }

.caret {
  display: inline-block;
  width: var(--stroke-2); height: 1.1em;
  margin-left: var(--stroke-2);
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink var(--dur-blink) steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.waiting {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.waiting__dots { display: flex; gap: var(--sp-1); }
.waiting__dots i { width: var(--dot-sm); height: var(--dot-sm); border-radius: 50%; background: var(--accent); animation: bounce var(--dur-bounce) var(--ease) infinite; }
.waiting__dots i:nth-child(2) { animation-delay: var(--stagger); }
.waiting__dots i:nth-child(3) { animation-delay: calc(var(--stagger) * 2); }
@keyframes bounce { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(calc(var(--bounce) * -1)); } }
.waiting__title { font-weight: var(--weight-medium); }
.waiting__meta { color: var(--ink-3); font-size: var(--text-sm); }

.notice {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-size: var(--text-sm);
}
.notice svg { color: var(--ink-3); margin-top: 2px; }
.notice--danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: var(--danger-soft); }
.notice--danger svg { color: var(--danger); }
.notice--info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.notice--info svg { color: var(--accent); }

/* ── Документы ───────────────────────────────────────────────────────── */
.drop {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: var(--stroke-2) solid var(--focus); outline-offset: 2px; }
.drop { cursor: pointer; }
.drop__icon { display: grid; place-items: center; width: var(--size-drop); height: var(--size-drop); border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); flex: none; }
.drop__body { flex: 1; min-width: 0; }
.drop__title { font-weight: var(--weight-medium); }
.drop__meta { color: var(--ink-3); font-size: var(--text-sm); }

/* ── Сроки ───────────────────────────────────────────────────────────── */
.group-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-6) 0 var(--sp-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}
.group-label--danger { color: var(--danger); }
.group-label--warn { color: var(--warn); }
.group-label--muted { color: var(--ink-3); }

.form-card {
  margin-bottom: var(--sp-5);
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.form-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 0 var(--sp-4); }
.form-grid .field--wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: var(--sp-2); }

/* ── Организация ─────────────────────────────────────────────────────── */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(var(--w-menu-min), 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--line); }
.fact { padding: var(--sp-4) var(--sp-5); background: var(--surface); }
.fact__label { color: var(--ink-3); font-size: var(--text-sm); }
.fact__value { margin-top: var(--sp-1); font-size: var(--text-title); font-weight: var(--weight-medium); }
.fact--lead { grid-column: 1 / -1; }
.fact--lead .fact__value { font-size: var(--text-h2); font-weight: var(--weight-bold); letter-spacing: var(--tracking-title); }

/* ── Диалог подтверждения ────────────────────────────────────────────── */
.modal {
  width: min(var(--w-modal), calc(100vw - var(--sp-6)));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: var(--scrim); }
.modal__body { padding: var(--sp-5) var(--sp-5) var(--sp-4); }
.modal__title { font-size: var(--text-h2); font-weight: var(--weight-bold); letter-spacing: var(--tracking-title); }
.modal__text { margin-top: var(--sp-2); color: var(--ink-2); font-size: var(--text-sm); }
.modal__field { margin-top: var(--sp-4); }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: 0 var(--sp-5) var(--sp-5); }

/* ── Меню действий темы ──────────────────────────────────────────────── */
.menu { position: relative; }
.menu__list {
  position: absolute;
  top: calc(100% + var(--gap-xs));
  right: 0;
  z-index: 30;
  min-width: var(--w-menu-min);
  padding: var(--sp-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  animation: rise var(--dur) var(--ease-out);
}
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: var(--size-md);
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-2); outline: none; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger:hover, .menu__item--danger:focus-visible { background: var(--danger-soft); }

/* ── Всплывающее сообщение ───────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--sp-5);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: calc(100vw - var(--sp-6));
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: var(--on-ink);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: rise var(--dur) var(--ease-out);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

/* ── Вход и служебные страницы ───────────────────────────────────────── */
.auth { display: grid; place-items: center; min-height: 100dvh; padding: var(--sp-5); background: var(--backdrop); }
.auth__card {
  width: 100%;
  max-width: var(--w-auth);
  padding: var(--sp-7) var(--sp-6) var(--sp-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}
.auth .brand { padding: 0 0 var(--sp-6); }
.auth__title {
  font-size: var(--text-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
}
.auth__sub { margin: var(--sp-2) 0 var(--sp-6); color: var(--ink-2); }
.auth__foot { margin-top: var(--sp-5); color: var(--ink-3); font-size: var(--text-sm); }
.auth__foot a { color: var(--accent); }

/* Вход с рассказом о продукте: слева кто мы, справа форма; на телефоне форма первой */
.auth--split {
  grid-template-columns: minmax(0, var(--l-max-text)) minmax(0, var(--w-auth));
  justify-content: center;
  align-content: center;
  gap: var(--sp-8);
}
.auth__pitch { max-width: var(--l-max-text); }
.auth__kicker { color: var(--accent); font-size: var(--text-sm); font-weight: var(--weight-bold); }
.auth__pitch-title {
  font-weight: var(--weight-bold);
  margin-top: var(--sp-3);
  font-size: var(--l-h2);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}
.auth__pitch-title span { color: var(--accent); }
.auth__pitch-lead { margin-top: var(--sp-4); color: var(--ink-2); font-size: var(--l-lead); }
.auth__ticks { display: grid; gap: var(--sp-3); margin: var(--sp-5) 0 0; padding: 0; list-style: none; font-size: var(--l-body); }
.auth__ticks li { display: flex; gap: var(--sp-3); align-items: flex-start; }
.auth__ticks svg { margin-top: var(--pill-y); color: var(--ok); }
.auth__pitch-cta { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-6); }
.auth__pill { border-radius: var(--radius-pill); }
@media (max-width: 960px) {
  .auth--split { grid-template-columns: minmax(0, var(--w-auth)); gap: var(--sp-6); padding-block: var(--sp-6); }
  .auth--split .auth__card { order: -1; }
}
.file-row__meta { color: var(--ink-3); font-size: var(--text-xs); }

/* ── Узкий экран ─────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; gap: var(--sp-6); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    z-index: 25;
    width: min(var(--sidebar-w), 86vw);
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease-out);
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .mobilebar { display: flex; }
  .page { padding: var(--sp-6) var(--sp-4) var(--sp-7); }
  .page-head { margin-bottom: var(--sp-6); }
  .page-title { font-size: var(--text-display-sm); }
  .thread__head { justify-content: flex-end; padding: var(--sp-2) var(--sp-4); }
  /* заголовок темы уже стоит в верхней панели: прячем визуально, диктор его читает */
  .thread__title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .thread__inner { padding: var(--sp-5) var(--sp-4); }
  .thread__foot { padding: 0 var(--sp-3) var(--sp-3); }
  .q__bubble { max-width: 94%; }
  .form-grid { grid-template-columns: 1fr; }
  .composer__hint { display: none; }
  .picker__btn .picker__label { display: none; }
  .composer__bar { min-width: 0; }
  .picker__menu { width: min(var(--w-menu), calc(100vw - var(--sp-6))); }
  .drop { flex-direction: column; align-items: flex-start; }
}

/* На широком экране меню не выезжает, затемнение не нужно и не должно ловить клики */
@media (min-width: 861px) {
  .scrim { display: none; }
}
