/*
 * Applied visual system (plan §20, Stage 9). Every custom property here is a direct expression of
 * packages/web/src/design/tokens.ts — this file must never introduce a color, spacing, or motion
 * value tokens.ts does not already define. Light is the default; dark is selected via
 * data-theme set by the startup appearance initializer.
 */

:root {
  color-scheme: light;

  --surface-page: #f3f5fa;
  --surface-0: #f3f5fa;
  --surface-1: #ffffff;
  --surface-2: #eaeef6;
  --surface-3: #dfe4ee;
  --surface-4: #ccd3e2;

  --ink-primary: #0a0e1a;
  --ink-secondary: #3d475e;
  --ink-muted: #6b7590;
  --ink-border: rgba(10, 14, 26, 0.1);

  --accent-intelligence: #1d4ed8;
  --accent-glow-soft: rgba(29, 78, 216, 0.16);
  --accent-glow-strong: rgba(29, 78, 216, 0.32);
  --gradient-accent: linear-gradient(135deg, #14318f 0%, #1d4ed8 55%, #5b9dff 100%);
  --gradient-hero: linear-gradient(160deg, #ffffff 0%, #eef2fb 100%);

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --status-neutral: #898781;

  --type-display: 2rem;
  --type-heading: 1.25rem;
  --type-body: 1rem;
  --type-label: 0.8125rem;
  --type-mono: 0.875rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  --elevation-raised: 0 1px 2px rgba(11, 11, 11, 0.08);
  --elevation-overlay: 0 4px 16px rgba(11, 11, 11, 0.16);

  --motion-micro: 150ms;
  --motion-stage: 250ms;
  --motion-easing: cubic-bezier(0.2, 0, 0, 1);

  --focus-outline: 2px solid var(--accent-intelligence);

  --breakpoint-tablet: 640px;
  --breakpoint-laptop: 1024px;
  --breakpoint-large-desktop: 1440px;

  --vi-bg-base: #020d17;
  --vi-bg-panel: #081829;
  --vi-bg-raised: #122432;
  --vi-border-subtle: #0a2d4d;
  --vi-border-glow: rgba(43, 203, 247, 0.24);
  --vi-cyan: #2bcbf7;
  --vi-blue: #1aa2ec;
  --vi-violet: #b538ff;
  --vi-gray: #4b6f95;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-page: #05070d;
  --surface-0: #05070d;
  --surface-1: #0b0f1a;
  --surface-2: #121826;
  --surface-3: #1a2233;
  --surface-4: #242e44;
  --ink-primary: #f4f7fd;
  --ink-secondary: #aab4cc;
  --ink-muted: #7580a0;
  --ink-border: rgba(150, 175, 255, 0.14);
  --accent-intelligence: #4d8dff;
  --accent-glow-soft: rgba(77, 141, 255, 0.16);
  --accent-glow-strong: rgba(77, 141, 255, 0.4);
  --gradient-accent: linear-gradient(135deg, #0d1b4a 0%, #1d4ed8 55%, #8fc2ff 100%);
  --gradient-hero: linear-gradient(160deg, #0b0f1a 0%, #0d1428 55%, #10193a 100%);
  --focus-outline: 2px solid var(--accent-intelligence);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--surface-page);
  color: var(--ink-primary);
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-size: var(--type-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 var(--space-3);
}
h1 {
  font-size: var(--type-display);
}
h2 {
  font-size: var(--type-heading);
}
h3 {
  font-size: 1.0625rem;
}
p {
  margin: 0 0 var(--space-2);
}
.label {
  font-size: var(--type-label);
  color: var(--ink-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
code,
.mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--type-mono);
}

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

:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* --- Surfaces / cards ---------------------------------------------------------------------- */

.surface {
  background: var(--surface-1);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-raised);
  padding: var(--space-4);
}
.panel + .panel {
  margin-top: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.panel-title h2 {
  margin: 0;
}

.card {
  background: var(--surface-2);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.card + .card {
  margin-top: var(--space-3);
}

/* Advisory/provisional register (plan §20): generated, unapproved, or predicted content is
   visually distinct from canonical/approved/completed content — dashed border + reduced-opacity
   badge, never just a label. */
.card--provisional {
  border-style: dashed;
  border-color: var(--accent-intelligence);
}
.card--authoritative {
  border-left: 3px solid var(--status-good);
}

.field-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.field-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.field-row .label {
  margin: 0;
}

/* --- Badges --------------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2) 2px var(--space-1);
  border-radius: 999px;
  font-size: var(--type-label);
  font-weight: 600;
  border: 1px solid var(--ink-border);
  background: var(--surface-2);
}
.badge-icon {
  width: 10px;
  height: 10px;
  flex: none;
  display: inline-block;
}
.badge[data-role="good"] .badge-icon {
  background: var(--status-good);
  border-radius: 50%;
}
.badge[data-role="warning"] .badge-icon {
  background: var(--status-warning);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
.badge[data-role="serious"] .badge-icon {
  background: var(--status-serious);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.badge[data-role="critical"] .badge-icon {
  background: var(--status-critical);
  clip-path: polygon(
    30% 0%,
    70% 0%,
    100% 30%,
    100% 70%,
    70% 100%,
    30% 100%,
    0% 70%,
    0% 30%
  );
}
.badge[data-role="neutral"] .badge-icon {
  background: var(--status-neutral);
  border-radius: 2px;
}
.badge[data-role="good"] {
  color: var(--status-good);
}
.badge[data-role="critical"] {
  color: var(--status-critical);
}

/* --- Confidence indicator --------------------------------------------------------------------- */

.confidence-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.confidence-label {
  font-weight: 600;
  font-size: var(--type-label);
  text-transform: capitalize;
}
.confidence-fill {
  position: relative;
  display: inline-block;
  width: 64px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.confidence-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  width: calc(1% * var(--fill-percent, 0));
  background: var(--accent-intelligence);
  border-radius: 3px;
}
.confidence-basis {
  color: var(--ink-secondary);
  font-size: var(--type-label);
}

/* --- Empty / error / unavailable / stale / loading states -------------------------------------- */

.empty-state,
.error-state,
.unavailable-state {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px dashed var(--ink-border);
  color: var(--ink-secondary);
  text-align: left;
}
.error-state {
  border-color: var(--status-critical);
  color: var(--status-critical);
}
.unavailable-state {
  border-color: var(--status-warning);
}
.empty-state-title,
.error-state-title,
.unavailable-state-title {
  font-weight: 600;
  color: var(--ink-primary);
  margin: 0 0 var(--space-1);
}

.stale-data-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--type-label);
  color: var(--status-warning);
  border: 1px solid var(--status-warning);
  border-radius: 999px;
  padding: 2px var(--space-2);
}

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  min-height: 1em;
}
@keyframes skeleton-shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

.loading-state {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* --- Trace panel ------------------------------------------------------------------------------ */

.trace-panel {
  padding: var(--space-4);
}
.trace-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.trace-step {
  position: relative;
  padding: var(--space-3) 0 var(--space-3) var(--space-5);
  border-left: 2px solid var(--surface-4);
}
.trace-step::before {
  content: "";
  position: absolute;
  left: -5px;
  top: var(--space-3);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-4);
}
.trace-step[data-active="true"] {
  border-left-color: var(--accent-intelligence);
}
.trace-step[data-active="true"]::before {
  background: var(--accent-intelligence);
}
.trace-step[data-active="false"] {
  opacity: 0.5;
}
.trace-step h3 {
  margin: 0 0 4px;
  font-size: var(--type-body);
}

/* --- Motion: restrained, tied to real state transitions, fully disabled under reduced-motion --- */

.panel,
.card,
.trace-step {
  transition:
    box-shadow var(--motion-micro) var(--motion-easing),
    border-color var(--motion-micro) var(--motion-easing);
}

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

/* --- Utility ------------------------------------------------------------------------------- */

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

.long-text {
  overflow-wrap: anywhere;
}

/* --- Collaboration OS application shell (markup: public/index.html) ---------------------- */

.app-frame {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--surface-page);
}
/* A `display` declaration on this class has the same specificity as the UA `[hidden]` rule and
   wins the cascade tie as the later author rule — without this, adding the `hidden` attribute in
   index.html does not actually hide the legacy page, it just renders underneath the new shell. */
.app-frame[hidden] {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-4);
  background: var(--gradient-hero);
  border-right: 1px solid var(--ink-border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.brand-lockup strong {
  display: flex;
  flex-direction: column;
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.2;
}
.brand-lockup-accent {
  color: var(--accent-intelligence);
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
}
.brand-lockup span {
  display: block;
  font-size: var(--type-label);
  color: var(--ink-muted);
  margin-top: 2px;
}
.brand-mark {
  /* icons/vested-intelligence-mark.png is a transparent square canvas with no baked-in frame
     or corner radius — object-fit: contain preserves it without cropping or stretching. */
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 0 10px var(--accent-glow-strong));
}

.primary-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  color: var(--ink-secondary);
  text-decoration: none;
  font-weight: 500;
  transition:
    background var(--motion-micro) var(--motion-easing),
    color var(--motion-micro) var(--motion-easing),
    border-color var(--motion-micro) var(--motion-easing);
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink-primary);
}
.nav-item--active {
  background: var(--accent-glow-soft);
  border-left-color: var(--accent-intelligence);
  color: var(--ink-primary);
}
.nav-item span[aria-hidden] {
  color: var(--accent-intelligence);
}

.sidebar-status {
  margin-top: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.sidebar-status strong {
  display: block;
  font-size: var(--type-label);
}
.sidebar-status span {
  display: block;
  font-size: var(--type-label);
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}
.status-dot {
  width: 10px;
  height: 10px;
  flex: none;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--status-neutral);
}
.status-dot[data-state="connected"] {
  background: var(--status-good);
}
.status-dot[data-state="error"] {
  background: var(--status-critical);
}

.button {
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-2);
  color: var(--ink-primary);
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--motion-micro) var(--motion-easing),
    box-shadow var(--motion-micro) var(--motion-easing),
    transform var(--motion-micro) var(--motion-easing);
}
.button:hover {
  background: var(--surface-3);
}
.button:active {
  transform: translateY(1px);
}
.button--primary {
  background: var(--gradient-accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 14px var(--accent-glow-strong);
}
.button--primary:hover {
  filter: brightness(1.12);
  box-shadow: 0 4px 20px var(--accent-glow-strong);
}
.button--secondary {
  background: var(--surface-1);
}
.button--danger {
  background: var(--surface-1);
  border-color: var(--status-critical);
  color: var(--status-critical);
}
.button--danger:hover {
  background: var(--status-critical);
  color: #fff;
}
.job-controls {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.button--ghost {
  background: transparent;
}
.button--full {
  width: 100%;
}
.icon-button {
  border: 1px solid var(--ink-border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.application {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-5);
  background: var(--surface-1);
  border-bottom: 1px solid var(--ink-border);
  box-shadow: var(--elevation-raised);
}
.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  font-size: var(--type-label);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px var(--space-3);
  border-radius: 999px;
  border: 1px solid var(--ink-border);
  background: var(--surface-2);
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--ink-secondary);
}
.connection-pill[data-state="connected"] {
  color: var(--status-good);
  border-color: var(--status-good);
  box-shadow: 0 0 10px rgba(12, 163, 12, 0.25);
}
.connection-pill[data-state="error"] {
  color: var(--status-critical);
  border-color: var(--status-critical);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5);
  min-width: 0;
}

