/* ────────────────────────────────────────────────────────────
   Helm — design system
   Calm operator console with editorial nautical texture.
   Type:  Inter (UI) · Fraunces italic (editorial) · JetBrains Mono (numbers)
   ──────────────────────────────────────────────────────────── */

:root,
:root[data-theme="dark"] {
  /* Surfaces */
  --bg:        #0a0e1a;
  --bg2:       #0f1525;
  --surface:   #141a2e;
  --surface2:  #1a2240;
  --surface3:  #232c4f;
  --border:    rgba(255,255,255,0.06);
  --border2:   rgba(255,255,255,0.10);
  --border3:   rgba(255,255,255,0.18);

  /* Brand */
  --blue:      #3d6fd6;
  --blue-l:    #5b8df0;
  --blue-d:    #2a52a0;
  --blue-glow: rgba(61,111,214,0.45);

  /* Accents — used sparingly */
  --cyan:      #22d3ee;
  --accent:    #a78bfa;       /* purple, L3 */
  --accent-l:  #c4b5fd;
  --success:   #34d399;
  --warn:      #fbbf24;
  --danger:    #f87171;

  /* Ink */
  --ink:       #f4f6fb;
  --ink-dim:   rgba(244,246,251,0.72);
  --ink-faint: rgba(244,246,251,0.48);
  --ink-mute:  rgba(244,246,251,0.32);

  /* Backwards-compat aliases for legacy main.css selectors */
  --primary:    var(--blue);
  --primary-l:  var(--blue-l);
  --text:       var(--ink);
  --text-dim:   var(--ink-dim);
  --text-muted: var(--ink-faint);
  --green:      var(--success);
  --red:        var(--danger);
  --card-glow:  var(--blue-glow);
  --input-bg:   var(--surface2);
  --nav-bg:     rgba(10,14,26,0.72);

  /* Radii */
  --r-pill:    8px;
  --r-card:    18px;
  --r-card-lg: 24px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.30), 0 4px 12px rgba(0,0,0,0.20);
  --shadow-md:   0 12px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  --shadow-lg:   0 24px 60px rgba(0,0,0,0.40), inset 0 1px 0 rgba(255,255,255,0.04);
  --shadow-glow: 0 30px 80px rgba(61,111,214,0.18);
  --shadow-glow-strong: 0 30px 80px rgba(61,111,214,0.40);
}

:root[data-theme="light"] {
  /* Light-mode Helm — taken from scenes/common.jsx light theme */
  --bg:        #eef2fb;
  --bg2:       #e6ecf6;
  --surface:   #ffffff;
  --surface2:  #f4f6fb;
  --surface3:  #e2e7f1;
  --border:    rgba(10,14,26,0.08);
  --border2:   rgba(10,14,26,0.14);
  --border3:   rgba(10,14,26,0.22);

  --blue:      #3d6fd6;
  --blue-l:    #2a52a0;
  --blue-d:    #1a3268;
  --blue-glow: rgba(61,111,214,0.30);

  --cyan:      #0891b2;
  --accent:    #7c5cf0;
  --accent-l:  #6244d6;
  --success:   #059669;
  --warn:      #d97706;
  --danger:    #dc2626;

  --ink:       #0a0e1a;
  --ink-dim:   rgba(10,14,26,0.72);
  --ink-faint: rgba(10,14,26,0.50);
  --ink-mute:  rgba(10,14,26,0.32);

  --primary:    var(--blue);
  --primary-l:  var(--blue-l);
  --text:       var(--ink);
  --text-dim:   var(--ink-dim);
  --text-muted: var(--ink-faint);
  --green:      var(--success);
  --red:        var(--danger);
  --card-glow:  var(--blue-glow);
  --input-bg:   #ffffff;
  --nav-bg:     rgba(238,242,251,0.78);

  --shadow-sm:   0 1px 2px rgba(10,14,26,0.06), 0 4px 12px rgba(10,14,26,0.04);
  --shadow-md:   0 12px 32px rgba(10,14,26,0.08), 0 2px 0 rgba(255,255,255,0.6) inset;
  --shadow-lg:   0 24px 60px rgba(10,14,26,0.10);
  --shadow-glow: 0 30px 80px rgba(61,111,214,0.18);
  --shadow-glow-strong: 0 30px 80px rgba(61,111,214,0.30);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

/* Type utilities */
.font-mono   { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums slashed-zero; }
.font-serif  { font-family: 'Fraunces', 'Times New Roman', serif; font-style: italic; font-weight: 500; font-variation-settings: "SOFT" 80, "WONK" 1, "opsz" 144; letter-spacing: -0.035em; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--blue-l);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.eyebrow::before { content: ''; width: 18px; height: 1px; background: var(--blue-l); }

/* Atmospheric layer for any page */
.helm-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 700px at 12% -10%, var(--blue-glow), transparent 65%),
    radial-gradient(800px 700px at 92% 28%, rgba(167,139,250,0.18), transparent 65%);
  filter: blur(40px);
}
.helm-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 75%);
}
:root[data-theme="light"] .helm-grid {
  background-image: radial-gradient(rgba(10,14,26,0.06) 1px, transparent 1px);
}

