/* OmniChat chrome. Color/type/radius SoT: /brand/kit-v2/tokens.css */
:root {
  --sidebar-collapsed-w: 64px;
  --sidebar-expanded-w: 228px;
  /* Wide enough for open chat-cluster (Chat+Web+Deep) + Code/Photo without clipping. */
  --chat-col-w: 960px;
  --chat-col-empty-w: 1040px;
  --sidebar-icon-slot: 40px;
  --sidebar-logo: 40px;
  --sidebar-rail-pad: 12px;
  --sidebar-motion-dur: 0.24s;
  --sidebar-motion-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-label-dur: 0.16s;
  --sidebar-label-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ws-topbar-h: 5.25rem;

  color-scheme: dark;
}

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

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--omni-bg);
}

body {
  color: var(--omni-text);
  font-family: var(--omni-font-ui);
  font-weight: 500;
  font-size: 14px;
  line-height: 1.45;
  background: var(--omni-bg);
  -webkit-font-smoothing: antialiased;
  /* Kill rubber-band scroll that Telegram WebView amplifies with keyboard. */
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.app-shell {
  /* Fill the layout viewport edge-to-edge (no hairline “frame” when --app-height
     lags the real window). Keyboard overlays; dock lifts via --kb-lift. */
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  width: auto;
  height: auto;
  max-height: none;
  overflow: hidden;
  overflow-x: clip;
  background: var(--omni-bg);
  box-sizing: border-box;
  padding: 0;
  border: 0;
  outline: none;
  box-shadow: none;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  background: transparent;
  transition: background var(--sidebar-motion-dur) var(--sidebar-label-ease);
}
.app-shell:has(.app-sidebar:is(:hover, .app-sidebar--expanded))::before,
body.is-side-open .app-shell::before {
  background: rgba(0, 0, 0, 0.52);
}

.app-shell-dim {
  position: fixed;
  inset: 0;
  z-index: 65;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
}
body.is-side-open .app-shell-dim {
  opacity: 1;
  pointer-events: auto;
}
/* Mobile drawer open — prevent background rubber-band under overlay. */
html.is-side-open,
html.is-side-open body {
  overscroll-behavior: none;
}
html.is-side-open .app-shell,
html.is-side-open .app-frame,
html.is-side-open .thread {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}
html.is-side-open .app-sidebar {
  touch-action: pan-y;
  overscroll-behavior: contain;
  overflow-x: hidden;
  overflow-y: auto;
}
html.is-side-open #chatThreads {
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* ---- Sidebar (canon rail) ---- */
.app-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  /* Above mobile .topbar (50) and .btn-login (60) so drawer logo is never covered. */
  z-index: 70;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-collapsed-w);
  padding: 0 var(--sidebar-rail-pad) 14px;
  background: var(--omni-bg-deep);
  border-right: 1px solid var(--omni-border);
  overflow: hidden;
  transition:
    width var(--sidebar-motion-dur) var(--sidebar-motion-ease),
    transform var(--sidebar-motion-dur) var(--sidebar-motion-ease),
    filter var(--sidebar-motion-dur) var(--sidebar-label-ease);
}
.app-sidebar:is(:hover, .app-sidebar--expanded) {
  width: var(--sidebar-expanded-w);
  filter: drop-shadow(10px 0 22px rgba(0, 0, 0, 0.38));
}

.side-brand {
  display: grid;
  grid-template-columns: var(--sidebar-icon-slot) minmax(0, 1fr);
  align-items: center;
  column-gap: 0;
  flex: 0 0 var(--ws-topbar-h);
  height: var(--ws-topbar-h);
  min-height: var(--ws-topbar-h);
  margin: 0;
  padding: 0;
  text-decoration: none;
  color: var(--omni-text);
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  /* Collapse: keep gap until label fades, then close. */
  transition: column-gap var(--sidebar-label-dur) var(--sidebar-label-ease) 0.1s;
}
.side-brand-logo {
  grid-column: 1;
  justify-self: center;
  width: var(--sidebar-logo);
  height: var(--sidebar-logo);
  border-radius: 10px;
  display: block;
  object-fit: contain;
  /* Collapsed: hide squircle frame; keep O mark.
     Same shape family (circle→circle) so the reveal interpolates smoothly. */
  clip-path: circle(34% at 50% 50%);
  transition: clip-path 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.app-sidebar:is(:hover, .app-sidebar--expanded) .side-brand-logo {
  clip-path: circle(72% at 50% 50%);
}
.side-brand-name {
  grid-column: 2;
  position: static;
  width: auto;
  height: auto;
  clip: auto;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  font: 800 1.05rem/1.1 var(--omni-font-display);
  letter-spacing: 0.08em;
  color: var(--omni-text);
  transition:
    opacity 0.1s ease,
    max-width var(--sidebar-label-dur) var(--sidebar-label-ease);
}
.app-sidebar:is(:hover, .app-sidebar--expanded) .side-brand {
  column-gap: 12px;
  transition-delay: 0s;
}
.app-sidebar:is(:hover, .app-sidebar--expanded) .side-brand-name {
  max-width: 140px;
  opacity: 1;
  transition-delay: 0.06s;
}

.side-nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0.85rem 0 0;
  overflow: hidden; /* history scrolls inside; Business/API stay in .side-nav-end */
}
.side-nav__indicator {
  position: absolute;
  left: 0;
  right: 0;
  top: 0.85rem;
  height: 40px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--omni-accent-dim) 88%, transparent);
  box-shadow: inset 0 0 0 1px rgba(228, 154, 76, 0.12);
  pointer-events: none;
  z-index: 0;
}

.side-nav button,
.side-nav-link {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-icon-slot) minmax(0, 1fr);
  align-items: center;
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0;
  column-gap: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--omni-text);
  font-family: var(--omni-font-ui);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  overflow: visible;
  outline: none;
  transition:
    column-gap var(--sidebar-label-dur) var(--sidebar-label-ease) 0.08s,
    color 0.15s ease,
    background 0.18s ease;
}
.side-nav button:focus-visible,
.side-nav-link:focus-visible {
  outline: none;
}
.side-nav button:focus-visible::after,
.side-nav-link:focus-visible::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid color-mix(in srgb, var(--omni-accent) 75%, transparent);
  border-radius: 8px;
  pointer-events: none;
  z-index: 2;
}
.app-sidebar:is(:hover, .app-sidebar--expanded) .side-nav button,
.app-sidebar:is(:hover, .app-sidebar--expanded) .side-nav-link,
.app-sidebar:is(:hover, .app-sidebar--expanded) .side-foot .side-nav-link {
  column-gap: 10px;
  transition-delay: 0s;
}
.side-nav button:hover,
.side-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.side-nav button.is-active {
  color: var(--omni-accent-hover);
}