.hero-card {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  border: 1px solid var(--ink-border);
  background: var(--gradient-hero);
  box-shadow: var(--elevation-raised);
  overflow: hidden;
}
.hero-card::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 60%;
  height: 180%;
  background: radial-gradient(circle, var(--accent-glow-soft) 0%, transparent 70%);
  pointer-events: none;
}
.hero-card > * {
  position: relative;
}
.hero-card h2 {
  margin: var(--space-2) 0;
  font-size: 1.5rem;
  max-width: 46ch;
}
.hero-card p:not(.eyebrow) {
  color: var(--ink-secondary);
  max-width: 60ch;
}
.hero-metrics {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}
.hero-metrics > div {
  min-width: 96px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  text-align: center;
}
.hero-metrics span {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-intelligence);
}
.hero-metrics small {
  color: var(--ink-muted);
  font-size: var(--type-label);
}

.hero-status-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}
.hero-status-field {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  background: var(--surface-1);
}
.hero-status-field p:not(.eyebrow) {
  margin: 0;
  font-weight: 600;
}

.primary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: var(--space-4);
  align-items: start;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.section-heading h2 {
  margin: 0;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-3);
  border-radius: 999px;
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--status-good);
  border: 1px solid var(--status-good);
}
.live-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-good);
}

.conversation-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--elevation-raised);
  min-height: 480px;
}

.conversation-feed {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow-y: auto;
  max-height: 52vh;
  padding-right: var(--space-2);
  margin-bottom: var(--space-4);
}

.message {
  display: flex;
  gap: var(--space-3);
  max-width: 92%;
}
.message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message-avatar {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-1);
  border: 1px solid var(--ink-border);
  color: #fff;
  font-size: var(--type-label);
  font-weight: 700;
}
/* Approved V.I. mark: rendered on a neutral surface, never on the saturated accent color,
 * so its own blue/cyan strokes stay legible instead of washing out against a same-hue fill. */
.message-avatar img {
  width: 38px;
  height: 38px;
  display: block;
  object-fit: contain;
}
.message--user .message-avatar {
  background: var(--surface-4);
  border: none;
  color: var(--ink-primary);
}
.message-content {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--ink-border);
  min-width: 0;
}
.message--user .message-content {
  background: var(--surface-3);
}
.message-content p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message-meta {
  font-size: var(--type-label);
  color: var(--ink-muted);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.message-status-badge {
  display: inline-flex;
}

.continuity-ticker {
  margin: 0 0 var(--space-2);
  padding-left: var(--space-3);
  border-left: 2px solid var(--status-good);
  font-size: var(--type-label);
  color: var(--ink-secondary);
}

.governance-trace summary,
.intelligence-detail summary {
  cursor: pointer;
  font-weight: 600;
  padding: var(--space-2) 0;
}
.intelligence-detail {
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  padding: var(--space-4);
}
.intelligence-detail .insight-grid {
  margin-top: var(--space-3);
}

.card--coding-inspection {
  border-left: 3px solid var(--accent-intelligence);
}
.card--coding-inspection .section-heading {
  margin-bottom: var(--space-2);
}

.composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.composer textarea {
  width: 100%;
  resize: vertical;
  padding: var(--space-3);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  color: var(--ink-primary);
}
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--type-label);
  color: var(--ink-muted);
  flex-wrap: wrap;
}
.composer-footer-hint {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.provider-select-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink-secondary);
}
.provider-select-label select {
  padding: 3px var(--space-2);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-primary);
  font-size: var(--type-label);
}

.context-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.slot-card {
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--elevation-raised);
  padding: var(--space-4);
  min-width: 0;
  overflow-wrap: anywhere;
}
.slot-card:empty {
  display: none;
}

.empty-slot span {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.empty-slot p {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--type-label);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-4);
  align-items: start;
}
.slot-card--wide {
  grid-column: 1 / -1;
}
.slot-card--brain {
  border-color: var(--accent-intelligence);
  box-shadow:
    var(--elevation-raised),
    0 0 0 1px var(--accent-glow-soft);
}

.brain-summary {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--ink-border);
}
.brain-summary-attention {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.brain-summary-attention p {
  margin: 0;
  font-weight: 600;
}
.brain-summary-attention[data-role="warning"] p {
  color: var(--status-warning);
}
.brain-summary-attention[data-role="neutral"] p {
  color: var(--ink-secondary);
}
.brain-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  margin: 0;
}
.brain-summary-grid dt {
  font-size: var(--type-label);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.brain-summary-grid dd {
  margin: 2px 0 0;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--accent-intelligence);
}

.evidence-card {
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--elevation-raised);
  padding: var(--space-5);
}

.card-group {
  margin-bottom: var(--space-4);
}
.card-group:last-child {
  margin-bottom: 0;
}
.card-group h3 {
  margin-bottom: var(--space-2);
}

.resolve-contradiction-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.resolve-contradiction-form label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--type-label);
  color: var(--ink-secondary);
}
.resolve-contradiction-form input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-sm);
  background: var(--surface-0);
  color: var(--ink-primary);
  font-size: var(--type-mono);
}

/*
 * Both dialogs (#setup-dialog, #north-star-dialog) are native <dialog> elements, opened via
 * showModal() — they render in the browser's top layer regardless of any ancestor's `hidden`
 * attribute, so they always sit on top of the new .vi-shell now that it's the primary UI. Rather
 * than the old light/dark-switchable `--surface-1`/`--ink-*` tokens (which default to a bright
 * white card in a light-mode browser, clashing badly with the fixed-dark shell behind it), these
 * are hardcoded to the same locked `--vi-*` palette as the shell so a dialog opening on top of it
 * is always visually consistent, never a mismatched light popup over a dark screen.
 */
.setup-dialog {
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-lg);
  background: var(--vi-surface);
  color: var(--vi-text);
  padding: var(--space-6);
  width: min(560px, 92vw);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.5);
}
.setup-dialog::backdrop {
  background: rgba(2, 4, 10, 0.72);
}
.setup-dialog form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.setup-dialog label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--vi-text-muted);
}
.setup-dialog input,
.setup-dialog select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-sm);
  background: var(--vi-surface-raised);
  color: var(--vi-text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--type-mono);
}
.setup-dialog .eyebrow {
  color: var(--vi-text-muted);
}
.setup-dialog h2 {
  color: var(--vi-text);
}
.setup-dialog .icon-button {
  border-color: var(--vi-border);
  background: var(--vi-surface-raised);
  color: var(--vi-text);
}
.setup-dialog .button--secondary {
  background: var(--vi-surface-raised);
  border-color: var(--vi-border);
  color: var(--vi-text);
}
.setup-dialog .button--primary {
  background: linear-gradient(135deg, #14318f 0%, #1d4ed8 55%, #4d8dff 100%);
  border-color: transparent;
  color: #fff;
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}
.dialog-heading h2 {
  margin: var(--space-1) 0;
}
.dialog-heading p:not(.eyebrow) {
  margin: 0;
  color: var(--vi-text-muted);
  font-size: var(--type-label);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 1023px) {
  .app-frame {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--ink-border);
  }
  .sidebar-status {
    margin-top: 0;
  }
  .primary-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- Mobile (≤639px) --------------------------------------------------------------------- */

@media (max-width: 639px) {
  .sidebar {
    padding: var(--space-3);
    gap: var(--space-3);
  }
  .primary-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .nav-item {
    padding: var(--space-1) var(--space-2);
    font-size: var(--type-label);
  }
  .sidebar-status {
    display: none;
  }

  .topbar {
    padding: var(--space-2) var(--space-3);
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }
  .topbar h1 {
    font-size: 1.0625rem;
  }
  .topbar-actions {
    justify-content: space-between;
  }

  .workspace {
    padding: var(--space-3);
    gap: var(--space-3);
  }
  .hero-card {
    flex-direction: column;
    padding: var(--space-4);
  }
  .hero-card h2 {
    font-size: 1.1875rem;
  }
  .hero-metrics {
    width: 100%;
    justify-content: space-between;
  }
  .hero-metrics > div {
    min-width: 0;
    flex: 1;
    padding: var(--space-2);
  }
  .hero-status-row {
    grid-template-columns: 1fr;
  }

  .conversation-card {
    padding: var(--space-3);
    min-height: 0;
  }
  .conversation-feed {
    max-height: 44vh;
  }
  .governance-trace[open] > div {
    max-height: min(32dvh, 280px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .composer-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .composer-footer-hint {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }
  .provider-select-label select {
    width: 100%;
  }

  .insight-grid {
    grid-template-columns: 1fr;
  }
  .brain-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .setup-dialog {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }
}

/*
 * V.I. screen-based application shell (Stage A). Scoped entirely to `.vi-*` classes so it never
 * touches the existing `.app-frame` dense-page styling above — the two coexist during the
 * migration (`.app-frame` is hidden via the `hidden` attribute in index.html, not deleted, until
 * its content is moved into a shell destination one stage at a time). Palette is the locked V.I.
 * brand identity. These compatibility aliases intentionally resolve to the semantic appearance
 * tokens so current and future private screens inherit Light, Dark, and System without overrides.
 */
:root {
  --vi-bg: var(--surface-page);
  --vi-surface: var(--surface-1);
  --vi-surface-raised: var(--surface-2);
  --vi-border: var(--ink-border);
  --vi-text: var(--ink-primary);
  --vi-text-muted: var(--ink-secondary);
  --vi-accent: var(--accent-intelligence);
  --vi-accent-strong: var(--accent-intelligence);
  --vi-accent-glow: var(--accent-glow-strong);
}

.vi-shell {
  display: flex;
  min-height: 100vh;
  background: var(--vi-bg);
  color: var(--vi-text);
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}

.vi-rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 232px;
  flex-shrink: 0;
  background: var(--vi-surface);
  border-right: 1px solid var(--vi-border);
  padding: 20px 12px;
}

.vi-rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 20px;
}
.vi-monogram {
  /* Preserve the approved transparent square canvas at a size where the hollow V, separate
     capital I, and upper-right flare remain recognisable without cropping or distortion. */
  width: 46px;
  height: 46px;
  display: block;
  object-fit: contain;
  box-shadow: none;
}
.vi-rail-brand-label {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--vi-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vi-rail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--vi-text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition:
    background-color 150ms cubic-bezier(0.2, 0, 0, 1),
    color 150ms cubic-bezier(0.2, 0, 0, 1);
}
.vi-rail-item:hover {
  background: var(--accent-glow-soft);
  color: var(--vi-text);
}
.vi-rail-item:focus-visible {
  outline: 2px solid var(--vi-accent);
  outline-offset: 2px;
}
.vi-rail-item--active {
  background: linear-gradient(135deg, #14318f 0%, #1d4ed8 55%, #4d8dff 100%);
  color: #fff;
  box-shadow: 0 2px 14px var(--vi-accent-glow);
}
.vi-rail-icon {
  display: inline-flex;
  width: 18px;
  justify-content: center;
}
.vi-rail-spacer {
  flex: 1;
  min-height: 24px;
}

.vi-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.vi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--vi-border);
  background: var(--vi-surface);
}
.vi-header-eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--vi-text-muted);
}
.vi-header-title {
  margin: 2px 0 0;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--vi-text);
}
.vi-header-context {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  text-align: right;
}
.vi-header-context-value {
  min-width: 0;
}
.vi-header-northstar-value {
  margin: 2px 0 0;
  color: var(--vi-text);
  font-weight: 600;
  max-width: 420px;
}
.vi-header-context .button {
  margin-top: 8px;
}

