:root {
  --canvas: #121316;
  --surface: #191B20;
  --surface-raised: #20232A;
  --surface-hover: #292D36;
  --ink: #EFF1F5;
  --muted: #A9B0BC;
  --rule: #343841;
  --control-border: #6C7585;
  --cite: #A9C0F8;
  --action-hover: #D4D9E6;
  --alert: #F2A799;
  --indexed: #8FD3A8;
  --evidence-fill: #433A25;
  --evidence-ink: #F5E6BC;
  --sheet: #FFFEFA;
  --sheet-ink: #28251F;
  --sheet-muted: #6A6255;
  --sheet-rule: #D8D2C4;
  --sheet-cite: #2A4B9B;
  --sheet-mark: #F2E2A0;
  --sans: "Avenir Next", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --raised-edge: rgb(255 255 255 / .04);
  --gutter: clamp(20px, 3.1vw, 48px);
  color-scheme: dark;
  background: var(--canvas);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  margin: 0;
}
main {
  min-width: 0;
  overflow: auto;
  padding-bottom: 28px;
  scroll-padding-block: 18px;
}
button, input { font: inherit; color: inherit; border-radius: 0; }
button, summary, a {
  -webkit-tap-highlight-color: transparent;
  transition: background-color 100ms, color 100ms, text-decoration-color 100ms;
}
button { min-height: 40px; cursor: pointer; }
button:disabled { color: var(--muted); opacity: .54; cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex="-1"]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
h1, h2, h3, h4, p { margin: 0; }
h2, h3, h4, strong { font-weight: 600; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 1; top: 10px; left: 10px; min-height: 40px; background: var(--surface-raised); color: var(--ink); padding: 9px 14px; }

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 6px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.identity, .mast-actions { display: flex; align-items: center; gap: 16px; }
.wordmark { font-size: 24px; font-weight: 600; line-height: 1; }
.wordmark span { color: var(--muted); }
.mast-divider { width: 1px; height: 17px; background: var(--rule); }
.workspace-name { color: var(--muted); }
[data-variant="A"] .mast-actions { display: none; }
.ghost, .icon-button, .add-button {
  border: 1px solid var(--control-border);
  background: var(--surface-raised);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.ghost, .add-button { padding: 0 12px; }
.icon-button { width: 40px; padding: 0; flex: none; font-size: 20px; line-height: 1; }
.ghost:hover, .add-button:hover, .icon-button:not(:disabled):hover { background: var(--surface-hover); }

.layout {
  margin: 0 auto;
  padding: 22px var(--gutter) 0;
}
.panel, .workspace, .reader-query { min-width: 0; }
.composer-field {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-inline: 11px 4px;
  border: 1px solid var(--control-border);
  background: var(--surface);
}
.composer-field:has(input:focus) { outline: 2px solid var(--cite); outline-offset: 2px; }
.composer input {
  width: 0;
  min-width: 0;
  flex: 1;
  height: 100%;
  border: 0;
  outline: none;
  padding: 0;
  background: transparent;
  font-size: 15px;
}
.composer input::placeholder { color: var(--muted); }
.composer input:not(:focus) { text-overflow: ellipsis; }
.search-icon { width: 11px; height: 11px; margin: 0 4px 3px 0; border: 1.5px solid var(--muted); border-radius: 50%; position: relative; flex: none; }
.search-icon::after { content: ''; position: absolute; width: 5px; height: 1.5px; top: 8px; left: 8px; background: var(--muted); transform: rotate(45deg); transform-origin: left; }
.composer-scope, .example {
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}
.composer-scope { margin-top: 8px; }
.composer-scope:hover, .example:hover { border-color: var(--control-border); background: var(--surface-hover); }
.primary {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  height: 40px;
  background: var(--ink);
  border: 1px solid var(--ink);
  padding: 0 12px;
  color: var(--canvas);
  font-weight: 600;
  white-space: nowrap;
}
.primary:hover { background: var(--action-hover); border-color: var(--action-hover); }
.primary[aria-disabled="true"] { opacity: .78; cursor: progress; }
.examples { margin-top: 10px; container: sample-questions / inline-size; }
.example-list { display: flex; flex-wrap: wrap; gap: 6px; }
.example { min-height: 32px; text-align: center; line-height: 1.15; text-wrap: balance; }
@container sample-questions (max-width: 470px) {
  .example-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .example { padding-inline: 3px; }
}
.citation {
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--cite);
}
.citation-open:hover { text-decoration: underline; text-underline-offset: .18em; }
.citation:focus-visible { outline-color: var(--cite); }

