/* One reading column, visual first: a sticky bar (brand, sessions), then turns: the question, the agent's progress
   folding into a summary, and the answer: a lead paragraph, then its text with charts and cards in the flow.
   Entity links and chart segments open a
   popover (a bottom sheet on phones). Lime is the brand; violet marks AI-generated content. Ratings and defect
   conditions share one scale (--lv1 best .. --lv6 worst): teal for good, warm neutral for fair, orange to red for
   bad; N/A (a gap) hatched orange, N/R (not required) hatched blue; chips and stripes use the same hues. */
:root {
  color-scheme: light;
  --bg: #f3f6ee;
  --surface: #ffffff;
  --sunk: #eaefe2;
  --line: #dbe2d1;
  --line-strong: #c3ccb6;
  --ink: #152011;
  --ink-2: #3c4836;
  --muted: #687463;
  --lime: #a3e635;
  --lime-hover: #b6ef55;
  --lime-wash: #ebf7d4;
  --lime-ink: #3a6a06;
  --on-lime: #142105;
  --ai: #5a4bc7;
  --ai-wash: #f1effc;
  --ai-line: #dcd7f5;
  --crit: #b8321c;  --crit-wash: #fbe6e1;
  --bad: #b65a0c;   --bad-wash: #fcecd9;
  --warn: #6f6440;  --warn-wash: #efeadb;
  --ok: #13636a;    --ok-wash: #dcefee;
  --calm: #4c5a48;  --calm-wash: #e9eee4;
  --lv1: #16696f; --lv2: #3d9a9c; --lv3: #7cc0c0; --lv4: #d6cfb8; --lv5: #e07b2e; --lv6: #c23a22;
  --on-lv1: #ffffff; --on-lv2: #ffffff; --on-lv3: #0c2a2a; --on-lv4: #2b2617; --on-lv5: #1d0f03; --on-lv6: #ffffff;
  --lv-na: #fbe5d3; --lv-na-line: #e39457; --on-lv-na: #8c3f0b;
  --lv-nr: #e5ebf7; --lv-nr-line: #8ea6d6; --on-lv-nr: #2f4677;
  --scrim: rgb(14 20 10 / 0.42);
  --shadow: 0 22px 48px -14px rgb(21 32 17 / 0.30), 0 2px 6px rgb(21 32 17 / 0.08);

  --font-display: "Familjen Grotesk", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-body: "Instrument Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --col: 48rem;
  --radius: 14px;
  --rail-w: 18.5rem;
}
:root[data-theme="dark"] {
  --bg: #0d120b; --surface: #151c12; --sunk: #1b2417; --line: #273222; --line-strong: #36442f;
  --ink: #e5eddc; --ink-2: #c3cdb8; --muted: #8e9a85;
  --lime: #b2ee4a; --lime-hover: #c4f46c; --lime-wash: #1f2e13; --lime-ink: #b8f05a; --on-lime: #142105;
  --ai: #aea2ff; --ai-wash: #1d1a33; --ai-line: #322c57;
  --crit: #ff8b74; --crit-wash: #3a1810; --bad: #ffa45a; --bad-wash: #36220e; --warn: #d6c99a;
  --warn-wash: #2c2a1e; --ok: #7fd8d2; --ok-wash: #12302f; --calm: #a3ad99; --calm-wash: #222a1d;
  --lv1: #86d6d2; --lv2: #3aa3a5; --lv3: #1f6f74; --lv4: #57523f; --lv5: #d77a35; --lv6: #ff6b55;
  --on-lv1: #0b1f1e; --on-lv2: #061514; --on-lv3: #e6f4f3; --on-lv4: #f0ead6; --on-lv5: #1d0f03; --on-lv6: #2a0700;
  --lv-na: #36220f; --lv-na-line: #97562b; --on-lv-na: #ffc395;
  --lv-nr: #1a2134; --lv-nr-line: #41598a; --on-lv-nr: #b8c9ef;
  --scrim: rgb(0 0 0 / 0.55);
  --shadow: 0 24px 56px -12px rgb(0 0 0 / 0.65), 0 2px 8px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10;
  background: var(--bg);
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lime-ink); outline-offset: 2px; border-radius: 6px; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ── bar ─────────────────────────────────────────────────────────────── */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar-in {
  max-width: 72rem; margin: 0 auto; min-height: 54px;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 10px;
}
.bar .controls { margin-inline-start: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--lime); color: var(--on-lime);
  font: 600 12px/1 var(--font-mono); letter-spacing: 0.02em;
}
.brand-name { font: 600 17px/1 var(--font-display); letter-spacing: -0.01em; }
.icon-btn {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px; background: none; color: var(--ink-2);
}
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── history rail: docked on wide screens, a drawer below 1240px ─────── */
.rail {
  position: fixed; z-index: 45; top: 0; bottom: 0; left: 0; width: var(--rail-w);
  overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 14px;
  background: color-mix(in srgb, var(--sunk) 55%, var(--bg)); border-right: 1px solid var(--line);
  padding: max(14px, env(safe-area-inset-top, 0px)) 14px max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.rail-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.rail-actions .btn { width: 100%; justify-content: center; }
.rail-foot { margin: auto 0 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rail-scrim { position: fixed; inset: 0; z-index: 44; background: var(--scrim); }
.search {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: none;
  padding: 0 12px; height: 40px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
}
.search:focus-within { border-color: var(--lime-ink); }
.search-ico { display: grid; color: var(--muted); }
.search-ico svg { width: 16px; height: 16px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font: inherit; font-size: 14px; }
.search input::placeholder { color: var(--muted); }
.sessions { display: grid; gap: 2px; align-content: start; }
.tab {
  display: grid; gap: 3px; text-align: start; cursor: pointer; width: 100%;
  padding: 9px 10px; border: 1px solid transparent; border-radius: 10px; background: none;
}
.tab:hover { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.tab[aria-current="true"] { background: var(--surface); border-color: var(--line); }
.tab-title { font-weight: 600; font-size: 13.5px; line-height: 1.3; overflow-wrap: anywhere; }
.tab-meta { font: 400 11.5px/1.3 var(--font-mono); color: var(--muted); }
.tab[aria-current="true"] .tab-title { box-shadow: inset 0 -2px 0 var(--lime); justify-self: start; }
.outline, .hits {
  list-style: none; margin: 2px 0 8px 14px; padding: 0 0 0 12px; display: grid; gap: 1px;
  border-left: 1px solid var(--line-strong);
}
.ol-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1px 8px; align-items: baseline; width: 100%;
  text-align: start; cursor: pointer; border: 0; background: none; padding: 7px 8px; border-radius: 8px; color: var(--ink-2);
}
.ol-item:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); color: var(--ink); }
.ol-item[aria-current="true"] { background: var(--lime-wash); color: var(--ink); }
.ol-q { font: 500 11.5px/1.4 var(--font-mono); color: var(--muted); }
.ol-item[aria-current="true"] .ol-q { color: var(--lime-ink); }
.ol-text { font-size: 13px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ol-proj { grid-column: 2; justify-self: start; font: 500 11px/1.4 var(--font-mono); color: var(--muted); }
@media (min-width: 1240px) {
  body:not(.signed-out) { padding-left: var(--rail-w); }
  .rail-open, .rail-close, .bar-brand, .rail-scrim { display: none !important; }
  body:not(.signed-out) .composer { left: var(--rail-w); }
  [data-mode="live"] .bar { display: none; }
}
@media (max-width: 1239px) {
  .rail {
    width: min(20rem, 86vw); box-shadow: var(--shadow); visibility: hidden;
    transform: translateX(-102%); transition: transform 220ms ease, visibility 0s linear 220ms;
  }
  .rail.is-open { transform: none; visibility: visible; transition: transform 220ms ease; }
}
.controls { display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 600; font-size: 13.5px; line-height: 1; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn-primary { background: var(--lime); border-color: var(--lime); color: var(--on-lime); }
.btn-primary:hover { background: var(--lime-hover); border-color: var(--lime-hover); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-quiet { background: none; border-color: transparent; color: var(--lime-ink); padding-inline: 10px; }
.btn-quiet:hover { background: var(--lime-wash); border-color: transparent; }
.btn svg { width: 14px; height: 14px; }
@media (max-width: 720px) { .bar .brand-name { font-size: 16px; } }

/* ── thread ──────────────────────────────────────────────────────────── */
.thread {
  max-width: calc(var(--col) + 32px); margin: 0 auto;
  padding-block: 28px 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 40px;
}
.session-date { font: 400 12px/1 var(--font-mono); color: var(--muted); text-align: center; letter-spacing: 0.04em; }
.turn { display: grid; gap: 14px; min-width: 0; }
.ask {
  justify-self: end; max-width: min(34rem, 88%);
  background: var(--lime-wash); color: var(--ink);
  border-radius: 18px 18px 4px 18px; padding: 10px 16px;
  font-size: 15px; line-height: 1.5;
}
.ask p { margin: 0; white-space: pre-wrap; }

/* progress */
.work { display: grid; gap: 6px; min-width: 0; }
.work-head {
  justify-self: start; display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 0; padding: 4px 6px 4px 2px; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; color: var(--muted);
}
.work-head:hover { color: var(--ink); }
.work-head .chev { width: 14px; height: 14px; transition: transform 160ms ease; }
.work-head[aria-expanded="true"] .chev { transform: rotate(90deg); }
.work.is-live .work-head { cursor: default; color: var(--ink); font-weight: 500; }
.work.is-live .work-head .chev { display: none; }
.work.no-steps .work-head { cursor: default; }
.work.no-steps .work-head .chev { display: none; }
.work-label strong { font-weight: 600; color: var(--ink-2); }
.pulse { width: 16px; height: 16px; display: grid; place-items: center; }
.pulse::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--lime); border-right-color: transparent;
  animation: spin 800ms linear infinite;
}
.work:not(.is-live) .pulse::before {
  animation: none; border: 0; width: 8px; height: 8px; background: var(--lime);
}
.steps { list-style: none; margin: 0; padding: 0 0 0 7px; display: grid; }
.step {
  position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 3px 0; font-size: 13.5px; line-height: 1.45; color: var(--muted);
}
.step::before {
  content: ""; position: absolute; left: 7px; top: -3px; bottom: -3px; width: 1px; background: var(--line);
}
.step:first-child::before { top: 12px; }
.step:last-child::before { bottom: calc(100% - 12px); }
.step:only-child::before { display: none; }
.dot {
  position: relative; z-index: 1; margin-top: 3px; width: 15px; height: 15px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg);
}
.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.step[data-state="running"] { color: var(--ink); }
.step[data-state="running"] .dot::before {
  width: 11px; height: 11px; background: none; border: 2px solid var(--lime); border-right-color: transparent;
  animation: spin 800ms linear infinite;
}
.step[data-state="done"] .dot::before { background: var(--lime); }
.step[data-state="error"] { color: var(--bad); }
.step[data-state="error"] .dot::before { background: var(--bad); border-radius: 2px; transform: rotate(45deg); }
.step-text { min-width: 0; overflow-wrap: anywhere; }
.step-time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.step.is-new { animation: rise 220ms ease-out; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0.2; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* answer */
.answer { min-width: 0; display: grid; gap: 0; }
.answer > .card { margin-block: 6px 18px; }
.caret {
  display: inline-block; width: 8px; height: 1.05em; margin-left: 2px; vertical-align: -0.15em;
  background: var(--lime); border-radius: 2px; animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }
.stopped { font-size: 13.5px; color: var(--bad); }

.prose { min-width: 0; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 0.85em; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-display); letter-spacing: -0.01em; line-height: 1.25; text-wrap: balance;
  margin: 1.3em 0 0.5em;
}
.prose h1 { font-size: 22px; } .prose h2 { font-size: 20px; } .prose h3 { font-size: 18px; } .prose h4 { font-size: 16px; }
.prose ul, .prose ol { margin: 0 0 0.9em; padding-inline-start: 1.35em; }
.prose li { margin: 0.25em 0; }
.prose li::marker { color: var(--muted); }
.prose ul ul, .prose ol ul { margin: 0.25em 0 0.25em; }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 1.4em 0; }
.prose strong { font-weight: 600; }
.prose code {
  font: 0.86em/1 var(--font-mono); background: var(--sunk); padding: 0.18em 0.38em; border-radius: 5px;
}
.prose blockquote { margin: 0 0 0.9em; padding-inline-start: 12px; border-inline-start: 2px solid var(--line-strong); color: var(--ink-2); }
.prose a { color: var(--lime-ink); text-underline-offset: 3px; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.prose table { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.prose th, .prose td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.prose th { font-weight: 600; background: var(--sunk); white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }

/* entity links */
.ref {
  display: inline; cursor: pointer; border: 0; margin: 0; font: inherit; line-height: inherit;
  padding: 0.05em 0.32em 0.08em; border-radius: 6px;
  background: var(--lime-wash); color: var(--lime-ink);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--lime-ink) 35%, transparent);
  text-underline-offset: 3px;
}
.ref:hover { text-decoration-color: currentColor; }
.ref svg { display: inline-block; width: 0.85em; height: 0.85em; margin-inline-end: 0.28em; vertical-align: -0.08em; }
.ref[aria-expanded="true"] { background: var(--lime); color: var(--on-lime); }