.vi-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.project-picker {
  margin: 20px 24px 0;
  padding: 20px;
  border: 1px solid var(--border, rgba(126, 162, 213, 0.25));
  border-radius: 16px;
  background: var(--vi-surface);
  color: var(--vi-text);
  overflow: visible;
  height: auto;
}

.vi-first-owner-setup {
  overflow: visible;
  height: auto;
}
.vi-first-owner-setup form#vi-first-owner-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  overflow: visible;
  height: auto;
}
.vi-first-owner-setup form#vi-first-owner-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vi-first-owner-setup form#vi-first-owner-form input {
  min-height: 44px;
}
.vi-first-owner-setup form#vi-first-owner-form button#vi-first-owner-preflight {
  grid-column: 1 / -1;
}
@media (max-width: 720px) {
  .vi-first-owner-setup form#vi-first-owner-form {
    grid-template-columns: 1fr;
  }
}

.project-picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.project-picker-item {
  display: grid;
  gap: 6px;
  padding: 16px;
  color: inherit;
  text-align: left;
  border: 1px solid rgba(126, 162, 213, 0.3);
  border-radius: 12px;
  background: var(--vi-surface-raised);
  cursor: pointer;
}

.project-picker-item:hover,
.project-picker-item:focus-visible {
  border-color: #65a7ff;
}

.project-picker-item small {
  color: var(--vi-text-muted);
}

.vi-screen {
  display: none;
}
.vi-screen--active {
  display: block;
}

@media (max-width: 640px) {
  .vi-rail {
    width: 76px;
    padding: 16px 8px;
  }
  .vi-rail-brand-label,
  .vi-rail-item span:last-child {
    display: none;
  }
  .vi-rail-item {
    justify-content: center;
  }
  .vi-header {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .vi-header-context {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    text-align: left;
  }
  .vi-content {
    padding: 16px;
  }
}

/*
 * Stage B: the real Collaborate screen. `.vi-placeholder` is the honest "not yet moved" marker
 * for every destination that still has no real content — never a fake populated screen.
 */
.vi-placeholder {
  margin: 0;
  color: var(--vi-text-muted);
  font-size: 0.9375rem;
}

/*
 * The conversation card/message/composer markup is unchanged (same classes, same ids) — only
 * relocated into [data-vi-screen="workspace"]. These are scoped overrides of the same
 * light/dark-switchable tokens those rules use elsewhere (`--surface-*`/`--ink-*`), replacing them
 * with the fixed `--vi-*` palette for exactly this screen, the same pattern used for the dialogs
 * above — never a global retarget of `.section-heading`/`.composer`, since those class names are
 * also used by other, still-unmoved parts of the legacy page.
 */
[data-vi-screen="workspace"] .conversation-card {
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-lg);
  background: var(--vi-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Approved conversation + Living V.I. workspace composition. */
[data-vi-screen="workspace"] {
  display: grid;
  grid-template-columns: minmax(310px, 0.72fr) minmax(0, 2.28fr);
  grid-template-areas:
    "conversation living"
    "state state";
  align-items: stretch;
  gap: 14px;
}
[data-vi-screen="workspace"] .conversation-card {
  grid-area: conversation;
  min-width: 0;
  height: min(78vh, 900px);
  display: flex;
  flex-direction: column;
}
[data-vi-screen="workspace"] .conversation-feed {
  flex: 1 1 auto;
  min-height: 0;
}
[data-vi-screen="workspace"] .workspace-command {
  grid-area: state;
  margin: 0;
}
.workspace-living-visual-panel {
  grid-area: living;
  min-width: 0;
}
.workspace-living-visual-panel .vi-field {
  min-height: min(78vh, 900px);
  height: 100%;
}

@media (max-width: 1180px) {
  [data-vi-screen="workspace"] {
    grid-template-columns: 1fr;
    grid-template-areas: "conversation" "living" "state";
  }
  [data-vi-screen="workspace"] .conversation-card { height: auto; }
}
[data-vi-screen="workspace"] .section-heading h2 {
  color: var(--vi-text);
}
[data-vi-screen="workspace"] .eyebrow {
  color: var(--vi-text-muted);
}
[data-vi-screen="workspace"] .live-badge {
  color: var(--status-good);
  border-color: var(--status-good);
}
[data-vi-screen="workspace"] .live-badge::before {
  background: var(--status-good);
}
[data-vi-screen="workspace"] .live-badge--grounded {
  border-color: var(--vi-accent);
  background: var(--accent-glow-soft);
  color: var(--vi-accent);
}
[data-vi-screen="workspace"] .live-badge--grounded::before {
  background: var(--vi-accent);
  box-shadow: 0 0 8px var(--vi-accent-glow);
}
.section-heading-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
[data-vi-screen="workspace"] .section-heading-actions .button--secondary {
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="workspace"] .section-heading-actions .button--secondary:hover {
  border-color: var(--vi-accent);
  color: var(--vi-text);
}
[data-vi-screen="workspace"] .message-content {
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="workspace"] .message--user .message-content {
  background: var(--surface-3);
}
[data-vi-screen="workspace"] .message-avatar {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
}
[data-vi-screen="workspace"] .message--user .message-avatar {
  background: var(--vi-surface-raised);
  border: none;
  color: var(--vi-text);
}
[data-vi-screen="workspace"] .message-meta {
  color: var(--vi-text-muted);
}
[data-vi-screen="workspace"] .composer textarea {
  background: var(--vi-bg);
  color: var(--vi-text);
  border: 1px solid var(--vi-border);
}
[data-vi-screen="workspace"] .composer-footer {
  color: var(--vi-text-muted);
}
[data-vi-screen="workspace"] .provider-select-label {
  color: var(--vi-text-muted);
}
[data-vi-screen="workspace"] .provider-select-label select {
  background: var(--vi-surface-raised);
  color: var(--vi-text);
  border: 1px solid var(--vi-border);
}
[data-vi-screen="workspace"] .button--primary {
  background: linear-gradient(135deg, #14318f 0%, #1d4ed8 55%, #4d8dff 100%);
  border-color: transparent;
  color: #fff;
}

/*
 * Stage C: Evidence (claims + evidence references), Decisions (contradictions), and Execution
 * (execution jobs + plans) — same relocate-only pattern as Stage B's Collaborate move: no
 * component code changed, only which screen's markup contains them, plus the same scoped
 * light/dark-switchable-token overrides used for Collaborate and the dialogs. `.evidence-card`,
 * `.card`, `.field-list`, `.empty-state`, `.badge`, and the queue/create/resolve forms are all
 * still used by not-yet-moved destinations elsewhere in the legacy page, so these rules are
 * scoped to the three moved screens' selectors, never retargeted globally.
 */
[data-vi-screen="evidence"] .evidence-card,
[data-vi-screen="decisions"] .evidence-card,
[data-vi-screen="execution"] .evidence-card {
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-lg);
  background: var(--vi-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  margin-bottom: 20px;
}
[data-vi-screen="evidence"] .evidence-card:last-child,
[data-vi-screen="decisions"] .evidence-card:last-child,
[data-vi-screen="execution"] .evidence-card:last-child {
  margin-bottom: 0;
}
[data-vi-screen="evidence"] h2,
[data-vi-screen="decisions"] h2,
[data-vi-screen="execution"] h2 {
  color: var(--vi-text);
}
[data-vi-screen="evidence"] .card,
[data-vi-screen="decisions"] .card,
[data-vi-screen="execution"] .card {
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="evidence"] .label,
[data-vi-screen="decisions"] .label,
[data-vi-screen="execution"] .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="evidence"] .long-text,
[data-vi-screen="decisions"] .long-text,
[data-vi-screen="execution"] .long-text {
  color: var(--vi-text);
}
[data-vi-screen="evidence"] .empty-state,
[data-vi-screen="decisions"] .empty-state,
[data-vi-screen="execution"] .empty-state {
  border-color: var(--vi-border);
  color: var(--vi-text-muted);
}
[data-vi-screen="evidence"] .empty-state-title,
[data-vi-screen="decisions"] .empty-state-title,
[data-vi-screen="execution"] .empty-state-title {
  color: var(--vi-text);
}
[data-vi-screen="evidence"] .badge,
[data-vi-screen="decisions"] .badge,
[data-vi-screen="execution"] .badge {
  background: var(--vi-surface-raised);
  border-color: var(--vi-border);
}
[data-vi-screen="evidence"] .card-group h3,
[data-vi-screen="decisions"] .card-group h3,
[data-vi-screen="execution"] .card-group h3 {
  color: var(--vi-text);
}
[data-vi-screen="decisions"] .resolve-contradiction-form label,
[data-vi-screen="execution"] .queue-execution-job-form label,
[data-vi-screen="execution"] .create-execution-plan-form label {
  color: var(--vi-text-muted);
}
[data-vi-screen="decisions"] .resolve-contradiction-form input,
[data-vi-screen="execution"] .queue-execution-job-form input,
[data-vi-screen="execution"] .queue-execution-job-form select,
[data-vi-screen="execution"] .create-execution-plan-form input,
[data-vi-screen="execution"] .create-execution-plan-form textarea {
  background: var(--vi-bg);
  color: var(--vi-text);
  border: 1px solid var(--vi-border);
}
[data-vi-screen="execution"] .button--secondary {
  background: var(--vi-surface-raised);
  border-color: var(--vi-border);
  color: var(--vi-text);
}

/*
 * Doctor (packages/application/src/doctor.ts's real diagnostic report via
 * components/doctor-view.ts) — same scoped-override pattern as Stage C/Providers above. Fixes a
 * real bug: without this block, `.evidence-card`/`.card`/`.empty-state`/`.badge` fell back to
 * their unscoped legacy light-theme tokens (`--surface-1`/`--ink-border`), rendering as an
 * unstyled white box against the dark shell instead of a themed card.
 */
[data-vi-screen="visualize"] .evidence-card {
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-lg);
  background: var(--vi-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
[data-vi-screen="visualize"] section[data-field="doctor-view"] h2 {
  color: var(--vi-text);
}
[data-vi-screen="visualize"] .card {
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="visualize"] .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="visualize"] .empty-state {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  color: var(--vi-text-muted);
}
[data-vi-screen="visualize"] .empty-state-title {
  color: var(--vi-text);
}
[data-vi-screen="visualize"] .badge {
  background: var(--vi-surface-raised);
  border-color: var(--vi-border);
}
[data-vi-screen="visualize"] .badge[data-role="neutral"] {
  color: var(--vi-text-muted);
}

/*
 * Interview (the Collaboration Interview — components/interview-view.ts, a real, previously
 * undocumented-but-unimplemented product requirement, now backed by a real versioned
 * CollaborationProfile record). Same scoped-override pattern as Doctor immediately above.
 */
[data-vi-screen="interview"] .evidence-card {
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-lg);
  background: var(--vi-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
[data-vi-screen="interview"] section[data-field="interview-view"] h2 {
  color: var(--vi-text);
}
[data-vi-screen="interview"] .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="interview"] form[data-interview-form] label {
  display: block;
  color: var(--vi-text-muted);
  margin-block-end: var(--space-3);
}
[data-vi-screen="interview"] form[data-interview-form] textarea {
  display: block;
  width: 100%;
  margin-block-start: var(--space-1);
  background: var(--vi-bg);
  color: var(--vi-text);
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-md);
  font: inherit;
  padding: var(--space-2);
}
/* Fires only when a real save just completed (main.ts's runInterviewLoad renders this element
   fresh into the DOM at that exact moment, then replaces it on the next real fetch) — a one-shot
   flash, never a loop, never shown without a real successful POST behind it. */
[data-vi-screen="interview"] [data-field="interview-saved"] {
  display: inline-block;
  color: var(--vi-text);
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-accent);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  box-shadow: 0 0 0 var(--vi-accent-glow);
  animation: interview-saved-flash 900ms var(--motion-easing) 1;
}
@keyframes interview-saved-flash {
  0% {
    box-shadow: 0 0 24px 4px var(--vi-accent-glow);
    background: var(--vi-accent-glow);
  }
  100% {
    box-shadow: 0 0 0 var(--vi-accent-glow);
    background: var(--vi-surface-raised);
  }
}

