/* Super Data Model demo: cool registry paper, ink text, one highlighter accent for traversal. */
:root {
  --paper: #eef2f1;
  --surface: #f8faf9;
  --ink: #1b2433;
  --ink-soft: #4a5566;
  --rule: #c9d3d0;
  --rule-soft: #dde4e2;
  --highlight: #e9f26b;
  --highlight-deep: #b9c42a;
  --entity: #1f6f6b;
  --attribute: #6b7a8f;
  --obligation: #2f3e9e;
  --rule-kind: #7b4b8e;
  --event: #a86a12;
  --flow: #946c2e;
  --source: #4f6b2a;
  --neutral: #5c6670;
  --haiku: #5aa9d6;
  --sonnet: #2f3e9e;
  --opus: #4a1f5c;
  --danger: #a33a2b;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.25rem;
  --step-3: 1.75rem;
  --step-4: 2.5rem;
  --radius-s: 4px;
  --radius-m: 10px;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body {
  margin: 0;
  font: 400 var(--step-0)/1.5 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--obligation); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; }
.skip:focus { left: 1rem; z-index: 10; }

/* Masthead */
.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 0;
  border-bottom: 1px solid var(--rule);
}
.brand h1 {
  font: 600 var(--step-4)/1 var(--serif);
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}
.tagline { margin: 0 0 1rem; max-width: 62ch; color: var(--ink-soft); }
.tabs { display: flex; gap: 0.25rem; }
.tabs button {
  border: 1px solid transparent;
  border-bottom: none;
  background: none;
  padding: 0.55rem 1.1rem 0.6rem;
  border-radius: var(--radius-m) var(--radius-m) 0 0;
  cursor: pointer;
  color: var(--ink-soft);
}
.tabs button[aria-selected="true"] {
  background: var(--surface);
  border-color: var(--rule);
  color: var(--ink);
  font-weight: 700;
  margin-bottom: -1px;
}

/* Buttons */
.primary, .quiet, .chip {
  border-radius: var(--radius-s);
  cursor: pointer;
  padding: 0.45rem 0.9rem;
}
.primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); font-weight: 700; }
.primary:disabled { opacity: 0.5; cursor: progress; }
.quiet { background: transparent; border: 1px solid var(--rule); color: var(--ink); }
.quiet:hover { border-color: var(--ink-soft); }

/* Panels */
.panel { background: var(--surface); flex: 1; }
.panel[hidden] { display: none; }

/* Ask layout */
.ask {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 46%);
  min-height: 0;
}
.conversation {
  display: flex;
  flex-direction: column;
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem);
  border-right: 1px solid var(--rule);
  min-height: calc(100vh - 11rem);
}
.thread { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1.5rem; padding-bottom: 1rem; }
.turn-user {
  align-self: flex-end;
  max-width: 70%;
  background: var(--paper);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-m) var(--radius-m) var(--radius-s) var(--radius-m);
  padding: 0.65rem 0.9rem;
}
.turn-agent { max-width: 70ch; }
.answer {
  font: 400 var(--step-1)/1.6 var(--serif);
}
.answer h1, .answer h2, .answer h3 { font: 600 var(--step-2)/1.3 var(--serif); margin: 1.2em 0 0.4em; }
.answer p { margin: 0 0 0.8em; }
.answer ul, .answer ol { padding-left: 1.3em; margin: 0 0 0.8em; }
.answer table { border-collapse: collapse; font: 400 var(--step-0)/1.4 var(--sans); margin: 0.6em 0 1em; width: 100%; }
.answer th, .answer td { border-bottom: 1px solid var(--rule); padding: 0.35rem 0.5rem; text-align: left; vertical-align: top; }
.answer th { font-weight: 700; }
.answer code { font: 400 0.82em/1 var(--mono); background: var(--paper); padding: 0.1em 0.3em; border-radius: 3px; }
.answer pre { background: var(--paper); padding: 0.75rem; border-radius: var(--radius-s); overflow-x: auto; }
.answer pre code { background: none; padding: 0; }
.node-link {
  font: 500 0.82em/1 var(--mono);
  color: var(--obligation);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.node-link:hover { text-decoration-color: currentColor; background: var(--highlight); }
.answer-meta { margin-top: 0.6rem; color: var(--ink-soft); font-size: 0.85rem; }
.answer-error { color: var(--danger); }
.thinking-line { color: var(--ink-soft); font-style: italic; }

.starters { margin: 0 0 1.25rem; }
.starters-intro { margin: 0 0 0.6rem; color: var(--ink-soft); }
.starters ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.5rem; }
.starters button {
  width: 100%;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius-s);
  padding: 0.7rem 0.85rem;
  font: 400 var(--step-0)/1.4 var(--serif);
  cursor: pointer;
}
.starters button:hover { border-color: var(--ink-soft); }

