/* ==========================================================================
   The Ledger — design tokens (design doc §10)
   Identity: institutional memory = patina of time + the wax seal of authority.
   Dark-first, Linear/Raycast-grade restraint. Hairlines, not shadows.
   ========================================================================== */

:root {
  /* Canvas + surfaces */
  --canvas: #0b0e0d;
  --surface-1: #111413;
  --surface-2: #161a18;
  --surface-3: #1a1f1d;
  --hairline: #242a27;

  /* Accent: verdigris (the thread of continuity) */
  --verdigris: #2e8c7a;
  --verdigris-bright: #3fb6a0;

  /* Signet gold — ONLY for authority sign-off seals. Never decorative. */
  --signet-gold: #c9a24b;

  /* Caution + conflict */
  --amber: #d9a441;
  --conflict-red: #d1564e;

  /* Neutral status copy (non-conflict messages) — keeps --conflict-red
     reserved for genuine "sources disagree" UI. */
  --status-neutral: var(--text-3);

  /* Text */
  --text-1: #f4f6f5;
  --text-2: #c2c9c5;
  --text-3: #8a938e;
  --text-4: #5e6661;

  /* Warm paper — canonical reading view only */
  --paper: #f5f2ea;
  --paper-ink: #26231c;
  --paper-ink-muted: #5a5548;
  --paper-hairline: #ddd6c4;

  /* Type stacks */
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;

  /* Radius ladder */
  --r-1: 6px;
  --r-2: 8px;
  --r-3: 12px;
  --r-4: 16px;

  /* 4px spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --dur-fast: 120ms;
  --dur-med: 200ms;

  /* Node-kind palette — Browse (Slice 6). One swatch per `NodeKind`, reused
     by both the col-2 kind dot and the neighborhood-graph `<circle>` fill.
     Raw sources stay verdigris (continuity with the rest of the app);
     LLM-derived rollups get their own cool tones so they never read as raw
     source; decisions reuse the existing amber "attention" tone. */
  --kind-document: var(--verdigris-bright);
  --kind-condensed_memory: #8d86dd;
  --kind-thread: #5b93d6;
  --kind-conversation_summary: #63b7c4;
  --kind-conversation_decision: var(--amber);
  --kind-canonical_page: var(--text-3);
  --kind-tombstone: var(--text-4);
  --kind-default: var(--text-3);

  color-scheme: dark;
}

/* ==========================================================================
   Reset + base
   ========================================================================== */

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--verdigris-bright);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

/* ==========================================================================
   Shell layout
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.rail {
  background: var(--surface-1);
  border-right: 1px solid var(--hairline);
  padding: var(--sp-6) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-2);
}

.rail-mark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--verdigris);
  box-shadow: 0 0 0 3px rgba(46, 140, 122, 0.18);
}

.rail-word {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-1);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1;
}

.rail-item {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  text-align: left;
  padding: var(--sp-3) var(--sp-3);
  color: var(--text-3);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.rail-item:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

.rail-item.is-active {
  background: var(--surface-3);
  color: var(--text-1);
  border-color: var(--hairline);
}

.rail-identity {
  border-top: 1px solid var(--hairline);
  padding-top: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.rail-identity-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-4);
  padding: 0 var(--sp-1);
}

.rail-identity-input {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 13px;
}

.rail-identity-hint {
  font-size: 11px;
  color: var(--text-4);
  padding: 0 var(--sp-1);
  line-height: 1.4;
}

.rail-asof-input {
  color-scheme: dark;
}

.rail-asof-input:focus-visible {
  outline: none;
  border-color: var(--verdigris);
  box-shadow: 0 0 0 2px rgba(46, 140, 122, 0.25);
}

/* ==========================================================================
   As-of (bitemporal time-travel) indicator
   ========================================================================== */

.asof-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--verdigris-bright);
  background: rgba(63, 182, 160, 0.1);
  border: 1px solid rgba(63, 182, 160, 0.28);
  border-radius: 999px;
  padding: 2px var(--sp-3);
  margin-top: var(--sp-2);
}

.ask-hero .asof-badge {
  margin: var(--sp-2) 0 0;
}

.view-header .asof-badge {
  margin-top: var(--sp-3);
}

