:root {
  --surface-0: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #ffffff;
  --surface-3: #ffffff;
  --paper: var(--surface-1);
  --paper-deep: var(--surface-0);
  --paper-light: var(--surface-2);
  --ink: #151515;
  --ink-soft: #525252;
  --muted: #6d6b67;
  --clay: #d97757;
  --clay-deep: #b8593b;
  --clay-hover: #cc5a36;
  --clay-soft: #fbf3ef;
  --moss: #10b981;
  --line: rgba(0, 0, 0, 0.10);
  --hairline: rgba(0, 0, 0, 0.06);
  --line-strong: rgba(0, 0, 0, 0.20);
  --display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --header: 48px;
  --side: 288px;
  --rail: 384px;
  --radius-8: 8px;
  --radius-10: 10px;
  --radius-12: 12px;
  --radius-16: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.05), 0 6px 16px rgba(0, 0, 0, 0.08);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

[hidden] { display: none !important; }

html { background: var(--paper); }

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

p { margin: 0; }

::selection { background: var(--clay); color: var(--paper-light); }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 300;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--ink);
  transform: translateY(-180%);
  font: 500 11px/1 var(--mono);
}
.skip-link:focus { transform: translateY(0); }

.eyebrow {
  font: 500 11px/1.2 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--clay-deep);
}

/* ---------- header ---------- */

.demo-header {
  position: relative;
  z-index: 40;
  flex: 0 0 var(--header);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  color: var(--ink);
  background: var(--surface-1);
  border-bottom: 1px solid var(--line);
}

.demo-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.demo-brand em {
  font-style: normal;
  color: var(--muted);
}
.brand-mark { display: grid; grid-template-columns: repeat(3, 5px); gap: 2px; }
.brand-mark i { width: 5px; height: 5px; background: currentColor; }
.brand-mark i:nth-child(2) { background: var(--clay); }
.brand-mark i:nth-child(3) { grid-column: 1 / -1; width: 19px; height: 5px; }

.header-center {
  display: flex;
  align-items: center;
  gap: 16px;
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.header-center span + span::before {
  content: "·";
  margin-right: 16px;
  color: var(--line-strong);
}
.header-center .header-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
}
.header-state i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--moss);
}

.demo-nav {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.demo-nav a { padding: 8px 0; transition: color 120ms var(--ease); }
.demo-nav a:hover { color: var(--ink); }

/* ---------- shell ---------- */

.workbench {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr) var(--rail);
}

.mobile-tabs { display: none; }

/* ---------- left rail ---------- */

.rail {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 0 10px;
  border-right: 1px solid var(--line);
  background: var(--surface-0);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--hairline);
}
.rail-brand .brand-mark { color: var(--ink); }
.rail-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.rail-brand-text strong {
  font: 600 12px/1.2 var(--sans);
  letter-spacing: 0.01em;
}
.rail-brand-text em {
  font: 400 11px/1.2 var(--sans);
  font-style: normal;
  color: var(--muted);
}

