/* styles.css — Аркадий 2.0: спокойный профессиональный инструмент.
   Тёмная тема по умолчанию, светлая — по переключателю (data-theme="light").
   Три зоны ≥1180px, две 900–1180, нижняя навигация <900. Без внешних ресурсов. */

/* ───────────────────────────── Токены ───────────────────────────── */

:root {
  color-scheme: dark;
  --bg: #0e1116;
  --surface: #151a21;
  --raised: #1c2230;
  --raised-2: #222938;
  --border: #262d3a;
  --border-soft: #1e242e;
  --text: #e8ecf3;
  --text-2: #c3cad6;
  --muted: #98a2b3;
  --faint: #8590a0;
  --accent: #f5a623;
  --accent-ink: #191307;
  --accent-text: #f5a623;
  --focus: #f5a623;
  --accent-soft: rgba(245, 166, 35, 0.12);
  --accent-soft-2: rgba(245, 166, 35, 0.2);
  --success: #35d0ba;
  --success-text: #35d0ba;
  --success-soft: rgba(53, 208, 186, 0.12);
  --danger: #ff5c6c;
  --danger-text: #ff7b88;
  --danger-soft: rgba(255, 92, 108, 0.12);
  --warn: #f0b13c;
  --warn-soft: rgba(240, 177, 60, 0.14);
  --info: #6ea8ff;
  --info-soft: rgba(110, 168, 255, 0.12);
  --owner-bubble: rgba(245, 166, 35, 0.14);
  --owner-border: rgba(245, 166, 35, 0.28);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-3: 0 24px 64px rgba(0, 0, 0, 0.5);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  --sidebar-w: 236px;
  --context-w: 320px;
  --topbar-h: 60px;
  --bottomnav-h: 58px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

[data-theme='light'] {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --raised: #f7f9fc;
  --raised-2: #eef2f7;
  --border: #d9e0ea;
  --border-soft: #e6ebf2;
  --text: #141a23;
  --text-2: #38414f;
  --muted: #5c6878;
  --faint: #616b7a;
  --accent: #f5a623;
  --accent-ink: #22180a;
  --accent-text: #945d00;
  --focus: #a06500;
  --accent-soft: rgba(245, 166, 35, 0.16);
  --accent-soft-2: rgba(245, 166, 35, 0.28);
  --success: #0a7f6f;
  --success-text: #067a69;
  --success-soft: rgba(15, 168, 146, 0.12);
  --danger: #e11d31;
  --danger-text: #b4121f;
  --danger-soft: rgba(225, 29, 49, 0.1);
  --warn: #8f5d00;
  --warn-soft: rgba(196, 132, 0, 0.14);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.1);
  --owner-bubble: rgba(245, 166, 35, 0.16);
  --owner-border: rgba(196, 132, 0, 0.34);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-2: 0 8px 24px rgba(16, 24, 40, 0.1), 0 2px 6px rgba(16, 24, 40, 0.06);
  --shadow-3: 0 24px 64px rgba(16, 24, 40, 0.22);
}

/* ───────────────────────────── База ───────────────────────────── */

/* Skip-link: первая цель Tab — сразу к содержимому, а не 15 остановок по шапке
   (UI/UX-аудит, A11Y-09). Виден только при фокусе. */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--raised-2);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  transition: top 0.12s ease;
}

.skip-link:focus {
  top: 12px;
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
h5,
p {
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

a:hover {
  text-decoration: underline;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

svg.icon {
  flex: 0 0 auto;
  display: block;
}

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

::selection {
  background: var(--accent-soft-2);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.hide {
  display: none !important;
}

/* ───────────────────────────── Каркас ───────────────────────────── */

.app {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  /* Высоту задаёт JS по visualViewport, чтобы мобильная клавиатура не перекрывала
     композер (аудит §5.1, мобильная клавиатура). Фолбэки: 100vh для старых браузеров
     без dvh, 100dvh — когда JS ещё не отработал (CSS-25). */
  height: 100vh;
  height: var(--app-h, 100dvh);
  min-height: 0;
  min-width: 0;
}

/* явные строки: скрытый баннер (display:none) не сдвигает .app-body в auto-строку,
   иначе внизу остаётся пустая 1fr-полоса */
.topbar { grid-row: 1; }
.offline-banner { grid-row: 2; }
.app-body { grid-row: 3; }
.bottom-nav { grid-row: 4; }

[hidden] {
  display: none !important;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 30;
  min-width: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 4px;
  background: none;
  border: 0;
  padding: 4px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  flex: 0 1 auto;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent-soft-2);
}

.brand-name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.1px;
  line-height: 1.15;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.2;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
  background: var(--raised);
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.tick-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}

.tick.is-live .tick-dot {
  background: var(--success);
  box-shadow: 0 0 0 0 var(--success-soft);
  animation: pulse-dot 2.4s ease-out infinite;
}

.tick.is-live {
  color: var(--text-2);
}

.tick.is-paused .tick-dot {
  background: var(--warn);
}

.tick.is-dead .tick-dot {
  background: var(--danger);
}

.tick-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 560;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.mode-pill:hover {
  background: var(--raised-2);
}

.mode-pill .icon {
  width: 15px;
  height: 15px;
}

.mode-pill.is-live {
  color: var(--success-text);
  border-color: rgba(53, 208, 186, 0.3);
  background: var(--success-soft);
}

.mode-pill.is-paused {
  color: var(--warn);
  border-color: rgba(240, 177, 60, 0.35);
  background: var(--warn-soft);
}

[data-theme='light'] .mode-pill.is-live {
  color: var(--success-text);
}

.budget-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--raised);
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}

.budget-chip .budget-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex: 0 0 auto;
}

.budget-chip.tone-ok .budget-dot {
  background: var(--success);
}

.budget-chip.tone-warn .budget-dot {
  background: var(--warn);
}

.budget-chip.tone-danger .budget-dot {
  background: var(--danger);
}

.budget-chip b {
  font-weight: 600;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 6px;
  border-left: 1px solid var(--border-soft);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.icon-btn:hover {
  background: var(--raised);
  color: var(--text);
}

.icon-btn[aria-expanded='true'] {
  background: var(--raised);
  color: var(--text);
}

.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--context-w);
  min-height: 0;
  overflow: hidden;
}