.stage {
  padding: var(--sp-16) var(--sp-10) var(--sp-16);
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: view-in var(--dur-med) var(--ease);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-header {
  margin-bottom: var(--sp-8);
}

.view-title {
  font-size: 26px;
  font-weight: 590;
  letter-spacing: -0.015em;
  margin: 0 0 var(--sp-1);
}

.view-subtitle {
  color: var(--text-3);
  font-size: 14px;
}

/* ==========================================================================
   Ask (hero)
   ========================================================================== */

.ask-hero {
  padding-top: var(--sp-10);
  margin-bottom: var(--sp-8);
  text-align: center;
}

.ask-title {
  font-size: 34px;
  font-weight: 590;
  letter-spacing: -0.02em;
  color: var(--text-1);
  margin: 0 0 var(--sp-6);
}

.ask-form {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  padding: var(--sp-2);
  gap: var(--sp-2);
  transition: border-color var(--dur-med) var(--ease), background var(--dur-med) var(--ease);
}

.ask-form:focus-within {
  border-color: var(--verdigris);
  background: var(--surface-3);
}

.ask-form-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-1);
  padding: var(--sp-1) var(--sp-2);
  flex-shrink: 0;
}

.ask-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-1);
  font-size: 16px;
  font-weight: 500;
  padding: var(--sp-3) var(--sp-2);
}

.ask-input::placeholder {
  color: var(--text-4);
}

.ask-input:focus {
  outline: none;
}

.ask-submit,
.inline-submit {
  appearance: none;
  border: none;
  background: var(--verdigris);
  color: #06110d;
  font-weight: 590;
  font-size: 13.5px;
  border-radius: var(--r-2);
  padding: var(--sp-3) var(--sp-5);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.ask-submit:hover,
.inline-submit:hover {
  background: var(--verdigris-bright);
}

.ask-submit:active,
.inline-submit:active {
  transform: scale(0.98);
}

.ask-status {
  min-height: 1px;
  color: var(--status-neutral);
  font-size: 13.5px;
  text-align: center;
  margin-bottom: var(--sp-4);
}

.ask-status:empty {
  margin: 0;
}

/* ==========================================================================
   Retrieving shimmer
   ========================================================================== */

.retrieving-shimmer {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-6);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
}

.shimmer-line {
  height: 12px;
  border-radius: var(--r-1);
  background: linear-gradient(
    100deg,
    var(--surface-2) 30%,
    var(--surface-3) 50%,
    var(--surface-2) 70%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.shimmer-line-lg {
  width: 92%;
}
.shimmer-line-md {
  width: 78%;
}
.shimmer-line-sm {
  width: 55%;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ==========================================================================
   Empty states
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  border: 1px dashed var(--hairline);
  border-radius: var(--r-3);
  color: var(--text-3);
}

.empty-state-title {
  font-size: 16px;
  font-weight: 590;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}

.empty-state-body {
  font-size: 13.5px;
  color: var(--text-3);
  max-width: 46ch;
  margin: 0 auto;
  line-height: 1.6;
}

/* ==========================================================================
   Answer card
   ========================================================================== */

.answer-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-4);
  padding: var(--sp-6);
  animation: view-in var(--dur-med) var(--ease);
}

.answer-confidence {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  font-weight: 590;
  letter-spacing: 0.01em;
  padding: var(--sp-1) var(--sp-3);
  border-radius: 999px;
  margin-bottom: var(--sp-4);
  border: 1px solid transparent;
}

.answer-confidence::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.answer-confidence.confidence-high {
  color: var(--verdigris-bright);
  background: rgba(63, 182, 160, 0.1);
  border-color: rgba(63, 182, 160, 0.25);
}

.answer-confidence.confidence-medium {
  color: var(--text-2);
  background: var(--surface-2);
  border-color: var(--hairline);
}

.answer-confidence.confidence-low {
  color: var(--amber);
  background: rgba(217, 164, 65, 0.1);
  border-color: rgba(217, 164, 65, 0.25);
}

.answer-text {
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-1);
  margin-bottom: var(--sp-6);
  white-space: pre-wrap;
}

/* streamed-in answer text */
.answer-text .answer-word {
  display: inline-block;
  opacity: 0;
  animation: word-in var(--dur-med) var(--ease) forwards;
}

@keyframes word-in {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.conflict-callout {
  background: rgba(209, 86, 78, 0.08);
  border: 1px solid rgba(209, 86, 78, 0.3);
  border-radius: var(--r-3);
  padding: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.conflict-title {
  font-size: 13px;
  font-weight: 590;
  color: var(--conflict-red);
  margin: 0 0 var(--sp-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.conflict-notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-3);
}

.conflict-notes li {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--sp-3);
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}

.answer-citations {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* ==========================================================================
   Provenance chips
   ========================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--sp-2) var(--sp-3);
  font-size: 12.5px;
  color: var(--text-2);
}

