/* ── Enterprise layer ──────────────────────────────────────────────────────────
   Loaded last. One type scale, one set of surfaces, real icons, a calm header, a
   designed phone layout (top bar + bottom tab bar + More sheet). Presentation only:
   nothing here adds, hides or implies data; empty values stay visibly empty.
   Selectors in the phone block carry :not(#vi-x) so they outrank the older workspace rules
   (which use :has() and !important) without editing those files. */

:root {
  --ent-font: "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --ent-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ent-fs-xs: 11px;
  --ent-fs-sm: 12.5px;
  --ent-fs-md: 14px;
  --ent-fs-lg: 16px;
  --ent-fs-xl: 20px;
  --ent-fs-2xl: 24px;
  --ent-bg: #050a14;
  --ent-surface: #0a1322;
  --ent-surface-2: #0e1a2e;
  --ent-surface-3: #13223a;
  --ent-line: rgba(120, 170, 235, 0.16);
  --ent-line-strong: rgba(120, 175, 245, 0.32);
  --ent-text: #e6eefb;
  --ent-text-2: #a9b8cf;
  --ent-text-3: #7d8ca4;
  --ent-accent: #3b8cff;
  --ent-accent-soft: rgba(59, 140, 255, 0.14);
  --ent-ok: #3ccf8e;
  --ent-warn: #f5b041;
  --ent-radius: 12px;
  --ent-radius-sm: 8px;
  --ent-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
  --ent-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ent-rail-w: 84px;
  --ent-tabbar-h: 64px;
}