/* ───────────────────────────── Меню ───────────────────────────── */

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  text-align: left;
  width: 100%;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  position: relative;
}

.nav-item:hover {
  background: var(--raised);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--text);
  font-weight: 600;
}

.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-icon {
  color: var(--muted);
  display: grid;
  place-items: center;
}

.nav-item.is-active .nav-icon {
  color: var(--accent-text);
}

.nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.badge-count.is-quiet {
  background: var(--raised-2);
  color: var(--muted);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.llm-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--muted);
}

.llm-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex: 0 0 auto;
}

.llm-dot.is-off {
  background: var(--danger);
}

.llm-line .mono {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ───────────────────────────── Контент ───────────────────────────── */

.view {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.view-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 28px 40px;
}

.view-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.section-head-text {
  flex: 1 1 auto;
  min-width: 0;
}

.section-title {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.2px;
}

.section-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 70ch;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ───────────────────────────── Правая панель ───────────────────────────── */

.context {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 32px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.context-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 15px;
}

.context-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.context-title {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.context-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--border-soft);
}

.context-row:last-child {
  border-bottom: 0;
}

.context-row .k {
  color: var(--muted);
}

.context-row .v {
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.context-big {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 2px 0 8px;
}

.context-big b {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.5px;
}

.context-big span {
  color: var(--muted);
  font-size: 13px;
}

.progress {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--raised-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width 0.4s var(--ease), background 0.2s var(--ease);
}

.progress-fill.tone-warn {
  background: var(--warn);
}

.progress-fill.tone-danger {
  background: var(--danger);
}

.context-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.artifact-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.artifact-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  min-width: 0;
}

.artifact-item:hover {
  background: var(--raised);
  text-decoration: none;
}

.artifact-item .icon {
  color: var(--muted);
}

.artifact-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-size {
  color: var(--faint);
  font-size: 11.5px;
  font-family: var(--mono);
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-2);
  min-width: 0;
}

.queue-item .queue-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-empty {
  color: var(--faint);
  font-size: 12.5px;
  padding: 4px 0;
}

/* ───────────────────────────── Общие компоненты ───────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

.card-sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), opacity 0.15s var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--raised-2);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn .icon {
  width: 17px;
  height: 17px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}

.btn-primary:hover:not(:disabled) {
  background: #ffb63c;
  border-color: #ffb63c;
}

[data-theme='light'] .btn-primary:hover:not(:disabled) {
  background: #ee9c12;
  border-color: #ee9c12;
}

.btn-ghost {
  background: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--raised);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(255, 92, 108, 0.35);
  color: var(--danger-text);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 92, 108, 0.22);
}

.btn-ok {
  background: var(--success-soft);
  border-color: rgba(53, 208, 186, 0.35);
  color: var(--success-text);
}

.btn-ok:hover:not(:disabled) {
  background: rgba(53, 208, 186, 0.2);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  min-height: 22px;
  white-space: nowrap;
}

.badge .icon {
  width: 13px;
  height: 13px;
}

.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.badge-accent {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
}

.badge-ok {
  color: var(--success-text);
  background: var(--success-soft);
  border-color: rgba(53, 208, 186, 0.3);
}

.badge-warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(240, 177, 60, 0.32);
}

.badge-danger {
  color: var(--danger-text);
  background: var(--danger-soft);
  border-color: rgba(255, 92, 108, 0.3);
}

.badge-muted {
  color: var(--muted);
  background: var(--raised);
  border-color: var(--border);
}

[data-theme='light'] .badge-ok {
  border-color: rgba(15, 168, 146, 0.35);
}

[data-theme='light'] .badge-warn {
  border-color: rgba(168, 111, 0, 0.3);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* формы */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  background: var(--bg);
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--border-soft);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--raised-2);
  flex: 0 0 auto;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
  padding: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.switch.is-on {
  background: var(--accent-soft-2);
  border-color: var(--accent);
}

.switch.is-on::after {
  transform: translateX(18px);
  background: var(--accent);
}

/* аватары */
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
  user-select: none;
}

.avatar-assistant {
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent-soft-2);
}

.avatar-owner {
  background: var(--raised-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* скелетоны */
.skeleton-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.sk-line {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--raised) 25%, var(--raised-2) 37%, var(--raised) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

/* пустые состояния */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 46px 24px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-bottom: 4px;
}

.empty-icon .icon {
  width: 22px;
  height: 22px;
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.empty-text {
  font-size: 13.5px;
  max-width: 56ch;
  line-height: 1.55;
}

.empty-state .btn {
  margin-top: 8px;
}

/* спиннер */
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex: 0 0 auto;
}

.spinner-sm {
  width: 13px;
  height: 13px;
  border-width: 1.5px;
}

/* ───────────────────────────── Тосты и модалки ───────────────────────────── */

.toast-root {
  position: fixed;
  right: 20px;
  /* Выше композера: раньше тост накрывал кнопку отправки (аудит Q10). */
  bottom: 104px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--raised-2);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  cursor: pointer;
}

.toast.is-in {
  opacity: 1;
  transform: translateY(0);
}

.toast-icon {
  color: var(--muted);
  margin-top: 1px;
}

.toast-ok {
  border-color: rgba(53, 208, 186, 0.35);
}

.toast-ok .toast-icon {
  color: var(--success-text);
}

.toast-danger {
  border-color: rgba(255, 92, 108, 0.4);
}

.toast-danger .toast-icon {
  color: var(--danger-text);
}

.toast-warn .toast-icon {
  color: var(--warn);
}

.toast-text {
  min-width: 0;
  line-height: 1.45;
}

.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* dvh — чтобы мобильный тулбар не выталкивал модалку за экран (CSS-26);
     overlay не скроллится, скролл внутри .modal-body (CSS-41). */
  padding: 7vh 16px 16px;
  padding: 7dvh 16px 16px;
  background: rgba(5, 8, 12, 0.62);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.16s var(--ease);
  overflow: hidden;
}

[data-theme='light'] .modal-overlay {
  background: rgba(20, 26, 35, 0.4);
}

.modal-overlay.is-in {
  opacity: 1;
}

.modal {
  width: min(640px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  transform: translateY(-6px);
  transition: transform 0.16s var(--ease);
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 900px);
  max-height: min(86dvh, 900px);
  outline: none;
}

.modal-overlay.is-in .modal {
  transform: translateY(0);
}