/* ── cards ───────────────────────────────────────────────────────────── */
.card {
  container-type: inline-size;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  min-width: 0; overflow: hidden;
}
.card-in { display: grid; gap: 12px; padding: 14px 16px 16px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.kind {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 11px/1 var(--font-mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted);
}
.kind svg { width: 13px; height: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap;
  padding: 4px 9px; border-radius: 999px; font-size: 12px; line-height: 1.2; font-weight: 600;
  background: var(--tone-wash, var(--calm-wash)); color: var(--tone, var(--calm));
}
.chip-label { font-weight: 400; opacity: 0.8; }
.tone-crit { --tone: var(--crit); --tone-wash: var(--crit-wash); }
.tone-bad  { --tone: var(--bad);  --tone-wash: var(--bad-wash); }
.tone-warn { --tone: var(--warn); --tone-wash: var(--warn-wash); }
.tone-ok   { --tone: var(--ok);   --tone-wash: var(--ok-wash); }
.tone-calm { --tone: var(--calm); --tone-wash: var(--calm-wash); }
.tone-na   { --tone: var(--on-lv-na); --tone-wash: var(--lv-na); }
.tone-nr   { --tone: var(--on-lv-nr); --tone-wash: var(--lv-nr); }
.tone-ai   { --tone: var(--ai);   --tone-wash: var(--surface); }
.card-title {
  margin: 0; font: 600 17px/1.35 var(--font-display); letter-spacing: -0.005em; text-wrap: balance;
  overflow-wrap: anywhere;
}
.card-dek { margin: -6px 0 0; color: var(--ink-2); font-size: 14px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.crumbs span + span::before { content: "›"; margin-inline-end: 6px; color: var(--line-strong); }
.note-quote {
  margin: 0; padding: 10px 12px; background: var(--sunk); border-radius: 10px;
  font-size: 14.5px; line-height: 1.55; white-space: pre-wrap;
}
.note-quote-label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; white-space: normal; }
.req { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.req b { font-weight: 600; color: var(--muted); font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; margin-inline-end: 6px; }
.fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 14px; }
.fields dt { color: var(--muted); font-size: 12.5px; padding-top: 1px; }
.fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@container (max-width: 380px) {
  .fields { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .fields dd + dt { margin-top: 6px; }
}

/* photos: one swipeable strip everywhere; a single photo fills the width, a hero strip runs edge to edge */
.strip { position: relative; display: grid; gap: 8px; min-width: 0; }
.strip-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: min(15rem, 70%); gap: 8px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none;
  margin-inline: -16px; padding-inline: 16px; scroll-padding-inline: 16px;
}
.strip-track::-webkit-scrollbar { display: none; }
.strip[data-n="1"] .strip-track { grid-auto-columns: 100%; margin-inline: 0; padding-inline: 0; }
.shot { margin: 0; display: grid; gap: 6px; align-content: start; min-width: 0; scroll-snap-align: start; }
.photo {
  position: relative; display: block; padding: 0; border: 0; cursor: zoom-in; background: var(--sunk); border-radius: 10px;
  overflow: hidden; aspect-ratio: 4 / 3; width: 100%; max-width: 100%;
}
.strip[data-n="1"] .photo { aspect-ratio: 16 / 10; }
.photo img { width: 100%; height: 100%; object-fit: cover; transition: transform 300ms ease; }
.photo:hover img { transform: scale(1.03); }
.shot figcaption { display: grid; gap: 3px; font-size: 12.5px; line-height: 1.35; color: var(--ink-2); overflow-wrap: anywhere; }
.shot figcaption .ref { justify-self: start; }
.shot-kicker {
  font: 500 10.5px/1.2 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--tone, var(--muted));
}
.shot-count {
  position: absolute; right: 10px; bottom: 10px; padding: 5px 8px; border-radius: 999px;
  background: rgb(10 14 8 / 0.62); color: #f3f7ee; font: 500 11px/1 var(--font-mono);
}
.strip--hero .strip-track { grid-auto-columns: 100%; gap: 2px; margin-inline: 0; padding-inline: 0; scroll-padding-inline: 0; }
.strip--hero .photo, .strip--hero[data-n="1"] .photo { border-radius: 0; aspect-ratio: 16 / 11; }
.strip-nav {
  display: none; position: absolute; top: 34%; z-index: 1; width: 36px; height: 36px; place-items: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.strip-nav svg { width: 16px; height: 16px; }
.strip-prev { left: 6px; }
.strip-next { right: 6px; }
.strip--hero .strip-nav { top: calc(50% - 18px); }
@media (hover: hover) { .strip:hover .strip-nav { display: grid; } }
.media-other audio, .media-other video { width: 100%; }

/* asset with one photo: photo beside the text when the card is wide */
@container (min-width: 560px) {
  .card--split .card-in { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; column-gap: 18px; }
  .card--split .card-in > .photos { grid-column: 1; grid-row: 1 / span 20; }
  .card--split .card-in > .photos .photo { aspect-ratio: 4 / 5; }
  .card--split .card-in > :not(.photos) { grid-column: 2; }
}

/* AI analysis fold */
.ai { border: 1px solid var(--ai-line); background: var(--ai-wash); border-radius: 10px; min-width: 0; }
.ai summary {
  list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  padding: 8px 12px; color: var(--ai); font-weight: 600; font-size: 13.5px;
}
.ai summary::-webkit-details-marker { display: none; }
.ai summary .spark { width: 14px; height: 14px; }
.ai summary .chev { flex: none; width: 14px; height: 14px; margin-inline-start: auto; transition: transform 160ms ease; }
.ai[open] summary .chev { transform: rotate(90deg); }
.ai-meta { font-weight: 500; color: var(--ink-2); font-size: 12.5px; }
.ai-meta .chip { vertical-align: 1px; }
.ai-body { padding: 0 12px 12px; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.ai-body .prose h1, .ai-body .prose h2, .ai-body .prose h3, .ai-body .prose h4 { font-size: 14px; margin: 1em 0 0.3em; }
.ai-score { font: 500 12px/1 var(--font-mono); color: var(--ai); }

/* table card */
.card--table .card-in { padding-bottom: 6px; }
.card--table .table-wrap { margin: 0 -16px; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.data { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.data th {
  text-align: start; font: 500 11px/1.2 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 9px 10px; white-space: nowrap; border-bottom: 1px solid var(--line);
}
.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data th:first-child, .data td:first-child { padding-inline-start: 16px; }
.data th:last-child, .data td:last-child { padding-inline-end: 16px; }
.data tr:last-child td { border-bottom: 0; }
.data td.num { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.data td.wide { min-width: 12rem; }
.data tr.row-link { cursor: pointer; }
.data tr.row-link:hover td { background: var(--sunk); }
.data tr.row-link:focus-visible { outline: 2px solid var(--lime-ink); outline-offset: -2px; }
.data .go { width: 14px; height: 14px; color: var(--muted); }

/* note card */
.card--note { border-color: color-mix(in srgb, var(--lime) 55%, var(--line)); }
.card--note .kind { color: var(--lime-ink); }

/* ── popover / sheet ─────────────────────────────────────────────────── */
.pop {
  position: absolute; z-index: 40; width: min(27.5rem, calc(100vw - 32px));
  max-height: min(70vh, 36rem); overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow);
  animation: pop-in 140ms ease-out;
}
.pop .card { border: 0; border-radius: 0; background: none; }
.pop-bar {
  position: sticky; top: 0; z-index: 2; display: flex; gap: 8px; padding: 8px 8px 0; margin-bottom: -42px;
  pointer-events: none;
}
.pop-btn {
  pointer-events: auto; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted);
}
.pop-btn:hover { color: var(--ink); }
.pop-btn svg { width: 15px; height: 15px; }
.pop-close { margin-inline-start: auto; }
.pop .card-head { padding-inline-end: 40px; }
.pop-bar:has(.pop-back) + .card:not(.card--defect) .card-head { padding-inline-start: 40px; }
.pop.is-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto !important; width: auto; max-height: 84vh;
  border-radius: 18px 18px 0 0; border-bottom: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
  animation: sheet-in 200ms ease-out;
}
.pop.is-sheet::before {
  content: ""; display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--line-strong);
  margin: 8px auto 0;
}
.scrim { position: fixed; inset: 0; z-index: 35; background: var(--scrim); }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0.4; } }

