/*
 * 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
 * prefers-color-scheme AND via a data-theme toggle the viewer controls, matching each other.
 */

: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;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    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);
  }
}
: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 {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--radius-md);
  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: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-intelligence);
  color: #fff;
  font-size: var(--type-label);
  font-weight: 700;
}
.message--user .message-avatar {
  background: var(--surface-4);
  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-route-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-health {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.brain-summary-health p {
  margin: 0;
  font-weight: 600;
}
.brain-summary-health[data-role="good"] p {
  color: var(--status-good);
}
.brain-summary-health[data-role="serious"] p {
  color: var(--status-serious);
}
.brain-summary-health[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;
  }
  .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: midnight-black/navy surfaces, silver-white type, one electric-blue accent —
 * hardcoded here (not the light/dark-switchable token set above) because this identity is fixed,
 * not theme-dependent.
 */
:root {
  --vi-bg: #05070d;
  --vi-surface: #0b0f1a;
  --vi-surface-raised: #121826;
  --vi-border: rgba(150, 175, 255, 0.14);
  --vi-text: #f4f7fd;
  --vi-text-muted: #aab4cc;
  --vi-accent: #4d8dff;
  --vi-accent-strong: #1d4ed8;
  --vi-accent-glow: rgba(77, 141, 255, 0.35);
}

.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 {
  /* icons/mark.svg is the real, approved V.I. mark — a rounded-square metallic-blue gradient
     with a designed 14px corner radius baked into the asset itself. It must render unclipped,
     never forced into a circle (which would crop the gradient and the shine highlight). */
  border-radius: 22%;
  box-shadow: 0 0 0 1px var(--vi-border), 0 0 16px var(--vi-accent-glow);
}
.vi-rail-brand-label {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--vi-text);
}

.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: rgba(77, 141, 255, 0.1);
  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-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-northstar {
  text-align: right;
}
.vi-header-northstar-value {
  margin: 2px 0 0;
  color: var(--vi-text);
  font-weight: 600;
  max-width: 420px;
}

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

.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-northstar {
    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="collaborate"]. 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="collaborate"] .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);
}
[data-vi-screen="collaborate"] .section-heading h2 {
  color: var(--vi-text);
}
[data-vi-screen="collaborate"] .eyebrow {
  color: var(--vi-text-muted);
}
[data-vi-screen="collaborate"] .live-badge {
  color: #34d399;
  border-color: #34d399;
}
[data-vi-screen="collaborate"] .live-badge::before {
  background: #34d399;
}
.section-heading-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
[data-vi-screen="collaborate"] .section-heading-actions .button--secondary {
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="collaborate"] .section-heading-actions .button--secondary:hover {
  border-color: var(--vi-accent);
  color: var(--vi-text);
}
[data-vi-screen="collaborate"] .message-content {
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="collaborate"] .message--user .message-content {
  background: #16233f;
}
[data-vi-screen="collaborate"] .message-avatar {
  background: var(--vi-accent);
}
[data-vi-screen="collaborate"] .message--user .message-avatar {
  background: var(--vi-surface-raised);
  color: var(--vi-text);
}
[data-vi-screen="collaborate"] .message-meta {
  color: var(--vi-text-muted);
}
[data-vi-screen="collaborate"] .composer textarea {
  background: var(--vi-bg);
  color: var(--vi-text);
  border: 1px solid var(--vi-border);
}
[data-vi-screen="collaborate"] .composer-footer {
  color: var(--vi-text-muted);
}
[data-vi-screen="collaborate"] .provider-select-label {
  color: var(--vi-text-muted);
}
[data-vi-screen="collaborate"] .provider-select-label select {
  background: var(--vi-surface-raised);
  color: var(--vi-text);
  border: 1px solid var(--vi-border);
}
[data-vi-screen="collaborate"] .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="doctor"] .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="doctor"] section[data-field="doctor-view"] h2 {
  color: var(--vi-text);
}
[data-vi-screen="doctor"] .card {
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="doctor"] .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="doctor"] .empty-state {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  color: var(--vi-text-muted);
}
[data-vi-screen="doctor"] .empty-state-title {
  color: var(--vi-text);
}
[data-vi-screen="doctor"] .badge {
  background: var(--vi-surface-raised);
  border-color: var(--vi-border);
}
[data-vi-screen="doctor"] .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="history"] .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="history"] section[data-field="auditor-module-activity"] h2 {
  color: var(--vi-text);
}
[data-vi-screen="history"] .card {
  background: var(--vi-surface-raised);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="history"] .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="history"] .empty-state {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  color: var(--vi-text-muted);
}
[data-vi-screen="history"] .empty-state-title {
  color: var(--vi-text);
}
[data-vi-screen="history"] .auditor-activity-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
[data-vi-screen="history"] .auditor-activity-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--vi-bg);
  border: 1px solid var(--vi-border);
  overflow: hidden;
}
[data-vi-screen="history"] .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="brain"] .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="brain"] .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="brain"] .panel {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  box-shadow: none;
}
[data-vi-screen="brain"] .panel-title h2,
[data-vi-screen="brain"] h2 {
  color: var(--vi-text);
}
[data-vi-screen="brain"] .brain-summary {
  border-bottom-color: var(--vi-border);
}
[data-vi-screen="brain"] .brain-summary-grid dt {
  color: var(--vi-text-muted);
}
[data-vi-screen="brain"] .brain-summary-grid dd {
  color: var(--vi-accent);
}
[data-vi-screen="brain"] .trace-panel .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="brain"] .trace-step {
  border-left-color: #2a3550;
}
[data-vi-screen="brain"] .trace-step[data-active="true"] {
  border-left-color: var(--vi-accent);
}
[data-vi-screen="brain"] .trace-step[data-active="true"]::before {
  background: var(--vi-accent);
}
[data-vi-screen="brain"] .trace-step h3 {
  color: var(--vi-text);
}
[data-vi-screen="brain"] .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="providers"] section[data-field="providers-view"] h2,
[data-vi-screen="providers"] .card-group h3 {
  color: var(--vi-text);
}
[data-vi-screen="providers"] .card {
  background: var(--vi-surface);
  border: 1px solid var(--vi-border);
  color: var(--vi-text);
}
[data-vi-screen="providers"] .label {
  color: var(--vi-text-muted);
}
[data-vi-screen="providers"] .badge {
  background: var(--vi-surface-raised);
  border-color: var(--vi-border);
}
[data-vi-screen="providers"] .badge[data-role="neutral"] {
  color: var(--vi-text-muted);
}
[data-vi-screen="providers"] .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;
}
.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);
}