.rail-trip { padding: 14px 16px 12px; }
.rail-trip h2 {
  margin: 5px 0 0;
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.rail-trip-when {
  margin-top: 6px;
  font: 400 11px/1.5 var(--sans);
  color: var(--ink-soft);
}
.rail-trip-where {
  font: 400 11px/1.5 var(--sans);
  color: var(--muted);
}
.rail-trip-session {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
  font: 500 11px/1.4 var(--sans);
  color: var(--clay-deep);
}

.rail-sessions {
  padding: 8px 8px 12px;
  border-bottom: 1px solid var(--hairline);
}
.rail-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px 8px;
}
.rail-section-head > span {
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.02em;
  color: var(--muted);
}
.session-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.session-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-8);
  background: transparent;
  text-align: left;
  transition: background 120ms var(--ease);
}
.session-item:hover { background: rgba(0, 0, 0, 0.04); }
.session-item.is-active { background: rgba(0, 0, 0, 0.06); }
.session-num {
  flex: 0 0 auto;
  padding-top: 1px;
  font: 400 11px/1 var(--mono);
  color: var(--muted);
}
.session-item.is-active .session-num { color: var(--clay-deep); }
.session-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.session-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font: 400 11px/1.2 var(--mono);
  color: var(--muted);
}
.session-top span:first-child { color: var(--ink-soft); }
.session-item.is-active .session-top span:first-child { color: var(--clay-deep); }
.session-copy strong {
  font-size: 12px;
  font-weight: 580;
  line-height: 1.35;
  color: var(--ink);
}
.session-foot {
  font: 400 11px/1.3 var(--sans);
  color: var(--muted);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px 12px;
  border-bottom: 1px solid var(--hairline);
}
.rail-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-8);
  font: 500 12px/1.2 var(--sans);
  color: var(--ink-soft);
  transition: color 120ms var(--ease), background 120ms var(--ease);
}
.rail-link:hover { color: var(--ink); background: rgba(0, 0, 0, 0.04); }
.rail-link.is-active { color: var(--ink); background: rgba(0, 0, 0, 0.06); }
.rail-index {
  font: 400 11px/1 var(--mono);
  color: var(--muted);
}
.rail-link.is-active .rail-index { color: var(--clay-deep); }

.rail-health {
  margin: 0 8px;
  padding: 12px 8px;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
}
.rail-stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 9px 0 0;
}
.rail-stats div { min-width: 0; }
.rail-stats dt {
  font: 400 11px/1 var(--mono);
  color: var(--muted);
}
.rail-stats dd {
  margin: 4px 0 0;
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.rail-meter {
  height: 4px;
  margin-top: 10px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.rail-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: var(--clay);
  transition: width 300ms var(--ease);
}
.rail-budget {
  margin-top: 6px;
  font: 400 11px/1.4 var(--sans);
  color: var(--muted);
}
.rail-checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 0;
  padding: 9px 0 0;
  border-top: 1px solid var(--hairline);
  list-style: none;
}
.rail-checks li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font: 400 11px/1.45 var(--sans);
  color: var(--muted);
}
.rail-checks .dot {
  flex: 0 0 auto;
  margin-top: 5px;
}

.rail-foot {
  margin-top: auto;
  padding: 14px 16px 0;
  font: 400 11px/1.55 var(--sans);
  color: var(--muted);
}

.graph-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
}

.graph-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 64px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-1);
}

.trip-meta { flex: 1 1 auto; min-width: 0; max-width: calc(100% - 244px); }
.trip-meta h1 {
  margin: 3px 0 3px;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.trip-sub {
  font: 400 11px/1.4 var(--sans);
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.trip-sub span { margin: 0 4px; color: var(--line-strong); }

.graph-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.zoom-controls {
  display: flex;
  align-items: center;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  background: var(--surface-2);
}
.zoom-controls button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-8);
  background: transparent;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1;
}
.zoom-controls button:hover { background: rgba(0, 0, 0, 0.05); }
.zoom-controls span {
  min-width: 38px;
  text-align: center;
  font: 400 11px/1 var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ghost-btn,
.add-btn,
.danger-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  background: transparent;
  font: 500 11px/1 var(--sans);
  color: var(--ink-soft);
  transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
}
.ghost-btn:hover { background: rgba(0, 0, 0, 0.04); color: var(--ink); }
.add-btn {
  background: var(--ink);
  color: var(--surface-2);
  border-color: var(--ink);
}
.add-btn:hover { background: #2b2b2b; border-color: #2b2b2b; }
.danger-btn {
  color: var(--clay-deep);
  border-color: rgba(217, 119, 87, 0.35);
}
.danger-btn:hover { background: var(--clay-soft); }

.graph-hint {
  flex: 0 0 auto;
  display: flex;
  gap: 18px;
  padding: 6px 20px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-0);
  font: 400 11px/1.4 var(--sans);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.graph-hint span + span::before {
  content: "/";
  margin-right: 18px;
  color: var(--line-strong);
}

.graph-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  outline: 0;
  cursor: grab;
  touch-action: none;
  background-color: var(--surface-1);
  background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.10) 1px, transparent 0);
  background-size: 20px 20px;
}
.graph-viewport:active { cursor: grabbing; }
.graph-viewport:focus-visible { box-shadow: inset 0 0 0 1.5px var(--clay); }

.stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 786px;
  height: 690px;
  transform-origin: 0 0;
  will-change: transform;
}

.edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 2;
}
.edges path {
  fill: none;
  stroke: rgba(0, 0, 0, 0.20);
  stroke-width: 1.35;
  vector-effect: non-scaling-stroke;
}
.edges path.edge--chain {
  stroke: rgba(217, 119, 87, 0.65);
  stroke-width: 1.6;
}
.edges path.edge--day {
  stroke: rgba(0, 0, 0, 0.26);
  stroke-width: 1.4;
}
.edges path.edge--seq {
  stroke: rgba(217, 119, 87, 0.45);
  stroke-width: 1.4;
}
.edges path.edge--active {
  stroke: var(--clay);
  stroke-width: 1.8;
}

.stage-note {
  position: absolute;
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}
.stage-note--one { left: 172px; top: 20px; }
.stage-note--two { left: 172px; top: 112px; }
.stage-note--three { left: 14px; top: 650px; }

/* ---------- nodes ---------- */

.node {
  z-index: 3;
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-10);
  background: var(--surface-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  user-select: none;
  touch-action: none;
  cursor: grab;
  transition: box-shadow 120ms var(--ease), border-color 120ms var(--ease);
  will-change: transform;
}
.node:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.node.is-dragging { cursor: grabbing; box-shadow: var(--shadow-md); z-index: 20; }
.node.is-selected {
  border-color: var(--clay);
  box-shadow: 0 0 0 1.5px var(--clay), 0 0 6px rgba(217, 119, 87, 0.20), var(--shadow-sm);
}

.node--root {
  padding: 12px;
  background: var(--ink);
  color: var(--surface-2);
  border-color: var(--ink);
  cursor: default;
}
.node--root:hover { border-color: var(--ink); box-shadow: var(--shadow-md); }
.root-kicker {
  font: 500 11px/1.2 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--clay);
}
.root-title {
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.root-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: auto;
  font: 400 11px/1.2 var(--mono);
  color: rgba(255, 255, 255, 0.62);
}
.root-meta span + span::before { content: "·"; margin-right: 8px; color: rgba(255, 255, 255, 0.28); }

.node--day {
  padding: 8px 9px;
  border-left: 2px solid rgba(0, 0, 0, 0.15);
}
.day-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font: 500 11px/1.2 var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-title {
  margin-top: 4px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-meta {
  display: flex;
  gap: 6px;
  margin-top: auto;
  font: 400 11px/1.2 var(--sans);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.day-meta span + span::before { content: "·"; margin-right: 6px; color: var(--line-strong); }
.day-add {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  background: var(--surface-2);
  color: var(--clay-deep);
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: opacity 120ms var(--ease), background 120ms var(--ease);
}
.node--day:hover .day-add,
.day-add:focus-visible { opacity: 1; }
.day-add:hover { background: rgba(0, 0, 0, 0.05); }

.node--block {
  padding: 6px 8px;
  border-left: 2px solid rgba(0, 0, 0, 0.16);
}
.block-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font: 500 11px/1.2 var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.block-kind {
  color: var(--clay-deep);
}
.block-title {
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.005em;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.block-foot {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  margin-top: auto;
  font: 400 11px/1.2 var(--sans);
  color: var(--muted);
}
.block-foot span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.block-foot span:last-child { flex: 0 0 auto; }
.block-foot span:last-child { color: var(--ink-soft); }
.node--block.is-selected .block-kind { color: var(--clay-deep); }

.viewport-corner {
  position: absolute;
  z-index: 2;
  right: 14px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font: 400 11px/1.2 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}
.viewport-corner span:first-child {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--line-strong);
}

.graph-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 20px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-1);
  font: 400 11px/1.4 var(--sans);
  color: var(--muted);
}
.graph-status span { display: inline-flex; align-items: center; gap: 6px; }
.graph-status b { font-weight: 500; color: var(--ink-soft); }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.moss { background: var(--moss); }
.text-btn {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
  font: 500 11px/1.2 var(--sans);
  color: var(--clay-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- conversations ---------- */

.conversations {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--surface-1);
}

.conv-head {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}
.conv-head .eyebrow { color: var(--muted); }
.conv-head h2 {
  margin: 2px 0 0;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.readonly-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid rgba(217, 119, 87, 0.35);
  border-radius: var(--radius-8);
  font: 500 11px/1 var(--mono);
  color: var(--clay-deep);
  background: var(--clay-soft);
}

.conv-transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 12px;
  outline: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}