/*
 * History (Auditor module activity — components/audit-history-view.ts's real per-module rollup
 * of this project's own chronology). Same scoped-override pattern as Doctor/Interview above.
 */
[data-vi-screen="project-map"] .evidence-card {
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-lg);
  background: var(--vi-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
[data-vi-screen="project-map"] section[data-field="auditor-module-activity"] h2 {
  color: var(--vi-text);
}
[data-vi-screen="project-map"] .card {
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="project-map"] .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="project-map"] .empty-state {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  color: var(--vi-text-muted);
}
[data-vi-screen="project-map"] .empty-state-title {
  color: var(--vi-text);
}
[data-vi-screen="project-map"] .auditor-activity-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
[data-vi-screen="project-map"] .auditor-activity-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--vi-bg);
  border: 1px solid var(--vi-border);
  overflow: hidden;
}
[data-vi-screen="project-map"] .auditor-activity-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--vi-accent-strong), var(--vi-accent));
  box-shadow: 0 0 8px var(--vi-accent-glow);
  transform-origin: left;
  /* The fill's real width is set inline per row from that module's real event count (see
     renderAuditorModuleActivity) — this animation only grows it into view on render, it never
     changes what proportion the bar actually represents. */
  animation: auditor-activity-bar-grow 600ms var(--motion-easing) 1;
}
@keyframes auditor-activity-bar-grow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/*
 * Stage D: V.I. Brain screen (workspace-level aggregate summary, same relocate-only pattern as
 * every prior stage) plus the live Brain panel inside Collaborate — see render.ts's
 * renderBrainLiveWorking/renderLiveBrainTrace doc comment for exactly what is and is not real
 * here. Scoped overrides of the same shared token-driven classes used elsewhere.
 */
[data-vi-screen="visualize"] .slot-card {
  border: 1px solid var(--vi-border);
  background: var(--vi-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
[data-vi-screen="visualize"] .slot-card--brain {
  border-color: var(--vi-accent);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 0 0 1px var(--vi-accent-glow);
}
[data-vi-screen="visualize"] .panel {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  box-shadow: none;
}
[data-vi-screen="visualize"] .panel-title h2,
[data-vi-screen="visualize"] h2 {
  color: var(--vi-text);
}
[data-vi-screen="visualize"] .brain-summary {
  border-bottom-color: var(--vi-border);
}
[data-vi-screen="visualize"] .brain-summary-grid dt {
  color: var(--vi-text-muted);
}
[data-vi-screen="visualize"] .brain-summary-grid dd {
  color: var(--vi-accent);
}
[data-vi-screen="visualize"] .trace-panel .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="visualize"] .trace-step {
  border-left-color: #2a3550;
}
[data-vi-screen="visualize"] .trace-step[data-active="true"] {
  border-left-color: var(--vi-accent);
}
[data-vi-screen="visualize"] .trace-step[data-active="true"]::before {
  background: var(--vi-accent);
}
[data-vi-screen="visualize"] .trace-step h3 {
  color: var(--vi-text);
}
[data-vi-screen="visualize"] .trace-step p {
  color: var(--vi-text-muted);
}

/* --- Collaborate's live V.I. Brain panel --------------------------------------------------- */

.brain-live:empty {
  display: none;
}
.brain-live-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  font-size: 0.875rem;
  color: var(--vi-text-muted);
}
.brain-live-status[data-state="failed"] {
  border-color: var(--status-critical);
  color: var(--status-critical);
}
.brain-live-status[data-state="done"] {
  color: var(--vi-text);
  font-weight: 600;
}
.brain-live-pulse {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--vi-accent);
  box-shadow: 0 0 0 0 var(--vi-accent-glow);
  animation: brain-live-pulse 1.1s ease-out infinite;
}
@keyframes brain-live-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--vi-accent-glow);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(77, 141, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(77, 141, 255, 0);
  }
}

/*
 * True incremental step lighting: each `<li>`'s `data-live-status` reflects the most recent real
 * SSE event for that step (main.ts re-renders the whole list on every real event, so a step's
 * visual state changes at the exact moment the server's event arrives, not on a fixed delay).
 * "pending" is dim (genuinely hasn't started), "in_progress" pulses the real accent color for
 * exactly as long as that real server-side phase takes, "done" settles to a solid, non-pulsing
 * accent border.
 */
.brain-live-steps {
  margin-bottom: 16px;
}
.brain-live-steps .trace-step {
  border-left-color: #2a3550;
  transition:
    border-color 150ms ease-out,
    opacity 150ms ease-out,
    box-shadow 150ms ease-out;
}
.brain-live-steps .trace-step[data-live-status="pending"] {
  opacity: 0.45;
}
.brain-live-steps .trace-step[data-live-status="in_progress"] {
  border-left-color: var(--vi-accent);
  opacity: 1;
  /* Soft ambient glow along the whole step, not just the dot, for exactly as long as this real
   * server-side phase is genuinely running — removed the instant `data-live-status` moves on. */
  box-shadow: -3px 0 10px -2px var(--vi-accent-glow);
}
.brain-live-steps .trace-step[data-live-status="in_progress"]::before {
  background: var(--vi-accent);
  animation: brain-live-pulse 1.1s ease-out infinite;
}
/*
 * The connecting line between an in-progress step and the next one "flows" toward it — a moving
 * gradient overlaid on the border, not a separate fake progress bar. This only ever renders on
 * the step the server is really in the middle of; it disappears the instant that step's real
 * `data-live-status` changes (main.ts replaces this list's innerHTML on every real SSE/step
 * event, so the animation restarts exactly when, and only when, a step genuinely re-enters
 * "in_progress" — never a timer independent of real state).
 */
.brain-live-steps .trace-step[data-live-status="in_progress"]::after {
  content: "";
  position: absolute;
  left: -2px;
  top: calc(var(--space-3) + 8px);
  bottom: calc(var(--space-3) * -1);
  width: 2px;
  background: linear-gradient(
    to bottom,
    var(--vi-accent) 0%,
    var(--vi-accent-glow) 50%,
    transparent 100%
  );
  background-size: 100% 200%;
  animation: brain-connector-flow 1.4s linear infinite;
}
.brain-live-steps .trace-step[data-live-status="done"] {
  border-left-color: #34d399;
  opacity: 1;
}
.brain-live-steps .trace-step[data-live-status="done"]::before {
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55);
  /* Plays once, the moment this step's real data first renders as "done" (a fresh DOM node from
   * main.ts's full-list re-render, so the animation genuinely restarts only on that real
   * transition) — never a looping decorative pulse once settled. */
  animation: brain-step-complete 550ms var(--motion-easing) 1;
}
.brain-live-steps .trace-step h3 {
  color: var(--vi-text);
}
@keyframes brain-connector-flow {
  0% {
    background-position: 0 100%;
  }
  100% {
    background-position: 0 -100%;
  }
}
@keyframes brain-step-complete {
  0% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55);
    transform: scale(1);
  }
  40% {
    box-shadow: 0 0 0 6px rgba(52, 211, 153, 0);
    transform: scale(1.35);
  }
  100% {
    box-shadow: 0 0 0 6px rgba(52, 211, 153, 0);
    transform: scale(1);
  }
}
/*
 * Stage E: Providers (real getProviderStatus() data via components/providers-view.ts) and
 * Settings (real connectionValues() + reopen of the existing, already-dark #setup-dialog).
 */