/* ────────────────────────────────────────────────────────────
   Buttons
   ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font: 600 14px/1 'Inter', system-ui, sans-serif;
  letter-spacing: -0.005em;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform .18s cubic-bezier(.2,.8,.4,1), background .18s, border-color .18s, box-shadow .18s, color .18s;
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue), 0 8px 24px var(--blue-glow); }
.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 24px var(--blue-glow);
}
.btn-primary:hover { background: var(--blue-l); transform: translateY(-1px); box-shadow: 0 12px 32px var(--blue-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; border-color: var(--border2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--border3); background: rgba(255,255,255,0.04); }
:root[data-theme="light"] .btn-ghost:hover { background: rgba(10,14,26,0.04); }
.btn-quiet { background: var(--surface2); color: var(--ink-dim); }
.btn-quiet:hover { background: var(--surface3); color: var(--ink); }
.btn-lg { padding: 14px 26px; font-size: 15px; border-radius: 12px; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }

/* ────────────────────────────────────────────────────────────
   Inputs
   ──────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 14px; }
.field label {
  display: block;
  font: 600 11px/1 'Inter', system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border2);
  color: var(--ink);
  font: 500 14.5px/1.4 'Inter', system-ui, sans-serif;
  letter-spacing: -0.005em;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder { color: var(--ink-mute); }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(61,111,214,0.18);
}

/* ────────────────────────────────────────────────────────────
   Cards / pills
   ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-md);
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.card.glow { box-shadow: var(--shadow-md), var(--shadow-glow); }
.card.hoverable:hover {
  transform: translateY(-3px);
  border-color: var(--border2);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font: 600 11px/1.4 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(61,111,214,0.16);
  border: 1px solid var(--border2);
  color: var(--ink);
}
.pill-cyan   { background: rgba(34,211,238,0.16);  color: var(--cyan); }
.pill-blue   { background: rgba(61,111,214,0.18);  color: var(--blue-l); }
.pill-accent { background: rgba(167,139,250,0.18); color: var(--accent); }
.pill-success{ background: rgba(52,211,153,0.18);  color: var(--success); }
.pill-warn   { background: rgba(251,191,36,0.18);  color: var(--warn); }

/* ────────────────────────────────────────────────────────────
   Atlas avatar — pulsing sphere
   ──────────────────────────────────────────────────────────── */
.atlas-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #c4b5fd 0%, #5b8df0 50%, #1a2a6c 100%);
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 4px 12px rgba(61,111,214,0.4);
}
.atlas-avatar::after {
  content: '';
  position: absolute;
  inset: 15%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.6) 0%, transparent 45%);
}
.atlas-avatar.is-active {
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--blue),
    0 0 24px var(--blue-glow);
}

.atlas-orb {
  position: relative;
  width: 220px;
  height: 220px;
}
.atlas-orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--blue);
  animation: helm-ring 2.4s ease-out infinite;
}
.atlas-orb-ring:nth-child(2) { animation-delay: 0.8s; }
.atlas-orb-core {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e9d5ff 0%, #5b8df0 45%, #1a2a6c 100%);
  box-shadow: 0 30px 80px var(--blue-glow), inset 0 0 60px rgba(255,255,255,0.08);
}
.atlas-orb-core::after {
  content: '';
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.55) 0%, transparent 45%);
}
@keyframes helm-ring {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0;   }
}

/* ────────────────────────────────────────────────────────────
   Trust ladder rungs (used by landing + dashboard pages)
   ──────────────────────────────────────────────────────────── */