.modal-sm {
  width: min(460px, 100%);
}

.modal-lg {
  width: min(820px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
}

.modal-title {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.35;
  min-width: 0;
}

.modal-close {
  margin: -2px -6px 0 0;
}

.modal-body {
  padding: 4px 18px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px 18px;
  padding-bottom: max(18px, calc(14px + env(safe-area-inset-bottom, 0px)));
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.modal-text {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.55;
}

.pre {
  overscroll-behavior: contain;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  overflow: auto;
  max-height: 260px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-2);
  margin: 0;
}

.pre .add {
  color: var(--success-text);
}

.pre .del {
  color: var(--danger-text);
}

.pre .meta {
  color: var(--faint);
}

.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 14px;
  font-size: 13.5px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ───────────────────────────── Чат ───────────────────────────── */

.chat-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.chat-top {
  /* Компактная шапка: одна строка вместо двух — переписке достаётся больше высоты
     (просьба владельца 02.11.2026). */
  padding: 8px 28px 6px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: nowrap;
  min-width: 0;
}

.chat-top-title {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.chat-top-title .section-title {
  font-size: 17px;
  line-height: 1.2;
}

.chat-top-title .section-sub {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: none;
}

.chat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 28px 10px;
  /* Без scroll-behavior:smooth: он делал каждое присваивание scrollTop анимацией,
     промежуточные позиции гасили автопрокрутку длинного ответа (02.11.2026). */
}

.chat-list {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 100%;
}

.msg-assistant {
  justify-content: flex-start;
  padding-right: 8%;
}

.msg-owner {
  flex-direction: row-reverse;
  padding-left: 8%;
}

.msg-system {
  justify-content: center;
  padding: 0 8%;
}

.msg-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* Комфортная длина строки: на 1440 пузырь больше не растягивается на ~90 знаков
     (аудит CSS-31); на телефоне ограничение не мешает. */
  max-width: 74ch;
}

.msg-owner .msg-main {
  align-items: flex-end;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--faint);
  padding: 0 2px;
}

.msg-author {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
}

.msg-time {
  font-family: var(--mono);
}

.bubble {
  border-radius: 14px;
  padding: 11px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-1);
}

.msg-owner .bubble {
  background: var(--owner-bubble);
  border-color: var(--owner-border);
  border-bottom-right-radius: 5px;
}

.msg-assistant .bubble {
  border-bottom-left-radius: 5px;
}

.bubble.is-typing::after {
  content: '▍';
  display: inline-block;
  margin-left: 2px;
  color: var(--accent);
  animation: blink 1s steps(2, start) infinite;
}

.msg-system .bubble {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 12.5px;
  border-radius: var(--radius-pill);
  padding: 5px 14px;
  max-width: 640px;
  text-align: center;
  box-shadow: none;
}

.msg-job-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--muted);
  font-size: 11.5px;
  max-width: 100%;
}

.msg-job-chip .icon {
  width: 13px;
  height: 13px;
}

.msg-job-chip:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--raised-2);
}

.msg-artifacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.artifact-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text-2);
  font-size: 12.5px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.artifact-chip .icon {
  width: 15px;
  height: 15px;
  color: var(--success-text);
}

.artifact-chip:hover {
  background: var(--raised-2);
  text-decoration: none;
}

.artifact-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 0 1 auto;
}

/* markdown внутри пузырей */
.md-p {
  margin: 0 0 8px;
}

.md-p:last-child {
  margin-bottom: 0;
}

.md-h {
  margin: 10px 0 6px;
  font-size: 14.5px;
  font-weight: 650;
}

.md-h:first-child {
  margin-top: 0;
}

.bubble ul,
.bubble ol {
  margin: 4px 0 8px;
  padding-left: 22px;
}

.bubble li {
  margin: 3px 0;
}

.bubble li::marker {
  color: var(--muted);
}

.inline-code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--raised-2);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 1px 5px;
}

.md-code {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
}

.md-code code {
  font-family: inherit;
  white-space: pre;
}

.md-link {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft-2);
}

[data-theme='light'] .md-link {
  color: var(--accent-text);
}

/* карточка дела в чате */
.job-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  /* Свёрнутая карточка: одна компактная строка над композером. */
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-1);
}

.job-card.is-expanded {
  padding: 12px 14px;
  gap: 10px;
}

.job-card-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.job-card-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  flex: 0 0 auto;
}

.job-card-icon .icon {
  width: 16px;
  height: 16px;
}

.job-card-toggle {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.job-card-toggle:hover {
  background: var(--raised);
  color: var(--text);
}

.job-card-toggle .icon {
  width: 18px;
  height: 18px;
  transition: transform 0.15s var(--ease);
}

.job-card.is-expanded .job-card-toggle .icon {
  transform: rotate(90deg);
}

.job-card-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.job-card-title-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.job-card-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.job-card.is-expanded .job-card-title {
  white-space: normal;
  overflow-wrap: anywhere;
}

.job-card-meta {
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
  flex: 0 0 auto;
}

.job-card-latest {
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.job-card-wait {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  color: var(--faint);
}

.job-card.is-expanded .job-card-latest {
  display: none;
}

.job-card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.job-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.job-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-text);
  font-size: 12px;
}

.job-live .dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.6s ease-out infinite;
}

.job-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 5px 0;
  min-width: 0;
  font-size: 13px;
}

.step-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--raised);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  flex: 0 0 auto;
  margin-top: 0;
}

.step-icon .icon {
  width: 13px;
  height: 13px;
}

.step.is-ok .step-icon {
  color: var(--success-text);
  border-color: rgba(53, 208, 186, 0.25);
  background: var(--success-soft);
}

.step.is-fail .step-icon {
  color: var(--danger-text);
  border-color: rgba(255, 92, 108, 0.3);
  background: var(--danger-soft);
}

.step.is-running .step-icon {
  color: var(--accent-text);
  border-color: var(--accent-soft-2);
  background: var(--accent-soft);
}

.step-body {
  flex: 1 1 auto;
  min-width: 0;
}