.conv-transcript:focus-visible { box-shadow: inset 0 0 0 1.5px var(--clay); }
.conv-transcript.has-fade {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}
.transcript-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
  font: 400 11px/1.4 var(--sans);
  color: var(--muted);
}
.source-tag {
  align-self: flex-start;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  font: 500 11px/1 var(--mono);
  color: var(--ink-soft);
  background: var(--surface-0);
  white-space: nowrap;
}
.message {
  margin-top: 16px;
}
.message-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font: 500 11px/1.3 var(--mono);
  color: var(--muted);
}
.message--user .message-label span:first-child { color: var(--ink-soft); }
.message--agent .message-label span:first-child { color: var(--clay-deep); }
.message-body {
  margin-top: 6px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.message--user .message-body {
  width: fit-content;
  max-width: 90%;
  margin-left: auto;
  padding: 10px 12px;
  border-radius: var(--radius-12);
  background: #f2f2f0;
  color: var(--ink);
}
.message--agent .message-body { padding: 0 0 0 2px; }
.suggestion {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-10);
}
.suggestion-label {
  display: block;
  font: 500 11px/1.2 var(--mono);
  color: var(--clay-deep);
}
.suggestion strong {
  display: block;
  margin-top: 5px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}
.suggestion span:last-child {
  display: block;
  margin-top: 4px;
  font: 400 11px/1.4 var(--mono);
  color: var(--muted);
}
.readonly-line {
  margin-top: 10px;
  font: 400 11px/1.45 var(--sans);
  color: var(--muted);
}

