@import url("palette.css?v=16");

* { box-sizing: border-box; margin: 0; padding: 0; }

::selection { background: var(--accent); color: var(--user-fg); }

html { overflow-x: clip; }

html, body {
  font-family: "Times New Roman", Times, "Liberation Serif", serif;
  font-size: 12pt;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}

body {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 48px 0;
}

main > section { margin-bottom: 48px; }


/* ── Header ─────────────────────────────────────────────────────────── */

.wordmark {
  background: var(--bg);
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-top: -64px;
  margin-bottom: 0;
  padding: 64px 24px 40px;
}
.wordmark > * {
  max-width: 624px;
  margin-left: auto;
  margin-right: auto;
}
.wordmark h1 { font-size: 28pt; font-weight: normal; }

.wordmark-lockup {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  line-height: 1;
}
.lockup-prefix { font-size: 28pt; color: var(--text); letter-spacing: 0.5px; }
.plate-naked {
  display: inline-block;
  color: var(--text);
  letter-spacing: 0.5px;
  font-size: 28pt;
}
.acc-red { color: var(--accent); font-weight: 900; }

.tagline {
  font-size: 14pt;
  color: var(--muted);
  font-style: italic;
}


/* ── Composer ───────────────────────────────────────────────────────── */

#composer-section {
  background: var(--bg);
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-top: 0;
  margin-bottom: 0;
  padding: 0 24px 16px;
}
#composer-section > * {
  max-width: 624px;
  margin-left: auto;
  margin-right: auto;
}

#ask {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.samples {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sample {
  font-family: inherit;
  font-size: 11pt;
  text-align: left;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--slate);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.sample:hover,
.sample:focus {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--user-fg);
  outline: none;
}
.sample:disabled {
  pointer-events: none;
  opacity: 0.55;
}

textarea#q {
  width: 100%;
  font-family: inherit;
  font-size: 12pt;
  line-height: 1.4;
  padding: 12px 14px;
  border: 1px solid var(--input-border);
  background: var(--bg);
  resize: none;
  overflow-y: hidden;  /* JS auto-grows the height; no scrollbar needed */
  color: var(--text);
}
textarea#q::placeholder { color: var(--placeholder); }
textarea#q:focus { outline: 2px solid var(--accent); outline-offset: -2px; border-color: var(--accent); }
textarea#q:disabled { opacity: 0.55; pointer-events: none; }

.form-bottom {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}
.token-counter {
  font-size: 11pt;
  color: var(--muted);
  font-style: italic;
  margin-right: auto;  /* pushes Stress-Test button to the right edge */
}
.token-counter:empty { display: none; }
.token-counter.over-limit { color: var(--accent); font-style: normal; font-weight: bold; }

button#send {
  font-family: inherit;
  font-size: 12pt;
  padding: 11px 25px;
  background: var(--accent);
  color: var(--user-fg);
  border: none;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background-color 0.15s;
}
button#send:hover:not(:disabled) { background: var(--vermilion); }
button#send:disabled {
  cursor: not-allowed;
  background: var(--rule);
  color: var(--muted);
}


/* ── Chain ──────────────────────────────────────────────────────────── */

#chain {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.msg.user {
  padding: 24px;
  white-space: pre-wrap;
  color: var(--text);
  background: var(--panel);
}

.msg.error { color: var(--error); }
.msg.empty {
  color: var(--muted);
  font-style: italic;
  padding: 18px 22px;
  background: var(--bg);
  border: 1px solid var(--border);
}


/* ── Under-the-hood — vertical stack of stat-blocks ─────────────────── */

#under-the-hood {
  background: var(--bg);
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-bottom: 0;
  padding: 56px 24px 96px;
}
#under-the-hood > * {
  max-width: 624px;
  margin-left: auto;
  margin-right: auto;
}
#under-the-hood .stat-block { margin-bottom: 80px; }
#under-the-hood .stat-block:last-child { margin-bottom: 0; }

.stat-block h3 {
  font-size: 12pt;
  font-weight: bold;
  color: var(--text);
  margin-bottom: 18px;
  line-height: 1.35;
}
.chart-note {
  font-size: 12pt;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 18px;
}
.stat-block h3 + .chart-note { margin-top: -10px; }

/* Three-tile proportional bar — 706 / 881 / 552 fr-units = one
   horizontal proportion bar. */
.va-tiles {
  display: grid;
  grid-template-columns: minmax(0, 706fr) minmax(0, 881fr) minmax(0, 552fr);
  gap: 6px;
}

