:root {
  color-scheme: light;
  --paper: #faf6ea;
  --surface: #fffcf4;
  --ink: #1b2c25;
  --muted: #526358;
  --line: #b6b9a2;
  --forest: #244538;
  --copper: #a44025;
  --mono: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.53 Verdana, "Trebuchet MS", sans-serif; }
main { max-width: 78rem; padding: clamp(0.75rem, 3vw, 2.5rem); margin: auto; }
a { color: var(--forest); text-underline-offset: 0.25em; font-weight: 650; }
:focus-visible { outline: 3px solid var(--copper); outline-offset: 3px; }
h1, h2, h3, .ordinal { font-family: Georgia, "Times New Roman", serif; }

.banner { margin: 0 0 clamp(0.75rem, 2vw, 1.25rem); }
.banner img {
  display: block; width: 480px; max-width: 92%; height: auto; margin: 0 auto;
  border: 1px solid var(--line); border-radius: 12px;
}

.masthead {
  position: relative; isolation: isolate; overflow: hidden;
  padding: clamp(1.3rem, 4vw, 3rem);
  border-block: 1px solid var(--line);
}
.masthead::after {
  content: ""; position: absolute; z-index: -1; inset: 0 0 0 auto; width: 44%;
  background: radial-gradient(circle, #748572 0.85px, transparent 1px) 0 0 / 10px 10px;
  mask-image: linear-gradient(90deg, transparent, black); opacity: 0.5;
}
.result-meta, .section-num {
  color: var(--muted); font: 0.75rem/1.55 var(--mono); text-transform: uppercase; letter-spacing: 0.08em;
}
.masthead h1 { font-size: clamp(3.55rem, 9.5vw, 7.25rem); line-height: 0.98; letter-spacing: -0.07em; margin: 0.12em 0; }
.masthead h1 span, .formula span { color: var(--copper); }
.lede { max-width: 33rem; font-size: 1.06rem; margin: 0.9rem 0 1.1rem; }
.masthead nav { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.85rem; }

.bench { display: grid; grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.5fr); gap: 1rem; margin-top: 1rem; align-items: start; }
.panel { min-width: 0; padding: clamp(0.9rem, 2.4vw, 1.6rem); border: 1px solid var(--line); background: var(--surface); }
.panel h2 { font-size: 1.75rem; line-height: 1.06; margin: 0 0 1rem; }
.section-num { display: inline-block; color: var(--copper); font-weight: 700; vertical-align: middle; margin-right: 0.25em; }
label { font-size: 0.8rem; font-weight: 700; display: block; margin-top: 0.85rem; }
textarea, select, button { font: inherit; color: inherit; }
select, textarea { width: 100%; margin-top: 0.32rem; padding: 0.65rem; background: var(--surface); border: 1px solid var(--line); border-radius: 0.2rem; }
textarea { resize: vertical; }
summary { cursor: pointer; font-weight: 650; }
.inputs details { margin: 0.8rem 0; padding: 0.6rem 0; border-block: 1px solid var(--line); }
#corpus { font-size: 0.86rem; }
.note, footer { font-size: 0.8rem; color: var(--muted); }
button { cursor: pointer; }
button:disabled { opacity: 0.72; cursor: not-allowed; }
.primary { display: flex; justify-content: space-between; gap: 1rem; width: 100%; padding: 0.65rem 0.85rem; border: 1px solid var(--forest); background: var(--forest); color: white; font-weight: 650; border-radius: 0.2rem; }
.primary:hover:not(:disabled) { background: #19392d; }
.quiet { background: transparent; padding: 0.22rem 0.38rem; border: 1px solid var(--line); border-radius: 0.2rem; color: var(--forest); font-size: 0.72rem; }
.quiet:hover { border-color: var(--forest); }

#status { color: var(--muted); font-size: 0.88rem; }
#status.error { color: var(--copper); }
progress { width: 100%; accent-color: var(--forest); }
.results { list-style: none; margin: 0; padding: 0; }
.result { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.75rem; align-items: start; padding: 0.85rem 0.65rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.result.lead { border-inline-start: 4px solid var(--copper); background: #f3eddb; }
.result p { margin: 0.2rem 0 0; }
.ordinal { font-size: 1.45rem; line-height: 1.2; color: var(--forest); }
.result-aside { text-align: right; display: grid; gap: 0.38rem; justify-items: end; }
.score { color: var(--forest); font: 700 1rem/1.5 var(--mono); }
.walkthrough { background: var(--paper); margin-top: 0.85rem; padding: 0.9rem; border: 1px solid var(--line); overflow-wrap: anywhere; }
.walkthrough h3 { margin-bottom: 0.3rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.legend { margin-bottom: 0.7rem; }
.token { font: 0.76rem/1.5 var(--mono); color: var(--ink); padding: 0.1rem 0.3rem; border: 1px solid transparent; border-radius: 3px; }
.token.query { background: #d6e5d6; border-color: #9faf9e; }
.token.passage { background: #f0dfc8; border-color: #c4a386; }
.token.special { background: #e6e5df; border-color: #b5b4ac; }
.formula { font: 700 0.93rem/1.5 var(--mono); }
footer { margin-top: 1.25rem; }

@media (max-width: 780px) { .bench { grid-template-columns: 1fr; } }
@media (max-width: 430px) {
  .result { grid-template-columns: auto minmax(0, 1fr); gap: 0.5rem; }
  .result-aside { grid-column: 2; display: flex; align-items: center; gap: 0.65rem; }
}