.usage-card,
.thinking-card {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 20px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
}
.panel-note {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 20px 10px;
  border-top: 1px solid var(--hairline);
  font-size: 11px;
  line-height: 1.45;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
}
.card-head .eyebrow { color: var(--muted); }
.card-tag {
  font: 400 11px/1 var(--mono);
  color: var(--muted);
}
.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 14px;
  margin: 0;
}
.usage-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 8px;
  min-width: 0;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline);
}
.usage-cell--wide { grid-column: 1 / -1; }
.usage-cell:nth-child(4),
.usage-cell:nth-child(5) { border-bottom: 0; }
.usage-cell dt {
  grid-column: 1;
  font: 500 11px/1.3 var(--mono);
  color: var(--muted);
}
.usage-cell dd {
  grid-column: 2;
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.usage-cell > span {
  grid-column: 1 / -1;
  display: block;
  margin-top: 2px;
  font: 400 11px/1.35 var(--mono);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.usage-bar {
  display: block;
  height: 3px;
  margin-top: 5px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.usage-cell > span.usage-bar { margin-top: 5px; white-space: normal; }
.usage-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--clay);
}

.thinking-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 0 6px;
  border: 0;
  background: transparent;
  text-align: left;
}
.thinking-toggle .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--clay);
  animation: status-pulse 1.8s ease-in-out infinite;
}
.thinking-label {
  font: 600 12px/1.3 var(--sans);
  color: var(--ink);
}
.thinking-summary {
  margin-left: auto;
  font: 400 11px/1.3 var(--mono);
  color: var(--muted);
}
.thinking-chevron {
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  transition: transform 200ms var(--ease);
}
.thinking-card.is-open .thinking-chevron { transform: rotate(180deg); }
.thinking-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 200ms var(--ease);
}
.thinking-card.is-open .thinking-body { grid-template-rows: 1fr; }
.thinking-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  list-style: none;
}
.thinking-step {
  display: flex;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--hairline);
}
.thinking-step:last-child { border-bottom: 0; padding-bottom: 1px; }
.thinking-mark {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  font: 500 11px/1 var(--mono);
  color: var(--moss);
}
.thinking-step--active .thinking-mark i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--clay);
  animation: status-pulse 1.8s ease-in-out infinite;
}
.thinking-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 8px;
  min-width: 0;
}
.thinking-copy strong {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-soft);
}
.thinking-meta {
  font: 400 11px/1.3 var(--mono);
  color: var(--muted);
  white-space: nowrap;
}
.thinking-step--active .thinking-meta { color: var(--clay-deep); }
@keyframes status-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.conv-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 8px 20px 10px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-1);
}
.full-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line-strong);
  font: 500 11px/1.5 var(--sans);
  color: var(--clay-deep);
}
.full-link:hover { border-color: var(--clay); }
.conv-run {
  font: 400 11px/1.5 var(--sans);
  color: var(--muted);
}
.conv-run code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
  font-family: var(--mono);
  font-size: 11px;
}

/* ---------- editor ---------- */

.editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(21, 21, 21, 0.36);
}

.editor {
  width: min(580px, 100%);
  max-height: min(92dvh, 760px);
  overflow-y: auto;
  padding: 22px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-16);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
}
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.editor-head h2 {
  margin: 4px 0 0;
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  background: transparent;
  font-size: 12px;
  line-height: 1;
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.05); }

#blockForm { margin-top: 16px; }
.field-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.field-row .field:first-child:nth-last-child(2),
.field-row .field:first-child:nth-last-child(2) ~ .field { grid-column: span 1; }
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 11px;
  min-width: 0;
}
.field--wide { width: 100%; }
.field > span {
  font: 500 11px/1.2 var(--mono);
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
  outline: 0;
}
.field textarea { resize: vertical; min-height: 62px; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--clay); box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.14); }
.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.editor-spacer { flex: 1; }

.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  padding: 9px 14px;
  border-radius: var(--radius-10);
  background: var(--ink);
  color: var(--surface-2);
  font: 500 12px/1.3 var(--sans);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */

@media (max-width: 1439px) {
  :root { --side: 264px; --rail: 360px; }
}

@media (max-width: 1199px) {
  :root { --side: 240px; --rail: 360px; }
  .header-center { display: none; }
  .demo-header { grid-template-columns: 1fr auto; }
  .graph-toolbar { flex-wrap: wrap; }
  .trip-meta { flex: 1 1 100%; max-width: none; }
  .graph-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
}