.va-tile {
  padding: 16px 18px;
  font-variant-numeric: tabular-nums;
}
.va-tile-value { font-size: 33pt; line-height: 1; margin-bottom: 7px; }
.va-tile-sub   { font-size: 12pt; font-weight: bold; }

.va-tiles.va-vivid .va-tile-a { background: var(--accent);      color: var(--user-fg); }
.va-tiles.va-vivid .va-tile-b { background: var(--accent-deep); color: var(--user-fg); }
.va-tiles.va-vivid .va-tile-c { background: var(--plot-blue);   color: var(--user-fg); }

/* Segmented progress bar — proportions track raw counts (706 / 881 / 552).
   Labels live inside each segment (12pt, parchment on dark fills). */
.va-bar {
  display: grid;
  grid-template-columns: minmax(0, 706fr) minmax(0, 881fr) minmax(0, 552fr);
  gap: 0;
  height: 64px;
}
.va-bar-fill {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 0 14px;
  color: var(--user-fg);
  font-size: 12pt;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
}
.va-bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.va-bar-a { background: var(--accent); }
.va-bar-b { background: var(--graphite); }
.va-bar-c { background: var(--pebble); color: var(--ink); }

/* Variant B — per-court horizontal bars, label left, value right */
.va-rows { display: flex; flex-direction: column; gap: 8px; }
.va-row {
  display: grid;
  grid-template-columns: 220px 1fr 48px;
  align-items: center;
  gap: 12px;
  height: 24px;
}
.va-row-label { font-size: 12pt; white-space: nowrap; }
.va-row-bar   { position: relative; height: 100%; }
.va-row-fill  { height: 100%; }
.va-row-num   { font-size: 12pt; font-variant-numeric: tabular-nums; text-align: right; }
.va-row-cat .va-row-fill { background: var(--accent);   }
.va-row-uk  .va-row-fill { background: var(--graphite); }
.va-row-eu  .va-row-fill { background: var(--pebble);   }


/* Tcite — proportional bars with overlaid label/count */

.tcite-stack { margin-top: 12px; }

.tcite-row {
  position: relative;
  height: 57px;
  margin-bottom: 6px;
}
.tcite-row:last-child { margin-bottom: 0; }

.tcite-fill {
  height: 100%;
  min-width: 2px;
  box-sizing: border-box;
}

.tcite-text {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  white-space: nowrap;
  font-size: 12pt;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.tcite-text-light { color: var(--user-fg); }
.tcite-text-dark  { color: var(--ink); }
.tcite-text-page  { color: var(--text); }

.tcite-applied    { background: var(--graphite); }
.tcite-challenged { background: var(--accent); }
.tcite-mentioned  { background: var(--pebble); }


/* Ranked list */

.ranked { list-style: none; }
.ranked li {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  font-size: 12pt;
  border-bottom: 1px solid var(--border);
}
.ranked li:last-child { border-bottom: none; }

.ranked-row {
  display: grid;
  grid-template-columns: 28px 1fr 44px;
  align-items: baseline;
  gap: 12px;
}
.rank       { color: var(--text); text-align: right; }
.cite-title { color: var(--text); line-height: 1.35; }
.cite-ref   { color: var(--muted); font-style: italic; }
.cite-num   { color: var(--text); text-align: right; }


/* Authorities bubble chart — x=year, y=cite count (log), size=√count.
   Pure SVG. */

.auth-host {
  position: relative;
  width: 100%;
  aspect-ratio: 624 / 360;
  margin-top: 8px;
}
.auth-host svg { display: block; width: 100%; height: 100%; overflow: visible; }
.auth-bubble           { fill: var(--aggregate); fill-opacity: 1; }
.auth-bubble:not(.auth-bubble-marked):hover { fill: var(--graphite); }
.auth-bubble-marked    { fill: var(--accent); }
.auth-grid          { stroke: var(--rule); stroke-width: 1; fill: none; }
.auth-tick-label {
  font-size: 12pt;
  fill: var(--text);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.auth-label {
  font-size: 12pt;
  fill: var(--text);
  font-family: inherit;
}
.auth-host { position: relative; }
.auth-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--parchment);
  color: var(--ink);
  border: 1px solid var(--rule);
  padding: 8px 12px;
  font-size: 12pt;
  width: 280px;
  line-height: 1.3;
  visibility: hidden;
  z-index: 10;
}


/* Timeline chart — pure HTML. Bars are CSS grid cells, gridlines are
   absolute divs. Browsers snap CSS block geometry to pixels natively, so
   adjacent bars never leak sub-pixel seams the way scaled SVG rects do. */