.step-title {
  color: var(--text-2);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.step.is-running .step-title {
  color: var(--text);
}

.step-detail {
  color: var(--faint);
  font-size: 12px;
  margin-top: 1px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.step-cost {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  flex: 0 0 auto;
  padding-top: 2px;
}

.job-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
}

.job-cost {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.job-cost b {
  color: var(--text);
  font-weight: 600;
}

.job-foot .spacer {
  flex: 1 1 auto;
}

/* одобрения в чате */
.chat-approval {
  border: 1px solid rgba(240, 177, 60, 0.35);
  background: var(--warn-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chat-approval-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(240, 177, 60, 0.18);
  color: var(--warn);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.chat-approval-text {
  flex: 1 1 220px;
  min-width: 0;
}

.chat-approval-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.chat-approval-sub {
  overflow-wrap: anywhere;
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

/* пустой чат и подсказки */
.chat-empty {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 6vh 0 20px;
}

.chat-empty-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.chat-empty-mark {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-2);
  color: var(--accent-text);
}

.chat-empty-mark .icon {
  width: 24px;
  height: 24px;
}

.chat-empty-title {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.2px;
}

.chat-empty-text {
  color: var(--muted);
  font-size: 13.5px;
  max-width: 52ch;
  line-height: 1.55;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.suggestion-chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.suggestion-chip:hover {
  background: var(--raised);
  border-color: var(--accent-soft-2);
  color: var(--text);
}

/* композер */
.composer-wrap {
  padding: 8px 28px 10px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg);
}

.composer-inner {
  max-width: 980px;
  margin: 0 auto;
}

.composer-approvals {
  margin-bottom: 10px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 14px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.composer:focus-within {
  border-color: var(--accent-soft-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  resize: none;
  max-height: 180px;
  min-height: 24px;
  padding: 7px 0;
  font-size: 14.5px;
  line-height: 1.45;
  outline: none;
  color: var(--text);
}

.composer textarea::placeholder {
  color: var(--faint);
}

.composer-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: filter 0.15s var(--ease), opacity 0.15s var(--ease);
}

.composer-send .icon {
  width: 18px;
  height: 18px;
}

.composer-send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.composer-send:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Вложения в чате (план 2.1): скрепка, чипы над полем ввода, drag&drop */
.composer-attach {
  width: 34px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  flex: 0 0 auto;
  cursor: pointer;
}

.composer-attach:hover {
  color: var(--text);
  background: var(--raised);
}

.composer-attach .icon {
  width: 18px;
  height: 18px;
}

.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 8px 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text-2);
  font-size: 12.5px;
}

.attach-chip .icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--accent);
}

.attach-chip.is-loading {
  opacity: 0.65;
}

.attach-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-size {
  color: var(--faint);
  font-size: 11.5px;
  flex: 0 0 auto;
}

.attach-remove {
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--faint);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.attach-remove:hover {
  color: var(--danger-text);
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.attach-chip.is-static:hover {
  border-color: var(--accent-soft-2);
}

.chat-view.is-dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
  border-radius: 12px;
}

.composer-hint {
  margin-top: 5px;
  padding: 0 4px;
  font-size: 11px;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* .composer-suggestions удалён: блок подсказок над полем съедал место, а в пустом
   чате те же подсказки уже показаны крупно (просьба владельца 02.11.2026). */

/* ───────────────────────────── Лента ───────────────────────────── */

.feed-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 22px;
}

.feed-list::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: var(--border);
}

.feed-item {
  position: relative;
}

.feed-dot {
  position: absolute;
  left: -22px;
  top: 24px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  transform: translateX(0.5px);
}

.feed-item.tone-accent .feed-dot {
  border-color: var(--accent);
}

.feed-item.tone-warn .feed-dot {
  border-color: var(--warn);
}

.feed-item.tone-muted .feed-dot {
  border-color: var(--faint);
}

.feed-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s var(--ease);
}

.feed-item.is-unread .feed-card {
  border-color: var(--border);
  box-shadow: inset 3px 0 0 var(--accent);
}

.feed-card:hover {
  background: var(--raised);
  border-color: var(--border);
}

.feed-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.feed-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.4;
  flex: 1 1 auto;
  min-width: 0;
}

.feed-text {
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-line;
}

.feed-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--faint);
  font-size: 12px;
}

.feed-foot .mono {
  font-family: var(--mono);
}

.feed-why-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0;
  border-radius: 6px;
}

.feed-why-toggle:hover {
  color: var(--text);
}

.feed-why-toggle .icon {
  width: 14px;
  height: 14px;
  transition: transform 0.15s var(--ease);
}

.feed-why-toggle[aria-expanded='true'] .icon {
  transform: rotate(90deg);
}

.feed-why {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.why-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--muted);
}

.why-mark {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--raised);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  flex: 0 0 auto;
}

.why-mark .icon {
  width: 12px;
  height: 12px;
}

.why-text {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.why-text b {
  color: var(--text-2);
  font-weight: 600;
}

.why-chain {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ───────────────────────────── Дела ───────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
}

.filter-chip {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.filter-chip:hover {
  color: var(--text);
}

.filter-chip.is-active {
  background: var(--raised-2);
  color: var(--text);
  font-weight: 600;
}

.filter-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  margin-left: 4px;
}

.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.job-row {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.job-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  min-width: 0;
}

.job-row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.job-row-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.job-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 3px;
  color: var(--faint);
  font-size: 11.5px;
}

.job-row-meta .mono {
  font-family: var(--mono);
}

.job-row-cost {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  flex: 0 0 auto;
}