[data-vi-screen="execution"] section[data-field="providers-view"] h2,
[data-vi-screen="execution"] .card-group h3 {
  color: var(--vi-text);
}
[data-vi-screen="execution"] .card {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="execution"] .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="execution"] .badge {
  background: var(--vi-surface-raised);
  border-color: var(--vi-border);
}
[data-vi-screen="execution"] .badge[data-role="neutral"] {
  color: var(--vi-text-muted);
}
[data-vi-screen="execution"] .empty-state {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  color: var(--vi-text-muted);
}
.vi-settings-card {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  border-radius: 12px;
  padding: 20px;
  color: var(--vi-text);
  max-width: 480px;
}
.vi-settings-card h2 {
  margin-top: 0;
}
.appearance-selector {
  margin: 0;
  padding: 0;
  border: 0;
}
.appearance-selector legend {
  font-size: var(--type-heading);
  font-weight: 600;
}
.vi-settings-help {
  margin: var(--space-1) 0 var(--space-3);
  color: var(--vi-text-muted);
  font-size: var(--type-label);
}
.appearance-options {
  display: inline-flex;
  max-width: 100%;
  gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-md);
  background: var(--vi-surface-raised);
}
.appearance-options label {
  position: relative;
  cursor: pointer;
}
.appearance-options input {
  position: absolute;
  opacity: 0;
}
.appearance-options span {
  display: block;
  padding: var(--space-1) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--vi-text-muted);
  font-size: var(--type-label);
  font-weight: 600;
  transition:
    background-color var(--motion-micro) var(--motion-easing),
    border-color var(--motion-micro) var(--motion-easing),
    color var(--motion-micro) var(--motion-easing);
}
.appearance-options label:hover span {
  color: var(--vi-text);
}
.appearance-options input:checked + span {
  border-color: var(--vi-accent);
  background: var(--accent-glow-soft);
  color: var(--vi-text);
}
.appearance-options input:focus-visible + span {
  outline: var(--focus-outline);
  outline-offset: 2px;
}
.vi-settings-list {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}
.vi-settings-list dt {
  color: var(--vi-text-muted);
  font-size: 0.8125rem;
}
.vi-settings-list dd {
  margin: 2px 0 0;
  font-size: 0.9375rem;
  word-break: break-all;
}
#vi-settings-open-connection {
  background: var(--vi-accent-strong);
  color: var(--vi-text);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
}
.brain-live-steps .trace-step p {
  color: var(--vi-text-muted);
}

.vi-settings-subheading {
  margin: 0 0 var(--space-1);
  color: var(--vi-text-muted);
  font-size: var(--type-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.vi-settings-note {
  margin: 0 0 var(--space-3);
  color: var(--vi-text-muted);
  font-size: var(--type-label);
}

/* Bring Your Own Key (Settings). Reuses the same field styling language as .setup-dialog rather
 * than inventing a third input style. */
#byok-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}
#byok-form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--vi-text-muted);
}
#byok-form label[hidden] {
  display: none;
}
#byok-form label em {
  font-weight: 400;
  font-style: normal;
  opacity: 0.75;
}
#byok-form input,
#byok-form select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-sm);
  background: var(--vi-surface-raised);
  color: var(--vi-text);
  font-size: var(--type-label);
}
.byok-form-actions {
  display: flex;
  gap: var(--space-2);
}
#byok-status {
  margin: 0;
}
#byok-status.byok-status--active {
  color: var(--vi-accent);
}

/* Patent-development extraction review panel (Evidence screen). Reuses the same field styling
 * language as #byok-form rather than inventing a fourth input style. */
#patent-extraction-form {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  margin: var(--space-3) 0;
  flex-wrap: wrap;
}
#patent-extraction-form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--vi-text-muted);
  flex: 1 1 320px;
}
#patent-extraction-form input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-sm);
  background: var(--vi-surface-raised);
  color: var(--vi-text);
  font-size: var(--type-label);
}
#patent-extraction-status {
  margin: 0 0 var(--space-3);
  color: var(--vi-text-muted);
  font-size: var(--type-label);
}
#patent-extraction-results ul {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
#patent-extraction-results li {
  border: 1px solid var(--vi-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  background: var(--vi-surface-raised);
}
#patent-extraction-results li p:first-child {
  margin: 0 0 var(--space-1);
  color: var(--vi-text);
  font-weight: 600;
}
#patent-extraction-results blockquote {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-3);
  border-left: 2px solid var(--vi-border);
  color: var(--vi-text-muted);
  font-style: italic;
}

/* First visible manifestation: read-only compositions over the existing workspace responses. */
.manifest,
.project-map {
  display: grid;
  gap: 20px;
  margin-bottom: 24px;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid color-mix(in srgb, var(--vi-accent) 34%, var(--vi-border));
  border-radius: 18px;
  background:
    linear-gradient(color-mix(in srgb, var(--vi-accent) 7%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--vi-accent) 7%, transparent) 1px, transparent 1px),
    var(--vi-surface);
  background-size: 28px 28px;
  box-shadow: 0 18px 48px rgba(0, 18, 56, 0.16);
}
.manifest-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.manifest-heading h2,
.manifest-heading p {
  margin: 0;
}
.manifest-heading h2 {
  margin-top: 4px;
  font-size: clamp(1.4rem, 3vw, 2rem);
}
.manifest-heading p:last-child {
  margin-top: 6px;
  color: var(--vi-text-muted);
}
.manifest-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.manifest-card,
.project-map-node {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--vi-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--vi-surface-raised) 92%, transparent);
}
.manifest-card h3,
.manifest-card p,
.project-map-node p {
  margin: 0;
  overflow-wrap: anywhere;
}
.manifest-card h3 {
  margin: 6px 0;
  font-size: 1.05rem;
}
.manifest-card > p:last-child,
.project-map-node > p:last-child {
  color: var(--vi-text-muted);
}
.manifest-card--grounded,
.project-map-node--grounded {
  border-color: color-mix(in srgb, #37c8ff 58%, var(--vi-border));
  box-shadow: inset 3px 0 #37c8ff;
}
.manifest-card--conceptual,
.project-map-node--forming {
  border-color: color-mix(in srgb, #8b5cf6 58%, var(--vi-border));
  box-shadow: inset 3px 0 #8b5cf6;
}
.manifest-card--attention,
.project-map-node--attention {
  border-color: color-mix(in srgb, #fab219 62%, var(--vi-border));
  box-shadow: inset 3px 0 #fab219;
}
.project-map-node--unavailable {
  border-color: color-mix(in srgb, #898781 55%, var(--vi-border));
  box-shadow: inset 3px 0 #898781;
}
.manifest-facts {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
}
.manifest-facts div,
.manifest-ledger > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.manifest-facts dt,
.manifest-facts dd {
  margin: 0;
}
.manifest-ledger {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--vi-border);
  border-radius: 12px;
  background: var(--vi-border);
}
.manifest-ledger > div {
  min-width: 0;
  padding: 12px 14px;
  background: var(--vi-surface-raised);
  font-size: 0.85rem;
}
.manifest-state {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.manifest-state--active { color: #37c8ff; }
.manifest-state--neutral,
.manifest-state--unavailable { color: #898781; }
.manifest-boundary {
  margin: 0;
  color: var(--vi-text-muted);
  font-size: 0.82rem;
}
.manifest-system-state {
  margin-bottom: 24px;
  padding: 24px;
  border: 1px dashed var(--vi-border);
  border-radius: 14px;
  background: var(--vi-surface);
  color: var(--vi-text-muted);
}
.manifest-system-state p { margin: 0; }
.manifest-system-state .empty-state-title { color: var(--vi-text); }
.manifest-system-state--loading { border-color: var(--vi-accent); }
.manifest-system-state--error { border-color: #d03b3b; }
#environmental-context-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
#environmental-context-form label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  color: var(--vi-text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}
#environmental-context-form input,
#environmental-context-form textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--vi-border);
  border-radius: 8px;
  background: var(--vi-surface-raised);
  color: var(--vi-text);
  font: inherit;
  font-weight: 400;
}
#environmental-context-form button {
  justify-self: start;
}
.project-map-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
}
.project-map-connector {
  align-self: center;
  color: #37c8ff;
  font-size: 1.4rem;
}
.project-map-support-grid,
.decision-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.decision-boundary-card {
  border-color: color-mix(in srgb, #898781 45%, var(--vi-border));
}

@media (max-width: 980px) {
  .manifest-ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-map-flow { grid-template-columns: 1fr; }
  .project-map-connector { justify-self: center; transform: rotate(90deg); }
}
@media (max-width: 640px) {
  .manifest-grid,
  .manifest-ledger,
  .project-map-support-grid,
  .decision-overview-grid { grid-template-columns: 1fr; }
  .manifest-heading { flex-direction: column; }
  #environmental-context-form { grid-template-columns: 1fr; }
  [data-vi-screen="workspace"] .section-heading,
  [data-vi-screen="workspace"] .section-heading-actions {
    align-items: stretch;
    flex-direction: column;
  }
  [data-vi-screen="workspace"] .section-heading-actions { width: 100%; }
  [data-vi-screen="workspace"] .section-heading-actions .button { width: 100%; }
  .vi-rail-spacer { display: none; }
}
/* Closed, non-sensitive authentication outcome surface. */
.auth-result { max-width: 34rem; margin: 12vh auto; padding: 2rem; text-align: center; }
.auth-result img { width: 3rem; height: 3rem; }
.auth-result a { display: inline-block; margin-top: 1rem; }

/* Final visual-delivery layer: blueprint-black, conversation-first, and evidence governed. */
:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 78% -12%, var(--accent-glow-strong), transparent 32rem),
    radial-gradient(circle at 18% 96%, var(--accent-glow-soft), transparent 28rem),
    var(--vi-bg);
}

:root[data-theme="dark"] .vi-shell {
  position: relative;
  background:
    linear-gradient(color-mix(in srgb, var(--vi-accent) 5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--vi-accent) 5%, transparent) 1px, transparent 1px),
    transparent;
  background-size: 40px 40px;
}

.vi-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 5;
  backdrop-filter: blur(22px);
  background: color-mix(in srgb, var(--vi-surface) 86%, transparent);
}

:root[data-theme="dark"] .vi-rail {
  box-shadow: 18px 0 52px color-mix(in srgb, var(--vi-bg) 78%, transparent);
}

.vi-rail-brand {
  position: relative;
  margin-bottom: 12px;
}

.vi-rail-brand::after {
  content: "Governed collaboration";
  position: absolute;
  left: 66px;
  bottom: 5px;
  color: var(--vi-text-muted);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.vi-monogram {
  filter: drop-shadow(0 0 13px var(--vi-accent-glow));
}

.vi-rail-item {
  border: 1px solid transparent;
}

.vi-rail-item--active {
  border-color: color-mix(in srgb, var(--vi-accent) 48%, transparent);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--vi-accent) 28%, transparent), transparent),
    color-mix(in srgb, var(--vi-surface-raised) 78%, transparent);
  box-shadow:
    inset 3px 0 var(--vi-accent),
    0 8px 28px color-mix(in srgb, var(--vi-accent-glow) 54%, transparent);
}

.vi-header {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 86px;
  backdrop-filter: blur(22px);
  background: color-mix(in srgb, var(--vi-surface) 82%, transparent);
}

:root[data-theme="dark"] .vi-header-title {
  text-shadow: 0 0 24px var(--accent-glow-soft);
}

.vi-content {
  width: min(100%, 1600px);
  margin: 0 auto;
  padding: clamp(20px, 2.6vw, 42px);
}

.project-picker {
  position: relative;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--vi-accent) 28%, var(--vi-border));
  background: color-mix(in srgb, var(--vi-surface) 86%, transparent);
  box-shadow: inset 3px 0 color-mix(in srgb, var(--status-warning) 72%, transparent);
}