.ts-host {
  position: relative;
  width: 100%;
  aspect-ratio: 624 / 360;
  margin-top: 8px;
}

.ts-chart-area {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 87%;       /* bottom 13% reserved for x-tick labels */
}

.ts-gridline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--rule);
}

.ts-xaxis {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid var(--muted);
}

.ts-bars-grid {
  position: absolute;
  inset: 0 0 1px 0;  /* leave 1px gutter at the bottom for the x-axis line */
  display: grid;
}
.ts-year-col {
  display: flex;
  flex-direction: column-reverse;
  padding: 0 3px;  /* 6px visual gap between adjacent year bars; tick marks sit in this gutter */
}
.ts-seg {
  width: 100%;
  box-sizing: border-box;
}
.ts-seg.ts-cat { background: var(--accent);   }
.ts-seg.ts-uk  { background: var(--graphite); }
.ts-seg.ts-eu  { background: var(--pebble);   }

.ts-xtick-mark {
  position: absolute;
  top: 87%;
  width: 1px;
  height: 6px;
  background: var(--muted);
  transform: translateX(-50%);
}
.ts-xtick-mark.ts-xtick-major {
  height: 12px;
}

.ts-legend {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--bg);
  padding: 6px 28px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11pt;
  line-height: 1;
  z-index: 2;
}
.ts-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ts-legend-sw {
  display: inline-block;
  width: 12px;
  height: 12px;
  box-sizing: border-box;
}
.ts-legend-sw.ts-cat { background: var(--accent);   }
.ts-legend-sw.ts-uk  { background: var(--graphite); }
.ts-legend-sw.ts-eu  { background: var(--pebble);   }

.ts-host > span {
  position: absolute;
  font-size: 12pt;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
  line-height: 1;
}
.ts-y-tick {
  right: 0;
  padding-bottom: 3px;
}
.ts-xtick {
  top: calc(87% + 18px);
  transform: translateX(-50%);
}


/* ── Install CTA — local preview only ─────────────────────────────────── */

#install-cta { display: none; }
html.local #install-cta {
  display: block;
  background: var(--blue);
  color: var(--user-fg);
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-top: 0;
  margin-bottom: 0;
  padding: 64px 24px;
  text-align: center;
}
#install-cta .cta-headline,
#install-cta .cta-lede {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
#install-cta .cta-headline {
  font-size: 22pt;
  font-weight: bold;
  margin-bottom: 12px;
  color: var(--user-fg);
}
#install-cta .cta-lede {
  font-size: 13pt;
  line-height: 1.45;
  margin-bottom: 20px;
  color: var(--user-fg);
}
#install-cta .cta-source {
  display: inline-block;
  font-size: 12pt;
  font-weight: bold;
  border-bottom: none;
  text-decoration: none;
  background: var(--parchment);
  color: var(--blue);
  padding: 10px 22px;
  outline: 2px solid var(--parchment);
  outline-offset: -2px;
  transition: background-color 0.15s, color 0.15s;
}
#install-cta .cta-source:hover {
  background: transparent;
  color: var(--parchment);
}


/* ── Footer ─────────────────────────────────────────────────────────── */

#built-by {
  background: var(--bg);
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-top: 0;
  margin-bottom: 0;
  padding: 32px 24px 120px;
  color: var(--muted);
  font-size: 11pt;
}
#built-by > * {
  max-width: 624px;
  margin-left: auto;
  margin-right: auto;
}
#built-by a {
  color: var(--text);
  border-bottom: 1px solid var(--muted);
}
#built-by a:hover { border-bottom-color: var(--accent); color: var(--accent); }


/* ── Anchors (generic) ──────────────────────────────────────────────── */

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
a:hover { border-bottom-color: var(--text); }


/* ── Mobile ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  body { padding: 36px 20px 64px; }
  .wordmark { margin-bottom: 36px; }
  .wordmark h1 { font-size: 22pt; }
  .tagline { font-size: 12pt; }
  main > section { margin-bottom: 40px; }
  .ranked-row { grid-template-columns: 22px 1fr 32px; gap: 10px; }
}




/* ── Streaming SSE stack ────────────────────────────────────────────── */

.submission {
  display: flex;
  flex-direction: column;
  gap: 44px;
  margin-top: 16px;
  margin-bottom: 32px;
}

.dot-loader {
  display: inline-flex;
  gap: 6px;
  margin-left: 10px;
  vertical-align: middle;
}
.dot-loader span {
  width: 8px;
  height: 8px;
  display: inline-block;
  background: var(--accent-soft);
  animation: dot-cycle 1.5s ease-in-out infinite;
}
.dot-loader span:nth-child(2) { animation-delay: 0.25s; }
.dot-loader span:nth-child(3) { animation-delay: 0.5s; }