.ask-form { border-top: 1px solid var(--rule); padding-top: 1rem; }
.ask-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 3.2rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  background: #fff;
  font: 400 var(--step-1)/1.5 var(--serif);
}
.ask-controls { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.6rem; flex-wrap: wrap; }
.ask-controls .primary { margin-left: auto; padding-inline: 1.4rem; }
.model-pick { display: flex; align-items: center; gap: 0.45rem; color: var(--ink-soft); }
.model-pick select { border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 0.35rem 0.5rem; background: #fff; }
.ask-status { min-height: 1.4em; margin: 0.4rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }

/* Reasoning column */
.reasoning { padding: 1.25rem clamp(1rem, 2vw, 1.75rem); display: flex; flex-direction: column; min-width: 0; }
.graph-head, .trail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.reasoning h2, .calc-intro h2 { font: 600 var(--step-2)/1.3 var(--serif); margin: 0; }
.graph-actions { display: flex; gap: 0.4rem; }
.graph-actions .quiet { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.graph-caption { margin: 0.35rem 0 0.6rem; color: var(--ink-soft); font-size: 0.875rem; max-width: 64ch; }
.graph {
  height: clamp(300px, 42vh, 520px);
  background:
    radial-gradient(circle at 1px 1px, var(--rule-soft) 1px, transparent 1.5px) 0 0 / 22px 22px,
    #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
}
.graph.small { height: 320px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; padding: 0; margin: 0.6rem 0 1.25rem; font-size: 0.8rem; color: var(--ink-soft); }
.legend li { display: flex; align-items: center; gap: 0.35rem; }
.legend .swatch { width: 0.7rem; height: 0.7rem; border-radius: 2px; display: inline-block; }

.tiers { list-style: none; display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; margin: 0.35rem 0 0.75rem; padding: 0; font-size: 0.8rem; color: var(--ink-soft); }
.tier {
  display: inline-block;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  color: #fff;
  margin-right: 0.25rem;
}
.tier.haiku { background: var(--haiku); color: var(--ink); }
.tier.sonnet { background: var(--sonnet); }
.tier.opus { background: var(--opus); }

.trail { list-style: none; counter-reset: step; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.trail > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0 0.5rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--rule-soft);
}
.trail > li::before {
  content: counter(step);
  font: 600 0.8rem/1.6 var(--sans);
  color: var(--ink-soft);
  text-align: right;
}
.trail > li.sub { margin-left: 1.75rem; }
.trail .step-title { font-weight: 700; }
.trail .step-time { margin-left: 0.5rem; font-size: 0.75rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.trail .step-tool { font: 500 0.8rem/1.4 var(--mono); color: var(--ink-soft); word-break: break-all; }
.trail .step-detail { color: var(--ink-soft); font-size: 0.85rem; grid-column: 2; }
.trail .step-detail.error { color: var(--danger); }
.trail .pending .step-detail::after { content: " working"; animation: pulse 1.2s ease-in-out infinite; }
.trail-empty { color: var(--ink-soft); font-size: 0.875rem; margin: 0; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* Explore */
.explore {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr) minmax(18rem, 30%);
  gap: 0;
}
.explore-search { padding: 1.25rem; border-right: 1px solid var(--rule); min-width: 0; }
.explore-form { display: flex; flex-direction: column; gap: 0.5rem; }
.explore-form input, .explore-form select {
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  padding: 0.55rem 0.7rem;
  background: #fff;
}
.browse { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.9rem 0; }
.browse p { margin: 0; color: var(--ink-soft); width: 100%; }
.browse .quiet { font-size: 0.85rem; padding: 0.3rem 0.6rem; }
.results { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.results li { border-top: 1px solid var(--rule-soft); }
.results button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 0.55rem 0.25rem; cursor: pointer; }
.results button:hover, .results button[aria-current="true"] { background: var(--paper); }
.results .r-label { font-weight: 700; display: block; }
.results .r-meta { font: 400 0.75rem/1.3 var(--mono); color: var(--ink-soft); display: block; word-break: break-all; }
.results .r-snippet { font-size: 0.85rem; color: var(--ink-soft); display: block; }
.results .group { padding: 0.8rem 0.25rem 0.3rem; font-weight: 700; color: var(--ink-soft); border-top: none; }

.detail { padding: 1.5rem clamp(1rem, 2.5vw, 2rem); min-width: 0; max-height: calc(100vh - 9rem); overflow-y: auto; }
.detail h2 { font: 600 var(--step-3)/1.15 var(--serif); margin: 0 0 0.25rem; overflow-wrap: anywhere; }
.detail .kind-line { color: var(--ink-soft); margin: 0 0 1rem; }
.detail .kind-badge { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 2px; margin-right: 0.35rem; }
.detail .lede { font: 400 var(--step-1)/1.6 var(--serif); max-width: 68ch; }
.detail dl { display: grid; grid-template-columns: minmax(9rem, 13rem) minmax(0, 1fr); gap: 0.45rem 1rem; margin: 1rem 0; }
.detail dt { color: var(--ink-soft); }
.detail dd { margin: 0; overflow-wrap: anywhere; }
.detail h3 { font: 600 var(--step-1)/1.3 var(--sans); margin: 1.4rem 0 0.4rem; }
.detail ul.links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; }
.detail table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
.detail th, .detail td { text-align: left; border-bottom: 1px solid var(--rule-soft); padding: 0.3rem 0.4rem; vertical-align: top; }
.detail pre { background: var(--paper); padding: 0.75rem; border-radius: var(--radius-s); white-space: pre-wrap; font: 400 0.8rem/1.45 var(--mono); max-height: 22rem; overflow: auto; }
.detail .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }
.detail-empty { color: var(--ink-soft); }
.explore-graph-wrap { padding: 1.25rem; border-left: 1px solid var(--rule); }