@media (max-width: 900px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .demo-header { flex: 0 0 56px; padding: 0 14px; gap: 10px; }
  .demo-nav { gap: 12px; font-size: 11px; }
  .demo-nav a:first-child { display: none; }
  .workbench { display: block; width: 100%; overflow-x: clip; }
  .mobile-tabs {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-1);
  }
  .mobile-tab {
    flex: 1 1 0;
    height: 32px;
    border: 0;
    border-radius: var(--radius-8);
    background: transparent;
    font: 500 12px/1 var(--sans);
    color: var(--muted);
  }
  .mobile-tab.is-active { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
  .rail {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface-0);
    overflow: hidden;
  }
  .rail-brand { flex: 0 0 auto; padding: 0; border: 0; }
  .rail-brand-text em { display: none; }
  .rail-trip { flex: 0 1 auto; min-width: 0; padding: 0; }
  .rail-trip .eyebrow,
  .rail-trip-when,
  .rail-trip-where { display: none; }
  .rail-trip h2 {
    margin: 0;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rail-trip-session {
    margin-top: 3px;
    padding-top: 3px;
    border-top: 0;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rail-sessions {
    order: 3;
    flex: 1 0 100%;
    min-width: 0;
    padding: 0;
    border-bottom: 0;
    overflow: hidden;
  }
  .rail-section-head { display: none; }
  .session-list {
    flex-direction: row;
    gap: 6px;
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .session-list::-webkit-scrollbar { display: none; }
  .session-item {
    flex: 0 0 auto;
    min-width: 178px;
    max-width: 230px;
    border-radius: var(--radius-8);
    background: rgba(0, 0, 0, 0.03);
  }
  .session-item.is-active { background: rgba(0, 0, 0, 0.07); }
  .rail-nav, .rail-health, .rail-foot { display: none; }
  .graph-panel {
    height: 70dvh;
    min-height: 480px;
    border-top: 0;
  }
  .conversations {
    display: none;
    height: 70dvh;
    min-height: 480px;
    border-left: 0;
    border-top: 1px solid var(--line);
    overflow-y: auto;
  }
  body.mobile-view-chat .graph-panel { display: none; }
  body.mobile-view-chat .conversations { display: flex; }
  .conv-transcript { flex: 0 0 auto; overflow: visible; max-height: none; }
  .graph-toolbar { padding: 10px 14px; flex-wrap: wrap; align-items: flex-start; }
  .trip-meta { flex: 1 1 100%; max-width: none; }
  .graph-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .graph-hint { display: none; }
  .graph-status { padding: 8px 14px; gap: 12px; flex-wrap: wrap; }
  .stage-note { display: none; }
  .trip-meta h1 { font-size: 16px; }
  .graph-viewport { min-height: 300px; }
}

@media (max-width: 620px) {
  .demo-header { padding: 0 12px; }
  .demo-brand { font-size: 11px; }
  .demo-nav { gap: 10px; }
  .rail { gap: 6px 10px; padding: 8px 10px; }
  .rail-brand-text strong { font-size: 11px; }
  .rail-trip h2 { font-size: 15px; }
  .session-item { flex: 1 1 0; min-width: 0; max-width: none; padding: 6px 7px; }
  .session-num { padding-top: 2px; }
  .session-top, .session-foot { display: none; }
  .session-copy strong { font-size: 11px; line-height: 1.25; }
  .graph-panel, .conversations { height: 72dvh; min-height: 520px; }
  .graph-toolbar { gap: 8px; }
  .trip-meta h1 { font-size: 15px; }
  .trip-sub { font-size: 11px; line-height: 1.4; }
  .graph-actions { gap: 4px; }
  .ghost-btn, .add-btn, .danger-btn { padding: 0 9px; }
  .graph-status { gap: 8px; }
  .graph-status span:nth-child(2) { display: none; }
  .conv-head { padding: 10px 14px; }
  .conv-head h2 { font-size: 13px; }
  .readonly-badge { font-size: 11px; padding: 4px 6px; }
  .conv-transcript { padding: 14px 14px 10px; }
  .usage-card, .thinking-card { padding-left: 14px; padding-right: 14px; }
  .panel-note { padding-left: 14px; padding-right: 14px; }
  .conv-footer { padding: 10px 14px 12px; }
  .editor { padding: 18px; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row .field:first-child:nth-last-child(3),
  .field-row .field:first-child:nth-last-child(3) ~ .field { grid-column: span 1; }
  .field-row .field:first-child:nth-last-child(3) { grid-column: 1 / -1; }
  .editor-actions { flex-wrap: wrap; }
  .editor-spacer { display: none; }
  .danger-btn { margin-right: auto; }
}

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