:root {
  color-scheme: dark;
  --canvas: #010102;
  --surface-1: #0f1011;
  --surface-2: #141516;
  --surface-3: #18191a;
  --hairline: #23252a;
  --hairline-strong: #34343a;
  --ink: #f7f8f8;
  --ink-muted: #d0d6e0;
  --ink-subtle: #8a8f98;
  --accent: #5e6ad2;
  --accent-hover: #828fff;
  --success: #27a644;
  --review: #8b7cf6;
  --warning: #f1c21b;
  --danger: #da1e28;
  --orange: #d97706;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset;
}

:root[data-theme="light"] {
  color-scheme: light;
  --canvas: #ffffff;
  --surface-1: #f4f4f4;
  --surface-2: #ffffff;
  --surface-3: #e8e8e8;
  --hairline: #d9d9d9;
  --hairline-strong: #a8a8a8;
  --ink: #161616;
  --ink-muted: #393939;
  --ink-subtle: #6f6f6f;
  --accent: #0f62fe;
  --accent-hover: #0043ce;
  --success: #24a148;
  --review: #6f45d8;
  --warning: #b28600;
  --danger: #da1e28;
  --orange: #b65c00;
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: -0.01em;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.8), transparent 65%);
}

:root[data-theme="light"] body::before {
  background:
    linear-gradient(rgba(0,0,0,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.035) 1px, transparent 1px);
  background-size: 32px 32px;
}

.topbar {
  position: relative;
  z-index: 2;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -.03em;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.topbar-links a,
.theme-toggle {
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink-subtle);
  background: transparent;
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  text-decoration: none;
}

.topbar-links a:hover,
.theme-toggle:hover,
.topbar-links a[aria-current="page"] {
  border-color: var(--hairline-strong);
  color: var(--ink);
  background: var(--surface-1);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
  align-items: end;
  max-width: 1440px;
  margin: 0 auto;
  padding: 34px 32px 20px;
}

.hero-copy { max-width: 980px; }

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--ink-subtle);
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
}

.section-kicker {
  margin-bottom: 5px;
  font-size: 11px;
}

h1, h2, h3, h4, p { margin-top: 0; }