.rung-node {
  width: 64px; height: 64px;
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font: 700 22px/1 'Inter', sans-serif;
  letter-spacing: -0.02em;
  color: #fff;
}
.rung-l0 .rung-node { background: var(--surface3); color: var(--ink-dim); border: 1px solid var(--border2); }
.rung-l1 .rung-node { background: linear-gradient(135deg, #1a2240, var(--cyan)); box-shadow: 0 0 0 4px rgba(34,211,238,0.16), 0 12px 30px rgba(34,211,238,0.25); }
.rung-l2 .rung-node { background: linear-gradient(135deg, #1a2240, var(--blue)); box-shadow: 0 0 0 4px rgba(61,111,214,0.18), 0 12px 30px var(--blue-glow); }
.rung-l3 .rung-node { background: linear-gradient(135deg, var(--blue), var(--accent)); box-shadow: 0 0 0 4px rgba(167,139,250,0.18), 0 12px 30px rgba(167,139,250,0.4); }

/* ────────────────────────────────────────────────────────────
   Reveal-on-scroll
   ──────────────────────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .7s cubic-bezier(.2,.8,.4,1), transform .7s cubic-bezier(.2,.8,.4,1);
}
.reveal.in { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .reveal, .atlas-orb-ring, * { animation: none !important; transition-duration: 0.001s !important; }
}

/* ────────────────────────────────────────────────────────────
   App chrome — sidebar + topbar (used by dashboard, supplier)
   ──────────────────────────────────────────────────────────── */
.helm-sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 240px;
  padding: 24px 18px;
  background: rgba(8,12,22,0.55);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  z-index: 50;
}
:root[data-theme="light"] .helm-sidebar { background: rgba(255,255,255,0.85); }

.helm-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--ink);
}
.helm-sidebar-brand img { width: 28px; height: 28px; filter: drop-shadow(0 0 12px rgba(91,141,240,0.4)); }
.helm-sidebar-brand b { font: 600 17px/1 'Inter', sans-serif; letter-spacing: -0.02em; }

.helm-sidebar-section {
  font: 600 10.5px/1 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  padding: 16px 10px 8px;
}

.helm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font: 500 14px/1 'Inter', sans-serif;
  letter-spacing: -0.005em;
  color: var(--ink-dim);
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s, border-color .15s;
}
.helm-nav-item:hover { color: var(--ink); background: rgba(255,255,255,0.03); }
.helm-nav-item.active {
  color: var(--ink);
  background: rgba(61,111,214,0.18);
  border-color: var(--border2);
  font-weight: 600;
}
.helm-nav-item .dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--blue); flex-shrink: 0;
  box-shadow: 0 0 8px var(--blue-glow);
}
.helm-nav-item .badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  font: 700 10px/1.4 'JetBrains Mono', monospace;
  background: var(--blue);
  color: #fff;
}

.helm-content {
  margin-left: 240px;
  min-height: 100vh;
  padding: 28px 36px;
}
@media (max-width: 900px) {
  .helm-sidebar { width: 100%; height: auto; position: relative; padding: 14px 18px; flex-direction: row; gap: 10px; overflow-x: auto; }
  .helm-content { margin-left: 0; padding: 20px; }
  .helm-sidebar-section, .helm-sidebar-brand { display: none; }
}

/* ────────────────────────────────────────────────────────────
   Topbar (in-app)
   ──────────────────────────────────────────────────────────── */
.helm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.helm-topbar h1 {
  font: 600 28px/1.05 'Inter', sans-serif;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.helm-topbar h1 em {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "SOFT" 80, "WONK" 1;
  color: var(--blue-l);
  letter-spacing: -0.035em;
}
.helm-topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ────────────────────────────────────────────────────────────
   KPI tiles — used on dashboards
   ──────────────────────────────────────────────────────────── */
.helm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.helm-kpi {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  backdrop-filter: blur(14px);
}
.helm-kpi-k { font: 600 11px/1 'Inter', sans-serif; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); }
.helm-kpi-v { font: 600 30px/1 'Inter', sans-serif; letter-spacing: -0.025em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.helm-kpi-d { font: 600 13px/1.4 'Inter', sans-serif; margin-top: 6px; }
.helm-kpi-d.up   { color: var(--success); }
.helm-kpi-d.down { color: var(--danger); }

/* ────────────────────────────────────────────────────────────
   Helm chat — page-helm и плавающий overlay
   ──────────────────────────────────────────────────────────── */

/* Кнопка в сайдбаре с лого */
.nav-tab-helm {
  display: flex !important;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, rgba(61,111,214,0.12), transparent 80%) !important;
  border: 1px solid var(--border2) !important;
  margin-bottom: 8px;
  font-weight: 600 !important;
}
.nav-tab-helm img { filter: drop-shadow(0 0 6px rgba(91,141,240,0.5)); }
.nav-tab-helm.active {
  background: rgba(61,111,214,0.20) !important;
  border-color: var(--blue) !important;
  box-shadow: 0 8px 20px var(--blue-glow);
}