.chip-source {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-weight: 590;
  color: var(--text-1);
}

.chip-source::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
}

.chip-source.source-slack::before {
  background: var(--amber);
}
.chip-source.source-jira::before {
  background: var(--text-2);
}
.chip-source.source-confluence::before {
  background: var(--verdigris-bright);
}
.chip-source.source-wiki::before {
  background: var(--text-3);
}
.chip-source.source-other::before,
.chip-source.source-test::before {
  background: var(--text-4);
}
/* Extends the swatch convention to `Workspace.kind` (Browse col 1 — Slice 6),
   a distinct vocabulary from document `source` above (connected-source
   instance rather than per-document origin). */
.chip-source.source-github::before {
  background: var(--text-2);
}
.chip-source.source-google_drive::before {
  background: var(--verdigris);
}
.chip-source.source-notion::before {
  background: var(--text-3);
}
.chip-source.source-email::before {
  background: var(--amber);
}

.chip-updated {
  font-family: var(--font-mono);
  color: var(--text-3);
  font-size: 11.5px;
}

.chip-seal {
  color: var(--signet-gold);
  display: inline-flex;
  align-items: center;
  font-weight: 590;
}

.chip-trace {
  appearance: none;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: var(--r-1);
  color: var(--verdigris-bright);
  font-size: 11.5px;
  font-weight: 590;
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.chip-trace:hover {
  border-color: var(--verdigris);
  background: rgba(46, 140, 122, 0.1);
}

/* ==========================================================================
   Inline forms (spine / canonical / experts topic inputs)
   ========================================================================== */

.inline-form {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-6);
}

.inline-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--sp-3) var(--sp-3);
  color: var(--text-1);
  font-size: 14px;
}

.inline-input::placeholder {
  color: var(--text-4);
}

/* ==========================================================================
   Decision Spine
   ========================================================================== */

.spine-thread {
  position: relative;
  padding-left: var(--sp-8);
}

.spine-thread::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(var(--verdigris), var(--verdigris-bright));
  opacity: 0.55;
}

.spine-node {
  position: relative;
  padding-bottom: var(--sp-8);
}

.spine-node:last-child {
  padding-bottom: 0;
}

.spine-node::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--sp-8) + 2px);
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 2px solid var(--verdigris-bright);
  box-shadow: 0 0 0 3px var(--canvas);
}

.spine-node.is-current::before {
  background: var(--verdigris-bright);
}

.spine-node-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  padding: var(--sp-4);
}

.spine-node.is-current .spine-node-card {
  border-color: var(--verdigris);
}

.spine-node-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.spine-timestamp {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
}

.spine-current-badge {
  font-size: 10.5px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--verdigris-bright);
  background: rgba(63, 182, 160, 0.12);
  border: 1px solid rgba(63, 182, 160, 0.3);
  border-radius: 999px;
  padding: 2px var(--sp-2);
}

.spine-seal {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--signet-gold);
  font-size: 12px;
  font-weight: 590;
}

.spine-seal-icon {
  display: inline-flex;
}

.spine-snippet {
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.6;
}

.spine-actors {
  margin-top: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
}

/* ==========================================================================
   Experts
   ========================================================================== */

.experts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-3);
}

.expert-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.expert-rank {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-4);
}

.expert-id {
  font-size: 16px;
  font-weight: 590;
  color: var(--text-1);
}

.expert-stats {
  display: flex;
  gap: var(--sp-4);
}

.expert-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.expert-stat-value {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-1);
}

.expert-stat-value.is-sealed {
  color: var(--signet-gold);
}

.expert-stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-4);
}

/* ==========================================================================
   Canonical / warm-paper reading view
   ========================================================================== */

.paper {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: var(--r-4);
  padding: var(--sp-10) var(--sp-8);
  border: 1px solid var(--paper-hairline);
}

.paper-body {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.75;
  white-space: pre-wrap;
  margin-bottom: var(--sp-6);
}

.paper-citations {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  border-top: 1px solid var(--paper-hairline);
  padding-top: var(--sp-4);
}

.paper .chip {
  background: #ece7d8;
  border-color: var(--paper-hairline);
  color: var(--paper-ink-muted);
}

.paper .chip-source {
  color: var(--paper-ink);
}

.paper .chip-updated {
  color: var(--paper-ink-muted);
}

/* Reused answer-card components (confidence pill, conflict callout) restyled
   for legibility against the warm paper background. */
.paper .answer-confidence.confidence-medium {
  background: #ece7d8;
  border-color: var(--paper-hairline);
  color: var(--paper-ink-muted);
}