.job-expand {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.job-expand:hover {
  background: var(--raised);
  color: var(--text);
}

.job-expand .icon {
  width: 16px;
  height: 16px;
  transition: transform 0.15s var(--ease);
}

.job-expand[aria-expanded='true'] .icon {
  transform: rotate(90deg);
}

.job-row-body {
  border-top: 1px solid var(--border-soft);
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.job-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.job-result-text {
  font-size: 13px;
  color: var(--text-2);
  white-space: pre-line;
  line-height: 1.55;
}

/* ───────────────────────────── Память ───────────────────────────── */

.memory-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}

.search-box .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.search-box .input {
  padding-left: 34px;
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 12px;
}

.fact-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.fact-head {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.fact-key {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fact-delete {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--faint);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.15s var(--ease), color 0.15s var(--ease), background 0.15s var(--ease);
}

.fact-card:hover .fact-delete,
.fact-delete:focus-visible {
  opacity: 1;
}

.fact-delete:hover {
  color: var(--danger-text);
  background: var(--danger-soft);
}

.fact-delete .icon {
  width: 14px;
  height: 14px;
}

.fact-value {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
}

.fact-foot {
  display: flex;
  align-items: center;
  gap: 6px 10px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}

.fact-date {
  color: var(--faint);
  font-size: 11.5px;
  font-family: var(--mono);
}

.confidence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
}

.confidence-bar {
  width: 34px;
  height: 4px;
  border-radius: 3px;
  background: var(--raised-2);
  overflow: hidden;
}

.confidence-bar i {
  display: block;
  height: 100%;
  background: var(--success);
}

.add-fact {
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.add-fact-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.add-fact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 170px auto;
  gap: 10px;
  align-items: end;
}

.subsection-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.subsection-title {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.episodes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.episode {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text-2);
  align-items: baseline;
  flex-wrap: wrap;
}

.episode time {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11.5px;
  flex: 0 0 auto;
}

.episode-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tag {
  font-size: 11px;
  color: var(--muted);
  background: var(--raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
}

.memory-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--faint);
  font-size: 12px;
}

/* ───────────────────────────── Контроль ───────────────────────────── */

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 12px;
}

.control-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.control-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.control-card-title {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.budget-big {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.budget-big b {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -1px;
  line-height: 1.1;
}

.budget-big span {
  color: var(--muted);
  font-size: 13px;
}

.budget-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  font-size: 12.5px;
}

.budget-meta div {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: var(--muted);
}

.budget-meta .mono {
  color: var(--text-2);
}

.mode-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}

.toggle-row:last-child {
  border-bottom: 0;
}

.toggle-row .label {
  font-size: 13.5px;
  color: var(--text-2);
}

.toggle-row .hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.approvals-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.approval-card {
  border: 1px solid rgba(240, 177, 60, 0.32);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.approval-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.approval-tool {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px 8px;
}

.approval-title {
  font-size: 13.5px;
  color: var(--text-2);
  flex: 1 1 auto;
  min-width: 0;
}

.approval-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.approval-args {
  overscroll-behavior: contain;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 120px;
  overflow: auto;
  margin: 0;
}

.control-empty-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  padding: 2px 0 4px;
  border: 0;
  background: none;
}

.events-wrap {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.events-scroll {
  overflow-x: auto;
}

.events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 640px;
}

.events-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--raised);
}

.events-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-2);
  vertical-align: top;
}

.events-table tr:last-child td {
  border-bottom: 0;
}

.events-table tr:hover td {
  background: var(--raised);
}

.events-table .cell-time {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.events-table .cell-source {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.events-table .cell-kind {
  color: var(--text);
  font-weight: 560;
}

.events-table .cell-reason {
  color: var(--muted);
  max-width: 320px;
}

.events-table .cell-decision {
  white-space: nowrap;
}

/* ───────────────────────────── Возможности ───────────────────────────── */

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr));
  gap: 12px;
}

.skill-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.skill-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.skill-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--raised);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  flex: 0 0 auto;
}

.skill-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  flex: 1 1 auto;
  min-width: 0;
}

.skill-name {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  flex: 1 1 auto;
}

.skill-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.risk-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.risk-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}

.risk-legend-text {
  white-space: normal;
}

.skill-risk-hint {
  color: var(--faint);
  font-size: 12px;
  min-width: 0;
}

/* ───────────────────────────── Настройки ───────────────────────────── */

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 820px;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.settings-card-title {
  font-size: 15px;
  font-weight: 650;
}

.settings-card-sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-actions .saved-note {
  color: var(--success-text);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.settings-actions .saved-note .icon {
  width: 14px;
  height: 14px;
}

.principles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.principle-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.principle-num {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--raised);
  border: 1px solid var(--border-soft);
  color: var(--faint);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  flex: 0 0 auto;
}

.folder-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
  min-width: 0;
}

.folder-item .folder-path {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-item .icon-btn {
  width: 28px;
  height: 28px;
}

.folder-add {
  display: flex;
  gap: 8px;
}

.hint-box {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 13px;
  border-radius: 10px;
  background: var(--info-soft);
  border: 1px solid rgba(110, 168, 255, 0.25);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.5;
}

.hint-box .icon {
  color: var(--info);
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.theme-choice {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
}

.theme-choice button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.theme-choice button .icon {
  width: 15px;
  height: 15px;
}

.theme-choice button.is-active {
  background: var(--raised-2);
  color: var(--text);
}

/* ───────────────────────────── Баннер связи и навигация ───────────────────────────── */

.offline-banner {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  background: var(--danger-soft);
  border-bottom: 1px solid rgba(255, 92, 108, 0.35);
  color: var(--text);
  font-size: 13px;
  z-index: 25;
}

.offline-banner.is-visible {
  display: flex;
}

.offline-banner .icon {
  color: var(--danger-text);
}

.offline-banner .retry-link {
  margin-left: auto;
  background: none;
  border: 1px solid rgba(255, 92, 108, 0.4);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 10px;
  min-height: 24px;
  font-size: 12px;
}

.bottom-nav {
  display: none;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 40;
}

.bottom-nav-inner {
  display: flex;
  height: var(--bottomnav-h);
}

.bottom-nav-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  padding: 4px 2px;
  position: relative;
  min-width: 0;
}

.bottom-nav-item .nav-icon {
  position: relative;
}

.bottom-nav-item.is-active {
  color: var(--accent-text);
}

.bottom-nav-item.is-active .nav-icon {
  color: var(--accent-text);
}

.bottom-nav-badge {
  position: absolute;
  top: -5px;
  right: -9px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.55);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s var(--ease);
}

.drawer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 84vw);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 95;
  transform: translateX(-100%);
  transition: transform 0.2s var(--ease);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 12px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 10px;
}

.drawer-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ───────────────────────────── Анимации ───────────────────────────── */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes pulse-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(53, 208, 186, 0.45);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(53, 208, 186, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(53, 208, 186, 0);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fade-in 0.18s var(--ease);
}

/* ───────────────────────────── Календарь ───────────────────────────── */

.cal-card {
  padding: 16px 18px 18px;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}

.cal-title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.2px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-nav-btn .icon {
  width: 18px;
  height: 18px;
}

.cal-prev .icon {
  transform: rotate(180deg);
}

.cal-today {
  flex: 0 0 auto;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 4px;
}