/* Icons */
.vi-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  vertical-align: middle;
}
.vi-pixel-workspace .vi-dashboard-rail button span .vi-icon { width: clamp(16px, 1.25vw, 22px); height: clamp(16px, 1.25vw, 22px); }
.vi-pixel-workspace .vi-dashboard-rail button span { text-shadow: none !important; }
.vi-pixel-workspace .vi-dashboard-rail button.is-active span { color: #7cc0ff; filter: drop-shadow(0 0 6px rgba(40, 150, 255, 0.6)); }

/* Shell type */
.vi-shell { font-family: var(--ent-font); -webkit-font-smoothing: antialiased; }
.vi-rail-more { display: none; }

/* ── Desktop and tablet (≥ 821px) ── */
@media (min-width: 821px) {
  html .vi-shell .vi-rail {
    width: var(--ent-rail-w);
    padding: 14px 8px;
    gap: 4px;
    background: linear-gradient(180deg, #071122, #040a16);
    border-right: 1px solid var(--ent-line);
    box-shadow: none;
  }
  html .vi-shell .vi-rail-brand { padding: 0 0 12px; margin-bottom: 4px; border-bottom: 1px solid var(--ent-line); }
  html .vi-shell .vi-monogram { width: 44px; height: 44px; filter: drop-shadow(0 0 10px rgba(59, 140, 255, 0.45)); }
  html .vi-shell .vi-rail-item {
    min-height: 58px;
    gap: 5px;
    padding: 8px 4px;
    border: 0;
    border-radius: 10px;
    color: var(--ent-text-3);
    font: 600 11px/1.1 var(--ent-font);
    letter-spacing: 0.01em;
    transition: background 0.16s var(--ent-ease), color 0.16s var(--ent-ease);
  }
  html .vi-shell .vi-rail-item:hover { color: var(--ent-text); background: rgba(120, 170, 235, 0.07); }
  html .vi-shell .vi-rail-item--active {
    color: #fff;
    background: var(--ent-accent-soft);
    box-shadow: inset 3px 0 0 var(--ent-accent);
  }
  html .vi-shell .vi-rail-item--active .vi-rail-icon { color: #8cc1ff; }
  html .vi-shell .vi-rail-icon { font-size: 0; line-height: 0; }
}

/* ── Header (screens other than Insights) ── */
html .vi-shell .vi-header {
  font-family: var(--ent-font);
  background: rgba(5, 10, 20, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ent-line);
}
html .vi-shell .vi-header-eyebrow {
  margin: 0 0 3px;
  color: var(--ent-text-3);
  font: 600 var(--ent-fs-xs)/1.2 var(--ent-font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
html .vi-shell .vi-header-title {
  margin: 0;
  color: var(--ent-text);
  font: 650 var(--ent-fs-xl)/1.2 var(--ent-font);
  letter-spacing: -0.01em;
}
html .vi-shell .vi-header-project-id { color: var(--ent-text-3); font: 500 var(--ent-fs-xs)/1.4 var(--ent-mono); }
html .vi-shell .vi-header-context-value {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--ent-line);
  border-radius: var(--ent-radius-sm);
  background: var(--ent-surface);
  box-shadow: none;
}
html .vi-shell .vi-header-context-value--attention { border-color: rgba(245, 176, 65, 0.35); }
html .vi-shell .vi-header-northstar-value {
  overflow: hidden;
  margin: 0;
  color: var(--ent-text);
  font: 600 var(--ent-fs-md)/1.3 var(--ent-font);
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* An empty value reads as empty, not as a finding. */
html .vi-shell .vi-header-northstar-value:is(:empty) { color: var(--ent-text-3); }
html .vi-shell .vi-header-controls .button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--ent-line-strong);
  border-radius: var(--ent-radius-sm);
  color: var(--ent-text);
  background: var(--ent-surface-2);
  font: 600 var(--ent-fs-sm)/1 var(--ent-font);
  box-shadow: none;
  transition: background 0.16s var(--ent-ease), border-color 0.16s var(--ent-ease);
}
html .vi-shell .vi-header-controls .button:hover { border-color: var(--ent-accent); background: var(--ent-surface-3); }
html .vi-shell .vi-header-controls label span { color: var(--ent-text-3); font: 600 var(--ent-fs-xs)/1.2 var(--ent-font); letter-spacing: 0.05em; text-transform: uppercase; }
html .vi-shell .vi-header-controls select {
  min-height: 34px;
  border: 1px solid var(--ent-line);
  border-radius: var(--ent-radius-sm);
  color: var(--ent-text-2);
  background: var(--ent-surface);
  font: 500 var(--ent-fs-sm)/1 var(--ent-font);
}
html .vi-shell .vi-header-state {
  padding: 4px 10px;
  border: 1px solid var(--ent-line);
  border-radius: 999px;
  color: var(--ent-text-2);
  background: transparent;
  font: 500 var(--ent-fs-xs)/1.3 var(--ent-font);
}


/* Who this window is: set by setSignedInControls from the real session check. */
html[data-vi-identity] .vi-shell .vi-header-primary::after {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 3px 10px;
  border: 1px solid var(--ent-line);
  border-radius: 999px;
  color: var(--ent-text-2);
  font: 600 var(--ent-fs-xs)/1.4 var(--ent-font);
}
html[data-vi-identity="signed-in"] .vi-shell .vi-header-primary::after { content: "● Signed in"; color: #9be7c2; border-color: rgba(60, 207, 142, 0.35); }
html[data-vi-identity="guest"] .vi-shell .vi-header-primary::after { content: "● Guest on this device"; color: #f7cf8a; border-color: rgba(245, 176, 65, 0.35); }

/* ── Sign-in / project picker card ── */
html .vi-shell .project-picker {
  font-family: var(--ent-font);
  border: 1px solid var(--ent-line-strong);
  border-radius: 16px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(59, 140, 255, 0.12), transparent 55%),
    var(--ent-surface);
  box-shadow: var(--ent-shadow);
}
html .vi-shell .project-picker h2 { margin: 0 0 6px; color: var(--ent-text); font: 650 var(--ent-fs-xl)/1.25 var(--ent-font); }
html .vi-shell .project-picker p { color: var(--ent-text-2); font: 400 var(--ent-fs-md)/1.55 var(--ent-font); }
html .vi-shell .project-picker summary { color: var(--ent-text-2); font: 500 var(--ent-fs-sm)/1.4 var(--ent-font); cursor: pointer; }

/* ── Content screens: one card, one form, one button language ── */
html .vi-shell .vi-content { font-family: var(--ent-font); color: var(--ent-text); }
html .vi-shell .vi-screen:not([data-vi-screen="workspace"]) :is(.evidence-card, .vi-settings-card, .workspace-command, .slot-card) {
  border: 1px solid var(--ent-line);
  border-radius: var(--ent-radius);
  background: var(--ent-surface);
  box-shadow: var(--ent-shadow);
}
html .vi-shell .vi-screen:not([data-vi-screen="workspace"]) h2 { color: var(--ent-text); font: 650 var(--ent-fs-lg)/1.3 var(--ent-font); letter-spacing: -0.005em; }
html .vi-shell .vi-screen:not([data-vi-screen="workspace"]) h3 { color: var(--ent-text); font: 600 var(--ent-fs-md)/1.35 var(--ent-font); }
html .vi-shell .vi-screen:not([data-vi-screen="workspace"]) :is(p, li) { color: var(--ent-text-2); font-size: var(--ent-fs-md); line-height: 1.55; }
html .vi-shell .vi-screen:not([data-vi-screen="workspace"]) :is(.eyebrow, .vi-settings-eyebrow) { color: var(--ent-text-3); font: 600 var(--ent-fs-xs)/1.2 var(--ent-font); letter-spacing: 0.06em; text-transform: uppercase; }
html .vi-shell .vi-screen:not([data-vi-screen="workspace"]) label { color: var(--ent-text-2); font: 500 var(--ent-fs-sm)/1.4 var(--ent-font); }
html .vi-shell .vi-screen:not([data-vi-screen="workspace"]) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--ent-line-strong);
  border-radius: var(--ent-radius-sm);
  color: var(--ent-text);
  background: #071020;
  font: 400 var(--ent-fs-md)/1.4 var(--ent-font);
  transition: border-color 0.16s var(--ent-ease), box-shadow 0.16s var(--ent-ease);
}
html .vi-shell .vi-screen:not([data-vi-screen="workspace"]) :is(input, select, textarea):focus-visible {
  outline: none;
  border-color: var(--ent-accent);
  box-shadow: 0 0 0 3px rgba(59, 140, 255, 0.25);
}
html .vi-shell .vi-screen:not([data-vi-screen="workspace"]) .button {
  min-height: 38px;
  border-radius: var(--ent-radius-sm);
  font: 600 var(--ent-fs-sm)/1 var(--ent-font);
  letter-spacing: 0;
}


/* Desktop header layout: identity and actions on one row, project context below. */
@media (min-width: 821px) {
  html .vi-shell .vi-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "primary controls" "context context" "boundaries boundaries";
    gap: 12px 20px;
    padding: 16px 24px 12px;
  }
  html .vi-shell .vi-header-context {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
  }
  html .vi-shell .vi-header-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: flex-end;
    gap: 8px;
  }
  html .vi-shell .vi-header-controls label { display: grid; gap: 4px; }
  html .vi-shell .vi-header-controls label select { min-width: 150px; }
  html .vi-shell .vi-header-boundaries { display: flex; gap: 8px; justify-content: flex-start; }
}