/* ── lightbox ────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgb(8 10 6 / 0.93);
  display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
           max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lightbox-cap { color: #e7eedf; font-size: 13.5px; text-align: center; max-width: 46rem; padding-top: 10px; }
.lightbox-cap span { color: #9aa690; font-family: var(--font-mono); font-size: 12px; margin-inline-start: 8px; }
.lb-btn {
  position: absolute; width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer;
  border-radius: 50%; border: 1px solid rgb(255 255 255 / 0.18); background: rgb(255 255 255 / 0.08); color: #f1f6ea;
}
.lb-btn:hover { background: rgb(255 255 255 / 0.16); }
.lb-btn svg { width: 18px; height: 18px; }
.lb-close { top: max(14px, env(safe-area-inset-top, 0px)); right: max(14px, env(safe-area-inset-right, 0px)); }
.lb-prev { left: max(14px, env(safe-area-inset-left, 0px)); top: 50%; translate: 0 -50%; }
.lb-next { right: max(14px, env(safe-area-inset-right, 0px)); top: 50%; translate: 0 -50%; }

.foot {
  max-width: calc(var(--col) + 32px); margin: 0 auto;
  padding-block: 8px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  font-size: 12.5px; color: var(--muted); text-align: center;
}

/* ── live: composer, empty state, sign-in ────────────────────────────── */
[data-mode="live"] .thread { padding-bottom: 150px; }
.who { align-self: center; font-size: 13px; color: var(--muted); }
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: linear-gradient(to top, var(--bg) 72%, transparent);
  padding: 22px max(16px, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px))
           max(16px, env(safe-area-inset-left, 0px));
}
.composer-in { max-width: var(--col); margin: 0 auto; display: grid; gap: 8px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 22px;
  padding: 6px 6px 6px 16px; box-shadow: 0 10px 28px -14px rgb(21 32 17 / 0.35);
}
.composer-box:focus-within { border-color: var(--lime-ink); }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: none; color: var(--ink);
  font: inherit; line-height: 1.5; padding: 7px 0; max-height: 200px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:disabled { cursor: not-allowed; }