h1 {
  margin-bottom: 12px;
  max-width: 980px;
  font-size: clamp(38px, 5vw, 72px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.055em;
}

h2 { font-size: 20px; line-height: 1.2; letter-spacing: -0.03em; }
h3 { font-size: 17px; line-height: 1.25; letter-spacing: -0.02em; }

.subtitle {
  max-width: 860px;
  margin-bottom: 0;
  color: var(--ink-subtle);
  font-size: 17px;
  line-height: 1.55;
}

.hero-ledger {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.hero-ledger span,
.badge,
.chip,
.readonly-note,
.tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .01em;
  padding: 4px 8px;
}

.mode-card,
.proof-card,
.summary-card,
.sidebar,
.timeline-panel,
.detail-card,
.trace-panel,
.transcript-panel,
.story-panel,
.agent-mesh-panel {
  border: 1px solid var(--hairline);
  background: var(--surface-1);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.mode-card {
  padding: 16px;
}

.mode-card p {
  color: var(--ink-subtle);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 0;
}

.badge.safe { color: #b7f3c4; border-color: rgba(39,166,68,.35); background: rgba(39,166,68,.12); }
.badge.static { color: #ffe58a; border-color: rgba(241,194,27,.35); background: rgba(241,194,27,.11); }
.badge.error { color: #ffb4b4; border-color: rgba(218,30,40,.45); background: rgba(218,30,40,.12); }

.proof-grid {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 32px 18px;
}

.proof-card {
  min-height: 112px;
  padding: 14px;
}

.proof-card span {
  color: var(--ink-subtle);
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.proof-card strong { display: block; margin-bottom: 8px; }
.proof-card p { color: var(--ink-subtle); font-size: 13px; line-height: 1.45; margin-bottom: 0; }

.layout {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 276px 1fr;
  gap: 18px;
  padding: 0 32px 28px;
}

.sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
  padding: 14px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header.compact { margin-bottom: 10px; }
.panel-header h2, .detail-card h3 { margin: 0; }

button {
  border: 1px solid var(--hairline-strong);
  color: var(--ink);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

button:hover { border-color: var(--accent); color: var(--ink); }

.room-list { display: grid; gap: 8px; }

.room-item {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 5px;
  padding: 11px;
  background: var(--surface-2);
  border-radius: 8px;
}

.room-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(94,106,210,.18) inset;
}

.room-title { font-weight: 600; }
.room-meta, .hint, .muted, small, .notes { color: var(--ink-subtle); }
.hint { margin-top: 12px; font-size: 12px; line-height: 1.45; }

.boundary-note {
  border-top: 1px solid var(--hairline);
  margin-top: 16px;
  padding-top: 14px;
}

.boundary-note span {
  color: var(--warning);
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.boundary-note p { color: var(--ink-subtle); font-size: 12px; line-height: 1.45; margin: 0; }

.main-panel { display: grid; gap: 14px; min-width: 0; }

.summary-grid {
  display: grid;
  grid-template-columns: 1.3fr .8fr 1fr;
  gap: 10px;
}

.summary-card {
  padding: 14px;
}

.summary-card .label {
  display: block;
  color: var(--ink-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 7px;
}

.summary-card strong { display: block; font-size: 19px; overflow-wrap: anywhere; }
.summary-card p { color: var(--ink-subtle); font-size: 13px; margin: 7px 0 0; }
.summary-card a { color: var(--accent-hover); text-decoration: none; }

.agent-mesh-panel,
.timeline-panel,
.story-panel,
.trace-panel,
.transcript-panel { padding: 14px; }

.agent-list { display: grid; gap: 8px; }
.agent-strip { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.agent-card {
  position: relative;
  min-height: 142px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.agent-card::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;
  height: 2px;
  background: var(--accent);
}

.agent-card.agent-evidence::before { background: var(--success); }
.agent-card.agent-review::before { background: var(--review); }
.agent-card.agent-remediation::before { background: var(--orange); }
.agent-card.agent-reporting::before { background: var(--warning); }
.agent-card.unconfigured { border-color: rgba(241,194,27,.45); }

.agent-handle {
  color: var(--ink-muted);
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  margin-bottom: 5px;
}

.agent-card strong { display: block; margin-bottom: 6px; line-height: 1.2; }
.agent-card p { color: var(--ink-subtle); font-size: 12px; line-height: 1.42; margin-bottom: 9px; }
.agent-capabilities { display: flex; flex-wrap: wrap; gap: 4px; }
.compact-empty { font-size: 12px; padding: 10px; }

.timeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--hairline);
  border-radius: 8px;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 112px;
  padding: 12px;
  border-right: 1px solid var(--hairline);
  background: var(--surface-2);
}

.stage:last-child { border-right: 0; }

.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ink-subtle);
  margin-bottom: 10px;
}

.stage.complete .stage-dot { background: var(--success); }
.stage.active .stage-dot { background: var(--accent); }
.stage.blocked .stage-dot { background: var(--warning); }
.stage.error .stage-dot { background: var(--danger); }
.stage span { display: block; color: var(--ink-subtle); margin: 5px 0; font-size: 12px; }
.stage p { color: var(--ink-subtle); font-size: 12px; line-height: 1.38; margin-bottom: 0; }

.card-flow { display: grid; gap: 8px; }

.story-card {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.story-card.evidence { border-left: 2px solid var(--success); }
.story-card.review { border-left: 2px solid var(--review); }
.story-card.report { border-left: 2px solid var(--accent); }
.story-card.closeout { border-left: 2px solid var(--warning); }
.story-card.task { border-left: 2px solid var(--hairline-strong); }
.story-card.remediation { border-left: 2px solid var(--orange); }

.story-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.story-head span {
  color: var(--ink-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.story-head em {
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--ink-subtle);
  display: inline-flex;
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
  margin: 0 0 4px 4px;
  padding: 2px 6px;
  text-transform: uppercase;
}

.story-card h3 { margin: 0 0 7px; }
.story-card p { color: var(--ink-muted); line-height: 1.45; margin-bottom: 8px; }

.story-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.story-details div,
.story-item {
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface-3);
  padding: 8px;
}

.story-details span {
  color: var(--ink-subtle);
  display: block;
  font-size: 10px;
  letter-spacing: .03em;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.story-details strong { overflow-wrap: anywhere; }
.story-item { margin-top: 6px; }
.story-item p { color: var(--ink-subtle); font-size: 12px; margin: 4px 0 0; }

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-card {
  padding: 14px;
  min-height: 248px;
}

.detail-intro {
  color: var(--ink-subtle);
  font-size: 12px;
  line-height: 1.45;
  margin: 7px 0 0;
}

.stack { display: grid; gap: 8px; margin-top: 12px; }

.mini-card,
.trace-row,
.message {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 11px;
}

.mini-card.accent { border-color: rgba(139,124,246,.45); }
.mini-card strong { display: block; margin: 7px 0; }
.mini-card p { color: var(--ink-muted); line-height: 1.42; margin-bottom: 7px; }
.chip { color: var(--accent-hover); padding: 3px 7px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.chip.priority { color: var(--warning); }
.tag { margin: 0; font-size: 10px; padding: 2px 6px; }

.field-block { margin-top: 8px; }

.field-block > span {
  display: block;
  color: var(--ink-subtle);
  font-size: 10px;
  letter-spacing: .03em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.raw-excerpt { margin-top: 8px; }
.raw-excerpt summary { color: var(--ink-muted); cursor: pointer; font-size: 12px; }
.review-subsection h4 { color: var(--ink-subtle); margin: 16px 0 8px; }
.mini-card.nested { background: var(--surface-3); }

.check-row { border-left: 2px solid var(--hairline-strong); margin-top: 8px; padding-left: 9px; }
.check-row.passed { border-color: var(--success); }
.check-row.failed { border-color: var(--danger); }
.check-row.unknown { border-color: var(--warning); }
.check-row p { color: var(--ink-subtle); margin: 4px 0 0; }

.traceability { display: grid; gap: 8px; }

.trace-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.trace-row div { border-left: 1px solid var(--hairline-strong); padding-left: 9px; }
.trace-row span { display: block; color: var(--ink-subtle); font-size: 10px; text-transform: uppercase; letter-spacing: .03em; }
.trace-row p { grid-column: 1 / -1; color: var(--ink-subtle); margin-bottom: 0; }

.compact-proof { background: rgba(15,16,17,.9); }
.transcript { display: grid; gap: 8px; max-height: 500px; overflow: auto; padding-right: 4px; }
.message-head { display: flex; justify-content: space-between; color: var(--ink-subtle); margin-bottom: 8px; }
.message-head strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

.asap-block {
  border-left: 2px solid var(--review);
  padding-left: 10px;
  margin: 7px 0;
}

.asap-block.core-executed,
.message.core-executed-message { border-color: rgba(39,166,68,.45); }
.core-marker { color: #b7f3c4; font-size: 10px; font-weight: 600; margin-right: 10px; }

pre {
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 10px;
  background: var(--canvas);
  color: var(--ink-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.loading, .empty, .error {
  border: 1px dashed var(--hairline-strong);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink-subtle);
}

.error { color: #ffb4b4; border-color: rgba(218,30,40,.45); }

footer {
  max-width: 1376px;
  margin: 0 auto 32px;
  padding: 14px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  color: var(--ink-subtle);
  background: var(--surface-1);
  font-size: 13px;
}

code {
  color: var(--ink-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Plan B local chatroom */
.chat-layout {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  padding: 0 32px 28px;
}

.chat-sidebar { min-height: 720px; }
.chat-field { display: grid; gap: 6px; margin-bottom: 14px; }
.chat-field span { color: var(--ink-subtle); font-size: 11px; text-transform: uppercase; }

.chat-field input,
.chat-compose textarea {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-2);
  padding: 10px 12px;
  font: inherit;
}

.mesh-panel { border-top: 1px solid var(--hairline); margin-top: 16px; padding-top: 14px; }
.role-list { display: grid; gap: 8px; }

.role-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 11px;
}

.role-option input { margin-top: 4px; }
.role-option strong, .role-option em, .role-option small { display: block; }
.role-option strong { color: var(--ink-muted); }
.role-option em { color: var(--ink-subtle); font-size: 11px; font-style: normal; letter-spacing: .03em; margin: 3px 0; text-transform: uppercase; }
.chat-main { min-width: 0; }
.local-chat-panel { min-height: 560px; }
.local-chat-messages { display: grid; gap: 8px; max-height: 620px; overflow: auto; padding-right: 4px; }
.chat-message { border: 1px solid var(--hairline); border-radius: 8px; background: var(--surface-2); padding: 11px; }
.chat-message.human-message { border-left: 2px solid var(--accent); }
.chat-message.agent-message { border-left: 2px solid var(--success); }
.chat-message pre { max-height: 360px; margin-bottom: 0; }
.chat-compose { display: grid; gap: 10px; margin-top: 14px; }
.snapshot-preview { max-height: 420px; }

@media (max-width: 1220px) {
  .agent-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .hero, .layout, .chat-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .proof-grid, .summary-grid, .details-grid, .timeline { grid-template-columns: 1fr; }
  .stage { border-right: 0; border-bottom: 1px solid var(--hairline); }
  .stage:last-child { border-bottom: 0; }
  .trace-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; padding-left: 18px; padding-right: 18px; }
  .topbar-links { margin-left: 0; flex-wrap: wrap; }
  .hero, .proof-grid, .layout, .chat-layout { padding-left: 18px; padding-right: 18px; }
  footer { margin-left: 18px; margin-right: 18px; }
  .agent-strip { grid-template-columns: 1fr; }
  .panel-header { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