.answer { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--rule); }
.answer-meta { margin-bottom: 7px; }
.outcome { color: var(--muted); font: 400 12px/1.55 var(--mono); }
.outcome.supported { color: var(--indexed); }
.outcome.error { color: var(--alert); }
.answer h2 { max-width: 55ch; font-size: 20px; line-height: 1.4; font-weight: 600; }
.claim p, .answer-message { color: var(--ink); font-size: 16px; line-height: 1.65; }
.claim p, .answer-message { max-width: 63ch; }
.claim p, .answer-message { margin-top: 10px; }
.answer.pending { color: var(--muted); font: 400 12px/1.55 var(--mono); }
.retry { margin-top: 14px; }

.citation-chip {
  display: inline-block;
  padding: 2px 4px;
  border: 1px solid color-mix(in srgb, var(--cite) 40%, transparent);
  border-radius: 2px;
  background: color-mix(in srgb, var(--cite) 12%, transparent);
  color: var(--cite);
  font: 600 11px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  transition: background-color 100ms;
}
.citation.is-linked .citation-chip, .citation:hover .citation-chip, .citation:focus-visible .citation-chip { background: color-mix(in srgb, var(--cite) 20%, transparent); }
.citation.compact {
  display: inline-block;
  vertical-align: baseline;
  min-width: 24px;
  height: 40px;
  margin: -10px 0;
  padding: 0 4px 4px;
  line-height: 1;
}
.claim p .citation-number { position: relative; top: -.2em; }
.citation-open.is-linked,
.citation-list.is-linked .citation-title { text-decoration: underline 2px; text-underline-offset: 3px; }
.source-links { list-style: none; margin: 16px 0 0; padding: 0; }
.source-links li { border-top: 1px solid var(--rule); }
.citation-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  text-align: left;
  width: 100%;
}
.citation-list.is-linked { background: var(--surface-hover); }
.citation-title, .citation-page { color: var(--muted); font-size: 13px; }
.citation-page { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.citation-list.active .citation-title { color: var(--ink); }
.citation-tooltip {
  position: fixed;
  z-index: 2;
  width: max-content;
  max-width: calc(100vw - 16px);
  padding: 6px 8px;
  border: 1px solid var(--control-border);
  border-top-color: var(--raised-edge);
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 12px;
  pointer-events: none;
}
.answer-reveal .claim { animation: answer-in 180ms ease-out both; animation-delay: calc(var(--claim-index) * 120ms); }
.answer-reveal .citation-chip, .paper-passage.revealed .citation-chip { animation: citation-outline 300ms ease-out both; }
.answer-reveal .citation-chip { animation-delay: calc(var(--claim-index, 0) * 120ms + 180ms); }
.answer-reveal .answer-meta { animation: answer-in 150ms ease-out both; animation-delay: calc(var(--claim-count) * 120ms + 360ms); }
@keyframes answer-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes citation-outline { 50% { outline: 1px solid var(--cite); outline-offset: 2px; } }

mark {
  background: var(--evidence-fill);
  color: var(--evidence-ink);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.active > mark, .is-linked > mark, .active blockquote mark, .is-linked blockquote mark {
  text-decoration: underline 2px var(--cite);
  text-underline-offset: 4px;
  text-decoration-skip-ink: auto;
}

.ledger { max-width: calc(880px + 2 * var(--gutter)); }
.ledger .answer { padding-top: 13px; }
.ledger .claim {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1.09fr);
  align-items: start;
  gap: 12px;
  border-bottom: 1px solid var(--rule);
  padding: 14px 0;
}
.ledger .claim:first-of-type { margin-top: 8px; }
.ledger .claim p { margin: 4px 0 0; }
.ledger .claim > .citation { margin: 0; padding: 0 4px 8px; }
.evidence-row { min-width: 0; border-left: 1px solid var(--rule); padding-left: 18px; }
.evidence-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  min-height: 40px;
}
.evidence-source { color: var(--muted); font-size: 13px; }
.citation-open { white-space: nowrap; font-size: 12px; font-weight: 600; }
.evidence-row blockquote { margin: 0; font: 15px/1.7 Georgia, serif; font-variant-numeric: tabular-nums; }
.ledger-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.ledger-preview .expand { margin-left: auto; }