.side-nav-ico {
  grid-column: 1;
  justify-self: center;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.side-nav-ico svg {
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.side-nav-lab {
  grid-column: 2;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition:
    opacity 0.1s ease,
    max-width var(--sidebar-label-dur) var(--sidebar-label-ease);
}
.app-sidebar:is(:hover, .app-sidebar--expanded) .side-nav-lab {
  max-width: 140px;
  opacity: 1;
  transition-delay: 0.05s;
}

.side-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ---- Main frame: full-bleed scrollport (scrollbar at screen right) ---- */
.app-frame {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 18px 0 16px;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
}
.app-frame.is-empty {
  max-width: none;
  padding-inline: 0;
  /* Tight equal rhythm: modes ↔ composer ↔ suggestion chips */
  --landing-stack-gap: 8px;
}

/* Empty = centered hero; with messages = thread + dock bottom */
.stage {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  display: grid;
  /* thread + dock (suggestions live inside dock on landing) */
  grid-template-rows: 1fr auto;
  align-content: stretch;
  gap: 12px;
  height: 100%;
}
.dock,
.controls,
.modes {
  min-width: 0;
  max-width: 100%;
}
.hero-title {
  display: none;
  margin: 0;
  text-align: center;
  font-family: var(--omni-font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 4.5vw, 2.4rem);
  letter-spacing: -0.02em;
  color: var(--omni-text);
}
.suggestions {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 4px;
  box-sizing: border-box;
}
.chip {
  appearance: none;
  border: 0;
  background: var(--omni-surface);
  color: var(--omni-text-secondary);
  font: 500 0.82rem var(--omni-font-ui);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  outline: none;
  transition: color 0.15s ease, background 0.15s ease;
}
.chip:hover {
  color: var(--omni-text);
  background: var(--omni-surface-hover);
}

.app-frame.is-empty .stage {
  grid-template-rows: auto auto;
  align-content: center;
  justify-items: stretch;
  gap: 22px; /* hero ↔ stack only; stack internals use --landing-stack-gap */
  padding-bottom: 8vh;
}
.app-frame.is-empty .hero-title { display: block; }
.app-frame.is-empty .thread { display: none; }
.app-frame.is-empty .suggestions { display: flex; }
.app-frame.is-empty .dock {
  width: min(var(--chat-col-empty-w), calc(100% - 40px));
  max-width: min(var(--chat-col-empty-w), calc(100% - 40px));
  margin-inline: auto;
  /* Gap only between composer-shell and suggestions */
  gap: var(--landing-stack-gap);
  /* No wash/plate under Веб/Deep — chips sit on page bg */
  background: none !important;
  background-image: none !important;
  box-shadow: none !important;
  filter: none !important;
}
.app-frame.is-empty .dock::before,
.app-frame.is-empty .dock::after {
  content: none !important;
  display: none !important;
}
.app-frame.is-empty .hero-title {
  width: min(var(--chat-col-empty-w), calc(100% - 40px));
  margin-inline: auto;
}
.app-frame.is-empty .composer-shell {
  width: 100%;
  max-width: 100%;
}
.app-frame.is-empty .controls {
  align-items: center;
  width: 100%;
  max-width: 100%;
}
.app-frame.is-empty .modes {
  justify-content: center;
  flex-wrap: nowrap;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: transparent;
}
.app-frame.is-empty .modes.params-bar {
  overflow: visible !important;
  padding: 0 !important;
  background: none !important;
  box-shadow: none !important;
  filter: none !important;
}
.app-frame.is-empty .modes::-webkit-scrollbar { display: none; }
.app-frame.is-empty .composer {
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
}
/* Same composer width in chat — avoids L↔R stretch when leaving empty state */
.app-frame:not(.is-empty) .composer {
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
}
.app-frame:not(.is-empty) .modes {
  justify-content: center;
}
.dock.is-settling {
  will-change: transform;
  pointer-events: none;
}
.app-frame.is-empty .suggestions {
  width: 100%;
  max-width: 100%;
  margin: 0;
  justify-content: center;
  box-sizing: border-box;
}
.app-frame.is-empty .controls,
.app-frame.is-empty .composer,
.app-frame.is-empty .composer-queue,
.app-frame.is-empty .composer-shell {
  margin-top: 0;
  margin-bottom: 0;
}

/* Field unit only (queue/attach/composer). Params live as a dock sibling. */
.composer-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
  filter: none !important;
}
/* Standalone chip row — no plate, shrink-wrapped, tight to the field. */
.composer-tabs-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
  background: none !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  filter: none !important;
  isolation: auto !important;
  contain: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
/* Net ~4px to the field regardless of dock gap */
.dock > .composer-tabs-wrap {
  margin-bottom: calc(4px - var(--landing-stack-gap, 8px));
}
.app-frame:not(.is-empty) .dock > .composer-tabs-wrap {
  margin-bottom: calc(4px - 10px);
}
.composer-tabs-wrap::before,
.composer-tabs-wrap::after {
  content: none !important;
  display: none !important;
}

/* Chat dock: no wash behind chips. Scroll fade sits ABOVE the dock only. */
.app-frame:not(.is-empty) .dock {
  position: relative;
  /* Own stacking context so ::before (z:0) stays under .composer (z:1) while
     the whole dock still paints above the thread. */
  z-index: 5;
  width: min(var(--chat-col-w), calc(100% - 40px));
  max-width: min(var(--chat-col-w), calc(100% - 40px));
  margin-inline: auto;
  background: none !important;
  background-image: none !important;
  box-shadow: none !important;
  filter: none !important;
  overflow: visible;
}
/* Thread tucks under the dock: gradient above chips/field, not under them.
   z-index must stay BELOW .composer (z-index:1) — otherwise the wash paints
   over plus-menu (menu extends above the field into this band) and reads as a
   hard “shadow” on hover, split at the dock’s left edge. */
.app-frame:not(.is-empty) .dock::before {
  content: "" !important;
  display: block !important;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 20px;
  pointer-events: none;
  z-index: 0;
  opacity: 1 !important;
  background: linear-gradient(
    to top,
    var(--omni-bg) 0%,
    color-mix(in srgb, var(--omni-bg) 72%, transparent) 48%,
    transparent 100%
  ) !important;
  background-image: linear-gradient(
    to top,
    var(--omni-bg) 0%,
    color-mix(in srgb, var(--omni-bg) 72%, transparent) 48%,
    transparent 100%
  ) !important;
  box-shadow: none !important;
}
.app-frame:not(.is-empty) .dock::after {
  content: none !important;
  display: none !important;
  background: none !important;
  box-shadow: none !important;
}
.app-frame:not(.is-empty) .composer {
  /* Negative spread keeps depth below the field — no upward wash under chips */
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 10px 24px -8px rgba(0, 0, 0, 0.38);
}

.app-frame:not(.is-empty) .hero-title,
.app-frame:not(.is-empty) .suggestions { display: none !important; }

/* Viewport corner — not tied to content column */
.btn-login {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--omni-radius-pill);
  background: #f2f0eb;
  color: #14110e;
  font: 700 0.88rem var(--omni-font-ui);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-login:hover {
  background: #fff;
  color: #14110e;
}
.btn-login.is-profile {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(165deg, #32302c 0%, #161410 100%);
  color: var(--omni-accent, #d4893a);
  border: 1px solid rgba(212, 137, 58, 0.42);
  overflow: hidden;
  font-size: 0.92rem;
  letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.btn-login.is-profile:hover {
  background: linear-gradient(165deg, #3c3934 0%, #1c1914 100%);
  color: var(--omni-accent-hover, #e09a4a);
  border-color: rgba(212, 137, 58, 0.6);
}

.topbar {
  display: none;
  align-items: center;
  min-height: 0;
}

.side-burger {
  appearance: none;
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--omni-text);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.16s ease, visibility 0.16s ease;
}
.side-burger-bars,
.side-burger-bars::before,
.side-burger-bars::after {
  display: block;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  position: relative;
}
/* Middle = longest; top shortest; bottom between them. */
.side-burger-bars {
  width: 16px;
}
.side-burger-bars::before,
.side-burger-bars::after {
  content: "";
  position: absolute;
  left: 0;
}
.side-burger-bars::before {
  top: -5px;
  width: 8px;
}
.side-burger-bars::after {
  top: 5px;
  width: 12px;
}
body.is-side-open .side-burger {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.dock {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  /* Keep plus-menu (opens upward) from being clipped by ancestors */
  overflow: visible;
}

.consent {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 18px;
  padding: 14px 16px;
  border-radius: var(--omni-radius-lg);
  border: 1px solid var(--omni-border);
  background: var(--omni-bg-elevated);
}
.consent[hidden] { display: none !important; }
.consent-copy { flex: 1 1 240px; min-width: 0; }
.consent-title {
  margin: 0 0 6px;
  font: 700 0.95rem/1.25 var(--omni-font-ui);
  color: var(--omni-text);
}
.consent-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--omni-text-secondary);
}
.consent-text a {
  color: var(--omni-accent);
  text-decoration: none;
}
.consent-text a:hover { text-decoration: underline; }
.consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}
.btn-ghost,
.btn-solid {
  appearance: none;
  border-radius: var(--omni-radius-pill);
  font: 700 0.82rem var(--omni-font-ui);
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-ghost {
  border: 1px solid rgba(242, 240, 235, 0.35);
  background: transparent;
  color: var(--omni-text);
}
.btn-ghost:hover { border-color: #fff; }
.btn-solid {
  border: 0;
  background: #f2f0eb;
  color: #14110e;
}
.btn-solid:hover { background: #fff; }

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.modes {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  /* Pad so Tab focus rings are not clipped by the scrollport. */
  padding: 4px;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
/* Params bar as tab row on the composer edge. */
.modes.params-bar,
.modes.composer-tabs,
.app-frame.is-empty .modes.params-bar,
.modes:has(> .param-chip) {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  padding: 0 8px !important;
  border: none !important;
  border-radius: 0 !important;
  overflow: visible !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  background: none !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  filter: none !important;
  outline: none !important;
  isolation: auto !important;
  contain: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  transform: none !important;
}
.controls:has(.params-bar),
.controls:has(.param-chip) {
  background: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
  filter: none !important;
  isolation: auto !important;
  contain: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
.controls:has(.params-bar)::before,
.controls:has(.params-bar)::after,
.controls:has(.param-chip)::before,
.controls:has(.param-chip)::after {
  content: none !important;
  display: none !important;
  opacity: 0 !important;
  background: none !important;
}

/* Standalone param chips — same surface + border language as .composer. */
.param-chip {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  height: 34px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--omni-border);
  border-radius: var(--omni-radius-pill);
  background: var(--omni-surface) !important;
  background-color: var(--omni-surface) !important;
  background-image: none !important;
  color: var(--omni-text-secondary);
  font: 600 0.8rem/1 var(--omni-font-ui);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  /* Match composer inset edge — no outer glow/tray */
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset !important;
  filter: none !important;
  outline: none !important;
  text-shadow: none !important;
  transform: none !important;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.param-chip::before,
.param-chip::after {
  content: none !important;
  display: none !important;
}
.param-chip::-moz-focus-inner {
  border: 0;
  padding: 0;
}
.param-chip:hover {
  color: var(--omni-text);
  border-color: var(--omni-accent-line);
  background: var(--omni-surface-hover) !important;
  background-color: var(--omni-surface-hover) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset !important;
  filter: none !important;
}
.param-chip[aria-pressed="true"] {
  color: var(--omni-accent-hover);
  border-color: var(--omni-accent);
  background: var(--omni-surface) !important;
  background-color: var(--omni-surface) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset !important;
  filter: none !important;
}
.param-chip:focus-visible {
  border-color: var(--omni-accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset !important;
  outline: 2px solid color-mix(in srgb, var(--omni-accent) 75%, transparent);
  outline-offset: 2px;
}
.chip:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--omni-accent) 75%, transparent);
  outline-offset: 2px;
}
.param-chip-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  line-height: 0;
  background: none !important;
  box-shadow: none !important;
  filter: none !important;
}
.param-chip-ico svg {
  display: block;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.param-chip-lab {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  /* no transform — avoids compositing plate behind the chip */
  background: none !important;
  box-shadow: none !important;
  filter: none !important;
}
.modes::-webkit-scrollbar { display: none; }
.modes > .mode,
.modes > .mode-cluster {
  flex-shrink: 0;
}

/* Params-only bar (Веб / Deep) — без tray/подложки, только сами кнопки */
.mode-cluster {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0;
  padding: 0;
  width: max-content;
  max-width: 100%;
  border-radius: 0;
  border: none;
  background: transparent !important;
  box-shadow: none !important;
  filter: none !important;
  vertical-align: middle;
  transition:
    padding 0.36s cubic-bezier(0.32, 0.72, 0, 1),
    gap 0.36s cubic-bezier(0.32, 0.72, 0, 1);
}
.mode-cluster.is-open,
.mode-cluster.params-only {
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent !important;
  box-shadow: none !important;
  filter: none !important;
}
.mode-cluster .mode[data-mode="chat"] {
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.mode-cluster.is-open .mode[data-mode="chat"] {
  /* Keep same chrome as other mode pills — no “tray” merge */
  border-color: var(--omni-border);
}
.mode-cluster.is-open .mode[data-mode="chat"].active {
  border-color: var(--omni-accent);
}

/* width via 0fr→1fr — ровнее, чем max-width */
.chat-extras {
  display: grid;
  grid-template-columns: 0fr;
  opacity: 0;
  pointer-events: none;
  transition:
    grid-template-columns 0.4s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.28s ease;
}
.mode-cluster.is-open .chat-extras,
.mode-cluster.params-only .chat-extras {
  grid-template-columns: max-content;
  width: max-content;
  max-width: 100%;
  opacity: 1;
  pointer-events: auto;
  background: transparent !important;
  transition:
    grid-template-columns 0.42s cubic-bezier(0.32, 0.72, 0, 1),
    opacity 0.32s ease 0.04s;
}
.chat-extras-track {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: max-content;
  max-width: 100%;
  overflow: visible;
  padding: 0;
  background: transparent !important;
  box-shadow: none !important;
  filter: none !important;
  transition: padding-left 0.36s cubic-bezier(0.32, 0.72, 0, 1);
}
.mode-cluster.is-open .chat-extras-track {
  padding-left: 4px;
}
.mode-cluster.params-only .chat-extras-track {
  padding-left: 0;
}

.mode-opt {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 12px;
  white-space: nowrap;
  background: transparent;
  color: var(--omni-text-secondary);
  opacity: 1;
  transform: none;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease;
}
.mode-cluster.is-open .mode-opt,
.mode-cluster.params-only .mode-opt {
  opacity: 1;
  transform: none;
}
.mode-cluster.is-open .mode-opt:nth-child(1) {
  transition-delay: 0.05s, 0.05s, 0s, 0s;
}
.mode-cluster.is-open .mode-opt:nth-child(2) {
  transition-delay: 0.1s, 0.1s, 0s, 0s;
}
.mode-cluster:not(.is-open) .mode-opt {
  transition-delay: 0s;
}
.mode-cluster.is-open .mode-opt:hover,
.mode-cluster.params-only .mode-opt:hover {
  color: var(--omni-text);
  background: transparent !important;
  background-color: transparent !important;
  border-color: var(--omni-accent-line) !important;
  box-shadow: none !important;
  filter: none !important;
}
.mode-cluster.is-open .mode-opt[aria-pressed="true"],
.mode-cluster.params-only .mode-opt[aria-pressed="true"],
.mode.mode-opt.active {
  color: var(--omni-accent-hover) !important;
  background: transparent !important;
  background-color: transparent !important;
  border-color: var(--omni-accent) !important;
  box-shadow: none !important;
  filter: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .mode-cluster,
  .chat-extras,
  .chat-extras-track,
  .mode-opt {
    transition: none !important;
  }
  .mode-opt { transform: none; opacity: 1; }
}
.mode {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  height: 34px;
  border: 1px solid var(--omni-border);
  background: transparent;
  color: var(--omni-text);
  font: 600 0.82rem/1 var(--omni-font-ui);
  padding: 0 12px;
  border-radius: var(--omni-radius-pill);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  /* Depth via shadow only — never on .mode-opt (params pills). */
  box-shadow: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}
.mode:not(.mode-opt) {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
}
.mode-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  line-height: 0;
}
.mode-ico svg {
  display: block;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Auto = favicon O (ring + core) */
.mode[data-mode="auto"] .mode-ico-ring {
  stroke: var(--omni-accent);
  stroke-width: 2.75;
}
.mode[data-mode="auto"] .mode-ico-core {
  fill: var(--omni-metal-bright);
  stroke: none;
}
.mode[data-mode="auto"].active .mode-ico-ring {
  stroke: #fff;
}
.mode[data-mode="auto"].active .mode-ico-core {
  fill: #fff;
  opacity: 0.7;
}
.mode-lab {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  /* Optical: Cyrillic/UI fonts sit low in the em-box */
  transform: translateY(-0.04em);
}
.mode:not(.mode-opt):hover {
  border-color: var(--omni-accent-line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.42);
}
.mode:not(.mode-opt).active {
  background: var(--omni-accent);
  color: #fff;
  border-color: var(--omni-accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.mode-opt {
  gap: 6px;
  padding-inline: 11px;
  border-color: var(--omni-border) !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  color: var(--omni-text-secondary);
  /* Border only — any shadow/filter became the sharp tray under both pills. */
  box-shadow: none !important;
  filter: none !important;
  transform: none !important;
  opacity: 1 !important;
  text-shadow: none !important;
}
.mode.mode-opt,
.mode.mode-opt:hover,
.mode.mode-opt.active,
.mode.mode-opt[aria-pressed="true"] {
  box-shadow: none !important;
  filter: none !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  transform: none !important;
}
.mode.mode-opt.active,
.mode.mode-opt[aria-pressed="true"] {
  color: var(--omni-accent-hover) !important;
  border-color: var(--omni-accent) !important;
}
.mode-opt .mode-ico {
  width: 14px;
  height: 14px;
}
.mode-opt .mode-ico svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.65;
}
.plus-item.is-on {
  color: var(--omni-accent-hover);
  background: var(--omni-accent-dim);
}

.thread {
  /* Full-bleed scrollport → native scrollbar sits on the right of the screen.
     Readable column is inset via symmetric gutters. */
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  width: 100%;
  /* Slightly lower start so top wash does not press into the first bubble. */
  padding: 16px max(20px, calc((100% - var(--chat-col-w)) / 2)) 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-content: flex-start;
  gap: 14px;
  /* Instant scroll — smooth fights stick-to-bottom during streaming. */
  scroll-behavior: auto;
  /* Avoid a permanent gutter stripe that reads as a right-edge “frame”. */
  scrollbar-gutter: auto;
  overflow-anchor: none;
  border: 0;
  outline: none;
  box-shadow: none;
  /* Dock height synced from JS — keep last lines above composer/modes. */
  scroll-padding-bottom: var(--dock-pad, 96px);
}
/* OSK lift overlays the thread: grow end spacer (not message padding) so
   stick-to-bottom can clear the dock without reflowing bubbles. */
.thread::after {
  content: "";
  flex: 0 0 auto;
  height: 0;
  max-height: 0;
  width: 100%;
  pointer-events: none;
}
/* Cap OSK spacer — a stuck --kb-lift used to open a huge void under the last bubble. */
html.is-keyboard-open .thread::after,
html.is-kb-field-focused .thread::after {
  height: min(var(--kb-lift, 0px), 42vh);
  max-height: 42vh;
}
html:not(.is-keyboard-open):not(.is-kb-field-focused) .thread::after {
  height: 0 !important;
  max-height: 0 !important;
}
/* Ref photo 2: compact flat user pill; assistant = prose, no card */
.msg {
  max-width: min(48rem, 100%);
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
  box-shadow: none;
  border-radius: 0;
  background: transparent;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}
.msg.user {
  align-self: flex-end;
  width: fit-content;
  max-width: min(70%, 36rem);
  padding: 8px 16px;
  border-radius: 22px;
  background: #3a322a;
  color: var(--omni-text);
}
.msg.msg-enter {
  animation: msg-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.msg.user.msg-enter {
  transform-origin: 100% 100%;
}
@keyframes msg-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.msg.assistant {
  align-self: stretch;
  width: 100%;
  max-width: min(48rem, 100%);
  padding: 0;
  color: var(--omni-text);
  white-space: normal;
}
/* Tables, code cards + file artifacts use the full chat column — including WHILE streaming.
   Bug was: widen only on :has(.msg-exports), but exports mount after stream ends
   → table looked skinny mid-gen, then jumped wide on done.
   Same for .md-code: without this, fences stayed at 48rem while the landing is --chat-col-w.
   .has-md-code/.has-md-table are set from JS (reliable while streaming). */
.msg.assistant:has(.md-table-wrap),
.msg.assistant:has(.md-code),
.msg.assistant.has-md-table,
.msg.assistant.has-md-code,
.msg.assistant:has(> .msg-exports) {
  max-width: min(var(--chat-col-w), 100%);
}
.msg.assistant:has(.md-table-wrap) > .md,
.msg.assistant:has(.md-code) > .md,
.msg.assistant.has-md-table > .md,
.msg.assistant.has-md-code > .md,
.msg.assistant:has(> .msg-exports) > .md {
  max-width: none;
  width: 100%;
}
.msg.assistant:has(.md-table-wrap) > .md .md-table-wrap,
.msg.assistant:has(.md-code) > .md .md-code,
.msg.assistant.has-md-table > .md .md-table-wrap,
.msg.assistant.has-md-code > .md .md-code,
.msg.assistant:has(> .msg-exports) > .md .md-table-wrap {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.msg.assistant .md.md-streaming strong {
  /* streaming bold feels live without layout jump */
  font-weight: 700;
  color: #fff;
}
.msg.assistant .md {
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--omni-text);
}
.msg.assistant .md > :first-child { margin-top: 0; }
.msg.assistant .md > :last-child { margin-bottom: 0; }
.msg.assistant .md p {
  margin: 0 0 0.75em;
}
.msg.assistant .md strong { font-weight: 700; color: #fff; }
.msg.assistant .md em { font-style: italic; }
.msg.assistant .md ul,
.msg.assistant .md ol {
  margin: 0.35em 0 0.85em;
  padding-left: 1.35em;
}
.msg.assistant .md li { margin: 0.25em 0; }
.msg.assistant .md li::marker { color: var(--omni-accent); }
.msg.assistant .md h1,
.msg.assistant .md h2,
.msg.assistant .md h3 {
  margin: 0.95em 0 0.45em;
  font-family: var(--omni-font-display);
  font-weight: 650;
  line-height: 1.25;
  color: #fff;
  letter-spacing: -0.01em;
}
.msg.assistant .md > h1:first-child,
.msg.assistant .md > h2:first-child,
.msg.assistant .md > h3:first-child {
  margin-top: 0.15em;
}
.msg.assistant .md h1 { font-size: 1.22rem; }
.msg.assistant .md h2 { font-size: 1.1rem; }
.msg.assistant .md h3 { font-size: 1.02rem; color: #f2f0eb; }
.msg.assistant .md .md-table-wrap {
  position: relative;
  margin: 0.65em 0 1em;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--omni-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--omni-bg-elevated) 88%, transparent);
}
.msg.assistant .md .md-table-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.msg.assistant .md .md-table-wrap:hover .md-table-toolbar,
.msg.assistant .md .md-table-wrap:focus-within .md-table-toolbar {
  opacity: 1;
  pointer-events: auto;
}
.msg.assistant .md .md-table-tool {
  appearance: none;
  border: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: var(--omni-text);
  background: color-mix(in srgb, var(--omni-surface) 92%, #000 8%);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.msg.assistant .md .md-table-tool:hover {
  color: var(--omni-accent-hover);
  background: var(--omni-surface-hover);
}
.msg.assistant .md .md-table-tool svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.msg.assistant .md .md-table {
  /* Wide tables (4+ cols): grow + horizontal scroll. */
  width: max-content;
  min-width: 100%;
  max-width: none;
  table-layout: auto;
  border-collapse: collapse;
  font-size: 0.92rem;
  line-height: 1.45;
}
/* 2–3 columns: fill the chat/landing column, equal widths, wrap cell text. */
.msg.assistant .md .md-table-wrap--fit {
  overflow-x: hidden;
}
.msg.assistant .md .md-table.md-table--fit {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  table-layout: fixed;
}
.msg.assistant .md .md-table.md-table--cols-2 th,
.msg.assistant .md .md-table.md-table--cols-2 td {
  width: 50%;
}
.msg.assistant .md .md-table.md-table--cols-3 th,
.msg.assistant .md .md-table.md-table--cols-3 td {
  width: 33.333%;
}
.msg.assistant .md .md-table th,
.msg.assistant .md .md-table td {
  padding: 0.55em 0.85em;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--omni-border);
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
  min-width: 8.5rem;
}
.msg.assistant .md .md-table th {
  font-weight: 650;
  color: #fff;
  background: color-mix(in srgb, var(--omni-surface) 70%, transparent);
  white-space: nowrap;
}
.msg.assistant .md .md-table td {
  color: var(--omni-text);
  white-space: normal;
}
/* Label / first column: keep words intact on wide scrollable tables. */
.msg.assistant .md .md-table.md-table--wide th:first-child,
.msg.assistant .md .md-table.md-table--wide td:first-child {
  white-space: nowrap;
  min-width: 7rem;
  max-width: none;
}
/* Fit tables: every cell wraps under equal column widths. */
.msg.assistant .md .md-table.md-table--fit th,
.msg.assistant .md .md-table.md-table--fit td {
  min-width: 0;
  max-width: none;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
.msg.assistant .md .md-table.md-table--fit th {
  white-space: normal;
  line-height: 1.35;
}
.msg.assistant .md .md-table tbody tr:last-child td {
  border-bottom: 0;
}
.msg.assistant .md .md-table code {
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant .md .md-table.md-table--wide code {
  white-space: nowrap;
}
.msg.assistant .md a {
  color: var(--omni-accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg.assistant .md code {
  font-family: var(--omni-font-mono);
  font-size: 0.86em;
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: var(--omni-surface);
  color: var(--omni-accent-hover);
}
/* Code card — OMNI warm metal (no accent stripe — reads as a bug on mobile) */
.msg.assistant .md .md-code {
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0.65em 0 1em;
  border-radius: 12px;
  background: color-mix(in srgb, var(--omni-bg-elevated) 82%, #000 18%);
  border: 1px solid var(--omni-border);
  overflow: hidden;
  box-shadow: none;
}
.msg.assistant .md .md-code-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 34px;
  padding: 4px 8px 0 14px;
}
.msg.assistant .md .md-code[data-lang]::after {
  content: attr(data-lang);
  position: absolute;
  top: 10px;
  left: 14px;
  font: 600 0.68rem/1 var(--omni-font-ui, Onest, system-ui, sans-serif);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: rgba(196, 191, 182, 0.5);
  pointer-events: none;
}
.msg.assistant .md .md-code-copy {
  appearance: none;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: rgba(196, 191, 182, 0.55);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.msg.assistant .md .md-code-copy:hover {
  background: rgba(212, 137, 58, 0.12);
  color: var(--omni-text, #f2f0eb);
}
.msg.assistant .md .md-code-copy svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.msg.assistant .md .md-code-body,
.msg.assistant .md .md-pre {
  margin: 0;
  padding: 4px 14px 14px 16px;
  overflow-x: auto;
  border-radius: 0;
  background: transparent;
  border: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
/* Horizontal scroll affordance — inset fades (avoid ::after; lang label owns it). */
.msg.assistant .md .md-code.is-scrollable-x > .md-code-body {
  --code-fade: color-mix(in srgb, var(--omni-bg-elevated) 92%, #000 8%);
}
.msg.assistant .md .md-code.is-scrollable-x.is-scroll-start > .md-code-body {
  box-shadow: inset -22px 0 16px -10px var(--code-fade);
}
.msg.assistant .md .md-code.is-scrollable-x.is-scroll-end > .md-code-body {
  box-shadow: inset 22px 0 16px -10px var(--code-fade);
}
.msg.assistant .md .md-code.is-scrollable-x.is-scroll-mid > .md-code-body {
  box-shadow:
    inset 22px 0 16px -10px var(--code-fade),
    inset -22px 0 16px -10px var(--code-fade);
}
/* Legacy bare <pre class="md-pre"> (if any) */
.msg.assistant .md > .md-pre {
  margin: 0.65em 0 1em;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: 12px;
  background: color-mix(in srgb, var(--omni-bg-elevated) 82%, #000 18%);
  border: 1px solid var(--omni-border);
  box-shadow: none;
}
.msg.assistant .md .md-code-body code,
.msg.assistant .md .md-pre code {
  padding: 0;
  background: transparent;
  color: #e6e1d8;
  font-family: var(--omni-font-mono);
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: pre;
  tab-size: 2;
}
.msg.assistant .md .md-math {
  margin: 0.7em 0;
  overflow-x: auto;
  padding: 0.15em 0;
}
.msg.assistant .md .katex {
  color: #f2f0eb;
  font-size: 1.08em;
}
.msg.assistant .md .katex-display {
  margin: 0.55em 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.msg.assistant .md .md-math-fallback,
.msg.assistant .md .md-math-pending {
  color: var(--omni-text-secondary);
  font-family: var(--omni-font-mono);
  font-size: 0.92em;
  background: transparent;
  padding: 0;
}

/* Pending status: Думаю / Рисую / Видео */
.status-msg {
  max-width: min(48rem, 100%);
  padding: 2px 0;
}
.status-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--omni-text-secondary);
  font: 600 0.95rem var(--omni-font-ui);
}
.status-lab {
  letter-spacing: 0.01em;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.status-phrase {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}
/* Светло-белый ↔ блекло-серый */
.status-shimmer {
  color: #f2f0eb;
  animation: status-pulse 1.55s ease-in-out infinite;
}
.status-dots {
  display: inline-block;
  min-width: 1.15em;
  text-align: left;
}
@keyframes status-pulse {
  0%, 100% { color: #f2f0eb; }
  50% { color: #6e6a64; }
}
.status-hint {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--omni-text-muted);
}
.status-ico {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--omni-accent);
}
.status-ico svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico-draw .draw-frame {
  opacity: 0.45;
}
.ico-draw .draw-stroke {
  fill: none;
  stroke-dasharray: 28;
  stroke-dashoffset: 28;
  animation: draw-stroke 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
.ico-draw .draw-brush {
  opacity: 0.85;
  animation: draw-brush 1.6s ease-in-out infinite;
}
.ico-draw .draw-tip {
  fill: currentColor;
  stroke: none;
  animation: draw-tip 1.6s ease-in-out infinite;
}
@keyframes draw-stroke {
  0% { stroke-dashoffset: 28; opacity: 0.25; }
  35% { stroke-dashoffset: 0; opacity: 1; }
  70% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: -4; opacity: 0.2; }
}
@keyframes draw-brush {
  0% { transform: translate(0, 0); }
  40% { transform: translate(2px, -2px); }
  100% { transform: translate(0, 0); }
}
@keyframes draw-tip {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.85; }
  40% { transform: translate(1.5px, -1.5px) scale(1.15); opacity: 1; }
}

.ico-think .think-d {
  fill: currentColor;
  stroke: none;
  animation: think-bounce 1.05s ease-in-out infinite;
}
.ico-think .d2 { animation-delay: 0.15s; }
.ico-think .d3 { animation-delay: 0.3s; }
@keyframes think-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.ico-video .vid-frame,
.ico-video .vid-play {
  animation: vid-pulse 1.4s ease-in-out infinite;
}
@keyframes vid-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ico-draw .draw-stroke,
  .ico-draw .draw-brush,
  .ico-draw .draw-tip,
  .ico-think .think-d,
  .ico-video .vid-frame,
  .ico-video .vid-play,
  .status-shimmer,
  .msg.msg-enter {
    animation: none !important;
  }
  .ico-draw .draw-stroke { stroke-dashoffset: 0; opacity: 1; }
  .status-shimmer { color: var(--omni-text-secondary); }
}
.msg.system {
  align-self: center;
  color: var(--omni-text-secondary);
  font-size: 0.85rem;
  padding: 2px 4px;
}
.msg .meta {
  margin-top: 8px;
  font-size: 0.72rem;
  font-family: var(--omni-font-mono);
  color: var(--omni-text-muted);
}
/* Product SoT: never show SERP «Источники» to the user (JS also no-ops). */
.msg .sources {
  display: none !important;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.msg .sources-title {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--omni-text-muted);
  margin-bottom: 6px;
}
.msg .sources-queries {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0 0 8px;
}
.msg .sources-query {
  font-size: 0.78rem;
  color: var(--omni-text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg .sources-query::before {
  content: "· ";
  opacity: 0.7;
}
.msg .sources ul {
  margin: 0;
  padding-left: 1.1em;
}
.msg .sources li {
  margin: 0.2em 0;
  font-size: 0.85rem;
  color: var(--omni-text-secondary);
}
.msg .sources a {
  color: var(--omni-accent);
  text-decoration: none;
}
.msg .sources a:hover {
  text-decoration: underline;
}
.msg-exports {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  margin-bottom: 0;
  width: 100%;
  max-width: 100%;
}
/* File card must not leave a tall empty preview shell when closed. */
.msg-artifact:not(.is-preview-open) .msg-artifact-preview {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}
.msg.assistant:has(> .msg-exports) {
  /* Keep deliverable turns tight — avoid a “dead floor” under the card. */
  margin-bottom: 0;
}
.msg-artifact {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0;
  border-radius: 16px;
  border: 1px solid var(--omni-border-strong);
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb, var(--omni-surface) 88%, transparent),
      color-mix(in srgb, var(--omni-bg-elevated) 94%, transparent)
    );
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.045) inset,
    0 8px 28px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.msg-artifact.is-preview-open {
  border-color: color-mix(in srgb, var(--omni-accent) 35%, var(--omni-border-strong));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 10px 32px rgba(0, 0, 0, 0.22);
}
.msg-artifact-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 14px;
  padding: 14px 16px;
}
.msg-artifact-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--omni-accent-dim) 70%, var(--omni-surface));
  color: var(--omni-accent-hover);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--omni-accent) 18%, transparent);
}
.msg-artifact-ico.is-csv {
  background: color-mix(in srgb, #3dba7a 22%, var(--omni-surface));
  color: #7dcea0;
  box-shadow: 0 0 0 1px color-mix(in srgb, #3dba7a 22%, transparent);
}
.msg-artifact-ico.is-docx {
  background: color-mix(in srgb, #5b8def 22%, var(--omni-surface));
  color: #9bb7f0;
  box-shadow: 0 0 0 1px color-mix(in srgb, #5b8def 22%, transparent);
}
.msg-artifact-ico.is-pptx {
  background: color-mix(in srgb, #e07a3a 22%, var(--omni-surface));
  color: #f0b089;
  box-shadow: 0 0 0 1px color-mix(in srgb, #e07a3a 22%, transparent);
}
.msg-artifact-ico.is-html {
  background: color-mix(in srgb, #5ec8c8 22%, var(--omni-surface));
  color: #8edede;
  box-shadow: 0 0 0 1px color-mix(in srgb, #5ec8c8 22%, transparent);
}
.msg-artifact-ico.is-py,
.msg-artifact-ico.is-js,
.msg-artifact-ico.is-ts,
.msg-artifact-ico.is-css,
.msg-artifact-ico.is-sh,
.msg-artifact-ico.is-txt {
  background: color-mix(in srgb, #8a7ec8 22%, var(--omni-surface));
  color: #b7aee0;
  box-shadow: 0 0 0 1px color-mix(in srgb, #8a7ec8 22%, transparent);
}
.msg-artifact-preview-html {
  display: block;
  width: 100%;
  min-height: 360px;
  height: min(70vh, 560px);
  border: 0;
  border-radius: 12px;
  background: #0e0d0c;
}
.html-build-status {
  margin: 0.85rem 0 0.15rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  font: 500 0.95rem/1.4 var(--omni-font-ui);
  color: #f2f0eb;
}
.html-build-status .html-build-word {
  white-space: nowrap;
}
.html-build-status .html-build-dots {
  min-width: 1.15em;
  text-align: left;
}
.msg-artifact-ico svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.msg-artifact-meta {
  min-width: 0;
}
.msg-artifact-name {
  font: 600 0.92rem/1.25 var(--omni-font-ui);
  color: var(--omni-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.msg-artifact-sub {
  margin-top: 3px;
  font: 500 0.72rem/1.3 var(--omni-font-ui);
  color: var(--omni-text-muted);
}
.msg-artifact-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.msg-artifact-preview-btn {
  appearance: none;
  border: 1px solid var(--omni-border-strong);
  border-radius: 12px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 0.8rem/1 var(--omni-font-ui);
  cursor: pointer;
  color: var(--omni-text-secondary);
  background: color-mix(in srgb, var(--omni-surface) 70%, transparent);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.msg-artifact-preview-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.msg-artifact-preview-btn:hover,
.msg-artifact.is-preview-open .msg-artifact-preview-btn {
  color: var(--omni-text);
  border-color: color-mix(in srgb, var(--omni-accent) 40%, var(--omni-border-strong));
  background: color-mix(in srgb, var(--omni-accent-dim) 45%, var(--omni-surface));
}
.msg-artifact-dl {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  min-width: 7.25rem;
  font: 600 0.84rem/1 var(--omni-font-ui);
  cursor: pointer;
  color: #1a1510;
  background: var(--omni-accent);
  transition: background 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.msg-artifact-dl:hover {
  background: var(--omni-accent-hover);
}
.msg-artifact-dl:disabled {
  opacity: 0.55;
  cursor: wait;
}
/* Compact preview — capped height, scrolls inside; no tall layout jump */
.msg-artifact-preview {
  border-top: 1px solid color-mix(in srgb, var(--omni-border-strong) 85%, transparent);
  background: color-mix(in srgb, #0c0b09 55%, var(--omni-bg-elevated));
  padding: 10px 12px 12px;
}
.msg-artifact-preview[hidden] {
  display: none !important;
}
.msg-artifact-preview-scroll {
  width: 100%;
  max-height: 9.75rem; /* ~156px — small window */
  overflow: auto;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--omni-border-strong) 80%, transparent);
  background: color-mix(in srgb, var(--omni-surface) 55%, #12110f);
  scrollbar-width: thin;
  box-sizing: border-box;
}
.msg-artifact-preview-table-wrap {
  width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
}
.msg-artifact-preview-table {
  width: 100%;
  min-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font: 500 0.72rem/1.35 var(--omni-font-ui);
  color: var(--omni-text);
}
.msg-artifact-preview-table th,
.msg-artifact-preview-table td {
  padding: 6px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--omni-border) 90%, transparent);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-artifact-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--omni-accent) 22%, #1a1713);
  color: #f4efe6;
  font-weight: 700;
}
.msg-artifact-preview-table td:first-child {
  font-weight: 600;
  color: #f0ebe3;
}
.msg-artifact-preview-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, #ffffff 3%, transparent);
}
.msg-artifact-preview-more {
  padding: 6px 10px 8px;
  font: 500 0.68rem/1.3 var(--omni-font-ui);
  color: var(--omni-text-muted);
}
.msg-artifact-preview-sep {
  height: 8px;
  background: color-mix(in srgb, var(--omni-border) 50%, transparent);
}
.msg-artifact-preview-prose {
  max-height: 9.75rem;
  overflow: auto;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--omni-border-strong) 80%, transparent);
  background: color-mix(in srgb, var(--omni-surface) 55%, #12110f);
  font: 500 0.78rem/1.45 var(--omni-font-ui);
  color: var(--omni-text-secondary);
  white-space: pre-wrap;
  scrollbar-width: thin;
}
@media (max-width: 520px) {
  .msg-artifact-head {
    grid-template-columns: 40px minmax(0, 1fr);
  }
  .msg-artifact-actions {
    grid-column: 1 / -1;
    width: 100%;
  }
  .msg-artifact-preview-btn,
  .msg-artifact-dl {
    flex: 1 1 0;
    justify-content: center;
    min-width: 0;
  }
}
.msg-attach-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.msg-attach-frame img {
  display: block;
  max-width: 100%;
}
.msg-img-dl {
  appearance: none;
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: #f4f4f5;
  background: rgba(0, 0, 0, 0.55);
  transition: background 0.15s ease;
}
.msg-img-dl:hover {
  background: rgba(0, 0, 0, 0.72);
}
.msg-img-dl svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.msg .sources-num {
  color: var(--omni-text-muted);
  margin-right: 0.35em;
  font-variant-numeric: tabular-nums;
}
.msg .sources-host {
  display: block;
  font-size: 0.72rem;
  color: var(--omni-text-muted);
  margin-top: 0.1em;
  opacity: 0.85;
}
.msg-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.msg-actions-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
/* Copy / share / voice-out stay a tight left cluster; «Проговорить» stays right. */
.msg-actions-tools {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}
.msg-action {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--omni-text-muted);
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: color 0.15s ease, background 0.15s ease;
}
.msg-action svg {
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.msg-action:hover {
  color: var(--omni-accent-hover);
  background: rgba(255, 255, 255, 0.05);
}
.msg-action.is-on {
  color: var(--omni-accent-hover);
  background: var(--omni-accent-dim);
}
.msg-action.is-on:hover {
  background: rgba(212, 137, 58, 0.28);
}
.msg-action:disabled {
  opacity: 0.5;
  cursor: wait;
}
/* Replay TTS for this answer — visible while voice-out is on. */
.msg-action-speak {
  appearance: none;
  margin-left: auto;
  flex: 0 1 auto;
  max-width: min(52vw, 11rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  background: transparent;
  color: var(--omni-accent-hover);
  font: 500 0.8rem/1.2 var(--omni-font-ui);
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}
.msg-action-speak:hover {
  background: var(--omni-accent-dim);
}
/* Held/pressed look while answer streams or TTS is already playing. */
.msg-action-speak:active,
.msg-action-speak.is-pressed {
  color: color-mix(in srgb, var(--omni-accent-hover) 55%, #1a1612);
  background: rgba(0, 0, 0, 0.38);
  filter: brightness(0.72);
  opacity: 0.78;
}
.msg-action-speak:disabled {
  cursor: wait;
}
.msg-action-speak[hidden] {
  display: none !important;
}
/* Copy/share feedback: centered under the icon row. */
.msg-action-hint {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: #5dca7a;
  font: 500 0.8rem/1.2 var(--omni-font-ui);
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(3px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.msg-action-hint.is-on {
  opacity: 1;
  transform: translateY(0);
}
.msg-action-hint.is-err {
  color: #e08a7a;
}
.msg-error {
  margin-top: 10px;
  color: var(--omni-text-muted);
  font: 500 0.82rem var(--omni-font-ui);
}
/* Cursor-like pause: no card/outline frame around unfinished answers. */
.msg.is-paused {
  outline: none;
  border: none;
  box-shadow: none;
}
.msg-paused {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 0;
  border: none;
}
.msg-paused-note {
  color: var(--omni-text-muted, #9a9690);
  font: 500 0.8rem var(--omni-font-ui, Onest, system-ui, sans-serif);
}
.msg-paused-note.soft-finish {
  margin-top: 4px;
  font-style: italic;
  opacity: 0.85;
}
.msg-paused-continue {
  appearance: none;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--omni-accent, #d4893a);
  font: 600 0.8rem var(--omni-font-ui, Onest, system-ui, sans-serif);
  padding: 2px 4px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}
.msg-paused-continue:hover {
  color: var(--omni-accent-hover, #e09a4a);
  background: transparent;
}
.omni-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 80;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(40, 34, 28, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--omni-text);
  font: 500 0.85rem var(--omni-font-ui);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.omni-toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.msg img, .msg video {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  margin-top: 10px;
}

.composer-queue {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.composer-queue[hidden] {
  display: none !important;
}
/* Dock gap is ~12px; pull composer up so queue↔input is ~half of before. */
.composer-queue:not([hidden]) + .composer {
  margin-top: -6px;
}
.composer-attach {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  /* left 0 — align photo chip with composer-plus in .composer-main */
  padding: 8px 6px 10px 0;
  width: 100%;
  box-sizing: border-box;
  grid-column: 1 / -1;
}
.composer-attach[hidden] {
  display: none !important;
}
.composer-attach-chip {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  flex: none;
}
.composer-attach-chip.is-photo {
  width: 52px;
  height: 52px;
}
.composer-attach-chip.is-file {
  /* Full landing/composer width — narrow chips look like a weak upload block */
  width: 100%;
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
  height: auto;
  min-height: 56px;
  padding: 12px 36px 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: visible;
  box-sizing: border-box;
  border-radius: 16px;
  border-color: var(--omni-border-strong, rgba(255, 255, 255, 0.12));
}
.composer-attach-chip img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.composer-attach-file-ico {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--omni-text-secondary, #b9b3a8);
  font: 700 0.68rem/1 var(--omni-font-ui);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.composer-attach-file-meta {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.composer-attach-file-name {
  font: 600 0.78rem/1.25 var(--omni-font-ui);
  color: var(--omni-text, #f2eee6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.composer-attach-file-sub {
  font: 500 0.68rem/1.2 var(--omni-font-ui);
  color: var(--omni-text-secondary, #b9b3a8);
}
.composer-attach-chip.is-large {
  min-width: 0;
  max-width: 100%;
  min-height: 60px;
}
.composer-attach-chip.is-large.is-indexing .composer-attach-file-sub,
.composer-attach-chip.is-large.is-uploading .composer-attach-file-sub {
  color: #e8c27a;
}
.composer-attach-chip.is-large.is-error .composer-attach-file-sub {
  color: #e8a0a0;
}
.composer-attach-chip.is-large.is-ready .composer-attach-file-sub {
  color: #9dceb0;
}
.composer-attach-del {
  appearance: none;
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font: 700 0.78rem/1 var(--omni-font-ui);
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 2;
}
.composer-attach-del:hover {
  background: rgba(0, 0, 0, 0.88);
}
.msg .msg-attach {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.msg .msg-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(320px, 85vw);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}
.msg .msg-file-ext {
  flex: none;
  min-width: 36px;
  padding: 4px 6px;
  border-radius: 8px;
  text-align: center;
  font: 700 0.62rem/1 var(--omni-font-ui);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--omni-text-secondary, #b9b3a8);
  background: rgba(255, 255, 255, 0.06);
}
.msg .msg-file-name {
  min-width: 0;
  font: 600 0.8rem/1.25 var(--omni-font-ui);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg .msg-attach img {
  display: block;
  max-width: min(420px, 85vw);
  max-height: 360px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  object-fit: cover;
}
.msg.user .msg-attach img {
  max-width: min(220px, 70vw);
  max-height: 160px;
}
.msg .msg-attach-caption {
  white-space: pre-wrap;
  word-break: break-word;
}
.composer-queue-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--omni-radius-lg);
  background: color-mix(in srgb, var(--omni-surface) 88%, rgba(255, 255, 255, 0.04));
  color: var(--omni-text-secondary, #c9c4bb);
  font: 550 0.82rem/1.35 var(--omni-font-ui);
}
.composer-queue-badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--omni-text-muted, #9a958c);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.composer-queue-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--omni-text, #f2f0eb);
}
.composer-queue-del {
  appearance: none;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--omni-text-muted, #9a958c);
  cursor: pointer;
}
.composer-queue-del:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.composer-queue-del svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.composer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 6px;
  border: 1px solid var(--omni-border);
  border-radius: var(--omni-radius-lg);
  background: var(--omni-surface);
  overflow: visible;
}
.composer:has(.composer-attach:not([hidden])) {
  padding-top: 4px;
}
.composer-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-width: 0;
}
.composer-main > input[type="file"] {
  display: none !important;
}
.composer-main > .composer-plus-wrap {
  grid-column: 1;
  grid-row: 1;
}
.composer-main > textarea,
.composer-main > .composer-voice {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}
.composer-main > .composer-send-wrap {
  grid-column: 3;
  grid-row: 1;
  position: relative;
  flex-shrink: 0;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.voice-hold-tip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 50;
  padding: 10px 14px;
  border-radius: var(--omni-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--omni-bg-elevated);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  color: var(--omni-text);
  font: 600 0.92rem/1.2 var(--omni-font-ui);
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
}
.voice-hold-tip[hidden] {
  display: none !important;
}
.composer-shell > .composer-queue:not([hidden]) {
  margin-bottom: 8px;
}
.composer-plus-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 40;
}
.composer-plus {
  appearance: none;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--omni-border);
  border-radius: var(--omni-radius-pill);
  background: transparent;
  color: var(--omni-text);
  line-height: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.composer-plus-ico {
  display: block;
  flex-shrink: 0;
}
.composer-plus:hover,
.composer-plus[aria-expanded="true"] {
  border-color: var(--omni-accent-line);
  color: var(--omni-accent-hover);
  background: var(--omni-accent-dim);
}
.composer-plus:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--omni-accent) 75%, transparent);
  outline-offset: 2px;
}
.plus-menu {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  z-index: 50;
  min-width: max(100%, 200px);
  width: max-content;
  padding: 6px;
  border-radius: var(--omni-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--omni-bg-elevated);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}
.plus-menu:not([hidden]) { display: block; }
.plus-menu[hidden] { display: none !important; }
.plus-item {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--omni-radius);
  background: transparent;
  color: var(--omni-text);
  font: 600 0.92rem/1.2 var(--omni-font-ui);
  text-align: left;
  cursor: pointer;
}
.plus-item:hover { background: rgba(255, 255, 255, 0.06); }
.plus-item--gated { color: var(--omni-text-secondary); font-weight: 500; font-size: 0.88rem; }
.plus-ico {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}
.plus-ico svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.plus-sep {
  height: 1px;
  margin: 6px 8px;
  background: rgba(255, 255, 255, 0.08);
}
.plus-hint {
  margin: 2px 12px 6px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--omni-text-muted);
}
.composer textarea {
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--omni-text);
  font: 500 0.95rem/1.35 var(--omni-font-ui);
  max-height: 120px;
  min-height: 22px;
  padding: 6px 2px;
}
.composer textarea::placeholder { color: var(--omni-text-muted); }
.send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--omni-accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.08s ease;
}
.send svg {
  width: 16px;
  height: 16px;
  display: block;
}
.send:hover { background: var(--omni-accent-hover); }
.send:active { transform: scale(0.96); }
.send:disabled {
  opacity: 0.45;
  cursor: wait;
}
.send.is-stop {
  cursor: pointer;
  opacity: 1;
}
.send.is-stop:hover {
  background: #a35a3a;
}
.send.is-stop svg {
  width: 12px;
  height: 12px;
}
.send.is-locked {
  background: var(--omni-bg-elevated, #2a2a2a);
  color: var(--omni-text-secondary, #c8c8c8);
  border: 1px solid var(--omni-border, rgba(255, 255, 255, 0.14));
  cursor: pointer;
  opacity: 1;
}
.send.is-locked:hover {
  background: var(--omni-bg-elevated, #333);
  color: var(--omni-text, #fff);
}
.send.is-voice {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.send.is-voice-rec {
  background: var(--omni-accent-hover);
  transform: scale(1.04);
}
.send.is-voice-busy {
  opacity: 0.7;
  cursor: wait;
}
.send .send-wave {
  width: 18px;
  height: 18px;
  display: block;
}
.send .send-wave-bar {
  transform-origin: center;
}
.composer-main.is-voice-ui textarea {
  display: none !important;
}
.composer-voice {
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  min-height: 36px;
  padding: 0 2px;
}
.composer-main.is-voice-ui .composer-voice {
  display: flex;
}
.composer-voice[hidden] {
  display: none !important;
}
.composer-voice-clear {
  appearance: none;
  flex: none;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--omni-text-secondary);
  cursor: pointer;
}
.composer-voice-clear svg {
  width: 16px;
  height: 16px;
  display: block;
}
.composer-voice-clear:hover {
  color: var(--omni-text);
  background: rgba(255, 255, 255, 0.06);
}
.composer-voice.is-recording .composer-voice-clear {
  visibility: hidden;
  pointer-events: none;
}
.composer-voice-track {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  border-radius: var(--omni-radius-pill);
  background: rgba(212, 137, 58, 0.12);
  border: 1px solid rgba(212, 137, 58, 0.28);
  overflow: hidden;
  display: flex;
  align-items: center;
}
.composer-voice-wave {
  display: block;
  width: 100%;
  height: 36px;
}
.composer-voice-play {
  appearance: none;
  flex: none;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--omni-accent-dim);
  color: var(--omni-accent-hover);
  cursor: pointer;
}
.composer-voice-play svg {
  width: 14px;
  height: 14px;
  display: block;
}
.composer-voice-play:hover {
  background: rgba(212, 137, 58, 0.28);
}
.composer-voice-play[hidden] {
  display: none !important;
}
.composer-voice-time {
  flex: none;
  min-width: 2.4em;
  font: 600 0.82rem/1 var(--omni-font-mono);
  color: var(--omni-accent-hover);
  letter-spacing: 0.02em;
  text-align: right;
}
.composer-voice.is-recording .composer-voice-time {
  color: var(--omni-text);
}
.guest-limit[hidden] {
  display: none !important;
}

@media (min-width: 921px) {
  .app-frame {
    /* Full remaining width after the fixed rail — scrollbar at the viewport right. */
    margin-left: var(--sidebar-collapsed-w);
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    grid-template-rows: 1fr;
    transition: margin-left var(--sidebar-motion-dur) var(--sidebar-motion-ease);
  }
  .app-frame.is-empty {
    margin-left: var(--sidebar-collapsed-w);
  }
  /* Keep content put — expanded rail overlays + dims; do not push the frame. */
  .app-shell:has(.app-sidebar:is(:hover, .app-sidebar--expanded)) .app-frame,
  body.is-side-open .app-frame,
  .app-shell:has(.app-sidebar:is(:hover, .app-sidebar--expanded)) .app-frame.is-empty,
  body.is-side-open .app-frame.is-empty {
    margin-left: var(--sidebar-collapsed-w);
  }
  .topbar { display: none !important; }
  .app-shell-dim { display: none !important; }
  .side-burger { display: none !important; }
  /* Desktop has no .topbar — mirror .dock::before wash at the top edge. */
  .app-frame::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 20px;
    pointer-events: none;
    z-index: 6;
    background: linear-gradient(
      to bottom,
      var(--omni-bg) 0%,
      color-mix(in srgb, var(--omni-bg) 72%, transparent) 48%,
      transparent 100%
    );
  }
}

@media (max-width: 920px) {
  .topbar {
    --omni-chrome-top: max(10px, env(safe-area-inset-top, 0px));
    --omni-chrome-x: max(12px, env(safe-area-inset-left, 0px));
    --omni-chrome-btn: 36px;
    position: relative;
    z-index: 50;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    min-height: calc(var(--omni-chrome-top) + var(--omni-chrome-btn) + 10px);
    padding: var(--omni-chrome-top) max(12px, env(safe-area-inset-right, 0px)) 10px var(--omni-chrome-x);
    /* Same canvas as page — no surface plate / hard border (looked like a crutch). */
    background: var(--omni-bg);
    border: 0;
    box-shadow: none;
  }
  /* Mirror .dock::before: soft bg wash into content, not a card drop-shadow. */
  .topbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 20px;
    pointer-events: none;
    z-index: 6;
    background: linear-gradient(
      to bottom,
      var(--omni-bg) 0%,
      color-mix(in srgb, var(--omni-bg) 72%, transparent) 48%,
      transparent 100%
    );
  }
  .side-burger {
    display: inline-flex;
    position: relative;
    top: auto;
    left: auto;
    z-index: 1;
    width: var(--omni-chrome-btn, 36px);
    height: var(--omni-chrome-btn, 36px);
    box-sizing: border-box;
    border: 0;
    background: transparent;
  }
  body.is-side-open .topbar {
    /* Keep layout, but never paint over the open drawer / logo. */
    z-index: 40;
    pointer-events: none;
  }
  body.is-side-open .topbar .side-burger {
    opacity: 0;
    visibility: hidden;
  }
  .btn-login {
    /* Match .topbar chrome row so burger ↔ avatar share one baseline */
    top: max(10px, env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    width: auto;
    height: var(--omni-chrome-btn, 36px);
    padding: 0 15px;
    box-sizing: border-box;
  }
  .btn-login.is-profile {
    width: var(--omni-chrome-btn, 36px);
    height: var(--omni-chrome-btn, 36px);
    padding: 0;
  }
  .app-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-expanded-w) - 8px));
    width: var(--sidebar-expanded-w);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
    padding-left: max(var(--sidebar-rail-pad), env(safe-area-inset-left, 0px));
  }
  body.is-side-open .app-sidebar {
    display: flex;
    transform: translateX(0);
    filter: drop-shadow(10px 0 22px rgba(0, 0, 0, 0.38));
  }
  /* Drawer: stack Job/API under history — do not pin to viewport bottom (empty void). */
  body.is-side-open .app-sidebar .side-nav-end {
    margin-top: 12px;
  }
  body.is-side-open .app-sidebar .side-brand { column-gap: 12px; }
  body.is-side-open .app-sidebar .side-brand-logo {
    clip-path: circle(72% at 50% 50%);
  }
  body.is-side-open .app-sidebar .side-brand-name,
  body.is-side-open .app-sidebar .side-nav-lab {
    max-width: 140px;
    opacity: 1;
  }
  body.is-side-open .app-sidebar .side-nav button,
  body.is-side-open .app-sidebar .side-nav-link,
  body.is-side-open .app-sidebar .side-foot .side-nav-link {
    column-gap: 10px;
  }

  .app-shell {
    width: 100%;
    max-width: 100%;
    /* clip keeps x contained without forcing y=auto (which ate topbar box-shadow) */
    overflow-x: clip;
  }
  .app-frame {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: clip;
    /* Top chrome lives in .topbar (bg + shadow); no extra frame pad above it. */
    padding: 0 0 12px;
    /* Bottom safe-area only when keyboard is closed — kb-inset handles open state. */
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }
  html.is-keyboard-open .app-frame {
    padding-bottom: 8px;
  }
  .app-frame.is-empty {
    max-width: 100%;
    padding-inline: 16px;
  }
  /* Keep header full-bleed over empty-state side gutters */
  .app-frame.is-empty .topbar {
    width: calc(100% + 32px);
    margin-inline: -16px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .app-frame:not(.is-empty) .thread {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .app-frame:not(.is-empty) .dock {
    width: calc(100% - 32px);
    max-width: calc(100% - 32px);
  }

  /* Landing: one centered column — hero → params → composer → chips */
  .app-frame.is-empty .stage {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0;
    padding-bottom: 0;
    min-width: 0;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  .app-frame.is-empty .hero-title {
    margin: 0 0 22px;
    font-size: clamp(1.55rem, 7.2vw, 1.95rem);
    line-height: 1.15;
    width: 100%;
    max-width: 100%;
    text-align: center;
  }
  .app-frame.is-empty .dock {
    width: 100%;
    max-width: 100%;
    margin: 0;
    gap: var(--landing-stack-gap);
    min-width: 0;
    align-items: center;
  }
  /* controls === composer-tabs-wrap in DOM — keep a full-width centering row */
  .app-frame.is-empty .controls,
  .app-frame.is-empty .controls.composer-tabs-wrap {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
  }
  .app-frame.is-empty .controls::before,
  .app-frame.is-empty .controls::after {
    display: none !important;
    opacity: 0 !important;
  }
  .app-frame.is-empty .modes,
  .app-frame.is-empty .modes.params-bar,
  .app-frame.is-empty .modes.composer-tabs,
  .app-frame.is-empty .modes:has(> .param-chip) {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: max-content;
    max-width: 100%;
    min-width: 0;
    margin-inline: auto;
    padding: 0 !important;
    overflow: visible !important;
    background: none !important;
    box-shadow: none !important;
    filter: none !important;
  }
  /* Params bar: never reintroduce the scrollport tray on mobile. */
  .modes.params-bar,
  .modes:has(> .param-chip) {
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    padding: 0 !important;
    justify-content: center;
    width: max-content;
    max-width: 100%;
    margin-inline: auto;
    background: none !important;
    box-shadow: none !important;
    filter: none !important;
  }
  .app-frame.is-empty .composer-shell,
  .app-frame.is-empty .composer,
  .app-frame.is-empty .suggestions {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    box-sizing: border-box;
  }
  .app-frame.is-empty .composer {
    padding: 8px;
    border-radius: 22px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.04) inset,
      0 10px 24px -8px rgba(0, 0, 0, 0.34);
  }
  .app-frame.is-empty .suggestions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
    gap: 10px;
  }
  .app-frame.is-empty .chip {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 12px 16px;
    font-size: 0.88rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: color-mix(in srgb, var(--omni-surface) 88%, transparent);
  }

  /* Mode rail: edge fades hint horizontal scroll */
  .controls {
    position: relative;
    /* isolation:isolate made filtered/overflow children paint a plate; keep auto */
    isolation: auto;
  }
  .controls:has(.mode-cluster.params-only) {
    isolation: auto;
    background: transparent !important;
  }
  .controls::before,
  .controls::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 4px;
    width: 36px;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  .controls::before {
    left: 0;
    background: linear-gradient(
      90deg,
      var(--omni-bg) 0%,
      color-mix(in srgb, var(--omni-bg) 70%, transparent) 55%,
      transparent 100%
    );
  }
  .controls::after {
    right: 0;
    background: linear-gradient(
      270deg,
      var(--omni-bg) 0%,
      color-mix(in srgb, var(--omni-bg) 70%, transparent) 55%,
      transparent 100%
    );
  }
  .controls.can-scroll-left::before,
  .controls.can-scroll-right::after {
    opacity: 1;
  }
  .mode {
    height: 38px;
    padding: 0 13px;
    gap: 7px;
  }
  .mode-lab {
    letter-spacing: 0.01em;
  }

  /* Active chat: dock sits on the bottom with lift */
  .app-frame:not(.is-empty) .stage {
    grid-template-rows: 1fr auto;
    gap: 0;
    min-height: 0;
  }
  .app-frame:not(.is-empty) .thread {
    /* Keep last lines above modes+composer; gutters keep text column centered */
    padding: 14px max(16px, calc((100% - var(--chat-col-w)) / 2)) 18px;
    scroll-padding-bottom: 24px;
  }
  .app-frame:not(.is-empty) .dock {
    position: relative;
    z-index: 5;
    gap: 12px;
    padding-top: 10px;
    width: min(var(--chat-col-w), calc(100% - 32px));
    max-width: min(var(--chat-col-w), calc(100% - 32px));
    min-width: 0;
    flex-shrink: 0;
    overflow: visible;
    /* No full-dock wash under chips; upward scroll fade is ::before above dock. */
    background: none !important;
    background-image: none !important;
    box-shadow: none !important;
  }
  .app-frame:not(.is-empty) .dock > .composer-tabs-wrap {
    margin-bottom: calc(4px - 12px);
  }
  .app-frame:not(.is-empty) .controls {
    margin-bottom: 0;
  }
  .app-frame:not(.is-empty) .composer {
    border-radius: 22px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.04) inset,
      0 12px 28px -8px rgba(0, 0, 0, 0.4);
  }
  .dock.is-settling {
    will-change: transform;
  }

  .plus-menu {
    left: 0;
    right: auto;
    transform: none;
    bottom: calc(100% + 14px);
    min-width: 200px;
    max-height: min(52vh, 320px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  }
  /* OSK up: keep menu above dock, compress into remaining vv height. */
  .plus-menu.is-kb-open,
  html.is-keyboard-open .plus-menu:not([hidden]) {
    bottom: calc(100% + 10px);
    max-height: min(36vh, calc(var(--vv-height, 100dvh) - var(--kb-lift, 0px) - 120px));
  }
  .composer-plus,
  .send {
    width: 40px;
    height: 40px;
  }
  /* iOS Safari zooms focused fields under 16px — force px, not rem. */
  .composer textarea {
    font-size: 16px;
    line-height: 1.35;
    padding: 8px 4px;
  }
  .ticket-input,
  .ticket-textarea {
    font-size: 16px;
  }
  /* Long URLs / unbroken tokens must not widen the thread. */
  .msg.assistant .md,
  .msg.user {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .thread {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
  .msg.assistant .md .md-code-copy {
    width: 44px;
    height: 44px;
  }
  .consent {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }
  .consent-actions {
    width: 100%;
  }
  .consent-actions .btn-ghost,
  .consent-actions .btn-solid {
    flex: 1 1 auto;
    text-align: center;
  }
  .omni-toast {
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    left: 16px;
    right: 16px;
    transform: translateY(12px);
    width: auto;
  }
  .omni-toast.is-on {
    transform: translateY(0);
  }

  /*
   * Keyboard open: pin the shell to the visual viewport (OmniKeyboardAssist
   * sets --vv-top/--vv-height + html.is-kb-vv-pin). That keeps the dock inside
   * the visible area. Do NOT also translateY(--kb-lift) — on iOS Safari the
   * layout often already shrank, and a second lift pushes the composer off-screen.
   */
  html.is-kb-vv-pin .app-shell {
    top: var(--vv-top, 0px);
    height: var(--vv-height, 100%);
    max-height: var(--vv-height, 100%);
    bottom: auto;
  }
  html.is-keyboard-open .dock,
  html.is-kb-field-focused .dock,
  html.is-keyboard-open .dock.is-settling,
  html.is-kb-field-focused .dock.is-settling {
    transform: none !important;
    transition: none !important;
  }
  /* Fallback only when visualViewport pin is unavailable. */
  html.is-keyboard-open:not(.is-kb-vv-pin) .dock,
  html.is-kb-field-focused:not(.is-kb-vv-pin) .dock,
  html.is-keyboard-open:not(.is-kb-vv-pin) .dock.is-settling,
  html.is-kb-field-focused:not(.is-kb-vv-pin) .dock.is-settling {
    transform: translateY(calc(-1 * var(--kb-lift, 0px))) !important;
  }
  /* display:none — visibility:hidden left a dead hole and made the dock jump. */
  html.is-keyboard-open .app-frame.is-empty .hero-title,
  html.is-keyboard-open .app-frame.is-empty .suggestions {
    display: none !important;
  }
  /* Avoid empty centered hole while hero is hidden. */
  html.is-keyboard-open .app-frame.is-empty .stage {
    justify-content: flex-end;
  }
  html.is-keyboard-open .btn-login,
  html.is-keyboard-open .ticket-fab {
    opacity: 0;
    pointer-events: none;
  }
  html.is-keyboard-open .omni-toast {
    bottom: calc(12px + var(--kb-lift, 0px));
  }
  /* Do NOT mutate thread padding when OSK opens — that reflows messages (jumps).
     Dock lifts via transform only; scroll-padding stays stable via --dock-pad. */
  .app-frame:not(.is-empty) .thread {
    scroll-padding-bottom: max(24px, var(--dock-pad, 96px));
    padding-bottom: 18px;
  }

  /* HTML artifact iframe — shrink under OSK so preview + dock both fit. */
  .msg-artifact-preview-html {
    height: min(42vh, 360px);
    min-height: 180px;
  }
  html.is-keyboard-open .msg-artifact-preview-html {
    height: min(28vh, 240px);
    min-height: 120px;
  }

  /* Tables on narrow screens */
  .msg.assistant .md .md-table-wrap {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .msg.assistant .md .md-table {
    font-size: 0.86rem;
  }
  .msg.assistant .md .md-table th,
  .msg.assistant .md .md-table td {
    padding: 0.5em 0.75em;
  }
  .msg.assistant .md .md-table.md-table--wide th,
  .msg.assistant .md .md-table.md-table--wide td {
    min-width: 9rem;
  }
  .msg.assistant .md .md-table.md-table--wide th:first-child,
  .msg.assistant .md .md-table.md-table--wide td:first-child {
    white-space: nowrap;
    word-break: keep-all;
  }
  .msg.assistant .md .md-table.md-table--fit th,
  .msg.assistant .md .md-table.md-table--fit td {
    min-width: 0;
    white-space: normal;
  }
}

/* Telegram in-app browser: tighter chrome, no bounce, no animated dock settle. */
html.is-tg-browser,
html.is-tg-browser body {
  touch-action: manipulation;
}
html.is-tg-browser .app-shell {
  /* Shell is vv-pinned — no extra kb pad (was double-shrinking the dock). */
  padding-bottom: 0;
}
html.is-tg-browser .dock.is-settling {
  transition: none !important;
  transform: none !important;
}
/* TG: same vv-pin policy — no transform lift when shell is vv-pinned. */
html.is-tg-browser.is-keyboard-open .dock,
html.is-tg-browser.is-keyboard-open .dock.is-settling,
html.is-tg-browser.is-kb-field-focused .dock,
html.is-tg-browser.is-kb-field-focused .dock.is-settling {
  transform: none !important;
  transition: none !important;
}
html.is-tg-browser.is-keyboard-open:not(.is-kb-vv-pin) .dock,
html.is-tg-browser.is-keyboard-open:not(.is-kb-vv-pin) .dock.is-settling,
html.is-tg-browser.is-kb-field-focused:not(.is-kb-vv-pin) .dock,
html.is-tg-browser.is-kb-field-focused:not(.is-kb-vv-pin) .dock.is-settling {
  transform: translateY(calc(-1 * var(--kb-lift, 0px))) !important;
}
html.is-tg-browser.is-keyboard-open .app-frame.is-empty .controls {
  display: none;
}
html.is-tg-browser.is-keyboard-open .app-frame.is-empty .hero-title {
  display: none;
}
/* 16px already set for all mobile composers; keep TG explicit. */
html.is-tg-browser .composer textarea {
  font-size: 16px;
}

@media (max-width: 920px) and (prefers-reduced-motion: reduce) {
  .dock.is-settling {
    transition: none !important;
    transform: none !important;
  }
  /* vv-pin / lift policy still wins under reduced-motion. */
  html.is-keyboard-open .dock,
  html.is-keyboard-open .dock.is-settling,
  html.is-kb-field-focused .dock,
  html.is-kb-field-focused .dock.is-settling {
    transform: none !important;
  }
  html.is-keyboard-open:not(.is-kb-vv-pin) .dock,
  html.is-keyboard-open:not(.is-kb-vv-pin) .dock.is-settling,
  html.is-kb-field-focused:not(.is-kb-vv-pin) .dock,
  html.is-kb-field-focused:not(.is-kb-vv-pin) .dock.is-settling {
    transform: translateY(calc(-1 * var(--kb-lift, 0px))) !important;
  }
}

/* ---- Shared / ticket landing (/c/{id}) — bare page, no personal shell ---- */
html.is-share .ticket-fab,
body.is-share .ticket-fab,
html.is-share .btn-login,
body.is-share .btn-login,
html.is-share .app-sidebar,
body.is-share .app-sidebar,
html.is-share .topbar,
body.is-share .topbar,
html.is-share .app-shell-dim,
body.is-share .app-shell-dim,
html.is-share #chatThreads,
body.is-share #chatThreads,
html.is-share .side-history,
body.is-share .side-history {
  display: none !important;
}
html.is-share .composer-tabs-wrap,
body.is-share .composer-tabs-wrap,
html.is-share .composer-shell,
body.is-share .composer-shell,
html.is-share .suggestions,
body.is-share .suggestions,
html.is-share .consent,
body.is-share .consent,
html.is-share .hero-title,
body.is-share .hero-title,
html.is-share .dock,
body.is-share .dock {
  display: none !important;
}
html.is-share .app-shell,
body.is-share .app-shell {
  display: block;
}
html.is-share .app-frame,
body.is-share .app-frame {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  box-sizing: border-box;
}
.share-landing {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  margin: 0 0 18px;
}
html.is-share .share-landing,
body.is-share .share-landing {
  display: flex;
}
.share-landing[hidden] {
  display: none !important;
}
html.is-share .share-landing:not([hidden]),
body.is-share .share-landing:not([hidden]) {
  display: flex;
}
.share-landing__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  text-decoration: none;
  color: var(--omni-text, #f2f0eb);
}
.share-landing__logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: block;
}
.share-landing__brand-name {
  font: 700 1.05rem/1 var(--omni-font-ui, Onest, system-ui, sans-serif);
  letter-spacing: 0.04em;
}
.share-landing__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(138, 134, 128, 0.35);
  background: rgba(18, 16, 14, 0.72);
}
.share-landing__title {
  font: 700 0.95rem/1.25 var(--omni-font-ui, Onest, system-ui, sans-serif);
  color: var(--omni-text, #f2f0eb);
}
.share-landing__cta {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 999px;
  background: #f2f0eb;
  color: #14110e;
  font: 700 0.82rem var(--omni-font-ui, Onest, system-ui, sans-serif);
  text-decoration: none;
  white-space: nowrap;
}
.share-landing__cta:hover {
  background: #fff;
}

/* ---- Feedback ticket FAB + panel (logged-in only) ---- */
.ticket-fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  z-index: 60;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--omni-accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, opacity 0.15s ease;
}
.ticket-fab:hover {
  background: var(--omni-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
}
.ticket-fab:active { transform: translateY(0); }
.ticket-fab[hidden] { display: none !important; }

/* Mobile: top chrome — just left of the avatar (not over the composer). */
@media (max-width: 920px) {
  .ticket-fab {
    --ticket-chrome: 36px;
    top: max(10px, env(safe-area-inset-top, 0px));
    right: calc(
      max(12px, env(safe-area-inset-right, 0px)) + var(--ticket-chrome) + 8px
    );
    bottom: auto;
    width: var(--ticket-chrome);
    height: var(--ticket-chrome);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
  }
  .ticket-fab:hover,
  .ticket-fab:active {
    transform: none;
  }
  /* Typing: fade with other chrome — field needs the focus. */
  html.is-keyboard-open .ticket-fab {
    opacity: 0;
    pointer-events: none;
  }
}

.ticket-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 16px;
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}
.ticket-layer[hidden] { display: none !important; }

.ticket-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.52);
  cursor: pointer;
}

.ticket-panel {
  position: relative;
  z-index: 1;
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100dvh - 32px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(180deg, #221f1a 0%, #191612 100%);
  border: 1px solid rgba(138, 134, 128, 0.28);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  color: var(--omni-text, #f2f0eb);
}

.ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(138, 134, 128, 0.22);
  background: rgba(255, 255, 255, 0.03);
}
.ticket-title {
  margin: 0;
  font: 700 0.98rem/1.2 var(--omni-font-display, Geologica, system-ui, sans-serif);
  letter-spacing: 0.02em;
}
.ticket-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--omni-text-secondary, #9a9690);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.ticket-close:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.ticket-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 16px;
  min-height: 0;
  flex: 1;
}
.ticket-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ticket-field--grow { flex: 1; min-height: 0; }
.ticket-lab {
  color: rgb(92, 90, 86);
  font: 600 0.78rem/1.2 var(--omni-font-ui, Onest, system-ui, sans-serif);
  letter-spacing: 0.01em;
}

.ticket-input,
.ticket-textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(138, 134, 128, 0.32);
  background: rgba(10, 9, 8, 0.55);
  color: var(--omni-text, #f2f0eb);
  font: 500 0.92rem/1.4 var(--omni-font-ui, Onest, system-ui, sans-serif);
  padding: 0.72rem 0.85rem;
  outline: none;
}
.ticket-textarea {
  resize: none;
  min-height: 120px;
  flex: 1;
}
.ticket-input::placeholder,
.ticket-textarea::placeholder { color: rgba(154, 150, 144, 0.72); }
.ticket-input:focus,
.ticket-textarea:focus {
  border-color: rgba(212, 137, 58, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 137, 58, 0.12);
}

.ticket-actions {
  display: flex;
  justify-content: center;
  padding-top: 2px;
}
.ticket-send {
  min-width: 118px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  padding: 0 1.15rem;
  background: var(--omni-accent, #d4893a);
  color: #161410;
  font: 700 0.9rem/1 var(--omni-font-ui, Onest, system-ui, sans-serif);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.ticket-send:hover { background: var(--omni-accent-hover, #e49a4c); }
.ticket-send:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

@media (max-width: 520px) {
  .ticket-layer {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
  }
  .ticket-panel {
    width: 100%;
    max-height: 100dvh;
    border-radius: 18px 18px 0 0;
    margin-top: auto;
  }
}

/* ---- Profile panel styles moved to /cabinet/cabinet.css (Mini App reference) ---- */