.paper .conflict-callout {
  background: rgba(209, 86, 78, 0.06);
  border-color: rgba(209, 86, 78, 0.25);
}

.paper .conflict-notes li {
  background: #ece7d8;
  border-color: var(--paper-hairline);
  color: var(--paper-ink-muted);
}

/* ==========================================================================
   Browse — Team/Workspace navigator + neighborhood graph (Slice 6)
   ========================================================================== */

.browse-columns {
  display: grid;
  grid-template-columns: 200px 320px 1fr;
  gap: var(--sp-5);
  align-items: start;
}

.browse-col {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  padding: var(--sp-4);
  min-width: 0;
}

.browse-col-title {
  font-size: 12px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-4);
  margin: 0 0 var(--sp-3);
}

.browse-col-empty {
  padding: var(--sp-6) var(--sp-3);
}

/* --- Col 1: Team / Workspace tree --- */

.browse-tree {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.browse-team + .browse-team {
  border-top: 1px solid var(--hairline);
  padding-top: var(--sp-3);
}

.browse-team-name {
  font-size: 13px;
  font-weight: 590;
  color: var(--text-2);
  margin: 0 0 var(--sp-2);
}

.browse-ws-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.browse-ws-btn {
  appearance: none;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  padding: var(--sp-2) var(--sp-2);
  cursor: pointer;
  color: var(--text-3);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.browse-ws-btn:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

.browse-ws-btn.is-selected {
  background: var(--surface-3);
  border-color: var(--hairline);
}

.browse-ws-btn.is-selected .chip-source {
  color: var(--text-1);
}

.browse-ws-btn .chip-source {
  font-size: 12.5px;
  color: inherit;
}

/* --- Col 2: kind segmented control + node list --- */

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: 2px;
  margin-bottom: var(--sp-4);
}

.segmented-btn {
  appearance: none;
  flex: 1 1 auto;
  background: transparent;
  border: none;
  border-radius: var(--r-1);
  padding: var(--sp-2) var(--sp-2);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 590;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.segmented-btn:hover {
  color: var(--text-2);
}

.segmented-btn.is-pressed {
  background: var(--surface-3);
  color: var(--text-1);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.browse-node-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.browse-node-row {
  display: block;
}

.browse-node-btn {
  appearance: none;
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--sp-3);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.browse-node-btn:hover {
  border-color: var(--verdigris);
}

.browse-node-btn.is-selected {
  border-color: var(--verdigris);
  background: var(--surface-3);
}

.browse-node-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.browse-node-preview {
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.browse-load-more {
  margin-top: var(--sp-4);
  width: 100%;
}

/* Kind dot — shared by the col-2 row badge and the graph legend/nodes. */
.kind-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
  background: var(--kind-default);
}

.kind-dot.kind-document {
  background: var(--kind-document);
}
.kind-dot.kind-condensed_memory {
  background: var(--kind-condensed_memory);
}
.kind-dot.kind-thread {
  background: var(--kind-thread);
}
.kind-dot.kind-conversation_summary {
  background: var(--kind-conversation_summary);
}
.kind-dot.kind-conversation_decision {
  background: var(--kind-conversation_decision);
}
.kind-dot.kind-canonical_page {
  background: var(--kind-canonical_page);
}
.kind-dot.kind-tombstone {
  background: var(--kind-tombstone);
}

/* --- Col 3: detail panel --- */

.browse-derived-banner {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 11px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--signet-gold);
  background: rgba(201, 162, 75, 0.1);
  border: 1px solid rgba(201, 162, 75, 0.28);
  border-radius: 999px;
  padding: 2px var(--sp-3);
  margin-bottom: var(--sp-3);
}

.browse-detail-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.browse-detail-content {
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  margin-bottom: var(--sp-4);
  max-height: 340px;
  overflow-y: auto;
}

.browse-detail-actions {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.browse-rel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.browse-rel-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--sp-1) var(--sp-3);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease);
}

.browse-rel-chip:hover {
  border-color: var(--verdigris);
}

.browse-rel-chip-kind {
  font-family: var(--font-mono);
  color: var(--verdigris-bright);
  font-weight: 590;
}

/* --- Neighborhood graph (secondary surface) --- */

.browse-neighborhood {
  margin-top: var(--sp-6);
  border-top: 1px solid var(--hairline);
  padding-top: var(--sp-5);
}

.browse-graph-wrap {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  padding: var(--sp-3);
  margin-bottom: var(--sp-4);
  overflow-x: auto;
}