.library-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin-bottom: 10px;
}
.library-heading h2 { font-size: 14px; }
.add-button { gap: 7px; margin-bottom: 14px; }
.file-list { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--rule); }
.file-list li { border-top: 1px solid var(--rule); }
.file-row {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  padding: 8px 9px 8px 10px;
  text-align: left;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
}
button.file-row:hover, .file-row.selected { background: var(--surface-hover); }
.file-row.selected { border-left-color: var(--cite); }
.file-text { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.file-text strong { font-size: 14px; line-height: 1.4; }
.file-text small { color: var(--muted); font: 400 12px/1.55 var(--mono); }
.file-text .upload-failed, .upload-feedback { color: var(--alert); }
.library-note { margin-top: 12px; color: var(--indexed); font: 400 12px/1.5 var(--mono); }
.upload-feedback { font-size: 12px; margin-bottom: 10px; }

.viewer { min-width: 0; scroll-margin-top: 14px; }
.viewer-heading h2:not(.sr-only) { padding: 14px 14px 0; font-size: 14px; overflow-wrap: anywhere; }
.viewer-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 8px;
  row-gap: 3px;
  padding: 5px 0 7px;
  border-bottom: 1px solid var(--rule);
}
.viewer-description { flex: 1 1 114px; min-width: 0; }
.viewer-file { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.viewer-evidence, .viewer-location { color: var(--muted); font: 400 12px/1.5 var(--mono); }
.viewer-controls {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.viewer-controls .icon-button { width: 32px; height: 32px; min-height: 32px; background: var(--surface-raised); font-size: 19px; }
.viewer-controls .icon-button:disabled { opacity: .78; }
.expand { padding-inline: 7px; min-height: 32px; font-size: 12px; white-space: nowrap; }

.reader-sheet {
  background: var(--surface);
  padding: clamp(13px, 1.6vw, 25px);
}
.paper {
  --inset: clamp(18px, 2.3vw, 33px);
  --ink: var(--sheet-ink);
  --muted: var(--sheet-muted);
  --rule: var(--sheet-rule);
  --cite: var(--sheet-cite);
  --evidence-fill: var(--sheet-mark);
  --evidence-ink: var(--sheet-ink);
  display: flex;
  flex-direction: column;
  max-width: 580px;
  min-height: 466px;
  margin: 0 auto;
  padding: var(--inset) max(var(--inset), 42px) var(--inset) var(--inset);
  border: 1px solid var(--rule);
  background: var(--sheet);
  color: var(--ink);
  color-scheme: light;
}
.paper-identity { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; }
.paper-mark { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--ink); font: 400 13px/1 Georgia, serif; }
.paper-topic, .paper-folio { color: var(--muted); font-size: 12px; }
.paper-folio > span:last-child { font-family: var(--mono); }
.paper-topic { margin-top: 23px; }
.paper h3 { margin-top: 4px; font: 400 25px/1.2 Georgia, serif; }
.paper h4 { margin-top: 17px; padding-top: 9px; border-top: 1px solid var(--rule); font-size: 12px; }
.paper p { margin-top: 7px; font: 400 16px/1.7 Georgia, serif; font-variant-numeric: tabular-nums; }
.paper-folio {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 20px;
}
.paper-passage { position: relative; scroll-margin-block: 18px; }
.citation-margin {
  position: absolute;
  inset-inline-start: calc(100% + 3px);
  inset-block-start: -6px;
  width: 32px;
}
.paper-passage.revealed mark { animation: reveal-passage 300ms ease-out both; }
@keyframes reveal-passage { from { background-color: transparent; } to { background-color: var(--evidence-fill); } }
.reader-empty { padding: 32px 20px; background: var(--surface); color: var(--muted); }

.desk {
  display: grid;
  grid-template-columns: 240px minmax(0, 640px) 480px;
  max-width: 1540px;
}
.desk .library { grid-area: 1 / 1; padding-right: 22px; }
.desk .workspace { grid-area: 1 / 2; padding-inline: clamp(18px, 2.1vw, 30px); border-inline: 1px solid var(--rule); }
.desk .viewer { grid-area: 1 / 3; padding-left: 22px; }

.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  grid-template-areas: "viewer query";
  gap: 27px;
  align-items: start;
  max-width: 1440px;
}
.reader-focus { grid-area: viewer; min-width: 0; }
.reader-query { grid-area: query; position: relative; }
.reader-query::before {
  content: "";
  position: absolute;
  inset-block: 0;
  left: -14px;
  border-left: 1px solid var(--rule);
}
.reader-layout .reader-sheet { padding: clamp(18px, 3.2vw, 46px); }
.reader-layout .paper { --inset: clamp(27px, 3.25vw, 47px); min-height: 510px; }