/* With no project chosen there is no context to show: the header is just the name, and the
   sign-in card carries the page. */
html:has(.project-picker:not([hidden])) .vi-shell :is(.vi-header-context, .vi-header-controls, .vi-header-boundaries, .vi-header-project-id) { display: none; }
html:has(.project-picker:not([hidden])) .vi-shell .vi-header { padding-block: 12px; }

/* Sign-in card buttons */
html .vi-shell .project-picker :is(.button, a.button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 10px;
  font: 600 var(--ent-fs-md)/1 var(--ent-font);
  text-decoration: none;
}
html .vi-shell .project-picker .button--primary {
  border: 1px solid transparent;
  color: #fff;
  background: linear-gradient(180deg, #4a97ff, #2d74e6);
  box-shadow: 0 6px 18px rgba(45, 116, 230, 0.35);
}
html .vi-shell .project-picker .button--primary:hover { background: linear-gradient(180deg, #5ba2ff, #3580f0); }
html .vi-shell .project-picker .button--apple { border: 1px solid #fff; color: #000; background: #fff; }
html .vi-shell .project-picker { width: min(680px, calc(100% - 32px)); margin: 24px auto; padding: 24px 28px; }


/* ── Readable floor for the Insights canvas (laptop) ──
   The canvas scales with the window, which left labels at 6–9px on a 1440px laptop. These
   rules keep the same layout but never let a label fall below 10px. */
@media (min-width: 821px) {
  html .vi-pixel-workspace__canvas :is(.vi-inspector, .vi-attention, .vi-path-comparison, .vi-metrics) {
    font-size: max(10.5px, .72vw);
  }
  html .vi-pixel-workspace__canvas :is(.vi-inspector, .vi-attention, .vi-path-comparison, .vi-metrics) :is(p, small, span, strong, b, dt, dd, li, button, h2, h3, label) {
    font-size: max(10px, .68vw);
    line-height: 1.35;
  }
  html .vi-pixel-workspace__canvas :is(.vi-inspector, .vi-attention) :is(h2, h3) { font-size: max(10.5px, .72vw); letter-spacing: .06em; }
  html .vi-pixel-workspace__canvas .vi-attention-list small { font-size: max(10px, .66vw); color: var(--ent-text-3); }
  html .vi-pixel-workspace__canvas .vi-attention-viewall { min-height: 26px; font-size: max(10.5px, .7vw); }
  html .vi-pixel-workspace__canvas .vi-intervention-levels button { font-size: max(10px, .66vw); }
  html .vi-pixel-workspace__canvas :is(.vi-dashboard-topbar, .vi-dashboard-footer) :is(small, span, p) { font-size: max(10px, .66vw); }
  html .vi-pixel-workspace__canvas .vi-dashboard-rail button { font-size: max(10.5px, .72vw); }
  html .vi-pixel-workspace__canvas .vi-manifestation__context { font-size: max(10px, .68vw); }
  html .vi-pixel-workspace__canvas .vi-manifestation :is(button, select, summary, p, small) { font-size: max(10px, .68vw); }
  html .vi-pixel-workspace__canvas .vi-conversation :is(.message-meta, .message-copy, summary, small, label, .eyebrow) { font-size: max(10.5px, .72vw); }
  html .vi-pixel-workspace .conversation-card :is(.message-meta, .message-copy, summary, small, label, .eyebrow, .live-badge, .vi-chip b) { font-size: max(10.5px, .72vw); }
  html .vi-pixel-workspace .conversation-card .message-avatar { font-size: max(10px, .7vw); }
  html:not(#vi-x) .vi-shell .conversation-card :is(.eyebrow, .message-meta, .message-copy, summary, small, label, strong, b, p, .live-badge, .message-avatar, h2, h3) { font-size: max(10.5px, .72vw) !important; }
  html:not(#vi-x) .vi-shell .conversation-card h2 { font-size: max(12px, .85vw) !important; }
  html:not(#vi-x) .vi-pixel-workspace__canvas :is(.vi-dashboard-selectors label, .vi-dashboard-selectors p, article > span, article strong) { font-size: max(10px, .66vw) !important; }
  html:not(#vi-x) .vi-pixel-workspace__canvas .vi-dashboard-selectors select { font-size: max(10px, .66vw); }
}

/* ── Header on content screens: one tidy row ── */
@media (min-width: 821px) {
  html:not([data-vi-active-screen="workspace"]) .vi-shell .vi-header-controls label { display: none; }
  html .vi-shell #vi-continuity-state { max-width: 62ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  html .vi-shell .vi-header-boundaries { flex-wrap: nowrap; overflow: hidden; }
}

/* ── CoreDrive: long record text stays inside its card; the full text opens in the inspector ── */
html .vi-shell .vi-crystal-node-copy > strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-size: 15px; line-height: 1.3; }
html .vi-shell .vi-crystal-node-copy > span:not(.eyebrow) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-size: 12.5px; line-height: 1.45; }
html .vi-shell .vi-crystal-node-copy > .eyebrow { font-size: 10.5px; }
html .vi-shell .vi-field-inspector .vi-inspector-tabs { display: flex; flex-wrap: wrap; gap: 4px; height: auto; border: 0; padding-bottom: 6px; }
html .vi-shell .vi-field-inspector .vi-inspector-tabs button {
  flex: 0 0 auto; min-height: 30px; padding: 0 10px; border: 1px solid var(--ent-line); border-radius: 999px;
  font: 600 var(--ent-fs-xs)/1 var(--ent-font); color: var(--ent-text-2); background: transparent;
}
html .vi-shell .vi-field-inspector .vi-inspector-tabs button[aria-selected="true"] { color: #fff; border-color: var(--ent-accent); background: var(--ent-accent-soft); box-shadow: none; }

/* ── Phone (≤ 820px): top bar, bottom tab bar, More sheet ── */
@media (max-width: 820px) {
  html:not(#vi-x) .vi-shell { padding-bottom: calc(var(--ent-tabbar-h) + env(safe-area-inset-bottom)); }
  /* Scrolling the composer into view must clear the fixed bottom tab bar. */
  #message-input,
  #send-message { scroll-margin-bottom: calc(var(--ent-tabbar-h) + 16px + env(safe-area-inset-bottom)); }

  /* Bottom tab bar: five destinations always in reach. */
  html:not(#vi-x) .vi-shell .vi-rail {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 60;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    width: auto;
    height: calc(var(--ent-tabbar-h) + env(safe-area-inset-bottom));
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    gap: 2px;
    overflow: visible;
    border: 0;
    border-top: 1px solid var(--ent-line);
    background: rgba(5, 10, 20, 0.94);
    backdrop-filter: blur(14px);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  }
  html:not(#vi-x) .vi-shell .vi-rail-brand,
  html:not(#vi-x) .vi-shell .vi-rail-spacer { display: none; }
  html:not(#vi-x) .vi-shell .vi-rail-item {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 0;
    padding: 4px 2px;
    border: 0;
    border-radius: 10px;
    color: var(--ent-text-3);
    background: transparent;
    box-shadow: none;
    font: 600 10.5px/1.1 var(--ent-font);
  }
  html:not(#vi-x) .vi-shell .vi-rail-item span:last-child { display: block; }
  html:not(#vi-x) .vi-shell .vi-rail-icon { font-size: 0; line-height: 0; }
  html:not(#vi-x) .vi-shell .vi-rail-item:is([data-vi-dest="workspace"], [data-vi-dest="evidence"], [data-vi-dest="decisions"], [data-vi-dest="workbench"]),
  html:not(#vi-x) .vi-shell .vi-rail-more { display: flex; }
  html:not(#vi-x) .vi-shell .vi-rail-item--active,
  html:not(#vi-x) .vi-shell .vi-rail-more[aria-expanded="true"] { color: #fff; background: var(--ent-accent-soft); }
  html:not(#vi-x) .vi-shell .vi-rail-item--active .vi-rail-icon { color: #8cc1ff; }

  /* More sheet: every other destination, plus Apps and Profile. */
  html[data-vi-nav-sheet="open"]:not(#vi-x) .vi-shell .vi-rail::before {
    content: "";
    position: fixed;
    inset: 0 0 calc(var(--ent-tabbar-h) + env(safe-area-inset-bottom)) 0;
    background: rgba(1, 4, 10, 0.55);
    z-index: -1;
  }
  html[data-vi-nav-sheet="open"]:not(#vi-x) .vi-shell .vi-rail {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-auto-rows: 64px;
    height: auto;
    padding-top: 14px;
    border-radius: 18px 18px 0 0;
    border-top-color: var(--ent-line-strong);
  }
  html[data-vi-nav-sheet="open"]:not(#vi-x) .vi-shell .vi-rail-item { display: flex; }

  /* Compact header: project name and North Star first, the rest one swipe away. */
  html:not(#vi-x) .vi-shell .vi-header {
    position: sticky;
    top: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas: "primary" "context" "controls";
    gap: 8px;
    padding: 10px 14px 10px;
  }
  html:not(#vi-x) .vi-shell .vi-header-title { font-size: var(--ent-fs-lg); }
  html:not(#vi-x) .vi-shell .vi-header-project-id { display: none; }
  html:not(#vi-x) .vi-shell .vi-header-context {
    display: flex;
    flex-wrap: nowrap;
    grid-template-columns: none;
    gap: 8px;
    overflow-x: auto;
    margin: 0 -14px;
    padding: 0 14px 2px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  html:not(#vi-x) .vi-shell .vi-header-context::-webkit-scrollbar { display: none; }
  html:not(#vi-x) .vi-shell .vi-header-context-value { flex: 0 0 auto; max-width: 70vw; padding: 7px 11px; scroll-snap-align: start; }
  html:not(#vi-x) .vi-shell .vi-header-northstar-value { font-size: var(--ent-fs-sm); }
  html:not(#vi-x) .vi-shell .vi-header-controls {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    margin: 0 -14px;
    padding: 0 14px;
    scrollbar-width: none;
  }
  html:not(#vi-x) .vi-shell .vi-header-controls::-webkit-scrollbar { display: none; }
  html:not(#vi-x) .vi-shell .vi-header-controls > * { flex: 0 0 auto; }
  html:not(#vi-x) .vi-shell .vi-header-controls label { display: none; }
  html:not(#vi-x) .vi-shell .vi-header-controls .button { min-height: 32px; padding: 0 12px; white-space: nowrap; }
  html:not(#vi-x) .vi-shell .vi-header-boundaries { display: none; }


  /* Insights on a phone already shows its context under the Context tab; the header is just the
     project name there. */
  html[data-vi-active-screen="workspace"]:not(#vi-x) .vi-shell .vi-header :is(.vi-header-context, .vi-header-controls, .vi-header-boundaries) { display: none; }
  html:not(#vi-x) .vi-shell .vi-context-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  html:not(#vi-x) .vi-shell .vi-context-strip .vi-legend { grid-column: 1 / -1; justify-self: start; }
  html:not(#vi-x) .vi-shell .vi-chip { padding: 6px 10px; }
  html:not(#vi-x) .vi-shell .vi-chip b { font-size: 10px; }
  html:not(#vi-x) .vi-shell .vi-chip span { font-size: 12.5px; }


  /* Conversation card on a phone: a normal reading size, heading on one line. */
  html:not(#vi-x) .vi-shell .conversation-card { font-family: var(--ent-font); }
  html:not(#vi-x) .vi-shell .conversation-card .section-heading { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
  html:not(#vi-x) .vi-shell .conversation-card .section-heading > div:first-child { display: block; min-width: 0; }
  html:not(#vi-x) .vi-shell .conversation-card .section-heading .eyebrow { display: block; margin: 0; font: 600 10.5px/1.2 var(--ent-font); letter-spacing: .06em; }
  html:not(#vi-x) .vi-shell .conversation-card .section-heading h2 { margin: 0; font: 650 17px/1.25 var(--ent-font); letter-spacing: 0; }
  html:not(#vi-x) .vi-shell .conversation-card .section-heading-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  html:not(#vi-x) .vi-shell .conversation-card .interaction-status { font-size: 13px; line-height: 1.45; }
  html:not(#vi-x) .vi-shell .conversation-card .interaction-status :is(h3, strong, .interaction-status__headline) { font-size: 14px; }

  html:not(#vi-x) .vi-shell .project-picker { width: auto; margin: 12px; padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html .vi-shell :is(.vi-rail-item, .vi-header-controls .button, input, select, textarea) { transition: none; }
}

/* Generate guidance sits on its own row under the context strip so the approved chip row is unchanged
 * and a long outcome message wraps beneath the chips instead of squeezing them. */
.vi-generate-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 .5em; }
.vi-generate-row .vi-chip { flex: 0 0 auto; padding: .35em .8em; font-size: .8rem; }
.vi-generate-row .vi-chip b { font-size: .72rem; }
.vi-generate-status { flex: 1 1 16rem; min-width: 0; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; color: var(--ent-muted, #8393a8); }
.vi-generate-status:empty { display: none; }
.vi-generate-status[data-state="error"] { color: #ff8a8a; }

/* ── Visual polish pass (audit fixes) ────────────────────────────────────── */

/* The hidden continuity file input must stay hidden: the mobile action-row rule sets
   display on every child and otherwise shows the browser's plain "Choose File" button. */
html .conversation-card .section-heading-actions > [hidden] { display: none !important; }

@media (min-width: 821px) {
  /* The two header controls are meant to paint as small glyphs. The readable-floor rule above
     re-enabled their text, so "Governance controls" and "Clear conversation" printed on top of
     each other. Their accessible names stay; only the painted text collapses. */
  html[data-vi-active-screen="workspace"]:has(.vi-pixel-workspace):not(#vi-x) .vi-shell .conversation-card .section-heading-actions > * {
    font-size: 0 !important;
  }

  /* Thirteen nav items share the rail evenly (the original template only described seven rows,
     which left Cases without room for its icon and crowded Apps against Profile). */
  html:not(#vi-x) .vi-pixel-workspace__canvas .vi-dashboard-rail {
    grid-template-rows: repeat(13, minmax(0, 1fr));
    overflow: hidden;
  }

  /* Companion mode checkbox: a visible, themed control instead of a blank grey square. */
  .conversation-card input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: #3798ff; flex: none;
  }
}

/* 821–1279px: the percentage-based canvas is narrow, so give its labels room. */
@media (min-width: 821px) and (max-width: 1279px) {
  html:not(#vi-x) .vi-pixel-workspace__canvas .vi-dashboard-rail button {
    gap: 1px; padding: 1px 0; font-size: 9.5px; letter-spacing: -0.01em; overflow: hidden;
  }
  html:not(#vi-x) .vi-pixel-workspace__canvas .vi-dashboard-rail button span .vi-icon { width: 15px; height: 15px; }

  /* Profile preset / work mode: stack label over value so the value is not clipped. */
  html:not(#vi-x) .vi-pixel-workspace__canvas .vi-dashboard-selectors label {
    flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; padding: 2px 8px;
  }
  html:not(#vi-x) .vi-pixel-workspace__canvas .vi-dashboard-selectors select {
    width: 100%; text-overflow: ellipsis;
  }
  /* The one-line status note does not fit the narrow top bar and collides with the cards below. */
  html:not(#vi-x) .vi-pixel-workspace__canvas .vi-dashboard-selectors p { display: none; }

  /* Context chips: let values wrap instead of clipping to "Not Establis…". */
  .vi-context-strip .vi-chip span { white-space: normal; overflow-wrap: anywhere; }

  /* Keep the More toggle clear of the footer workspace links. */
  .vi-more-toggle { right: 28%; }
}

/* Reply attribution ("Answered by: …"): a small, quiet footer under the reply. */
html .conversation-card .message-attribution {
  margin: 4px 0 0; color: var(--ent-text-3, #8393a8); font-size: 11px !important; line-height: 1.35;
  overflow-wrap: anywhere;
}


/* ── Insights canvas: overflow containment (visual-audit fixes) ──
   The canvas positions panels by percentage, so long, real values (a project name, a task, a
   status word) used to be clipped mid-word or to collide with a neighbour. These rules keep
   the same layout but let text wrap, let rows grow, and keep every control on-panel.
   Truthful "NOT ESTABLISHED" wording is never shortened; the box is made to fit it. */

/* Top bar: Profile Preset / Work Mode selects must show their whole value. */
html .vi-pixel-workspace__canvas .vi-dashboard-selectors {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14.5rem), 1fr));
  row-gap: 4px;
  overflow: hidden;
}
html .vi-pixel-workspace__canvas .vi-dashboard-selectors label { min-width: 0; padding: 0 8px; gap: 6px; }
html .vi-pixel-workspace__canvas .vi-dashboard-selectors select {
  min-width: 0; flex: 1 1 auto; field-sizing: content; max-width: 100%; text-overflow: clip;
  padding-right: 2px;
}

/* Top bar: Continuity / Conversation Integrity labels stack with space, never overlap. */
html .vi-pixel-workspace__canvas .vi-dashboard-continuity {
  gap: 4px; padding: 2% 4%; overflow: hidden; line-height: 1.25;
}
html .vi-pixel-workspace__canvas .vi-dashboard-continuity > span {
  display: block; min-width: 0; overflow-wrap: anywhere; white-space: normal;
}

/* Inspector: project name and current task wrap instead of truncating. */
html .vi-pixel-workspace__canvas .vi-inspector { overflow: hidden; }
html .vi-pixel-workspace__canvas .vi-inspector-panel { overflow-y: auto; overflow-x: hidden; }
html .vi-pixel-workspace__canvas :is(.vi-inspector-overview strong, .vi-inspector dd, .vi-inspector-panel p) {
  overflow: visible; white-space: normal; text-overflow: clip; overflow-wrap: anywhere; min-width: 0;
}
html .vi-pixel-workspace__canvas .vi-inspector-overview { height: auto; min-height: 2.2em; flex-wrap: wrap; }
html .vi-pixel-workspace__canvas .vi-inspector dl div { grid-template-columns: minmax(4.5em, 36%) minmax(0, 1fr); align-items: start; }

/* Attention Queue: a column whose list flexes, so "View All" always stays inside the panel. */
html .vi-pixel-workspace__canvas .vi-attention {
  display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}
html .vi-pixel-workspace__canvas .vi-attention > * { flex: 0 0 auto; }
html .vi-pixel-workspace__canvas .vi-attention-list {
  flex: 1 1 auto; height: auto; min-height: 0; overflow-y: auto; grid-auto-rows: minmax(2.9em, 1fr);
  grid-template-rows: none; align-content: start;
}
html .vi-pixel-workspace__canvas .vi-attention-list button { overflow: hidden; row-gap: 2px; }
html .vi-pixel-workspace__canvas .vi-attention-list button > strong {
  min-width: 0; overflow-wrap: anywhere; white-space: normal; line-height: 1.2;
}
html .vi-pixel-workspace__canvas .vi-attention-viewall {
  flex: 0 0 auto; width: 100%; margin-top: 6px; padding: 6px 0; line-height: 1.2; white-space: nowrap;
}
/* Floating More / Panel toggles sit in the footer lane, clear of the queue's last row. */
html .vi-pixel-workspace__canvas :is(.vi-more-toggle, .vi-side-toggle) { z-index: 20; white-space: nowrap; }

/* Path Comparison: heading shares the cards' inset, and cards stay inside the panel. */
html .vi-pixel-workspace__canvas .vi-path-comparison { overflow: hidden; box-sizing: border-box; }
html .vi-pixel-workspace__canvas .vi-path-comparison h2 { padding: 6px 1.5% 4px calc(.8% + 6px); margin: 0; box-sizing: border-box; }
html .vi-pixel-workspace__canvas .vi-path-comparison .path {
  box-sizing: border-box; min-width: 0; max-width: calc(100% - 1.6%); overflow: hidden;
}
html .vi-pixel-workspace__canvas .vi-path-comparison .path > :is(span, strong, small) {
  min-width: 0; max-width: 100%; overflow-wrap: anywhere; white-space: normal;
  text-overflow: clip; overflow: visible;
}
/* Secondary detail line stays on one line (full text is in the card's title tooltip). */
html .vi-pixel-workspace__canvas .vi-path-comparison .path > small {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

/* Bottom status strip + status tiles: wrap whole words; never cut a label mid-word. */
html .vi-pixel-workspace__canvas .vi-metrics article { overflow: hidden; min-width: 0; }
html .vi-pixel-workspace__canvas .vi-metrics article > span {
  overflow: visible; white-space: normal; text-overflow: clip; overflow-wrap: break-word; hyphens: auto; line-height: 1.2;
}
html .vi-pixel-workspace__canvas .vi-metrics article > :is(small, p, strong) {
  overflow: visible; white-space: normal; text-overflow: clip; overflow-wrap: anywhere; min-width: 0;
}
html .vi-pixel-workspace__canvas .vi-metrics li { flex-wrap: wrap; row-gap: 0; min-width: 0; }
html .vi-pixel-workspace__canvas .vi-metrics li > b { min-width: 0; overflow-wrap: anywhere; text-align: right; }
html .vi-pixel-workspace__canvas .vi-metrics { grid-template-columns: 11% 10% 17% 13% 14% 12% 13% 10%; }
html .vi-pixel-workspace__canvas .vi-metrics li > b { white-space: nowrap; }

/* ── Conversation header: icon controls collapse to glyphs without overlapping ──
   The compact header paints "Governance controls", "Export continuity", etc. as glyph-only
   controls (font-size 0). The enterprise readable-floor rule above also targets .live-badge and
   label with !important, which un-collapsed their text inside ~19px boxes so the labels printed
   over each other. Re-assert the collapse with higher specificity; the labels stay in the
   accessibility tree. */
@media (min-width: 821px) {
  html:not(#vi-x)[data-vi-active-screen="workspace"]:has(.vi-pixel-workspace) .vi-shell .conversation-card
    .section-heading-actions > :is(.live-badge, label, button, span, input) {
    font-size: 0 !important; line-height: 0 !important; overflow: hidden; text-indent: 0;
  }
  html:not(#vi-x)[data-vi-active-screen="workspace"]:has(.vi-pixel-workspace) .vi-shell .conversation-card
    .section-heading-actions { gap: 8px; }
  /* The glyph pseudo-elements still need a readable size. */
  html:not(#vi-x)[data-vi-active-screen="workspace"]:has(.vi-pixel-workspace) .vi-shell .conversation-card
    .section-heading-actions > :is(.live-badge, #clear-conversation)::after { font-size: 12px !important; line-height: 1 !important; }
}

/* ── Conversation reply box: whole last line stays visible ──
   The ask box was a single ~26px row set in 6–9px type, so the placeholder/last typed line was
   cut off; the feed's final message also sat flush against the composer. */
html[data-vi-active-screen="workspace"]:has(.vi-pixel-workspace) .conversation-card .composer textarea {
  box-sizing: border-box; min-height: 44px; padding: 9px 30px 9px 9px;
  font-size: max(12px, .8vw); line-height: 1.4; resize: vertical; overflow-y: auto;
}
html[data-vi-active-screen="workspace"]:has(.vi-pixel-workspace) .conversation-card .composer textarea::placeholder { font-size: inherit; line-height: inherit; }
html[data-vi-active-screen="workspace"]:has(.vi-pixel-workspace) .conversation-card .conversation-feed {
  padding-bottom: 14px; scroll-padding-bottom: 14px;
}
html[data-vi-active-screen="workspace"]:has(.vi-pixel-workspace) .conversation-card .message-content { overflow: visible; padding-bottom: 2px; }

/* ── Status tiles: values wrap whole words instead of ending in "…" ── */
html .vi-chip { align-items: flex-start; height: auto; min-height: 0; }
html .vi-chip span {
  overflow: visible; max-width: 100%; white-space: normal; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.25;
}
html .vi-chip b { overflow: visible; white-space: normal; text-overflow: clip; overflow-wrap: break-word; line-height: 1.15; }

/* Printer hub polish (ported from PR #338 67665c17); the desktop-readability overlay is intentionally not included. */
/* Printer hub and the capability screens. Presentation only. No characters. */
.vi-hub {
  width: min(1120px, calc(100vw - 32px));
  max-height: min(900px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--ent-line-strong);
  border-radius: 16px;
  background: var(--ent-bg);
  color: var(--ent-text);
  box-shadow: var(--ent-shadow);
}
.vi-hub__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--ent-line);
  background: linear-gradient(180deg, #0c1830, #08111f);
}
.vi-hub__kicker {
  margin: 0 0 4px;
  color: var(--ent-accent);
  font: 700 11px/1 var(--ent-font);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.vi-hub__bar h2 { margin: 0; font: 650 28px/1.1 var(--ent-font); letter-spacing: -0.03em; }
.vi-hub__body { display: grid; grid-template-columns: 196px 1fr; min-height: 0; }
.vi-hub__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  background: var(--ent-surface);
  border-right: 1px solid var(--ent-line);
}
.vi-hub__group {
  margin: 12px 8px 2px;
  color: var(--ent-text-3);
  font: 700 10px/1 var(--ent-font);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.vi-hub__nav button:focus-visible,
.vi-hub .button:focus-visible,
.vi-hub input:focus-visible,
.vi-hub textarea:focus-visible,
.vi-hub select:focus-visible {
  outline: 2px solid var(--ent-accent);
  outline-offset: 2px;
}
html[data-theme="light"] .vi-hub {
  background: #f4f7fb;
  color: #142033;
  border-color: rgba(20, 40, 70, 0.16);
}
html[data-theme="light"] .vi-hub__bar,
html[data-theme="light"] .vi-hub__nav {
  background: #ffffff;
  color: #142033;
}
html[data-theme="light"] .vi-hub__modalities article,
html[data-theme="light"] .vi-hub input,
html[data-theme="light"] .vi-hub textarea,
html[data-theme="light"] .vi-hub select {
  background: #ffffff;
  color: #142033;
  border-color: rgba(20, 40, 70, 0.18);
}
html[data-theme="light"] .vi-hub__nav button { color: #3c4d66; }
html[data-theme="light"] .vi-hub__nav button.is-active { color: #102033; background: rgba(37, 99, 235, 0.12); }
.vi-hub__nav button {
  text-align: left;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  color: var(--ent-text-2);
  font: 600 13px/1.2 var(--ent-font);
}
.vi-hub__nav button.is-active { background: var(--ent-accent-soft); color: var(--ent-text); }
.vi-hub__stage { padding: 22px; overflow: auto; max-height: min(760px, calc(100vh - 140px)); }
.vi-hub__stage h3 { margin: 0 0 8px; font: 650 26px/1.15 var(--ent-font); letter-spacing: -0.03em; }
.vi-hub__tiles, .vi-hub__cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.vi-hub__tiles button, .vi-hub__cards article {
  text-align: left;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--ent-line);
  border-radius: var(--ent-radius);
  background: var(--ent-surface-2);
  color: var(--ent-text);
}
.vi-hub__tiles span, .vi-hub__cards span, .vi-hub__label {
  display: block;
  margin: 0 0 6px;
  color: var(--ent-accent);
  font: 700 11px/1 var(--ent-font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.vi-hub__tiles strong, .vi-hub__cards strong { display: block; font: 650 18px/1.2 var(--ent-font); }
.vi-hub__tiles em, .vi-hub__cards p { display: block; margin: 6px 0 0; color: var(--ent-text-2); font: 500 14px/1.4 var(--ent-font); font-style: normal; }
.vi-hub__source { margin: 0 0 8px; color: var(--ent-text-3); font: 600 13px/1.4 var(--ent-font); }
.vi-hub__gate { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.vi-hub__gate li { padding: 8px 12px; border-radius: 999px; background: var(--ent-accent-soft); color: var(--ent-text); font: 650 13px/1 var(--ent-font); }
.vi-hub__gate li + li::before { content: "› "; color: var(--ent-text-3); }
.vi-hub__history { margin: 0 0 16px; padding: 0; list-style: none; }
.vi-hub__history li { padding: 10px 0; border-top: 1px solid var(--ent-line); color: var(--ent-text-2); font: 500 15px/1.4 var(--ent-font); }
.vi-hub__modalities {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
.vi-hub__modalities article {
  min-height: 148px;
  padding: 16px;
  border: 1px solid var(--ent-line);
  border-radius: var(--ent-radius);
  background: var(--ent-surface-2);
}
.vi-hub__modalities span {
  display: block;
  margin-bottom: 8px;
  color: var(--ent-accent);
  font: 700 12px/1 var(--ent-font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.vi-hub__modalities p { margin: 0; font: 500 18px/1.45 var(--ent-font); }
.vi-hub .vi-personal-capture { display: grid; gap: 10px; margin-top: 12px; }
.vi-hub .vi-personal-capture label { display: grid; gap: 6px; color: var(--ent-text-2); font: 600 13px/1.3 var(--ent-font); }
.vi-hub input, .vi-hub textarea, .vi-hub select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--ent-line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  background: #07101c;
  color: var(--ent-text);
  font: 500 16px/1.4 var(--ent-font);
}
.vi-hub .button { justify-self: start; }
@media (max-width: 820px) {
  .vi-hub { width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .vi-hub__body { grid-template-columns: 1fr; }
  .vi-hub__nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--ent-line); }
  .vi-hub__nav button { white-space: nowrap; }
  .vi-hub__tiles, .vi-hub__cards, .vi-hub__modalities { grid-template-columns: 1fr; }
  .vi-hub__gate li + li::before { content: ""; }
  .vi-hub__bar h2 { font-size: 22px; }
  .vi-hub__modalities p { font-size: 17px; }
}