.browse-graph-svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 560px;
  margin: 0 auto;
}

.graph-edge {
  stroke: var(--hairline);
  stroke-width: 1.4;
}

.graph-edge-label {
  fill: var(--text-4);
  font-family: var(--font-mono);
  font-size: 8.5px;
}

.graph-node {
  cursor: pointer;
}

.graph-node:focus-visible {
  outline: 2px solid var(--verdigris-bright);
  outline-offset: 3px;
  border-radius: 50%;
}

.node-dot {
  fill: var(--kind-default);
  stroke: var(--canvas);
  stroke-width: 2;
  transition: fill var(--dur-fast) var(--ease);
}

.node-dot.kind-document {
  fill: var(--kind-document);
}
.node-dot.kind-condensed_memory {
  fill: var(--kind-condensed_memory);
}
.node-dot.kind-thread {
  fill: var(--kind-thread);
}
.node-dot.kind-conversation_summary {
  fill: var(--kind-conversation_summary);
}
.node-dot.kind-conversation_decision {
  fill: var(--kind-conversation_decision);
}
.node-dot.kind-canonical_page {
  fill: var(--kind-canonical_page);
}
.node-dot.kind-tombstone {
  fill: var(--kind-tombstone);
}

.node-dot.is-root {
  stroke: var(--verdigris-bright);
  stroke-width: 3;
}

.node-seal-ring {
  fill: none;
  stroke: var(--signet-gold);
  stroke-width: 1.6;
}

.node-label {
  fill: var(--text-2);
  font-size: 9.5px;
  font-family: var(--font-ui);
  text-anchor: middle;
}

.browse-fallback-title {
  font-size: 12px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-4);
  margin: 0 0 var(--sp-2);
}

.browse-graph-fallback {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.browse-graph-fallback-btn {
  appearance: none;
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  transition: border-color var(--dur-fast) var(--ease);
}

.browse-graph-fallback-btn:hover {
  border-color: var(--verdigris);
}

/* ==========================================================================
   Connections — OAuth connection broker (Slice 7)
   ========================================================================== */

.conn-banner {
  border-radius: var(--r-2);
  padding: var(--sp-3) var(--sp-4);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: var(--sp-4);
}

.conn-banner.is-success {
  color: var(--verdigris-bright);
  background: rgba(63, 182, 160, 0.1);
  border: 1px solid rgba(63, 182, 160, 0.28);
}

.conn-banner.is-error {
  color: var(--conflict-red);
  background: rgba(209, 86, 78, 0.1);
  border: 1px solid rgba(209, 86, 78, 0.3);
}

.conn-group {
  margin-bottom: var(--sp-8);
}

.conn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
}

.conn-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

.conn-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.conn-provider {
  font-size: 15px;
  font-weight: 590;
  color: var(--text-1);
}

.conn-kind-tag {
  font-size: 10.5px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-4);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 1px var(--sp-2);
  flex-shrink: 0;
}

.conn-none {
  font-size: 12.5px;
  color: var(--text-4);
}

.conn-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.conn-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
}

.conn-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.conn-ws {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-1);
  word-break: break-all;
}

.conn-status {
  font-size: 10.5px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  padding: 1px var(--sp-2);
  flex-shrink: 0;
}

.conn-status.is-connected {
  color: var(--verdigris-bright);
  background: rgba(63, 182, 160, 0.12);
}

.conn-status.is-expired {
  color: var(--amber);
  background: rgba(217, 164, 65, 0.12);
}

.conn-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
}

.conn-meta-item {
  font-size: 11.5px;
  color: var(--text-3);
  word-break: break-word;
}

.conn-disconnect {
  align-self: flex-start;
  margin-top: var(--sp-1);
}

.conn-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  border-top: 1px solid var(--hairline);
  padding-top: var(--sp-3);
}

.conn-field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-4);
}

.conn-input {
  width: 100%;
  font-size: 13px;
}

.conn-connect,
.conn-save {
  align-self: flex-start;
}

.conn-connect {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

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

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 860px) {
  .stage {
    padding: var(--sp-8) var(--sp-4) var(--sp-16);
  }

  .ask-title {
    font-size: 26px;
  }

  .browse-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: var(--sp-3) var(--sp-4);
    border-right: none;
    border-bottom: 1px solid var(--hairline);
    z-index: 10;
    gap: var(--sp-4);
    overflow-x: auto;
  }

  .rail-nav {
    flex-direction: row;
  }

  .rail-identity {
    border-top: none;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
  }

  .rail-identity-hint {
    display: none;
  }
}