.workspace-command {
  position: relative;
  overflow: hidden;
  margin-bottom: 22px;
  padding: clamp(20px, 2.4vw, 30px);
  border: 1px solid color-mix(in srgb, var(--vi-accent) 38%, var(--vi-border));
  border-radius: 20px;
  background:
    radial-gradient(circle at 88% 5%, var(--accent-glow-soft), transparent 34%),
    color-mix(in srgb, var(--vi-surface) 88%, transparent);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--vi-text) 6%, transparent),
    0 26px 82px color-mix(in srgb, var(--vi-bg) 58%, transparent);
}

.workspace-command::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.38;
  background-image:
    linear-gradient(color-mix(in srgb, var(--vi-accent) 7%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--vi-accent) 7%, transparent) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

.workspace-command__heading {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  list-style: none;
  cursor: pointer;
}

.workspace-command__heading::-webkit-details-marker,
.workspace-command__heading::marker {
  display: none;
  content: "";
}

.workspace-command__heading h2 {
  margin: 4px 0 0;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
}

.integrity-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--status-neutral);
  background: color-mix(in srgb, currentColor 8%, transparent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  white-space: nowrap;
}

.integrity-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.integrity-chip[data-state="grounded"] { color: var(--vi-accent); }
.integrity-chip[data-state="attention"] { color: var(--status-warning); }

.workspace-intelligence-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.intelligence-cell {
  min-width: 0;
  padding: 16px 17px;
  border: 1px solid var(--vi-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--vi-surface-raised) 74%, transparent);
  backdrop-filter: blur(10px);
}

.intelligence-cell p { margin: 0; }
.intelligence-cell > p:not(.eyebrow) {
  margin-top: 7px;
  color: var(--vi-text);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.intelligence-cell > span {
  display: block;
  margin-top: 9px;
  color: var(--vi-text-muted);
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}
.intelligence-cell--anchor,
.intelligence-cell--working { grid-column: span 6; }
.intelligence-cell--progress,
.intelligence-cell--attention,
.intelligence-cell--action,
.intelligence-cell--evidence { grid-column: span 3; }
.intelligence-cell--anchor { box-shadow: inset 3px 0 var(--vi-accent); }
.intelligence-cell--working { box-shadow: inset 3px 0 color-mix(in srgb, var(--vi-accent) 62%, var(--status-neutral)); }
.intelligence-cell--attention { box-shadow: inset 3px 0 var(--status-warning); }
.intelligence-cell--action { box-shadow: inset 3px 0 color-mix(in srgb, var(--vi-accent) 65%, var(--status-warning)); }

[data-vi-screen="workspace"] .conversation-card {
  border-color: color-mix(in srgb, var(--vi-accent) 26%, var(--vi-border));
  border-radius: 20px;
  background:
    radial-gradient(circle at 92% 0, var(--accent-glow-soft), transparent 28%),
    color-mix(in srgb, var(--vi-surface) 92%, transparent);
  box-shadow: 0 30px 90px color-mix(in srgb, var(--vi-bg) 58%, transparent);
}

[data-vi-screen="workspace"] .conversation-feed {
  min-height: clamp(230px, 30vh, 380px);
}

[data-vi-screen="workspace"] .message-content {
  border-color: color-mix(in srgb, var(--vi-accent) 20%, var(--vi-border));
  background: color-mix(in srgb, var(--vi-surface-raised) 74%, transparent);
}

.interaction-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  padding: 13px 15px;
  border: 1px solid var(--vi-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--vi-surface-raised) 62%, transparent);
}

.interaction-status__pulse {
  width: 12px;
  height: 12px;
  border: 2px solid var(--status-neutral);
  border-radius: 50%;
}
.interaction-status[data-state="running"] {
  border-color: color-mix(in srgb, var(--vi-accent) 54%, var(--vi-border));
  box-shadow: inset 3px 0 var(--vi-accent);
}
.interaction-status[data-state="running"] .interaction-status__pulse {
  border-color: var(--vi-accent);
  box-shadow: 0 0 0 5px var(--accent-glow-soft), 0 0 20px var(--vi-accent-glow);
  animation: interaction-pulse 1.6s var(--motion-easing) infinite;
}
.interaction-status[data-state="completed"] { box-shadow: inset 3px 0 var(--status-good); }
.interaction-status[data-state="error"] { box-shadow: inset 3px 0 var(--status-critical); }
.interaction-status[data-state="cancelled"] { box-shadow: inset 3px 0 var(--status-warning); }
@keyframes interaction-pulse { 50% { transform: scale(1.25); opacity: 0.58; } }

.interaction-status__headline {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.interaction-status__headline p,
.interaction-status__body > p { margin: 0; }
.interaction-status__headline strong { font-size: 0.92rem; }
.interaction-status__body > p {
  margin-top: 3px;
  color: var(--vi-text-muted);
  font-size: 0.78rem;
}
.interaction-status__facts {
  display: none;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}
.interaction-status[data-state="running"] .interaction-status__facts,
.interaction-status--expanded .interaction-status__facts { display: flex; }
.interaction-status__facts span {
  padding: 3px 7px;
  border: 1px solid var(--vi-border);
  border-radius: 999px;
  color: var(--vi-text-muted);
  font-size: 0.68rem;
}
.interaction-status__actions {
  display: flex;
  gap: 8px;
}
.interaction-status__actions .button { white-space: nowrap; }

@media (max-width: 1100px) {
  .intelligence-cell--progress,
  .intelligence-cell--attention,
  .intelligence-cell--action,
  .intelligence-cell--evidence { grid-column: span 6; }
  .interaction-status { grid-template-columns: auto minmax(0, 1fr); }
  .interaction-status__actions { grid-column: 2; }
}

@media (max-width: 720px) {
  .vi-shell { display: block; }
  .vi-rail {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--vi-border);
  }
  .vi-rail-brand { margin: 0; padding: 0 8px 0 2px; }
  .vi-rail-brand::after,
  .vi-rail-brand-label,
  .vi-rail-item span:last-child,
  .vi-rail-spacer { display: none; }
  .vi-monogram { width: 40px; height: 40px; }
  .vi-rail-item { flex: 0 0 42px; justify-content: center; padding: 9px; }
  .vi-header { position: static; }
  .workspace-command__heading { flex-direction: column; }
  .intelligence-cell { grid-column: 1 / -1; }
  .interaction-status { grid-template-columns: 1fr; }
  .interaction-status__pulse { display: none; }
  .interaction-status__actions { grid-column: 1; flex-wrap: wrap; }
  .interaction-status__actions .button { flex: 1 1 150px; }
}

@media (max-width: 420px) {
  .vi-header-context-value { flex: 1 1 45%; }
  .vi-header-context .button { flex: 1 1 100%; }
  .vi-content { padding: 12px; }
  .workspace-command { padding: 16px; border-radius: 16px; }
  [data-vi-screen="workspace"] .conversation-card { border-radius: 16px; }
}

/* Approved Living V.I. runtime composition. The immersive workspace intentionally remains in the
   blueprint-black product palette even when account/settings surfaces use another appearance.
   --accent-intelligence is set to the approved royal/electric blue (#168cff, matching
   pixel-perfect-ui.css's --vi-primary-neon) rather than the older --vi-cyan token: this property
   inherits into every descendant of .vi-shell (focus rings via --focus-outline, the rail/header
   chrome below, badges, etc.), so pointing it at cyan here previously made the whole functional
   workspace read cyan-heavy on mobile, where the rail/header are visible and pixel-perfect-ui.css
   never recolors them (it only toggles their display). */
