:root {
  color-scheme: dark;
  --surface: #141414;
  --text: #f0f0e9;
  --muted: #b7b7b1;
  --rule: #535350;
  --edge: #83837b;
  --accent: #d5e487;
  --error: #ffb39e;
  font: 15px/1.5 ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; background: var(--surface); color: var(--text); }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, dl, dd { margin: 0; }
h1 { font-size: 1.4rem; font-weight: 500; letter-spacing: .02em; }
h2 { font-size: 1.12rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 500; }
a, summary, .text-button { color: inherit; text-decoration: underline; text-underline-offset: .23em; }
button, input, textarea { font: inherit; color: inherit; }
button, .file-picker, textarea { border: 1px solid var(--edge); border-radius: 3px; background: transparent; }
button, .file-picker { min-height: 2.25rem; padding: .3rem .85rem; cursor: pointer; }
button:disabled { color: var(--muted); opacity: .68; cursor: default; }
button:hover:not(:disabled), .file-picker:hover, .file-picker.drag { background: #252525; }
button:focus-visible, a:focus-visible, summary:focus-visible, textarea:focus-visible, input:focus-visible, .file-picker:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
button[aria-pressed="true"].primary, .runtime-options button[aria-pressed="true"], button.primary {
  color: #151810;
  background: var(--accent);
  border-color: var(--accent);
}
button.primary:hover:not(:disabled), .runtime-options button[aria-pressed="true"]:hover { background: #e3edac; }
button.primary:disabled { color: #25291c; }
.text-button { padding-inline: 0; border-color: transparent; }
.text-button:hover:not(:disabled) { color: var(--accent); background: transparent; }
.muted { color: var(--muted); }
:where(#status, #runtime-status, #model-message)[data-error="true"], #run-state[data-state="failed"] { color: var(--error); }
.sr-only, .file-picker input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; top: .5rem; left: 1rem; padding: .5rem; color: #141414; background: var(--accent); z-index: 10; transform: translateY(-150%); }
.skip:focus { transform: none; }
.masthead { border-bottom: 1px solid var(--rule); padding: .65rem clamp(1rem, 2.6vw, 3rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.masthead a { text-decoration: none; }
.masthead a:hover { text-decoration: underline; }
main { width: 100%; flex: 1; padding: .75rem clamp(1rem, 3.4vw, 4rem) 3.5rem; }
main > nav { display: flex; flex-wrap: wrap; gap: .75rem; border-bottom: 1px solid var(--rule); }
main > nav button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: .65rem .55rem; }
main > nav button[aria-pressed="true"] { border-color: var(--accent); }
.runtime { border-bottom: 1px solid var(--rule); padding: 1.25rem 0 1rem; }
.runtime-bar, .runtime-options, .runtime-actions { display: flex; align-items: center; flex-wrap: wrap; column-gap: .7rem; row-gap: .5rem; }
.runtime-bar { gap: .7rem 1.25rem; }
.runtime-actions { margin-inline-start: auto; }
#runtime-status { color: var(--muted); font-size: .9rem; }
.runtime p { margin-top: .5rem; font-size: .88rem; }
#guest-setup { margin-top: .9rem; }
#guest-files { max-width: 100%; }
#guest-setup label { display: block; margin-bottom: .35rem; }
.inputs { border-bottom: 1px solid var(--rule); padding: 1.25rem 0; }
.input-row { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem 1.15rem; }
.file-picker { position: relative; display: inline-flex; align-items: center; }
.file-picker:has(input:disabled) { cursor: default; opacity: .68; }
.file-name { min-width: 8rem; max-width: 100%; overflow-wrap: anywhere; }
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.check input { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }
.samples, .input-end { margin-inline-start: auto; }
.samples { position: relative; }
.samples div { position: absolute; z-index: 1; inset-inline-end: 0; top: 1.8rem; min-width: max-content; padding: .6rem; background: #1b1b1b; border: 1px solid var(--rule); display: grid; gap: .4rem; }
summary { cursor: pointer; }
textarea { flex: 1 1 15rem; padding: .5rem; resize: vertical; }
#needle-limit { width: 100%; font-size: .88rem; }
#cancel { margin-top: .75rem; }
.output { min-height: 18rem; padding: .6rem 0 1rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .45rem; }
#status, #ocr-note { font-size: .9rem; }
#status:empty, #model-message:empty, #review p:empty, #issues:empty, .metric-details p:empty { display: none; }
#progress { width: min(25rem, 100%); accent-color: var(--accent); }
.page { padding: .85rem 0 0; }
.page p { white-space: pre-wrap; overflow-wrap: anywhere; }
.page details { margin-top: .35rem; color: var(--muted); font-size: .85rem; }
.page pre { max-height: 15rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.result-header { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.result-header span { color: var(--muted); font-size: .88rem; white-space: nowrap; }
#review, #ocr-note { margin-top: 1rem; }
.review-actions { display: flex; flex-wrap: wrap; gap: .65rem; }
#review-status, #needle-review { margin-top: .5rem; }
.metrics { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1rem; border-block: 1px solid var(--rule); padding: .55rem 0; font-size: .9rem; }
.metrics dl { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: .4rem 1.6rem; }
.metrics dl div { display: flex; gap: .5rem; }
.metrics dt, #run-state { color: var(--muted); }
.metric-details[open] { flex: 1 0 100%; }
.metric-details p { margin-top: .4rem; color: var(--muted); }
.models { margin-top: 1.4rem; padding-top: .55rem; border-top: 1px solid var(--rule); }
.model-list { padding: 0; list-style: none; }
.model-list li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(9rem, 20%) auto; align-items: center; gap: .65rem; border-bottom: 1px solid var(--rule); padding: .35rem 0; }
.model-list button { min-width: 6rem; }
.model-state { color: var(--muted); }
#model-message { margin-top: .5rem; font-size: .9rem; }
footer { margin: 0 clamp(1rem, 2.6vw, 3rem); border-top: 1px solid var(--rule); padding: .7rem 0 1.5rem; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: .5rem 1.5rem; font-size: .85rem; }
footer nav { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
@media (max-width: 48rem) {
  .runtime-actions { width: 100%; margin-inline-start: 0; }
  .output { min-height: 13rem; }
}
@media (max-width: 32rem) {
  :root { font-size: 14px; }
  main > nav { gap: .25rem; }
  main > nav button { padding-inline: .35rem; }
  .file-name { min-width: 0; }
  .samples, .input-end { margin-inline-start: 0; }
  .samples div { inset-inline: 0 auto; }
  .model-list li { grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .5rem; }
  .model-list button { grid-column: 2; grid-row: 1 / 3; }
  .model-state { grid-row: 2; font-size: .85rem; }
}
.model-state[data-loaded="true"]::before {
  content: "";
  display: inline-block;
  width: .55em;
  height: .55em;
  margin-inline-end: .55em;
  border-radius: 50%;
  background: #9ed28d;
  vertical-align: .1em;
}

.masthead h1 { display: flex; align-items: center; gap: .55rem; }
#guest-manual { margin-top: .6rem; }

.guest-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem .8rem; margin-top: .55rem; }
#guest-setup .guest-controls label { margin: 0; }
#guest-kernel { max-width: 100%; }
#guest-file-status[data-error="true"] { color: var(--error); }