.cal-weekday {
  min-width: 0;
  padding: 2px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

/* Скелетон и полноэкранная ошибка занимают всю ширину сетки. */
.cal-grid-full,
.cal-skeleton {
  grid-column: 1 / -1;
}

.cal-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

/* Ячейка дня — кнопка: клик выбирает день, с клавиатуры работают стрелки. */
.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  min-width: 0;
  min-height: 64px;
  padding: 5px 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  overflow: hidden;
}

.cal-day:hover {
  background: var(--raised);
  border-color: var(--border-soft);
}

.cal-day.is-outside {
  background: transparent;
  color: var(--faint);
}

.cal-day.is-today {
  border-color: var(--accent-soft-2);
}

.cal-day.is-selected,
.cal-day.is-selected:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.cal-day-num {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  font-size: 12.5px;
  font-weight: 560;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.cal-day.is-today .cal-day-num {
  font-weight: 700;
}

.cal-day.is-today .cal-day-num::after {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-text);
}

.cal-chips {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cal-chip {
  display: block;
  max-width: 100%;
  padding: 1px 4px;
  border-left: 2px solid var(--accent);
  border-radius: 4px;
  /* Фон непрозрачный: полупрозрачный чип на подсвеченном дне теряет контраст,
     а скринридеру и печати спокойнее с ровным фоном. */
  background: var(--raised-2);
  color: var(--text-2);
  font-size: 10px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-chip.is-allday {
  border-left-color: var(--success);
}

.cal-more {
  padding-left: 2px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

/* Полоса ошибки: старые данные остаются на экране, рядом — «Повторить». */
.cal-error {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid rgba(255, 92, 108, 0.38);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--text);
  font-size: 13px;
}

.cal-error .icon {
  color: var(--danger-text);
}

.cal-error-text {
  flex: 1 1 auto;
  min-width: 180px;
}

/* ── выбранный день ── */

.cal-day-panel {
  padding: 16px 18px 18px;
}

.cal-day-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.cal-day-head-text {
  flex: 1 1 0;
  min-width: 0;
}

.cal-day-title {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.3;
}

.cal-day-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

.cal-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cal-event {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--raised);
  color: var(--text);
  text-align: left;
}

.cal-event:hover {
  background: var(--raised-2);
  border-color: var(--border-soft);
}

.cal-event-time,
.cal-reminder-time {
  flex: 0 0 auto;
  min-width: 72px;
  padding-top: 1px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.cal-event-main,
.cal-reminder-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
}

.cal-event-title {
  font-size: 13.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cal-event-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.cal-event-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.cal-event-meta-item .icon {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}

.cal-event-notes {
  color: var(--muted);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.cal-event-go {
  align-self: center;
  color: var(--faint);
}

.cal-event-go .icon {
  width: 16px;
  height: 16px;
}

.cal-reminder {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-2);
}

.cal-reminder-main {
  gap: 5px;
}

.cal-reminder-text {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.cal-reminder-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Пустой день: пустое состояние без «карточки в карточке». */
.cal-day-empty .empty-state {
  border: 0;
  background: transparent;
  padding: 16px 8px 8px;
}

/* ── форма события ── */

.cal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cal-field-wide {
  grid-column: 1 / -1;
}

.cal-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}

.cal-check:hover {
  border-color: var(--border-soft);
}

.cal-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.cal-form .input:disabled,
.cal-form .select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.cal-delete {
  margin-right: auto;
}

.cal-confirm-text {
  align-self: center;
  margin-right: auto;
  color: var(--text-2);
  font-size: 13.5px;
}

.cal-ics-help {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cal-ics-help .field {
  margin-top: 4px;
}

/* ── адаптив календаря (390 px — без горизонтального скролла) ── */

@media (max-width: 899px) {
  .cal-card,
  .cal-day-panel {
    padding: 14px 14px 16px;
  }

  .cal-day {
    min-height: 60px;
    padding: 4px 3px;
  }

  .cal-grid,
  .cal-weekdays {
    gap: 3px;
  }

  .cal-event-time,
  .cal-reminder-time {
    min-width: 66px;
  }
}

@media (max-width: 520px) {
  .cal-card {
    padding: 12px 10px 14px;
  }

  .cal-day-panel {
    padding: 14px 12px 16px;
  }

  .cal-day {
    gap: 2px;
    min-height: 52px;
    padding: 4px 3px;
  }

  .cal-day-num {
    font-size: 12px;
  }

  .cal-weekday {
    font-size: 10px;
    letter-spacing: 0.03em;
  }

  .cal-chip {
    padding: 1px 3px;
    font-size: 9px;
  }

  .cal-more {
    font-size: 9px;
  }

  .cal-title {
    font-size: 16px;
  }

  .cal-event,
  .cal-reminder {
    gap: 9px;
    padding: 9px 10px;
  }

  .cal-event-time,
  .cal-reminder-time {
    min-width: 60px;
    font-size: 11.5px;
  }

  .cal-day-title {
    font-size: 15px;
  }

  .cal-day-empty .empty-state {
    padding: 12px 4px 6px;
  }
}

@media (max-width: 380px) {
  .cal-day {
    min-height: 50px;
  }

  .cal-chip {
    font-size: 8.5px;
  }
}

/* ───────────────────────────── Адаптивность ───────────────────────────── */

@media (max-width: 1399px) {
  :root {
    --context-w: 300px;
    --sidebar-w: 224px;
  }
}

@media (max-width: 1179px) {
  .app-body {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .context {
    display: none;
  }
}

@media (max-width: 899px) {
  .app-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .bottom-nav {
    display: block;
  }

  .topbar {
    padding: 0 12px;
    gap: 8px;
    min-width: 0;
  }

  .topbar-brand {
    flex: 0 1 auto;
    min-width: 0;
  }

  .topbar-right {
    flex: 0 1 auto;
    min-width: 0;
  }

  .brand-sub {
    display: none;
  }

  .brand-name {
    font-size: 15px;
  }

  .topbar-brand {
    margin-right: 0;
  }

  .tick {
    padding: 5px 9px;
    font-size: 11.5px;
  }

  .tick-full {
    display: none;
  }

  .budget-chip {
    padding: 5px 9px;
    font-size: 11.5px;
  }

  .budget-chip .budget-limit {
    display: none;
  }

  .mode-pill {
    padding: 6px 9px;
    font-size: 12px;
  }

  .mode-pill .mode-label {
    display: none;
  }

  .topbar-actions {
    padding-left: 2px;
  }

  .view-scroll {
    padding: 16px 16px 32px;
  }

  .chat-top {
    padding: 8px 16px 6px;
  }

  .chat-scroll {
    padding: 14px 16px 8px;
  }

  .composer-wrap {
    padding: 8px 12px 10px;
  }

  /* На телефоне подсказка про Enter не нужна, а занимает две строки —
     высвобождаем их под переписку (просьба владельца: больше текста). */
  .composer-hint {
    display: none;
  }

  .msg-assistant {
    padding-right: 0;
  }

  .msg-owner {
    padding-left: 0;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .add-fact-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .toast-root {
    right: 12px;
    left: 12px;
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + 84px);
    max-width: none;
  }

  .modal-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .modal {
    max-height: 88vh;
  }
}

@media (max-width: 560px) {
  /* На узких телефонах счётчик проверки в шапке не помещается — скрываем раньше,
     чем 520 px, иначе на 521–560 px страница уезжает вбок (аудит P1-1). */
  .tick {
    display: none;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 14.5px;
  }

  .section-title {
    font-size: 20px;
  }

  .theme-btn {
    display: none;
  }

  .chat-empty {
    padding-top: 3vh;
  }

  .chat-empty-title {
    font-size: 18px;
  }

  .job-row-head {
    padding: 11px 12px;
    gap: 9px;
  }

  .job-row-body {
    padding: 10px 12px 12px;
  }

  .card {
    padding: 15px 16px;
  }

  .settings-card {
    padding: 15px 16px;
  }

  .feed-list {
    padding-left: 16px;
  }

  .feed-dot {
    left: -16px;
  }

  /* Линия должна совпадать с центрами точек: точки 11 px начинаются на x=0
     от padding-left 16 → центр ≈5.5 px (аудит CSS-29). */
  .feed-list::before {
    left: 5px;
  }

  .control-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal-foot {
    padding: 12px 14px 14px;
  }

  .modal-head {
    padding: 14px 14px 8px;
  }

  .modal-body {
    padding: 2px 14px 10px;
  }
}

/* Телефоны: убираем из шапки второстепенное, чтобы не было горизонтального скролла
   (аудит P1-1: 320–430 px уезжали вбок на 111–181 px). */
@media (max-width: 520px) {
  .topbar {
    padding: 0 8px;
    gap: 6px;
  }

  .tick {
    display: none;
  }

  .bottom-nav-inner {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
  }

  .nav-item .nav-label {
    font-size: 10.5px;
  }

  /* На телефоне метаданные карточки дела уступают место заголовку: строка и так
     плотная, а прогресс видно по последнему шагу. */
  .job-card-meta {
    display: none;
  }

  .job-card-title {
    font-size: 13px;
  }

  .job-card-latest {
    max-width: 100%;
  }

  /* Название раздела уже в шапке; подзаголовок на 320–430 px занимает 3–4 строки
     (аудит CSS-48). */
  .chat-top .section-sub {
    display: none;
  }
}

@media (max-width: 380px) {
  .budget-chip {
    display: none;
  }

  .brand-name {
    font-size: 14px;
  }
}

/* Ландшафт телефона: делим высоту иначе, чем на десктопе (аудит §5.1). */
@media (max-height: 480px) and (max-width: 900px) {
  .chat-top {
    display: none;
  }

  .composer-hint {
    display: none;
  }

  .chat-scroll {
    padding-top: 8px;
  }
}

/* ───────────────────────────── Reduced motion ───────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .tick.is-live .tick-dot,
  .job-live .dot-pulse,
  .bubble.is-typing::after {
    animation: none !important;
  }
}

/* ───────────────────────────── Дополнения компонентов ───────────────────────────── */

.hide-desktop {
  display: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

/* Раньше здесь стоял display:block и для .brand-sub — он перебивал мобильное
   правило скрытия, шапка раздувалась до 491 px и телефон уезжал вбок (аудит P1-1). */
.brand-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.brand-sub {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 899px) {
  .topbar .brand-sub {
    display: none;
  }

  /* На тач-экранах основные кнопки делаем 44×44 (аудит CSS-24): иконка остаётся
     прежней, увеличивается только зона нажатия. */
  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .composer-send,
  .composer-attach {
    width: 44px;
    height: 44px;
  }

  .attach-remove,
  .fact-delete,
  .chat-error-close {
    width: 32px;
    height: 32px;
  }

  .job-expand {
    width: 36px;
    height: 36px;
  }
}

.page-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.toolbar-spacer {
  flex: 1 1 auto;
}

.chat-jobcards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-skeleton {
  max-width: 640px;
}

.msg-extras {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.msg-owner .msg-extras {
  align-items: flex-end;
}

.msg-extras-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.msg-owner .msg-extras-foot {
  justify-content: flex-end;
}

.step-title {
  display: block;
}

.chat-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 92, 108, 0.38);
  background: var(--danger-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.chat-error .icon {
  color: var(--danger-text);
  margin-top: 1px;
}

.chat-error-text {
  flex: 1 1 auto;
  min-width: 0;
}

.chat-error-close {
  width: 28px;
  height: 28px;
  margin: -3px -4px 0 0;
}

.feed-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-time {
  margin-left: auto;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

.why-foot {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  padding-left: 30px;
}

.job-steps-title {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

.job-loading {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
}

.job-error {
  color: var(--danger-text);
  background: var(--danger-soft);
  border: 1px solid rgba(255, 92, 108, 0.3);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
}

.job-goal {
  color: var(--muted);
  font-size: 12.5px;
}

.job-row-main {
  cursor: pointer;
}

.job-row-main:hover .job-row-title {
  color: var(--accent-text);
}

.job-row-body .job-steps {
  margin-top: 2px;
}

.memory-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.memory-layers {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ── Память: разделы «Факты / Вещи / Квитанции» ── */

.memory-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.memory-tabs::-webkit-scrollbar {
  display: none;
}

.memory-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 8px 13px 9px;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: color 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.memory-tab .icon {
  width: 16px;
  height: 16px;
}

.memory-tab:hover {
  color: var(--text-2);
  background: var(--raised);
}

.memory-tab.is-active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
}

.memory-tab:focus-visible {
  outline-offset: -2px;
}

.memory-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.memory-toolbar[hidden] {
  display: none;
}

/* ── Вещи ── */

.things-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 12px;
}

.thing-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.thing-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.thing-name {
  font-size: 15px;
  font-weight: 620;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.thing-meta {
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.thing-dates {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thing-date {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-2);
}

.thing-date .icon {
  width: 14px;
  height: 14px;
  color: var(--faint);
}

.thing-date-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.thing-note {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-2);
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.thing-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}

.btn.thing-retire {
  color: var(--danger-text);
}

.btn.thing-retire:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: rgba(255, 92, 108, 0.35);
}

[data-theme='light'] .btn.thing-retire:hover:not(:disabled) {
  border-color: rgba(225, 29, 49, 0.3);
}

.thing-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 10px;
  align-items: start;
}

.thing-form .field-full {
  grid-column: 1 / -1;
}

/* ── Квитанции ── */

.receipts-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
}

.receipts-month {
  flex: 0 1 240px;
  min-width: 160px;
}

.receipts-total {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-left: auto;
}

.receipts-total-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.receipts-total-value {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.receipts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.receipt-card {
  display: flex;
  align-items: center;
  gap: 12px 14px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 0;
}

.receipt-main {
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.receipt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.receipt-vendor {
  font-size: 14.5px;
  font-weight: 620;
  overflow-wrap: anywhere;
}

.receipt-meta {
  display: flex;
  align-items: center;
  gap: 6px 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.receipt-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.receipt-meta .icon {
  width: 13px;
  height: 13px;
  color: var(--faint);
}

.receipt-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.receipt-sum {
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
}

.receipt-file {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 200px;
  font-size: 12.5px;
  color: var(--accent-text);
}

.receipt-file .icon {
  width: 14px;
  height: 14px;
}

.receipt-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receipt-file.is-plain {
  color: var(--muted);
}

.receipt-delete {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--faint);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.receipt-delete .icon {
  width: 15px;
  height: 15px;
}

.receipt-delete:hover {
  color: var(--danger-text);
  background: var(--danger-soft);
}

@media (max-width: 520px) {
  .memory-tab {
    padding: 8px 10px 9px;
    font-size: 13px;
  }

  .receipts-month {
    flex: 1 1 100%;
  }

  .receipts-total {
    margin-left: 0;
  }

  .receipts-total-value {
    font-size: 22px;
  }

  .receipt-card {
    padding: 11px 12px;
  }

  .receipt-side {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .thing-actions .btn {
    flex: 1 1 auto;
  }
}

.approval-modal {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.approval-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.approval-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.approval-block-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}

.skill-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

@media (hover: none) {
  .fact-delete {
    opacity: 1;
  }
}

@media (max-width: 899px) {
  .hide-desktop {
    display: inline-grid;
  }
}

/* ── Состояния нажатия и недоступности (аудит CSS-20/40) ── */
.btn:active:not(:disabled),
.icon-btn:active:not(:disabled),
.nav-item:active,
.bottom-nav-item:active,
.composer-send:active:not(:disabled),
.composer-attach:active:not(:disabled),
.filter-chip:active {
  transform: translateY(1px);
  filter: brightness(0.96);
}

.switch:disabled,
.filter-chip:disabled,
.theme-choice button:disabled,
.icon-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn[aria-busy='true'] {
  min-width: 7.5em;
}

/* ── Режим «просто» для копий участников (§22 плана) ─────────────────────
   Кредиты вместо рублей, без модели и технического пульта. Включается
   классом ui-simple на <body>, когда сервер отдаёт ui_mode = simple. */
body.ui-simple .budget-limit { display: none; }
body.ui-simple .sidebar-foot .llm-line:first-child { display: none; }
body.ui-simple .nav-item[data-route="control"] { display: none; }
body.ui-simple .risk-badge,
body.ui-simple .approval-risk { display: none; }
body.ui-simple .context-big > span { display: none; }
body.ui-simple #ctx-wakes { display: none; }
body.ui-simple .nav-item[data-route="control"] { display: none !important; }
/* В режиме участника не показываем служебную телеметрию: проверки, режим, инициативу */
body.ui-simple #tick,
body.ui-simple #mode-pill { display: none; }

/* Живая строка «что делаю сейчас» в чате (участник беты, §22.1) */
.chat-activity {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px 2px;
  font-size: 13px;
  color: var(--muted, #9aa3b2);
}
.chat-activity[hidden] { display: none; }
.chat-activity .dot-pulse { flex: 0 0 auto; }

/* «Что умею» для участника беты: группы по-человечески */
.skills-sections { display: flex; flex-direction: column; gap: 22px; }
.skills-section-title { font-size: 15px; font-weight: 600; color: var(--text-soft, #c3c9d6); margin: 0 0 10px; }


/* Соучастие: реакции на карточки и настройки «Что мне подсказывать» (§24.9) */
.feed-reactions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.feed-reaction-done { font-size: 13px; color: var(--text-soft, #c3c9d6); }
.suggest-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.suggest-check { width: 18px; height: 18px; accent-color: var(--accent, #6b8afd); }
.suggest-title { font-size: 14px; }
.interest-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.interest-title { font-weight: 600; }
.interest-meta { color: var(--text-soft, #9aa3b5); font-size: 13px; margin-right: auto; }


/* Голосовая запись в композере */
.composer-mic {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-soft, #9aa3b5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.composer-mic:hover:not(:disabled) { color: var(--accent, #6b8afd); border-color: var(--accent, #6b8afd); }
.composer-mic.is-recording { color: #ff6b6b; border-color: #ff6b6b; animation: mic-pulse 1.2s infinite; }
.composer-mic.is-busy { opacity: 0.6; cursor: wait; }
.composer-mic .icon { width: 18px; height: 18px; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.35); } 50% { box-shadow: 0 0 0 5px rgba(255, 107, 107, 0); } }


/* Пометка голосового сообщения в чате */
.msg-voice { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-soft, #9aa3b5); margin-left: 2px; }
.msg-voice .icon { width: 12px; height: 12px; }


/* Ошибка в окне входа */
.login-error { color: #ff8a8a; }


/* Плашка «установить как приложение» */
.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface, #171c25);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.install-banner-text { font-size: 13px; margin-right: auto; }
