:root {
  --ground: #eef1ef;
  --ink: #16262b;
  --muted: #566a70;
  --line: #d2dbd9;
  --card: #fbfcfb;
  --panel: #f7f9f8;
  --accent: #0f6b6f;
  --accent-ink: #ffffff;
  --before: #b3c0c3;
  --match: #b8741a;
  --focus: #0f6b6f;
  --display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #101a1d;
    --ink: #e6eeec;
    --muted: #9db0b3;
    --line: #29393d;
    --card: #162327;
    --panel: #131e21;
    --accent: #4fb3b8;
    --accent-ink: #08191b;
    --before: #4a5b60;
    --match: #e0a24a;
    --focus: #4fb3b8;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--ink); color: var(--ground); padding: 8px 12px; border-radius: 4px; z-index: 10; }
.skip:focus { top: 8px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 400px; min-height: 100%; }

/* ---- Stage ---- */
.stage-wrap { padding: 28px clamp(20px, 4vw, 56px) 64px; min-width: 0; }
.masthead { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; justify-content: space-between; }
.who { margin: 0; font: 400 clamp(34px, 5vw, 52px)/1.05 var(--display); letter-spacing: -0.01em; }
.role { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: 4px; color: var(--muted); font-weight: 500; font-size: 14px; }
.tabs button:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.tabs button[aria-current="page"] { color: var(--accent-ink); background: var(--accent); }

/* Roster strip: duty periods on a timeline, a quiet nod to the work itself */
.strip {
  height: 10px; margin: 18px 0 28px; border-radius: 2px;
  background:
    linear-gradient(90deg,
      var(--accent) 0 9%, transparent 9% 11%,
      var(--accent) 11% 17%, transparent 17% 21%,
      var(--before) 21% 38%, transparent 38% 40%,
      var(--accent) 40% 49%, transparent 49% 53%,
      var(--accent) 53% 58%, transparent 58% 60%,
      var(--before) 60% 71%, transparent 71% 75%,
      var(--accent) 75% 90%, transparent 90% 92%,
      var(--before) 92% 100%);
  opacity: 0.85;
}

.stage { outline: none; max-width: 860px; }
.stage h2 { margin: 0 0 6px; font: 400 clamp(26px, 3.4vw, 34px)/1.15 var(--display); }
.stage .lede { margin: 0 0 24px; color: var(--muted); max-width: 62ch; }
.stage p { max-width: 68ch; }
.notice { margin: 0 0 20px; padding: 10px 14px; border-left: 3px solid var(--match); background: color-mix(in srgb, var(--match) 9%, transparent); border-radius: 0 4px 4px 0; font-size: 15px; }

/* Overview */
.summary { font-size: 18px; line-height: 1.55; max-width: 60ch; margin: 0 0 28px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; margin: 0 0 32px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fact { padding: 16px 16px 16px 0; margin-right: 16px; }
.fact dt { font: 400 26px/1.15 var(--display); }
.fact dd { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.try h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.try-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* Cards */
.cards { display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 20px 22px; }
.card.matched { border-left: 4px solid var(--match); }
.card h3 { margin: 0 0 4px; font: 400 24px/1.2 var(--display); }
.card .where { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.card .headline { margin: 0 0 12px; font-weight: 500; }
.metrics { margin: 0 0 12px; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 8px; }
.metrics li { font-size: 13px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--panel); }
.card .short { margin: 0 0 14px; color: var(--ink); }

.compare { margin: 4px 0 16px; max-width: 460px; }
.compare .ctitle { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.bar { height: 14px; background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: 2px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 2px; transform-origin: left; }
.bar .b { background: var(--before); }
.bar .a { background: var(--accent); }
.bar-row .v { min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: no-preference) {
  .bar > span { animation: grow 600ms cubic-bezier(.2,.7,.2,1) both; }
  .bar .a { animation-delay: 150ms; }
  @keyframes grow { from { transform: scaleX(0); } }
}

.more { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.full { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.full h4 { margin: 14px 0 2px; font-size: 14px; font-weight: 600; }
.full h4:first-child { margin-top: 0; }
.full p { margin: 0; }
.full .scope { margin-top: 14px; padding: 10px 12px; background: var(--panel); border-radius: 4px; font-size: 14px; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.links a, .linkrow a { color: var(--accent); font-weight: 500; text-underline-offset: 3px; }

/* Filters */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Timeline */
.tl { list-style: none; margin: 0; padding: 0 0 0 20px; border-left: 2px solid var(--line); }
.tl li { position: relative; padding: 0 0 26px 14px; }
.tl li::before { content: ""; position: absolute; left: -27px; top: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--ground); }
.tl h3 { margin: 0; font: 400 22px/1.2 var(--display); }
.tl .when { color: var(--muted); font-size: 14px; margin: 2px 0 6px; }

.linkrow { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

/* ---- Chat ---- */
.chat { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); }
.chat-head { padding: 22px 22px 12px; }
.chat-head h2 { margin: 0; font: 400 24px/1.2 var(--display); }
.chat-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.log { flex: 1; overflow-y: auto; padding: 8px 22px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 6px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--line); }
.msg.pending { color: var(--muted); font-style: italic; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 22px 0; }
.sug { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; text-align: left; }
.sug:hover { border-color: var(--accent); }
.composer { display: flex; gap: 8px; padding: 14px 22px 8px; }
.composer input { flex: 1; min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.composer button { padding: 0 18px; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.composer button:disabled { opacity: 0.55; cursor: progress; }
.mode-note, .privacy { margin: 0; padding: 0 22px 14px; font-size: 12.5px; color: var(--muted); }
.privacy { padding-bottom: 6px; }

/* ---- Small screens: stage first, chat below ---- */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .chat { position: static; height: auto; min-height: 520px; border-left: 0; border-top: 1px solid var(--line); }
  .log { min-height: 200px; max-height: 50vh; }
  .stage-wrap { padding-bottom: 32px; }
}