/* Calculate */
.calculate { padding: 1.5rem clamp(1rem, 3vw, 2.5rem); }
.calc-intro p { max-width: 70ch; color: var(--ink-soft); margin: 0.4rem 0 1.25rem; }
.calc-forms { display: grid; grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); gap: 1.25rem; align-items: start; }
.calc {
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  background: #fff;
  padding: 1rem 1.1rem 1.1rem;
}
.calc h3 { font: 600 var(--step-2)/1.25 var(--serif); margin: 0 0 0.25rem; }
.calc .calc-what { color: var(--ink-soft); margin: 0 0 0.8rem; font-size: 0.9rem; }
.calc label { display: block; margin: 0.5rem 0 0.2rem; font-weight: 700; font-size: 0.875rem; }
.calc .hint { font-weight: 400; color: var(--ink-soft); }
.calc input[type="text"], .calc input[type="number"], .calc input[type="date"] {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  padding: 0.45rem 0.6rem;
}
.calc .check { display: flex; align-items: center; gap: 0.45rem; font-weight: 400; }
.calc .calc-buttons { display: flex; gap: 0.5rem; margin-top: 0.9rem; flex-wrap: wrap; }
.calc-result { margin-top: 1rem; border-top: 1px solid var(--rule-soft); padding-top: 0.8rem; }
.calc-result .figure { font: 600 var(--step-3)/1.15 var(--serif); }
.calc-result .refused { color: var(--danger); font-weight: 700; }
.calc-result ol { padding-left: 1.2em; margin: 0.5rem 0; font-size: 0.875rem; }
.calc-result .src { font-size: 0.8rem; color: var(--ink-soft); }

/* Footer */
.colophon { border-top: 1px solid var(--rule); padding: 0.75rem clamp(1rem, 3vw, 2.5rem); color: var(--ink-soft); font-size: 0.8rem; }
.colophon p { margin: 0; max-width: 100ch; }

/* Small screens */
@media (max-width: 960px) {
  .masthead { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .ask, .explore { grid-template-columns: minmax(0, 1fr); }
  .conversation { border-right: none; min-height: auto; }
  .reasoning { border-top: 1px solid var(--rule); }
  .explore-search, .explore-graph-wrap { border: none; }
  .turn-user { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) {
  .trail .pending .step-detail::after { animation: none; }
}