.vi-shell {
  --surface-page: var(--vi-bg-base);
  --surface-1: var(--vi-bg-panel);
  --surface-2: var(--vi-bg-raised);
  --ink-border: var(--vi-border-subtle);
  --ink-primary: #e8f7ff;
  --ink-secondary: #83a5ba;
  --accent-intelligence: #168cff;
  --accent-glow-strong: rgba(22, 140, 255, 0.38);
  min-height: 100dvh;
  background:
    radial-gradient(circle at 58% 18%, rgba(26, 162, 236, 0.09), transparent 34%),
    linear-gradient(180deg, #02050a, var(--vi-bg-base) 42%, #02060d);
  color: var(--vi-text);
}

.vi-rail {
  width: 88px;
  padding: 12px 8px;
  background: linear-gradient(180deg, rgba(4, 12, 24, 0.98), rgba(2, 8, 18, 0.98));
  border-right-color: rgba(22, 140, 255, 0.28);
  box-shadow: 12px 0 44px rgba(0, 50, 95, 0.15);
}
.vi-rail-brand {
  justify-content: center;
  padding: 2px 0 14px;
}
.vi-rail-brand-label { display: none; }
.vi-monogram {
  width: 54px;
  height: 54px;
  filter: drop-shadow(0 0 12px rgba(22, 140, 255, 0.65));
}
.vi-rail-item {
  min-height: 54px;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 7px 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.62rem;
  letter-spacing: 0.03em;
}
.vi-rail-item span:last-child { display: block; }
.vi-rail-icon { font-size: 1rem; }
.vi-rail-item--active {
  color: #eaffff;
  border-color: rgba(22, 140, 255, 0.65);
  background: linear-gradient(145deg, rgba(22, 140, 255, 0.18), rgba(26, 162, 236, 0.08));
  box-shadow: inset 0 0 18px rgba(22, 140, 255, 0.1), 0 0 18px rgba(22, 140, 255, 0.16);
}

.vi-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) minmax(520px, 3fr) auto;
  grid-template-areas: "primary context controls" "boundaries boundaries boundaries";
  align-items: stretch;
  gap: 8px 14px;
  padding: 10px 14px 8px;
  border-bottom-color: rgba(22, 140, 255, 0.34);
  background: rgba(3, 10, 20, 0.96);
  box-shadow: 0 10px 36px rgba(0, 30, 70, 0.2), inset 0 -1px rgba(22, 140, 255, 0.12);
  backdrop-filter: blur(18px);
}
.vi-header-primary {
  grid-area: primary;
  min-width: 0;
  align-self: center;
}
.vi-header-title {
  overflow: hidden;
  margin: 1px 0;
  color: #eaffff;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 16px rgba(22, 140, 255, 0.35);
}
.vi-header-project-id {
  overflow: hidden;
  margin: 0;
  color: var(--vi-text-muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.6rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vi-header-context {
  grid-area: context;
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 6px;
  text-align: left;
}
.vi-header-context-value {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid rgba(22, 140, 255, 0.16);
  border-radius: 7px;
  background: linear-gradient(145deg, rgba(12, 33, 53, 0.72), rgba(3, 14, 28, 0.8));
}
.vi-header-context-value--attention { border-color: rgba(255, 153, 0, 0.28); }
.vi-header-eyebrow {
  color: #5f91ae;
  font-size: 0.58rem;
}
.vi-header-northstar-value {
  display: -webkit-box;
  overflow: hidden;
  margin: 2px 0 0;
  color: #ccefff;
  font-size: 0.67rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.vi-header-controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: center;
  gap: 6px;
  min-width: 230px;
}
.vi-header-controls label {
  display: grid;
  gap: 2px;
  color: var(--vi-text-muted);
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.vi-header-controls select {
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid rgba(22, 140, 255, 0.26);
  border-radius: 6px;
  color: var(--vi-gray);
  background: rgba(5, 18, 34, 0.88);
  font-size: 0.65rem;
}
.vi-header-controls .button {
  min-height: 34px;
  margin: 0;
  padding: 5px 8px;
  border-color: rgba(22, 140, 255, 0.28);
  color: #99dfff;
  font-size: 0.65rem;
}
.vi-header-boundaries {
  grid-area: boundaries;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.vi-header-state {
  display: inline-flex;
  min-width: 0;
  padding: 3px 8px;
  border: 1px solid rgba(22, 140, 255, 0.18);
  border-radius: 999px;
  color: #7fb7cb;
  font-size: 0.58rem;
  white-space: nowrap;
}
.vi-header-state[data-state="grounded"] { color: var(--accent-intelligence); }
.vi-header-state[data-state="boundary"] {
  margin-left: auto;
  color: #a8c6d5;
}

.vi-content {
  padding: 10px;
  background:
    linear-gradient(rgba(43, 203, 247, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(43, 203, 247, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
}
[data-vi-screen="workspace"] {
  grid-template-columns: minmax(280px, 0.72fr) minmax(680px, 2.3fr);
  grid-template-areas: "state state" "conversation living";
  gap: 8px;
}
.workspace-mobile-tabs { display: none; }
[data-vi-screen="workspace"] .workspace-command {
  padding: 8px;
  border-color: rgba(43, 203, 247, 0.28);
  border-radius: 8px;
  background: rgba(4, 16, 31, 0.84);
  box-shadow: inset 0 0 22px rgba(43, 203, 247, 0.035);
}
.workspace-command__heading { margin-bottom: 7px; }
.workspace-command__heading h2 { margin: 0; font-size: 0.86rem; }
.workspace-intelligence-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 5px;
}
.intelligence-cell,
.intelligence-cell--anchor,
.intelligence-cell--working,
.intelligence-cell--progress,
.intelligence-cell--attention,
.intelligence-cell--action,
.intelligence-cell--evidence {
  grid-column: span 2;
  min-height: 58px;
  padding: 7px 8px;
  border-color: rgba(43, 203, 247, 0.17);
  border-radius: 6px;
  background: rgba(5, 18, 34, 0.8);
}
.intelligence-cell > p:not(.eyebrow) {
  margin: 2px 0;
  font-size: 0.67rem;
  line-height: 1.2;
}
.intelligence-cell > span { font-size: 0.58rem; line-height: 1.2; }
[data-vi-screen="workspace"] .conversation-card {
  height: min(69vh, 760px);
  min-height: 600px;
  padding: 10px;
  border-color: rgba(43, 203, 247, 0.3);
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(7, 23, 43, 0.96), rgba(3, 13, 27, 0.98));
  box-shadow: inset 0 0 28px rgba(43, 203, 247, 0.035), 0 0 30px rgba(0, 55, 100, 0.12);
}
[data-vi-screen="workspace"] .section-heading { margin-bottom: 7px; }
[data-vi-screen="workspace"] .section-heading h2 { margin: 0; font-size: 0.9rem; }
[data-vi-screen="workspace"] .conversation-feed {
  max-height: none;
  padding: 7px;
  border: 1px solid rgba(43, 203, 247, 0.1);
  border-radius: 6px;
  background: rgba(2, 10, 22, 0.56);
}
[data-vi-screen="workspace"] .message-content {
  border-color: rgba(43, 203, 247, 0.14);
  border-radius: 6px;
  background: rgba(10, 30, 50, 0.7);
  font-size: 0.75rem;
}
[data-vi-screen="workspace"] .composer { gap: 6px; padding-top: 7px; }
[data-vi-screen="workspace"] .composer textarea {
  min-height: 76px;
  border-color: rgba(43, 203, 247, 0.25);
  border-radius: 6px;
  background: rgba(2, 10, 22, 0.86);
  box-shadow: inset 0 0 18px rgba(43, 203, 247, 0.025);
}
[data-vi-screen="workspace"] .button--primary {
  background: linear-gradient(135deg, #006dc2, #00b9e8 58%, #2bcbf7);
  box-shadow: 0 0 20px rgba(43, 203, 247, 0.18);
}
.workspace-living-visual-panel .vi-field { min-height: 600px; height: min(69vh, 760px); }

@media (max-width: 1280px) {
  .vi-header {
    grid-template-columns: minmax(160px, 0.7fr) minmax(480px, 2.6fr);
    grid-template-areas: "primary controls" "context context" "boundaries boundaries";
  }
  .vi-header-controls { justify-self: end; }
  [data-vi-screen="workspace"] {
    grid-template-columns: minmax(270px, 0.8fr) minmax(600px, 2fr);
  }
}

@media (max-width: 1024px) {
  .vi-header {
    position: static;
    grid-template-columns: 1fr;
    grid-template-areas: "primary" "context" "controls" "boundaries";
  }
  .vi-header-context { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vi-header-controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-self: stretch;
  }
  [data-vi-screen="workspace"] {
    grid-template-columns: 1fr;
    grid-template-areas: "state" "conversation" "living";
  }
  [data-vi-screen="workspace"] .conversation-card,
  .workspace-living-visual-panel .vi-field {
    height: auto;
    min-height: 560px;
  }
}

@media (max-width: 720px) {
  .vi-rail {
    z-index: 40;
    width: 100%;
    padding: 6px;
    border-bottom-color: rgba(22, 140, 255, 0.28);
  }
  .vi-rail-brand { padding: 0 4px; }
  .vi-rail-item { min-height: 44px; flex: 0 0 44px; padding: 6px; }
  .vi-rail-item span:last-child { display: none; }
  .vi-header { padding: 9px; }
  .vi-header-context { grid-template-columns: 1fr 1fr; }
  .vi-header-context-value:last-child { grid-column: 1 / -1; }
  .vi-header-controls { grid-template-columns: 1fr 1fr; }
  .vi-header-controls label { display: none; }
  .vi-header-boundaries { align-items: stretch; flex-direction: column; }
  .vi-header-state,
  .vi-header-state[data-state="boundary"] { margin: 0; white-space: normal; }
  .vi-content { padding: 8px; }
  [data-vi-screen="workspace"] {
    display: grid;
    grid-template-areas: "mobile-tabs" "state" "conversation";
  }
  .workspace-mobile-tabs {
    grid-area: mobile-tabs;
    position: sticky;
    top: 0;
    z-index: 12;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border: 1px solid rgba(43, 203, 247, 0.22);
    border-radius: 8px;
    background: rgba(3, 13, 26, 0.96);
  }
  .workspace-mobile-tabs button {
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--vi-text-muted);
    background: transparent;
  }
  .workspace-mobile-tabs button[aria-selected="true"] {
    border-color: rgba(43, 203, 247, 0.48);
    color: #eaffff;
    background: rgba(43, 203, 247, 0.1);
  }
  [data-vi-screen="workspace"] .workspace-command { display: none; }
  [data-vi-screen="workspace"][data-mobile-view="conversation"] .conversation-card { display: flex; }
  [data-vi-screen="workspace"][data-mobile-view="conversation"] .workspace-living-visual-panel { display: none; }
  [data-vi-screen="workspace"][data-mobile-view="living"] .conversation-card { display: none; }
  [data-vi-screen="workspace"][data-mobile-view="living"] .workspace-living-visual-panel { display: block; }
  [data-vi-screen="workspace"][data-mobile-view="living"] .vi-field-inspector { display: none; }
  [data-vi-screen="workspace"][data-mobile-view="inspector"] .conversation-card { display: none; }
  [data-vi-screen="workspace"][data-mobile-view="inspector"] .workspace-living-visual-panel { display: block; }
  [data-vi-screen="workspace"][data-mobile-view="inspector"] .vi-field-status-grid,
  [data-vi-screen="workspace"][data-mobile-view="inspector"] .vi-field-stage,
  [data-vi-screen="workspace"][data-mobile-view="inspector"] .vi-path-comparison,
  [data-vi-screen="workspace"][data-mobile-view="inspector"] .manifest-ledger,
  [data-vi-screen="workspace"][data-mobile-view="inspector"] .manifest-boundary { display: none; }
  [data-vi-screen="workspace"] .conversation-card,
  .workspace-living-visual-panel .vi-field { min-height: calc(100dvh - 116px); }
}

/* Premium desktop correction aligned to the approved V.I. control-room reference. */
@media (min-width: 1281px) {
  .vi-rail {
    width: 74px;
    padding: 8px 6px;
  }
  .vi-rail-brand { padding-bottom: 8px; }
  .vi-monogram { width: 46px; height: 46px; }
  .vi-rail-item {
    min-height: 47px;
    padding: 5px 3px;
    font-size: 0.54rem;
  }
  .vi-header {
    grid-template-columns: minmax(150px, 0.62fr) minmax(590px, 3.3fr) minmax(230px, auto);
    gap: 5px 10px;
    padding: 7px 10px 5px;
  }
  .vi-header-context { gap: 4px; }
  .vi-header-context-value {
    min-height: 45px;
    padding: 5px 7px;
    border-radius: 4px;
  }
  .vi-header-title { font-size: 0.9rem; }
  .vi-header-northstar-value { font-size: 0.6rem; -webkit-line-clamp: 1; }
  .vi-header-controls { gap: 4px; }
  .vi-header-controls select,
  .vi-header-controls .button { min-height: 29px; border-radius: 4px; font-size: 0.57rem; }
  .vi-header-state { padding: 2px 6px; border-radius: 3px; font-size: 0.51rem; }
  .vi-content { padding: 6px; }
  [data-vi-screen="workspace"] {
    grid-template-columns: minmax(275px, 0.68fr) minmax(770px, 2.62fr);
    gap: 6px;
  }
  [data-vi-screen="workspace"] .workspace-command {
    padding: 6px;
    border-radius: 4px;
  }
  [data-vi-screen="workspace"] .workspace-command__heading {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  [data-vi-screen="workspace"] .workspace-intelligence-grid { gap: 3px; }
  [data-vi-screen="workspace"] .intelligence-cell,
  [data-vi-screen="workspace"] .intelligence-cell--anchor,
  [data-vi-screen="workspace"] .intelligence-cell--working,
  [data-vi-screen="workspace"] .intelligence-cell--progress,
  [data-vi-screen="workspace"] .intelligence-cell--attention,
  [data-vi-screen="workspace"] .intelligence-cell--action,
  [data-vi-screen="workspace"] .intelligence-cell--evidence {
    min-height: 46px;
    padding: 5px 6px;
    border-radius: 3px;
  }
  [data-vi-screen="workspace"] .intelligence-cell > p:not(.eyebrow) { font-size: 0.59rem; }
  [data-vi-screen="workspace"] .intelligence-cell > span { font-size: 0.5rem; }
  [data-vi-screen="workspace"] .conversation-card,
  .workspace-living-visual-panel .vi-field {
    height: min(75vh, 760px);
    min-height: 630px;
  }
  [data-vi-screen="workspace"] .conversation-card {
    padding: 7px;
    border-radius: 4px;
  }
  [data-vi-screen="workspace"] .section-heading { margin-bottom: 4px; }
  [data-vi-screen="workspace"] .section-heading h2 { font-size: 0.78rem; }
  [data-vi-screen="workspace"] .section-heading-actions { gap: 4px; }
  [data-vi-screen="workspace"] .section-heading-actions .button { min-height: 28px; padding: 4px 7px; font-size: 0.56rem; }
  [data-vi-screen="workspace"] .brain-live:empty { display: none; }
  [data-vi-screen="workspace"] .interaction-status {
    margin: 0 0 5px;
    padding: 6px;
    border-radius: 4px;
    gap: 6px;
  }
  [data-vi-screen="workspace"] .interaction-status__pulse { width: 8px; height: 8px; }
  [data-vi-screen="workspace"] .interaction-status__headline strong { font-size: 0.66rem; }
  [data-vi-screen="workspace"] .interaction-status__body > p { font-size: 0.55rem; }
  [data-vi-screen="workspace"] .interaction-status__actions .button { min-height: 26px; padding: 3px 6px; font-size: 0.52rem; }
  [data-vi-screen="workspace"] .conversation-feed { padding: 5px; }
  [data-vi-screen="workspace"] .message { gap: 5px; margin-bottom: 5px; }
  [data-vi-screen="workspace"] .message-avatar { width: 24px; height: 24px; }
  [data-vi-screen="workspace"] .message-content { padding: 6px 7px; font-size: 0.64rem; }
  [data-vi-screen="workspace"] .message-meta { font-size: 0.52rem; }
  [data-vi-screen="workspace"] .composer textarea { min-height: 60px; padding: 7px; font-size: 0.66rem; }
  [data-vi-screen="workspace"] .composer-footer-hint { font-size: 0.5rem; }
  [data-vi-screen="workspace"] .provider-select-label { font-size: 0.5rem; }
  [data-vi-screen="workspace"] .provider-select-label select { min-height: 28px; font-size: 0.56rem; }
  [data-vi-screen="workspace"] #send-message { min-height: 32px; padding: 5px 8px; font-size: 0.58rem; }
}

/* Final single-screen proportion correction against the approved lifecycle workspace references. */
@media (min-width: 1281px) {
  html,
  body {
    min-height: 100%;
    background: #02050a;
  }
  body { margin: 0; overflow: hidden; }
  .vi-shell {
    width: 100%;
    height: min(100dvh, calc(100vw / 1.82));
    min-height: 0;
    overflow: hidden;
  }
  .vi-main {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .vi-header {
    position: relative;
    flex: 0 0 68px;
    grid-template-rows: 43px 16px;
    gap: 3px 8px;
    height: 68px;
    min-height: 0;
    padding: 4px 8px 3px;
    overflow: hidden;
    box-sizing: border-box;
  }
  .vi-header-primary { align-self: center; }
  .vi-header-title { font-size: 0.78rem; }
  .vi-header-project-id { font-size: 0.49rem; }
  .vi-header-context {
    height: 43px;
    gap: 3px;
  }
  .vi-header-context-value {
    min-height: 0;
    height: 43px;
    padding: 4px 6px;
    box-sizing: border-box;
  }
  .vi-header-eyebrow { font-size: 0.47rem; }
  .vi-header-northstar-value {
    margin-top: 1px;
    font-size: 0.53rem;
    line-height: 1.15;
  }
  .vi-header-controls {
    grid-template-columns: 1fr 1fr;
    align-content: start;
    height: 43px;
  }
  .vi-header-controls label span { display: none; }
  .vi-header-controls select,
  .vi-header-controls .button {
    min-height: 20px;
    height: 20px;
    padding: 2px 5px;
    font-size: 0.49rem;
  }
  .vi-header-boundaries {
    height: 16px;
    gap: 4px;
  }
  .vi-header-state {
    height: 15px;
    padding: 1px 5px;
    font-size: 0.46rem;
    line-height: 1;
    box-sizing: border-box;
  }
  .vi-content {
    flex: 1 1 auto;
    min-height: 0;
    height: calc(100% - 68px);
    padding: 4px;
    overflow: hidden;
    box-sizing: border-box;
  }
  [data-vi-screen="workspace"] {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(255px, 0.75fr) minmax(0, 2.7fr);
    grid-template-areas: "conversation living";
    gap: 4px;
  }
  [data-vi-screen="workspace"] .workspace-command { display: none; }
  [data-vi-screen="workspace"] .conversation-card,
  .workspace-living-visual-panel,
  .workspace-living-visual-panel .vi-field {
    height: 100%;
    min-height: 0;
  }
  [data-vi-screen="workspace"] .conversation-card {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 4px;
    padding: 5px;
    overflow: hidden;
  }
  [data-vi-screen="workspace"] .section-heading {
    min-height: 29px;
    margin: 0;
  }
  [data-vi-screen="workspace"] .section-heading h2 { font-size: 0.68rem; }
  [data-vi-screen="workspace"] .section-heading .eyebrow { font-size: 0.44rem; }
  [data-vi-screen="workspace"] #clear-conversation { display: none; }
  [data-vi-screen="workspace"] .live-badge {
    padding: 2px 5px;
    font-size: 0.44rem;
  }
  [data-vi-screen="workspace"] .interaction-status[data-state="idle"] {
    grid-template-columns: 8px minmax(0, 1fr);
    min-height: 30px;
    margin: 0;
    padding: 4px 6px;
  }
  [data-vi-screen="workspace"] .interaction-status[data-state="idle"] .interaction-status__body > p,
  [data-vi-screen="workspace"] .interaction-status[data-state="idle"] .interaction-status__actions,
  [data-vi-screen="workspace"] .interaction-status[data-state="idle"] .interaction-status__headline .eyebrow {
    display: none;
  }
  [data-vi-screen="workspace"] .interaction-status[data-state="idle"] .interaction-status__headline strong {
    font-size: 0.56rem;
  }
  [data-vi-screen="workspace"] .conversation-feed {
    min-height: 0;
    height: auto;
    overflow-y: auto;
  }
  [data-vi-screen="workspace"] .message-content {
    padding: 5px 6px;
    font-size: 0.56rem;
    line-height: 1.35;
  }
  [data-vi-screen="workspace"] .message-content p { margin: 3px 0; }
  [data-vi-screen="workspace"] .message-avatar { width: 20px; height: 20px; }
  [data-vi-screen="workspace"] .composer {
    min-height: 78px;
    padding-top: 4px;
  }
  [data-vi-screen="workspace"] .composer textarea {
    min-height: 42px;
    max-height: 58px;
    padding: 6px;
  }
  [data-vi-screen="workspace"] .composer-footer { gap: 4px; }
  [data-vi-screen="workspace"] .composer-footer-hint > span:first-child { display: none; }
  [data-vi-screen="workspace"] .provider-select-label { gap: 2px; }
}

/* Approved V.I. blueprint palette, scoped to the singular runtime workspace. */
:root[data-theme="dark"] .vi-header,
:root[data-theme="dark"] .vi-rail,
:root[data-theme="dark"] .vi-content,
:root[data-theme="dark"] [data-vi-screen="workspace"] .conversation-card {
  background-color: var(--vi-bg-base);
}
:root[data-theme="dark"] [data-vi-screen="workspace"] .conversation-card,
:root[data-theme="dark"] .workspace-living-visual-panel .vi-runtime {
  border-color: rgba(26, 162, 236, 0.72);
  box-shadow: inset 0 0 14px rgba(26, 162, 236, 0.1), 0 0 7px rgba(26, 162, 236, 0.28);
}
:root[data-theme="dark"] [data-vi-screen="workspace"] .message-content,
:root[data-theme="dark"] [data-vi-screen="workspace"] .conversation-feed,
:root[data-theme="dark"] [data-vi-screen="workspace"] .composer textarea {
  background: var(--vi-bg-base);
  border-color: rgba(26, 162, 236, 0.4);
}

/* Phase 2.2 — Easy/Instant renderer scene-transition classes. These are
   applied by manifestation-easy-renderer.ts's transitionTo() from the exact
   same SceneTransition (diffRenderScene) the Advanced 3D renderer reads;
   the keyframes below are the only place the *visual* meaning of assembly,
   growth, fracture, and healing is defined for this renderer, matched to
   the Advanced renderer's equivalent timings (600/700/900/900/400ms). */
.vi-easy-node--assembling {
  animation: vi-easy-assemble 600ms ease;
}
@keyframes vi-easy-assemble {
  from {
    filter: drop-shadow(0 0 0 rgba(139, 233, 255, 0));
  }
  to {
    filter: drop-shadow(0 0 6px rgba(139, 233, 255, 0.6));
  }
}

.vi-easy-node--removing {
  pointer-events: none;
}

.vi-easy-node--fracture-pulse {
  animation: vi-easy-fracture-pulse 900ms ease-out;
}
@keyframes vi-easy-fracture-pulse {
  0% {
    filter: drop-shadow(0 0 0 rgba(255, 92, 110, 0));
  }
  15% {
    filter: drop-shadow(0 0 10px rgba(255, 92, 110, 0.95));
  }
  100% {
    filter: drop-shadow(0 0 0 rgba(255, 92, 110, 0));
  }
}

.vi-easy-node--healing {
  animation: vi-easy-heal-pulse 900ms ease-in;
}
@keyframes vi-easy-heal-pulse {
  0% {
    filter: drop-shadow(0 0 10px rgba(143, 255, 173, 0.85));
  }
  100% {
    filter: drop-shadow(0 0 0 rgba(143, 255, 173, 0));
  }
}

.vi-easy-edge--fracture-pulse {
  animation: vi-easy-edge-fracture-pulse 900ms ease-out;
}
@keyframes vi-easy-edge-fracture-pulse {
  0% {
    stroke-width: 1.6;
  }
  15% {
    stroke-width: 3.2;
  }
  100% {
    stroke-width: 1.6;
  }
}

/* Phase 2.2 follow-up — the persistent visual consequence, on a component's
   OWN circle, of it being an endpoint of a currently-fractured relation (or,
   if ever set, its own resolved state — the two reasons manifestation-easy-
   renderer.ts ORs together). This is steady, unlike the transient pulse/heal
   keyframes above: it exists for as long as the node is touched by at least
   one fractured relation, and both `.vi-easy-node--fracture-pulse` (on
   arrival) and `.vi-easy-node--healing` (on departure) still fire on top of
   it for the moment of change. */
.vi-easy-node--fractured {
  stroke: #ff5c6e;
  stroke-width: 2;
  stroke-dasharray: 2 2;
}