.composer .btn { padding: 10px 16px; }
.notice { margin: 0; padding: 8px 12px; border-radius: 10px; font-size: 13px; background: var(--bad-wash); color: var(--bad); }
.notice.is-info { background: var(--sunk); color: var(--ink-2); }
.meter { margin: -2px 0 0; font-size: 12px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.meter, .work-meta, .step-time { word-spacing: 0.18em; }
.meter.is-out { color: var(--bad); }
.empty { display: grid; justify-items: center; gap: 10px; padding-top: 12vh; text-align: center; }
.empty h1 { margin: 0; font: 600 26px/1.2 var(--font-display); letter-spacing: -0.01em; text-wrap: balance; }
.empty p { margin: 0; color: var(--muted); }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.suggestion {
  cursor: pointer; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 13.5px; text-align: start;
}
.suggestion:hover { border-color: var(--ink-2); }
.ai-note { width: 100%; margin-top: 36px; text-align: center; }
.ai-note h2 { margin: 0 0 2px; font: 500 11px/1.4 var(--font-mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.ai-note p { font-size: 12.5px; }
.ai-note ul {
  list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(min(12.5rem, 100%), 1fr));
}
.ai-project {
  cursor: pointer; display: grid; gap: 2px; align-content: start; width: 100%; height: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: start; color: inherit;
}
.ai-project:hover { border-color: var(--ink-2); }
.ai-code { font: 500 13px/1.4 var(--font-mono); color: var(--ink); }
.ai-meta { font-size: 12.5px; color: var(--muted); }
.signed-out .bar, .signed-out .thread, .signed-out .composer, .signed-out .rail { display: none; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form {
  width: min(22rem, 100%); display: grid; gap: 14px; padding: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.login h1 { margin: 6px 0 0; font: 600 22px/1.2 var(--font-display); }
.login label { display: grid; gap: 5px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.login input {
  font: inherit; color: var(--ink); background: var(--bg);
  padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
}
.login input:focus { outline: 2px solid var(--lime-ink); outline-offset: 1px; }
.login .btn { justify-content: center; padding: 11px; }
.login-error { margin: 0; font-size: 13px; color: var(--bad); }

/* ── answer: lead and follow-ups ─── */
.prose.lead > p:first-child { font-size: 16.5px; line-height: 1.55; color: var(--ink); }


/* ── defect list: photo rows ─────────────────────────────────────────── */
.dlist { list-style: none; margin: 0 -16px -16px; padding: 0; display: grid; border-top: 1px solid var(--line); }
.dlist li { border-bottom: 1px solid var(--line); min-width: 0; }
.dlist li:last-child { border-bottom: 0; }
@container (min-width: 640px) {
  .dlist { grid-template-columns: 1fr 1fr; }
  .dlist li:nth-child(odd) { border-inline-end: 1px solid var(--line); }
  .dlist li:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}
.drow {
  width: 100%; min-height: 76px; display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 14px 10px 16px; border: 0; background: none; color: inherit; font: inherit; text-align: start;
}
button.drow { cursor: pointer; }
button.drow:hover { background: var(--sunk); }
.drow-thumb {
  position: relative; width: 60px; height: 60px; border-radius: 10px; overflow: hidden;
  display: grid; place-items: center; background: var(--sunk); color: var(--muted);
}
.drow-thumb::after { content: ""; position: absolute; inset: auto 0 0; height: 4px; background: var(--tone, var(--calm)); }
.drow-thumb img { width: 100%; height: 100%; object-fit: cover; }
.drow-thumb svg { width: 22px; height: 22px; }
.drow-n {
  position: absolute; top: 4px; right: 4px; padding: 2px 5px; border-radius: 6px;
  background: rgb(10 14 8 / 0.62); color: #f3f7ee; font: 500 10px/1.2 var(--font-mono);
}
.drow-main { display: grid; gap: 3px; min-width: 0; }
.drow-title { font-weight: 600; font-size: 14.5px; line-height: 1.3; overflow-wrap: anywhere; }
.drow-sub { font-size: 12.5px; line-height: 1.35; color: var(--muted); overflow-wrap: anywhere; }
.drow .chips { margin-top: 3px; }
.drow .chip { padding: 3px 8px; font-size: 11.5px; }
.drow .go { width: 16px; height: 16px; color: var(--muted); }

/* ── breakdown ───────────────────────────────────────────────────────── */
.modes { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--sunk); }
.mode {
  min-height: 32px; padding: 6px 12px; border: 0; border-radius: 999px; background: none; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.mode[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(21 32 17 / 0.14); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { display: grid; gap: 3px; align-content: start; min-width: 0; padding: 10px 12px; border-radius: 12px; background: var(--sunk); }
.tile-v { display: flex; align-items: center; gap: 8px; font: 600 26px/1.1 var(--font-body); letter-spacing: -0.01em; }
.tile-l { font-size: 12.5px; line-height: 1.3; color: var(--muted); }
.tile .sw { width: 12px; height: 12px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--sw); }
.lv-1 { --sw: var(--lv1); --on: var(--on-lv1); }
.lv-2 { --sw: var(--lv2); --on: var(--on-lv2); }
.lv-3 { --sw: var(--lv3); --on: var(--on-lv3); }
.lv-4 { --sw: var(--lv4); --on: var(--on-lv4); }
.lv-5 { --sw: var(--lv5); --on: var(--on-lv5); }
.lv-6 { --sw: var(--lv6); --on: var(--on-lv6); }
.lv-na { --sw: repeating-linear-gradient(135deg, var(--lv-na) 0 3px, var(--lv-na-line) 3px 4.5px); --on: var(--on-lv-na); }
.lv-nr { --sw: repeating-linear-gradient(135deg, var(--lv-nr) 0 3px, var(--lv-nr-line) 3px 4.5px); --on: var(--on-lv-nr); }
.lv-none { --sw: var(--surface); --on: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }
.bars { display: grid; gap: 12px; }
.bd-row { display: grid; gap: 5px; min-width: 0; }
.bd-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13.5px; }
.bd-label { min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.bd-total { font: 500 12.5px/1.4 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.track { display: flex; gap: 2px; width: 100%; height: 28px; min-width: 0; transition: width 240ms ease; }
.card--breakdown[data-mode="count"] .track { width: max(calc(var(--w) * 100%), 28px); }
.seg {
  flex: 1 1 0; min-width: 5px; display: flex; align-items: center; padding: 0 7px; overflow: hidden; cursor: pointer;
  border: 0; border-radius: 4px; background: var(--sw); color: var(--on);
  font: 600 12px/1 var(--font-body); font-variant-numeric: tabular-nums;
}
.seg.is-tight .seg-n { visibility: hidden; }
.card--breakdown:not([data-mode="share"]) .n-share, .card--breakdown[data-mode="share"] .n-count { display: none; }
.seg:hover { filter: brightness(1.08) saturate(1.05); }
.seg[aria-expanded="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }
.bd-table, .card--breakdown[data-mode="table"] .bars, .card--breakdown[data-mode="table"] .bd-hint { display: none; }
.card--breakdown[data-mode="table"] .bd-table { display: block; }
.bd-table { margin: 0; }
.data th.num, .data td.num { text-align: end; }
.bd-hint { margin: 0; font-size: 12px; color: var(--muted); }

.card--list .card-title { display: flex; align-items: center; gap: 9px; }
.card--list .sw { width: 14px; height: 14px; }
.items { list-style: none; margin: 0 -16px -16px; padding: 0; border-top: 1px solid var(--line); }
.items li + li { border-top: 1px solid var(--line); }
.item {
  width: 100%; min-height: 48px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 11px 16px; border: 0; background: none; color: inherit; font: inherit; text-align: start;
}
button.item { cursor: pointer; }
button.item:hover { background: var(--sunk); }
.item-text { display: grid; gap: 2px; min-width: 0; }
.item-label { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.item-detail { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.item .go { width: 15px; height: 15px; color: var(--muted); }

/* ── projects ────────────────────────────────────────────────────────── */
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.ptile {
  display: grid; gap: 5px; align-content: start; min-width: 0; padding: 12px 14px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.ptile-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pcode { font: 600 14px/1.2 var(--font-mono); }
.pdate { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ptype { font: 600 16px/1.25 var(--font-display); text-wrap: balance; overflow-wrap: anywhere; }
.ploc { font-size: 13px; color: var(--ink-2); }
.pranks { display: flex; gap: 4px; margin-top: 3px; }
.prank {
  padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px;
  font: 500 10.5px/1 var(--font-mono); color: var(--muted); opacity: 0.6;
}
.prank.is-on { border-color: transparent; background: var(--lime-wash); color: var(--lime-ink); opacity: 1; }
.pai { display: grid; gap: 6px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.pai-head { display: flex; align-items: baseline; gap: 6px; color: var(--ai); }
.pai-head .spark { align-self: center; width: 13px; height: 13px; }
.pai-pct { font: 600 22px/1 var(--font-body); color: var(--ink); }
.pai-label { font-size: 12.5px; color: var(--muted); }
.meter-bar { display: block; height: 4px; border-radius: 4px; background: var(--ai-line); overflow: hidden; }
.meter-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--ai); }
.meter-bar.is-main { height: 8px; }
.pai-parts { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 5px 10px; margin: 2px 0 0; font-size: 12px; }
.pai-parts dt { color: var(--muted); }
.pai-parts dd {
  margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  font: 400 11.5px/1.2 var(--font-mono); color: var(--ink-2); font-variant-numeric: tabular-nums;
}

/* ── tooltip, lightbox details ───────────────────────────────────────── */
.tip {
  position: fixed; z-index: 70; display: grid; gap: 1px; padding: 7px 10px; pointer-events: none;
  border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 12.5px; box-shadow: var(--shadow);
}
.tip b { font-weight: 600; }
.lightbox-cap small { display: block; margin-bottom: 3px; font: 500 10.5px/1.2 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: #9aa690; }
.lb-details {
  margin-inline-start: 10px; padding: 6px 12px; cursor: pointer;
  border: 1px solid rgb(255 255 255 / 0.3); border-radius: 999px; background: rgb(255 255 255 / 0.1); color: #f1f6ea; font-size: 12.5px;
}

/* ── replay on phones: the controls sit at the bottom, under the thumb ── */
@media (max-width: 720px) {
  body:not([data-mode="live"]) .bar { backdrop-filter: none; background: var(--bg); }
  body:not([data-mode="live"]) .controls {
    position: fixed; z-index: 30; left: 50%; translate: -50% 0; bottom: max(16px, env(safe-area-inset-bottom, 0px));
    padding: 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
  }
  body:not([data-mode="live"]) .controls .btn { min-height: 44px; padding: 12px 20px; font-size: 14.5px; }
  body:not([data-mode="live"]) .foot { padding-bottom: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .caret { animation: none; }
}
.item[aria-busy="true"] { cursor: progress; opacity: .6; }
