/* Agent Hub — визуальный слой журнала работ.
   Лежит поверх work-log.css: разметка и семантика не меняются, поэтому один и
   тот же файл оформляет Mini App в Telegram и панель расширения VS Code.

   Тема задаётся атрибутом html[data-theme]; без него действует «Орбита».
   Здесь остаётся только общая геометрия интерфейса. Палитры, текстуры и
   специфичные эффекты находятся в самодостаточных пакетах `themes/<id>`. */

:root {
  color-scheme: dark;

  /* ---- типографика ---- */
  --font-body: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto,
    "Helvetica Neue", sans-serif;
  --font-display: var(--font-body);
  --font-title: var(--font-display);
  --font-numeric: var(--font-body);
  --display-weight: 620;
  --display-spacing: -0.02em;
  --display-transform: none;
  --display-shadow: none;
  --title-weight: 545;
  --label-spacing: 0.15em;
  --label-transform: uppercase;
  /* Подпись поля в модальных карточках. До этого карточка Stream писала
     подписи 0.83rem, Workspace — 0.72rem, задача — 0.68rem, и одинаковые по
     смыслу строки выглядели тремя разными уровнями. */
  --card-label-size: 0.78rem;

  /* Заголовок секции: один источник истины для «ПАРАМЕТРЫ», «ДЕЙСТВИЯ» и
     заголовков вложенных блоков карточки. Тема переопределяет эти токены, а
     не каждое место по отдельности. */
  --section-heading-family: var(--font-title);
  --section-heading-size: 0.63rem;
  --section-heading-weight: 700;
  --section-heading-spacing: 0.18em;
  --section-heading-transform: uppercase;
  --section-heading-color: var(--text-faint);

  /* ---- геометрия ---- */
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;
  --radius-chip: 999px;
  --rail-width: 2px;

  /* ---- поверхности ---- */
  --bg: #080b11;
  --surface-1: rgba(255, 255, 255, 0.026);
  --surface-2: rgba(255, 255, 255, 0.045);
  --surface-3: rgba(255, 255, 255, 0.07);
  --sunken: rgba(0, 0, 0, 0.18);

  --line: rgba(150, 178, 214, 0.13);
  --line-strong: rgba(150, 178, 214, 0.24);

  --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.016));
  --card-bg-open: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  --card-texture: none;
  --card-border: var(--line);
  --card-border-open: var(--line-strong);
  --card-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 18px 40px -26px rgba(0, 0, 0, 0.9);

  --plate-bg: var(--surface-2);
  --plate-texture: none;
  --plate-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --turn-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);

  /* ---- текст ---- */
  --text: #e9eff8;
  --text-soft: #b6c3d5;
  --text-muted: #8797ab;
  --text-faint: #667689;

  /* ---- акцент ---- */
  --accent: #6cb2ff;
  --accent-soft: rgba(108, 178, 255, 0.13);
  --accent-line: rgba(108, 178, 255, 0.4);
  --accent-glow: 0 0 18px -8px rgba(108, 178, 255, 0.85);
  --selection: rgba(108, 178, 255, 0.3);
  --brand-gradient: linear-gradient(150deg, rgba(108, 178, 255, 0.28), rgba(126, 78, 190, 0.22));
  --brand-shadow: 0 6px 18px -10px rgba(108, 178, 255, 0.7);

  --provider-none: #8797ab;
  /* Семантическая палитра принадлежит Hub и не меняется вместе с темой. */
  --provider-codex: #6cb2ff !important;
  --provider-claude: #e08a63 !important;
  --task-status-new: #858b94 !important;
  --task-status-in-progress: #4285f4 !important;
  --task-status-testing: #d4a20d !important;
  --task-status-awaiting: #e87823 !important;
  --task-status-done: #2ea44f !important;
  /* Реестр провайдеров владеет только hue. Светлость, хрома и прозрачность
     колонки расхода задаёт активный пакет темы. */
  --provider-codex-hue: 260;
  --provider-claude-hue: 35;
  --provider-tone-lightness: 0.78;
  --provider-tone-chroma: 0.09;
  --provider-tone-alpha: 0.18;
  --comparison-local: #f3f7ff;
  --comparison-deviation: #f0b95b;
  --comparison-cost: #d49cff;

  /* Геометрия Phosphor Icons Regular 2.1.1 для CSS-маркеров раскрытия. */
  --ph-mask-caret-right:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='96 48 176 128 96 208' fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='16'/%3E%3C/svg%3E");
  --ph-mask-caret-double-up:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='48 200 128 120 208 200' fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='16'/%3E%3Cpolyline points='48 120 128 40 208 120' fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='16'/%3E%3C/svg%3E");

  --ok: #4fd08a;
  --pending: #f0b95b;

  /* ---- маркеры категорий расхода ---- */
  --dot-input: #6cb2ff;
  --dot-cache: #62d3b4;
  --dot-output: #f0b95b;
  --dot-think: #b58cf0;

  /* ---- фон ---- */
  --space-glow-a: rgba(56, 124, 196, 0.24);
  --space-glow-b: rgba(126, 78, 190, 0.16);
  --space-base: linear-gradient(180deg, #0d1219 0, var(--bg) 32rem);
  --space-star: rgba(188, 220, 255, 0.32);
  --star-opacity: 0.34;
  --decor-opacity: 1;

  /* ---- раскладка ---- */
  --header-height: 4.15rem;
  --content-width: 92rem;
  --gutter-left: max(0.9rem, env(safe-area-inset-left));
  --gutter-right: max(0.9rem, env(safe-area-inset-right));

  /* work-log.css использует эти переменные для раскрытого хода */
  --vscode-focusBorder: var(--accent);
  --vscode-foreground: var(--text);
}

dialog:not([open]),
[hidden] {
  display: none !important;
}

/* ================================================================== база === */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  min-height: 100%;
  scroll-padding-top: calc(var(--header-height) + 1rem);
  /* Место под вертикальную полосу резервируется всегда: без этого страницы без
     прокрутки шире прокручиваемых, и при переключении разделов вся оболочка
     дёргается на ширину полосы. */
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(115% 55% at 84% -14%, var(--space-glow-a), transparent 60%),
    radial-gradient(85% 50% at 6% -10%, var(--space-glow-b), transparent 58%),
    var(--space-base);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  margin: 0;
  min-height: 100vh;
  padding: 0;
}

/* звёздная пыль — общий слой для всех тем */
body::before {
  background-image:
    radial-gradient(circle, var(--space-star) 0 0.65px, transparent 0.9px),
    radial-gradient(circle, var(--space-star) 0 0.55px, transparent 0.8px);
  background-position: 0 0, 2.7rem 1.8rem;
  background-size: 4.8rem 4.8rem, 6.4rem 6.4rem;
  content: "";
  inset: 0;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
  opacity: var(--star-opacity);
  pointer-events: none;
  position: fixed;
  z-index: 1;
}

/* характерный слой темы */
body::after {
  content: "";
  inset: 0;
  opacity: var(--decor-opacity);
  pointer-events: none;
  position: fixed;
  z-index: 0;
}

/* Отдельная плоскость для полноэкранных атмосферных эффектов. Она остаётся
   между растровым фоном и интерфейсом и не перехватывает ввод. */
.theme-atmosphere {
  display: none;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  z-index: 1;
}

.theme-atmosphere canvas {
  display: block;
  height: 100%;
  opacity: 0;
  transition: opacity 320ms ease;
  width: 100%;
}

::selection {
  background: var(--selection);
}

:focus-visible {
  border-radius: 6px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

* {
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  height: 0.5rem;
  width: 0.5rem;
}

*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-chip);
}

*::-webkit-scrollbar-track {
  background: transparent;
}

a,
[role="link"] {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

[role="link"][aria-disabled="true"] {
  cursor: default;
}

/* ================================================================ шапка === */

.app-header {
  backdrop-filter: var(--shell-header-backdrop-filter, blur(18px) saturate(150%));
  -webkit-backdrop-filter: var(--shell-header-backdrop-filter, blur(18px) saturate(150%));
  background: var(--shell-header-background, color-mix(in srgb, var(--bg) 82%, transparent));
  border-bottom: 1px solid var(--line);
  /* Положение верхней оболочки принадлежит Hub, а не теме: декоративный CSS
     может менять материал панели, но не её высоту или привязку к краю. */
  margin-top: 0 !important;
  padding: var(--shell-header-padding, max(0.55rem, env(safe-area-inset-top)) 0 0.55rem) !important;
  position: sticky !important;
  top: 0 !important;
  transform: none !important;
  z-index: 20;
}

.app-header::after {
  background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
  bottom: -1px;
  content: "";
  height: 1px;
  left: 0;
  opacity: 0.7;
  position: absolute;
  right: 0;
}

.app-header::before {
  border: var(--shell-header-frame-border, 0);
  border-image: var(--shell-header-frame-image, none);
  box-sizing: border-box;
  content: var(--shell-header-frame-content, none);
  filter: var(--shell-header-frame-filter, none);
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 0;
}

.app-header-inner {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: var(--content-width);
  padding-left: var(--gutter-left);
  padding-right: var(--gutter-right);
  position: relative;
  z-index: 1;
}

.brand {
  align-items: center;
  display: flex;
  gap: 0.65rem;
  min-width: 0;
}

.brand-mark {
  align-items: center !important;
  background: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: flex;
  flex: 0 0 auto;
  clip-path: none !important;
  filter: none !important;
  height: var(--shell-brand-mark-size, 2.3rem) !important;
  justify-content: center;
  overflow: visible !important;
  padding: 0 !important;
  rotate: 0deg !important;
  transform: none !important;
  width: var(--shell-brand-mark-size, 2.3rem) !important;
}

.brand-mark::before,
.brand-mark::after {
  content: none !important;
  display: none !important;
}

.brand-mark > img {
  display: block !important;
  height: 100% !important;
  object-fit: contain;
  transform: none !important;
  width: 100% !important;
}

.brand-mark > svg {
  display: none !important;
}

.brand-text {
  min-width: 0;
}

.eyebrow {
  color: var(--text-faint);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: var(--label-spacing);
  margin: 0;
  text-transform: uppercase;
}

h1 {
  font-family: var(--font-title);
  font-size: 1.22rem;
  font-weight: var(--display-weight);
  letter-spacing: var(--display-spacing);
  /* Запас сверху и снизу обязателен для display-шрифтов тем: при 1.15
     контуры Hub, Log, Dash и Stats иногда упирались в overflow-зону строки. */
  line-height: 1.3;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: var(--display-shadow);
  text-transform: var(--display-transform);
  white-space: nowrap;
}

.toolbar {
  align-items: center;
  align-self: var(--shell-toolbar-align-self, auto);
  display: flex;
  flex: 1 1 auto;
  gap: 0.55rem;
  margin-top: var(--shell-toolbar-margin-top, 0);
  min-width: 0;
}

.toolbar .view-settings {
  margin-left: auto;
}

.theme-picker,
.group-picker {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  display: inline-flex;
  font-size: 0.74rem;
  gap: 0.35rem;
  margin-left: auto;
  padding: 0.2rem 0.38rem 0.2rem 0.6rem;
}

.theme-picker-label,
.group-picker-label {
  color: var(--text-faint);
}

.theme-picker select,
.group-picker select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%) calc(100% - 0.72rem) 50% / 0.28rem 0.28rem no-repeat,
    linear-gradient(135deg, var(--accent) 50%, transparent 50%) calc(100% - 0.52rem) 50% / 0.28rem 0.28rem no-repeat,
    var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-chip);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  min-width: 7.3rem;
  padding: 0.18rem 1.15rem 0.18rem 0.55rem;
}

.group-picker select {
  min-width: 7.8rem;
}

.theme-picker option,
.group-picker option {
  background: var(--bg);
  color: var(--text);
}

.connection {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  display: inline-flex;
  font-size: 0.74rem;
  gap: 0.4rem;
  padding: 0.24rem 0.65rem 0.24rem 0.5rem;
  white-space: nowrap;
}

.connection-dot {
  background: var(--pending);
  border-radius: 50%;
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--pending) 16%, transparent);
  flex: 0 0 auto;
  height: 0.42rem;
  width: 0.42rem;
}

.connection[data-connection="online"] .connection-dot {
  animation: pulse 2.4s ease-in-out infinite;
  background: var(--ok);
}

.connection-banner {
  align-items: center;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--surface-2) 92%, transparent);
  border: 0;
  border-radius: var(--radius-chip);
  color: var(--text);
  display: inline-flex;
  flex: 0 1 auto;
  font-size: 0.78rem;
  justify-content: center;
  left: 50%;
  margin: 0;
  max-width: min(42rem, 100%);
  min-height: 2.25rem;
  min-width: 0;
  padding: 0.35rem 0.75rem;
  pointer-events: none;
  position: fixed;
  text-align: center;
  top: max(0.75rem, env(safe-area-inset-top));
  transform: translateX(-50%);
  width: max-content;
  z-index: 50;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--ok) 18%, transparent);
  }

  50% {
    box-shadow: 0 0 0 0.34rem color-mix(in srgb, var(--ok) 4%, transparent);
  }
}

/* ==================================================== лимиты в шапке === */

.rate-limits {
  align-items: center;
  display: inline-flex;
  gap: 0.3rem;
}

.rate-limits [data-rate-limit-group],
.rate-limits [data-rate-limit-credit] {
  align-items: stretch;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  display: inline-flex;
  flex-direction: column;
  gap: 0.16rem;
  padding: 0.3rem 0.62rem;
  white-space: nowrap;
}

/* Подпись нужна только в теле журнала: в шапке чипы говорят сами за себя.
   `strong` — подпись из блоков, записанных прежней версией Hub: они лежат в
   журнале до первого перезапуска и иначе тянули бы в шапку слово «Лимиты:». */
.rate-limits [data-rate-limit-caption],
.rate-limits strong {
  display: none;
}

.rate-limits [data-rate-limit] {
  align-items: baseline;
  display: grid;
  gap: 0.32rem;
  grid-template-columns: minmax(3.6rem, auto) auto auto;
  padding: 0;
  white-space: nowrap;
}

.rate-limits [data-rate-limit-name] {
  color: var(--text-faint);
  font-size: 0.62rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.rate-limits [data-rate-limit-value] {
  color: var(--text);
  font-family: var(--font-numeric);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.rate-limits [data-rate-limit-reset] {
  color: var(--text-muted);
  font-size: 0.68rem;
}

.rate-limits [data-rate-limit-plain] {
  color: var(--text-muted);
  font-size: 0.68rem;
}

.rate-limits [data-rate-limit-credit-count] {
  color: var(--text);
  font-family: var(--font-numeric);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.rate-limits [data-rate-limit-credit-deadline] {
  color: var(--text-muted);
  font-size: 0.68rem;
}

/* Сводка становится кнопкой-триггером диалога истории лимитов. */
.rate-limits.is-interactive {
  border-radius: var(--radius-chip);
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

.rate-limits.is-interactive:hover {
  background: var(--accent-soft);
}

.rate-limits.is-interactive:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
}

/* На среднем десктопном окне все элементы шапки уже не помещаются в одну
   строку, хотя рабочая область чата и двухколоночный журнал ещё удобны.
   Переносим только toolbar, не включая мобильную навигацию и раскладку. */
@media (min-width: 860px) and (max-width: 1119px) {
  .app-header-inner {
    flex-wrap: wrap;
    gap: 0.45rem 0.75rem;
    padding-bottom: 0.45rem;
    padding-top: 0.45rem;
  }

  html[data-view="journal"] .toolbar {
    flex: 1 0 100%;
  }

  html[data-view="chat"] .app-header-inner {
    flex-wrap: nowrap;
  }

  html[data-view="chat"] .view-switch {
    flex: 1 1 auto;
    min-width: 0;
  }

  html[data-view="chat"] .view-tab {
    padding-inline: 0.5rem !important;
  }

  html[data-view="chat"] .view-tab > span {
    display: none;
  }

  html[data-view="chat"] .toolbar {
    flex: 0 0 auto;
    margin-left: 0;
    width: auto;
  }

  html[data-view="chat"] .toolbar .view-settings {
    padding-inline: 0.55rem !important;
  }
}

/* Блок остаётся в теле журнала там, где шапки нет (панель VS Code до
   переноса, печать, fallback): красим его по теме, а не нейтральным серым. */
.journal div[data-work-log-rate-limits] {
  align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
}

.journal div[data-work-log-rate-limits] [data-rate-limit-caption] {
  color: var(--text-faint);
  font-size: 0.64rem;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
}

.journal div[data-work-log-rate-limits] [data-rate-limit] {
  align-items: baseline;
  display: inline-flex;
  gap: 0.32rem;
}

.journal div[data-work-log-rate-limits] [data-rate-limit-name] {
  color: var(--text-soft);
}

.journal div[data-work-log-rate-limits] [data-rate-limit-value] {
  color: var(--text);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

.journal div[data-work-log-rate-limits] [data-rate-limit-reset],
.journal div[data-work-log-rate-limits] [data-rate-limit-plain] {
  color: var(--text-muted);
  font-size: 0.8rem;
}

button {
  font: inherit;
}

.refresh {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.76rem;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem 0.3rem 0.6rem;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.refresh:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: var(--accent-glow);
  color: var(--accent);
}

.refresh:disabled {
  cursor: progress;
  opacity: 0.55;
}

.refresh:disabled .refresh-icon {
  animation: spin 0.9s linear infinite;
}

.refresh-icon {
  height: 0.85rem;
  width: 0.85rem;
}

/* время последнего обновления живёт прямо в кнопке */
.refresh-label {
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================================= полотно дня === */

main {
  margin: 0 auto;
  max-width: var(--content-width);
  padding: 1.1rem var(--gutter-right) max(2.5rem, env(safe-area-inset-bottom)) var(--gutter-left);
  position: relative;
  z-index: 2;
}

.journal {
  min-height: 40vh;
}

.journal[aria-busy="true"]::before {
  animation: shimmer 1.4s ease-in-out infinite;
  background: linear-gradient(100deg, var(--surface-1) 30%, var(--surface-3) 50%, var(--surface-1) 70%);
  background-size: 220% 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  content: "";
  display: block;
  height: 11rem;
}

.journal[aria-busy="true"] > * {
  visibility: hidden;
}

@keyframes shimmer {
  from {
    background-position: 140% 0;
  }

  to {
    background-position: -40% 0;
  }
}

.journal summary,
.journal details {
  -webkit-tap-highlight-color: transparent;
}

.journal details[data-work-log-day-section] {
  backdrop-filter: none;
  background-color: transparent;
  background-image: var(--card-texture), var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  margin: 0 0 0.8rem;
  padding: 0.4rem 0.5rem;
  position: relative;
}

.journal details[data-work-log-day-section][open] {
  background-image: var(--card-texture), var(--card-bg-open);
  border-color: var(--card-border-open);
  padding-bottom: 0.55rem;
}

.journal summary[data-work-log-day] {
  align-items: center;
  border-radius: calc(var(--radius-lg) - 6px);
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  font-size: 1em;
  gap: 0.35rem 0.5rem;
  overflow-x: visible;
  padding: 0.45rem 0.55rem;
  position: relative;
  transition: background 0.16s ease;
}

.journal summary[data-work-log-day]:hover {
  background: var(--surface-2);
}

.journal summary[data-work-log-day]::before,
.journal details[open] > summary[data-work-log-day]::before {
  background: var(--text-muted);
  content: "";
  flex: 0 0 auto;
  height: 0.72rem;
  margin-right: 0.15rem;
  -webkit-mask: var(--ph-mask-caret-right) center / contain no-repeat;
  mask: var(--ph-mask-caret-right) center / contain no-repeat;
  transform-origin: center;
  transition: transform 0.18s ease;
  width: 0.72rem;
}

.journal details[open] > summary[data-work-log-day]::before {
  background: var(--accent);
  transform: rotate(90deg);
}

.journal summary[data-work-log-day] > strong {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
  font-weight: var(--display-weight);
  letter-spacing: var(--display-spacing);
  margin-right: 0.2rem;
  text-shadow: var(--display-shadow);
}

/* дневной итог прижат к дате, детализация — к правому краю */
.journal span[data-day-usage-table] {
  align-items: center;
  border: 0;
  border-radius: 0;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-left: 0;
  overflow: visible;
}

.journal span[data-day-usage-breakdown] {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-left: auto;
}

.journal span[data-day-usage],
.journal span[data-day-usage-part] {
  align-items: baseline;
  background-color: transparent;
  background-image: var(--plate-texture), var(--plate-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  box-shadow: var(--plate-shadow);
  color: var(--text-muted);
  display: inline-flex;
  font-size: 0.75rem;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  width: auto;
}

.journal span[data-day-usage-part]::before {
  align-self: center;
  background: var(--dot, var(--text-faint));
  border-radius: 50%;
  box-shadow: 0 0 8px -1px var(--dot, var(--text-faint));
  content: "";
  flex: 0 0 auto;
  height: 0.36rem;
  margin-right: 0.05rem;
  width: 0.36rem;
}

.journal span[data-day-usage-breakdown] > span[data-day-usage-part]:nth-child(1) {
  --dot: var(--dot-input);
}

.journal span[data-day-usage-breakdown] > span[data-day-usage-part]:nth-child(2) {
  --dot: var(--dot-cache);
}

.journal span[data-day-usage-breakdown] > span[data-day-usage-part]:nth-child(3) {
  --dot: var(--dot-output);
}

.journal span[data-day-usage-breakdown] > span[data-day-usage-part]:nth-child(4) {
  --dot: var(--dot-think);
}

.journal span[data-day-usage] {
  background-color: transparent;
  background-image: linear-gradient(180deg, var(--accent-soft), var(--accent-soft));
  border-color: var(--accent-line);
  box-shadow: var(--plate-shadow), var(--accent-glow);
  color: var(--text-soft);
  font-weight: 600;
  gap: 0.3rem;
}

.journal span[data-work-log-day-duration] {
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==================================================== задача и её ходы === */

.journal details[data-work-log-workspace] {
  background: color-mix(in srgb, var(--surface-1) 54%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--plate-shadow);
  margin: 0.4rem 0 0.7rem;
  overflow: hidden;
}

.journal details[data-work-log-workspace][data-work-log-workspace-kind="system"] {
  border-style: dashed;
}

.journal details[data-work-log-workspace]:not([open]) > :not(summary) {
  display: none !important;
}

.journal summary[data-work-log-workspace-header] {
  align-items: center;
  background: color-mix(in srgb, var(--surface-2) 68%, transparent);
  cursor: pointer;
  display: grid;
  gap: 0.35rem;
  grid-template-columns: 1rem 17.5rem minmax(0, 1fr);
  list-style: none;
  min-height: 2.4rem;
  padding: 0.35rem 0.55rem;
}

.journal details[data-work-log-workspace][open] > summary[data-work-log-workspace-header] {
  border-bottom: 1px solid var(--line);
}

.journal summary[data-work-log-workspace-header]::-webkit-details-marker {
  display: none;
}

.journal summary[data-work-log-workspace-header]::marker {
  content: "";
}

.journal summary[data-work-log-workspace-header]::before {
  color: var(--text-faint);
  content: "›";
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.14s ease;
}

.journal details[data-work-log-workspace][open] > summary[data-work-log-workspace-header]::before {
  transform: rotate(90deg);
}

.journal summary[data-work-log-workspace-header] > strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.88rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal span[data-work-log-workspace-usage] {
  align-items: baseline;
  color: var(--text-muted);
  display: inline-grid;
  font-family: var(--font-numeric);
  font-size: 0.75rem;
  gap: 0.4rem;
  grid-template-columns: 8.6ch 6ch;
  justify-self: start;
  min-width: 0;
  padding: 0.18rem 0.35rem;
}

.journal span[data-work-log-workspace-usage] > span {
  justify-self: end;
  text-align: right;
}

.journal details[data-work-log-workspace-usage-details] {
  position: relative;
}

.journal summary[data-work-log-workspace-usage-summary] {
  align-items: baseline;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-grid;
  font-family: var(--font-numeric);
  font-size: 0.75rem;
  gap: 0.4rem;
  grid-template-columns: 8.6ch 6ch;
  list-style: none;
  padding: 0.18rem 0.35rem;
}

.journal summary[data-work-log-workspace-usage-summary]::-webkit-details-marker {
  display: none;
}

.journal summary[data-work-log-workspace-usage-summary]::marker {
  content: "";
}

.journal summary[data-work-log-workspace-usage-summary] > span {
  justify-self: end;
  text-align: right;
}

.journal span[data-work-log-workspace-usage-breakdown] {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  display: grid;
  left: 0;
  min-width: 17.5rem;
  padding: 0.25rem 0;
  position: absolute;
  top: calc(100% + 0.25rem);
  z-index: 4;
}

.journal span[data-work-log-workspace-usage-part] {
  color: var(--text-muted);
  column-gap: 0.4rem;
  display: grid;
  font-family: var(--font-numeric);
  font-size: 0.75rem;
  grid-template-columns: minmax(0, 1fr) 8.6ch 6ch;
  padding: 0.24rem 0.55rem;
}

.journal span[data-work-log-workspace-usage-part] > span {
  justify-self: end;
  text-align: right;
}

.journal details[data-work-log-stream] + details[data-work-log-stream] {
  border-top: 1px solid var(--line);
}

.journal details[data-work-log-stream] {
  --row-accent: var(--provider-none);
}

.journal [data-work-log-workspace-streams] details[data-work-log-stream] {
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.journal [data-work-log-workspace-streams] details[data-work-log-stream]
  + details[data-work-log-stream] {
  margin-top: 0.38rem;
}

.journal details[data-work-log-stream][data-work-log-provider="codex"] {
  --row-accent: var(--provider-codex);
}

.journal details[data-work-log-stream][data-work-log-provider="claude"] {
  --row-accent: var(--provider-claude);
}

.journal details[data-work-log-stream][open] {
  display: block;
}

.journal details[data-work-log-stream]:not([open]) > :not(summary) {
  display: none !important;
}

.journal summary[data-work-log-stream-summary] {
  align-items: center;
  align-self: start;
  column-gap: 0;
  cursor: pointer;
  display: grid;
  grid-template-columns: 23rem minmax(0, 1fr);
  list-style: none;
  min-width: 0;
  padding: 0.55rem;
  position: static;
}

.journal [data-work-log-workspace-streams] summary[data-work-log-stream-summary] {
  min-height: 2.35rem;
  padding: 0;
}

.journal [data-work-log-workspace-streams] span[data-work-log-stream-title] {
  background: transparent;
  border: 0;
  border-left: var(--rail-width) solid var(--row-accent);
  border-radius: 0;
  box-shadow: none;
  padding: 0.55rem 0.68rem;
}

.journal span[data-work-log-stream-title] {
  align-items: center;
  display: flex;
  gap: 0.7rem;
  justify-content: space-between;
}

.journal span[data-work-log-stream-turn-count] {
  color: var(--text-muted);
  flex: 0 0 auto;
  font-family: var(--font-numeric);
  font-size: 0.72rem;
  font-weight: 400;
}

.journal [data-work-log-workspace-streams] span[data-work-log-stream-usage] {
  padding: 0.48rem 0.65rem;
}

.journal summary[data-work-log-stream-summary]::-webkit-details-marker {
  display: none;
}

.journal summary[data-work-log-stream-summary]::marker {
  content: "";
}

.journal span[data-work-log-stream-title] {
  background-color: transparent;
  background-image:
    linear-gradient(115deg, color-mix(in srgb, var(--row-accent) 10%, transparent), transparent 46%),
    var(--plate-texture),
    var(--plate-bg);
  border: 1px solid var(--line);
  border-left: var(--rail-width) solid var(--row-accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--plate-shadow), -7px 0 18px -14px var(--row-accent);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: var(--title-weight);
  line-height: 1.35;
  overflow: hidden;
  padding: 0.42rem 0.6rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal span[data-work-log-stream-title] a,
.journal span[data-work-log-stream-title] [role="link"],
.journal span[data-work-log-stream-title] button[data-open-task] {
  background: transparent;
  border: 0;
  color: color-mix(in srgb, var(--row-accent) 45%, var(--text));
  cursor: pointer;
  display: block;
  font: inherit;
  overflow: hidden;
  padding: 0;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.journal span[data-work-log-stream-usage] {
  align-items: center;
  color: var(--text-muted);
  gap: 0.45rem;
  display: grid;
  grid-template-columns: minmax(10.75rem, 1fr) 6.2rem 3.2rem;
  font-family: var(--font-numeric);
  font-size: 0.75rem;
  padding: 0.48rem 0.65rem;
  white-space: nowrap;
}

.journal span[data-work-log-stream-usage] > span {
  text-align: left;
}

.journal span[data-work-log-stream-usage] > span:nth-child(n + 2) {
  text-align: right;
}

.journal div[data-work-log-stream-turns] {
  min-width: 0;
  padding: 0 0 0.45rem 1.05rem;
}

.journal [data-work-log-workspace-streams] div[data-work-log-stream-turns] {
  border-top: 1px solid var(--line);
  padding: 0;
}

.journal div[data-work-log-stream-turns] > div[data-work-log-row] {
  display: block;
  padding: 0.15rem 0;
}

.journal div[data-work-log-stream-turns] div[data-work-log-task-cell] {
  display: none;
}

.journal div[data-work-log-task-content]:empty {
  display: none;
}

.journal div[data-work-log-task-content]:empty + div[data-work-log-usage] {
  margin-top: 0;
}

.journal div[data-work-log-table] {
  --work-log-task-card-width: 100%;
}

.journal div[data-work-log-header] {
  border-bottom: 0;
  color: var(--text-faint);
  grid-template-columns: 17.5rem minmax(0, 1fr);
  padding: 0.5rem 0 0.05rem;
}

.journal div[data-work-log-header] > strong {
  font-size: 0.64rem;
  font-weight: 650;
  letter-spacing: var(--label-spacing);
  padding: 0 0.55rem;
  text-transform: var(--label-transform);
}

.journal div[data-work-log-row] {
  --row-accent: var(--provider-none);

  column-gap: 0.4rem;
  grid-template-columns: 17.5rem minmax(0, 1fr);
  padding: 0.15rem 0;
}

.journal div[data-work-log-row][data-work-log-provider="codex"] {
  --row-accent: var(--provider-codex);
}

.journal div[data-work-log-row][data-work-log-provider="claude"] {
  --row-accent: var(--provider-claude);
}

.journal div[data-work-log-body] > div[data-work-log-row] {
  border-bottom: 1px solid var(--line);
}

.journal div[data-work-log-task-cell] {
  align-self: start;
  padding: 0.4rem;
  position: sticky;
  top: calc(var(--header-height) + 0.6rem);
}

.journal div[data-work-log-task-cell] > div[data-work-log-task-content] {
  background-color: transparent;
  background-image:
    linear-gradient(115deg, color-mix(in srgb, var(--row-accent) 10%, transparent), transparent 46%),
    var(--plate-texture),
    var(--plate-bg);
  border: 1px solid var(--line);
  border-left: var(--rail-width) solid var(--row-accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--plate-shadow), -7px 0 18px -14px var(--row-accent);
  font-family: var(--font-display);
  font-weight: var(--title-weight);
  line-height: 1.35;
  overflow: hidden;
  padding: 0.42rem 0.6rem;
  position: relative;
}

.journal div[data-work-log-task-cell] > div[data-work-log-task-content]::after {
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--row-accent) 26%, transparent), transparent);
  content: "";
  height: 1px;
  inset: 0.05rem 12% auto;
  opacity: 0.55;
  pointer-events: none;
  position: absolute;
}

.journal div[data-work-log-task-content] a,
.journal div[data-work-log-task-content] [role="link"] {
  color: color-mix(in srgb, var(--row-accent) 45%, var(--text));
}

.journal div[data-work-log-task-cell] > div[data-work-log-usage] {
  margin-top: 0.32rem;
}

/* Сводка расхода: фиксированные колонки, поэтому единицы и проценты
   выстраиваются в общий столбец у всех строк задачи. */
.journal summary[data-task-usage],
.journal span[data-task-usage-part] {
  column-gap: 0.4rem;
  display: grid;
  font-family: var(--font-numeric);
  font-size: 0.75rem;
  grid-template-columns: minmax(0, 1fr) 8.6ch 6ch;
  padding: 0.24rem 0.55rem;
}

.journal summary[data-task-usage] {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.journal summary[data-task-usage]:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.journal details[data-task-usage-details][open] > summary[data-task-usage] {
  background: var(--surface-2);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.journal span[data-task-usage-breakdown] {
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border-top: 0;
}

.journal span[data-task-usage-part] {
  color: var(--text-muted);
}

.journal summary[data-task-usage] > span,
.journal span[data-task-usage-part] > span {
  justify-self: end;
  text-align: right;
}

.journal summary[data-task-usage] > span[data-work-log-duration-summary] {
  align-items: baseline;
  column-gap: 0.4rem;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) 6ch;
  width: 100%;
}

/* Сводка свёрнутого Workspace всегда занимает одну строку: слева доля времени
   и длительность, справа расход и его доля от расхода дня. */
.journal details[data-work-log-collapsed-workspace-usage-details]
  > summary[data-task-usage] {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.journal details[data-work-log-collapsed-workspace-usage-details]
  > summary[data-task-usage]
  > span[data-work-log-duration-summary] {
  display: contents;
}

.journal details[data-work-log-collapsed-workspace-usage-details]
  > summary[data-task-usage]
  span[data-work-log-duration-percent],
.journal details[data-work-log-collapsed-workspace-usage-details]
  > summary[data-task-usage]
  span[data-work-log-duration] {
  justify-self: start;
  text-align: left;
}

.journal span[data-work-log-duration-summary] > span {
  justify-self: end;
  text-align: right;
}

.journal span[data-work-log-duration] {
  color: var(--text);
  white-space: nowrap;
}

.journal span[data-work-log-duration-percent] {
  color: var(--text-faint);
  white-space: nowrap;
}

.journal span[data-task-usage-part] + span[data-task-usage-part] {
  border-top: 1px solid var(--line);
}

.journal div[data-work-log-turn-list] {
  padding: 0.4rem;
}

.journal div[data-work-log-turn-table] {
  border: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow: visible;
}

.journal div[data-work-log-turn-entry] {
  --row-accent: var(--provider-none);
}

.journal div[data-work-log-turn-entry][data-work-log-turn-provider="codex"] {
  --row-accent: var(--provider-codex);
}

.journal div[data-work-log-turn-entry][data-work-log-turn-provider="claude"] {
  --row-accent: var(--provider-claude);
}

.journal div[data-work-log-turn-table] > div[data-work-log-turn-entry],
.journal div[data-work-log-turn-entry] + div[data-work-log-turn-entry],
.journal div[data-work-log-turn-entry] + div[data-work-log-legacy-outcome],
.journal div[data-work-log-turn-list] > details,
.journal div[data-work-log-previous-turn-list] > div[data-work-log-turn-entry]
  + div[data-work-log-turn-entry] {
  margin: 0;
}

.journal div[data-work-log-turn-children] {
  border-left-color: var(--accent-line);
  gap: 0.35rem;
  margin-left: 1rem;
  padding-left: 0.75rem;
}

.journal details[data-work-log-turn-children-details] {
  margin-top: 0.35rem;
}

.journal details[data-work-log-turn-children-details] > summary {
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  font-size: 0.75rem;
  justify-content: center;
  list-style: none;
  margin-inline: auto;
  padding: 0.3rem 0.75rem;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  width: max-content;
}

.journal details[data-work-log-turn-children-details] > summary:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.journal details[data-work-log-turn-children-details] > summary::-webkit-details-marker {
  display: none;
}

.journal details[data-work-log-turn-children-details] > summary::marker {
  content: "";
}

.journal details[data-work-log-turn-children-details] > summary
  span[data-work-log-turn-children-open] {
  display: none;
}

.journal details[data-work-log-turn-children-details][open] > summary
  span[data-work-log-turn-children-closed] {
  display: none;
}

.journal details[data-work-log-turn-children-details][open] > summary
  span[data-work-log-turn-children-open] {
  display: inline;
}

.journal div[data-work-log-turn-children] > div[data-work-log-turn-entry]::before {
  border-top-color: var(--accent-line);
}

.journal div[data-work-log-turn-entry][data-work-log-turn-depth]:not([data-work-log-turn-depth="0"])
  > details[data-work-log-turn-details] {
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 45%, transparent);
}

/* предыдущие ходы */

.journal details[data-work-log-previous-turns] {
  border-bottom: 0;
  border-top: 0;
  display: block;
}

.journal details[data-work-log-previous-turns] > summary {
  align-items: center;
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  display: flex;
  font-size: 0.75rem;
  gap: 0.35rem;
  justify-content: center;
  margin-inline: auto;
  padding: 0.28rem 0.8rem;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  width: fit-content;
}

/* Переключатель, а не третья карточка: во всю ширину колонки он вставал
   вровень с названием задачи и её расходом, и рамка — единственная во всём
   журнале взятая из --line-strong — читалась ярче самих данных.
   Селектор повторяет форму базового правила из work-log.css: там задан
   `width: 100%` с той же специфичностью, и без `div[…] >` он побеждал. */
.journal div[data-work-log-usage] > button[data-work-log-collapse-turns] {
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: var(--radius-chip);
  box-sizing: border-box;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  margin: 0.35rem auto 0;
  max-width: 100%;
  padding: 0.28rem 0.8rem;
  text-align: center;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  width: fit-content;
}

.journal div[data-work-log-usage] > button[data-work-log-collapse-turns]:hover {
  background: var(--surface-2);
  border-color: var(--accent-line);
  color: var(--accent);
}

.journal details[data-work-log-previous-turns][open] > summary {
  background: transparent;
  border-bottom: 1px dashed var(--line-strong);
  margin-bottom: 0.4rem;
}

.journal details[data-work-log-previous-turns] > summary:hover {
  background: var(--surface-2);
  border-color: var(--accent-line);
  color: var(--accent);
}

.journal div[data-work-log-previous-turn-list] {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0;
}

.journal div[data-work-log-no-previous-turns] {
  border-bottom: 0;
  color: var(--text-faint);
  font-size: 0.75rem;
  padding: 0.15rem 0.2rem;
  text-align: center;
}

/* группировка по задачам */

.journal [data-work-log-task-overview] {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0.65rem 0;
  padding: 0.55rem 0.75rem;
}

.journal [data-work-log-task-groups] {
  display: grid;
  gap: 0.55rem;
}

.journal details[data-work-log-task-group] {
  --row-accent: var(--provider-none);

  background-color: transparent;
  background-image:
    linear-gradient(115deg, color-mix(in srgb, var(--row-accent) 8%, transparent), transparent 42%),
    var(--card-texture),
    var(--surface-1);
  border: 1px solid var(--line);
  border-left: var(--rail-width) solid var(--row-accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow), -8px 0 22px -18px var(--row-accent);
  overflow: hidden;
}

.journal details[data-work-log-task-group][data-work-log-provider="codex"] {
  --row-accent: var(--provider-codex);
}

.journal details[data-work-log-task-group][data-work-log-provider="claude"] {
  --row-accent: var(--provider-claude);
}

.journal summary[data-work-log-task-group-summary] {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 0.5rem 0.7rem;
  grid-template-columns: 0.8rem minmax(0, 1fr) auto;
  list-style: none;
  padding: 0.65rem 0.8rem;
}

.journal summary[data-work-log-task-group-summary]::-webkit-details-marker {
  display: none;
}

.journal summary[data-work-log-task-group-summary]::before {
  background: currentColor;
  color: var(--row-accent);
  content: "";
  grid-column: 1;
  height: 0.7rem;
  -webkit-mask: var(--ph-mask-caret-right) center / contain no-repeat;
  mask: var(--ph-mask-caret-right) center / contain no-repeat;
  transform-origin: center;
  transition: transform 0.18s ease;
  width: 0.7rem;
}

.journal details[data-work-log-task-group][open]
  > summary[data-work-log-task-group-summary]::before {
  transform: rotate(90deg);
}

.journal details[data-work-log-task-group][open]
  > summary[data-work-log-task-group-summary] {
  background: var(--surface-2);
}

.journal [data-work-log-task-group-title] {
  color: var(--text);
  font-family: var(--font-display);
  font-weight: var(--title-weight);
  grid-column: 2;
  min-width: 0;
  overflow-wrap: anywhere;
}

.journal [data-work-log-task-group-title] [data-work-log-task-content] {
  display: contents;
}

.journal [data-work-log-task-group-title] a,
.journal [data-work-log-task-group-title] [role="link"] {
  color: color-mix(in srgb, var(--row-accent) 45%, var(--text));
}

.journal [data-work-log-task-metrics] {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  font-family: var(--font-numeric);
  font-size: 0.75rem;
  gap: 0.3rem 0.75rem;
  grid-column: 3;
  justify-content: flex-end;
}

/* Плашка повторяет дневную сводку: подпись приглушена, значение внутри —
   цветной бейдж той же шкалы, что и в режиме по датам. */
.journal [data-work-log-task-duration],
.journal [data-work-log-task-credits] {
  align-items: baseline;
  background-color: transparent;
  background-image: linear-gradient(180deg, var(--accent-soft), var(--accent-soft));
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-chip);
  box-shadow: var(--plate-shadow);
  color: var(--text-soft);
  display: inline-flex;
  font-weight: 600;
  gap: 0.32rem;
  padding: 0.18rem 0.55rem;
  white-space: nowrap;
}

.journal [data-work-log-task-credits] [data-usage-label],
.journal [data-work-log-task-duration] [data-usage-label] {
  color: var(--text-faint);
  font-size: 0.92em;
  font-weight: 500;
}

.journal [data-work-log-task-unknown-durations] {
  color: var(--pending);
}

.journal [data-work-log-task-unknown-credits] {
  color: var(--pending);
}

.journal [data-work-log-task-profile] {
  align-items: center;
  background:
    radial-gradient(circle at 82% 48%, color-mix(in srgb, var(--row-accent) 13%, transparent), transparent 34%),
    linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 88%, transparent), var(--surface-1));
  border-top: 1px solid var(--line);
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 22rem;
  min-height: 17rem;
  padding: 0.8rem 1rem;
}

/* Author rules below assign display:grid/flex to task-group children. Without
   this explicit closed state they override the browser's native details
   hiding rule and reserve the 17rem profile height behind a collapsed
   summary. Keep the entire task body out of layout until the card is open. */
.journal details[data-work-log-task-group]:not([open]) > :not(summary) {
  display: none !important;
}

.journal [data-work-log-task-profile-copy] {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
}

.journal [data-work-log-task-profile-heading] {
  display: grid;
  gap: 0.25rem;
}

.journal [data-work-log-task-profile-heading] > strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1rem;
}

.journal [data-work-log-task-profile-heading] > span {
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.45;
  max-width: 42rem;
}

.journal [data-work-log-task-profile-values] {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(3, minmax(7rem, 1fr));
}

.journal [data-work-log-task-profile-value] {
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 0.14rem;
  min-width: 0;
  padding: 0.5rem 0.6rem;
}

.journal [data-work-log-task-profile-value] > span {
  color: var(--text-faint);
  font-size: 0.64rem;
  letter-spacing: var(--label-spacing);
  text-transform: var(--label-transform);
}

.journal [data-work-log-task-profile-value] > strong {
  color: var(--text-soft);
  font-family: var(--font-numeric);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.journal [data-work-log-task-profile-value][data-missing] > strong {
  color: var(--pending);
  font-weight: 500;
}

.journal [data-work-log-task-profile-detail] {
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
}

.journal [data-work-log-task-profile-detail] > summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: minmax(0, 1fr) auto;
  list-style: none;
  padding: 0.5rem 0.6rem;
}

.journal [data-work-log-task-profile-detail] > summary::-webkit-details-marker {
  display: none;
}

.journal [data-work-log-task-profile-detail] > summary::after {
  border-bottom: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  color: var(--text-faint);
  content: "";
  grid-column: 3;
  grid-row: 1;
  height: 0.38rem;
  margin-left: 0.12rem;
  transform: rotate(45deg) translateY(-0.08rem);
  transition: transform 0.15s ease;
  width: 0.38rem;
}

.journal [data-work-log-task-profile-detail][open] > summary::after {
  transform: rotate(225deg) translate(-0.08rem, -0.08rem);
}

.journal [data-work-log-task-profile-detail] > summary > span {
  color: var(--text-faint);
  font-size: 0.64rem;
  letter-spacing: var(--label-spacing);
  text-transform: var(--label-transform);
}

.journal [data-work-log-task-profile-detail] > summary > strong {
  color: var(--text-soft);
  font-family: var(--font-numeric);
  font-size: 0.78rem;
}

.journal [data-work-log-task-profile-detail][data-missing] > summary > strong {
  color: var(--pending);
  font-weight: 500;
}

.journal [data-work-log-task-profile-detail-content] {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.45rem;
  padding: 0.55rem 0.6rem 0.65rem;
}

.journal [data-work-log-task-profile-detail-items] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}

.journal [data-work-log-task-profile-detail-items] > span {
  background: color-mix(in srgb, var(--row-accent) 10%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--row-accent) 28%, var(--line));
  border-radius: var(--radius-chip);
  color: var(--text-soft);
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 0.26rem 0.45rem;
}

.journal [data-work-log-task-profile-detail-empty],
.journal [data-work-log-task-profile-detail-note] {
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.journal [data-work-log-task-profile-detail-note] {
  color: var(--pending);
}

.journal figure[data-work-log-task-radar] {
  margin: 0;
  min-width: 0;
  position: relative;
}

.journal figure[data-work-log-task-radar] svg {
  display: block;
  height: auto;
  max-height: 15rem;
  overflow: visible;
  width: 100%;
}

.journal [data-radar-ring] {
  fill: none;
  stroke: color-mix(in srgb, var(--row-accent) 18%, var(--line));
  stroke-width: 1;
}

.journal [data-radar-spoke] {
  stroke: color-mix(in srgb, var(--row-accent) 14%, var(--line));
  stroke-width: 1;
}

.journal [data-radar-baseline] {
  fill: color-mix(in srgb, var(--text-muted) 5%, transparent);
  stroke: color-mix(in srgb, var(--text-muted) 70%, transparent);
  stroke-dasharray: 4 5;
  stroke-width: 1.2;
}

.journal [data-radar-current] {
  fill: color-mix(in srgb, var(--row-accent) 20%, transparent);
  filter: drop-shadow(0 0 9px color-mix(in srgb, var(--row-accent) 30%, transparent));
  stroke: color-mix(in srgb, var(--row-accent) 82%, var(--text));
  stroke-linejoin: round;
  stroke-width: 2;
}

.journal [data-radar-point] {
  fill: var(--surface-1);
  stroke: color-mix(in srgb, var(--row-accent) 82%, var(--text));
  stroke-width: 2;
}

.journal [data-radar-point][data-missing] {
  opacity: 0.25;
}

.journal [data-radar-hit] {
  cursor: help;
  fill: transparent;
  outline: none;
  pointer-events: all;
  stroke: transparent;
}

.journal [data-radar-hit]:focus {
  stroke: color-mix(in srgb, var(--row-accent) 55%, transparent);
  stroke-width: 1.5;
}

.journal [data-radar-label] {
  cursor: help;
  fill: var(--text-muted);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 620;
}

.journal [data-radar-tooltip] {
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--surface-2) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--row-accent) 45%, var(--line));
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow), 0 0 18px color-mix(in srgb, var(--row-accent) 18%, transparent);
  color: var(--text-soft);
  display: grid;
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  gap: 0.16rem;
  left: var(--radar-tooltip-x);
  max-width: 13rem;
  min-width: 9.5rem;
  padding: 0.48rem 0.58rem;
  pointer-events: none;
  position: absolute;
  top: var(--radar-tooltip-y);
  transform: translate(-50%, calc(-100% - 0.65rem));
  z-index: 3;
}

.journal [data-radar-tooltip][hidden] {
  display: none;
}

.journal [data-radar-tooltip] > strong {
  color: color-mix(in srgb, var(--row-accent) 76%, var(--text));
  font-family: var(--font-display);
  font-size: 0.72rem;
}

.journal [data-radar-tooltip] > span {
  white-space: nowrap;
}

.journal figure[data-work-log-task-radar] figcaption {
  align-items: center;
  color: var(--text-faint);
  display: flex;
  font-size: 0.66rem;
  gap: 1rem;
  justify-content: center;
}

.journal [data-radar-legend]::before {
  border: 1px solid currentColor;
  border-radius: 999px;
  content: "";
  display: inline-block;
  height: 0.48rem;
  margin-right: 0.35rem;
  vertical-align: -0.04rem;
  width: 0.9rem;
}

.journal [data-radar-legend="current"] {
  color: color-mix(in srgb, var(--row-accent) 82%, var(--text));
}

.journal [data-radar-legend="current"]::before {
  background: color-mix(in srgb, var(--row-accent) 35%, transparent);
}

.journal [data-radar-legend="baseline"]::before {
  border-style: dashed;
}

.journal [data-work-log-task-group-turns] {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.55rem;
}

.journal [data-work-log-task-show-more] {
  align-self: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-chip);
  color: var(--text-soft);
  cursor: pointer;
  font: 600 0.74rem/1 var(--font-display);
  margin: 0.2rem 0;
  padding: 0.55rem 1rem;
}

.journal [data-work-log-task-show-more]:hover {
  border-color: var(--accent-line);
  color: var(--text);
}

.journal [data-work-log-turn-day] {
  color: var(--row-accent, var(--accent));
  font-weight: 620;
}

.journal [data-work-log-grouped-legacy] {
  display: grid;
  gap: 0.3rem;
}

html:is([data-grouping="stream"], [data-grouping="workspace"])
  .journal
  details[data-work-log-turn-details]
  > summary {
  grid-template-columns: 17rem minmax(0, 1fr);
}

@media (max-width: 860px) {
  .journal [data-work-log-task-profile] {
    grid-template-columns: 1fr;
  }

  .journal figure[data-work-log-task-radar] {
    justify-self: center;
    max-width: 24rem;
    width: 100%;
  }
}

/* карточка хода */

.journal details[data-work-log-turn-details] {
  background-color: transparent;
  background-image: var(--plate-texture), linear-gradient(180deg, var(--surface-1), var(--surface-1));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.journal details[data-work-log-turn-details]:hover {
  background-color: var(--surface-2);
  border-color: var(--line-strong);
  box-shadow: var(--turn-shadow);
}

.journal details[data-work-log-turn-details][open] {
  background-color: var(--surface-2);
  border: 1px solid var(--accent-line);
  box-shadow: inset var(--rail-width) 0 0 var(--accent), var(--turn-shadow);
}

/* Третья колонка была рассчитана на одну кнопку; со значком субагентов их
   стало две, поэтому под действия отводится авторазмер. */
.journal details[data-work-log-turn-details] > summary {
  align-items: center;
  grid-template-columns: 11.5rem minmax(0, 1fr) auto auto;
}

/* только снятие оформления work-log.css — без свойств, которые ниже
   переопределяются медиазапросами (специфичность [open] выше) */
.journal details[data-work-log-turn-details][open] > summary {
  background: transparent;
  border-bottom: 0;
}

/* Кнопка открытия хода: вместо глифа «↗» — иконка того же набора, что и в
   остальной оболочке, и оформление по токенам темы вместо серого из
   work-log.css. */
.journal details[data-work-log-turn-details] > summary > button[data-open-turn] {
  border-left-color: var(--line);
  color: var(--text-faint);
  justify-content: center;
  padding: 0.3rem 0.45rem;
  transition: background 0.14s ease, color 0.14s ease;
}

.journal details[data-work-log-turn-details] > summary > button[data-open-turn] svg {
  height: 1.05rem;
  width: 1.05rem;
}

.journal details[data-work-log-turn-details] > summary > button[data-open-turn]:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Субагенты раскрываются кнопкой в строке хода, поэтому собственная строка
   «Показать субагентов» больше не нужна — она остаётся только для чтения с
   экрана. */
.journal details[data-work-log-turn-details] > summary > button[data-toggle-subagents] {
  align-items: center;
  background: none;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--text-faint);
  cursor: pointer;
  display: inline-flex;
  gap: 0.22rem;
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  justify-content: center;
  padding: 0.3rem 0.42rem;
  transition: background 0.14s ease, color 0.14s ease;
}

.journal details[data-work-log-turn-details] > summary > button[data-toggle-subagents] svg {
  height: 0.95rem;
  width: 0.95rem;
}

.journal details[data-work-log-turn-details] > summary > button[data-toggle-subagents]:hover,
.journal details[data-work-log-turn-details] > summary > button[data-toggle-subagents][aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.journal details[data-work-log-turn-children-details] > summary {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.journal span[data-work-log-turn-meta] {
  color: var(--text-muted);
  font-family: var(--font-numeric);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  gap: 0.45rem;
  padding: 0.42rem 0.6rem;
}

.journal span[data-work-log-turn-share] {
  color: var(--text-muted);
}

.journal span[data-work-log-turn-title] {
  align-items: center;
  border-left: 1px solid var(--line);
  color: var(--text);
  display: flex;
  font-weight: var(--title-weight);
  gap: 0.5rem;
  min-width: 0;
  padding: 0.42rem 0.7rem;
}

.journal span[data-work-log-turn-stream] {
  background: color-mix(in srgb, var(--row-accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--row-accent) 35%, var(--line));
  border-radius: 999px;
  color: color-mix(in srgb, var(--row-accent) 72%, var(--text));
  flex: 0 1 auto;
  font-family: var(--font-numeric);
  font-size: 0.67rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  max-width: min(12rem, 38%);
  overflow: hidden;
  padding: 0.12rem 0.42rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal span[data-work-log-turn-heading] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Раскрытый ход: полоса «Длит. + Запрос» сверху, ответ на всю ширину снизу —
   длинный запрос не сжимается в узкую колонку. */

.journal div[data-work-log-turn-expanded] {
  animation: reveal 0.18s ease;
  border-top: 1px solid var(--line);
  display: block;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-0.2rem);
  }
}

.journal div[data-work-log-turn-meta-details] {
  background: var(--sunken);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.5rem;
  padding: 0.5rem 0.75rem;
}

.journal div[data-work-log-turn-body-details] {
  border-left: 0;
  padding: 0.6rem 0.75rem 0.7rem;
}

/* «Свой расход» стоит в том же столбце фактов, что модель и длительность,
   поэтому и выглядит так же: мелкая подпись над значением. */
.journal div[data-work-log-turn-context],
.journal div[data-work-log-turn-own-usage],
.journal div[data-work-log-turn-prompt] {
  color: var(--text-soft);
  font-size: 0.8rem;
}

.journal div[data-work-log-turn-context] > strong,
.journal div[data-work-log-turn-own-usage] > strong,
.journal div[data-work-log-turn-prompt] > strong {
  color: var(--text-faint);
  display: block;
  font-size: 0.68rem;
  font-weight: 620;
  letter-spacing: 0.02em;
  margin-bottom: 0.05rem;
}

.journal div[data-work-log-turn-facts] {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 7rem;
}

/* Модель идёт без подписи над длительностью и остаётся служебной справкой. */
.journal div[data-work-log-turn-pricing] {
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.01em;
}

.journal div[data-work-log-turn-prompt] {
  border-left: 2px solid var(--line-strong);
  flex: 1 1 24rem;
  margin-top: 0;
  opacity: 1;
  padding-left: 0.55rem;
}

.journal div[data-work-log-turn-body] {
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

.journal div[data-work-log-turn-files] {
  display: none;
}

.journal div[data-work-log-turn-files] a,
.journal div[data-work-log-turn-files] [role="link"] {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.14rem 0.5rem;
}

.journal div[data-work-log-turn-files] a:hover {
  border-color: var(--accent-line);
  color: var(--accent);
  text-decoration: none;
}

.journal details[data-work-log-turn-diff] {
  margin-top: 0.7rem;
}

.journal details[data-work-log-turn-diff] > summary {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.75rem;
  gap: 0.35rem;
  list-style: none;
  padding: 0.25rem 0.65rem;
}

.journal details[data-work-log-turn-diff] > summary::-webkit-details-marker {
  display: none;
}

.journal details[data-work-log-turn-diff] > summary::before {
  background: currentColor;
  content: "";
  height: 0.65rem;
  -webkit-mask: var(--ph-mask-caret-right) center / contain no-repeat;
  mask: var(--ph-mask-caret-right) center / contain no-repeat;
  transform-origin: center;
  transition: transform 0.18s ease;
  width: 0.65rem;
}

.journal details[data-work-log-turn-diff][open] > summary::before {
  transform: rotate(90deg);
}

.journal details[data-work-log-turn-diff] pre {
  background: color-mix(in srgb, var(--surface-0) 92%, #000);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  box-sizing: border-box;
  color: var(--text-muted);
  font-family: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
  margin: 0.5rem 0 0;
  max-height: 32rem;
  overflow: auto;
  padding: 0.55rem 0;
  white-space: pre;
  width: 100%;
}

.journal span[data-work-log-diff-line] {
  display: block;
  min-height: 1.45em;
  padding: 0 0.7rem;
}

.journal span[data-work-log-diff-line="file"] {
  color: #8ecbff;
  font-weight: 650;
}

.journal span[data-work-log-diff-line="hunk"] {
  background: rgba(49, 131, 189, 0.2);
  color: #9cdcfe;
}

.journal span[data-work-log-diff-line="added"] {
  background: rgba(46, 160, 67, 0.2);
  color: #b7f5c5;
}

.journal span[data-work-log-diff-line="removed"] {
  background: rgba(248, 81, 73, 0.18);
  color: #ffc1bd;
}

.journal div[data-work-log-legacy-outcome] {
  background: var(--sunken);
  border: 1px solid var(--line);
  border-left: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.5;
  padding: 0.5rem 0.7rem;
}

/* ==================================================== расход в credits === */

.journal span[data-kilo-usage],
.journal span[data-mega-usage],
.journal span[data-high-usage] {
  border-radius: calc(var(--radius-sm) - 3px);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  padding: 0.02rem 0.28rem;
  white-space: nowrap;
}

.journal span[data-kilo-usage] {
  background: rgba(229, 192, 123, 0.11);
  box-shadow: inset 0 0 0 1px rgba(229, 192, 123, 0.18);
}

.journal span[data-mega-usage] {
  background: rgba(255, 157, 0, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 157, 0, 0.2);
}

.journal span[data-high-usage] {
  background: rgba(241, 76, 76, 0.13);
  box-shadow: inset 0 0 0 1px rgba(241, 76, 76, 0.24);
}

/* В новом журнальном ledger расход читается как число, а не как отдельный badge. */
.journal-ledger .journal span[data-kilo-usage],
.journal-ledger .journal span[data-mega-usage],
.journal-ledger .journal span[data-high-usage] {
  background: transparent;
  box-shadow: none;
  padding-left: 0;
  padding-right: 0;
}

.journal span[data-usage-percent] {
  color: var(--text-muted);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}

/* ============================================== нестандартные случаи === */

[data-mini-app-fallback] {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font: inherit;
  margin: 0;
  overflow-wrap: anywhere;
  padding: 1rem;
  white-space: pre-wrap;
}

[data-mini-app-empty] {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  padding: 3rem 1rem;
  text-align: center;
}

/* «Rain»: дождь из отдельных капель.
   Три попытки сделать дождь плиткой провалились по одной причине: любой
   `background-repeat` повторяет один рисунок, и глаз читает регулярность как
   мелкую текстуру. Сначала это были длинные палки, потом горизонтальные
   жалюзи, затем ровные вертикальные дорожки. Капли создаёт app.js — каждая со
   своей позицией, длиной, толщиной, прозрачностью и скоростью, поэтому узора
   нет вообще. Слой наклонён целиком, а анимируется только transform. */
.rain {
  /* `contain: strict` включает `contain: size` и обнуляет слой вместе с
     каплями — здесь достаточно ограничить только отрисовку. */
  contain: paint;
  inset: -14% -18%;
  /* светлые капли на тёмном лесу иначе почти не читаются */
  mix-blend-mode: screen;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  transform: none;
  /* На фоновой фотографии дождь идёт почти отвесно, но при падении немного
     смещается вправо. Направление задаётся в rain-fall явным сдвигом по X,
     чтобы анимация не расходилась с уже нарисованными полосами дождя.
     Фон темы рисует body::after с z-index 0, а рабочая область идёт на 2:
     на нулевом слое дождь оказывался под фоном и не был виден вовсе. */
  z-index: 1;
}

.rain > span {
  animation: rain-fall var(--dur) linear infinite;
  animation-delay: var(--delay);
  background: linear-gradient(180deg,
    rgba(226, 244, 246, 0) 0,
    rgba(226, 244, 246, var(--alpha)) 42%,
    rgba(226, 244, 246, calc(var(--alpha) * 0.5)) 100%);
  border-radius: 999px;
  height: var(--len);
  left: var(--x);
  position: absolute;
  top: 0;
  width: var(--thickness);
}

/* Ливень темы «Storm»: круче наклон, больше запас по краям и своя
   траектория — струи должны пересекать кадр насквозь. */
.rain.downpour {
  inset: -20% -26%;
  opacity: 0.9;
}

.rain.downpour > span {
  animation-name: downpour-fall;
}

@keyframes downpour-fall {
  from { transform: translate3d(-3vw, -24vh, 0) rotate(-7deg); }
  to { transform: translate3d(9vw, 132vh, 0) rotate(-7deg); }
}

@keyframes rain-fall {
  from { transform: translate3d(-1vw, -18vh, 0) rotate(-1.5deg); }
  to { transform: translate3d(3vw, 128vh, 0) rotate(-1.5deg); }
}

/* «Gothic»: пыль в свете факела.
   Та же причина, что и у дождя: плитка читалась как узор. Каждая пылинка —
   отдельный элемент, поднимается снизу вверх со своей скоростью и слегка
   виляет вбок, появляясь и растворяясь на краях пути. */
.motes {
  contain: paint;
  inset: 0;
  /* тёплая пыль осветляет камень, а не закрашивает его */
  mix-blend-mode: screen;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  /* слева в кадре лунный проём: тёплые частицы там были бы чужими */
  -webkit-mask-image: linear-gradient(90deg, transparent 0 26%, rgba(0, 0, 0, 0.45) 50%, #000 78%);
  mask-image: linear-gradient(90deg, transparent 0 26%, rgba(0, 0, 0, 0.45) 50%, #000 78%);
  z-index: 1;
}

.motes > span {
  animation: mote-rise var(--dur) linear infinite;
  animation-delay: var(--delay);
  background: radial-gradient(circle,
    rgba(255, 238, 202, var(--alpha)) 0 26%,
    rgba(255, 198, 118, calc(var(--alpha) * 0.32)) 58%,
    transparent 100%);
  border-radius: 50%;
  bottom: -4%;
  height: var(--size);
  left: var(--x);
  opacity: 0;
  position: absolute;
  width: var(--size);
}

@keyframes mote-rise {
  0% { opacity: 0; transform: translate3d(0, 0, 0); }
  9% { opacity: 1; }
  27% { transform: translate3d(var(--drift), -27vh, 0); }
  52% { transform: translate3d(0, -52vh, 0); }
  76% { transform: translate3d(calc(var(--drift) * -1), -76vh, 0); }
  90% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(0, -106vh, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .motes,
  .rain {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none !important;
  }
}

/* =========================================================== адаптивность === */

@media (max-width: 1100px) {
  .journal div[data-work-log-header],
  .journal div[data-work-log-row] {
    grid-template-columns: 15rem minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .journal details[data-work-log-turn-details] > summary {
    grid-template-columns: 10rem minmax(0, 1fr) auto auto;
  }
}

html[data-surface="mobile"] body {
  font-size: 14px;
}

/* На телефоне «Показать ещё» остаётся полноценной сенсорной целью, даже
   когда сама подпись короткая. */
html[data-surface="mobile"] .msg-disclosure {
  min-height: 2.75rem;
  padding: 0.35rem 0.2rem;
  touch-action: manipulation;
}

html[data-surface="mobile"] {
  --header-height: 3.75rem;
}

html[data-surface="mobile"] .brand-mark {
  height: 2.05rem !important;
  width: 2.05rem !important;
}

html[data-surface="mobile"] h1 {
  font-size: 1.06rem;
}

/* Шапка на телефоне выстраивалась в колонку и вместе с надписью «Agent Hub»
   занимала до 300 px — больше трети экрана. Теперь это одна строка с брендом
   и кнопками, а лимиты с выбором темы переносятся во вторую только когда не
   влезают. */
html[data-surface="mobile"] .app-header-inner {
  align-items: center;
  box-sizing: border-box;
  column-gap: 0.45rem;
  flex-direction: row;
  flex-wrap: wrap;
  row-gap: 0.4rem;
  width: 100%;
}

html[data-surface="mobile"] .eyebrow {
  display: none;
}

/* В модальных карточках надзаголовок не дублирует нижнюю навигацию, а у
   карточки Stream он вообще единственное название окна, поэтому на телефоне
   шапка карточки остаётся подписанной. */
html[data-surface="mobile"] .dialog-settings-head .eyebrow,
html[data-surface="mobile"] .workspace-card-modal .eyebrow,
html[data-surface="mobile"] .workspace-archive-modal .eyebrow,
html[data-surface="mobile"] .task-card-modal .eyebrow,
html[data-surface="mobile"] .task-start-modal .eyebrow {
  display: block;
}

/* Название раздела на телефоне дублирует подписанную вкладку нижней
   навигации, поэтому из шапки оно убирается визуально, но остаётся в
   структуре страницы для скринридера. */
html[data-surface="mobile"] .brand-text {
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

html[data-surface="mobile"] .brand {
  flex: 0 1 auto;
  min-width: 0;
}

html[data-surface="mobile"] .theme-picker-label {
  display: none;
}

/* Подпись кнопки занимала треть строки, поэтому на телефоне остаётся только
   глиф; полное название доступно в title и для скринридера в тексте кнопки. */
html[data-surface="mobile"] .collapse-all {
  font-size: 0.86rem;
  justify-content: center;
  line-height: 1;
  min-width: 2.1rem;
  padding: 0.3rem 0.45rem;
}

html[data-surface="mobile"] .collapse-all > span {
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

html[data-surface="mobile"] .collapse-all::before {
  background: currentColor;
  content: "";
  display: block;
  height: 0.9rem;
  -webkit-mask: var(--ph-mask-caret-double-up) center / contain no-repeat;
  mask: var(--ph-mask-caret-double-up) center / contain no-repeat;
  width: 0.9rem;
}

/* flex-basis: 0 обязателен: с `auto` панель считалась по max-content и целиком
   переносилась под бренд, оставляя первую строку почти пустой. */
html[data-surface="mobile"] .toolbar {
  box-sizing: border-box;
  flex: 1 1 0;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  min-width: 0;
}

html[data-surface="mobile"] .connection-banner {
  max-width: 100%;
}

html[data-surface="mobile"] .theme-picker {
  box-sizing: border-box;
  margin-left: 0;
  max-width: 100%;
}

html[data-surface="mobile"] .theme-picker select,
html[data-surface="mobile"] .theme-picker .themed-select {
  max-width: min(6.6rem, 38vw);
  min-width: 0;
  width: 6.6rem;
}

html[data-surface="mobile"] .rate-limits {
  margin-left: 0;
  min-width: 0;
}

/* Два лимита стояли столбиком и вместе с блоком сбросов забирали в шапке
   целую строку. На телефоне они идут в ряд, а сбросы уходят в историю
   лимитов — она открывается тапом по этому же чипу. */
html[data-surface="mobile"] .rate-limits [data-rate-limit-group] {
  flex-direction: row;
  gap: 0.5rem;
  padding: 0.26rem 0.5rem;
}

html[data-surface="mobile"] .rate-limits [data-rate-limit-credit] {
  display: none;
}

/* на телефоне из чипа остаётся только имя и процент: срок сброса не влезает */
html[data-surface="mobile"] .rate-limits [data-rate-limit-reset],
html[data-surface="mobile"] .rate-limits [data-rate-limit-plain] {
  display: none;
}

html[data-surface="mobile"] .refresh {
  padding: 0.3rem 0.55rem;
}

html[data-surface="mobile"] main {
  padding-top: 0.85rem;
}

html[data-surface="mobile"] .journal summary[data-work-log-day] > strong {
  font-size: 0.95rem;
}

html[data-surface="mobile"] .journal span[data-day-usage-table] {
  margin-left: 0;
  min-width: 0;
}

html[data-surface="mobile"] .journal span[data-day-usage-breakdown] {
  flex-basis: 100%;
  margin-left: 0;
  margin-top: 0.3rem;
}

html[data-surface="mobile"] .journal details[data-work-log-day-section] {
  padding: 0.35rem 0.4rem;
}

html[data-surface="mobile"] .journal div[data-work-log-header] {
  display: none;
}

html[data-surface="mobile"] .journal span[data-work-log-workspace-usage-breakdown] {
  left: auto;
  min-width: min(17.5rem, calc(100vw - 2.5rem));
  right: 0;
}

html[data-surface="mobile"] .journal div[data-work-log-row] {
  display: block;
  padding: 0.35rem 0 0.5rem;
}

html[data-surface="mobile"] .journal div[data-work-log-task-cell] {
  padding: 0.2rem;
  position: static;
}

html[data-surface="mobile"] .journal div[data-work-log-turn-list] {
  padding: 0.2rem;
}

html[data-surface="mobile"] .journal details[data-work-log-turn-details] > summary {
  grid-template-columns: 9rem minmax(0, 1fr);
}

html[data-surface="mobile"] .journal span[data-work-log-turn-meta] {
  font-size: 0.75rem;
  gap: 0.25rem;
}

/* Мобильный профиль: сводки находятся в заголовках, содержимое раскрывается
   самими заголовками без промежуточных кнопок. */
html[data-surface="mobile"] .journal summary[data-work-log-day] {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

html[data-surface="mobile"] .journal span[data-day-usage-table] {
  display: contents;
}

html[data-surface="mobile"] .journal span[data-day-usage] {
  cursor: pointer;
  grid-column: 3;
  justify-self: end;
}

html[data-surface="mobile"] .journal [data-usage-label] {
  display: none;
}

html[data-surface="mobile"] .journal span[data-day-usage-breakdown] {
  display: none;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0.35rem 0 0;
  width: 100%;
}

html[data-surface="mobile"]
  .journal
  span[data-day-usage-table][data-mobile-expanded]
  > span[data-day-usage-breakdown] {
  display: grid;
}

html[data-surface="mobile"] .journal span[data-day-usage-part] {
  box-sizing: border-box;
  display: grid;
  column-gap: 0.3rem;
  grid-template-columns: auto minmax(3.15rem, 1fr) 7.4ch 5ch;
  justify-content: stretch;
  width: 100%;
}

html[data-surface="mobile"] .journal span[data-day-usage-part] > span {
  justify-self: end;
  text-align: right;
}

html[data-surface="mobile"] .journal div[data-work-log-task-cell] {
  align-items: stretch;
  cursor: pointer;
  display: grid;
  gap: 0.32rem;
  grid-template-columns: minmax(0, 1fr) auto;
}

html[data-surface="mobile"]
  .journal
  div[data-work-log-task-cell]
  > div[data-work-log-task-content] {
  grid-column: 1;
  grid-row: 1;
}

html[data-surface="mobile"] .journal div[data-work-log-task-cell] > div[data-work-log-usage],
html[data-surface="mobile"] .journal details[data-task-usage-details] {
  display: contents;
}

html[data-surface="mobile"] .journal summary[data-task-usage] {
  align-self: stretch;
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: 8.6ch 5ch;
  margin: 0;
  width: auto;
}

html[data-surface="mobile"] .journal span[data-task-usage-breakdown] {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
}

html[data-surface="mobile"] .journal div[data-work-log-turn-list] {
  display: none;
}

html[data-surface="mobile"]
  .journal
  div[data-work-log-row][data-mobile-open]
  > div[data-work-log-turn-list] {
  display: block;
}

html[data-surface="mobile"] .journal details[data-work-log-previous-turns] > summary,
html[data-surface="mobile"] .journal button[data-work-log-collapse-turns],
html[data-surface="mobile"] .journal button[data-work-log-collapse-turns][hidden],
html[data-surface="mobile"] .journal div[data-work-log-no-previous-turns] {
  display: none !important;
}

html[data-surface="mobile"] .journal div[data-work-log-previous-turn-list] {
  padding-top: 0;
}

html[data-surface="mobile"] .journal div[data-work-log-turn-children] {
  margin-left: 0.45rem;
  padding-left: 0.45rem;
}

html[data-surface="mobile"] .journal div[data-work-log-turn-children]
  > div[data-work-log-turn-entry]::before {
  left: -0.45rem;
  width: 0.38rem;
}

html[data-surface="mobile"] .journal summary[data-work-log-task-group-summary] {
  align-items: start;
  grid-template-columns: 0.8rem minmax(0, 1fr);
}

html[data-surface="mobile"] .journal [data-work-log-task-metrics] {
  grid-column: 2;
  justify-content: flex-start;
}

html[data-surface="mobile"] .journal [data-work-log-task-duration],
html[data-surface="mobile"] .journal [data-work-log-task-credits] {
  white-space: normal;
}

html[data-surface="mobile"] .journal [data-work-log-task-group-turns] {
  padding: 0.35rem;
}

html[data-surface="mobile"]:is([data-grouping="stream"], [data-grouping="workspace"])
  .journal
  details[data-work-log-turn-details]
  > summary {
  grid-template-columns: 12.5rem minmax(0, 1fr);
}

@media (max-width: 460px) {
  /* Раньше выбор темы занимал всю строку — это было оправдано, пока шапка
     стояла в колонку. Теперь он делит строку с брендом и лимитами. */
  html[data-surface="mobile"] .theme-picker,
  html[data-surface="mobile"] .group-picker {
    flex: 0 0 auto;
  }

  html[data-surface="mobile"] .theme-picker select,
  html[data-surface="mobile"] .group-picker select,
  html[data-surface="mobile"] .theme-picker .themed-select,
  html[data-surface="mobile"] .group-picker .themed-select {
    min-width: 0;
    width: 6.6rem;
  }

  html[data-surface="mobile"] .journal span[data-day-usage],
  html[data-surface="mobile"] .journal span[data-day-usage-part] {
    font-size: 0.72rem;
    padding: 0.16rem 0.5rem;
  }

  html[data-surface="mobile"] .journal details[data-work-log-turn-details] > summary {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0.05rem;
  }

  html[data-surface="mobile"] .journal span[data-work-log-turn-meta] {
    justify-content: flex-start;
    padding-bottom: 0;
  }

  html[data-surface="mobile"] .journal span[data-work-log-turn-share] {
    margin-left: 0.4rem;
  }

  html[data-surface="mobile"] .journal span[data-work-log-turn-title] {
    border-left: 0;
    padding-top: 0;
  }
}

/* =================================================== оболочка Agent Hub === */
/* Общая оболочка над журналом: слева список задач, справа чат, журнал —
   отдельная вкладка. Использует те же токены тем, что и журнал, поэтому
   переключение темы меняет и оболочку. Стили журнала выше не тронуты. */

:root {
  --mobile-nav-h: 3.4rem;
  --task-rail-width: clamp(230px, 16vw, 280px);
  --activity-rail-width: clamp(300px, 19vw, 340px);
}

body {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Border-box только для поддерева оболочки: журнал выше рассчитан на
   content-box и не затрагивается. */
.workspace,
.workspace *,
.activity-rail,
.activity-rail *,
.settings-panel,
.settings-panel *,
.text-dialog,
.text-dialog *,
.mobile-nav,
.mobile-nav *,
.toast {
  box-sizing: border-box;
}

/* Чат — полноэкранная оболочка: прокручивается только лента, композер
   закреплён. Журнал остаётся обычной страницей с липкой шапкой. */
html[data-view="chat"] body {
  height: 100dvh;
  overflow: hidden;
}

/* В полноэкранном чате корневой документ не прокручивается. Стабильный gutter
   здесь создавал пустую полосу только справа от верхней панели. */
html[data-view="chat"] {
  scrollbar-gutter: auto;
}

.app-header {
  flex: 0 0 auto;
}

.workspace {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: var(--task-rail-width) minmax(0, 1fr) var(--activity-rail-width);
  margin: 0 auto;
  max-width: var(--content-width);
  min-height: 0;
  position: relative;
  width: 100%;
  z-index: 2;
}

/* На desktop верхние границы списка Workspace и панели Streams всегда стоят
   на одной линии. Темы сохраняют собственные ширины, фон, рамки и прозрачность. */
html[data-view="chat"]:not([data-surface="mobile"]) body > .workspace {
  gap: var(--shell-workspace-gap, 0) !important;
  grid-template-columns: var(--task-rail-width) minmax(0, 1fr) var(--activity-rail-width) !important;
  padding-bottom: var(--shell-workspace-padding-bottom, 0) !important;
  padding-top: var(--shell-workspace-padding-top, 0.72rem) !important;
  transform: none !important;
}

/* На desktop рабочая область следует тем же краям, что логотип и кнопка
   настроек. Темы отвечают за материал панелей, но не сужают общую сцену.
   Мультичат использует весь viewport без внешних полей. */
html[data-view="chat"]:not([data-surface="mobile"]) body > .workspace {
  margin-left: var(--shell-header-padding-left, clamp(1rem, 4vw, 4.25rem)) !important;
  margin-right: var(--shell-header-padding-right, clamp(1rem, 4vw, 4.25rem)) !important;
  max-width: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  width: auto !important;
}

/* Gothic сохраняет исходную цельную железную сцену даже с одним Stream. */
html[data-theme="gothic"][data-view="chat"]:not([data-surface="mobile"])
  body > .workspace {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 100% !important;
}

html[data-view="chat"]:not([data-surface="mobile"])
  body > .workspace:has(.stream-chat-columns[data-multi-stream]) {
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  width: 100% !important;
}

@media (min-width: 1120px) {
  html:not([data-surface="mobile"]) .workspace:has(.stream-chat-columns[data-multi-stream]) {
    --task-rail-width: clamp(232px, 15vw, 280px);
  }
}

.journal-view {
  box-sizing: border-box;
  display: none;
  flex: 1 1 auto;
  width: 90%;
}

html[data-view="journal"] .workspace {
  display: none;
}

html[data-view="journal"] .journal-view {
  display: block;
}

/* ---- переключатель разделов в шапке (десктоп) ---- */

.view-switch {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.15rem;
  padding: 0.18rem;
}

.view-tab {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.78rem;
  gap: 0.35rem;
  padding: 0.32rem 0.75rem;
  transition: background 0.16s ease, color 0.16s ease;
}

.view-tab svg {
  height: 0.95rem;
  width: 0.95rem;
}

.view-tab:hover {
  color: var(--text);
}

.view-tab[aria-pressed="true"] {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  padding: calc(0.32rem - 1px) calc(0.75rem - 1px);
}

.connection-label {
  white-space: nowrap;
}

[data-journal-only] {
  display: none;
}

html[data-view="journal"] [data-journal-only] {
  display: inline-flex;
}

/* В панели «Вид» те же группы должны раскладываться в столбец: правило выше
   рассчитано на кнопки шапки, и из-за inline-flex подпись, переключатель и
   пояснение налезали друг на друга. */
html[data-view="journal"] .settings-body > [data-journal-only] {
  display: block;
}

/* ---- общие примитивы кнопок ---- */

.icon-button {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  height: 2.1rem;
  justify-content: center;
  padding: 0;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  width: 2.1rem;
}

.icon-button svg {
  height: 1.1rem;
  width: 1.1rem;
}

.icon-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.chip-button {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.76rem;
  gap: 0.35rem;
  padding: 0.36rem 0.72rem;
  text-decoration: none;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}

.chip-button svg {
  height: 0.95rem;
  width: 0.95rem;
}

.chip-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.chip-button.primary {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent) 26%, transparent),
    color-mix(in srgb, var(--accent) 12%, transparent));
  border-color: var(--accent-line);
  color: color-mix(in srgb, var(--accent) 55%, var(--text));
  font-weight: 600;
}

.chip-button.primary:hover {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  color: var(--text);
}

.chip-button.danger:hover {
  background: color-mix(in srgb, #ff6b6b 16%, transparent);
  border-color: color-mix(in srgb, #ff6b6b 55%, transparent);
  color: #ff9d9d;
}

/* =============================================== левая колонка задач === */

.task-rail {
  background: var(--surface-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.task-rail-head {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.75rem var(--gutter-left) 0.5rem;
}

.task-new-picker {
  flex: 0 0 auto;
  position: relative;
}

.task-new-picker > summary {
  list-style: none;
}

.task-new-picker > summary::-webkit-details-marker {
  display: none;
}

.task-new-picker[open] > summary {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.task-new-menu {
  background: var(--card-bg-open);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  min-width: 9.5rem;
  padding: 0.3rem;
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 45;
}

.task-new-menu button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 0.82rem;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  text-align: left;
}

.task-new-menu button:hover,
.task-new-menu button:focus-visible {
  background: var(--surface-2);
  color: var(--text);
}

.task-rail-title {
  align-items: center;
  color: var(--text);
  display: flex;
  font-size: 0.72rem;
  font-weight: 700;
  gap: 0.4rem;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
}

.task-count {
  background: var(--surface-3);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0;
  padding: 0.05rem 0.42rem;
}

.task-search {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-faint);
  display: flex;
  gap: 0.4rem;
  margin: 0 var(--gutter-left) 0.55rem;
  padding: 0.3rem 0.6rem;
}

.task-search svg {
  flex: 0 0 auto;
  height: 0.95rem;
  width: 0.95rem;
}

.task-search input {
  background: transparent;
  border: 0;
  color: var(--text);
  flex: 1 1 auto;
  font: inherit;
  font-size: 0.8rem;
  min-width: 0;
  outline: none;
}

.task-list {
  flex: 1 1 auto;
  list-style: none;
  margin: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0.5rem 0.6rem;
}

html[data-surface="mobile"] .journal summary[data-work-log-workspace-header] {
  gap: 0.35rem;
  grid-template-columns: 1rem minmax(0, 1fr) auto;
}

html[data-surface="mobile"] .journal span[data-work-log-workspace-usage] {
  width: auto;
}

html[data-surface="mobile"] .journal details[data-work-log-stream][open] {
  display: block;
}

html[data-surface="mobile"] .journal summary[data-work-log-stream-summary] {
  position: static;
}

html[data-surface="mobile"]
  .journal
  span[data-work-log-workspace-usage]
  details[data-task-usage-details] {
  display: block;
  width: 100%;
}

html[data-surface="mobile"]
  .journal
  span[data-work-log-workspace-usage]
  summary[data-task-usage] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8.6ch 5ch;
  width: 100%;
}

.workspace-task-panel {
  border-top: 1px solid var(--line);
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.workspace-task-section {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 9px;
}

.workspace-task-section + .workspace-task-section {
  border-top: 1px solid var(--line);
}

.workspace-task-section > header {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.workspace-task-section > header strong {
  color: var(--text-muted);
  font-size: 0.68rem;
  letter-spacing: var(--label-spacing);
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.workspace-task-section > header button,
.board-task-quiet,
.board-task-remove {
  background: transparent;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  font: inherit;
  font-size: 0.68rem;
}

.workspace-task-list {
  display: grid;
  flex: 1 1 auto;
  gap: 0.35rem;
  min-height: 0;
  overscroll-behavior: contain;
  overflow-y: auto;
}

.workspace-task-empty {
  color: var(--text-faint);
  font-size: 0.72rem;
  margin: 0;
  padding: 0.45rem;
}

/* =========================================== правая колонка активности === */

.activity-rail {
  background: var(--surface-1);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.activity-rail-head {
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  padding: 0.5rem;
}

.activity-rail-toggle {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  gap: 0.45rem;
  justify-content: space-between;
  letter-spacing: var(--label-spacing);
  min-height: 2rem;
  padding: 0.35rem 0.5rem;
  text-transform: uppercase;
  width: 100%;
}

.activity-rail-toggle:hover,
.activity-rail-toggle:focus-visible {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
  outline: none;
}

.activity-rail-toggle svg {
  flex: 0 0 auto;
  height: 0.9rem;
  transform: rotate(0deg);
  transition: transform 0.14s ease;
  width: 0.9rem;
}

.activity-rail[data-collapsed] .activity-rail-toggle svg {
  transform: rotate(180deg);
}

.activity-rail-content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.activity-rail[data-collapsed] .activity-streams {
  display: none;
}

.activity-streams {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
}

.activity-recent-streams {
  border-top: 1px solid var(--line);
  flex-grow: 1;
  flex-shrink: 1000;
  min-height: 2rem;
}

.activity-section-head {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex: 0 0 auto;
  font-size: 0.68rem;
  justify-content: space-between;
  letter-spacing: var(--label-spacing);
  min-height: 2rem;
  padding: 0.4rem 0.75rem 0.25rem;
  text-transform: uppercase;
}

.activity-stream-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 0;
  overflow-y: auto;
  padding: 0.35rem;
}

html[data-view="chat"]:not([data-surface="mobile"])
  .activity-stream-list .stream-tab {
  flex: 0 0 auto !important;
  max-width: none !important;
  width: 100% !important;
}

.activity-stream-item[data-current] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.activity-stream-empty {
  color: var(--text-faint);
  font-size: 0.72rem;
  margin: 0;
  padding: 0.8rem;
  text-align: center;
}

.activity-rail .workspace-task-panel {
  margin-top: auto;
}

/* ======================================================= Task board === */
.task-board-view {
  --task-board-detail-width: 0px;
  --task-board-content-end: 1.2rem;
  display: none;
  min-height: 0;
  width: 100%;
}

html[data-view="dashboard"] body {
  height: 100dvh;
  overflow: hidden;
}

html[data-view="dashboard"] .workspace,
html[data-view="dashboard"] .journal-view,
html[data-view="dashboard"] .statistics-view,
html[data-view="dashboard"] .background-view,
html[data-view="dashboard"] .server-view {
  display: none;
}

html[data-view="dashboard"] .task-board-view {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: var(--task-rail-width, 17.5rem) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100dvh - var(--app-header-h, 4.2rem));
  margin-inline: 0;
  max-width: none;
  overflow: hidden;
  padding: 0.6rem clamp(0.5rem, 1vw, 1rem);
}

.task-board-toolbar {
  grid-column: 2 / -1;
  grid-row: 1;
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex: 0 0 auto;
  gap: 0.55rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
  padding: 0.45rem 0.7rem;
}

.task-board-toolbar-actions,
.task-board-filter-controls {
  align-items: center;
  display: flex;
  gap: 0.45rem;
  min-width: 0;
}

.task-board-sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: var(--surface-1);
  padding: 0.75rem;
}
.task-board-sidebar > h2 { margin: 0 0 0.8rem; }
.task-board-catalog-title { display: none; }
.is-status-view .task-board-toolbar {
  grid-column: 1;
  grid-row: 1;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface-1);
}
.is-status-view .task-board-catalog-title {
  display: block;
  margin: 0;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}
.is-status-view .task-board-toolbar-actions { gap: 0.3rem; }
.is-status-view .task-board-filter-toggle { padding: 0.45rem; font-size: 0.65rem; }
.is-status-view .task-board-sidebar { grid-row: 2; border-top: 0; padding-top: 0.25rem; }
.is-status-view .task-board-columns { grid-row: 1 / -1; }
.task-board-scope-strip { display: grid; gap: 0.25rem; }
.task-board-scope-strip .task-board-scope {
  width: 100%;
  min-width: 0;
  text-align: start;
  white-space: normal;
  overflow-wrap: anywhere;
}
.task-board-columns { grid-column: 2; grid-row: 2; }

.task-board-toolbar-actions {
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.task-board-settings {
  box-sizing: border-box;
  position: fixed;
  inset: auto;
  margin: 0;
  width: min(24rem, calc(100vw - 16px));
  padding: 1rem;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: linear-gradient(var(--surface-1), var(--surface-1)), var(--bg);
  color: var(--text);
  box-shadow: 0 0.5rem 1.5rem #0006;
}
.task-board-settings:popover-open { display: grid; gap: 1rem; }
.task-board-setting { display: grid; gap: 0.6rem; min-width: 0; }
.task-board-setting strong { font-size: 0.8rem; }
.task-board-setting p { margin: 0; color: var(--text-muted); font-size: 0.7rem; line-height: 1.5; }
.task-board-settings .task-board-status-language { justify-content: space-between; }
.task-board-settings .task-board-status-language-options { display: flex; }
.task-board-settings .task-board-status-language-options button { flex: 1; }
.task-board-grouping-setting { display: flex; align-items: center; gap: 0.6rem; font-size: 0.8rem; cursor: pointer; }
.task-board-grouping-setting[hidden] { display: none; }
.task-board-grouping-setting { position: relative; }
.task-board-grouping-setting.setting-switch input {
  position: absolute;
  inset-inline-start: 0;
  margin: 0;
  opacity: 0;
  pointer-events: auto;
  inline-size: 2.35rem;
  block-size: 1.3rem;
  z-index: 1;
  cursor: pointer;
}

.task-board-folder-heading { display: flex; min-width: 0; }
.task-board-folder-heading > .task-board-scope { flex: 1; border: 0; }
.task-board-folder.is-selected { border-color: var(--accent-line); }
.task-board-folder-toggle {
  cursor: pointer;
  border: 0;
  border-inline-start: 1px solid var(--line);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  padding: 0.4rem 0.65rem;
}
.task-board-folder-toggle:is(:hover, :focus-visible) {
  background: var(--accent-soft);
  color: var(--accent);
}
.task-board-folder .task-workspace-folder-list[hidden] { display: none; }

.task-board-scope,
.task-board-filter-toggle {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 0.65rem 0.8rem;
}

.task-board-scope:hover,
.task-board-scope:focus-visible,
.task-board-scope.is-selected,
.task-board-scope.is-dragover,
.task-board-filter-toggle:hover,
.task-board-filter-toggle:focus-visible,
.task-board-filter-toggle[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  outline: none;
}

.task-board-status-language {
  align-items: center;
  color: var(--text-faint);
  display: flex;
  font-size: 0.68rem;
  gap: 0.4rem;
}

.task-board-status-language-options {
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  display: flex;
  overflow: hidden;
}

.task-board-status-language-options button {
  background: var(--surface-2);
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.32rem 0.44rem;
}

.task-board-status-language-options button + button {
  border-left: 1px solid var(--line);
}

.task-board-status-language-options button:hover,
.task-board-status-language-options button:focus-visible,
.task-board-status-language-options button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}

.task-board-completed-toggle {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.38rem 0.65rem;
}

.task-board-completed-toggle:hover,
.task-board-completed-toggle:focus-visible,
.task-board-completed-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  outline: none;
}

.task-board-inline-create textarea,
.task-start-new input,
.task-start-new select,
.board-task-destination {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font: inherit;
}

.task-board-inline-create textarea {
  min-height: 5rem;
  padding: 0.55rem 0.65rem;
  resize: vertical;
  width: 100%;
}

.board-task-primary,
.task-start-new button {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.48rem 0.72rem;
}

.task-board-columns {
  --task-board-column-base-width: 16rem;
  box-sizing: border-box;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
}

.task-board-status-columns {
  align-items: stretch;
  display: flex;
  flex: 1 1 auto;
  gap: 0;
  inline-size: 100%;
  min-height: 0;
  min-inline-size: 100%;
}

.task-board-column {
  background: transparent;
  border: 0;
  border-inline-end: 1px solid var(--line);
  border-radius: 0;
  display: flex;
  flex: 1 0 var(--task-board-column-base-width);
  flex-direction: column;
  min-height: 0;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.task-board-column.is-dragover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.task-board-column.is-backlog {
  background: color-mix(in srgb, var(--surface-1) 65%, transparent);
}

.task-board-column.is-notes {
  background: color-mix(in srgb, var(--surface-1) 96%, var(--surface-2));
  border-top-color: color-mix(in srgb, var(--provider-claude) 70%, var(--line));
  box-shadow: -0.65rem 0 0.9rem -0.75rem color-mix(in srgb, var(--text) 24%, transparent);
}

.task-board-column.is-status-in_progress {
  border-top-color: color-mix(in srgb, var(--task-status-in-progress) 70%, transparent);
}

.task-board-column.is-status-testing {
  border-top-color: color-mix(in srgb, var(--task-status-testing) 70%, transparent);
}

.task-board-column.is-status-awaiting_implementation {
  border-top-color: color-mix(in srgb, var(--task-status-awaiting) 70%, transparent);
}

@media (min-width: 960px) {
  html[data-view="dashboard"] .task-board-view.is-status-view > .task-card-modal[open] {
    grid-row: 2;
  }
  html[data-view="dashboard"] .task-board-view.has-open-task {
    --task-board-detail-width: clamp(19rem, 24vw, 25rem);
    grid-template-columns: var(--task-rail-width, 17.5rem) minmax(0, 1fr) var(--task-board-detail-width);
  }

  html[data-view="dashboard"] .task-board-view > .task-card-modal[open] {
    position: static;
    grid-column: 3;
    grid-row: 2;
    align-self: stretch;
    block-size: 100%;
    inline-size: 100%;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    max-height: none;
    max-width: none;
    border: 0;
    border-inline-start: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    background: var(--surface-1);
  }
}

.task-board-column-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
  display: flex;
  flex: 0 0 3.75rem;
  gap: 0.6rem;
  height: 3.75rem;
  justify-content: space-between;
  overflow: hidden;
  padding: 0.6rem 0.7rem;
}

.task-board-column-head > div:first-child {
  min-width: 0;
}

.is-status-view .task-board-column-head {
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

.task-board-column-controls,
.task-board-inline-actions {
  align-items: center;
  display: flex;
  gap: 0.35rem;
}

.task-board-create-button,
.task-board-workspace-handle {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.68rem;
  padding: 0.18rem 0.45rem;
}

.task-board-create-button:hover,
.task-board-create-button:focus-visible {
  border-color: var(--accent-line);
  color: var(--accent);
}

.task-board-workspace-handle {
  cursor: grab;
  padding-inline: 0.35rem;
}

.task-board-column-head h2,
.task-board-column-head p {
  margin: 0;
}

.task-board-stream-count {
  color: var(--text-faint);
  display: block;
  font-size: 0.62rem;
  margin-top: 0.2rem;
}

.task-board-column-head h2 {
  color: var(--text);
  font-size: 0.84rem;
}

.task-board-column-head p {
  color: var(--text-faint);
  font-size: 0.66rem;
  margin-top: 0.18rem;
}

.task-board-count {
  background: var(--surface-3);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  font-size: 0.68rem;
  padding: 0.1rem 0.42rem;
}

.task-board-column-list {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0.65rem;
}

.task-board-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--text-faint);
  font-size: 0.72rem;
  margin: 0;
  padding: 1.1rem 0.6rem;
  text-align: center;
}

.task-board-inline-create {
  background: var(--surface-2);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 0.45rem;
  padding: 0.55rem;
}

.board-task-card {
  background: var(--card-bg-open);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  max-inline-size: none;
  padding: 0.65rem;
}

.board-task-card.is-started {
  border-color: var(--accent-line);
}

.board-task-card.is-completed {
  background: color-mix(in srgb, var(--card-bg-open) 72%, var(--surface-1));
  border-color: color-mix(in srgb, var(--line) 70%, transparent);
  opacity: 0.78;
}

.board-task-card.is-dragover {
  border-color: var(--accent);
  transform: translateY(2px);
}

.board-task-card.is-pointer-dragging {
  cursor: grabbing;
  opacity: 0.72;
  user-select: none;
}

.board-task-card.is-compact {
  box-shadow: none;
  cursor: default;
  padding: 0.5rem;
}

.board-task-card:focus-visible {
  border-color: var(--accent-line);
  box-shadow: var(--accent-glow);
  outline: none;
}

.board-task-summary {
  align-items: center;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.board-task-number {
  border-bottom: 1px solid var(--accent-line);
  color: var(--accent);
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.12rem 0.05rem 0.16rem;
  white-space: nowrap;
}

.board-task-number.is-placeholder {
  border-bottom: 0;
  padding-inline: 0;
}

.board-task-title {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0.42rem 0 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.board-task-executor {
  color: var(--text-muted);
  font-size: 0.62rem;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-task-status {
  --task-status-color: var(--task-status-new);
  border: 1px solid color-mix(in srgb, var(--task-status-color) 72%, transparent);
  color: var(--task-status-color);
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  line-height: 1;
  padding: 0.22rem 0.3rem;
  text-transform: none;
}

.board-task-status[data-workflow-status="in_progress"] {
  --task-status-color: var(--task-status-in-progress);
}

.board-task-status[data-workflow-status="testing"] {
  --task-status-color: var(--task-status-testing);
}

.board-task-status[data-workflow-status="blocked"] {
  --task-status-color: #e5484d;
}

.board-task-blocked-reason {
  color: var(--text-muted);
  font-size: 0.75rem;
  grid-column: 1 / -1;
  margin: 0;
}

.board-task-status[data-workflow-status="awaiting_implementation"] {
  --task-status-color: var(--task-status-awaiting);
}

/* Dashboard rows share the column grid; embedded cards keep their own layout. */
html[data-view="dashboard"] .task-board-columns .board-task-card {
  display: grid;
  grid-template-columns: 2.9rem minmax(0, 1fr) minmax(3.4rem, 30%);
  align-items: start;
  gap: 0.4rem;
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: 0.9rem 0.4rem;
}

html[data-view="dashboard"] .task-board-columns .board-task-card:hover {
  background: var(--accent-soft);
}

html[data-view="dashboard"] .task-board-columns .board-task-card:is(.is-selected, :focus-visible) {
  background: var(--accent-soft);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  box-shadow: inset 3px 0 var(--accent);
}

html[data-view="dashboard"] .task-board-columns .board-task-title {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 450;
  line-height: 1.5;
  overflow-wrap: break-word;
}

html[data-view="dashboard"] .task-board-columns .board-task-number {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.6rem;
  line-height: 1.7;
  color: var(--text-muted);
  border: 0;
}

html[data-view="dashboard"] .task-board-columns .board-task-summary {
  display: contents;
}

html[data-view="dashboard"] .task-board-columns .board-task-executor {
  grid-column: 3;
  grid-row: 1;
  line-height: 1.7;
}

.board-task-workspace {
  grid-column: 2;
  grid-row: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.62rem;
  line-height: 1.7;
}

html[data-view="dashboard"] .task-board-columns .board-task-status {
  grid-column: 1 / -1;
  justify-self: start;
}

html[data-view="dashboard"] .task-board-columns [class*="is-status-"] .board-task-status {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  padding: 0;
  border: 0;
}

html[data-view="dashboard"] .task-board-columns .board-task-attachments {
  grid-column: 1 / -1;
}

.task-card-preview {
  display: none;
}

/* Status board: shared column headings and Workspace swimlanes. */
.is-status-view { --task-rail-width: 15rem; column-gap: 0.6rem; }
.is-status-view .task-board-status-columns { gap: 0.6rem; }
.is-status-view .task-board-status-columns > .is-backlog { flex: 0 0 12rem; }
.is-status-view .task-board-row-head { display: none; }
.is-grouped-view .task-board-status-columns {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 0.75rem;
  min-width: 0;
}
.is-grouped-view .task-board-columns { overflow: hidden; }
.is-grouped-view .task-board-status-columns > .is-backlog {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.is-grouped-view .is-backlog .task-board-row-head { display: none; }
.is-grouped-view .task-board-column-head { flex-basis: 4.5rem; height: 4.5rem; }
.is-status-view .is-backlog .board-task-workspace { display: none; }
html[data-view="dashboard"] .is-status-view .is-backlog .board-task-executor { grid-column: 2; }
.task-board-matrix {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}
.task-board-matrix-content { min-width: calc(var(--task-status-count) * 16rem); }
.task-board-matrix-head,
.task-board-lane-cells {
  display: grid;
  grid-template-columns: repeat(var(--task-status-count), minmax(0, 1fr));
  gap: 0.5rem;
}
.task-board-matrix-head {
  position: sticky;
  top: 0;
  z-index: 2;
  gap: 0.5rem;
  background: transparent;
}
.task-board-status-heading {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.task-board-lane { margin-bottom: 0.65rem; }
.task-board-lane-heading {
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: color-mix(in srgb, var(--bg) 96%, var(--accent) 4%);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
}
.task-board-lane-heading > span { margin-inline-start: 0.5rem; }
.task-board-lane-heading:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.task-board-lane-cell {
  min-width: 0;
  padding: 0.65rem 0.3rem 1rem;
  border-inline-end: 1px dashed var(--line);
}
.task-board-lane-cell:last-child { border-inline-end: 0; }
.task-board-lane-cell .task-board-column-list { overflow: visible; }
.task-board-lane-create { align-self: flex-start; margin-top: 0.2rem; }
.is-status-view .task-board-column-list { gap: 0.6rem; padding: 0.6rem; }
.task-board-lane-cell .task-board-column-list { padding: 0.1rem 0.25rem; }
html[data-view="dashboard"] .is-status-view .task-board-columns .board-task-card {
  grid-template-columns: 3.4rem minmax(0, 1fr) minmax(3.4rem, 30%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 96%, var(--accent) 4%);
  padding: 0.8rem;
  gap: 0.5rem;
}
html[data-view="dashboard"] .is-status-view .task-board-columns .board-task-card:hover {
  border-color: var(--accent-line);
  background: color-mix(in srgb, var(--bg) 92%, var(--accent) 8%);
}
html[data-view="dashboard"] .is-status-view .task-board-columns .board-task-card:is(.is-selected, :focus-visible) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--bg) 88%, var(--accent) 12%);
  box-shadow: none;
  outline-offset: -1px;
}
html[data-view="dashboard"] .is-status-view .task-board-columns .board-task-title { font-size: 0.9375rem; }
html[data-view="dashboard"] .is-status-view .task-board-columns :is(.board-task-number, .board-task-workspace, .board-task-executor) { font-size: 0.6875rem; }
.is-status-view .task-board-row-head { grid-template-columns: 3.4rem minmax(0, 1fr) minmax(3.4rem, 30%); }
html[data-view="dashboard"] .is-status-view .is-backlog .board-task-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

@media (max-width: 959px) {
  .is-grouped-view .task-board-status-columns { grid-template-columns: 10rem minmax(0, 1fr); gap: 0.5rem; }
}

html[data-view="dashboard"] .task-board-view.is-workspace-view .task-board-columns .board-task-status {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

html[data-view="dashboard"] .task-board-view.is-workspace-view .board-task-executor {
  grid-column: 2;
}

html[data-view="dashboard"] .task-board-view.is-workspace-view .board-task-workspace {
  display: none;
}

.is-workspace-view .task-board-row-head > :last-child { text-align: end; }

.task-board-row-head {
  display: grid;
  grid-template-columns: 2.9rem minmax(0, 1fr) minmax(3.4rem, 30%);
  gap: 0.4rem;
  padding: 0.65rem 1.05rem;
  border-bottom: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 0.62rem;
}

@media (min-width: 960px) {
  html[data-view="dashboard"] .task-board-view > .task-card-modal:not(.is-editing) .task-card-editor {
    display: none;
  }
  html[data-view="dashboard"] .task-board-view > .task-card-modal:not(.is-editing) .task-card-preview {
    display: grid;
    gap: 1rem;
  }
  .task-card-preview-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }
  .task-card-preview-meta strong {
    font: 0.75rem var(--font-mono);
  }
  .task-card-preview h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.45;
  }
  .task-card-preview-description {
    border-top: 1px solid var(--line);
    padding-top: 1rem;
    font-size: 0.8rem;
  }
  .task-card-preview-description p {
    color: var(--text-muted);
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin-top: 0.5rem;
  }
  html[data-view="dashboard"] .task-board-view > .task-card-modal .task-card-checklist,
  html[data-view="dashboard"] .task-board-view > .task-card-modal .task-card-release-details {
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    padding: 1rem 0;
    background: transparent;
  }
}

/* The view and active filters share one persistent row above the board. */
html[data-view="dashboard"] .task-board-view .task-board-toolbar {
  grid-column: 2 / -1;
  grid-row: 1;
  justify-content: flex-end;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface-1);
}
.task-board-toolbar .task-board-toolbar-actions,
.task-board-toolbar .task-board-view-options { justify-content: flex-end; }
html[data-view="dashboard"] .task-board-view .task-board-sidebar {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0;
}
.task-board-sidebar-head { flex: 0 0 auto; padding: 0.75rem; }
.task-board-sidebar-head h2 { margin: 0; }
.task-board-sidebar .task-board-scope-strip {
  min-height: 0;
  overflow-y: auto;
  padding: 0.25rem 0.75rem 0.75rem;
}
html[data-view="dashboard"] .task-board-view .task-board-columns {
  grid-row: 2;
}
.task-board-toolbar-actions > label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.task-board-toolbar-actions select {
  min-width: 0;
  max-width: 13rem;
  padding: 0.4rem;
}
.task-board-toolbar-actions .task-board-grouping-setting[hidden] { display: none; }
.task-board-toolbar-actions .task-board-view-options { flex-wrap: wrap; }
html[data-view="dashboard"] .task-board-view.is-list-view .task-board-columns {
  overflow: hidden;
}
.is-list-view .task-board-status-columns { min-width: 0; }
.is-list-view .task-board-column { flex: 1 1 100%; min-width: 0; border-right: 0; }
.is-list-view .task-board-column-list { flex: 1 1 auto; }
.is-list-view .task-board-row-head { display: none; }

.is-status-view.has-status-filter .task-board-status-columns > .task-board-column {
  flex: 1 1 100%;
  min-width: 0;
}
.is-grouped-view.has-status-filter .task-board-status-columns {
  grid-template-columns: minmax(0, 1fr);
}
.has-status-filter .task-board-matrix-content { min-width: 0; }

@media (min-width: 960px) {
  .task-board-toolbar-actions > .task-board-scope-control { display: none; }
}

.task-board-filter-controls[hidden] {
  display: none;
}

@media (max-width: 959px) {
  html[data-view="dashboard"] .task-board-view {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  .task-board-sidebar { grid-column: 1; grid-row: 1; max-height: 12rem; }
  .task-board-toolbar { grid-column: 1; grid-row: 2; }
  .task-board-columns { grid-column: 1; grid-row: 3; }
  .is-status-view .task-board-toolbar { flex-direction: row; align-items: center; }
  .is-status-view .task-board-sidebar { grid-row: 2; }
  .is-status-view .task-board-columns { grid-row: 3; }
  html[data-view="dashboard"] .task-board-view.is-workspace-view {
    grid-template-rows: auto minmax(0, 1fr);
  }
  .is-workspace-view .task-board-toolbar { grid-row: 1; }
  .is-workspace-view .task-board-columns { grid-row: 2; }
  .task-card-backdrop { display: none; }
  .task-board-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.6rem;
  }
  .task-board-toolbar-actions {
    flex-wrap: wrap;
  }
  .task-board-scope-strip {
    padding-bottom: 0.25rem;
  }
  html[data-view="dashboard"] .task-board-view,
  html[data-view="dashboard"] .task-board-view.is-workspace-view {
    grid-template-rows: auto minmax(0, 1fr);
  }
  html[data-view="dashboard"] .task-board-view .task-board-sidebar { display: none; }
  html[data-view="dashboard"] .task-board-view .task-board-toolbar {
    grid-column: 1;
    grid-row: 1;
  }
  html[data-view="dashboard"] .task-board-view .task-board-columns {
    grid-column: 1;
    grid-row: 2;
  }
  .task-board-toolbar-actions { width: 100%; }
  .task-board-toolbar-actions > label { flex: 1 1 auto; }
  .task-board-toolbar-actions select { flex: 1 1 auto; max-width: 100%; width: 0; }
  .task-board-toolbar-actions .task-board-view-options { flex: 1 0 100%; }
  .task-board-toolbar-actions .view-settings { margin-left: auto; }
}

.board-task-status[data-workflow-status="done"] {
  --task-status-color: var(--task-status-done);
}

.board-task-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.board-task-attachment {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  font-size: 0.68rem;
  justify-content: center;
  min-height: 3.4rem;
  min-width: 4.8rem;
  overflow: hidden;
  padding: 0.35rem;
}

.board-task-attachment:hover,
.board-task-attachment:focus-visible {
  border-color: var(--accent-line);
  box-shadow: var(--accent-glow);
  outline: none;
}

.board-task-attachment img {
  display: block;
  height: 8rem;
  max-width: 100%;
  object-fit: contain;
}

.board-task-attachments.is-compact .board-task-attachment {
  min-height: 2.8rem;
  min-width: 3.4rem;
  padding: 0.2rem;
}

.board-task-attachments.is-compact .board-task-attachment img {
  height: 3.8rem;
  width: 3.8rem;
}

.board-task-attachment-count {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.board-task-card-attachments {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.5rem;
  padding-top: 0.75rem;
}

.task-card-attachment-toolbar {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: var(--card-label-size);
  justify-content: space-between;
}

.task-card-attachment-add {
  height: 2rem;
  width: 2rem;
}

.task-card-attachment-add svg {
  height: 1rem;
  width: 1rem;
}

.task-card-attachment-hint {
  color: var(--text-faint);
  font-size: 0.68rem;
}

.board-task-card-head,
.board-task-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.board-task-card-head {
  justify-content: space-between;
}

.board-task-source,
.board-task-ai {
  color: var(--text-faint);
  font-size: 0.62rem;
}

.board-task-ai {
  background: var(--surface-2);
  border: 0;
  border-radius: var(--radius-chip);
  padding: 0.12rem 0.38rem;
}

.board-task-ai.is-pending {
  color: var(--pending);
}

.board-task-ai.is-failed {
  color: #ff9d9d;
  cursor: pointer;
}

.board-task-text {
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0.5rem 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.board-task-card.is-compact .board-task-text {
  display: -webkit-box;
  font-size: 0.72rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.board-task-original {
  color: var(--text-faint);
  font-size: 0.67rem;
  margin-bottom: 0.5rem;
}

.board-task-original-toggle {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0.18rem 0;
}

.board-task-original-toggle:hover,
.board-task-original-toggle:focus-visible {
  text-decoration: underline;
}

.board-task-original p {
  margin: 0.35rem 0;
  white-space: pre-wrap;
}

.board-task-actions {
  margin-top: 0.55rem;
}

.board-task-destination {
  flex: 1 1 7rem;
  font-size: 0.68rem;
  min-width: 0;
  padding: 0.35rem;
}

.board-task-remove:hover,
.board-task-remove:focus-visible {
  color: #ff9d9d;
}

.task-start-modal,
.task-card-modal,
.task-delete-modal,
.context-usage-modal {
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text);
  max-height: min(78dvh, 44rem);
  max-width: 34rem;
  padding: 0;
  width: calc(100% - 2rem);
}

.task-start-modal::backdrop,
.task-card-modal::backdrop,
.task-delete-modal::backdrop,
.context-usage-modal::backdrop {
  background: rgba(2, 5, 10, 0.76);
  backdrop-filter: blur(3px);
}

.task-delete-modal {
  max-width: 26rem;
}

.task-cleanup-preview {
  margin: 0;
  max-height: 45dvh;
  overflow: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.task-delete-modal > section,
.task-delete-modal > footer {
  padding: 1rem;
}

.task-delete-modal > section {
  display: grid;
  gap: 0.45rem;
}

.task-delete-modal h2,
.task-delete-modal p {
  margin: 0;
}

.task-delete-modal h2 {
  font-size: 1.05rem;
}

.task-delete-modal > section > p:last-child {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.task-delete-modal > footer {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.65rem;
  justify-content: flex-end;
}

.task-delete-confirm {
  background: color-mix(in srgb, #b44747 24%, var(--surface-2));
  border: 1px solid color-mix(in srgb, #ff7777 55%, var(--line-strong));
  border-radius: var(--radius-sm);
  color: #ffb0b0;
  cursor: pointer;
  font: inherit;
  padding: 0.45rem 0.8rem;
}

.task-delete-confirm:hover,
.task-delete-confirm:focus-visible {
  border-color: #ff8d8d;
  color: #ffd0d0;
}

.task-card-modal > header,
.task-card-modal > section,
.task-card-modal > footer {
  padding: 0.85rem 1rem;
}

.task-card-modal > header {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.task-card-modal > footer {
  border-top: 1px solid var(--line);
  gap: 0.5rem;
  margin-top: 0;
}

/* Действия футера одного размера; удаление отделено и уходит к правому краю,
   а при переносе строки остаётся справа, а не повисает под кнопками. */
.task-card-modal > footer .board-task-quiet,
.task-card-modal > footer .board-task-remove {
  border-radius: var(--radius-md);
  font-size: 0.76rem;
  padding: 0.48rem 0.6rem;
}

.task-card-modal > footer .board-task-remove {
  margin-inline-start: auto;
}

.task-card-modal > footer > * {
  min-height: 2.15rem;
}

.task-card-modal > footer .board-task-destination {
  flex: 0 1 11rem;
}

.task-card-modal h2,
.task-card-modal p {
  margin: 0;
}

.task-card-modal h2 {
  font-size: 1rem;
  margin-top: 0.2rem;
}

.task-card-content {
  display: grid;
  gap: 0.75rem;
  max-height: min(55dvh, 30rem);
  overflow-y: auto;
}

.task-card-editor {
  display: grid;
  gap: 0.75rem;
}

/* Сохранение относится к паре полей выше, а не ко всей карточке, поэтому
   кнопка не растягивается на всю ширину и не спорит с действиями футера. */
.task-card-editor > .board-task-primary {
  justify-self: end;
  min-height: 2.15rem;
}

.task-card-editor label {
  color: var(--text-muted);
  display: grid;
  font-size: var(--card-label-size);
  gap: 0.35rem;
}

.task-card-title-control {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  min-width: 0;
}

.task-card-number {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  color: var(--accent);
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.32rem 0.4rem;
  white-space: nowrap;
}

.task-card-number[hidden] {
  display: none;
}

.task-card-status-field[hidden],
.board-task-status[hidden] {
  display: none;
}

.task-card-status-field {
  color: var(--text-muted);
  display: grid;
  font-size: var(--card-label-size);
  gap: 0.35rem;
}

.task-card-status-field select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 0.5rem 0.6rem;
  width: 100%;
}

.task-card-status-field select:focus {
  border-color: var(--accent-line);
  outline: 2px solid var(--accent-soft);
}

.task-card-release-details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem;
}

.task-card-detail-row,
.task-card-work-log,
.task-card-work-log-entries {
  display: grid;
  gap: 0.35rem;
}

.task-card-detail-row > span,
.task-card-work-log > span {
  color: var(--text-muted);
  font-size: var(--card-label-size);
}

.task-card-detail-row strong {
  color: var(--text);
  font-size: 0.82rem;
}

.task-card-project-root {
  color: var(--text-soft);
  font-family: var(--font-numeric);
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.task-card-diff {
  min-width: 0;
  overflow: auto;
  max-height: 32rem;
}
.task-card-diff .task-diff-code {
  font-family: monospace;
  white-space: pre;
  font-size: 0.72rem;
}

.task-card-detail-empty {
  color: var(--text-faint);
  font-size: 0.72rem;
  margin: 0;
}

/* Записи лога лежат внутри блока «Исполнение и изменения», у которого уже есть
   своя рамка. Вторая рамка внутри первой давала двойной контур, поэтому запись
   отделяется заливкой. */
.task-card-work-log-entry {
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem;
}

.task-card-work-log-entry p {
  color: var(--text-soft);
  font-size: 0.74rem;
  line-height: 1.4;
  margin: 0;
  overflow-wrap: anywhere;
}

.task-card-work-log-meta {
  align-items: center;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  font-family: var(--font-numeric);
  font-size: 0.64rem;
  gap: 0.45rem;
}

.task-card-work-log-meta strong {
  color: var(--text);
}


.task-card-editor textarea {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  padding: 0.55rem 0.65rem;
  width: 100%;
}

.task-card-editor [data-task-card-title] {
  flex: 1 1 auto;
  font-size: 0.92rem;
  font-weight: 650;
  min-height: 0;
  overflow-y: hidden;
  resize: none;
}

.task-card-editor [data-task-card-description] {
  min-height: 8rem;
  resize: vertical;
}

.task-card-editor textarea:focus {
  border-color: var(--accent-line);
  outline: 2px solid var(--accent-soft);
}

.workspace-card-modal {
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text);
  max-height: min(90dvh, 56rem);
  max-width: 42rem;
  /* Форма берёт max-height диалога через inherit, поэтому рамка диалога
     добавляла ровно свои 2px переполнения и рядом с полосой прокрутки полей
     появлялась вторая, внешняя. Прокручиваются только поля. */
  overflow: hidden;
  padding: 0;
  width: calc(100% - 2rem);
}

.workspace-archive-modal {
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text);
  max-height: min(80dvh, 38rem);
  max-width: 36rem;
  padding: 0;
  width: calc(100% - 2rem);
}

.workspace-archive-modal::backdrop {
  background: rgba(2, 5, 10, 0.76);
  backdrop-filter: blur(3px);
}

.workspace-archive-modal > header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 0.85rem 1rem;
}

.workspace-archive-modal h2,
.workspace-archive-modal p {
  margin: 0;
}

.workspace-archive-modal h2 {
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

.workspace-archive-note {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.45;
  padding: 0.85rem 1rem 0;
}

.workspace-archive-list {
  display: grid;
  gap: 0.55rem;
  max-height: min(56dvh, 28rem);
  overflow-y: auto;
  padding: 0.85rem 1rem 1rem;
}

.workspace-archive-item {
  align-items: center;
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 0.2rem 0.75rem;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 0.7rem 0.75rem;
}

.workspace-archive-item strong,
.workspace-archive-item span {
  min-width: 0;
}

.workspace-archive-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-archive-item span {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.workspace-archive-actions {
  align-items: center;
  display: flex;
  gap: 0.4rem;
  grid-column: 2;
  grid-row: 1 / span 2;
}

.workspace-archive-delete,
.workspace-card-archive,
.stream-card-archive {
  background: color-mix(in srgb, var(--danger, #ff7b7b) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger, #ff7b7b) 55%, var(--line));
  border-radius: var(--radius-sm);
  color: var(--danger, #ff7b7b);
  cursor: pointer;
  font: inherit;
  padding: 0.42rem 0.62rem;
}

.workspace-archive-delete:hover,
.workspace-card-archive:hover,
.stream-card-archive:hover {
  background: color-mix(in srgb, var(--danger, #ff7b7b) 20%, transparent);
}

.workspace-card-archive:disabled,
.stream-card-archive:disabled {
  cursor: default;
  opacity: 0.45;
}

.workspace-archive-empty {
  color: var(--text-faint);
  padding: 1.5rem 1rem 1.8rem;
  text-align: center;
}

/* Общая форма prompt-шаблонов повторяет карточку Workspace: шапка, прокрутка
   полей и строка действий. Сам редактор внутри — прежний, поэтому его
   собственные стили здесь не переопределяются. */
.prompt-templates-modal {
  /* Форму открывают и поверх панели настроек, поэтому фон непрозрачный: тот же
     рецепт, что у самой панели, а не полупрозрачный --surface-1. */
  background:
    radial-gradient(120% 60% at 90% -20%, var(--space-glow-a), transparent 60%),
    var(--space-base);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(90dvh, 52rem);
  max-width: 40rem;
  overflow: hidden;
  padding: 0;
  width: calc(100% - 2rem);
}

.prompt-templates-modal::backdrop {
  backdrop-filter: blur(3px);
  background: rgba(2, 5, 10, 0.76);
}

.prompt-templates-modal > header,
.prompt-templates-modal > footer {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.85rem 1rem;
}

.prompt-templates-modal > header {
  border-bottom: 1px solid var(--line);
}

.prompt-templates-modal > footer {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.prompt-templates-modal > footer button {
  min-height: 2.15rem;
}

.prompt-templates-modal h2,
.prompt-templates-modal p {
  margin: 0;
}

.prompt-templates-modal h2 {
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

.prompt-templates-fields {
  display: grid;
  gap: 0.7rem;
  overflow-y: auto;
  padding: 1rem;
}

/* Внутри формы карточка редактора занимает всю ширину: ограничение меры нужно
   было соседству с другими настройками, а здесь она одна. */
.prompt-templates-card {
  max-width: none;
}

/* Область действия видна с одного взгляда: выбранная подсвечена, рядом стоит
   число шаблонов именно этой области. Кнопки переносятся, а не сжимаются. */
.prompt-templates-scopes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.prompt-templates-scope {
  align-items: baseline;
  display: inline-flex;
  gap: 0.4rem;
  max-width: 100%;
}

.prompt-templates-scope-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-templates-scope-count {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.prompt-templates-scope[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.prompt-templates-scope[aria-pressed="true"] .prompt-templates-scope-count {
  color: inherit;
}

.prompt-templates-scope[data-prompt-templates-diverged] {
  border-color: color-mix(in srgb, var(--danger, #ff7b7b) 60%, transparent);
}

.prompt-templates-scope:disabled {
  cursor: default;
  opacity: 0.45;
}

.prompt-templates-note {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Расхождение показывается прямо в форме: черновик остаётся на месте, а выбор
   между ним и сохранёнными значениями делает человек. */
.prompt-templates-conflict {
  align-items: start;
  background: color-mix(in srgb, var(--danger, #ff7b7b) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger, #ff7b7b) 45%, transparent);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.6rem 0.7rem;
}

.prompt-templates-conflict[hidden] {
  display: none;
}

.prompt-templates-conflict p {
  flex: 1 1 14rem;
  font-size: 0.8rem;
}

/* Вход в общую форму на месте прежнего редактора. */
.workspace-card-modal::backdrop {
  background: rgba(2, 5, 10, 0.76);
  backdrop-filter: blur(3px);
}

.workspace-card-modal form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: inherit;
}

.workspace-card-modal header,
.workspace-card-modal footer {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.85rem 1rem;
}

.workspace-card-modal header {
  border-bottom: 1px solid var(--line);
}

.workspace-card-modal footer {
  border-top: 1px solid var(--line);
  gap: 0.5rem;
  justify-content: flex-end;
}

/* «Отмена» остаётся тише «Сохранить», но обе кнопки одного размера. */
.workspace-card-modal footer button {
  min-height: 2.15rem;
}

.workspace-card-modal footer .board-task-quiet {
  border-radius: var(--radius-md);
  font-size: 0.76rem;
  padding: 0.48rem 0.72rem;
}

.workspace-card-modal footer .board-task-quiet:hover {
  color: var(--text);
}

.workspace-card-modal h2,
.workspace-card-modal p {
  margin: 0;
}

.workspace-card-modal h2 {
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

.workspace-card-fields {
  align-content: start;
  display: grid;
  gap: 0.8rem;
  grid-auto-rows: max-content;
  overflow-y: auto;
  padding: 1rem;
}

.workspace-card-actions-section {
  padding-top: 0.45rem;
}

/* Тот же размер, что у действий карточки Stream. */
.workspace-card-actions .workspace-card-archive {
  border-radius: var(--radius-chip);
  font-size: 0.76rem;
  min-height: 2.45rem;
  width: 100%;
}

.workspace-card-fields [hidden] {
  display: none;
}

.workspace-card-fields label {
  display: grid;
  gap: 0.35rem;
}

.workspace-card-fields .directory-field-setting {
  display: grid;
  gap: 0.35rem;
}

.workspace-card-fields label > span {
  color: var(--text-muted);
  font-size: var(--card-label-size);
}

.workspace-card-fields .directory-field-setting > span {
  color: var(--text-muted);
  font-size: var(--card-label-size);
}

/* Поля брали оформление у браузера и оставались серыми в любой теме. Токены
   те же, что у остальных полей оболочки, поэтому диалог следует за темой. */
.workspace-card-fields input,
.workspace-card-fields select,
.workspace-card-fields textarea {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  transition: border-color 0.14s ease, background 0.14s ease;
  width: 100%;
}

.workspace-card-fields select option {
  background: var(--surface-1);
  color: var(--text);
}

.workspace-card-fields input::placeholder,
.workspace-card-fields textarea::placeholder {
  color: var(--text-faint);
}

.workspace-card-fields input:hover,
.workspace-card-fields select:hover,
.workspace-card-fields textarea:hover {
  border-color: var(--line-strong);
}

.workspace-card-fields input:focus,
.workspace-card-fields select:focus,
.workspace-card-fields textarea:focus {
  border-color: var(--accent-line);
  box-shadow: var(--accent-glow);
  outline: none;
}

/* Необязательный комментарий занимал столько же, сколько правила агента, и
   вытеснял нижние поля за край карточки. Растянуть его по-прежнему можно. */
.workspace-card-fields textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.workspace-card-fields [data-workspace-card-comment] {
  height: 4.5rem;
}

.workspace-card-fields [data-workspace-card-rules] {
  min-height: 11rem;
}

.agent-rules-field textarea {
  background: color-mix(in srgb, var(--surface-2) 86%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  min-width: 0;
  padding: 0.6rem 0.65rem;
  resize: vertical;
  width: 100%;
}

.agent-rules-field textarea:focus {
  border-color: var(--accent-line);
  box-shadow: var(--accent-glow);
  outline: none;
}

.agent-rules-meta {
  align-items: baseline;
  color: var(--text-faint);
  display: flex;
  font-size: 0.68rem;
  gap: 0.6rem;
  justify-content: space-between;
}

.agent-rules-meta output {
  flex: 0 0 auto;
  font-family: var(--font-numeric);
}

.agent-rules-meta output[data-limit-exceeded] {
  color: var(--danger);
}

/* Та же раскладка, что у переключателей ролей Stream: подпись слева,
   пояснение следом, тумблер прижат к правому краю карточки. */
.workspace-release-workflow-setting {
  align-items: center;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: minmax(0, 1fr) auto auto;
  position: relative;
}

.workspace-release-workflow-switch,
.workspace-auto-review-switch {
  cursor: pointer;
  display: contents !important;
}

.workspace-release-workflow-switch .switch-text,
.workspace-auto-review-switch .switch-text {
  grid-area: 1 / 1;
}

.workspace-release-workflow-help-popover {
  grid-area: 1 / 2;
}

.workspace-release-workflow-switch .switch-track,
.workspace-auto-review-switch .switch-track {
  grid-area: 1 / 3;
  justify-self: end;
}

.workspace-release-workflow-help-popover {
  position: static;
}

.workspace-release-workflow-help {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: help;
  display: inline-flex;
  font: 700 0.68rem/1 var(--font-display);
  height: 1.25rem;
  justify-content: center;
  list-style: none;
  padding: 0;
  width: 1.25rem;
}

.workspace-release-workflow-help::-webkit-details-marker {
  display: none;
}

.workspace-release-workflow-tooltip {
  background: rgb(5 11 13);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  box-shadow: 0 12px 32px rgb(0 0 0 / 72%);
  color: rgb(229 238 240);
  display: none;
  font-size: 0.72rem;
  gap: 0.5rem;
  bottom: calc(100% + 0.35rem);
  left: 0;
  line-height: 1.45;
  max-height: min(50dvh, 24rem);
  max-width: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.75rem;
  position: absolute;
  right: 0;
  scrollbar-gutter: stable;
  white-space: normal;
  width: auto;
  z-index: 4;
}

.workspace-release-workflow-tooltip p {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.workspace-release-workflow-help-popover:hover .workspace-release-workflow-tooltip,
.workspace-release-workflow-help-popover[open] .workspace-release-workflow-tooltip,
.workspace-release-workflow-help:focus-visible + .workspace-release-workflow-tooltip {
  display: grid;
}

.stream-role-setting {
  display: grid;
  gap: 0.35rem;
}

/* Подпись, знак вопроса и тумблер — ячейки одной строки, поэтому тумблеры
   ролей стоят на той же вертикали, что «Автоподтверждение» над ними. */
.stream-role-setting-heading {
  align-items: center;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.stream-role-setting-heading .setting-switch {
  display: contents;
}

.stream-role-setting-heading .switch-text {
  grid-area: 1 / 1;
}

.stream-role-setting-heading .stream-role-help-popover {
  grid-area: 1 / 2;
}

.stream-role-setting-heading .switch-track {
  grid-area: 1 / 3;
  justify-self: end;
}

.stream-role-help-popover {
  display: inline-flex;
}

.stream-role-help {
  appearance: none;
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), var(--accent-glow);
  color: var(--accent);
  cursor: help;
  display: inline-flex;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 750;
  height: 1.1rem;
  justify-content: center;
  line-height: 1;
  min-width: 1.1rem;
  padding: 0;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
  width: 1.1rem;
}

.stream-role-help:hover {
  background: color-mix(in srgb, var(--accent) 24%, var(--surface-2));
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}

.stream-role-help:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stream-role-tooltip {
  background: color-mix(in srgb, var(--bg) 94%, var(--accent));
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 64px -20px rgba(0, 0, 0, 0.9), var(--accent-glow);
  color: var(--text);
  gap: 0.45rem;
  margin: auto;
  max-height: min(28rem, 70vh);
  max-width: calc(100vw - 2rem);
  overflow: auto;
  padding: 0.75rem;
  width: min(42rem, calc(100vw - 2rem));
  z-index: 8;
}

.stream-role-tooltip:popover-open {
  display: grid;
}

.stream-role-tooltip::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.stream-role-tooltip p {
  margin: 0;
}

/* Короткие значения не растягиваются на всю карточку: поле по длине данных
   читается как короткое, а не как ещё одна строка полной ширины. */
.workspace-card-fields input[type="number"] {
  max-width: 8rem;
}

.workspace-card-fields [data-workspace-card-task-prefix] {
  max-width: 12rem;
}

.workspace-card-fields input:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.task-start-modal > header,
.task-start-modal > section,
.task-start-new {
  padding: 0.85rem 1rem;
}

.task-start-modal > header {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.task-start-modal h2,
.task-start-modal h3,
.task-start-modal p {
  margin: 0;
}

.task-start-modal h2 {
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

.task-start-modal h3 {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-bottom: 0.55rem;
  text-transform: uppercase;
}

.task-start-options {
  display: grid;
  gap: 0.4rem;
  max-height: 14rem;
  overflow-y: auto;
}

.task-start-stream {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  display: flex;
  font: inherit;
  justify-content: space-between;
  padding: 0.55rem 0.65rem;
}

.task-start-stream span,
.task-start-empty {
  color: var(--text-faint);
  font-size: 0.68rem;
}

.task-start-new {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.task-start-new h3 {
  grid-column: 1 / -1;
}

.task-start-new input,
.task-start-new select {
  min-width: 0;
  padding: 0.5rem 0.6rem;
}

@media (max-width: 760px) {
  html[data-view="dashboard"] .task-board-view {
    height: calc(100dvh - var(--mobile-nav-h) - env(safe-area-inset-bottom));
    padding-bottom: 0;
  }

  .task-board-columns {
    display: flex;
    overflow-x: auto;
    padding: 0.8rem;
  }

  .task-board-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.55rem;
  }

  .task-board-toolbar-actions {
    justify-content: space-between;
  }

  .task-board-filter-controls {
    flex-wrap: wrap;
  }

  .task-board-column {
    flex-basis: min(82vw, 19rem);
  }

  .task-start-new {
    grid-template-columns: 1fr;
  }

  .task-start-new h3 {
    grid-column: 1;
  }
}

html[data-surface="mobile"]
  .journal
  span[data-work-log-workspace-usage]
  details[data-work-log-collapsed-workspace-usage-details]
  > summary[data-task-usage] {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

html[data-surface="mobile"]
  .journal
  div[data-work-log-task-cell]:has(> div[data-work-log-task-content]:empty) {
  grid-template-columns: minmax(0, 1fr);
}

html[data-surface="mobile"]
  .journal
  div[data-work-log-task-cell]:has(> div[data-work-log-task-content]:empty)
  > div[data-work-log-usage] {
  grid-column: 1;
}

.task-workspace-item {
  align-items: center;
  background: color-mix(in srgb, var(--surface-1) 76%, transparent);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  gap: 0.55rem;
  list-style: none;
  margin: 0 0 0.28rem;
  min-height: 2.55rem;
  overflow: hidden;
  padding: 0.55rem 0.62rem;
  position: relative;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.task-rail-actions {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.25rem;
}

.task-folder-new {
  color: var(--text-muted);
}

.task-folder-new:hover,
.task-folder-new:focus-visible {
  color: var(--accent);
}

.workspace-archive-open {
  position: relative;
}

.workspace-archive-count {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--surface-1);
  border-radius: 999px;
  color: var(--accent-contrast, var(--surface-1));
  display: flex;
  font-family: var(--font-numeric);
  font-size: 0.55rem;
  height: 1rem;
  justify-content: center;
  min-width: 1rem;
  padding: 0 0.18rem;
  position: absolute;
  right: -0.22rem;
  top: -0.22rem;
}

.task-workspace-folder {
  list-style: none;
  margin: 0.58rem 0 0.34rem;
}

.task-workspace-folder-details {
  background: color-mix(in srgb, var(--surface-1) 48%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: var(--radius-md);
  box-shadow: 0 0.3rem 1.2rem rgb(0 0 0 / 10%);
  overflow: hidden;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.task-workspace-folder-summary {
  align-items: center;
  background: color-mix(in srgb, var(--surface-1) 70%, transparent);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  font-size: 0.72rem;
  font-weight: 720;
  gap: 0.42rem;
  grid-template-columns: 0.65rem 1rem minmax(0, 1fr) auto;
  list-style: none;
  min-height: 2.15rem;
  padding: 0.44rem 0.58rem;
  text-transform: uppercase;
}

.task-workspace-folder-summary::-webkit-details-marker {
  display: none;
}

.task-workspace-folder-summary:hover,
.task-workspace-folder-summary:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.task-workspace-folder-icon {
  color: var(--text-faint);
  height: 0.72rem;
  transform: rotate(0deg);
  transition: transform 0.14s ease;
  width: 0.72rem;
}

.task-workspace-folder-glyph {
  color: var(--accent);
  height: 0.88rem;
  opacity: 0.78;
  width: 0.88rem;
}

.task-workspace-folder-details[open] .task-workspace-folder-icon {
  transform: rotate(90deg);
}

.task-workspace-folder-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-workspace-folder-count {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-faint);
  display: inline-flex;
  font-family: var(--font-numeric);
  font-size: 0.66rem;
  justify-content: center;
  min-width: 1.45rem;
  padding: 0.06rem 0.36rem;
}

.task-workspace-folder-list {
  display: grid;
  gap: 0.24rem;
  margin: 0;
  padding: 0.38rem 0.38rem 0.46rem;
}

.task-workspace-folder-empty {
  align-items: center;
  border: 1px dashed color-mix(in srgb, var(--accent-line) 58%, var(--line));
  border-radius: calc(var(--radius-md) - 0.18rem);
  color: var(--text-faint);
  display: flex;
  font-size: 0.68rem;
  justify-content: center;
  list-style: none;
  min-height: 2.45rem;
  padding: 0.45rem;
  text-align: center;
}

.task-workspace-folder[data-running] .task-workspace-folder-summary,
.task-workspace-folder[data-unread] .task-workspace-folder-summary,
.task-workspace-folder[data-selected] .task-workspace-folder-summary {
  color: var(--text);
}

.task-workspace-folder[data-workspace-folder-kind="folder"] .task-workspace-folder-details {
  border-color: color-mix(in srgb, var(--accent-line) 68%, var(--line));
}

.task-workspace-folder[data-selected] .task-workspace-folder-details {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent),
    0 0.4rem 1.4rem rgb(0 0 0 / 12%);
}

/* Внутри папки строки сдвинуты — видно, что они принадлежат заголовку. */
.task-workspace-item[data-folder-member] {
  margin: 0;
}

.task-workspace-item[data-workspace-kind="system"] {
  border-style: dashed;
}

.task-workspace-item:hover,
.task-workspace-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.task-workspace-item[data-selected] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.task-workspace-name {
  color: var(--text);
  flex: 1 1 auto;
  font-size: 0.82rem;
  font-weight: 680;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-workspace-time {
  color: var(--text-faint);
  flex: 0 0 auto;
  font-family: var(--font-numeric);
  font-size: 0.64rem;
}

.rail-empty {
  color: var(--text-faint);
  font-size: 0.78rem;
  line-height: 1.5;
  margin: 0.5rem;
  padding: 1rem 0.75rem;
  text-align: center;
}

.task-item {
  align-items: flex-start;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.28rem;
  padding: 0.55rem 0.6rem;
  position: relative;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.task-item:hover {
  background: var(--surface-2);
}

.task-item[data-selected] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.task-item[data-selected]::before {
  background: var(--accent);
  border-radius: var(--radius-chip);
  bottom: 0.55rem;
  content: "";
  left: -0.5rem;
  position: absolute;
  top: 0.55rem;
  width: 2px;
}

.provider-dot {
  background: var(--provider-none);
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--provider-none) 18%, transparent);
  flex: 0 0 auto;
  height: 0.5rem;
  margin-top: 0.4rem;
  width: 0.5rem;
}

[data-provider="codex"] > .provider-dot,
.provider-dot[data-provider="codex"] {
  background: var(--provider-codex) !important;
  border-color: var(--provider-codex) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--provider-codex) 18%, transparent);
}

[data-provider="claude"] > .provider-dot,
.provider-dot[data-provider="claude"] {
  background: var(--provider-claude) !important;
  border-color: var(--provider-claude) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--provider-claude) 18%, transparent);
}

.task-item[data-running] .provider-dot {
  animation: pulse 2.4s ease-in-out infinite;
}

.task-body {
  flex: 1 1 auto;
  min-width: 0;
}

.task-title-row {
  align-items: baseline;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
}

.task-title {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-item[data-unread] .task-title {
  font-weight: 680;
}

.task-time {
  color: var(--text-faint);
  flex: 0 0 auto;
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.task-footer {
  align-items: center;
  display: flex;
  gap: 0.4rem;
  justify-content: space-between;
  margin-top: 0.22rem;
}

.task-meta {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex: 1 1 auto;
  gap: 0.4rem;
  min-width: 0;
}

.task-agent {
  --task-provider: var(--text-soft);
  background: color-mix(in srgb, var(--task-provider) 13%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--task-provider) 44%, transparent);
  border-radius: var(--radius-chip);
  color: color-mix(in srgb, var(--task-provider) 78%, var(--text));
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  line-height: 1.25;
  padding: 0.05rem 0.3rem;
  white-space: nowrap;
}

.task-item[data-provider="codex"] .task-agent {
  --task-provider: var(--provider-codex);
}

.task-item[data-provider="claude"] .task-agent {
  --task-provider: var(--provider-claude);
}

.task-runtime {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-chip);
  color: var(--accent);
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-left: auto;
  line-height: 1.25;
  padding: 0.05rem 0.3rem;
}

.task-status {
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  font-size: 0.68rem;
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-status[data-status="running"] {
  color: var(--ok);
}

.task-status[data-status="waiting"],
.task-status[data-status="approval"] {
  color: var(--pending);
}

.task-unread {
  background: var(--accent);
  border-radius: 50%;
  box-shadow: var(--accent-glow);
  flex: 0 0 auto;
  height: 0.5rem;
  width: 0.5rem;
}

/* ======================================================= чат задачи === */

.reliquary-panel-corner {
  display: none;
}

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

/* Эта пользовательская настройка владеет только заливкой области переписки.
   Тема продолжает рисовать верхнюю панель Stream, композер, карточки сообщений,
   внешние тени и border-image рамок. !important нужен, потому что пакеты тем
   подключаются после общей оболочки и иначе возвращают собственную текстуру. */
:root[data-chat-surface="transparent"] .chat,
:root[data-chat-surface="transparent"] .stream-chat-columns,
:root[data-chat-surface="transparent"] .stream-chat-columns > .chat-pane,
:root[data-chat-surface="transparent"] .stream-chat-preview,
:root[data-chat-surface="transparent"] .chat-scroll {
  background-blend-mode: normal !important;
  background-color: transparent !important;
  background-image: none !important;
}

/* Некоторые минималистичные темы намеренно рисуют ответы агента без карточки,
   полагаясь на общий dialog-canvas. Растровая сцена теперь видна и при штатной
   заливке ленты, поэтому ответу нужна собственная тематическая подложка при
   любом режиме поверхности. Активный ход получает её только в прозрачном
   режиме: в обычном состоянии тему продолжает рисовать его отдельная карточка. */
:root:is(
  :not([data-theme]),
  [data-theme="orbit"],
  [data-theme="blackhole"],
  [data-theme="lake"],
  [data-theme="orange"],
  [data-theme="zero"]
) .msg-agent,
:root[data-chat-surface="transparent"]:is(
  :not([data-theme]),
  [data-theme="orbit"],
  [data-theme="blackhole"],
  [data-theme="lake"],
  [data-theme="orange"],
  [data-theme="zero"]
) .msg-live {
  background: var(--card-bg);
}

.stream-tabs {
  align-items: stretch;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex: 0 0 auto;
  gap: 0.35rem;
  min-height: 3.7rem;
  overflow-x: auto;
  padding: 0.3rem 0.55rem;
  scrollbar-width: thin;
  transform: none !important;
}

.stream-tabs[data-order-mode="activity"] {
  cursor: grab;
}

.stream-tabs[data-order-mode="activity"][data-scroll-drag] {
  cursor: grabbing;
  user-select: none;
}

.stream-tabs[data-order-mode="activity"] .stream-tab {
  cursor: inherit;
}

.stream-tab {
  align-items: stretch;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 650;
  min-height: 3.05rem;
  padding: 0.15rem;
  position: relative;
  text-align: left;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  max-width: 20rem;
  min-width: 12rem;
  width: max-content;
}

.stream-tab-divider {
  align-self: stretch;
  background: color-mix(in srgb, var(--line-strong) 72%, transparent);
  flex: 0 0 1px;
  margin: 0.48rem 0.05rem;
  pointer-events: none;
}

.stream-tab:hover,
.stream-tab:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.stream-tab[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--text);
}

.stream-tab.is-task-drop-target {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
  color: var(--text);
}

.chat-pane.is-task-drop-target {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.stream-tab[draggable="true"] {
  cursor: grab;
}

.stream-tab[draggable="true"]:active {
  cursor: grabbing;
}

.stream-context-menu {
  background-color: var(--bg);
  background-image: var(--card-bg-open);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 1rem 3rem rgb(0 0 0 / 72%), var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 0.16rem;
  max-height: min(32rem, calc(100vh - 1rem));
  min-width: 13.5rem;
  overflow: auto;
  padding: 0.35rem;
  position: fixed;
  scrollbar-gutter: stable;
  width: min(14rem, calc(100vw - 1rem));
  z-index: 90;
}

.stream-context-menu[hidden] {
  display: none;
}

.stream-context-action {
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  max-width: 22rem;
  overflow: hidden;
  padding: 0.48rem 0.58rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.stream-context-action:hover,
.stream-context-action:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.stream-context-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.stream-context-label {
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 0.65rem;
  margin-top: 0.15rem;
  padding: 0.42rem 0.58rem 0.2rem;
}

.stream-context-create {
  color: var(--accent);
}

.stream-context-danger {
  color: #ff9d9d;
}

.stream-context-submenu {
  border-top: 1px solid var(--line);
  box-sizing: border-box;
  margin-top: 0.15rem;
  padding-top: 0.15rem;
  width: 100%;
}

.stream-context-submenu > summary {
  align-items: center;
  display: flex;
  justify-content: space-between;
  list-style: none;
}

.stream-context-submenu > summary::-webkit-details-marker {
  display: none;
}

.stream-context-submenu > summary::after {
  content: "›";
  margin-left: 1rem;
  transform: rotate(90deg);
  transition: transform 0.14s ease;
}

.stream-context-submenu[open] > summary::after {
  transform: rotate(-90deg);
}

.stream-context-submenu-options {
  border-left: 1px solid var(--accent-line);
  display: flex;
  flex-direction: column;
  margin: 0.15rem 0.2rem 0.1rem 0.55rem;
  padding-left: 0.25rem;
}

.stream-tab-card {
  align-items: flex-start;
  background: color-mix(in srgb, var(--surface-2) 68%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  border-radius: calc(var(--radius-md) - 2px);
  display: flex;
  flex: 1 1 auto;
  gap: 0.5rem;
  min-width: 0;
  overflow: hidden;
  padding: 0.42rem 0.5rem;
  position: relative;
}

.stream-tab[aria-pressed="true"] .stream-tab-card {
  border-color: var(--accent-line);
}

.stream-tab-create {
  flex: 0 0 2rem;
  max-width: 2rem;
  min-width: 2rem;
  opacity: 0.58;
  width: 2rem;
}

.context-usage-modal > header,
.context-usage-modal > section,
.context-usage-modal > footer {
  padding: 0.9rem 1rem;
}

.context-usage-modal > header,
.context-usage-modal > footer {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.context-usage-modal > header {
  border-bottom: 1px solid var(--line);
}

.context-usage-modal > footer {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.context-usage-modal h2,
.context-usage-modal p {
  margin: 0;
}

.context-usage-modal h2 {
  font-size: 1rem;
  margin-top: 0.2rem;
}

.context-usage-modal > section {
  display: grid;
  gap: 0.75rem;
  max-height: min(62dvh, 34rem);
  overflow-y: auto;
}

.context-usage-summary,
.context-usage-category-head {
  align-items: baseline;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.context-usage-summary span,
.context-usage-category-head span:last-child {
  color: var(--text-muted);
  font-family: var(--font-numeric);
  font-size: 0.72rem;
}

.context-usage-total-bar,
.context-usage-category-bar {
  background: var(--line);
  border-radius: 999px;
  height: 0.36rem;
  overflow: hidden;
}

.context-usage-total-bar > span,
.context-usage-category-bar > span {
  background: var(--accent);
  display: block;
  height: 100%;
}

.context-usage-categories {
  display: grid;
  gap: 0.65rem;
}

.context-usage-category {
  display: grid;
  gap: 0.3rem;
}

.context-usage-category-head {
  font-size: 0.76rem;
}

.context-usage-category-bar {
  height: 0.24rem;
}

.context-usage-note {
  color: var(--text-faint);
  font-size: 0.7rem;
  line-height: 1.45;
}

.stream-order-toggle {
  align-items: center;
  align-self: stretch;
  appearance: none;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  border-radius: var(--radius-chip);
  box-shadow: none;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  flex: 0 0 2rem;
  font: inherit;
  justify-content: center;
  max-width: 2rem;
  min-height: 3.05rem;
  opacity: 1;
  padding: 0;
  position: relative;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  width: 2rem;
  writing-mode: horizontal-tb;
}

.stream-order-toggle:hover,
.stream-order-toggle:focus-visible {
  background: var(--surface-3);
  border-color: var(--accent-line);
  color: var(--text);
  outline: none;
}

.stream-order-icon {
  color: var(--accent);
  height: 1.1rem;
  width: 1.1rem;
}

.stream-tab-create .stream-tab-card {
  align-items: center;
  border-style: dashed;
  justify-content: center;
  padding: 0;
}

.stream-tab-create:hover,
.stream-tab-create:focus-visible {
  opacity: 1;
}

.stream-tab-create-mark {
  color: var(--accent);
  display: block;
  height: 1.15rem;
  width: 1.15rem;
}

.stream-tab-pin-icon {
  color: var(--accent);
  flex: 0 0 auto;
  height: 0.92rem;
  opacity: 0.9;
  width: 0.92rem;
}

.stream-tab-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.32rem;
  min-width: 0;
}

.stream-tab-title-row,
.stream-tab-meta {
  align-items: center;
  display: flex;
  gap: 0.32rem;
  min-width: 0;
}

.stream-tab-title {
  color: var(--text);
  flex: 1 1 auto;
  font-size: 0.78rem;
  font-weight: 680;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-tab .task-time {
  flex: 0 0 auto;
  font-size: 0.62rem;
}

.stream-tab-meta {
  overflow: hidden;
}

.stream-tab-meta .task-runtime {
  margin-left: auto;
}

/* Один общий набор состояний обслуживает Workspace и Stream во всех темах.
   Темы поставляют только accent-токены; режим меняет характер движения, не
   геометрию интерфейса. Все бесконечные эффекты используют transform/opacity. */
:root[data-stream-status-effect]:not([data-stream-status-effect="off"])
  .task-workspace-item[data-running],
:root[data-stream-status-effect]:not([data-stream-status-effect="off"])
  .task-workspace-item[data-unread]:not([data-running]) {
  border-color: var(--accent-line);
}

:root[data-stream-status-style="fill"]:not([data-stream-status-effect="off"])
  .task-workspace-item > *,
:root[data-stream-status-style="fill"]:not([data-stream-status-effect="off"])
  .stream-tab-card > * {
  position: relative;
  z-index: 1;
}

/* Спокойный: неподвижная сигнальная точка во время хода и зафиксированная
   верхняя риска после ответа. */
:root[data-stream-status-effect="calm"] .task-workspace-item[data-running]::before,
:root[data-stream-status-effect="calm"] .stream-tab[data-running] .stream-tab-status-layer::before {
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0.48rem color-mix(in srgb, var(--accent) 58%, transparent);
  content: "";
  height: 0.34rem;
  opacity: 0.78;
  pointer-events: none;
  position: absolute;
  right: 0.48rem;
  top: calc(50% - 0.17rem);
  width: 0.34rem;
}

:root[data-stream-status-effect="calm"] .task-workspace-item[data-unread]:not([data-running])::before,
:root[data-stream-status-effect="calm"] .stream-tab[data-answer-ready] .stream-tab-status-layer::before {
  background: linear-gradient(90deg, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  content: "";
  height: 1.5px;
  inset: 0 0 auto;
  opacity: 0.82;
  pointer-events: none;
  position: absolute;
}

:root[data-stream-status-style="fill"][data-stream-status-effect="calm"]
  .task-workspace-item[data-running]::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="calm"]
  .task-workspace-item[data-unread]:not([data-running])::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="calm"]
  .stream-tab[data-running] .stream-tab-status-layer::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="calm"]
  .stream-tab[data-answer-ready] .stream-tab-status-layer::before {
  background: var(--accent);
  border-radius: inherit;
  box-shadow: none;
  height: auto;
  inset: 0;
  opacity: 0.08;
  width: auto;
}

:root[data-stream-status-style="fill"][data-stream-status-effect="calm"]
  .task-workspace-item[data-unread]:not([data-running])::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="calm"]
  .stream-tab[data-answer-ready] .stream-tab-status-layer::before {
  opacity: 0.13;
}

/* Импульс: сигнал проходит по контуру, а готовый ответ дважды отвечает
   коротким маяком и остаётся со спокойной световой отметкой. */
:root[data-stream-status-effect="impulse"] .task-workspace-item[data-running]::after,
:root[data-stream-status-effect="impulse"] .stream-tab[data-running] .stream-tab-status-layer::after {
  animation: stream-running-wave 2.2s linear infinite;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 44%, var(--accent) 56%, transparent 100%);
  border-radius: inherit;
  content: "";
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 70%, transparent));
  inset: -1px;
  padding: 4px;
  pointer-events: none;
  position: absolute;
  transform: translateX(-110%);
  width: 58%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

:root[data-stream-status-effect="impulse"]
  .task-workspace-item[data-unread]:not([data-running])::before,
:root[data-stream-status-effect="impulse"]
  .stream-tab[data-answer-ready] .stream-tab-status-layer::before {
  --stream-status-peak: 1;
  border: 2px solid var(--accent);
  border-radius: inherit;
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent);
  content: "";
  inset: -1px;
  opacity: 0.5;
  pointer-events: none;
  position: absolute;
}

:root[data-stream-status-effect="impulse"]
  .task-workspace-item[data-unread][data-answer-arrived]:not([data-running])::before,
:root[data-stream-status-effect="impulse"]
  .stream-tab[data-answer-ready][data-answer-arrived] .stream-tab-status-layer::before {
  animation: stream-answer-ready 1.45s ease-out 2;
}

:root[data-stream-status-style="fill"][data-stream-status-effect="impulse"]
  .task-workspace-item[data-running]::after,
:root[data-stream-status-style="fill"][data-stream-status-effect="impulse"]
  .stream-tab[data-running] .stream-tab-status-layer::after {
  filter: none;
  inset: 0;
  opacity: 0.34;
  padding: 0;
  -webkit-mask: none;
  -webkit-mask-composite: initial;
  mask: none;
  mask-composite: initial;
}

:root[data-stream-status-style="fill"][data-stream-status-effect="impulse"]
  .task-workspace-item[data-unread]:not([data-running])::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="impulse"]
  .stream-tab[data-answer-ready] .stream-tab-status-layer::before {
  --stream-status-peak: 0.42;
  background: var(--accent);
  border: 0;
  box-shadow: none;
  inset: 0;
  opacity: 0.26;
}

/* Сканер: узкий луч проверяет канал; готовность фиксируется быстрой
   центральной развёрткой, которая не продолжает мигать. */
:root[data-stream-status-effect="scanner"] .task-workspace-item[data-running]::after,
:root[data-stream-status-effect="scanner"] .stream-tab[data-running] .stream-tab-status-layer::after {
  animation: stream-scanner-pass 1.85s linear infinite;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 40%, var(--accent) 60%, transparent 100%);
  border-radius: inherit;
  content: "";
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 78%, transparent));
  inset: -1px;
  opacity: 1;
  padding: 4px;
  pointer-events: none;
  position: absolute;
  transform: translateX(-145%);
  width: 30%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

:root[data-stream-status-style="edge"][data-stream-status-effect="impulse"]
  .task-workspace-item[data-running]::after,
:root[data-stream-status-style="edge"][data-stream-status-effect="impulse"]
  .stream-tab[data-running] .stream-tab-status-layer::after,
:root[data-stream-status-style="edge"][data-stream-status-effect="scanner"]
  .task-workspace-item[data-running]::after,
:root[data-stream-status-style="edge"][data-stream-status-effect="scanner"]
  .stream-tab[data-running] .stream-tab-status-layer::after {
  padding: 0;
  -webkit-mask:
    linear-gradient(#000 0 0) top / 100% 2px no-repeat,
    linear-gradient(#000 0 0) bottom / 100% 2px no-repeat;
  -webkit-mask-composite: source-over;
  mask:
    linear-gradient(#000 0 0) top / 100% 2px no-repeat,
    linear-gradient(#000 0 0) bottom / 100% 2px no-repeat;
  mask-composite: add;
}

:root[data-stream-status-effect="scanner"]
  .task-workspace-item[data-unread]:not([data-running])::after,
:root[data-stream-status-effect="scanner"]
  .stream-tab[data-answer-ready] .stream-tab-status-layer::after {
  background: linear-gradient(90deg, transparent, var(--accent) 14%, var(--accent) 86%, transparent);
  border-radius: 2px;
  box-shadow: 0 0 9px color-mix(in srgb, var(--accent) 55%, transparent);
  content: "";
  height: 3px;
  inset: calc(50% - 1.5px) 6% auto;
  opacity: 1;
  pointer-events: none;
  position: absolute;
  transform: scaleX(1);
}

:root[data-stream-status-effect="scanner"]
  .task-workspace-item[data-unread][data-answer-arrived]:not([data-running])::after,
:root[data-stream-status-effect="scanner"]
  .stream-tab[data-answer-ready][data-answer-arrived] .stream-tab-status-layer::after {
  animation: stream-scanner-lock 0.72s ease-out 2;
}

:root[data-stream-status-style="fill"][data-stream-status-effect="scanner"]
  .task-workspace-item[data-running]::after,
:root[data-stream-status-style="fill"][data-stream-status-effect="scanner"]
  .stream-tab[data-running] .stream-tab-status-layer::after {
  filter: none;
  inset: 0;
  opacity: 0.28;
  padding: 0;
  -webkit-mask: none;
  -webkit-mask-composite: initial;
  mask: none;
  mask-composite: initial;
}

:root[data-stream-status-style="fill"][data-stream-status-effect="scanner"]
  .task-workspace-item[data-unread]:not([data-running])::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="scanner"]
  .stream-tab[data-answer-ready] .stream-tab-status-layer::before {
  background: var(--accent);
  border-radius: inherit;
  content: "";
  inset: 0;
  opacity: 0.26;
  pointer-events: none;
  position: absolute;
}

/* Энергия: ход циклически набирает заряд слева направо; после ответа заряд
   дважды расширяется и остаётся заполненным до открытия Stream. */
:root[data-stream-status-effect="energy"] .task-workspace-item[data-running]::before,
:root[data-stream-status-effect="energy"] .stream-tab[data-running] .stream-tab-status-layer::before,
:root[data-stream-status-effect="energy"]
  .task-workspace-item[data-unread]:not([data-running])::before,
:root[data-stream-status-effect="energy"]
  .stream-tab[data-answer-ready] .stream-tab-status-layer::before {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 46%, transparent), var(--accent));
  border-radius: 3px;
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 50%, transparent);
  content: "";
  height: 5px;
  inset: auto 0 0;
  opacity: 1;
  pointer-events: none;
  position: absolute;
  transform: scaleX(1);
  transform-origin: left center;
}

:root[data-stream-status-effect="energy"] .task-workspace-item[data-running]::before,
:root[data-stream-status-effect="energy"] .stream-tab[data-running] .stream-tab-status-layer::before {
  animation: stream-energy-charge 2.65s cubic-bezier(0.22, 0.65, 0.3, 1) infinite;
}

:root[data-stream-status-effect="energy"]
  .task-workspace-item[data-unread][data-answer-arrived]:not([data-running])::before,
:root[data-stream-status-effect="energy"]
  .stream-tab[data-answer-ready][data-answer-arrived] .stream-tab-status-layer::before {
  animation: stream-energy-ready 0.92s ease-out 2;
}

:root[data-stream-status-style="fill"][data-stream-status-effect="energy"]
  .task-workspace-item[data-running]::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="energy"]
  .stream-tab[data-running] .stream-tab-status-layer::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="energy"]
  .task-workspace-item[data-unread]:not([data-running])::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="energy"]
  .stream-tab[data-answer-ready] .stream-tab-status-layer::before {
  border-radius: inherit;
  box-shadow: none;
  height: auto;
  inset: 0;
  opacity: 0.28;
}

:root[data-stream-status-style="fill"][data-stream-status-effect="energy"]
  .task-workspace-item[data-unread]:not([data-running])::before,
:root[data-stream-status-style="fill"][data-stream-status-effect="energy"]
  .stream-tab[data-answer-ready] .stream-tab-status-layer::before {
  opacity: 0.4;
}

/* Верхняя desktop-оболочка едина для всех тем. Shell применяет геометрию и
   разрешает темам выбирать только объявленные ниже радиусы и зазоры токенами. */
@media (min-width: 860px) {
  html:not([data-surface="mobile"]) .app-header {
    backdrop-filter: var(--shell-header-backdrop-filter, blur(18px) saturate(150%)) !important;
    -webkit-backdrop-filter: var(--shell-header-backdrop-filter, blur(18px) saturate(150%)) !important;
    background: var(--shell-header-background, color-mix(in srgb, var(--bg) 82%, transparent)) !important;
    border: 0 !important;
    border-bottom: var(--shell-header-border, 1px solid var(--line)) !important;
    border-radius: 0 !important;
    box-shadow: var(--shell-header-shadow, none) !important;
    box-sizing: border-box !important;
    height: var(--shell-header-height, auto) !important;
    min-height: var(--shell-header-height, auto) !important;
  }

  html:not([data-surface="mobile"]) .app-header::after {
    background: var(--shell-header-rule, linear-gradient(90deg, transparent, var(--accent-line), transparent)) !important;
    bottom: var(--shell-header-rule-bottom, -1px) !important;
    box-shadow: none !important;
    height: var(--shell-header-rule-height, 1px) !important;
    left: var(--shell-header-rule-left, 0) !important;
    opacity: var(--shell-header-rule-opacity, 0.7) !important;
    right: var(--shell-header-rule-right, 0) !important;
  }

  html:not([data-surface="mobile"]) .app-header-inner {
    gap: var(--shell-header-gap, 1rem) !important;
    height: 100% !important;
    margin: 0 !important;
    max-width: none !important;
    padding-left: var(--shell-header-content-padding-left, var(--shell-header-padding-left, clamp(1rem, 4vw, 4.25rem))) !important;
    padding-right: var(--shell-header-content-padding-right, var(--shell-header-padding-right, clamp(1rem, 4vw, 4.25rem))) !important;
    width: 100% !important;
  }

  html:not([data-surface="mobile"]) .view-switch {
    background: var(--shell-view-switch-background, var(--shell-control-background, var(--surface-1))) !important;
    border: var(--shell-view-switch-border, var(--shell-control-border, 1px solid var(--line))) !important;
    border-radius: var(--shell-view-switch-radius, 4px) !important;
    box-shadow: var(--shell-view-switch-shadow, var(--shell-control-shadow, none)) !important;
    gap: var(--shell-view-switch-gap, 0.15rem) !important;
    padding: var(--shell-view-switch-padding, 0.18rem) !important;
    transform: var(--shell-view-switch-transform, none) !important;
  }

  html:not([data-surface="mobile"]) .connection-banner:not([hidden]) {
    display: var(--shell-connection-banner-display, flex) !important;
  }

  html:not([data-surface="mobile"]) .view-tab {
    background: var(--shell-tab-background, transparent) !important;
    border: var(--shell-tab-border, 1px solid transparent) !important;
    border-radius: var(--shell-tab-radius, 3px) !important;
    box-shadow: var(--shell-tab-shadow, none) !important;
    min-height: 2rem !important;
    padding: 0.32rem 0.75rem !important;
    transform: none !important;
  }

  html:not([data-surface="mobile"]) .view-tab::before,
  html:not([data-surface="mobile"]) .view-tab::after {
    content: none !important;
  }

  html:not([data-surface="mobile"]) .view-tab[aria-pressed="true"] {
    background: var(--shell-tab-active-background, var(--accent-soft)) !important;
    border: var(--shell-tab-active-border, 1px solid var(--accent-line)) !important;
    box-shadow: var(--shell-tab-active-shadow, none) !important;
    color: var(--shell-tab-active-color, var(--accent)) !important;
    padding: var(--shell-tab-active-padding, 0.32rem 0.75rem) !important;
  }

  html:not([data-surface="mobile"]) .toolbar .view-settings {
    background: var(--shell-control-background, var(--surface-2)) !important;
    border: var(--shell-control-border, 1px solid var(--line)) !important;
    border-radius: var(--shell-control-radius, 3px) !important;
    box-shadow: var(--shell-control-shadow, none) !important;
    min-height: 2rem !important;
    padding: 0.3rem 0.75rem 0.3rem 0.6rem !important;
    transform: none !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .task-rail,
  html[data-view="chat"]:not([data-surface="mobile"]) .activity-rail,
  html[data-view="chat"]:not([data-surface="mobile"]) .chat {
    border: var(--shell-panel-border, 1px solid var(--line)) !important;
    border-image: var(--shell-panel-border-image, none) !important;
    border-image-width: var(--shell-panel-border-image-width, var(--shell-panel-border-width, 1px)) !important;
    border-width: var(--shell-panel-border-width, 1px) !important;
    border-radius: var(--shell-panel-radius, 4px) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .task-rail {
    border-image-width: var(--shell-task-panel-border-image-width, var(--shell-panel-border-image-width, var(--shell-panel-border-width, 1px))) !important;
    border-width: var(--shell-task-panel-border-width, var(--shell-panel-border-width, 1px)) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .activity-rail {
    border-image-width: var(--shell-activity-panel-border-image-width, var(--shell-panel-border-image-width, var(--shell-panel-border-width, 1px))) !important;
    border-width: var(--shell-activity-panel-border-width, var(--shell-panel-border-width, 1px)) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .chat {
    border: var(--shell-chat-border, var(--shell-panel-border, 1px solid var(--line))) !important;
    border-image: var(--shell-chat-border-image, var(--shell-panel-border-image, none)) !important;
    border-image-width: var(--shell-chat-panel-border-image-width, var(--shell-panel-border-image-width, var(--shell-panel-border-width, 1px))) !important;
    border-width: var(--shell-chat-panel-border-width, var(--shell-panel-border-width, 1px)) !important;
    border-radius: var(--shell-chat-radius, var(--shell-panel-radius, 4px)) !important;
    gap: var(--shell-chat-gap, 0) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tabs {
    align-items: stretch !important;
    background: var(--shell-stream-tabs-background, color-mix(in srgb, var(--surface-1) 88%, transparent)) !important;
    border: var(--shell-stream-tabs-border, 0) !important;
    border-bottom: var(--shell-stream-tabs-border-bottom, 1px solid var(--line)) !important;
    border-image: var(--shell-stream-tabs-border-image, none) !important;
    border-radius: var(--shell-stream-tabs-radius, 0) !important;
    gap: var(--shell-stream-tabs-gap, 0.35rem) !important;
    margin-top: var(--shell-stream-tabs-margin-top, 0) !important;
    min-height: var(--shell-stream-tabs-min-height, 3.7rem) !important;
    padding: var(--shell-stream-tabs-padding, 0.3rem 0.55rem) !important;
  }

  html[data-theme="bespin"][data-view="chat"][data-surface]:not([data-surface="mobile"]) .stream-tabs {
    border: var(--shell-stream-tabs-border, 0) !important;
    border-bottom: var(--shell-stream-tabs-border-bottom, 1px solid var(--line)) !important;
    border-radius: var(--shell-stream-tabs-radius, 0) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tabs::before {
    content: none !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tab {
    background: var(--shell-stream-tab-background, transparent) !important;
    border: var(--shell-stream-tab-border, 1px solid transparent) !important;
    border-radius: var(--shell-stream-tab-radius, 3px) !important;
    box-shadow: var(--shell-stream-tab-shadow, none) !important;
    flex: 0 0 auto !important;
    max-width: var(--shell-stream-tab-max-width, 20rem) !important;
    min-width: var(--shell-stream-tab-min-width, 12rem) !important;
    min-height: var(--shell-stream-tab-min-height, 3.05rem) !important;
    padding: var(--shell-stream-tab-padding, 0.15rem) !important;
    transform: none !important;
    width: var(--shell-stream-tab-width, max-content) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tab-create {
    flex: 0 0 var(--shell-stream-create-width, 2rem) !important;
    max-width: var(--shell-stream-create-width, 2rem) !important;
    min-width: var(--shell-stream-create-width, 2rem) !important;
    width: var(--shell-stream-create-width, 2rem) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-order-toggle {
    align-self: stretch !important;
    background: var(--shell-stream-order-background, var(--surface-2)) !important;
    border: 1px solid color-mix(in srgb, var(--line) 74%, transparent) !important;
    border-image: none !important;
    border-radius: var(--shell-stream-tab-radius, 3px) !important;
    box-shadow: none !important;
    flex-basis: 2rem !important;
    margin-block: var(--shell-stream-tab-padding, 0.15rem) !important;
    max-width: 2rem !important;
    min-height: 0 !important;
    padding: 0 !important;
    transform: none !important;
    width: 2rem !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tab:hover,
  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tab:focus-visible {
    background: var(--shell-stream-tab-hover-background, var(--surface-2)) !important;
    border-color: transparent !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tab[aria-pressed="true"] {
    background: var(--shell-stream-tab-active-background, var(--accent-soft)) !important;
    border-color: var(--accent-line) !important;
    color: var(--text) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tab-card {
    background: var(--shell-stream-card-background, color-mix(in srgb, var(--surface-2) 68%, transparent)) !important;
    border: var(--shell-stream-card-border, 1px solid color-mix(in srgb, var(--line) 74%, transparent)) !important;
    border-image: var(--shell-stream-card-border-image, none) !important;
    border-radius: var(--shell-stream-card-radius, 3px) !important;
    box-shadow: var(--shell-stream-card-shadow, none) !important;
    gap: var(--shell-stream-card-gap, 0.5rem) !important;
    padding: var(--shell-stream-card-padding, 0.42rem 0.5rem) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tab-create {
    max-width: var(--shell-stream-create-width, 2rem) !important;
    width: var(--shell-stream-create-width, 2rem) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-tab-create .stream-tab-card {
    border: 1px dashed color-mix(in srgb, var(--line) 74%, transparent) !important;
    border-image: none !important;
    padding: 0 !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]) .stream-order-toggle:hover,
  html[data-view="chat"]:not([data-surface="mobile"]) .stream-order-toggle:focus-visible {
    background: var(--shell-stream-tab-hover-background, var(--surface-3)) !important;
    border-color: var(--accent-line) !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"])
    .stream-tab[aria-pressed="true"] .stream-tab-card {
    border-color: var(--accent-line) !important;
  }

  /* «Апельсин» использует одну внешнюю рамку выбранного Stream. */
  html[data-theme="orange"][data-view="chat"]:not([data-surface="mobile"])
    .stream-tab[aria-pressed="true"] .stream-tab-card {
    border-color: transparent !important;
  }

  html[data-theme="orange"][data-view="chat"]:not([data-surface="mobile"])
    .stream-tab[aria-pressed="true"]:focus-visible {
    outline: none !important;
  }

  html[data-stream-card-settings="true"]:not([data-surface="mobile"]) .stream-order-toggle {
    display: none !important;
  }

  html[data-stream-card-settings="true"]:not([data-surface="mobile"]) .stream-tabs-overflow {
    padding-inline: 0 !important;
    transform: translateX(calc(-1 * var(--stream-overflow-shift, 0px)));
    z-index: 43;
  }

  html:not([data-surface="mobile"]) .stream-card-settings {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    margin-left: auto;
    margin-right: 0.375rem;
    position: relative;
    z-index: 44;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-toggle {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--shell-stream-tab-radius, 3px);
    color: var(--text-muted);
    display: inline-flex;
    height: 2rem;
    justify-content: center;
    padding: 0;
    width: 2rem;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-toggle:hover,
  html:not([data-surface="mobile"]) .stream-card-settings-toggle[aria-expanded="true"] {
    background: var(--surface-3);
    border-color: var(--accent-line);
    color: var(--text);
  }

  html:not([data-surface="mobile"]) .stream-card-settings-icon {
    display: block;
    height: 0.95rem;
    width: 0.95rem;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-menu {
    background: var(--surface-1);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 28px rgb(0 0 0 / 42%);
    color: var(--text);
    max-height: calc(100dvh - 5rem);
    min-width: 20rem;
    overflow-y: auto;
    padding: 0.45rem;
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    width: min(22rem, calc(100vw - 2rem));
    z-index: 90;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-menu[hidden],
  html:not([data-surface="mobile"]) .stream-card-settings-range[hidden] {
    display: none !important;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-section {
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: inherit;
    display: grid;
    gap: 0.45rem;
    margin-top: 0.4rem;
    padding: 0.65rem;
    text-align: left;
    width: 100%;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-group {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.7rem;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-group:first-child {
    margin-top: 0;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-group-head {
    align-items: center;
    display: flex;
    gap: 0.65rem;
    justify-content: space-between;
    padding-right: 0.65rem;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-options {
    display: grid;
    gap: 0.4rem;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-options[hidden] {
    display: none;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-group-title {
    color: var(--text-muted);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    margin: 0;
    padding: 0.15rem 0.1rem 0;
    text-transform: uppercase;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-group .stream-card-settings-section {
    margin-top: 0;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-inline-section {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) minmax(9rem, 1.25fr);
  }

  html:not([data-surface="mobile"]) .stream-card-settings-recent-section {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-kicker {
    color: var(--text-faint);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-gap-section {
    align-items: center;
    grid-template-columns: 1fr auto;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-duration {
    display: block;
    width: 6rem;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-duration label {
    align-items: center;
    color: var(--text-muted);
    display: grid;
    font-size: 0.72rem;
    gap: 0.3rem;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-duration input,
  html:not([data-surface="mobile"]) [data-stream-status-effect-select] {
    background: var(--surface-1);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    min-height: 1.9rem;
    padding: 0.3rem 0.45rem;
    width: 100%;
  }

  html:not([data-surface="mobile"]) .stream-card-gap-toggle {
    appearance: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: block;
    padding: 0;
  }

  html:not([data-surface="mobile"]) .stream-card-gap-toggle .switch-track {
    display: block;
  }

  html:not([data-surface="mobile"])
    .stream-card-gap-toggle[aria-checked="true"] .switch-track {
    background: var(--accent-soft);
    border-color: var(--accent-line);
  }

  html:not([data-surface="mobile"])
    .stream-card-gap-toggle[aria-checked="true"] .switch-track::after {
    background: var(--accent);
    transform: translateX(1.05rem);
  }

  html:not([data-surface="mobile"])
    .stream-card-gap-toggle:focus-visible .switch-track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-segmented button {
    background: var(--surface-1);
    border: 1px solid var(--line);
    color: var(--text-muted);
    min-height: 1.8rem;
    white-space: nowrap;
  }

  html:not([data-surface="mobile"])
    .stream-card-settings-segmented button[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--text);
  }

  html:not([data-surface="mobile"]) .stream-card-settings-range {
    color: var(--text-muted);
    display: grid;
    font-size: 0.7rem;
    gap: 0.3rem;
    grid-column: 1 / -1;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-range input {
    accent-color: var(--accent);
    margin: 0;
    width: 100%;
  }

  html:not([data-surface="mobile"]) .stream-card-settings-range small {
    color: var(--text-faint);
  }

  html:not([data-surface="mobile"])
    .stream-tabs[data-stream-card-gap-mode="on"] .stream-tabs-track {
    column-gap: 3px !important;
  }

  html:not([data-surface="mobile"])
    .stream-tabs .task-time[data-compact-stream-time] {
    font-size: 0 !important;
  }

  html:not([data-surface="mobile"])
    .stream-tabs .task-time[data-compact-stream-time]::after {
    content: attr(data-compact-stream-time);
    font-size: var(--stream-task-time-font-size, 0.62rem);
  }
}

@media (min-width: 860px) {
  html[data-view="chat"]:not([data-surface="mobile"]):not([data-activity-stream-cards="detailed"])
    .activity-stream-item {
    --shell-stream-card-gap: 0.34rem;
    --shell-stream-card-padding: 0.22rem 0.38rem;
    --shell-stream-tab-min-height: 2.05rem;
    --shell-stream-tab-padding: 0.05rem;
    font-size: 0.68rem;
  }

  html[data-view="chat"]:not([data-surface="mobile"]):not([data-activity-stream-cards="detailed"])
    .activity-stream-item .stream-tab-meta {
    display: none !important;
  }

  html[data-view="chat"]:not([data-surface="mobile"]):not([data-activity-stream-cards="detailed"])
    .activity-stream-item .stream-tab-title-row {
    gap: 0.4rem;
  }
}

@keyframes stream-running-wave {
  to { transform: translateX(300%); }
}

/* Кольцо статуса во вкладке двигает не сам слой, а градиент внутри него,
   поэтому у него отдельный ключевой кадр. Объявление обязано быть на верхнем
   уровне: dialog-area.css целиком вложен в правило html[...], а вложенность
   CSS допускает внутри правила только @media, @supports, @layer, @scope и
   @container — @keyframes оттуда молча выбрасывается. */
@keyframes stream-tab-ring-sweep {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@keyframes stream-answer-ready {
  0% { opacity: 0.08; transform: scale(0.98); }
  46% { opacity: var(--stream-status-peak, 0.68); transform: scale(1.025); }
  100% { opacity: 0.2; transform: scale(1); }
}

@keyframes stream-scanner-pass {
  to { transform: translateX(420%); }
}

@keyframes stream-scanner-lock {
  from { opacity: 0; transform: scaleX(0.04); }
}

@keyframes stream-energy-charge {
  0% { opacity: 0.3; transform: scaleX(0.04); }
  72% { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1); }
}

@keyframes stream-energy-ready {
  0% { opacity: 0.16; transform: scaleX(0.72); }
  52% { opacity: 0.92; transform: scaleX(1); }
  100% { opacity: 0.72; transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-stream-status-effect="impulse"] .task-workspace-item[data-running]::after,
  :root[data-stream-status-effect="impulse"] .stream-tab[data-running] .stream-tab-status-layer::after {
    animation: none;
    transform: translateX(70%);
  }

  :root[data-stream-status-effect="scanner"] .task-workspace-item[data-running]::after,
  :root[data-stream-status-effect="scanner"] .stream-tab[data-running] .stream-tab-status-layer::after {
    animation: none;
    transform: translateX(96%);
  }

  :root[data-stream-status-effect="energy"] .task-workspace-item[data-running]::before,
  :root[data-stream-status-effect="energy"] .stream-tab[data-running] .stream-tab-status-layer::before {
    animation: none;
    opacity: 0.72;
    transform: scaleX(0.72);
  }

  :root[data-stream-status-effect]:not([data-stream-status-effect="off"])
    .task-workspace-item[data-unread]:not([data-running])::before,
  :root[data-stream-status-effect]:not([data-stream-status-effect="off"])
    .task-workspace-item[data-unread]:not([data-running])::after,
  :root[data-stream-status-effect]:not([data-stream-status-effect="off"])
    .stream-tab[data-answer-ready] .stream-tab-status-layer::before,
  :root[data-stream-status-effect]:not([data-stream-status-effect="off"])
    .stream-tab[data-answer-ready] .stream-tab-status-layer::after {
    animation: none;
  }
}

/* Wide surfaces can inspect several Streams from one Workspace at once. The
   shared composer stays below the complete deck; the selected Stream owns it
   and is marked by a theme-coloured glow across the full chat column. */
.stream-chat-columns {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.stream-chat-columns[data-multi-stream] {
  grid-template-columns: repeat(var(--stream-chat-count, 1), minmax(13rem, 1fr));
  overflow-x: auto;
}

.stream-chat-columns > .chat-pane,
.stream-chat-preview {
  min-width: 0;
}

.stream-chat-columns[data-multi-stream] > .chat-pane[data-active-stream] {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  box-shadow:
    inset 0 0 0 1px var(--accent-line),
    inset 0 0 2.4rem color-mix(in srgb, var(--accent) 12%, transparent),
    0 0 1rem color-mix(in srgb, var(--accent) 18%, transparent);
  position: relative;
  transition: background 0.18s ease, box-shadow 0.18s ease;
  z-index: 1;
}

.stream-chat-preview {
  background: color-mix(in srgb, var(--card-bg) 86%, transparent);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.stream-chat-preview-head {
  align-items: baseline;
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex: 0 0 auto;
  gap: 0.55rem;
  justify-content: space-between;
  min-width: 0;
  padding: 0.55rem 0.75rem;
}

.stream-chat-preview-title,
.stream-chat-preview-workspace {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-chat-preview-title {
  color: var(--text);
  font-size: 0.78rem;
}

.stream-chat-preview-workspace {
  color: var(--text-faint);
  font-size: 0.68rem;
}

.stream-chat-preview-log {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.stream-chat-preview-empty {
  color: var(--text-faint);
  font-size: 0.8rem;
  margin: 1rem 0;
  text-align: center;
}

.stream-chat-preview-live-card {
  border-color: var(--accent-line);
}

.chat-scroll-down {
  align-items: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--surface-3) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-line) 72%, var(--line));
  border-radius: 0.65rem;
  bottom: 0.85rem;
  box-shadow: 0 0.45rem 1rem rgb(0 0 0 / 0.24);
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  font: 600 0.78rem/1 var(--font-body);
  gap: 0.38rem;
  height: 2rem;
  justify-content: center;
  min-width: 0;
  padding: 0 0.72rem;
  position: absolute;
  right: max(0.75rem, var(--gutter-right));
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
  width: auto;
  z-index: 9;
}

.chat-scroll-down[hidden] {
  display: none;
}

.chat-scroll-down:hover,
.chat-scroll-down:focus-visible {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-3));
  border-color: var(--accent);
  color: var(--text);
  outline: none;
  transform: translateY(-1px);
}

.chat-scroll-down svg {
  flex: 0 0 auto;
  height: 0.84rem;
  width: 0.84rem;
}

.chat-scroll-label {
  white-space: nowrap;
}

.chat-scroll-count {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  color: var(--surface-1);
  display: inline-flex;
  font-size: 0.64rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  height: 1rem;
  justify-content: center;
  min-width: 1rem;
  padding: 0 0.28rem;
}

.chat-scroll-count[hidden] {
  display: none;
}

.chat-scroll-working {
  display: none;
  gap: 0.16rem;
}

.chat-scroll-working i {
  animation: chat-scroll-working-pulse 1s ease-in-out infinite;
  background: currentColor;
  border-radius: 50%;
  height: 0.22rem;
  width: 0.22rem;
}

.chat-scroll-working i:nth-child(2) { animation-delay: 0.12s; }
.chat-scroll-working i:nth-child(3) { animation-delay: 0.24s; }
.chat-scroll-down[data-working] {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface-3));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--accent-line));
  color: color-mix(in srgb, var(--accent) 74%, var(--text));
}
.chat-scroll-down[data-working] svg,
.chat-scroll-down[data-working] .chat-scroll-count { display: none; }
.chat-scroll-down[data-working] .chat-scroll-working { display: inline-flex; }

@keyframes chat-scroll-working-pulse {
  0%, 70%, 100% { opacity: 0.35; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-0.15rem); }
}

.stream-chat-preview > .chat-scroll-down {
  right: 0.75rem;
}

.chat-empty {
  align-items: center;
  color: var(--text-faint);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  justify-content: center;
  margin: auto;
  max-width: 22rem;
  padding: 2rem;
  text-align: center;
}

.chat-empty-mark {
  align-items: center;
  background: var(--brand-gradient);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--brand-shadow);
  color: var(--accent);
  display: flex;
  height: 3.4rem;
  justify-content: center;
  width: 3.4rem;
}

.chat-empty-mark svg {
  height: 1.6rem;
  width: 1.6rem;
}

.chat-pane {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  position: relative;
  width: 100%;
}

.chat-pane[data-dialog-settings-open] {
  grid-template-columns: minmax(0, 1fr);
}

.stream-chat-columns[data-multi-stream] > .chat-pane[data-dialog-settings-open] {
  grid-template-columns: minmax(0, 1fr);
}

.chat-back {
  display: none;
}

/* Ранг модели читается насыщенностью, а не отдельным цветом: флагман берёт
   акцент активной темы, обычная модель — нейтральный текст, лёгкая гаснет.
   Так плашка остаётся уместной и в «Магме», и в «Озере», и в «Графите». */
.task-model[data-model-tier] {
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  padding: 0.02rem 0.4rem;
}

.task-model[data-model-tier="flagship"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: var(--accent-glow);
  color: var(--accent);
  font-weight: 620;
}

.task-model[data-model-tier="balanced"] {
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  border-color: var(--line);
  color: var(--text-soft);
}

.task-model[data-model-tier="light"] {
  background: none;
  border-color: color-mix(in srgb, var(--line) 60%, transparent);
  border-style: dashed;
  color: var(--text-faint);
}

.chat-overlay-actions {
  align-items: center;
  display: flex;
  gap: 0.4rem;
  position: absolute;
  right: max(0.65rem, var(--gutter-right));
  top: 0.55rem;
  z-index: 8;
}

[data-dialog-settings-toggle][aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.chat-overlay-actions > .chip-button {
  height: 2.1rem;
  justify-content: center;
  padding-block: 0;
}

.chat-overlay-actions > .chip-button svg,
.workspace-message-search svg {
  height: 1rem;
  width: 1rem;
}

.workspace-message-search {
  background:
    radial-gradient(90% 45% at 100% 0%, var(--space-glow-a), transparent 65%),
    color-mix(in srgb, var(--space-base) 96%, transparent);
  border-bottom: 1px solid var(--line-strong);
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  left: 0;
  min-height: 0;
  padding: 1rem max(1rem, var(--gutter-right)) 1.2rem max(1rem, var(--gutter-left));
  position: absolute;
  right: 0;
  top: 3.7rem;
  z-index: 30;
}

.workspace-message-search[hidden] {
  display: none;
}

.workspace-message-search-head,
.workspace-message-search-head > div,
.workspace-message-search-hit-meta {
  align-items: center;
  display: flex;
}

.workspace-message-search-head {
  gap: 1rem;
  justify-content: space-between;
}

.workspace-message-search-head > div {
  gap: 0.6rem;
  min-width: 0;
}

.workspace-message-search-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-message-search-head [data-workspace-message-search-count] {
  color: var(--text-muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.workspace-message-search-input {
  align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  color: var(--text-muted);
  display: flex;
  gap: 0.55rem;
  padding: 0 0.75rem;
}

.workspace-message-search-input:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
  color: var(--accent);
}

.workspace-message-search-input input {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  min-height: 2.65rem;
  min-width: 0;
  outline: 0;
  width: 100%;
}

.workspace-message-search-status {
  color: var(--text-muted);
  font-size: 0.84rem;
  margin: 0;
  padding: 0.4rem 0;
}

.workspace-message-search-results {
  display: grid;
  gap: 0.85rem;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 0 0.2rem 0.25rem 0;
}

.workspace-message-search-group {
  display: grid;
  gap: 0.25rem;
}

.workspace-message-search-group-head {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.75rem;
  gap: 0.45rem;
  padding: 0.2rem 0.35rem;
}

.workspace-message-search-group-head span {
  background: var(--surface-2);
  border-radius: var(--radius-chip);
  min-width: 1.45rem;
  padding: 0.05rem 0.38rem;
  text-align: center;
}

.workspace-message-search-hit {
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  color: var(--text);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  text-align: left;
  width: 100%;
}

.workspace-message-search-hit:hover,
.workspace-message-search-hit:focus-visible {
  background: var(--surface-2);
  border-color: var(--accent-line);
  outline: none;
}

.workspace-message-search-hit-meta {
  color: var(--text-muted);
  font-size: 0.72rem;
  gap: 0.5rem;
}

.workspace-message-search-hit-meta strong {
  color: var(--text-soft);
}

.workspace-message-search-field {
  background: var(--accent-soft);
  border-radius: var(--radius-chip);
  color: var(--accent);
  padding: 0.04rem 0.35rem;
}

.workspace-message-search-snippet {
  font-size: 0.86rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.workspace-message-search-snippet mark {
  background: var(--accent-soft);
  border-radius: 0.18rem;
  color: var(--text);
  padding: 0 0.08rem;
}

.workspace-message-search-more {
  align-self: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  min-height: 2.35rem;
  padding: 0.35rem 1rem;
}

.msg[data-search-match] {
  box-shadow: 0 0 0 2px var(--accent), var(--accent-glow);
}

/* ---- лента сообщений ---- */

.chat-scroll {
  flex: 1 1 auto;
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 3.55rem var(--gutter-right) 0.75rem var(--gutter-left);
}

.dialog-settings {
  /* Общая мера правой колонки карточки: чип агента, селекты и тумблеры
     выстраиваются по одному левому и правому краю. */
  --dialog-control-width: 13rem;
  --dialog-control-height: 2.125rem;
  background:
    radial-gradient(120% 60% at 90% -20%, var(--space-glow-a), transparent 60%),
    color-mix(in srgb, var(--space-base) 96%, transparent);
  border: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  height: min(90dvh, 56rem);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.dialog-settings[hidden] {
  display: none;
}

.dialog-settings:not([open]) {
  display: none;
}

.dialog-settings-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex: 0 0 auto;
  gap: 0.6rem;
  justify-content: space-between;
  min-height: 3rem;
  padding: 0.7rem 0.9rem;
}

.dialog-settings-head h2 {
  color: var(--text);
  flex: 1 1 auto;
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: var(--display-weight);
  margin: 0;
}

.dialog-settings-close {
  flex: 0 0 auto;
}

.stream-chat-columns[data-multi-stream] > .chat-pane[data-dialog-settings-open] .dialog-settings {
  bottom: 0;
  box-shadow: -1rem 0 1.8rem rgb(0 0 0 / 0.26);
  max-width: min(22rem, 100%);
  position: absolute;
  right: 0;
  top: 0;
  width: clamp(17rem, 28vw, 22rem);
  z-index: 20;
}

.dialog-settings-body {
  min-height: 0;
  overflow-y: auto;
  padding: 0.85rem 0.8rem max(1rem, env(safe-area-inset-bottom));
}

/* Подписи полей карточки Stream — той же меры, что в карточках Workspace
   и задачи; общая настроечная панель приложения свой размер сохраняет. */
.dialog-settings .setting-name,
.dialog-settings .switch-text,
.dialog-settings .setting-value {
  font-size: var(--card-label-size);
}

.quick-messages-editor {
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius-md) + 0.15rem);
  margin-inline: auto;
  max-width: 38.75rem;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.workspace-card-fields .quick-messages-editor {
  min-height: max-content;
}

.quick-message-editor-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  min-height: 3rem;
  padding: 0.75rem 1rem;
}

.quick-message-editor-header .setting-name {
  align-items: center;
  display: inline-flex;
  font-family: var(--font-numeric);
  font-size: 0.72rem;
  font-weight: 600;
  gap: 0.55rem;
  letter-spacing: 0.075em;
  min-width: 0;
  text-transform: uppercase;
}

.quick-message-editor-header .setting-name::before {
  background: var(--accent);
  border-radius: 50%;
  content: "";
  flex: 0 0 auto;
  height: 0.4rem;
  width: 0.4rem;
}

.quick-message-editor-header .setting-value {
  color: var(--text-muted);
  flex: 0 0 auto;
  font-family: var(--font-numeric);
  font-size: 0.72rem;
}

.quick-messages-editor-controls {
  min-width: 0;
}

.quick-message-editor-rows {
  min-width: 0;
}

.quick-message-editor-rows:empty {
  display: none;
}

.quick-message-editor-row {
  background: color-mix(in srgb, var(--surface-1) 72%, transparent);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.quick-message-editor-row.is-open {
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
}

.quick-message-editor-summary-row {
  align-items: center;
  display: grid;
  column-gap: 0.5rem;
  row-gap: 0.25rem;
  grid-template-columns: minmax(0, 1fr) auto auto;
  min-width: 0;
  padding: 0.35rem 0.65rem 0.35rem 0.9rem;
}

.quick-message-editor-summary {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  display: grid;
  gap: 0.65rem;
  grid-template-columns: auto minmax(5rem, auto) minmax(0, 1fr);
  min-height: 2.65rem;
  min-width: 0;
  padding: 0.35rem 0.45rem;
  text-align: left;
  width: 100%;
}

.quick-message-editor-summary:hover:not(:disabled),
.quick-message-editor-summary:focus-visible,
.quick-message-editor-action:hover:not(:disabled),
.quick-message-editor-action:focus-visible,
.quick-message-editor-add:hover:not(:disabled),
.quick-message-editor-add:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
}

.quick-message-editor-number {
  background: var(--surface-3);
  border-radius: 0.35rem;
  color: var(--text-muted);
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.35rem;
}

.quick-message-editor-title {
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-message-editor-preview {
  color: var(--text-muted);
  font-size: 0.78rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-message-editor-chevron,
.quick-message-editor-action-icon,
.quick-message-editor-add-icon {
  fill: currentColor;
  height: 1rem;
  width: 1rem;
}

.quick-message-editor-order,
.quick-message-editor-footer-order,
.quick-message-editor-footer {
  align-items: center;
  display: flex;
}

.quick-message-editor-order {
  gap: 0.1rem;
}

.quick-message-editor-action {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-flex;
  font: inherit;
  font-size: 0.76rem;
  gap: 0.35rem;
  justify-content: center;
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
}

.quick-message-editor-order .quick-message-editor-action {
  border-color: transparent;
  min-width: 2rem;
  padding: 0.35rem;
}

.quick-message-editor-action.toggle {
  border-color: transparent;
  min-width: 2rem;
  padding: 0.35rem;
}

.quick-message-editor-action.danger {
  color: var(--danger, #ff7b7b);
}

.quick-message-editor-action:disabled,
.quick-message-editor-add:disabled,
.quick-message-editor-summary:disabled {
  cursor: default;
  opacity: 0.42;
}

.quick-message-editor-details {
  display: grid;
  gap: 0.65rem;
  padding: 0.15rem 1rem 0.9rem;
}

.quick-message-editor-details[hidden] {
  display: none;
}

.quick-message-editor-row input,
.quick-message-editor-row textarea,
.stream-card-name-field input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 0.45rem 0.55rem;
  width: 100%;
}

.quick-message-editor-row textarea {
  line-height: 1.5;
  min-height: 6.5rem;
  resize: vertical;
}

.quick-message-editor-footer {
  gap: 0.6rem;
  justify-content: space-between;
  min-width: 0;
}

.quick-message-editor-footer-order {
  flex-wrap: wrap;
  gap: 0.35rem;
}

.quick-message-editor-add {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--accent);
  display: flex;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  gap: 0.45rem;
  min-height: 2.9rem;
  padding: 0.75rem 1rem;
  text-align: left;
  width: 100%;
}

.quick-message-editor-error {
  background: color-mix(in srgb, var(--danger, #ff7b7b) 10%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--danger, #ff7b7b) 35%, var(--line));
  color: var(--danger, #ff7b7b);
  font-size: 0.76rem;
  padding: 0.55rem 1rem;
}

.quick-messages-settings-row {
  margin-top: 0.7rem;
}

.stream-card-actions {
  align-items: stretch;
  display: grid;
  gap: 0.55rem;
}

/* Все действия одной высоты, а необратимое отделено от обычных пропуском. */
.stream-card-actions .chip-button {
  justify-content: center;
  min-height: 2.45rem;
}

.stream-card-actions .stream-card-archive {
  border-radius: var(--radius-chip);
  font-size: 0.76rem;
  margin-top: 0.45rem;
}

.stream-agent-rules,
.stream-card-actions-section {
  padding-top: 0.9rem;
}

.settings-card.stream-card-actions {
  padding-block: 0.5rem;
}

.stream-card-move-menu {
  background-color: var(--bg);
  background-image: var(--card-bg-open);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 1rem 3rem rgb(0 0 0 / 72%), var(--card-shadow);
  color: var(--text);
  display: grid;
  gap: 0.25rem;
  inset: auto;
  margin: 0;
  max-height: min(18rem, calc(100dvh - 2rem));
  min-width: min(22rem, calc(100vw - 2rem));
  overflow-y: auto;
  padding: 0.4rem;
  position: fixed;
}

.stream-card-move-menu:not(:popover-open) {
  display: none;
}

.stream-card-move-option {
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0.55rem 0.65rem;
  text-align: left;
}

.stream-card-move-option:hover,
.stream-card-move-option:focus-visible {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  outline: none;
}

.settings-card.agent-rules-card {
  gap: 0;
  padding-bottom: 0.5rem;
}

.stream-agent-rules textarea {
  min-height: 10rem;
}

.agent-rules-save {
  align-self: stretch;
  min-height: 2.2rem;
}

.agent-rules-save:disabled {
  cursor: default;
  opacity: 0.48;
}

.dialog-agent-row {
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
}

/* Чипы агента занимают ту же колонку, что селекты соседних строк: ширина
   и высота контролов карточки общие, иначе строка «Агент» выпадала из ряда. */
.dialog-agent-options {
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  justify-content: stretch;
  justify-self: end;
  max-width: var(--dialog-control-width);
  width: 100%;
}

.dialog-agent-options .option-chip {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: var(--dialog-control-height);
}

.dialog-agent {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  justify-self: end;
}

.chat-history-loader {
  display: flex;
  justify-content: center;
  margin: 0 auto 0.7rem;
  max-width: 54rem;
}

.chat-history-load {
  align-items: center;
  background:
    linear-gradient(
      90deg,
      color-mix(in srgb, var(--accent) 24%, var(--card-bg)) 0 var(--history-pull-progress, 0%),
      var(--card-bg) var(--history-pull-progress, 0%) 100%
    );
  border: 1px solid color-mix(in srgb, var(--accent) 52%, var(--line));
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 0.78rem;
  justify-content: center;
  min-height: 2.25rem;
  min-width: 10.5rem;
  padding: 0.42rem 1rem;
}

.chat-history-load:hover:not(:disabled),
.chat-history-load:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}

.chat-history-load:disabled {
  cursor: wait;
  opacity: 0.72;
}

html[data-surface="mobile"] .chat-history-loader {
  height: var(--history-pull-height, 0);
  margin-bottom: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: relative;
  transition: height 160ms ease, opacity 120ms ease;
}

html[data-surface="mobile"] .chat-history-loader[data-pulling],
html[data-surface="mobile"] .chat-history-loader[data-loading] {
  height: var(--history-pull-height, 3rem);
  opacity: 1;
}

html[data-surface="mobile"] .chat-history-loader[data-pulling] {
  transition: opacity 80ms ease;
}

html[data-surface="mobile"] .chat-history-load {
  bottom: 0.35rem;
  min-height: 2.15rem;
  position: absolute;
}

html[data-surface="mobile"] .chat-history-loader[data-armed] .chat-history-load {
  border-color: var(--accent);
  color: var(--text);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin: 0 auto;
  max-width: 54rem;
}

.chat-log-empty {
  color: var(--text-faint);
  font-size: 0.82rem;
  padding: 2rem 0;
  text-align: center;
}

.msg {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--turn-shadow);
  max-width: min(46rem, 88%);
  padding: 0.6rem 0.75rem;
}

.msg-user {
  align-self: flex-end;
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.msg-agent {
  align-self: flex-start;
}

.msg-subagent > .msg-head {
  align-items: center;
  cursor: pointer;
  justify-content: flex-start;
  list-style: none;
  margin-bottom: 0;
}

.msg-subagent > .msg-head::-webkit-details-marker {
  display: none;
}

.msg-subagent[open] > .msg-head {
  margin-bottom: 0.45rem;
}

.msg-subagent-chevron {
  color: var(--text-faint);
  display: inline-flex;
  flex: 0 0 auto;
}

.msg-subagent-chevron-icon {
  height: 0.78rem;
  transition: transform 140ms ease;
  width: 0.78rem;
}

.msg-subagent[open] .msg-subagent-chevron-icon {
  transform: rotate(90deg);
}

.msg-subagent-title {
  color: var(--text);
  font-size: 0.8rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-subagent .msg-time,
.msg-subagent .msg-delivery,
.msg-subagent .msg-turn-duration {
  margin-left: 0;
}

.msg-subagent .msg-time {
  margin-left: auto;
}

.msg-system {
  align-self: center;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-faint);
  font-size: 0.78rem;
  max-width: 100%;
  padding: 0.2rem 0.5rem;
  text-align: center;
}

.msg-live {
  align-self: flex-start;
  border-color: var(--accent-line);
  border-style: dashed;
  margin: 0.7rem auto 0 0;
  max-width: min(46rem, 88%);
}

/* Журнальные плашки намеренно оставлены прозрачными — фон темы должен
   просвечивать. Пузырям чата так нельзя: на светлых кадрах («Луг», «Магма»)
   текст сквозь `--card-bg` не читается, поэтому под ними своя плотная
   подложка в тон темы. Растровый фон теперь у всех тем, поэтому правило
   общее. */
.msg {
  backdrop-filter: blur(9px) saturate(115%);
  -webkit-backdrop-filter: blur(9px) saturate(115%);
  background: var(--card-bg);
}

/* акцентная подсветка своего сообщения ложится поверх той же подложки:
   один `--accent-soft` даёт всего 14 % плотности */
.msg-user {
  background-color: color-mix(in srgb, var(--bg) 78%, transparent);
  background-image: linear-gradient(var(--accent-soft), var(--accent-soft));
}

/* Системная строка живёт без плашки, но на светлом кадре теряется совсем,
   поэтому получает узкую подложку по размеру текста. */
.msg-system {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background-color: color-mix(in srgb, var(--bg) 66%, transparent);
  background-image: none;
  border-radius: var(--radius-chip);
  max-width: fit-content;
  padding: 0.22rem 0.75rem;
}

.msg-maintenance .msg-body {
  text-align: center;
}

.msg-maintenance .msg-body > :first-child {
  margin-top: 0;
}

.msg-maintenance .msg-body > :last-child {
  margin-bottom: 0;
}

.msg-head {
  align-items: baseline;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  margin-bottom: 0.28rem;
}

.msg-author {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 620;
}

.msg-head:has(.msg-upload-actions) { flex-wrap: wrap; }
.msg-upload-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; width: 100%; }
.msg-upload-actions button { white-space: normal; }

.msg-stage {
  color: var(--accent);
  font-size: 0.72rem;
}

.msg-delivery {
  color: var(--text-faint);
  font-size: 0.68rem;
  margin-left: auto;
}

.msg-delivery.is-failed {
  color: #ff9d9d;
}

.msg-time {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.msg-turn-duration {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  white-space: nowrap;
}

.msg-body {
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Мера реплики одна для обоих голосов.

   Раньше твоя реплика жила в 549 px, а ответ агента — в 670: разной ширине
   нечего сообщить, кто говорит — видно по выравниванию и подписи, поэтому
   ширина была лишним сигналом и заставляла глаз перестраиваться на каждой
   смене говорящего. Ограничение задано в ch, то есть в знаках, а не в
   пикселях: при смене кегля мера остаётся комфортной сама. */
.msg-body {
  max-width: var(--msg-measure, min(68ch, 100%));
}

.msg-user .msg-body.is-collapsed {
  max-height: var(--user-message-collapse-height, 448px);
  overflow: hidden;
}

.msg-stack {
  align-self: flex-end;
  display: flex;
  flex-direction: column;
  max-width: min(46rem, 88%);
  min-width: 0;
}

.msg-stack > .msg {
  align-self: stretch;
  max-width: 100%;
}

.msg-actions {
  align-self: flex-end;
  display: flex;
  justify-content: flex-end;
  margin: 0.22rem 0.12rem 0 0;
}

.msg-copy {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  color: var(--text-faint);
  cursor: pointer;
  display: inline-flex;
  height: 1.75rem;
  justify-content: center;
  padding: 0;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
  width: 1.75rem;
}

.msg-copy svg {
  height: 1rem;
  width: 1rem;
}

.msg-copy:hover,
.msg-copy:focus-visible {
  background: color-mix(in srgb, var(--accent-soft) 58%, transparent);
  border-color: var(--accent-line);
  color: var(--text);
}

.msg-copy:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
}

.msg-disclosure {
  align-self: flex-end;
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  margin: 0.42rem 0 0 auto;
  padding: 0.18rem 0;
}

.msg-disclosure:hover,
.msg-disclosure:focus-visible {
  text-decoration: underline;
}

.msg-reasoning {
  border-left: 2px solid var(--accent-line);
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 0.55rem;
  padding-left: 0.65rem;
  white-space: pre-wrap;
}

.msg-agent .msg-body {
  user-select: text;
}

/* Diff относится к последнему ответу, но получает всю ширину ленты и
   собственную прокрутку: исходный git-формат нельзя переносить как обычный текст. */
.message-with-diff {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.message-with-diff > .msg {
  align-self: flex-start;
}

.task-diff {
  backdrop-filter: blur(9px) saturate(115%);
  -webkit-backdrop-filter: blur(9px) saturate(115%);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: 100%;
}

.task-diff > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  list-style: none;
  min-height: 2.7rem;
  padding: 0.65rem 0.85rem;
  user-select: none;
}

.task-diff > summary::-webkit-details-marker {
  display: none;
}

.task-diff > summary::before {
  color: var(--accent);
  content: "›";
  flex: 0 0 auto;
  font: 700 1.2rem/1 var(--font-numeric);
  transform: rotate(0deg);
  transition: transform 0.14s ease;
}

.task-diff[open] > summary::before {
  transform: rotate(90deg);
}

.task-diff-title {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 650;
}

.task-diff-summary {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.7rem;
  margin-left: auto;
}

.task-diff-page {
  background: color-mix(in srgb, var(--sunken) 94%, transparent);
  border-top: 1px solid var(--line);
  max-height: min(62vh, 44rem);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}

.task-diff-page:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: -2px;
}

.task-diff-code {
  color: var(--text-soft);
  font: 0.76rem/1.55 var(--font-numeric);
  margin: 0;
  min-width: max-content;
  padding: 0.9rem 1rem 1rem;
  tab-size: 2;
  text-align: left;
  white-space: pre;
}

/* ---- подтверждения и очередь ---- */

.approvals {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 0.5rem;
  max-height: 40vh;
  overflow-y: auto;
  padding: 0.6rem var(--gutter-right) 0.6rem var(--gutter-left);
}

.approval {
  background: color-mix(in srgb, var(--pending) 10%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--pending) 40%, var(--line));
  border-radius: var(--radius-md);
  padding: 0.55rem 0.65rem;
}

.approval-kind {
  color: var(--pending);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
}

.approval-text {
  color: var(--text-soft);
  font-family: var(--font-numeric);
  font-size: 0.8rem;
  margin: 0.35rem 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.queue {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.7rem auto 0;
  max-width: 54rem;
  overflow: visible;
  padding: 0;
  width: 100%;
}

.approval-question {
  border: 1px solid color-mix(in srgb, var(--pending) 25%, var(--line));
  border-radius: var(--radius-sm);
  display: grid;
  gap: 0.45rem;
  margin: 0.55rem 0;
  padding: 0.55rem;
}

.approval-question legend {
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0 0.25rem;
}

.approval-question-text,
.approval-choice small {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.approval-choice {
  align-items: flex-start;
  cursor: pointer;
  display: flex;
  gap: 0.45rem;
}

.approval-choice span {
  display: grid;
  gap: 0.1rem;
}

.approval-input {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 0.45rem 0.55rem;
  width: 100%;
}

.stream-chat-preview .queue {
  max-width: none;
}

.queue-head {
  color: var(--text-muted);
  font-size: 0.7rem;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
}

.queue-item {
  align-items: flex-start;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  max-width: min(46rem, 88%);
  padding: 0.35rem 0.5rem;
  width: fit-content;
}

.chat-scroll .queue-item,
.stream-chat-preview .queue-item {
  align-self: flex-end;
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.stream-chat-preview .queue-item {
  max-width: 94%;
}

.queue-content {
  display: grid;
  flex: 1 1 auto;
  gap: 0.35rem;
  min-width: 0;
}

.queue-text {
  color: var(--text-soft);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.queue-annotation-list {
  display: grid;
  gap: 0.3rem;
}

.queue-annotation {
  border-left: 2px solid var(--accent-line);
  display: grid;
  gap: 0.12rem;
  min-width: 0;
  padding-left: 0.45rem;
}

.queue-annotation-label {
  color: var(--text-faint);
  font-size: 0.62rem;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
}

.queue-annotation-quote {
  color: var(--text-muted);
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}

.queue-annotation-comment {
  color: var(--text-soft);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.queue-optimistic {
  color: var(--text-faint);
  font-size: 0.68rem;
  white-space: nowrap;
}

.queue-actions {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}

.queue-accept,
.queue-steer,
.queue-edit,
.queue-move,
.queue-pause {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-chip);
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
}

.queue-accept:hover,
.queue-steer:hover,
.queue-edit:hover,
.queue-move:hover:not(:disabled),
.queue-pause:hover {
  color: var(--text);
}

.queue-move {
  min-width: 1.7rem;
  padding-inline: 0.35rem;
}

.queue-steer:disabled,
.queue-move:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.queue-remove,
.attachment-remove,
.annotation-remove {
  background: transparent;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
}

.queue-remove:hover,
.attachment-remove:hover,
.annotation-remove:hover {
  color: #ff9d9d;
}

.queue-remove {
  border: 1px solid color-mix(in srgb, #ff9d9d 38%, transparent);
  border-radius: var(--radius-chip);
  font-size: 0.7rem;
  line-height: normal;
  padding: 0.2rem 0.55rem;
}

/* ======================================================= композер === */

.composer {
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  border-top: 1px solid var(--line);
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem var(--gutter-right) max(0.6rem, env(safe-area-inset-bottom)) var(--gutter-left);
}

.composer.dropping {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent-line);
}

.annotations {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.annotation {
  align-items: flex-start;
  background: var(--surface-1);
  border-left: 3px solid var(--accent-line);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 0.4rem;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
}

.annotation-content {
  display: grid;
  flex: 1 1 auto;
  gap: 0.3rem;
  min-width: 0;
}

.annotation-quote {
  color: var(--text-soft);
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.4;
  max-height: 8.4em;
  overflow: auto;
  overflow-wrap: anywhere;
}

.annotation-comment {
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.35;
  min-height: 2rem;
  padding: 0.35rem 0.45rem;
  resize: vertical;
  width: 100%;
}

.annotation-comment:focus {
  border-color: var(--accent-line);
  outline: 0;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
}

.attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.attachment {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 0;
  position: relative;
}

.attachment-open {
  cursor: zoom-in;
}

.attachment-preparing-label {
  background: rgba(0, 0, 0, 0.75);
  bottom: 0;
  color: #fff;
  font-size: 0.65rem;
  left: 0;
  padding: 0.15rem 0.25rem;
  position: absolute;
  right: 0;
  text-align: center;
}

.attachment-file.attachment-open {
  cursor: pointer;
}

.attachment-open:hover,
.attachment-open:focus-visible {
  border-color: var(--accent-line);
  box-shadow: var(--accent-glow);
}

.attachment-missing {
  align-items: center;
  color: var(--text-faint);
  cursor: default;
  display: flex;
  height: 3.4rem;
  justify-content: center;
  width: 5.8rem;
}

.attachment-missing-label {
  font-size: 0.68rem;
  line-height: 1.15;
  padding: 0.3rem;
  text-align: center;
}

.attachment-load-label {
  align-items: center;
  color: var(--accent);
  display: flex;
  font-size: 0.72rem;
  height: 3.4rem;
  justify-content: center;
  width: 4.8rem;
}

.attachment-loading .attachment-load-label {
  color: var(--text-faint);
}

.attachment-loading .attachment-load-label::after {
  animation: attachment-thumbnail-pulse 1.1s steps(4, end) infinite;
  content: "…";
}

@keyframes attachment-thumbnail-pulse {
  50% { opacity: 0.35; }
}

.attachment img {
  display: block;
  height: 3.4rem;
  object-fit: cover;
  width: 3.4rem;
}

.attachment-file-card {
  align-items: center;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  min-height: 3.4rem;
  padding: 0.35rem 0.55rem;
  width: min(14rem, 62vw);
}

.attachment-task-reference {
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  cursor: pointer;
}

.attachment-task-card {
  align-items: center;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 3.4rem;
  padding: 0.35rem 0.55rem;
  width: min(18rem, 72vw);
}

.attachment-task-card .attachment-file-type {
  min-width: 2.25rem;
  padding-inline: 0.4rem;
  white-space: nowrap;
}

.attachment-task-copy {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.attachment-task-status {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  text-align: left;
}

.attachment-file-type {
  align-items: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid var(--accent-line);
  border-radius: 0.35rem;
  color: var(--accent);
  display: flex;
  font-size: 0.58rem;
  font-weight: 700;
  height: 2.25rem;
  justify-content: center;
  letter-spacing: 0.04em;
  overflow: hidden;
  padding: 0.15rem;
}

.attachment-file-name {
  color: var(--text);
  font-size: 0.74rem;
  line-height: 1.2;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment .attachment-remove {
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  color: #fff;
  font-size: 0.9rem;
  height: 1.2rem;
  padding: 0;
  position: absolute;
  right: 0.15rem;
  top: 0.15rem;
  width: 1.2rem;
}

.composer-main {
  align-items: flex-end;
  display: flex;
  gap: 0.4rem;
}

.composer-main > .chip-button {
  height: 2.4rem;
  justify-content: center;
  padding-block: 0;
}

.composer-input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
}

.composer-input:focus-within {
  border-color: var(--accent-line);
  box-shadow: var(--accent-glow);
}

.composer-input::after {
  content: attr(data-clone) " ";
  overflow-wrap: anywhere;
  visibility: hidden;
  white-space: pre-wrap;
}

.composer-input > textarea,
.composer-input::after {
  font: inherit;
  font-size: 0.9rem;
  grid-area: 1 / 1 / 2 / 2;
  line-height: 1.45;
  max-height: 40vh;
  padding: 0.55rem 0.7rem;
}

.composer-input > textarea {
  background: transparent;
  border: 0;
  color: var(--text);
  min-height: 1.45em;
  outline: none;
  overflow-y: auto;
  resize: none;
}

.composer-send {
  align-items: center;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent) 30%, transparent),
    color-mix(in srgb, var(--accent) 15%, transparent));
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
  color: color-mix(in srgb, var(--accent) 55%, var(--text));
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  height: 2.4rem;
  justify-content: center;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
  width: 2.4rem;
}

.composer-send svg {
  height: 1.15rem;
  width: 1.15rem;
}

.composer-send:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 75%, transparent);
  box-shadow: var(--accent-glow);
  color: var(--text);
}

.composer-send:disabled {
  cursor: default;
  opacity: 0.4;
}

.composer-attach {
  height: 2.4rem;
  width: 2.4rem;
}

.attachment-viewer {
  align-items: center;
  background: rgba(2, 7, 10, 0.94);
  border: 0;
  display: flex;
  height: auto;
  inset: 0;
  justify-content: center;
  margin: 0;
  max-height: none;
  max-width: none;
  padding: 0;
  position: fixed;
  width: auto;
  z-index: 120;
}

.attachment-viewer::backdrop {
  background: transparent;
}

.attachment-viewer[hidden] {
  display: none;
}

.attachment-viewer-stage {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  padding: max(4.5rem, env(safe-area-inset-top)) clamp(3.7rem, 7vw, 6.5rem) max(4rem, env(safe-area-inset-bottom));
  width: 100%;
}

.attachment-viewer img {
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.attachment-viewer-loading {
  color: #f4f8fa;
  max-width: min(80vw, 32rem);
  text-align: center;
}

.attachment-viewer-loading.is-error {
  color: #ffb5ad;
}

.attachment-viewer-close {
  align-items: center;
  background: rgba(2, 8, 11, 0.9);
  border: 1px solid rgba(244, 248, 250, 0.72);
  border-radius: 50%;
  color: #f4f8fa;
  cursor: pointer;
  display: flex;
  height: 2.8rem;
  justify-content: center;
  left: max(1rem, env(safe-area-inset-left));
  padding: 0;
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  width: 2.8rem;
  z-index: 1;
}

.attachment-viewer-close:hover,
.attachment-viewer-close:focus-visible,
.attachment-viewer-arrow:hover,
.attachment-viewer-arrow:focus-visible {
  background: rgba(35, 58, 67, 0.96);
  border-color: #ffffff;
  color: #ffffff;
  outline: 2px solid rgba(255, 255, 255, 0.38);
  outline-offset: 2px;
}

.attachment-viewer-close svg {
  height: 1.25rem;
  width: 1.25rem;
}

.attachment-viewer-arrow {
  align-items: center;
  background: rgba(2, 8, 11, 0.88);
  border: 1px solid rgba(244, 248, 250, 0.72);
  border-radius: 50%;
  color: #f4f8fa;
  cursor: pointer;
  display: flex;
  height: 3.15rem;
  justify-content: center;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3.15rem;
  z-index: 2;
}

.attachment-viewer-arrow.is-previous { left: max(0.75rem, env(safe-area-inset-left)); }
.attachment-viewer-arrow.is-next { right: max(0.75rem, env(safe-area-inset-right)); }

.attachment-viewer-arrow svg {
  height: 1.35rem;
  width: 1.35rem;
}

.attachment-viewer-arrow[hidden] { display: none; }

.attachment-viewer-caption {
  align-items: center;
  background: rgba(2, 8, 11, 0.9);
  border: 1px solid rgba(244, 248, 250, 0.58);
  border-radius: var(--radius-chip);
  bottom: max(1rem, env(safe-area-inset-bottom));
  color: #f4f8fa;
  display: flex;
  gap: 1rem;
  left: 50%;
  max-width: min(80vw, 44rem);
  padding: 0.45rem 0.85rem;
  position: absolute;
  transform: translateX(-50%);
  z-index: 2;
}

.attachment-viewer-caption [data-attachment-viewer-name] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-viewer-caption [data-attachment-viewer-counter] {
  color: rgba(244, 248, 250, 0.78);
  flex: 0 0 auto;
}

.resource-context-menu {
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  box-shadow: 0 0.9rem 2.2rem rgb(0 0 0 / 0.55);
  display: grid;
  min-width: 10.5rem;
  padding: 0.25rem;
  position: fixed;
  z-index: 140;
}

.resource-context-menu[hidden] { display: none; }

.resource-context-menu button {
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius-sm) - 0.15rem);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.48rem 0.72rem;
  text-align: left;
  white-space: nowrap;
}

.resource-context-menu button:hover,
.resource-context-menu button:focus-visible {
  background: var(--accent-soft);
  outline: 0;
}

.resource-context-menu-divider {
  border-top: 1px solid var(--line);
  display: block;
  margin: 0.25rem 0.45rem;
}

.resource-context-menu-divider[hidden] { display: none; }

.local-resource-overflow {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  cursor: pointer;
  display: none;
  flex: 0 0 44px;
  font: inherit;
  font-size: 1.15rem;
  height: 44px;
  justify-content: center;
  margin-inline: 0.1rem;
  padding: 0;
  vertical-align: middle;
  width: 44px;
}

.local-resource-overflow:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.file-transfer-owner-dialog,
.file-transfer-revoke-dialog {
  background: var(--panel, var(--bg));
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
  box-shadow: 0 1.4rem 4rem rgb(0 0 0 / 0.48);
  color: var(--text);
  max-height: calc(100dvh - 2rem);
  max-width: 34rem;
  overflow: hidden;
  padding: 0;
  width: calc(100% - 2rem);
}

.file-transfer-owner-dialog::backdrop,
.file-transfer-revoke-dialog::backdrop { background: rgb(0 0 0 / 0.62); backdrop-filter: blur(3px); }
.file-transfer-owner-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100dvh - 2rem);
  min-height: 0;
  overflow: hidden;
}
.file-transfer-owner-dialog header { align-items: flex-start; display: flex; gap: 1rem; justify-content: space-between; padding: 1.35rem 1.35rem 0; }
.file-transfer-owner-dialog h2, .file-transfer-revoke-dialog h2 { font-size: 1.25rem; margin: 0; }
.file-transfer-owner-dialog h2[tabindex="-1"]:focus { outline: none; }
.file-transfer-owner-kicker { color: var(--text-faint); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; margin: 0 0 0.3rem; text-transform: uppercase; }
.file-transfer-owner-close { align-items: center; background: transparent; border: 0; border-radius: 50%; color: var(--text-faint); cursor: pointer; display: flex; flex: 0 0 44px; font-size: 1.5rem; height: 44px; justify-content: center; }
.file-transfer-owner-body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 1.15rem 1.35rem; }
.file-transfer-owner-body h3 { font-size: 1.05rem; }
.file-transfer-owner-body p { line-height: 1.5; }
.file-transfer-owner-state { display: grid; gap: 0.45rem; margin-top: 1rem; }
.file-transfer-owner-state > h3, .file-transfer-owner-state > p { margin: 0; }
.file-transfer-owner-file { background: color-mix(in srgb, var(--accent) 7%, transparent); border: 1px solid var(--line); border-radius: var(--radius-sm); display: grid; gap: 0.3rem; margin-bottom: 1rem; padding: 0.85rem; }
.file-transfer-owner-file strong { overflow-wrap: anywhere; }
.file-transfer-owner-file span, .file-transfer-owner-helper { color: var(--text-faint); font-size: 0.82rem; }
.file-transfer-owner-field { display: grid; gap: 0.4rem; margin: 1rem 0; }
.file-transfer-owner-field > span { color: var(--text-faint); font-size: 0.78rem; }
.file-transfer-owner-field select, .file-transfer-owner-field input { background: var(--input-bg, var(--bg)); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); font: inherit; min-height: 44px; padding: 0.65rem 0.75rem; width: 100%; }
.file-transfer-owner-warning { background: color-mix(in srgb, #d99018 15%, transparent); border-left: 3px solid #d99018; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 0.75rem; }
.file-transfer-owner-progress { background: var(--line); border-radius: 999px; height: 0.65rem; margin-top: 0.9rem; overflow: hidden; }
.file-transfer-owner-progress span { background: var(--accent); display: block; height: 100%; width: var(--progress); }
.file-transfer-owner-details { display: grid; gap: 0.65rem; }
.file-transfer-owner-details div { display: grid; gap: 0.2rem; }
.file-transfer-owner-details dt { color: var(--text-faint); font-size: 0.75rem; }
.file-transfer-owner-details dd { margin: 0; overflow-wrap: anywhere; }
.file-transfer-owner-details code { user-select: all; }
.file-transfer-copy-status { color: var(--text-faint); min-height: 1.2em; }
.file-transfer-owner-error { border-left: 3px solid #d85d62; padding-left: 0.8rem; }
.file-transfer-owner-actions { border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 0.65rem; justify-content: flex-end; padding: 1rem 1.35rem max(1rem, env(safe-area-inset-bottom)); }
.file-transfer-owner-actions button { background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); cursor: pointer; font: inherit; min-height: 44px; padding: 0.6rem 0.9rem; }
.file-transfer-owner-actions button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast, #fff); }
.file-transfer-owner-actions button.danger { border-color: #d85d62; color: #ff8388; }
.file-transfer-revoke-dialog form { padding: 1.35rem; }
.file-transfer-revoke-dialog p { line-height: 1.5; }
.file-transfer-revoke-dialog .file-transfer-owner-actions { padding-inline: 0; padding-bottom: 0; }

@media (max-width: 700px), (pointer: coarse) {
  .local-resource-overflow { display: inline-flex; }
}

@media (max-width: 390px) {
  .file-transfer-owner-dialog { border-radius: var(--radius-md) var(--radius-md) 0 0; height: calc(100dvh - 16px); margin: auto 0 0; max-height: calc(100dvh - 16px); width: 100%; }
  .file-transfer-owner-panel { height: 100%; max-height: calc(100dvh - 16px); }
  .file-transfer-owner-actions { display: grid; }
  .file-transfer-owner-actions button { width: 100%; }
}

@media (max-width: 600px) {
  .attachment-viewer-arrow {
    height: 2.7rem;
    width: 2.7rem;
  }

  .attachment-viewer-stage {
    padding-inline: 3.35rem;
  }
}

.task-search-hits {
  display: grid;
  gap: 0.18rem;
  margin-top: 0.28rem;
}

.task-search-hit {
  background: transparent;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.68rem;
  overflow: hidden;
  padding: 0.16rem 0;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-search-hit:hover,
.task-search-hit:focus-visible {
  color: var(--accent);
  outline: none;
  text-decoration: underline;
}

.msg-body,
.msg-reasoning {
  white-space: normal;
}

.msg-body > :first-child,
.msg-reasoning > :first-child {
  margin-top: 0;
}

.msg-body > :last-child,
.msg-reasoning > :last-child {
  margin-bottom: 0;
}

.msg-body p,
.msg-reasoning p {
  margin: 0.45em 0;
}

.msg-body h1,
.msg-body h2,
.msg-body h3,
.msg-body h4,
.msg-body h5,
.msg-body h6 {
  color: var(--text);
  line-height: 1.25;
  margin: 0.85em 0 0.4em;
}

.msg-body h1 { font-size: 1.24em; }
.msg-body h2 { font-size: 1.16em; }
.msg-body h3 { font-size: 1.08em; }
.msg-body h4,
.msg-body h5,
.msg-body h6 { font-size: 1em; }

.msg-body ul,
.msg-body ol,
.msg-reasoning ul,
.msg-reasoning ol {
  margin: 0.45em 0;
  padding-left: 1.45em;
}

.msg-body li + li,
.msg-reasoning li + li {
  margin-top: 0.18em;
}

.msg-body a,
.msg-reasoning a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.msg-body .inline-file-link,
.msg-reasoning .inline-file-link {
  text-decoration: none;
}

.msg-body .inline-file-link code,
.msg-reasoning .inline-file-link code {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--accent);
  cursor: pointer;
}

.file-citation {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  border-radius: var(--radius-chip);
  color: var(--accent);
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 0.84em;
  max-width: 100%;
  overflow: hidden;
  padding: 0.08rem 0.4rem;
  text-decoration: none;
  text-overflow: ellipsis;
  vertical-align: baseline;
  white-space: nowrap;
}

.msg-body code,
.msg-reasoning code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 0.3em;
  font-family: var(--font-mono, monospace);
  font-size: 0.9em;
  padding: 0.08em 0.3em;
}

.msg-body pre,
.msg-reasoning pre {
  background: color-mix(in srgb, var(--bg) 92%, #000);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 0.55em 0;
  max-width: 100%;
  overflow: auto;
  padding: 0.7em;
}

.msg-body pre code,
.msg-reasoning pre code {
  background: transparent;
  border: 0;
  padding: 0;
}

.msg-body blockquote,
.msg-reasoning blockquote {
  border-left: 3px solid var(--accent-line);
  color: var(--text-muted);
  margin: 0.55em 0;
  padding-left: 0.75em;
}

.msg-body .markdown-table-scroll,
.msg-reasoning .markdown-table-scroll {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 0.6em 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  width: 100%;
}

.msg-body .markdown-table,
.msg-reasoning .markdown-table {
  border-collapse: collapse;
  font-size: 0.9em;
  max-width: 100%;
  min-width: 0;
  table-layout: fixed;
  width: 100%;
}

.msg-body .markdown-table th,
.msg-body .markdown-table td,
.msg-reasoning .markdown-table th,
.msg-reasoning .markdown-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  overflow-wrap: anywhere;
  padding: 0.42em 0.65em;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
}

/* В типовой двухколоночной сводке первая колонка остаётся компактной, а
   описание получает основную ширину. Таблицы с другим числом колонок делят
   доступное пространство равномерно благодаря fixed layout. */
.msg-body .markdown-table tr > :first-child:nth-last-child(2),
.msg-reasoning .markdown-table tr > :first-child:nth-last-child(2) {
  width: clamp(9rem, 30%, 18rem);
}

.msg-body .markdown-table :is(a, code),
.msg-reasoning .markdown-table :is(a, code) {
  overflow-wrap: anywhere;
  white-space: normal;
}

.msg-body .markdown-table th:last-child,
.msg-body .markdown-table td:last-child,
.msg-reasoning .markdown-table th:last-child,
.msg-reasoning .markdown-table td:last-child {
  border-right: 0;
}

.msg-body .markdown-table tbody tr:last-child td,
.msg-reasoning .markdown-table tbody tr:last-child td {
  border-bottom: 0;
}

.msg-body .markdown-table th,
.msg-reasoning .markdown-table th {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-1));
  color: var(--text);
  font-weight: 650;
}

.msg-body .markdown-table tbody tr:nth-child(even),
.msg-reasoning .markdown-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-2) 58%, transparent);
}

.activity-feed {
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column-reverse;
  margin-bottom: 0.7rem;
  padding-bottom: 0.45rem;
}

.activity-feed > summary {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.74rem;
}

.turn-trace {
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column-reverse;
  margin-bottom: 0.7rem;
  padding-bottom: 0.45rem;
}

.turn-trace > summary {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.74rem;
  list-style: none;
}

.turn-trace > summary::-webkit-details-marker {
  display: none;
}

.turn-trace > summary::before {
  color: var(--accent);
  content: "›";
  display: inline-block;
  margin-right: 0.38rem;
  transform: rotate(0deg);
  transition: transform 0.14s ease;
}

.turn-trace[open] > summary::before {
  transform: rotate(90deg);
}

.turn-trace-groups {
  border-left: 1px solid var(--accent-line);
  display: grid;
  gap: 0.8rem;
  margin: 0 0 0.6rem 0.18rem;
  padding-left: 0.8rem;
}

.turn-trace-block {
  display: grid;
  gap: 0.42rem;
  min-width: 0;
}

.turn-trace-omission {
  color: var(--text-faint);
  font-size: 0.75rem;
}

.turn-trace-archive-content {
  max-height: 60vh;
  overflow: auto;
}

.turn-trace-reasoning {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.turn-trace-reasoning > :first-child {
  margin-top: 0;
}

.turn-trace-reasoning > :last-child {
  margin-bottom: 0;
}

.turn-trace-activities {
  background: color-mix(in srgb, var(--surface-1) 54%, transparent);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.52rem 0.5rem;
}

.turn-trace-activities > summary {
  cursor: pointer;
  list-style: none;
}

.turn-trace-activities > summary::-webkit-details-marker {
  display: none;
}

.turn-trace-activities > summary::before {
  content: "›";
  display: inline-block;
  margin-right: 0.32rem;
  transition: transform 0.14s ease;
}

.turn-trace-activities[open] > summary::before {
  transform: rotate(90deg);
}

.live-turn-trace .turn-trace-groups {
  margin-top: 0.65rem;
}

.turn-trace-activities-title {
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 650;
}

.turn-trace-activities .activity-list {
  margin-top: 0.35rem;
}

.activity-list {
  display: grid;
  gap: 0.28rem;
  margin-top: 0.45rem;
}

.activity-item {
  align-items: baseline;
  display: grid;
  gap: 0.35rem;
  grid-template-columns: 0.45rem auto auto minmax(0, 1fr);
  min-width: 0;
}

.activity-marker {
  background: var(--accent);
  border-radius: 50%;
  height: 0.38rem;
  width: 0.38rem;
}

.activity-item[data-status="failed"] .activity-marker { background: #ff7777; }
.activity-item[data-status="waiting"] .activity-marker { background: #f2bd63; }
.activity-time,
.activity-detail {
  color: var(--text-faint);
  font-size: 0.69rem;
}
.activity-label {
  color: var(--text-soft);
  font-size: 0.73rem;
  white-space: nowrap;
}
.activity-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  position: relative;
}

.composer-slash {
  font-family: var(--font-mono, monospace);
  font-size: 1.15rem;
  font-weight: 650;
  height: 2.4rem;
  width: 2.4rem;
}

.slash-menu {
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  bottom: calc(100% + 0.4rem);
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.35);
  display: grid;
  left: var(--gutter-left);
  max-height: min(22rem, 55vh);
  min-width: min(24rem, calc(100vw - 2rem));
  overflow-y: auto;
  padding: 0.35rem;
  position: absolute;
  z-index: 20;
}

.slash-menu[hidden] {
  display: none;
}

.slash-command {
  align-items: baseline;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  padding: 0.5rem 0.65rem;
  text-align: left;
}

.slash-command strong {
  color: var(--text);
  font-family: var(--font-mono, monospace);
}

.slash-command:hover,
.slash-command[aria-selected="true"] {
  background: var(--accent-soft);
}

.context-usage {
  align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  font-family: var(--font-numeric);
  font-size: 0.72rem;
  gap: 0.32rem;
  height: 2.4rem;
  padding: 0 0.55rem;
}

.context-usage:disabled {
  cursor: default;
  opacity: 0.55;
}

.context-ring {
  background: conic-gradient(var(--accent) var(--context-percent, 0%), var(--line) 0);
  border-radius: 50%;
  height: 1rem;
  position: relative;
  width: 1rem;
}

.context-ring::after {
  background: var(--surface-1);
  border-radius: 50%;
  content: "";
  inset: 0.2rem;
  position: absolute;
}

@keyframes context-compaction-spin {
  to { transform: rotate(1turn); }
}

.context-usage[data-compacting] .context-ring {
  animation: context-compaction-spin 0.9s linear infinite;
  background: conic-gradient(transparent 0 24%, var(--accent) 24% 58%, transparent 58% 100%);
}

@media (prefers-reduced-motion: reduce) {
  .context-usage[data-compacting] .context-ring {
    animation: none;
  }
}

.chat-stop-bottom {
  display: inline-flex;
}

html[data-surface="mobile"] .chat-stop-bottom {
  height: 2.4rem;
  justify-content: center;
  padding: 0;
  width: 2.4rem;
}

html[data-surface="mobile"] .chat-stop-bottom > span {
  display: none;
}

/* ================================================== панель настроек === */

.panel-scrim,
.dialog-scrim {
  background: rgba(0, 0, 0, 0.5);
  inset: 0;
  opacity: 0;
  position: fixed;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.panel-scrim.open,
.dialog-scrim:not([hidden]) {
  opacity: 1;
}

.settings-panel {
  background:
    radial-gradient(120% 60% at 90% -20%, var(--space-glow-a), transparent 60%),
    var(--space-base);
  border-left: 1px solid var(--line-strong);
  bottom: 0;
  box-shadow: -24px 0 60px -40px rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  max-width: 92vw;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  width: 22rem;
  z-index: 60;
}

.settings-panel.open {
  transform: translateX(0);
}

.settings-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  padding: 0.85rem var(--gutter-right) 0.85rem 1.1rem;
}

.settings-head h2 {
  color: var(--text);
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: var(--display-weight);
  margin: 0;
  text-transform: var(--display-transform);
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  padding: 1rem 1.1rem max(1.2rem, env(safe-area-inset-bottom));
}

/* Раздел = заголовок + карточка. Настройки внутри карточки разделены
   волосяными линиями, поэтому подписи не приходится кричать капсом. */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.settings-card {
  background: color-mix(in srgb, var(--surface-2) 62%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  padding: 0 0.8rem;
}

.settings-card > * {
  padding: 0.6rem 0;
}

.settings-card > * + * {
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.bug-report-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 0.6rem;
  text-align: left;
  width: 100%;
}

.bug-report-toggle:hover,
.bug-report-toggle[aria-expanded="true"] {
  color: var(--accent);
}

.bug-report-toggle svg {
  flex: 0 0 auto;
  height: 1.2rem;
  width: 1.2rem;
}

.bug-report-form {
  display: grid;
  gap: 0.7rem;
}

.bug-report-form[hidden] {
  display: none;
}

.bug-report-field {
  display: grid;
  gap: 0.45rem;
}

.bug-report-field textarea {
  background: color-mix(in srgb, var(--surface-2) 86%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.45;
  min-height: 6.5rem;
  padding: 0.58rem 0.65rem;
  resize: vertical;
  width: 100%;
}

.bug-report-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
  outline: none;
}

.bug-report-screenshots {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bug-report-screenshot {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.bug-report-screenshot img {
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  width: 100%;
}

.bug-report-screenshot > span {
  color: var(--text-muted);
  display: block;
  font-size: 0.68rem;
  overflow: hidden;
  padding: 0.35rem 0.45rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bug-report-screenshot .attachment-remove {
  position: absolute;
  right: 0.25rem;
  top: 0.25rem;
}

.bug-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.bug-report-hint {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin: 0;
}

.bug-report-status {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.4;
  margin: 0;
  min-height: 1.05rem;
  overflow-wrap: anywhere;
}

.bug-report-status[data-state="error"] {
  color: var(--danger, #ff7b7b);
}

.bug-report-status[data-state="success"] {
  color: var(--accent);
}

/* Короткая настройка одной строкой: подпись слева, контрол справа. */
.setting-row {
  align-items: center;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
}

.setting-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-duration {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.setting-duration label {
  align-items: center;
  color: var(--text-muted);
  display: inline-flex;
  font-size: 0.75rem;
  gap: 0.35rem;
}

.setting-duration input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-numeric);
  font-size: 0.82rem;
  padding: 0.42rem 0.55rem;
  width: 4.5rem;
}

.setting-duration input:focus-visible {
  border-color: var(--accent-line);
  outline: 2px solid var(--accent-soft);
}

.setting-name {
  color: var(--text-soft);
  font-size: 0.83rem;
}

.setting-field select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%) calc(100% - 0.95rem) 50% / 0.3rem 0.3rem no-repeat,
    linear-gradient(135deg, var(--accent) 50%, transparent 50%) calc(100% - 0.7rem) 50% / 0.3rem 0.3rem no-repeat,
    var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.42rem 1.6rem 0.42rem 0.6rem;
  width: 100%;
}

.setting-row > select {
  justify-self: end;
  max-width: 11rem;
}

.prompt-template-action-row {
  align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(8.5rem, 11rem);
}

.prompt-template-action-copy {
  display: grid;
  min-width: 0;
}

.prompt-template-action-row .switch-note {
  overflow-wrap: anywhere;
}

.prompt-template-action-row > select,
.prompt-template-action-row > .themed-select {
  max-width: 11rem;
  min-width: 0;
}

.quick-messages-settings-row {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.quick-messages-settings-row .setting-name {
  overflow-wrap: anywhere;
}

.prompt-template-entry-heading {
  background: transparent;
  border: 0;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.prompt-template-entry-heading:hover {
  background: var(--accent-soft);
}

.prompt-template-entry-heading:focus-visible {
  outline-offset: -2px;
}

.setting-field select option {
  background: var(--bg);
  color: var(--text);
}

/* Chromium передаёт раскрытую часть native select операционной системе, и та
   подставляет системный синий highlight. Этот listbox остаётся обычным select
   для данных и событий, но вся видимая часть теперь следует токенам темы. */
.themed-select {
  min-width: 0;
  position: relative;
}

.themed-select-native {
  display: none;
}

.themed-select-button {
  align-items: center;
  background: color-mix(in srgb, var(--surface-2) 86%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 0.82rem;
  gap: 0.7rem;
  justify-content: space-between;
  min-height: 2rem;
  padding: 0.42rem 0.62rem;
  text-align: left;
  width: 100%;
}

.themed-select-button:hover,
.themed-select[data-open] .themed-select-button {
  background: color-mix(in srgb, var(--surface-3) 80%, transparent);
  border-color: var(--accent-line);
}

.themed-select-button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
  outline: none;
}

.themed-select-button:disabled {
  cursor: default;
  opacity: 0.52;
}

.themed-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.themed-select-chevron {
  border-bottom: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
  flex: 0 0 auto;
  height: 0.38rem;
  margin: -0.2rem 0.12rem 0 0;
  transform: rotate(45deg);
  transition: transform 0.16s ease, margin 0.16s ease;
  width: 0.38rem;
}

.themed-select[data-open] .themed-select-chevron {
  margin: 0.2rem 0.12rem 0 0;
  transform: rotate(225deg);
}

.themed-select-menu {
  backdrop-filter: blur(12px) saturate(112%);
  -webkit-backdrop-filter: blur(12px) saturate(112%);
  background: color-mix(in srgb, var(--surface-1) 94%, var(--bg));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--accent) 8%, transparent),
    0 18px 48px -22px rgba(0, 0, 0, 0.96),
    0 0 28px -22px var(--accent);
  color: var(--text);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.3rem;
  position: fixed;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
  z-index: 100;
}

.themed-select-menu[popover] {
  inset: auto;
  margin: 0;
}

.themed-select-menu[hidden] {
  display: none;
}

.themed-select-option {
  border: 1px solid transparent;
  border-radius: max(1px, calc(var(--radius-sm) - 1px));
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1.25;
  min-height: 2rem;
  overflow: hidden;
  padding: 0.45rem 0.58rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.themed-select-option:hover,
.themed-select-option:focus-visible {
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--text);
  outline: none;
}

.themed-select-option[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 650;
}

.themed-select-option[data-disabled="true"] {
  cursor: default;
  opacity: 0.42;
}

.themed-select-action {
  background: transparent;
  border-top: 1px solid var(--line-strong);
  border-radius: 0;
  display: block;
  margin-top: 0.3rem;
  text-align: left;
  white-space: normal;
  width: 100%;
}

.setting-field .themed-select {
  width: 100%;
}

.setting-row > .themed-select {
  justify-self: end;
  max-width: 11rem;
  width: 100%;
}

.dialog-settings .setting-row > .themed-select {
  max-width: var(--dialog-control-width);
}

.theme-picker .themed-select,
.group-picker .themed-select {
  min-width: 7.3rem;
}

.group-picker .themed-select {
  min-width: 7.8rem;
}

.theme-picker .themed-select-button,
.group-picker .themed-select-button {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  font: inherit;
  min-height: 1.65rem;
  padding: 0.18rem 0.48rem 0.18rem 0.55rem;
}

.setting-hint {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.35;
  margin: 0.4rem 0 0;
}

/* Свёрнутая справка по единицам: в закрытом виде занимает одну строку, чтобы
   формулы не отодвигали остальные настройки. */
.setting-note {
  margin-top: 0.35rem;
}

.setting-note > summary {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.76rem;
  list-style: none;
  padding-left: 0.85rem;
  position: relative;
  width: fit-content;
}

.setting-note > summary::-webkit-details-marker {
  display: none;
}

.setting-note > summary::before {
  border-left: 0.3rem solid currentColor;
  border-bottom: 0.22rem solid transparent;
  border-top: 0.22rem solid transparent;
  content: "";
  left: 0.1rem;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.15s ease;
}

.setting-note[open] > summary::before {
  transform: translateY(-50%) rotate(90deg);
}

.setting-note > summary:hover {
  color: var(--accent);
}

.setting-note-body {
  border-left: 1px solid var(--line);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  gap: 0.4rem;
  line-height: 1.4;
  margin: 0.45rem 0 0 0.28rem;
  padding-left: 0.6rem;
}

.setting-note-body p {
  margin: 0;
}

/* Коэффициенты моделей идут строками без маркеров: список читается как таблица,
   а не как перечисление действий. */
.setting-note-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  list-style: none;
  margin: -0.2rem 0 0;
  padding: 0;
}

.setting-note-body b {
  color: var(--text-soft);
  font-weight: 650;
}

.setting-note-aside {
  color: var(--text-faint);
}

/* Кнопка панели: подпись прячется на телефоне, остаётся один значок. */
.view-settings svg {
  height: 0.95rem;
  width: 0.95rem;
}

/* Разбивка по видам токенов включается в общей панели настроек. */
.journal span[data-day-usage-breakdown] {
  display: none;
}

.dialog-working-directory input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  font: inherit;
}

.dialog-working-directory input:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 24%, transparent);
  outline-offset: 1px;
}

/* Единое поле рабочей директории: компактное чтение крошками и явный режим
   редактирования сохраняют обычный input источником значения для форм. */
.directory-field {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.directory-field-view,
.directory-field-editor,
.directory-field-empty {
  align-items: center;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
}

.directory-field-editor {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.directory-field [hidden] {
  display: none;
}

.directory-field-path,
.directory-field-empty {
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  min-height: 2.3rem;
  min-width: 0;
}

.directory-field-path {
  align-items: center;
  cursor: pointer;
  display: flex;
  font: inherit;
  overflow: hidden;
  padding: 0.45rem 0.6rem;
  text-align: left;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  width: 100%;
}

.directory-field-path:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--text);
}

.directory-field-path:focus-visible,
.directory-field-action:focus-visible {
  border-color: var(--accent-line);
  box-shadow: var(--accent-glow);
  outline: none;
}

.directory-field-folder {
  color: var(--accent);
  flex: 0 0 auto;
  height: 1rem;
  margin-right: 0.45rem;
  width: 1rem;
}

.directory-field-breadcrumbs {
  align-items: center;
  display: flex;
  min-width: 0;
  overflow: hidden;
}

.directory-field-segment {
  flex: 0 1 auto;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-field-segment[data-collapsed] {
  color: var(--text-faint);
  flex: 0 0 auto;
}

.directory-field-segment[data-current] {
  color: var(--text);
  font-weight: 650;
}

.directory-field-separator {
  color: var(--text-faint);
  flex: 0 0 auto;
  height: 0.72rem;
  margin: 0 0.22rem;
  width: 0.72rem;
}

.directory-field-action {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.73rem;
  min-height: 2.15rem;
  padding: 0.38rem 0.65rem;
  white-space: nowrap;
}

.directory-field-action:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--text);
}

.directory-field-action-primary {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
  border-color: var(--accent-line);
  color: var(--text);
}

.directory-field-action:disabled,
.directory-field-path:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.directory-field-empty {
  border-style: dashed;
  padding: 0.38rem 0.45rem 0.38rem 0.65rem;
}

.directory-field-empty-value {
  color: var(--text-faint);
  font-size: 0.78rem;
  min-width: 0;
}

.directory-field-empty-actions {
  display: flex;
  gap: 0.35rem;
}

.directory-field .directory-field-input {
  box-sizing: border-box;
  font-family: var(--font-mono);
  min-height: 2.3rem;
  min-width: 0;
  width: 100%;
}

.directory-field-status {
  color: var(--text-faint);
  font-size: 0.68rem;
  line-height: 1.35;
}

.directory-field-status[data-tone="error"] {
  color: var(--danger);
}

@media (max-width: 640px) {
  .directory-field-editor {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .directory-field-editor .directory-field-input {
    grid-column: 1 / -1;
  }

  .directory-field-empty {
    align-items: stretch;
    grid-template-columns: minmax(0, 1fr);
  }

  .directory-field-empty-actions .directory-field-action {
    flex: 1 1 0;
  }
}

.setting-label {
  color: var(--text-faint);
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: var(--label-spacing);
  margin-bottom: 0.45rem;
  text-transform: uppercase;
}

/* Ровная сетка вместо рваного переноса: колонки одинаковой ширины, длинное
   название модели переносится внутри чипа, а не обрезается. */
.setting-options {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: repeat(auto-fill, minmax(7.2rem, 1fr));
}

.setting-options-column {
  grid-template-columns: minmax(0, 1fr);
}

.setting-empty {
  color: var(--text-faint);
}

.option-chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.25;
  min-width: 0;
  padding: 0.36rem 0.6rem;
  text-align: center;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.option-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.option-chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

/* Переключатель: подпись слева, тумблер прижат к правому краю карточки. */
.setting-switch {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.setting-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  flex: 0 0 auto;
  height: 1.3rem;
  position: relative;
  transition: background 0.16s ease, border-color 0.16s ease;
  width: 2.35rem;
}

.switch-track::after {
  background: var(--text-muted);
  border-radius: 50%;
  content: "";
  height: 0.9rem;
  left: 0.2rem;
  position: absolute;
  top: 0.15rem;
  transition: transform 0.16s ease, background 0.16s ease;
  width: 0.9rem;
}

/* Тумблер идёт в разметке после подписи, поэтому связь общая, а не соседняя. */
.setting-switch input:checked ~ .switch-track {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.setting-switch input:checked ~ .switch-track::after {
  background: var(--accent);
  transform: translateX(1.05rem);
}

.setting-switch input:focus-visible ~ .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.setting-switch[data-pending] {
  cursor: wait;
}

.setting-switch[data-pending] .switch-text::after {
  color: var(--text-muted);
  content: "Обновляю журнал…";
  display: block;
  font-size: 0.72rem;
  margin-top: 0.2rem;
}

.setting-switch[data-pending] .switch-track {
  opacity: 0.58;
}

.switch-text {
  color: var(--text-soft);
  font-size: 0.83rem;
  min-width: 0;
}

.switch-note {
  color: var(--text-muted);
  display: block;
  font-size: 0.72rem;
  line-height: 1.3;
  margin-top: 0.18rem;
}

.setting-status {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

.status-row {
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
  padding: 0.15rem 0;
}

.status-name {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.status-value {
  color: var(--text);
  font-family: var(--font-numeric);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.trusted-device-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.trusted-device-row {
  align-items: center;
  display: flex;
  gap: 0.7rem;
  justify-content: space-between;
}

.trusted-device-row[data-revoked] {
  opacity: 0.55;
}

.trusted-device-archive {
  border-top: 1px solid var(--line);
  margin-top: 0.2rem;
  padding-top: 0.5rem;
}

.trusted-device-archive > summary {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.74rem;
  list-style: none;
  user-select: none;
}

.trusted-device-archive > summary::-webkit-details-marker {
  display: none;
}

.trusted-device-archive > summary::before {
  content: "▸ ";
  color: var(--text-faint);
}

.trusted-device-archive[open] > summary::before {
  content: "▾ ";
}

.trusted-device-archive > summary:hover {
  color: var(--text-soft);
}

.trusted-device-archive > .trusted-device-list {
  padding: 0.5rem 0 0.15rem;
}

.trusted-device-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.trusted-device-info strong {
  color: var(--text);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.trusted-device-info small,
.setting-error {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.setting-error {
  color: var(--danger, #ff8b8b);
}

.trusted-device-pairing {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.trusted-device-code {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-numeric);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  padding: 0.55rem;
  text-align: center;
}

.trusted-device-add {
  align-self: flex-start;
}

.chip-button.compact {
  flex: 0 0 auto;
  font-size: 0.72rem;
  padding: 0.3rem 0.55rem;
}

.chip-button.danger {
  border-color: color-mix(in srgb, #ff8b8b 45%, var(--line));
  color: #ffb0b0;
}

.setting-danger {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

/* ================================================= диалог ввода текста === */

.composer-shortcuts-modal { max-width: min(38.75rem, calc(100vw - 32px)); }
.composer-shortcuts-modal > form { display: flex; flex-direction: column; min-height: 0; }
.composer-shortcuts-modal > header, .composer-shortcuts-modal footer { flex-shrink: 0; }
.composer-shortcuts-fields { overflow-y: auto; padding: 1rem; min-height: 0; }
.composer-shortcut-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.composer-shortcut-row > span { min-width: 0; }
.composer-shortcut-row select { width: min(100%, 17rem); max-width: 100%; min-height: 44px; }
.composer-shortcuts-modal button { min-height: 44px; min-width: 44px; }
.composer-shortcuts-modal footer .chip-button:not(:disabled) { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); opacity: 1; }
.composer-shortcuts-modal footer button:disabled { opacity: 0.45; cursor: not-allowed; }
.composer-shortcuts-modal #composer-shortcuts-helper { display: grid; gap: 0.85rem; margin-top: 1rem; }
.composer-shortcuts-modal .composer-shortcuts-mobile-note { margin-top: 1rem; }
.composer-shortcuts-modal .composer-shortcuts-feedback { margin-top: 1rem; padding: 0.75rem; border: 1px solid var(--line-strong); border-inline-start: 3px solid var(--warning, var(--accent)); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); }
.composer-shortcuts-modal .composer-shortcuts-error { border-inline-start-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface-2)); }
.composer-shortcuts-modal kbd { font: inherit; color: var(--text); }
.composer-shortcuts-modal :is(button, select):focus-visible,
.composer-shortcuts-discard button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.composer-shortcuts-modal footer, .composer-shortcuts-discard footer { display: flex; gap: 0.5rem; flex-wrap: wrap; padding: 1rem; }
.composer-shortcuts-modal footer button, .composer-shortcuts-discard button { min-height: 44px; }
.composer-shortcuts-saved:empty { display: none; }
.composer-shortcuts-mobile-note, .composer-shortcuts-mobile-helper { display: none; }
html[data-phone-composer] :is(.composer-shortcuts-mobile-note, .composer-shortcuts-mobile-helper) { display: block; }
.composer-shortcuts-mobile-helper { margin-top: 0.35rem; }
.composer-shortcuts-discard { width: min(24rem, calc(100vw - 32px)); color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); }
.composer-shortcuts-discard h2 { font-size: 1rem; }
.composer-shortcuts-discard::backdrop { background: rgb(0 0 0 / 65%); }
@media (max-width: 600px) {
  .composer-shortcut-row { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .composer-shortcut-row select { width: 100%; max-width: 100%; }
  .composer-shortcuts-modal footer button, .composer-shortcuts-discard footer button { width: 100%; }
}

.text-dialog {
  background: var(--card-bg-open);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  left: 50%;
  max-width: 92vw;
  padding: 1.1rem;
  position: fixed;
  top: 32%;
  transform: translate(-50%, -50%);
  width: 24rem;
  z-index: 70;
}

.text-dialog-label {
  color: var(--text-soft);
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.text-dialog input,
.text-dialog textarea {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 0.5rem 0.6rem;
  width: 100%;
}

.text-dialog input:focus,
.text-dialog textarea:focus {
  border-color: var(--accent-line);
  outline: none;
}

.text-dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.85rem;
}

/* ================================================ диалог истории лимитов === */

.limits-scrim {
  background: rgba(0, 0, 0, 0.72);
  inset: 0;
  opacity: 0;
  position: fixed;
  transition: opacity 0.2s ease;
  z-index: 68;
}

.limits-scrim:not([hidden]) {
  opacity: 1;
}

/* Диалог почти непрозрачен: аксессуарный градиент темы лежит поверх сплошной
 * подложки --bg, поэтому текст чата под окном не просвечивает ни в одной теме,
 * а граница и тень сохраняют прежнюю эстетику. */
.limits-dialog {
  background: var(--card-bg-open), var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  left: 50%;
  max-height: min(86vh, 40rem);
  max-width: 94vw;
  overflow-y: auto;
  padding: 1.1rem 1.2rem max(1.2rem, env(safe-area-inset-bottom));
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 42rem;
  z-index: 70;
}

.limits-head {
  align-items: flex-start;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.limits-head-main {
  min-width: 0;
}

.limits-head h2 {
  color: var(--text);
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: var(--display-weight);
  margin: 0;
  text-transform: var(--display-transform);
}

.limits-subtitle {
  color: var(--text-muted);
  font-size: 0.74rem;
  margin: 0.2rem 0 0;
}

.limits-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.limits-range {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  padding: 0.3rem 0.7rem;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  white-space: nowrap;
}

.limits-range:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.limits-range[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.limits-range:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
}

.limits-hint {
  color: var(--text-faint);
  font-size: 0.68rem;
  margin: 0;
}

.limits-body {
  min-height: 15rem;
  position: relative;
}

.limits-state {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  justify-content: center;
  min-height: 15rem;
  text-align: center;
}

.limits-error p,
.limits-empty p {
  margin: 0;
}

.limits-spinner {
  animation: spin 0.9s linear infinite;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  border-top-color: var(--accent);
  height: 1.4rem;
  width: 1.4rem;
}

.limits-chart-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  position: relative;
}

.limits-chart {
  margin: 0;
  position: relative;
  width: 100%;
}

.limits-chart-svg {
  display: block;
  height: 16rem;
  overflow: visible;
  width: 100%;
}

.limits-grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.limits-axis-label {
  fill: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 10px;
}

.limits-empty-plot {
  fill: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
}

.limits-series-line {
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.limits-point {
  opacity: 0.92;
  stroke: var(--bg);
  stroke-width: 1;
}

.limits-point-current {
  stroke: var(--bg);
  stroke-width: 1.5;
}

.limits-point:focus-visible {
  outline: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.limits-tooltip {
  background: var(--tooltip-background, var(--card-bg-open)), var(--bg);
  background-color: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  max-width: min(18rem, calc(100% - 1rem));
  padding: 0.4rem 0.55rem;
  pointer-events: none;
  position: absolute;
  transform: translate(0.6rem, -50%);
  white-space: normal;
  z-index: 6;
}

.limits-tooltip[data-side="left"] {
  transform: translate(calc(-100% - 0.6rem), -50%);
}

.limits-tooltip-title {
  font-weight: 600;
}

.limits-tooltip-time {
  color: var(--text-muted);
}

.limits-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.limits-legend-item {
  display: inline-flex;
}

/* Переключатель серии: компактная кнопка, естественно встроенная в легенду. */
.limits-legend-toggle {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 0.74rem;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem 0.15rem 0.35rem;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}

.limits-legend-toggle:hover {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}

.limits-legend-toggle:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
}

/* Скрытая серия однозначно обозначена: приглушена и перечёркнута. */
.limits-legend-toggle.is-hidden {
  color: var(--text-faint);
  opacity: 0.62;
}

.limits-legend-toggle.is-hidden .limits-legend-name {
  text-decoration: line-through;
}

.limits-legend-toggle.is-hidden .limits-legend-swatch {
  filter: grayscale(1);
  opacity: 0.5;
}

.limits-legend-swatch {
  background: var(--series-color, var(--accent));
  border-radius: 2px;
  height: 0.65rem;
  width: 0.65rem;
}

.limits-legend-window {
  color: var(--text-faint);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.limits-legend-value {
  color: var(--text);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

.limits-credits {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  padding-top: 0.6rem;
}

.limits-credit {
  align-items: baseline;
  display: inline-flex;
  gap: 0.4rem;
}

.limits-credit-label {
  color: var(--text-faint);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.limits-credit-value {
  color: var(--text);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

html[data-surface="mobile"] .limits-dialog {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  bottom: 0;
  left: 0;
  max-height: 90vh;
  max-width: 100vw;
  top: auto;
  transform: none;
  width: 100vw;
}

html[data-surface="mobile"] .limits-chart-svg {
  height: 13rem;
}

/* ========================================================== тост === */

.toast {
  background: var(--card-bg-open);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-chip);
  bottom: 1.2rem;
  box-shadow: var(--card-shadow);
  color: var(--text);
  font-size: 0.82rem;
  left: 50%;
  opacity: 0;
  padding: 0.5rem 0.9rem;
  position: fixed;
  transform: translate(-50%, 0.6rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
  align-items: center;
  display: flex;
  gap: 0.75rem;
}

.toast button {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ===================================== нижняя навигация (мобильный) === */

.mobile-nav {
  display: none;
}

/* ========================================= адаптив оболочки (мобильный) === */

html[data-surface="mobile"] .view-switch {
  display: none;
}

html[data-surface="mobile"] .connection-label {
  display: none;
}

html[data-surface="mobile"] .workspace {
  grid-template-columns: minmax(0, 1fr);
}

html[data-surface="mobile"] .activity-rail {
  display: none;
}

html[data-surface="mobile"] .task-rail,
html[data-surface="mobile"] .chat {
  min-width: 0;
  width: 100%;
}

html[data-surface="mobile"] .stream-chat-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

html[data-surface="mobile"] .stream-tabs {
  min-height: 3.35rem;
  padding: 0.22rem var(--gutter-right) 0.22rem var(--gutter-left);
}

html[data-surface="mobile"] .workspace-message-search {
  padding-inline: var(--gutter-left) var(--gutter-right);
  top: 3.35rem;
}

html[data-surface="mobile"] .stream-tab {
  min-height: 2.85rem;
  width: min(11rem, 72vw);
}

html[data-surface="mobile"] .stream-tab-create {
  flex-basis: 2rem;
  max-width: 2rem;
  width: 2rem;
}

html[data-surface="mobile"] .stream-order-toggle {
  flex-basis: 2rem;
  max-width: 2rem;
  width: 2rem;
}

html[data-surface="mobile"] .stream-chat-preview {
  display: none;
}

/* Слово «Задачи» дублирует подписанную вкладку нижней навигации, поэтому в
   шапке колонки остаются только счётчик и кнопка создания. */
html[data-surface="mobile"] .task-rail-head {
  padding: 0.45rem var(--gutter-left) 0.35rem;
}

html[data-surface="mobile"] .task-rail-title > span:first-child {
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

html[data-surface="mobile"] .task-search {
  margin-bottom: 0.4rem;
}

/* Строка задачи занимала около 85 px, и на экран влезало восемь задач из
   семидесяти. Плотность выше, но зона нажатия остаётся крупнее 44 px. */
html[data-surface="mobile"] .task-item {
  gap: 0.5rem;
  margin-bottom: 0.18rem;
  padding: 0.42rem 0.5rem;
}

html[data-surface="mobile"] .task-title {
  font-size: 0.84rem;
}

html[data-surface="mobile"] .task-meta {
  font-size: 0.72rem;
  gap: 0.32rem;
}

html[data-surface="mobile"] .chat-back {
  align-self: center;
  display: inline-flex;
  flex: 0 0 auto;
}

html[data-surface="mobile"] .chat-overlay-actions {
  right: var(--gutter-right);
  /* Панель настроек занимает ту же grid-ячейку. Кнопка остаётся поверх неё,
     чтобы повторный тап тем же переключателем закрывал панель. */
  z-index: 21;
}

html[data-surface="mobile"] .chat-pane[data-dialog-settings-open] {
  grid-template-columns: minmax(0, 1fr);
}

html[data-surface="mobile"][data-theme] .dialog-settings {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  max-width: 24rem;
  width: 100%;
  z-index: 20;
}

html[data-surface="mobile"] .quick-message-editor-summary-row,
html[data-surface="webview"] .quick-message-editor-summary-row {
  align-items: start;
}

html[data-surface="mobile"] .quick-message-editor-summary,
html[data-surface="webview"] .quick-message-editor-summary {
  grid-template-columns: auto minmax(0, 1fr);
  row-gap: 0.2rem;
}

html[data-surface="mobile"] .quick-message-editor-preview,
html[data-surface="webview"] .quick-message-editor-preview {
  grid-column: 2 / -1;
  grid-row: 2;
}

html[data-surface="mobile"] .quick-message-editor-action,
html[data-surface="mobile"] .quick-message-editor-add,
html[data-surface="mobile"] .quick-message-editor-summary {
  min-height: 2.75rem;
}

html[data-surface="mobile"] .quick-message-editor-order .quick-message-editor-action {
  min-width: 2.75rem;
}

html[data-surface="mobile"] .quick-message-editor-action.toggle {
  min-width: 2.75rem;
}

html[data-surface="mobile"] .quick-message-editor-footer {
  align-items: stretch;
  flex-direction: column;
}

html[data-surface="mobile"] .quick-message-editor-footer-order {
  align-items: stretch;
}

html[data-surface="mobile"] .quick-message-editor-footer-order .quick-message-editor-action,
html[data-surface="mobile"] .quick-message-editor-footer > .quick-message-editor-action {
  flex: 1 1 auto;
}

html[data-surface="mobile"][data-pane="tasks"] .chat {
  display: none;
}

html[data-surface="mobile"][data-pane="chat"] .task-rail {
  display: none;
}

/* На узком экране список задач и чат занимают всю ширину без прокрутки вбок. */
html[data-surface="mobile"] .msg {
  max-width: 92%;
}

/* На 360–390 px поле ввода получает отдельную строку, а инструменты не
   отнимают у него ширину. */
html[data-surface="mobile"] .composer-main {
  align-items: center;
  display: grid;
  grid-template-columns: auto auto auto auto minmax(0, 1fr) auto auto;
}

html[data-surface="mobile"] .composer-input {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
}

html[data-surface="mobile"] .composer-slash,
html[data-surface="mobile"] .composer-attach,
html[data-surface="mobile"] .context-usage,
html[data-surface="mobile"] .chat-back,
html[data-surface="mobile"] .chat-stop-bottom,
html[data-surface="mobile"] .composer-send {
  grid-row: 2;
}

html[data-surface="mobile"] .composer-send {
  grid-column: -2 / -1;
  justify-self: end;
}

html[data-surface="mobile"] .context-usage {
  justify-content: center;
  padding: 0;
  width: 2.4rem;
}

html[data-surface="mobile"] .context-usage > [data-context-label] {
  display: none;
}

html[data-surface="mobile"] .mobile-nav {
  align-items: stretch;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: flex;
  height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom));
  left: 0;
  padding-bottom: env(safe-area-inset-bottom);
  position: fixed;
  right: 0;
  z-index: 30;
}

.mobile-tab {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  font-size: 0.64rem;
  gap: 0.15rem;
  justify-content: center;
}

.mobile-tab svg {
  height: 1.25rem;
  width: 1.25rem;
}

.mobile-tab[aria-pressed="true"] {
  color: var(--accent);
}

/* Резервируем место под фиксированную навигацию. */
html[data-surface="mobile"][data-view="chat"] body {
  padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom));
}

html[data-surface="mobile"][data-view="journal"] .journal-view {
  padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom) + 1rem);
  width: 100%;
}

/* ========================================================= Статистика === */

.statistics-view {
  box-sizing: border-box;
  display: none;
  flex: 1 1 auto;
  width: 100%;
}

html[data-view="statistics"] .workspace,
html[data-view="statistics"] .journal-view {
  display: none;
}

html[data-view="statistics"] .statistics-view {
  display: block;
}

/* ================================================================ Фон === */

.background-view {
  box-sizing: border-box;
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

html[data-view="background"] body {
  height: 100dvh;
  overflow: hidden;
}

html[data-view="background"] .workspace,
html[data-view="background"] .journal-view,
html[data-view="background"] .statistics-view,
html[data-view="background"] .server-view {
  display: none;
}

html[data-view="background"] .background-view {
  display: block;
}

.msg-annotations {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.7rem;
}

.msg-annotation-content {
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  border: 0;
  border-left: 3px solid var(--accent-line);
  border-radius: var(--radius-sm);
  color: inherit;
  font: inherit;
  padding: 0.55rem 0.7rem;
  text-align: left;
  width: 100%;
}

.msg-annotation-content[data-response-annotation-source] {
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.msg-annotation-content[data-response-annotation-source]:hover,
.msg-annotation-content[data-response-annotation-source]:focus-visible {
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface-1));
  border-left-color: var(--accent);
  transform: translateY(-1px);
}

.msg-annotation-content[data-response-annotation-source]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 48%, transparent);
  outline-offset: 2px;
}

.msg-annotation-content.is-citation-target {
  animation: response-citation-target 1.8s ease-out;
  outline: 2px solid color-mix(in srgb, var(--accent) 72%, transparent);
  outline-offset: 3px;
}

.msg-source-citation-highlight {
  color: inherit;
  background: color-mix(in srgb, var(--accent, #d86a5d) 38%, transparent);
  border-radius: 3px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #d86a5d) 24%, transparent);
}

[data-response-citation-source-focus]:focus {
  outline: none;
}

@keyframes response-citation-target {
  0%, 28% {
    background: color-mix(in srgb, var(--accent-soft) 78%, var(--surface-1));
    box-shadow: 0 0 0 0.45rem color-mix(in srgb, var(--accent) 18%, transparent);
  }
  100% {
    background: color-mix(in srgb, var(--surface-1) 88%, transparent);
    box-shadow: none;
  }
}

.msg-response-citations {
  display: grid;
  gap: 0.42rem;
  margin-bottom: 0.65rem;
}

.msg-response-citation {
  align-items: start;
  background: color-mix(in srgb, var(--surface-1) 86%, transparent);
  border: 1px solid var(--accent-line);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 0.18rem;
  padding: 0.5rem 0.65rem;
  text-align: left;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
  width: 100%;
}

.msg-response-citation:hover,
.msg-response-citation:focus-visible {
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface-1));
  border-color: var(--accent);
  transform: translateY(-1px);
}

.msg-response-citation:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 48%, transparent);
  outline-offset: 2px;
}

.msg-response-citation.is-fallback {
  cursor: default;
}

.msg-response-citation.is-fallback:hover {
  background: color-mix(in srgb, var(--surface-1) 86%, transparent);
  border-color: var(--accent-line);
  transform: none;
}

.msg-response-citation-label {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.msg-response-citation-quote {
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--text-soft);
  display: -webkit-box;
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.42;
  overflow: hidden;
}

.msg-annotation-label {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
}

.msg-annotation-quote {
  color: var(--text-soft);
  font-size: 0.82rem;
  font-style: italic;
  white-space: pre-wrap;
}

.msg-annotation-comment {
  border-top: 1px solid var(--line);
  color: var(--text);
  margin-top: 0.45rem;
  padding-top: 0.45rem;
}

.msg-annotation-request {
  color: var(--text);
}

/* ============================================================ Сервер === */

.server-view {
  box-sizing: border-box;
  display: none;
  flex: 1 1 auto;
  margin: 0 auto;
  max-width: min(120rem, 100%);
  width: 100%;
}

html[data-view="server"] .workspace,
html[data-view="server"] .journal-view,
html[data-view="server"] .statistics-view,
html[data-view="server"] .background-view {
  display: none;
}

/* ================================================= новый журнал-реестр === */

.journal-view {
  margin-inline: auto;
  max-width: 1440px;
  width: min(100%, 1440px);
}

.journal-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.journal-shell-head {
  align-items: center;
  display: flex;
  gap: 1.2rem;
  min-width: 0;
  padding: 0 0.25rem;
}

.page-settings {
  background: color-mix(in srgb, var(--card-bg) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
}

.page-settings > summary {
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.8rem 1rem;
}

.page-settings-grid {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0 1rem 1rem;
}

.page-settings-grid > * {
  border-top: 1px solid var(--border-soft);
  padding: 0.85rem;
}

.page-settings-grid > .setting-stack:first-child {
  grid-row: span 4;
}

.journal-shell-title {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 0.08rem;
}

.journal-shell-title > span,
[data-journal-section-label] {
  color: var(--text-faint);
  font-family: var(--font-title);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.journal-shell-title h1 {
  color: var(--text);
  font-family: var(--font-title);
  font-size: 1.06rem;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0;
}

.journal-shell-totals {
  align-items: baseline;
  color: var(--text-muted);
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  font-family: var(--font-numeric);
  font-size: 0.75rem;
  gap: 0.5rem 1rem;
  min-width: 0;
}

.journal-shell-totals strong {
  color: var(--text);
  font-weight: 500;
}

.journal-shell-totals i {
  color: var(--line-strong);
  font-style: normal;
}

.journal-sync-status {
  background: color-mix(in srgb, var(--surface-2) 84%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  flex: 0 1 auto;
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  max-width: 21rem;
  min-width: 0;
  overflow: hidden;
  padding: 0.34rem 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal-sync-button {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  flex: 0 0 auto;
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  padding: 0.34rem 0.62rem;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}

.journal-sync-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--text);
}

.journal-sync-button:disabled {
  cursor: progress;
  opacity: 0.62;
}

.statistics-sync-card .statistics-card-head {
  margin-bottom: 0.75rem;
}

.statistics-sync-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.statistics-sync-controls .journal-sync-status {
  flex: 1 1 18rem;
  max-width: none;
}

.journal-grouping-tabs {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.15rem;
  padding: 0.18rem;
}

.journal-grouping-tabs button,
.journal-collapse-all {
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0.38rem 0.72rem;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.journal-grouping-tabs button:hover,
.journal-collapse-all:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.journal-grouping-tabs button[aria-pressed="true"] {
  background: var(--surface-3);
  border-color: var(--line-strong);
  color: var(--text);
}

.journal-collapse-all {
  border-color: var(--line);
  flex: 0 0 auto;
}

.journal-ledger {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.journal-ledger-head,
.journal summary[data-journal-ledger-summary] {
  column-gap: 1.4rem;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 76px 104px 140px 104px;
}

.journal-ledger-head {
  align-items: center;
  background: var(--sunken);
  border-bottom: 1px solid var(--line);
  color: var(--text-faint);
  font-family: var(--font-title);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 0.68rem 1.3rem;
  text-transform: uppercase;
}

.journal-ledger-head > span:not(:first-child) {
  text-align: right;
}

.journal-ledger .journal {
  min-height: 0;
}

.journal-ledger .journal[aria-busy="true"]::before {
  border: 0;
  border-radius: 0;
  height: 9rem;
}

.journal [data-work-log-task-groups],
.journal [data-journal-day-groups] {
  display: flex;
  flex-direction: column;
}

.journal details[data-journal-ledger-row] {
  background: var(--surface-1);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  overflow: hidden;
  padding: 0;
}

.journal details[data-journal-ledger-row]:last-child {
  border-bottom: 0;
}

.journal details[data-journal-ledger-row][open] {
  background: var(--card-bg-open);
}

.journal summary[data-journal-ledger-summary] {
  align-items: center;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  list-style: none;
  min-height: 3rem;
  padding: 0.82rem 1.35rem;
}

.journal summary[data-journal-ledger-summary]:hover {
  background: color-mix(in srgb, var(--surface-3) 58%, transparent);
}

.journal summary[data-journal-ledger-summary]::-webkit-details-marker,
.journal summary[data-journal-ledger-summary]::marker {
  display: none;
}

.journal summary[data-journal-ledger-summary]::before {
  content: none;
  display: none;
}

[data-journal-ledger-title] {
  align-items: center;
  color: var(--text);
  display: flex;
  gap: 0.55rem;
  min-width: 0;
}

[data-journal-ledger-title]::before {
  content: "";
  color: var(--text-faint);
  flex: 0 0 auto;
  font: 700 0.85rem/1 var(--font-numeric);
  height: 1em;
  text-align: center;
  transition: color 0.16s ease, transform 0.16s ease;
  width: 0.72rem;
}

details[open] > summary[data-journal-ledger-summary] [data-journal-ledger-title]::before {
  color: var(--accent);
  content: "›";
  transform: rotate(90deg);
}

details:not([open]) > summary[data-journal-ledger-summary] [data-journal-ledger-title]::before {
  content: "›";
}

[data-journal-ledger-title-text] {
  font-size: 0.86rem;
  font-weight: 560;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-journal-ledger-title-text] [data-work-log-task-content],
[data-journal-ledger-title-text] button[data-open-task] {
  border: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-journal-stream-badge] {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border-radius: var(--radius-sm);
  color: color-mix(in srgb, var(--accent) 62%, var(--text));
  flex: 0 0 auto;
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  padding: 0.12rem 0.42rem;
}

[data-journal-ledger-metric] {
  color: var(--text-soft);
  font-family: var(--font-numeric);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  justify-self: end;
  text-align: right;
  white-space: nowrap;
}

[data-journal-ledger-metric="credits"] {
  color: var(--warning, var(--accent));
}

[data-journal-ledger-metric="gaps"] {
  color: var(--text-faint);
}

[data-journal-ledger-expanded] {
  align-items: start;
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1fr) 260px;
  padding: 0.25rem 1.35rem 1.35rem;
}

[data-journal-ledger-expanded] > :is(
  [data-journal-virtual-turns],
  [data-journal-virtual-flat-turns],
  [data-work-log-workspace-streams],
  [data-journal-day-expanded]
) {
  grid-column: 1 / -1;
  min-width: 0;
}

[data-journal-virtual-turns][aria-busy="true"] [data-journal-turn-table]::before,
[data-journal-virtual-flat-turns][aria-busy="true"] [data-journal-turn-table]::before {
  color: var(--text-muted);
  content: "Загрузка ходов…";
  display: block;
  padding: 0.8rem;
}

[data-journal-turn-show-more] {
  margin: 0.75rem 0;
}

[data-journal-ledger-expanded] > [data-work-log-task-profile] {
  align-items: stretch;
  align-self: start;
  background: transparent;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 100%;
}

[data-journal-ledger-expanded]
  :is([data-journal-virtual-task-profile], [data-journal-virtual-workspace-profile])
  > [data-work-log-task-profile] {
  align-items: stretch;
  background: transparent;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 100%;
}

[data-journal-group-overview] {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

[data-journal-profile-metrics] {
  align-items: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 0;
}

[data-journal-profile-metric] {
  border-right: 1px solid var(--line);
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 7rem;
  padding: 0 1.7rem 0 0;
}

[data-journal-profile-metric] + [data-journal-profile-metric] {
  padding-left: 1.7rem;
}

[data-journal-profile-metric]:last-child {
  border-right: 0;
}

[data-journal-profile-metric] > span {
  color: var(--text-faint);
  font-family: var(--font-title);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

[data-journal-profile-metric] > strong {
  color: var(--text-soft);
  font-family: var(--font-numeric);
  font-size: 0.78rem;
  font-weight: 500;
}

[data-journal-profile-metric][data-missing] > strong {
  color: var(--text-faint);
}

[data-journal-ledger-expanded] [data-work-log-task-profile-copy] {
  display: block;
}

[data-journal-ledger-expanded] [data-work-log-task-profile-heading] {
  align-items: baseline;
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
}

[data-journal-ledger-expanded] [data-work-log-task-profile-heading] > strong {
  color: var(--text-faint);
  font-family: var(--font-title);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

[data-journal-ledger-expanded] [data-work-log-task-profile-heading] > span {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.62rem;
  line-height: 1;
  white-space: nowrap;
}

[data-journal-ledger-expanded] figure[data-work-log-task-radar] {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex: 0 0 190px;
  flex-direction: column;
  justify-content: center;
  height: 190px;
  max-height: 190px;
  min-height: 190px;
  overflow: hidden;
  padding: 0.15rem 0.35rem 0.45rem;
}

[data-journal-ledger-expanded] figure[data-work-log-task-radar] svg {
  height: 158px;
  max-height: 158px;
}

[data-journal-turn-list] {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

[data-journal-turn-list] > [data-journal-section-label] {
  margin-bottom: 0.1rem;
}

.journal [data-journal-turn-table] {
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.journal [data-journal-turn-table] > [data-work-log-turn-entry] {
  margin: 0;
}

.journal [data-journal-turn-table] > [data-work-log-turn-entry] + [data-work-log-turn-entry] {
  border-top: 1px solid var(--line);
}

.journal [data-journal-turn-table] details[data-work-log-turn-details] {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.journal [data-journal-turn-table] details[data-work-log-turn-details]:hover,
.journal [data-journal-turn-table] details[data-work-log-turn-details][open] {
  background: var(--surface-2);
  border: 0;
  box-shadow: none;
}

html:is([data-grouping="stream"], [data-grouping="workspace"])
  .journal [data-journal-turn-table]
  details[data-work-log-turn-details] > summary,
.journal [data-journal-turn-table] details[data-work-log-turn-details] > summary {
  grid-template-columns: 23rem minmax(0, 1fr) auto auto;
  min-height: 2.35rem;
}

.journal [data-journal-turn-table] [data-work-log-turn-meta] {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: minmax(10.75rem, 1fr) 6.2rem 3.2rem;
  padding: 0.48rem 0.65rem;
}

.journal details[data-journal-virtual-mode="date"]
  [data-journal-turn-table]
  [data-work-log-turn-day] {
  display: none;
}

.journal [data-journal-turn-table] [data-journal-turn-when],
.journal [data-journal-turn-table] [data-journal-turn-cost] {
  font-family: var(--font-numeric);
  font-size: 0.72rem;
  white-space: nowrap;
}

.journal [data-journal-turn-table] [data-journal-turn-cost] {
  color: var(--warning, var(--accent));
  text-align: right;
}

.journal [data-journal-turn-table] [data-work-log-turn-share] {
  display: inline;
}

.journal [data-journal-turn-table] [data-work-log-turn-title] {
  font-size: 0.8rem;
  padding-block: 0.48rem;
}

[data-journal-day-expanded] {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 1.4rem;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  padding: 0.85rem 1.3rem 1.2rem 2.5rem;
}

[data-journal-weekday] {
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 400;
  margin-left: 0.5rem;
}

[data-journal-day-picker] {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  min-width: 0;
}

[data-journal-day-picker-item] {
  background: color-mix(in srgb, var(--surface-1) 60%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

[data-journal-day-picker-item][data-selected] {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

[data-journal-day-picker-item] > button {
  align-items: baseline;
  background: transparent;
  border: 0;
  color: var(--text-soft);
  cursor: pointer;
  display: grid;
  gap: 0.38rem 0.6rem;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 0.62rem 0.7rem;
  text-align: left;
  width: 100%;
}

[data-journal-day-picker-item][data-selected] > button {
  color: var(--text);
}

[data-journal-day-picker-title] {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-journal-day-picker-title] [data-work-log-task-content],
[data-journal-day-picker-title] button[data-open-task] {
  border: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-journal-day-picker-credits] {
  align-items: baseline;
  display: inline-flex;
  flex: 0 0 auto;
  grid-column: 2;
  grid-row: 2;
  font-family: var(--font-numeric);
  font-size: 0.74rem;
}

[data-journal-day-picker-turns] {
  color: var(--text-muted);
  display: inline;
  flex: 0 0 auto;
  grid-column: 2;
  grid-row: 1;
  font-family: var(--font-numeric);
  font-size: 0.68rem;
  text-transform: uppercase;
}

[data-journal-day-picker-duration] {
  color: var(--text-muted);
  font-family: var(--font-numeric);
  font-size: 0.72rem;
  grid-column: 1;
  grid-row: 2;
  white-space: nowrap;
}

[data-journal-day-picker-share] {
  color: var(--text-muted);
}

[data-journal-day-breakdown] {
  border-top: 1px solid var(--line);
  display: none;
  padding: 0.5rem 0.7rem;
}

[data-journal-day-picker-item][data-selected] [data-journal-day-breakdown] {
  display: block;
}

[data-journal-day-breakdown] [data-task-usage-breakdown],
[data-journal-day-breakdown] [data-work-log-workspace-usage-breakdown] {
  background: transparent;
  border: 0;
  display: block;
  position: static;
  width: 100%;
}

[data-journal-day-breakdown]
  details[data-work-log-collapsed-workspace-usage-details] {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 0;
}

[data-journal-day-breakdown]
  details[data-work-log-collapsed-workspace-usage-details]
  > summary[data-task-usage] {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0.18rem 0;
}

[data-journal-day-breakdown]
  details[data-work-log-collapsed-workspace-usage-details]
  > summary[data-task-usage]::before {
  content: none;
  display: none;
}

[data-journal-day-breakdown]
  details[data-work-log-collapsed-workspace-usage-details]
  > [data-task-usage-breakdown] {
  border: 0;
  border-radius: 0;
  padding-top: 0.38rem;
}

[data-journal-day-breakdown] [data-task-usage-part] {
  border: 0;
  padding: 0.2rem 0;
}

[data-journal-day-panels] {
  min-width: 0;
}

/* ================================ Расход по аккаунтам в журнале ===
   Раскладка повторяет макет «Расход по аккаунтам.dc.html»: на десктопе лента
   периодов и таблица активного периода с раскрытием до устройств, на телефоне —
   крупный активный период, карточки аккаунтов и компактный список остальных
   периодов. Разметка у обеих раскладок общая, различие целиком в стилях. */
[data-work-log-account-panel] {
  background: var(--card-bg-open);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  margin: 0 0 0.9rem;
  overflow: hidden;

  /* Самый тихий уровень текста: отдельного токена под него в теме нет. */
  --account-text-dim: color-mix(in srgb, var(--text-faint) 76%, transparent);
}

[data-work-log-account-panel-head] {
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  padding: 1rem 1.35rem 0.85rem;
}

[data-work-log-account-panel-caption] {
  color: var(--text);
  font-family: var(--font-title);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

[data-work-log-account-panel-total] {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-chip);
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.69rem;
  padding: 0.12rem 0.5rem;
}

[data-work-log-account-panel-note] {
  color: var(--text-faint);
  font-size: 0.72rem;
  margin-left: auto;
}

[data-work-log-account-devices-toggle] {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.19rem 0.56rem;
  white-space: nowrap;
}

[data-work-log-account-devices-toggle]:hover {
  border-color: var(--accent-line);
}

[data-work-log-account-devices-toggle][disabled] {
  color: var(--text-faint);
  cursor: default;
  opacity: 0.6;
}

[data-work-log-account-periods] {
  display: grid;
  grid-template-columns: repeat(var(--account-period-count, 6), minmax(0, 1fr));
}

[data-work-log-account-period-tabs] {
  display: contents;
}

[data-work-log-account-period-tab] {
  appearance: none;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-family: inherit;
  gap: 0.37rem;
  grid-row: 1;
  padding: 1rem 1.35rem;
  text-align: left;
  transition: background 120ms ease;
}

[data-work-log-account-period-tabs] > [data-work-log-account-period-tab]:first-of-type {
  border-left: 0;
}

[data-work-log-account-period-tab]:hover {
  background: var(--surface-1);
}

[data-work-log-account-period-tab][data-active] {
  background: var(--accent-soft);
}

[data-work-log-account-period-name] {
  align-items: center;
  color: var(--text-faint);
  display: flex;
  font-family: var(--font-title);
  font-size: 0.65rem;
  font-weight: 600;
  gap: 0.37rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

[data-work-log-account-period-dot] {
  background: transparent;
  border-radius: 50%;
  flex: 0 0 auto;
  height: 5px;
  width: 5px;
}

[data-work-log-account-period-tab][data-active] [data-work-log-account-period-dot] {
  background: var(--accent);
}

[data-work-log-account-period-value] {
  align-items: baseline;
  display: flex;
  font-family: var(--font-numeric);
  gap: 0.44rem;
}

[data-work-log-account-period-amount] {
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1;
}

[data-work-log-account-period-tab][data-active] [data-work-log-account-period-amount] {
  color: var(--accent);
}

[data-work-log-account-period-unit] {
  color: var(--text-faint);
  font-size: 0.75rem;
}

[data-work-log-account-period-turns] {
  color: var(--text-muted);
  font-family: var(--font-numeric);
  font-size: 0.75rem;
}

[data-work-log-account-period-quality] {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.65rem;
}

[data-work-log-account-period-body] {
  background: var(--sunken);
  border-top: 1px solid var(--line-strong);
  display: none;
  grid-column: 1 / -1;
  grid-row: 2;
}

[data-work-log-account-period-body][data-active] {
  display: block;
}

/* Заголовок периода нужен только телефону: на десктопе он живёт в плитке. */
[data-work-log-account-period-headline] {
  display: none;
}

[data-work-log-account-columns],
[data-work-log-account-row],
[data-work-log-account-device-row] {
  column-gap: 1.25rem;
  display: grid;
  grid-template-columns: 2.3fr 1.25fr minmax(0, 1.5fr) 2.1rem 0.8fr 0.9fr;
}

[data-work-log-account-columns] {
  border-bottom: 1px solid var(--line);
  padding: 0.62rem 1.35rem;
}

[data-work-log-account-column] {
  color: var(--text-faint);
  font-family: var(--font-title);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

[data-work-log-account-column="share"] {
  grid-column: span 2;
}

[data-work-log-account-column="turns"],
[data-work-log-account-column="credits"] {
  text-align: right;
}

[data-work-log-account-group] {
  border-bottom: 1px solid var(--line);

  --account-color: var(--provider-none);
}

[data-work-log-account-group][data-open] {
  background: var(--card-bg-open);
}

[data-work-log-account-group]:has([data-account-color="0"]) { --account-color: var(--dot-think); }
[data-work-log-account-group]:has([data-account-color="1"]) { --account-color: var(--dot-cache); }
[data-work-log-account-group]:has([data-account-color="2"]) { --account-color: var(--dot-output); }
[data-work-log-account-group]:has([data-account-color="3"]) { --account-color: var(--accent); }
[data-work-log-account-group]:has([data-account-color="4"]) { --account-color: var(--ok); }
[data-work-log-account-group]:has([data-account-color="5"]) { --account-color: var(--pending); }

[data-work-log-account-row] {
  align-items: center;
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  padding: 0.88rem 1.35rem;
  text-align: left;
  transition: background 120ms ease;
  width: 100%;
}

[data-work-log-account-row]:hover {
  background: var(--surface-1);
}

[data-work-log-account-row][disabled] {
  cursor: default;
}

[data-work-log-account-name] {
  align-items: center;
  display: flex;
  gap: 0.56rem;
  min-width: 0;
}

[data-work-log-account-caret] {
  background: var(--text-faint);
  flex: 0 0 auto;
  height: 0.62rem;
  -webkit-mask: var(--ph-mask-caret-right) center / contain no-repeat;
  mask: var(--ph-mask-caret-right) center / contain no-repeat;
  transform-origin: center;
  transition: transform 0.18s ease;
  width: 0.62rem;
}

[data-work-log-account-group][data-open] [data-work-log-account-caret] {
  background: var(--accent);
  transform: rotate(90deg);
}

[data-work-log-account-row][disabled] [data-work-log-account-caret] {
  opacity: 0;
}

[data-work-log-account-identity] {
  align-items: baseline;
  column-gap: 0.3rem;
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  row-gap: 0.19rem;
}

[data-work-log-account-label] {
  flex: 1 0 100%;
  font-size: 0.84rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-work-log-account-quality],
[data-work-log-account-device-count] {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.65rem;
}

[data-work-log-account-device-count]::before {
  content: "· ";
}

[data-work-log-account-provider] {
  align-items: center;
  display: flex;
  gap: 0.37rem;
  min-width: 0;
}

[data-work-log-account-provider-rail] {
  align-self: stretch;
  display: flex;
  flex: 0 0 var(--rail-width);
  flex-direction: column;
  min-height: 1.35rem;
  overflow: hidden;
  width: var(--rail-width);
}

[data-work-log-account-provider-rail-segment] {
  background: var(--account-provider-color, var(--provider-none));
  flex: 1 1 0;
  min-height: 2px;
}

[data-work-log-account-provider-name] {
  align-items: baseline;
  display: inline-flex;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-work-log-account-provider-label] {
  color: var(--account-provider-color, var(--text-soft));
}

[data-work-log-account-provider-separator] {
  color: var(--text-faint);
}

[data-provider-tone="codex"] {
  --account-provider-hue: var(--provider-codex-hue);
  --account-provider-color: oklch(
    var(--provider-tone-lightness)
    var(--provider-tone-chroma)
    var(--account-provider-hue)
  );
  --account-provider-tint: oklch(
    var(--provider-tone-lightness)
    var(--provider-tone-chroma)
    var(--account-provider-hue)
    / var(--provider-tone-alpha)
  );
}

[data-provider-tone="claude"] {
  --account-provider-hue: var(--provider-claude-hue);
  --account-provider-color: oklch(
    var(--provider-tone-lightness)
    var(--provider-tone-chroma)
    var(--account-provider-hue)
  );
  --account-provider-tint: oklch(
    var(--provider-tone-lightness)
    var(--provider-tone-chroma)
    var(--account-provider-hue)
    / var(--provider-tone-alpha)
  );
}

[data-provider-tone="unknown"] {
  --account-provider-color: var(--provider-none);
}

[data-work-log-account-plan] {
  background: var(--account-provider-tint, var(--surface-2));
  border: 1px solid color-mix(
    in srgb,
    var(--account-provider-color, var(--provider-none)) 58%,
    transparent
  );
  border-radius: var(--radius-sm);
  color: var(--account-provider-color, var(--text-faint));
  font-family: var(--font-numeric);
  font-size: 0.65rem;
  overflow: hidden;
  padding: 0.06rem 0.31rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Общий шаг колонок — 20px, а между полосой и её долей макет оставляет 10px. */
[data-work-log-account-bar] {
  background: var(--line-strong);
  border-radius: 4px;
  display: flex;
  height: 7px;
  margin-right: -0.62rem;
  overflow: hidden;
  position: relative;
}

/* Ширина сегмента приезжает скриптом уже после разбора разметки, а строки
   периода при переключении заменяются целиком: перехода по width здесь нет
   намеренно, иначе полоса разгонялась бы от нуля на каждой перерисовке. */
[data-work-log-account-bar-segment] {
  background: var(--account-color);
  border-right: 1px solid var(--sunken);
  flex: 0 0 auto;
  min-width: 5px;
  width: var(--account-share, 0%);
}

[data-work-log-account-bar-segment]:last-child {
  border-right: 0;
}

[data-work-log-account-bar-device-fill] {
  background: var(--account-color);
  border-radius: inherit;
  bottom: 0;
  left: var(--account-offset, 0%);
  min-width: 4px;
  position: absolute;
  top: 0;
  width: var(--account-share, 0%);
}

/* Устройства аккаунта разведены по насыщенности, чтобы читаться на полосе 7px
   и оставаться цветом одного аккаунта. */
[data-work-log-account-group][data-open] [data-work-log-account-bar-segment][data-device-index="1"] {
  background: color-mix(in srgb, var(--account-color) 70%, var(--text-faint));
}

[data-work-log-account-group][data-open] [data-work-log-account-bar-segment][data-device-index="2"] {
  background: color-mix(in srgb, var(--account-color) 45%, var(--text-faint));
}

[data-work-log-account-group][data-open] [data-work-log-account-bar-segment][data-device-index="3"] {
  background: color-mix(in srgb, var(--account-color) 30%, var(--text-faint));
}

[data-work-log-account-group][data-open] [data-work-log-account-bar-device-fill][data-device-index="1"] {
  background: color-mix(in srgb, var(--account-color) 70%, var(--text-faint));
}

[data-work-log-account-group][data-open] [data-work-log-account-bar-device-fill][data-device-index="2"] {
  background: color-mix(in srgb, var(--account-color) 45%, var(--text-faint));
}

[data-work-log-account-group][data-open] [data-work-log-account-bar-device-fill][data-device-index="3"] {
  background: color-mix(in srgb, var(--account-color) 30%, var(--text-faint));
}

[data-work-log-account-share] {
  color: var(--text-muted);
  font-family: var(--font-numeric);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

[data-work-log-account-turns] {
  color: var(--text-muted);
  font-family: var(--font-numeric);
  font-size: 0.78rem;
  text-align: right;
}

[data-work-log-account-credits] {
  color: var(--account-color);
  font-family: var(--font-numeric);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

/* Внутри панели расход читается как число: цвет несёт аккаунт, а не badge. */
[data-work-log-account-panel] span[data-kilo-usage],
[data-work-log-account-panel] span[data-mega-usage],
[data-work-log-account-panel] span[data-high-usage] {
  background: transparent;
  box-shadow: none;
  color: inherit;
  font-weight: inherit;
  padding: 0;
}

[data-work-log-account-devices-breakdown] {
  display: none;
}

[data-work-log-account-group][data-open] > [data-work-log-account-devices-breakdown] {
  display: block;
}

/* Строка устройства не повторяет родительскую: вместо стрелки — рельс, а на
   полосе закрашена только собственная область устройства внутри аккаунта. */
[data-work-log-account-device-row] {
  align-items: center;
  padding: 0.56rem 1.35rem;
}

[data-work-log-account-device-row]:hover {
  background: var(--surface-1);
}

[data-work-log-account-device-row] > [data-work-log-account-name] {
  align-items: stretch;
  gap: 0;
  padding-left: 1.5rem;
}

[data-work-log-account-device-rail] {
  background: var(--line-strong);
  flex: 0 0 auto;
  width: 1px;
}

[data-work-log-account-device-swatch] {
  display: none;
}

[data-work-log-account-device-row] [data-work-log-account-identity] {
  flex-direction: column;
  padding-left: 0.62rem;
  row-gap: 0.12rem;
}

[data-work-log-account-device-head] {
  align-items: baseline;
  column-gap: 0.5rem;
  display: flex;
  min-width: 0;
}

[data-work-log-account-device-label] {
  color: var(--text-soft);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-work-log-account-device-id] {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.65rem;
}

[data-work-log-account-device-origin] {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.59rem;
  letter-spacing: 0.06em;
  padding: 0 0.31rem;
  text-transform: uppercase;
  white-space: nowrap;
}

[data-work-log-account-device-quality] {
  color: var(--account-text-dim);
  font-family: var(--font-numeric);
  font-size: 0.62rem;
}

[data-work-log-account-device-row] [data-work-log-account-provider-name] {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.72rem;
}

[data-work-log-account-device-row] [data-work-log-account-bar] {
  background: var(--line);
  border-radius: 3px;
  height: 6px;
}

[data-work-log-account-device-row] [data-work-log-account-share] {
  color: var(--text-faint);
  font-size: 0.69rem;
  font-weight: 400;
}

[data-work-log-account-device-row] [data-work-log-account-turns] {
  color: var(--text-faint);
  font-size: 0.72rem;
}

[data-work-log-account-device-row] [data-work-log-account-credits] {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 400;
}

[data-work-log-account-foot] {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.56rem 1.35rem;
}

[data-work-log-account-idle] {
  color: var(--text-faint);
  font-size: 0.72rem;
}

[data-work-log-account-total] {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.72rem;
  white-space: nowrap;
}

[data-work-log-account-empty] {
  color: var(--text-faint);
  font-size: 0.72rem;
  padding: 0.88rem 1.35rem;
}

/* Телефон: активный период — крупный блок с карточками аккаунтов, остальные
   периоды уходят компактным списком вниз. Порядок ячеек внутри карточки задан
   через order, потому что разметка у обеих раскладок одна. */
html[data-surface="mobile"] [data-work-log-account-panel-head] {
  padding: 0.88rem 1rem 0.75rem;
  row-gap: 0.37rem;
}

html[data-surface="mobile"] [data-work-log-account-panel-caption] {
  font-size: 0.75rem;
}

html[data-surface="mobile"] [data-work-log-account-panel-total] {
  border: 0;
  font-size: 0.65rem;
  padding: 0;
}

html[data-surface="mobile"] [data-work-log-account-panel-note] {
  flex: 1 0 100%;
  font-size: 0.69rem;
  margin-left: 0;
  order: 2;
  text-wrap: pretty;
}

html[data-surface="mobile"] [data-work-log-account-devices-toggle] {
  margin-left: auto;
}

html[data-surface="mobile"] [data-work-log-account-periods] {
  display: flex;
  flex-direction: column;
}

html[data-surface="mobile"] [data-work-log-account-period-body] {
  border-bottom: 1px solid var(--line-strong);
  border-top: 0;
  order: 1;
  padding: 0.88rem 1rem;
}

html[data-surface="mobile"] [data-work-log-account-period-tab] {
  background: var(--sunken);
  border-bottom: 1px solid var(--line);
  border-left: 0;
  box-sizing: border-box;
  flex-direction: row;
  gap: 0.62rem;
  min-height: 44px;
  order: 2;
  padding: 0.62rem 1rem;
  width: 100%;
}

html[data-surface="mobile"] [data-work-log-account-period-tab][data-active] {
  display: none;
}

html[data-surface="mobile"] [data-work-log-account-period-name] {
  color: var(--text-soft);
  font-family: var(--font-body);
  font-size: 0.81rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

html[data-surface="mobile"] [data-work-log-account-period-dot],
html[data-surface="mobile"] [data-work-log-account-period-quality] {
  display: none;
}

/* В компактном списке периодов сумма стоит последней, поэтому она меняется
   местами с числом ходов: в разметке плитки сумма идёт раньше. */
html[data-surface="mobile"] [data-work-log-account-period-turns] {
  font-size: 0.69rem;
  margin-left: auto;
  order: 2;
}

html[data-surface="mobile"] [data-work-log-account-period-tab]
  > [data-work-log-account-period-value] {
  order: 3;
}

html[data-surface="mobile"] [data-work-log-account-period-tab]
  [data-work-log-account-period-amount] {
  color: var(--text);
  font-size: 0.94rem;
}

html[data-surface="mobile"] [data-work-log-account-period-tab]
  [data-work-log-account-period-unit] {
  color: inherit;
  font-size: 0.94rem;
  font-weight: 600;
}

html[data-surface="mobile"] [data-work-log-account-period-headline] {
  align-items: baseline;
  column-gap: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  row-gap: 0.37rem;
}

html[data-surface="mobile"] [data-work-log-account-period-headline-title] {
  color: var(--text-faint);
  font-family: var(--font-title);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

html[data-surface="mobile"] [data-work-log-account-period-headline-quality] {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.69rem;
  margin-left: auto;
}

html[data-surface="mobile"] [data-work-log-account-period-headline-value] {
  flex: 0 0 auto;
  order: 3;
}

html[data-surface="mobile"] [data-work-log-account-period-headline-value]
  [data-work-log-account-period-amount] {
  color: var(--accent);
  font-size: 1.88rem;
}

html[data-surface="mobile"] [data-work-log-account-period-headline-value]
  [data-work-log-account-period-unit] {
  color: var(--accent);
  font-size: 0.81rem;
}

html[data-surface="mobile"] [data-work-log-account-period-headline-turns] {
  color: var(--text-muted);
  font-family: var(--font-numeric);
  font-size: 0.81rem;
  order: 4;
}

html[data-surface="mobile"] [data-work-log-account-columns] {
  display: none;
}

html[data-surface="mobile"] [data-work-log-account-rows] {
  display: grid;
  gap: 0.5rem;
  padding-top: 0.62rem;
}

html[data-surface="mobile"] [data-work-log-account-group],
html[data-surface="mobile"] [data-work-log-account-group][data-open] {
  background: var(--surface-2);
  border: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: 0.75rem;
  position: relative;
}

html[data-surface="mobile"] [data-work-log-account-row],
html[data-surface="mobile"] [data-work-log-account-row]:hover,
html[data-surface="mobile"] [data-work-log-account-device-row],
html[data-surface="mobile"] [data-work-log-account-device-row]:hover {
  align-items: baseline;
  background: transparent;
  column-gap: 0.44rem;
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  row-gap: 0.37rem;
}

html[data-surface="mobile"] [data-work-log-account-row] > [data-work-log-account-name],
html[data-surface="mobile"] [data-work-log-account-row] [data-work-log-account-identity],
html[data-surface="mobile"] [data-work-log-account-device-row] > [data-work-log-account-name],
html[data-surface="mobile"] [data-work-log-account-device-row] [data-work-log-account-identity],
html[data-surface="mobile"] [data-work-log-account-device-head] {
  display: contents;
}

html[data-surface="mobile"] [data-work-log-account-caret],
html[data-surface="mobile"] [data-work-log-account-quality],
html[data-surface="mobile"] [data-work-log-account-device-rail],
html[data-surface="mobile"] [data-work-log-account-device-quality],
html[data-surface="mobile"] [data-work-log-account-device-row] [data-work-log-account-provider],
html[data-surface="mobile"] [data-work-log-account-device-row] [data-work-log-account-bar] {
  display: none;
}

html[data-surface="mobile"] [data-work-log-account-row]::after,
html[data-surface="mobile"] [data-work-log-account-device-row]::after {
  content: "";
  flex: 1 0 100%;
  height: 0;
  order: 40;
}

html[data-surface="mobile"] [data-work-log-account-label] {
  flex: 1 1 auto;
  font-size: 0.81rem;
  order: 20;
}

html[data-surface="mobile"] [data-work-log-account-row] > [data-work-log-account-credits] {
  flex: 0 0 auto;
  font-size: 0.88rem;
  order: 30;
}

html[data-surface="mobile"] [data-work-log-account-row] > [data-work-log-account-bar] {
  align-self: center;
  flex: 1 0 100%;
  height: 6px;
  margin-right: 0;
  order: 50;
}

html[data-surface="mobile"] [data-work-log-account-row] > [data-work-log-account-provider] {
  flex: 0 0 auto;
  gap: 0.31rem;
  order: 60;
}

html[data-surface="mobile"] [data-work-log-account-provider-name] {
  border: 0;
  font-family: var(--font-body);
  font-size: 0.69rem;
  padding: 0;
}

html[data-surface="mobile"] [data-work-log-account-plan] {
  border: 0;
  border-radius: calc(var(--radius-sm) * 0.7);
  font-size: 0.62rem;
  padding: 0.08rem 0.28rem;
}

html[data-surface="mobile"] [data-work-log-account-provider-rail] {
  bottom: 0;
  left: 0;
  min-height: 0;
  position: absolute;
  top: 0;
}

html[data-surface="mobile"] [data-work-log-account-row] > [data-work-log-account-share] {
  color: var(--text-faint);
  flex: 0 0 auto;
  font-size: 0.69rem;
  font-weight: 400;
  order: 70;
}

html[data-surface="mobile"] [data-work-log-account-row] > [data-work-log-account-share]::before {
  content: "· ";
}

html[data-surface="mobile"] [data-work-log-account-row] > [data-work-log-account-turns] {
  color: var(--text-faint);
  flex: 0 0 auto;
  font-size: 0.69rem;
  margin-left: auto;
  order: 80;
}

html[data-surface="mobile"] [data-work-log-account-row] > [data-work-log-account-turns]::after {
  content: " ход.";
}

html[data-surface="mobile"] [data-work-log-account-device-count] {
  flex: 0 0 auto;
  order: 90;
}

html[data-surface="mobile"] [data-work-log-account-devices-breakdown] {
  border-left: 1px solid var(--line-strong);
  display: none;
  margin: 0.5rem 0 0 0.12rem;
  padding-left: 0.75rem;
}

html[data-surface="mobile"]
  [data-work-log-account-group][data-open] > [data-work-log-account-devices-breakdown] {
  display: grid;
  gap: 0.5rem;
}

html[data-surface="mobile"] [data-work-log-account-device-swatch] {
  background: var(--account-color);
  border-radius: 2px;
  display: block;
  flex: 0 0 auto;
  height: 8px;
  order: 10;
  width: 8px;
}

html[data-surface="mobile"]
  [data-work-log-account-device-row][data-device-index="1"] [data-work-log-account-device-swatch] {
  background: color-mix(in srgb, var(--account-color) 70%, var(--text-faint));
}

html[data-surface="mobile"]
  [data-work-log-account-device-row][data-device-index="2"] [data-work-log-account-device-swatch] {
  background: color-mix(in srgb, var(--account-color) 45%, var(--text-faint));
}

html[data-surface="mobile"]
  [data-work-log-account-device-row][data-device-index="3"] [data-work-log-account-device-swatch] {
  background: color-mix(in srgb, var(--account-color) 30%, var(--text-faint));
}

html[data-surface="mobile"] [data-work-log-account-device-label] {
  flex: 1 1 auto;
  font-size: 0.72rem;
  order: 20;
}

html[data-surface="mobile"] [data-work-log-account-device-row] > [data-work-log-account-credits] {
  color: var(--text-muted);
  flex: 0 0 auto;
  font-size: 0.72rem;
  order: 30;
}

html[data-surface="mobile"] [data-work-log-account-device-origin] {
  background: transparent;
  border: 0;
  color: var(--account-text-dim);
  font-size: 0.62rem;
  letter-spacing: 0;
  order: 50;
  padding: 0;
  text-transform: none;
}

html[data-surface="mobile"] [data-work-log-account-device-id] {
  color: var(--account-text-dim);
  font-size: 0.62rem;
  order: 60;
}

html[data-surface="mobile"] [data-work-log-account-device-row] > [data-work-log-account-turns] {
  color: var(--account-text-dim);
  flex: 0 0 auto;
  font-size: 0.62rem;
  order: 70;
}

html[data-surface="mobile"] [data-work-log-account-device-row] > [data-work-log-account-turns]::after {
  content: " ход.";
}

html[data-surface="mobile"] [data-work-log-account-device-row] > [data-work-log-account-share] {
  color: var(--account-text-dim);
  flex: 0 0 auto;
  font-size: 0.62rem;
  order: 80;
}

html[data-surface="mobile"] [data-work-log-account-device-id]::before,
html[data-surface="mobile"] [data-work-log-account-device-row] > [data-work-log-account-turns]::before,
html[data-surface="mobile"] [data-work-log-account-device-row] > [data-work-log-account-share]::before {
  content: "· ";
}

html[data-surface="mobile"] [data-work-log-account-foot] {
  padding: 0.62rem 0 0;
}

html[data-surface="mobile"] [data-work-log-account-idle] {
  font-size: 0.69rem;
}

html[data-surface="mobile"] [data-work-log-account-total] {
  display: none;
}

html[data-surface="mobile"] [data-work-log-account-empty] {
  padding: 0.5rem 0 0;
}
[data-journal-day-panel] {
  min-width: 0;
}

[data-journal-day-panel][hidden] {
  display: none;
}

[data-journal-day-panel-heading] {
  color: var(--text-faint);
  font-family: var(--font-title);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin-bottom: 0.42rem;
  text-transform: uppercase;
}

.journal [data-journal-day-panel] [data-work-log-turn-table] {
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  gap: 0;
  overflow: hidden;
}

.journal [data-journal-day-panel] [data-work-log-turn-entry] {
  margin: 0;
}

.journal [data-journal-day-panel] [data-work-log-turn-entry]
  + [data-work-log-turn-entry] {
  border-top: 1px solid var(--line);
}

.journal [data-journal-day-panel] details[data-work-log-turn-details],
.journal [data-journal-day-panel] details[data-work-log-turn-details]:hover,
.journal [data-journal-day-panel] details[data-work-log-turn-details][open] {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.journal [data-journal-day-panel] details[data-work-log-turn-details] > summary {
  grid-template-columns: 23rem minmax(0, 1fr) auto auto;
  min-height: 2.35rem;
}

.journal [data-journal-day-panel] [data-work-log-turn-meta] {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: minmax(10.75rem, 1fr) 6.2rem 3.2rem;
  padding: 0.48rem 0.65rem;
}

.journal [data-journal-day-panel] [data-journal-turn-when],
.journal [data-journal-day-panel] [data-journal-turn-cost],
.journal [data-journal-day-panel] [data-work-log-turn-share] {
  font-family: var(--font-numeric);
  font-size: 0.72rem;
  white-space: nowrap;
}

.journal [data-journal-day-panel] [data-journal-turn-cost],
.journal [data-journal-day-panel] [data-work-log-turn-share] {
  text-align: right;
}

.journal [data-journal-day-panel] [data-work-log-turn-title] {
  font-size: 0.8rem;
  padding-block: 0.48rem;
}

@media (max-width: 1100px) {
  .journal-shell-head {
    flex-wrap: wrap;
  }

  .journal-shell-totals {
    order: 2;
    width: 100%;
  }

  .journal-sync-status {
    order: 2;
  }

  .journal-sync-button {
    order: 2;
  }

  .journal-ledger-head,
  .journal summary[data-journal-ledger-summary] {
    column-gap: 0.8rem;
    grid-template-columns: minmax(230px, 1fr) 62px 88px 118px 62px;
  }
}

@media (max-width: 860px) {
  .journal-view {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

  .journal-shell-head {
    gap: 0.65rem;
  }

  .journal-shell-title {
    margin-right: auto;
  }

  .journal-grouping-tabs {
    display: grid;
    flex: 1 1 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    order: 3;
  }

  .journal-grouping-tabs button {
    min-width: 0;
    padding-inline: 0.25rem;
  }

  .journal-collapse-all {
    order: 1;
  }

  .journal-shell-totals {
    font-size: 0.68rem;
    gap: 0.35rem 0.65rem;
    order: 2;
  }

  .journal-sync-status {
    flex: 1 1 100%;
    max-width: none;
    order: 2;
  }

  .journal-sync-button {
    order: 2;
  }

  .journal-ledger-head {
    display: none;
  }

  .journal summary[data-journal-ledger-summary] {
    column-gap: 0.55rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 0.68rem 0.75rem;
    row-gap: 0.5rem;
  }

  [data-journal-ledger-title] {
    grid-column: 1 / -1;
  }

  [data-journal-ledger-metric] {
    align-items: end;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    justify-self: stretch;
    text-align: left;
  }

  [data-journal-ledger-metric]::before {
    color: var(--text-faint);
    font-family: var(--font-title);
    font-size: 0.48rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  [data-journal-ledger-metric="turns"]::before { content: "Ходы"; }
  [data-journal-ledger-metric="credits"]::before { content: "Расход"; }
  [data-journal-ledger-metric="duration"]::before { content: "Время"; }
  [data-journal-ledger-metric="gaps"]::before { content: "Пробелы"; }

  [data-journal-ledger-expanded],
  [data-journal-day-expanded] {
    display: block;
    padding: 0.7rem 0.75rem 0.9rem;
  }

  [data-journal-ledger-expanded] > [data-work-log-task-profile] {
    margin-top: 1rem;
  }

  [data-journal-profile-metrics] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  [data-journal-profile-metric],
  [data-journal-profile-metric] + [data-journal-profile-metric] {
    border: 0;
    border-bottom: 1px solid var(--line);
    min-width: 0;
    padding: 0 0 0.55rem;
  }

  [data-journal-day-picker] {
    margin-bottom: 0.8rem;
  }

  [data-journal-turn-list] {
    margin-top: 0.8rem;
  }
}

/* На телефоне строка ledger раскладывается явно в две колонки. Автоматическая
   четырёхколоночная сетка в Android Chrome могла расширить крайние метрики за
   внутренний отступ summary, после чего их обрезал overflow карточки. */
@media (max-width: 520px) {
  .journal summary[data-journal-ledger-summary] {
    box-sizing: border-box;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    padding: 0.78rem 1rem 0.9rem;
  }

  .journal summary[data-journal-ledger-summary] > [data-journal-ledger-title] {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .journal summary[data-journal-ledger-summary] > [data-journal-ledger-metric] {
    align-items: flex-start;
    justify-self: stretch;
    min-width: 0;
    text-align: left;
  }

  .journal summary[data-journal-ledger-summary] > [data-journal-ledger-metric="turns"] {
    grid-column: 1;
    grid-row: 2;
  }

  .journal summary[data-journal-ledger-summary] > [data-journal-ledger-metric="credits"] {
    grid-column: 2;
    grid-row: 2;
  }

  .journal summary[data-journal-ledger-summary] > [data-journal-ledger-metric="duration"] {
    grid-column: 1;
    grid-row: 3;
  }

  .journal summary[data-journal-ledger-summary] > [data-journal-ledger-metric="gaps"] {
    grid-column: 2;
    grid-row: 3;
  }

  .journal summary[data-journal-ledger-summary]
    > :is([data-journal-ledger-metric="credits"], [data-journal-ledger-metric="gaps"]) {
    align-items: flex-end;
    text-align: right;
  }
}

html[data-view="server"] .server-view {
  display: block;
}

/* Страница сервера, как статистика, занимает всю ширину: колонка по центру
   оставляла половину экрана пустой, а плитки внутри карточек всё равно
   раскладываются сами. */
.server-content {
  display: grid;
  gap: 1.15rem;
  padding: 1.25rem clamp(1rem, 2vw, 1.75rem) 3rem;
  width: 100%;
}

.server-overview-grid {
  align-items: start;
  display: grid;
  gap: 1.15rem;
  grid-template-columns: minmax(0, 1fr) clamp(18rem, 18vw, 22rem);
  min-width: 0;
  width: 100%;
}

.server-overview-column {
  display: grid;
  gap: 1.15rem;
  min-width: 0;
}

@media (max-width: 82rem) {
  .server-overview-grid {
    display: flex;
    flex-direction: column;
  }

  .server-overview-column {
    display: contents;
  }

  .server-health-card { order: 1; }
  .server-card[aria-labelledby="server-config-title"] { order: 2; }
  .root-agents-editor[data-agent-hub-guide] { order: 3; }
  .root-agents-editor[data-global-pre-turn-editor] { order: 4; }
  .root-agents-editor[data-root-agents-editor] { order: 5; }
  .server-card[aria-labelledby="server-components-title"] { order: 6; }
  .trusted-devices-panel { order: 7; }
}

.server-health-card,
.server-card {
  background: var(--card-bg-open);
  background-color: color-mix(in srgb, var(--bg) 94%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  min-width: 0;
  padding: clamp(1rem, 2.4vw, 1.35rem);
}

.server-health-card {
  background:
    radial-gradient(100% 110% at 100% 0%, color-mix(in srgb, var(--accent) 17%, transparent), transparent 64%),
    var(--card-bg-open);
  background-color: color-mix(in srgb, var(--bg) 94%, transparent);
}

.server-card-head {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.server-card-head h2 {
  color: var(--text);
  font-family: var(--font-title);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  margin: 0;
}

.server-card-head p {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0.32rem 0 0;
}

.server-card-head.compact {
  margin-bottom: 0.95rem;
}

.server-kicker {
  color: var(--accent) !important;
  font-family: var(--font-title);
  font-size: 0.65rem !important;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin: 0 0 0.35rem !important;
  text-transform: uppercase;
}

.server-state-dot {
  background: var(--text-faint);
  border-radius: 50%;
  box-shadow: 0 0 0 0.28rem color-mix(in srgb, var(--text-faint) 15%, transparent);
  flex: 0 0 auto;
  height: 0.65rem;
  margin: 0.42rem 0.2rem 0 0;
  width: 0.65rem;
}

.server-state-dot[data-online] {
  background: #72d8a4;
  box-shadow: 0 0 0 0.28rem color-mix(in srgb, #72d8a4 17%, transparent);
}

/* Пара «название — значение» лежит в своей плитке: в двух колонках список
   растягивался на всю ширину и значение уезжало от подписи через полэкрана. */
.server-facts {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  margin: 1.2rem 0 0;
}

.server-fact {
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  min-width: 0;
  padding: 0.65rem 0.72rem;
}

.server-facts dt {
  color: var(--text-faint);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.server-facts dd {
  color: var(--text);
  font-family: var(--font-numeric);
  font-size: 0.86rem;
  margin: 0.26rem 0 0;
  overflow-wrap: anywhere;
}

.server-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1rem;
  justify-content: space-between;
}

.server-controls .setting-switch {
  flex: 1 1 18rem;
}

.server-controls .chip-button {
  align-items: center;
  display: inline-flex;
  gap: 0.45rem;
}

.server-controls .chip-button svg {
  height: 1rem;
  width: 1rem;
}

.server-component-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.trusted-devices-panel {
  padding: 0;
  width: 100%;
}

.trusted-devices-summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 2.75rem 1rem 1.15rem;
  position: relative;
}

.trusted-devices-summary::-webkit-details-marker {
  display: none;
}

.trusted-devices-summary > span {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.trusted-devices-summary strong {
  color: var(--text);
  font-family: var(--font-title);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
}

.trusted-devices-summary small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.trusted-devices-summary::before {
  background: var(--text-faint);
  content: "";
  height: 0.72rem;
  -webkit-mask: var(--ph-mask-caret-right) center / contain no-repeat;
  mask: var(--ph-mask-caret-right) center / contain no-repeat;
  position: absolute;
  right: 1.15rem;
  top: 50%;
  transform: translateY(-50%);
  transform-origin: center;
  transition: transform 0.18s ease;
  width: 0.72rem;
}

.trusted-devices-panel[open] > .trusted-devices-summary::before {
  transform: translateY(-50%) rotate(90deg);
}

.root-agents-editor {
  padding: 0;
  width: 100%;
}

.root-agents-summary {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  padding: 1rem 1.15rem;
}

.root-agents-body {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.75rem;
  padding: 1rem 1.15rem 1.15rem;
}

.root-agents-note,
.root-agents-status {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin: 0;
}

.root-agents-input {
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-mono, monospace);
  font-size: 0.82rem;
  line-height: 1.5;
  min-height: min(50vh, 28rem);
  padding: 0.85rem;
  resize: vertical;
  width: 100%;
}

.root-agents-input:focus {
  border-color: var(--accent-line);
  outline: 2px solid color-mix(in srgb, var(--accent) 24%, transparent);
}

.root-agents-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
}

.root-agents-status[data-error] {
  color: var(--danger, #ff9292);
}

.server-config-grid {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.server-config-primary {
  display: grid;
  column-gap: clamp(0.85rem, 2vw, 1.35rem);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, auto));
  row-gap: 0;
}

.server-config-column {
  display: grid;
  grid-row: 1 / span 4;
  grid-template-rows: subgrid;
  min-width: 0;
}

.server-config-column:first-child {
  grid-column: 1;
}

.server-config-column:last-child {
  grid-column: 2;
}

.queue-error {
  color: #ff9292;
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.server-config-column-title {
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  display: flex;
  font-size: 0.82rem;
  font-weight: 650;
  margin: 0;
  min-height: 4.05rem;
  padding: 0.72rem 0.15rem;
}

.server-config-advanced-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.server-config-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  margin-top: 0.85rem;
}

.server-config-actions-note {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.server-config-actions .chip-button[disabled] {
  cursor: default;
  opacity: 0.45;
}

.server-component {
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 0.22rem;
  min-width: 0;
  padding: 0.65rem 0.72rem;
}

.server-account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.server-account .server-component-status {
  overflow-wrap: anywhere;
}

[data-server-accounts] {
  grid-template-columns: minmax(0, 1fr);
}

.server-account-code-row {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.server-account-code {
  flex: 1 1 12rem;
  min-width: 0;
}

.server-account[data-status="failed"] small {
  color: var(--danger, var(--text-soft));
}

.server-config-row {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.28rem 0.75rem;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 4.05rem;
  min-width: 0;
  padding: 0.72rem 0.15rem;
}

.server-config-copy {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

/* Меню всплывает поверх выделенного текста, поэтому подложка должна быть
   плотной: `--surface-2` сама полупрозрачна, и надпись сливалась с выделением. */
.annotation-context-menu {
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--text) 8%, transparent),
    0 0.9rem 2.2rem rgb(0 0 0 / 0.55);
  padding: 0.25rem;
  position: fixed;
  z-index: 90;
}

.annotation-context-menu button {
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius-sm) - 0.15rem);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.42rem 0.7rem;
  text-align: left;
  white-space: nowrap;
}

.annotation-context-menu button:hover,
.annotation-context-menu button:focus-visible {
  background: var(--accent-soft);
  outline: 0;
}

.server-config-switch-control {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 0.62rem;
  grid-template-columns: auto minmax(0, 1fr);
  min-width: 0;
}

.server-config-switch-control .switch-track {
  grid-column: 1;
  grid-row: 1;
}

.server-config-switch-control .switch-text {
  grid-column: 2;
  grid-row: 1;
}

/* Состояние дорожки описано только для `.setting-switch`, поэтому в плитке
   конфигурации тумблер не двигался: пока рядом жил нативный флажок, это было
   незаметно. */
.server-config-toggle input:checked ~ .switch-track {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.server-config-toggle input:checked ~ .switch-track::after {
  background: var(--accent);
  transform: translateX(1.05rem);
}

.server-config-toggle input:focus-visible ~ .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.server-config-toggle input:disabled ~ .switch-track {
  background: color-mix(in srgb, var(--surface-3) 58%, transparent);
  border-color: color-mix(in srgb, var(--line) 70%, transparent);
}

.server-config-toggle input:disabled ~ .switch-track::after {
  background: var(--text-faint);
}

.server-config-row.is-disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.server-config-row.is-disabled .server-config-switch-control {
  cursor: not-allowed;
}

.server-config-toggle .server-config-pending {
  grid-column: 1 / -1;
}

.server-config-automation {
  align-items: start;
  border-bottom: 1px solid var(--line);
  grid-template-columns: minmax(0, 1fr);
}

.server-config-inline-value {
  align-items: center;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  max-width: none;
  padding-left: 2.97rem;
}

.server-config-inline-label {
  color: var(--text-muted) !important;
  font-size: 0.72rem !important;
  line-height: 1.3;
  max-width: none;
  text-align: left;
}

.server-config-number-row {
  align-items: center;
  display: flex;
  gap: 0.42rem;
}

.server-config-number {
  background: color-mix(in srgb, var(--surface-3) 82%, transparent);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--text);
  font-family: var(--font-numeric);
  font-size: 0.78rem;
  min-width: 0;
  padding: 0.3rem 0.42rem;
  width: 4.9rem;
}

.server-config-row > .server-config-number {
  width: min(11rem, 100%);
}

.server-config-number:focus-visible {
  border-color: var(--accent-line);
  outline: 2px solid var(--accent-soft);
}

.server-config-unit,
.server-config-pending {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.server-config-pending {
  color: var(--accent);
}

.server-component-name,
.server-config-name,
.server-config-switch-control .switch-text {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.server-component-status,
.server-config-row strong {
  color: var(--text-faint);
  font-family: var(--font-numeric);
  font-size: 0.73rem;
  font-weight: 600;
}

.server-component[data-enabled] .server-component-status {
  color: #72d8a4;
}

.server-component small {
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1.3;
}

/* Пояснение объясняет, на что влияет настройка; та же строка лежит в title,
   поэтому длинный текст доступен и при наведении. */
.server-config-hint {
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1.35;
  margin-top: 0.12rem;
}

.server-config-toggle > .server-config-hint {
  grid-column: 1 / -1;
  margin-left: 2.97rem;
}

/* Состояние показывает дорожка тумблера; нативный флажок под названием был
   вторым индикатором того же значения. */
.server-config-switch-control > input[type="checkbox"] {
  height: 1px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 1px;
}

.server-config-advanced {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: clip;
}

.server-config-advanced-summary {
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.72rem 0.85rem;
}

.server-config-advanced-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.server-config-advanced-grid {
  display: grid;
  gap: 0 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0 0.7rem 0.65rem;
}

.server-config-advanced-column .server-config-row:last-child {
  border-bottom: 0;
}

/* Автозапуск и перезапуск лежат внизу карточки настроек, отделённые линией от
   плиток: это тоже настройки Hub, только применяются сразу. */
.server-card .server-controls {
  border-top: 1px solid var(--line);
  margin-top: 0.9rem;
  padding-top: 0.85rem;
}

.server-card .trusted-devices-card {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem 1.15rem 1.15rem;
}

/* На странице сервера устройства держат тот же ритм плиток, что компоненты и
   конфигурация; в узкой панели настроек список остаётся простым. */
.server-card .trusted-device-list > .trusted-device-row,
.server-card .trusted-device-archive .trusted-device-row {
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.72rem;
}

html[data-surface="mobile"][data-view="server"] .server-view {
  padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom) + 1rem);
}

html[data-surface="mobile"] .server-content {
  gap: 0.8rem;
  padding: 0.75rem 0.65rem 1rem;
}

html[data-surface="mobile"] .server-overview-grid {
  gap: 0.8rem;
}

html[data-surface="mobile"] .server-health-card,
html[data-surface="mobile"] .server-card {
  border-radius: var(--radius-md);
}

html[data-surface="mobile"] .server-facts {
  gap: 0.55rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-surface="mobile"] .server-component-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-surface="mobile"] .server-config-primary {
  display: flex;
  flex-direction: column;
}

html[data-surface="mobile"] .server-config-column {
  display: flex;
  flex-direction: column;
}

html[data-surface="mobile"] .server-config-advanced-grid {
  grid-template-columns: minmax(0, 1fr);
}

html[data-surface="mobile"] .server-config-advanced-grid {
  gap: 0;
}

html[data-surface="mobile"] .server-config-advanced-column .server-config-row:last-child {
  border-bottom: 1px solid var(--line);
}

html[data-surface="mobile"] .server-config-advanced-column:last-child .server-config-row:last-child {
  border-bottom: 0;
}

html[data-surface="mobile"] .server-config-automation {
  align-items: start;
  grid-template-columns: minmax(0, 1fr);
}

html[data-surface="mobile"] .server-config-inline-value {
  justify-content: flex-start;
  max-width: none;
  padding-left: 2.97rem;
}

html[data-surface="mobile"] .server-config-inline-label {
  max-width: none;
  text-align: left;
}

/* Статистика занимает всю ширину: графики читаются тем лучше, чем шире
   полотно, а колонка по центру оставляла половину экрана пустой. */
.statistics-content {
  display: grid;
  gap: 1.15rem;
  padding: 1.25rem clamp(1rem, 2vw, 1.75rem) 3rem;
  width: 100%;
}

.current-limits-card {
  background: var(--card-bg-open);
  background-color: color-mix(in srgb, var(--bg) 94%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  min-width: 0;
  padding: 18px 22px 20px;
}

.current-limits-head {
  margin-bottom: 16px;
}

.current-limits-head h2 {
  color: #93a6bc;
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin: 0;
  text-transform: uppercase;
}

.current-limits-row {
  align-items: stretch;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding-bottom: 0.08rem;
  scrollbar-width: thin;
}

/* В карточке статистики лимиты делят ширину поровну и переносятся, а не
   уезжают в горизонтальную прокрутку. */
.current-limits-card .current-limits-row {
  display: grid;
  column-gap: 34px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: visible;
}

.current-limit {
  align-items: baseline;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.35rem;
  min-height: 1.9rem;
  padding: 0.36rem 0.62rem;
  white-space: nowrap;
}

.current-limits-card .current-limit {
  align-items: stretch;
  background: none;
  border: 0;
  border-left: 1px solid #222e3d;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  min-width: 0;
  padding: 0 0 0 18px;
  white-space: normal;
}

.current-limit-copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.current-limit-primary {
  align-items: baseline;
  display: flex;
  gap: 14px;
  height: 17px;
  justify-content: space-between;
  min-width: 0;
}

.current-limits-card .current-limit-name {
  color: var(--current-limit-name-color, var(--text-faint));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-limits-card .current-limit-value {
  color: var(--current-limit-value-color, var(--text));
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 500;
}

.current-limits-card .current-limit-reset {
  color: var(--current-limit-reset-color, var(--text-muted));
  font-family: var(--font-numeric);
  font-size: 11px;
  height: 14px;
  line-height: 14px;
  white-space: nowrap;
}

.current-limit-ring {
  align-items: center;
  background: conic-gradient(
    from -90deg,
    var(--current-limit-accent) 0 var(--current-limit-progress),
    var(--current-limit-track, color-mix(in srgb, var(--line-strong) 72%, var(--surface-2))) var(--current-limit-progress) 100%
  );
  border-radius: 50%;
  display: none;
  flex: 0 0 44px;
  height: 44px;
  justify-content: center;
  position: relative;
  width: 44px;
}

.current-limit-ring::after {
  background: color-mix(in srgb, var(--bg) 88%, #131c27);
  border-radius: 50%;
  content: "";
  inset: 4px;
  position: absolute;
}

.current-limit-ring-value {
  color: var(--current-limit-ring-value-color, var(--text));
  font-family: var(--font-numeric);
  font-size: 11px;
  letter-spacing: -0.02em;
  position: relative;
  z-index: 1;
}

.current-limit-bar {
  background: var(--current-limit-track, color-mix(in srgb, var(--line-strong) 72%, var(--surface-2)));
  border-radius: 2px;
  display: block;
  height: 3px;
  overflow: hidden;
}

.current-limit-bar-fill {
  background: var(--current-limit-accent);
  border-radius: inherit;
  display: block;
  height: 100%;
  width: var(--current-limit-progress);
}

.current-limit[data-current-limit-provider="codex"] {
  --current-limit-accent: oklch(0.74 0.11 150);
}

.current-limit[data-current-limit-provider="spark"] {
  --current-limit-accent: oklch(0.72 0.1 195);
}

.current-limit[data-current-limit-provider="claude"] {
  --current-limit-accent: oklch(0.78 0.13 60);
}

.current-limit-name {
  color: var(--text-faint);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.current-limit-value {
  color: var(--text);
  font-family: var(--font-numeric);
  font-size: 0.77rem;
  font-variant-numeric: tabular-nums;
}

.current-limit-reset,
.current-limits-empty {
  color: var(--text-muted);
  font-size: 0.68rem;
}

/* В узкой панели лимиты не помещаются в строку: горизонтальная прокрутка
   превращалась в полосу с кнопками, поэтому здесь они идут списком. */
.current-limits-settings {
  display: grid;
  gap: 14px 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: visible;
  padding-bottom: 14px;
}

.current-limits-settings .current-limit {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 0;
  display: flex;
  flex-direction: row;
  gap: 6px;
  min-height: 0;
  min-width: 0;
  padding: 0;
  white-space: normal;
}

.current-limits-settings .current-limit-copy {
  gap: 4px;
}

.current-limits-settings .current-limit-name {
  font-size: 9px;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-limits-settings .current-limit-ring {
  display: flex;
}

.current-limits-settings .current-limit-value,
.current-limits-settings .current-limit-bar {
  display: none;
}

.statistics-card {
  background: var(--card-bg-open);
  background-color: color-mix(in srgb, var(--bg) 94%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  min-width: 0;
  padding: clamp(1rem, 2.4vw, 1.5rem);
}

.statistics-card-head {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.statistics-preferences-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.comparison-view-control {
  align-items: center;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: max-content minmax(12rem, 22rem);
  justify-content: start;
  margin-bottom: 0.8rem;
  width: min(100%, 30rem);
}

.statistics-card-head h2 {
  color: var(--text);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  margin: 0;
}

.statistics-card-head p,
.statistics-note {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0.32rem 0 0;
}

.limits-head-controls {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.limits-mode-switch {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0.14rem;
}

.limits-mode-switch button {
  background: transparent;
  border: 0;
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  padding: 0.28rem 0.62rem;
  white-space: nowrap;
}

.limits-mode-switch button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.limits-mode-switch button:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
}

.statistics-total {
  color: var(--accent);
  font-family: var(--font-numeric);
  font-size: clamp(1.05rem, 2.3vw, 1.45rem);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.statistics-card .limits-ranges {
  margin-bottom: 1rem;
}

.limits-speed-window-setting {
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: -0.3rem 0 1rem;
  padding: 0.62rem 0.72rem;
}

.statistics-card .limits-chart-wrap {
  position: relative;
}

.usage-bar {
  fill: var(--accent);
  opacity: 0.82;
  outline: none;
  transition: opacity 120ms ease, filter 120ms ease;
}

.usage-chart-svg [data-device-color],
.usage-device-swatch[data-device-color] {
  --usage-device-color: var(--accent);
}

.usage-chart-svg [data-device-color="1"],
.usage-device-swatch[data-device-color="1"] { --usage-device-color: var(--dot-think); }

.usage-chart-svg [data-device-color="2"],
.usage-device-swatch[data-device-color="2"] { --usage-device-color: var(--dot-cache); }

.usage-chart-svg [data-device-color="3"],
.usage-device-swatch[data-device-color="3"] { --usage-device-color: var(--dot-output); }

.usage-chart-svg [data-device-color="4"],
.usage-device-swatch[data-device-color="4"] { --usage-device-color: var(--ok); }

.usage-chart-svg [data-device-color="5"],
.usage-device-swatch[data-device-color="5"] { --usage-device-color: var(--pending); }

.usage-bar-device {
  fill: var(--usage-device-color);
}

.usage-bar-hit {
  fill: transparent;
  outline: none;
}

.usage-bar-group:hover .usage-bar,
.usage-bar-group:focus-within .usage-bar {
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 75%, transparent));
  opacity: 1;
}

.usage-bar:hover,
.usage-bar:focus {
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 75%, transparent));
  opacity: 1;
}

.usage-chart {
  overflow-x: auto;
  scrollbar-width: thin;
}

.usage-axis-day {
  font-size: 9px;
}

.usage-chart-svg .limits-axis-y {
  font-size: 8px;
}

/* Внутри суток расход показывается линией с заливкой, а не столбиками. */
.usage-line {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.usage-area {
  fill: color-mix(in srgb, var(--accent) 18%, transparent);
  stroke: none;
}

.usage-device-area {
  fill: var(--usage-device-color);
  opacity: 0.26;
  stroke: none;
}

.usage-device-line {
  stroke: var(--usage-device-color);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.usage-device-swatch {
  background: var(--usage-device-color);
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  height: 0.55rem;
  margin-right: 0.4rem;
  width: 0.55rem;
}

.usage-dot {
  fill: var(--accent);
  opacity: 0.85;
}

.usage-dot[data-device-color] {
  fill: var(--usage-device-color);
}

.limits-burn-average-segment {
  opacity: 0.72;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
  stroke-width: 1.5;
}

.limits-burn-target-line {
  opacity: 0.68;
  stroke-dasharray: 1 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.limits-burn-target-line.is-off-scale {
  opacity: 0.82;
}

.limits-burn-average-segment.is-preliminary,
.limits-burn-rate-segment.is-preliminary {
  opacity: 0.42;
}

.limits-burn-normal-line {
  opacity: 0.9;
  stroke: var(--pending, #e8bd69);
  stroke-dasharray: 2 4;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.limits-burn-normal-label {
  fill: var(--pending, #e8bd69);
  font-family: var(--font-numeric);
  font-size: 8px;
}

.limits-burn-actual-guide {
  opacity: 0.32;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4.6;
}

.limits-burn-rate-segment {
  stroke-linecap: round;
  stroke-width: 2.8;
}

.limits-burn-rate-segment.is-over-target {
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--danger, #ff7f8d) 45%, transparent));
  stroke: var(--danger, #ff7f8d);
}

.limits-burn-rate-segment.is-safe {
  stroke: var(--ok);
}

.limits-speed-point {
  fill: var(--ok);
}

.limits-speed-point.is-over-target {
  fill: var(--danger, #ff7f8d);
}

.limits-speed-unit {
  fill: var(--text-muted);
  font-size: 8px;
}

.limits-speed-value.is-over-target,
.limits-speed-deviation.is-over-target {
  color: var(--danger, #ff7f8d);
}

.limits-speed-value.is-safe,
.limits-speed-deviation.is-safe {
  color: var(--ok);
}

.limits-speed-note {
  line-height: 1.45;
  margin-top: 0;
}

.limits-speed-summary {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.limits-speed-summary-card {
  background: color-mix(in srgb, var(--surface-2) 86%, transparent);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 0.38rem;
  padding: 0.75rem 0.85rem;
}

.limits-speed-summary-card.is-over-target {
  border-left-color: var(--danger, #ff7f8d);
}

.limits-speed-summary-name {
  color: var(--text-faint);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.limits-speed-summary-rates {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
}

.limits-speed-summary-rates span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.limits-speed-summary-rates strong {
  color: var(--text);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

.limits-speed-summary-status {
  color: var(--ok);
  font-size: 0.78rem;
  font-weight: 650;
}

.limits-speed-summary-card.is-over-target .limits-speed-summary-status {
  color: var(--danger, #ff7f8d);
}

.usage-burn-summary {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  margin-bottom: 0.85rem;
}

.usage-burn-summary-card {
  background: color-mix(in srgb, var(--surface-2) 86%, transparent);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 0.26rem;
  padding: 0.7rem 0.8rem;
}

.usage-burn-summary-card.is-forecast {
  border-left-color: var(--ok);
}

.usage-burn-summary-card.is-muted {
  border-left-color: var(--text-faint);
}

.usage-burn-summary-name-row {
  align-items: center;
  display: flex;
  gap: 0.4rem;
  justify-content: space-between;
  min-width: 0;
}

.usage-burn-summary-name {
  color: var(--text-faint);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.usage-burn-summary-help {
  align-items: center;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text-soft);
  cursor: help;
  display: inline-flex;
  flex: 0 0 auto;
  font: 700 0.66rem/1 var(--font-body);
  height: 1rem;
  justify-content: center;
  padding: 0;
  width: 1rem;
}

.usage-burn-summary-help:hover,
.usage-burn-summary-help:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  outline: none;
}

.usage-burn-summary-value {
  color: var(--text);
  font-family: var(--font-numeric);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.usage-burn-summary-detail {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.comparison-card-head {
  align-items: center;
}

.comparison-head-controls {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.statistics-account-control {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.72rem;
  gap: 0.5rem;
  white-space: nowrap;
}

.statistics-account-control .themed-select {
  min-width: min(15rem, 34vw);
}

.statistics-account-control .themed-select-button {
  min-height: 2rem;
}

.comparison-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.comparison-metric {
  align-items: baseline;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  display: inline-flex;
  font-family: var(--font-numeric);
  font-size: 0.72rem;
  gap: 0.35rem;
  padding: 0.28rem 0.55rem;
}

.comparison-metric strong {
  color: var(--text);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.comparison-api-line {
  opacity: 0.8;
  stroke-width: 1.7;
}

.comparison-local-line {
  fill: none;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--comparison-local) 30%, transparent));
  stroke: var(--comparison-local);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
}

.comparison-deviation-line {
  opacity: 0.82;
  stroke: var(--comparison-deviation);
  stroke-dasharray: 5 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.comparison-cost-line {
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--comparison-cost) 26%, transparent));
  stroke: var(--comparison-cost);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.comparison-cost-axis {
  fill: var(--comparison-cost);
}

.comparison-metric.is-costlier strong {
  color: var(--pending);
}

.comparison-metric.is-cheaper strong {
  color: var(--ok);
}

.comparison-point-local {
  stroke-width: 1.4;
}

.comparison-legend {
  align-items: center;
}

.comparison-legend-static {
  cursor: default;
}

.comparison-legend-static:hover {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
}

.comparison-series-picker {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-chip);
  gap: 0.35rem;
  padding: 0.12rem 0.5rem 0.12rem 0.35rem;
}

.comparison-series-picker .themed-select {
  min-width: min(12rem, 42vw);
}

.comparison-series-picker .themed-select-button {
  background: transparent;
  border-color: transparent;
  border-radius: var(--radius-chip);
  font-size: 0.74rem;
  min-height: 1.55rem;
  padding: 0.12rem 0.38rem;
}

.comparison-series-picker .themed-select-button:hover,
.comparison-series-picker .themed-select[data-open] .themed-select-button {
  background: var(--surface-3);
  border-color: var(--line-strong);
  color: var(--text);
}

.comparison-series-picker > .limits-legend-value {
  white-space: nowrap;
}

html[data-surface="mobile"] .comparison-series-picker {
  max-width: 100%;
}

html[data-surface="mobile"] .comparison-series-picker .themed-select {
  min-width: min(10rem, 48vw);
}

html[data-surface="mobile"] .comparison-series-picker > .limits-legend-value {
  display: none;
}

.comparison-note {
  line-height: 1.45;
  max-width: 52rem;
}

/* День недели — вспомогательная строка под датой. */
.usage-axis-weekday {
  fill: var(--text-faint);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.limits-grid-day {
  opacity: 0.3;
}

.usage-modes {
  margin-bottom: 0.35rem;
}

.settings-section-title {
  color: var(--section-heading-color);
  font-family: var(--section-heading-family);
  font-size: var(--section-heading-size);
  font-weight: var(--section-heading-weight);
  letter-spacing: var(--section-heading-spacing);
  margin: 0 0 0 0.15rem;
  text-transform: var(--section-heading-transform);
}

.compact-options {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.turn-time-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-options > button {
  justify-content: center;
}

details[data-work-log-period-section] {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}

details[data-work-log-period-section] > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  list-style: none;
  padding: 1rem 1.15rem;
}

details[data-work-log-period-section] > summary::-webkit-details-marker {
  display: none;
}

details[data-work-log-period-section] > [data-work-log-task-overview],
details[data-work-log-period-section] > [data-work-log-task-groups] {
  margin-left: 1rem;
  margin-right: 1rem;
}

.period-usage {
  align-items: center;
  display: inline-flex;
  gap: 0.25rem;
}

[data-work-log-claude-work] {
  color: var(--provider-claude);
  font-weight: 650;
}

html[data-surface="mobile"][data-view="statistics"] .statistics-view {
  padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom) + 1rem);
}

html[data-surface="mobile"] .statistics-content {
  gap: 0.8rem;
  padding: 0.75rem 0.65rem 1rem;
}

html[data-surface="mobile"] .current-limits-card {
  border-radius: 14px;
  padding: 14px 14px 16px;
}

.comparison-view-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.comparison-split-view {
  display: grid;
  gap: 1rem;
}

.comparison-split-section {
  min-width: 0;
}

.comparison-split-section > h3 {
  color: var(--text-soft);
  font-family: var(--font-title);
  font-size: 0.78rem;
  font-weight: 650;
  margin: 0 0 0.35rem;
}

.comparison-compact-chart + .comparison-compact-chart {
  margin-top: 0.3rem;
}

.comparison-compact-chart .limits-chart-svg {
  height: 10.5rem;
}

.comparison-analysis-chart .limits-chart-svg {
  height: 14rem;
}

.comparison-analysis-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.comparison-split-svg {
  overflow: visible;
}

.comparison-panel-label,
.comparison-axis-title,
.comparison-correlation-label {
  fill: var(--text-soft);
  font-family: var(--font-numeric);
  font-size: 10px;
}

.comparison-correlation-label {
  fill: var(--text);
  font-weight: 650;
}

.comparison-split-line {
  stroke-linecap: round;
  stroke-linejoin: round;
}

.comparison-regression-line {
  opacity: 0.78;
  stroke: var(--text-soft);
  stroke-dasharray: 5 4;
  stroke-width: 1.4;
}

.comparison-scatter-point {
  opacity: 0.82;
  stroke: var(--surface-1);
  stroke-width: 1.2;
}

.comparison-scatter-point:hover {
  opacity: 1;
  stroke: var(--text);
  stroke-width: 1.8;
}

.comparison-zero-line {
  opacity: 0.78;
  stroke: var(--text-soft);
  stroke-width: 1.2;
}

.comparison-difference-bar {
  opacity: 0.78;
}

.comparison-difference-bar:hover {
  opacity: 1;
}

html[data-surface="mobile"] .current-limits-head {
  margin-bottom: 12px;
}

/* На телефоне лимиты не влезают в строку, поэтому идут сеткой два на два. */
html[data-surface="mobile"] .current-limits-card .current-limits-row {
  column-gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  row-gap: 14px;
}

html[data-surface="mobile"] .current-limits-card .current-limit {
  align-items: center;
  border-left: 0;
  flex-direction: row;
  gap: 8px;
  padding: 0;
}

html[data-surface="mobile"] .current-limit-copy {
  gap: 4px;
}

html[data-surface="mobile"] .current-limits-card .current-limit-name {
  font-size: 10px;
  letter-spacing: 0.06em;
}

html[data-surface="mobile"] .current-limits-card .current-limit-value,
html[data-surface="mobile"] .current-limit-bar {
  display: none;
}

html[data-surface="mobile"] .current-limit-ring {
  display: flex;
}

html[data-surface="mobile"] .current-limits-row {
  scrollbar-width: none;
}

html[data-surface="mobile"] .current-limits-row::-webkit-scrollbar {
  display: none;
}

html[data-surface="mobile"] .statistics-card {
  border-radius: var(--radius-md);
  padding: 0.85rem;
}

html[data-surface="mobile"] .statistics-card-head {
  align-items: stretch;
  flex-direction: column;
  gap: 0.25rem;
}

html[data-surface="mobile"] .page-settings-grid,
html[data-surface="mobile"] .statistics-preferences-grid {
  grid-template-columns: minmax(0, 1fr);
}

html[data-surface="mobile"] .page-settings-grid > .setting-stack:first-child {
  grid-row: auto;
}

html[data-surface="mobile"] .comparison-view-control {
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
}

html[data-surface="mobile"] .comparison-summary {
  justify-content: flex-start;
}

html[data-surface="mobile"] .comparison-analysis-grid {
  grid-template-columns: minmax(0, 1fr);
}

html[data-surface="mobile"] .comparison-head-controls {
  align-items: stretch;
}

html[data-surface="mobile"] .limits-head-controls {
  align-items: stretch;
}

html[data-surface="mobile"] .limits-mode-switch {
  align-self: flex-start;
}

html[data-surface="mobile"] .statistics-account-control {
  justify-content: space-between;
}

html[data-surface="mobile"] .statistics-account-control .themed-select {
  min-width: min(14rem, 68vw);
}

html[data-surface="mobile"] .statistics-total {
  white-space: normal;
}

html[data-surface="mobile"] .settings-panel {
  border-left: 0;
  border-top: 1px solid var(--line-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  bottom: 0;
  max-height: 86dvh;
  top: auto;
  transform: translateY(100%);
  width: 100%;
}

html[data-surface="mobile"] .settings-panel.open {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* ===================================================== trusted browser auth */

.browser-auth {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 15%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 42%),
    rgba(4, 8, 13, 0.94);
  backdrop-filter: blur(18px);
}

.browser-auth[hidden] {
  display: none;
}

.browser-auth-card {
  width: min(100%, 460px);
  padding: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--card-bg-open), var(--bg);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48), 0 0 44px var(--card-glow);
  text-align: center;
}

.browser-auth-mark {
  display: inline-grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 0;
  background: none;
}

.browser-auth-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.browser-auth-kicker {
  margin: 18px 0 5px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.browser-auth-card h1 {
  margin: 0;
  color: var(--text);
  font-size: 27px;
}

.browser-auth-copy,
.browser-auth-note,
.browser-auth-status {
  color: var(--text-muted);
  line-height: 1.5;
}

.browser-auth-copy {
  margin: 14px 0 24px;
}

.browser-auth-form {
  display: grid;
  gap: 16px;
  text-align: left;
}

.browser-auth-form[hidden] {
  display: none;
}

.browser-auth-form label {
  display: grid;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.browser-auth-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  font: inherit;
}

.browser-auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 17%, transparent);
}

.browser-auth-form input[data-browser-auth-code] {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.browser-auth-submit {
  min-height: 48px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  color: var(--button-text, var(--text));
  background: var(--button-bg, var(--accent-soft));
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.browser-auth-submit:disabled {
  cursor: wait;
  opacity: 0.62;
}

.browser-auth-status {
  min-height: 24px;
  margin: 17px 0 0;
  font-size: 13px;
}

.browser-auth-status[data-kind="error"] {
  color: var(--danger, #ff7f8d);
}

.browser-auth-note {
  margin: 15px 0 0;
  font-size: 11px;
}

html[data-browser-auth] {
  overflow: hidden;
}

@media (max-width: 520px) {
  .browser-auth {
    padding: 12px;
  }

  .browser-auth-card {
    padding: 26px 20px;
    border-radius: 20px;
  }
}

/* ============================================ Статистика: две колонки ===
   Лимиты, sync и настройки не зависят от выбранного графика и стоят справа,
   а три полотна больше не идут друг под другом: активна одна страница.
   Неактивные страницы остаются в рамке абсолютом и сохраняют ширину, поэтому
   SVG строится по фактической ширине карточки и не требует перерисовки при
   переключении вкладок. */
.statistics-view {
  margin: 0 auto;
  max-width: min(120rem, 100%);
  width: 100%;
}

.statistics-main {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
}

.statistics-aside {
  align-content: start;
  display: grid;
  gap: 0.85rem;
  min-width: 0;
}

@media (min-width: 1180px) {
  html:not([data-surface="mobile"]) .statistics-content {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) clamp(18rem, 18vw, 22rem);
  }

  /* Правая колонка выше экрана из-за панели статистики, поэтому прокручивается
     сама, а графики остаются на месте. */
  html:not([data-surface="mobile"]) .statistics-aside {
    max-height: calc(100dvh - 5.5rem);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Высота вкладок с нижним отступом и gap основного столбца: карточка
       лимитов начинается на одной линии с активным графиком. */
    padding-top: 3.55rem;
    position: sticky;
    scrollbar-width: none;
    top: 1rem;
  }

  html:not([data-surface="mobile"]) .statistics-aside::-webkit-scrollbar {
    display: none;
    width: 0;
  }
}

.statistics-pager {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}

.statistics-pager::-webkit-scrollbar {
  display: none;
  height: 0;
}

.statistics-pager-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  color: var(--text-muted);
  cursor: pointer;
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.86rem;
  padding: 0.42rem 0.9rem;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  white-space: nowrap;
}

.statistics-pager-tab:hover {
  color: var(--text);
}

.statistics-pager-tab[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 44%, transparent);
  color: var(--text);
}

.statistics-pager-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.statistics-pages {
  min-width: 0;
  position: relative;
}

.statistics-page {
  min-width: 0;
}

.statistics-page:not(.is-active) {
  inset: 0 0 auto;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

/* Управление графиком стоит вертикальным рельсом слева: полотну достаётся вся
   оставшаяся ширина, а страница перестала расти вниз рядами чипов. */
.chart-layout {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 900px) {
  html:not([data-surface="mobile"]) .chart-layout {
    grid-template-columns: clamp(8.5rem, 11vw, 10.5rem) minmax(0, 1fr);
  }
}

.chart-rail {
  display: grid;
  align-content: start;
  gap: 1rem;
  min-width: 0;
}

.chart-rail-group {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.chart-rail-label {
  color: var(--text-faint);
  font-family: var(--font-title);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chart-rail .limits-ranges {
  display: grid;
  gap: 0.3rem;
  grid-template-columns: repeat(auto-fit, minmax(3.4rem, 1fr));
}

@media (min-width: 900px) {
  html:not([data-surface="mobile"]) .chart-rail .limits-ranges {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Периоды короткие, поэтому идут в две колонки: столбец из шести кнопок
     делал рельс выше полотна и оставлял пустоту рядом с графиком. */
  html:not([data-surface="mobile"]) .chart-rail [data-usage-ranges],
  html:not([data-surface="mobile"]) .chart-rail [data-limits-ranges],
  html:not([data-surface="mobile"]) .chart-rail [data-comparison-ranges] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.chart-rail .limits-range {
  text-align: center;
  width: 100%;
}

.chart-rail-account-control,
.chart-rail-account-control .themed-select {
  min-width: 0;
  width: 100%;
}

.chart-main {
  min-width: 0;
}

/* Переключатель периода в расходе по аккаунтам тоже встаёт колонкой: шесть
   широких плиток в ряд занимали всю ширину и ломали ритм страницы. */
html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-periods] {
  grid-template-columns: clamp(9rem, 12vw, 11.5rem) minmax(0, 1fr);
}

html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-period-tabs] {
  align-self: start;
  display: flex;
  flex-direction: column;
  grid-column: 1;
  grid-row: 1;
}

/* Плитка периода в колонке остаётся компактной: название, сумма и ходы.
   Строка качества записей длинная и в узком рельсе занимала три строки —
   она переехала в шапку выбранного периода. */
html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-period-tab] {
  border-left: 0;
  border-top: 1px solid var(--line);
  gap: 0.1rem;
  padding: 0.5rem 0.75rem;
}

html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-period-name] {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}

html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-period-amount] {
  font-size: 0.98rem;
}

html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-period-unit] {
  font-size: 0.66rem;
}

html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-period-turns] {
  font-size: 0.66rem;
}

html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-period-quality] {
  display: none;
}

html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-period-tabs]
  > [data-work-log-account-period-tab]:first-of-type {
  border-top: 0;
}

html:not([data-surface="mobile"]) .statistics-account-panel
  [data-work-log-account-period-body][data-active] {
  align-self: start;
  border-left: 1px solid var(--line-strong);
  border-top: 0;
  grid-column: 2;
  grid-row: 1;
  max-height: min(62vh, 42rem);
  overflow: auto;
}

/* Шапка периода нужна здесь как подпись выбранного столбца рельса. */
html:not([data-surface="mobile"]) .statistics-account-panel [data-work-log-account-period-headline] {
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  padding: 0.55rem 0.9rem;
}

html:not([data-surface="mobile"]) .statistics-account-panel
  [data-work-log-account-period-headline-title] {
  color: var(--text-faint);
  font-family: var(--font-title);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

html:not([data-surface="mobile"]) .statistics-account-panel
  [data-work-log-account-period-headline-quality],
html:not([data-surface="mobile"]) .statistics-account-panel
  [data-work-log-account-period-headline-turns] {
  color: var(--text-faint);
  font-size: 0.68rem;
}

html:not([data-surface="mobile"]) .statistics-account-panel
  [data-work-log-account-period-headline-value] {
  margin-left: auto;
}

.chart-head {
  margin-bottom: 0.7rem;
}

/* В узкой колонке лимиты выстраиваются списком, а не в четыре столбца. */
.statistics-aside .current-limits-card .current-limits-row {
  grid-template-columns: minmax(0, 1fr);
  row-gap: 12px;
}

.statistics-aside .current-limits-card .current-limit {
  border-left: 0;
  gap: 8px;
  padding: 0;
}

.statistics-aside .current-limits-card .current-limit + .current-limit {
  border-top: 1px solid #222e3d;
  padding-top: 12px;
}

.statistics-aside .statistics-preferences-grid {
  grid-template-columns: minmax(0, 1fr);
}