/* Page shell — занимает всю высоту, чат прокручивается */
#page-helm.page.active { display: flex !important; flex-direction: column; height: 100vh; padding: 0 !important; }
.helm-shell {
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  max-width: 920px; margin: 0 auto;
  background: var(--bg);
}

/* Header */
.helm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; gap: 16px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(10,14,26,0.4); backdrop-filter: blur(12px);
}
:root[data-theme="light"] .helm-header { background: rgba(255,255,255,0.6); }
.helm-header-brand { display: flex; align-items: center; gap: 12px; }
.helm-header-icon { width: 28px; height: 28px; border-radius: 6px; filter: drop-shadow(0 0 8px rgba(91,141,240,0.5)); }
.helm-header h1 {
  font: 600 20px/1 'Inter', sans-serif;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0;
}
.helm-header h1 em {
  font-family: 'Fraunces', serif;
  font-style: italic; font-weight: 400;
  font-variation-settings: "SOFT" 80, "WONK" 1;
  color: var(--blue-l);
  letter-spacing: -0.03em;
}
.helm-header-actions { display: flex; gap: 6px; }

.helm-btn-quiet {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--ink-dim);
  font: 500 13px/1 'Inter', sans-serif;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.helm-btn-quiet:hover { background: rgba(255,255,255,0.04); color: var(--ink); border-color: var(--border3); }
:root[data-theme="light"] .helm-btn-quiet:hover { background: rgba(10,14,26,0.04); }

/* История диалогов (выезжает сверху) */
.helm-history {
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  max-height: 260px;
  overflow-y: auto;
}
.helm-history-list { display: flex; flex-direction: column; gap: 4px; }
.helm-history-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-dim);
  border: 1px solid transparent;
  background: transparent;
  display: flex; justify-content: space-between; gap: 12px;
  text-align: left;
  font-family: inherit;
}
.helm-history-item:hover { background: var(--surface2); color: var(--ink); }
.helm-history-item .h-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.helm-history-item .h-time { font: 500 11px/1 'JetBrains Mono', monospace; color: var(--ink-faint); flex-shrink: 0; }

/* Сообщения */
.helm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex; flex-direction: column; gap: 18px;
  scroll-behavior: smooth;
}