@keyframes dot-cycle {
  0%, 100% { background: var(--accent-soft); }
  33%      { background: var(--accent); }
  66%      { background: var(--accent-dark); }
}

.phase-meta {
  font-size: 10pt;
  color: var(--muted);
  font-style: italic;
  margin-top: 4px;
}
.phase-meta:empty { display: none; }

.round,
.skeleton {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.round-header {
  background: var(--graphite);
  color: var(--user-fg);
  font-size: 10pt;
  font-weight: bold;
  letter-spacing: 0.6px;
  padding: 4px 12px;
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.round-header.side-defendant { background: var(--accent); }
.round-header.side-claimant { background: var(--graphite); }
.round-header:empty { display: none; }
.round-footer,
.skeleton-header {
  color: var(--user-fg);
  font-size: 10pt;
  font-weight: bold;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  padding: 4px 12px;
  margin-top: 0;
  text-align: center;
}
.skeleton-header { background: var(--graphite); }
.round-footer    { background: var(--user-bg); }
.round-empty .phase { display: none; }
.round-empty::after {
  content: 'Round skipped — no grounding.';
  display: block;
  font-style: italic;
  color: var(--muted);
  font-size: 11pt;
}

.phase {
  position: relative;
  animation: phase-fade-in 220ms ease;
}
@keyframes phase-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.phase-header {
  display: flex;
  align-items: last baseline;
  gap: 18px;
  margin-bottom: 14px;
}
.phase-title { flex: 1; min-width: 0; }

.phase-body {
  background: var(--panel);
  padding: 24px;
}
.phase-body .dot-loader { margin-left: 0; gap: 8px; }
.phase-body .dot-loader span { width: 12px; height: 12px; }

.phase-head {
  font-size: 11pt;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
}

.phase-empty {
  font-size: 11pt;
  color: var(--muted);
  font-style: italic;
  padding: 6px 0 4px;
}
.phase-empty.errored {
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}


/* ── Inline citations inside synthesis ───────────────────────────────── */

/* All citation spans rendered italic — UK chambers convention for quoted
   material. The actual display_text comes from source (backend
   reconstruction), not from model output. Citation source is identified
   via markdown link [display](CHUNK_ID.SENTENCE_NUM) in the streamed text;
   the parser resolves chunk_id → source metadata via synthesis-citations
   SSE event payload. */
/* Verbatim quote = plain "double quotes" (chambers convention). No italic,
   no underline. The clickable affordance is the parenthetical that follows.
   citation-link: case_ref text inside (parens), grey underline default,
   black on hover, opens the PDF at cited page.
   citation-matched: source known but no PDF anchor — plain text, no link. */
.citation-link {
  color: var(--text);
  border-bottom: none;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: solid;
  text-decoration-color: var(--faint);
  text-underline-offset: 3px;
}
.citation-link:hover {
  text-decoration-color: var(--text);
}
.citation-link:focus,
.citation-link:focus-visible {
  outline: none;
}
.citation-matched {
  color: var(--text);
}


/* ── Stress test ────────────────────────────────────────────────────── */

.stress-test {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stress-test-block {
  font-size: 12pt;
  line-height: 1.55;
  white-space: pre-wrap;
}
.stress-heading {
  font-size: 12pt;
  font-weight: bold;
  margin-top: 28px;
  margin-bottom: 14px;
}
.stress-heading:first-child { margin-top: 0; }
.stress-body {
  white-space: pre-wrap;
  hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
}
.stress-body p { margin-bottom: 12px; }


/* ── Print — PDF deliverable for chambers ───────────────────────────── */

@media print {
  html, body {
    background: white !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }
  .wordmark, #composer-section, .samples, .phase-numeral, .dot-loader,
  #built-by, #under-the-hood, header, footer { display: none !important; }
  main > section { margin: 0 !important; }
  #chain-section { background: transparent !important; padding: 0 !important; margin: 0 !important; }
  .submission { margin: 0 !important; gap: 18pt !important; }
  .stress-body, .stress-heading, p {
    break-inside: avoid; page-break-inside: avoid;
    orphans: 3; widows: 3;
  }
  .stress-heading, h2 {
    break-after: avoid; page-break-after: avoid;
  }
  a { color: inherit; text-decoration: none; }
  .resonant-cite {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
@page { margin: 12mm 14mm; }