.prototype-footer {
  background: var(--surface);
  border-top: 1px solid var(--rule);
}
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 15px;
  height: 17px;
  padding-inline: 3px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface-raised);
  color: var(--ink);
  font: 400 11px/1 var(--mono);
  vertical-align: baseline;
}
.shortcuts-button, .upload-options summary {
  min-height: 30px;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.shortcuts-button:hover, .upload-options summary:hover { background: var(--surface-hover); color: var(--ink); }
.prototype-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 4px 8px max(4px, env(safe-area-inset-bottom));
}
.variant-switcher {
  display: inline-flex;
  align-items: center;
  width: max-content;
  gap: 5px;
  border: 1px solid var(--rule);
  border-top-color: var(--raised-edge);
  background: var(--surface-raised);
  color: var(--muted);
  white-space: nowrap;
}
.variant-switcher button {
  width: 28px;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 19px;
  line-height: 1;
}
.variant-switcher button:hover { background: var(--surface-hover); color: var(--ink); }
#variant-label { min-width: 108px; text-align: center; font-size: 12px; }
#variant-label span { color: var(--ink); font-weight: 600; margin-right: 3px; }
.upload-options { position: relative; color: var(--muted); font-size: 12px; }
.upload-options summary { cursor: pointer; white-space: nowrap; }
.upload-menu {
  position: absolute;
  z-index: 1;
  inset: auto 0 calc(100% + 5px) auto;
  width: 220px;
  padding: 10px;
  border: 1px solid var(--control-border);
  border-top-color: var(--raised-edge);
  background: var(--surface-raised);
}
.upload-menu button { display: block; width: 100%; min-height: 32px; padding: 4px; border: 0; background: transparent; text-align: left; font-weight: 600; }
.upload-menu button:hover { background: var(--surface-hover); }
.upload-menu p { margin-bottom: 5px; }

dialog {
  width: calc(100% - 28px);
  max-width: 690px;
  max-height: calc(100dvh - 36px);
  padding: 0;
  border: 1px solid var(--control-border);
  border-top-color: var(--raised-edge);
  background: var(--surface-raised);
  color: var(--ink);
  overscroll-behavior: contain;
}
dialog[open] { animation: dialog-in 150ms ease-out both; }
dialog::backdrop { background: rgb(0 0 0 / .6); }
@keyframes dialog-in { from { opacity: 0; } to { opacity: 1; } }
#library-dialog { max-width: 420px; padding: 15px 17px; }
#shortcuts-dialog { max-width: 420px; padding: 15px 17px; }
.shortcut-list { margin: 0; }
.shortcut-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.shortcut-list dd { margin: 0; white-space: nowrap; }
#source-dialog .viewer-tools { padding: 5px 14px 8px; }
#source-dialog .paper { --inset: clamp(20px, 4vw, 47px); min-height: 490px; }
#source-dialog .reader-sheet { padding: clamp(13px, 3vw, 25px); }

@media (max-width: 1199px) {
  .desk { grid-template-columns: minmax(150px, .65fr) minmax(0, 1.4fr) minmax(0, 1.27fr); }
  .desk .library { padding-right: 16px; }
  .desk .viewer { padding-left: 16px; }
  .reader-layout { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .masthead { padding-block: 6px; min-height: 53px; }
  .identity, .mast-actions { gap: 10px; }
  .workspace-name, .mast-divider { display: none; }
  .layout { padding-top: 22px; }
  .desk { display: block; }
  .desk .library { display: none; }
  .desk .workspace { padding: 0; border: 0; }
  .desk .viewer { margin-top: 22px; padding: 0; border-top: 1px solid var(--rule); }
  .reader-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "query" "viewer";
    gap: 19px;
  }
  .reader-query::before { display: none; }
  .reader-focus { border-top: 1px solid var(--rule); }
  .reader-layout .paper { min-height: 395px; }
  .ledger .claim { grid-template-columns: 32px minmax(0, 1fr); gap: 0 6px; }
  .evidence-row { grid-column: 2; margin-top: 5px; padding-left: 12px; }
  .ledger .claim > .citation { padding-inline: 0; min-width: 32px; }
  .evidence-heading { column-gap: 8px; }
  .paper { min-height: 390px; }
  .prototype-tools { gap: 8px; }
  #variant-label { min-width: 90px; font-size: 11px; }
  .variant-switcher { gap: 2px; }
  .variant-switcher button { width: 23px; }
  .composer-field { gap: 6px; }
  .composer-field .primary { padding-inline: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