/* Пустой экран */
.helm-empty {
  margin: auto;
  text-align: center;
  max-width: 540px;
  padding: 40px 20px;
}
.helm-empty-logo {
  width: 80px; height: 80px;
  filter: drop-shadow(0 20px 40px rgba(91,141,240,0.4));
  animation: helm-empty-pulse 6s ease-in-out infinite;
  margin-bottom: 18px;
}
@keyframes helm-empty-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.helm-empty-title {
  font: 600 28px/1.1 'Inter', sans-serif;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 12px;
}
.helm-empty-sub {
  font-size: 15px;
  color: var(--ink-dim);
  line-height: 1.5;
  margin-bottom: 24px;
}
.helm-empty-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.helm-chip {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 999px;
  color: var(--ink-dim);
  font: 500 13px/1 'Inter', sans-serif;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.helm-chip:hover { border-color: var(--blue); color: var(--ink); background: rgba(61,111,214,0.08); }

/* Сообщения */
.helm-msg { display: flex; flex-direction: column; gap: 6px; max-width: 92%; }
.helm-msg-meta {
  font: 600 10.5px/1 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}
.helm-msg-body {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.helm-msg-user { align-self: flex-end; align-items: flex-end; }
.helm-msg-user .helm-msg-body {
  background: var(--blue);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px 14px 4px 14px;
  max-width: 100%;
  box-shadow: 0 8px 20px var(--blue-glow);
}
.helm-msg-assistant { align-self: flex-start; }
.helm-msg-assistant .helm-msg-body {
  background: transparent;
  padding: 4px 0;
}
.helm-msg-assistant.streaming .helm-msg-body::after {
  content: '▍';
  color: var(--blue-l);
  animation: helm-cursor 1s steps(2) infinite;
  margin-left: 2px;
}
@keyframes helm-cursor { 50% { opacity: 0; } }

/* Tool notifications inline */
.helm-tool-note {
  align-self: flex-start;
  font: 500 12.5px/1.4 'JetBrains Mono', monospace;
  color: var(--ink-faint);
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.helm-tool-note .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--success); }
.helm-tool-note.failed .dot { background: var(--danger); }
.helm-tool-note.blocked .dot { background: var(--warn); }

/* Системное (error / warning) */
.helm-sys {
  align-self: center;
  padding: 8px 14px;
  background: rgba(248,113,113,0.10);
  border: 1px solid rgba(248,113,113,0.30);
  border-radius: 10px;
  font: 500 13px/1.4 'Inter', sans-serif;
  color: var(--danger);
  max-width: 80%;
}
.helm-sys.warn {
  background: rgba(251,191,36,0.10);
  border-color: rgba(251,191,36,0.30);
  color: var(--warn);
}

/* Action card (для этапа 1.14) */
.helm-action-card {
  align-self: stretch;
  padding: 18px;
  background: linear-gradient(180deg, rgba(61,111,214,0.10), var(--surface));
  border: 1px solid var(--blue);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-glow);
}
.helm-action-title { font: 600 16px/1.3 'Inter', sans-serif; letter-spacing: -0.015em; margin-bottom: 12px; }
.helm-action-fields { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.helm-action-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Input */
.helm-input-wrap {
  display: flex; gap: 10px;
  padding: 16px 28px 22px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.helm-input-wrap textarea {
  flex: 1;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  color: var(--ink);
  font: 400 15px/1.45 'Inter', sans-serif;
  letter-spacing: -0.005em;
  resize: none;
  max-height: 200px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.helm-input-wrap textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(61,111,214,0.18);
}
.helm-input-wrap textarea::placeholder { color: var(--ink-mute); }
.helm-send {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px var(--blue-glow);
  transition: background .15s, transform .1s;
  align-self: flex-end;
}
.helm-send:hover { background: var(--blue-l); }
.helm-send:active { transform: scale(0.95); }
.helm-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ────────────────────────────────────────────────────────────
   Helm overlay — плавающий чат поверх любой страницы
   ──────────────────────────────────────────────────────────── */
.helm-overlay-wrap {
  position: fixed;
  z-index: 600;
  inset: auto;
  pointer-events: none;
}
.helm-overlay-shell {
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 440px;
  height: 600px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border3);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45), 0 0 0 1px var(--border2), var(--shadow-glow);
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity .2s cubic-bezier(.2,.8,.4,1), transform .2s cubic-bezier(.2,.8,.4,1);
}
.helm-overlay-wrap.open .helm-overlay-shell {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.helm-overlay-header {
  cursor: grab;
  user-select: none;
  padding: 12px 16px;
}
.helm-overlay-header:active { cursor: grabbing; }
.helm-overlay-header h1 { font-size: 16px; }
.helm-overlay-context-label {
  font: 500 11px/1 'JetBrains Mono', monospace;
  color: var(--ink-faint);
  margin-left: 8px;
  padding: 3px 8px;
  background: var(--surface2);
  border-radius: 6px;
}
.helm-overlay-shell .helm-messages { padding: 16px 18px; gap: 14px; }
.helm-overlay-shell .helm-input-wrap { padding: 12px 18px 16px; }
.helm-overlay-shell .helm-msg-body { font-size: 14.5px; }

/* Кнопка-закрытия как btn-quiet но крупнее символ */
.helm-overlay-header .helm-btn-quiet {
  padding: 5px 10px;
  font: 600 16px/1 'Inter', sans-serif;
}

/* Мобила — fullscreen-bottom-sheet */
@media (max-width: 700px) {
  .helm-overlay-shell {
    right: 0; left: 0; bottom: 0;
    width: 100%;
    height: 84vh;
    max-height: 84vh;
    border-radius: 18px 18px 0 0;
  }
}

/* FAB icon-image внутри button (правильный display после открытия) */
#ai-overlay-fab[data-helm-mode="1"] { display: flex !important; }

/* Briefing card (этап 1.15) */
.helm-briefing-card {
  align-self: stretch;
  padding: 20px 22px;
  background: linear-gradient(180deg, rgba(61,111,214,0.10), var(--surface));
  border: 1px solid var(--border2);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-md);
  margin-bottom: 8px;
}
.helm-briefing-meta {
  font: 600 11px/1 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--blue-l);
  margin-bottom: 12px;
}
.helm-briefing-text {
  font-size: 15.5px;
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-wrap;
}
.helm-briefing-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
