:root {
  --paper: #fbfaf7;
  --panel: #ffffff;
  --ink: #131316;
  --muted: #6b6a66;
  --line: #e3e0d8;
  --accent: #ff5a1f;
  --accent-ink: #b93a0c;
  --accent-wash: #fff1ea;
  --code-bg: #101014;
  --code-ink: #e9e7e1;
  --code-dim: #8b8a93;
  --ok: #1f8f4e;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Hanken Grotesk', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--paper);
  /* the dot grid: a quiet reminder this is a machine-facing product */
  background-image: radial-gradient(circle at 1px 1px, #dedbd2 1px, transparent 0);
  background-size: 24px 24px;
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
code, pre, kbd { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* --- nav --- */
.nav { position: sticky; top: 0; z-index: 10; background: rgba(251, 250, 247, 0.88); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.nav .wrap { display: flex; align-items: center; gap: 28px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 15px var(--mono); text-decoration: none; letter-spacing: -0.01em; }
.brand i { width: 14px; height: 14px; background: var(--accent); display: block; }
.nav nav { display: flex; gap: 22px; margin-left: auto; font: 500 13px var(--mono); }
.nav nav a { text-decoration: none; color: var(--muted); }
.nav nav a:hover, .nav nav a[aria-current] { color: var(--ink); }

/* --- type --- */
.tag { font: 500 12px var(--mono); color: var(--accent-ink); letter-spacing: 0.04em; text-transform: uppercase; }
.tag::before { content: '[ '; color: var(--muted); }
.tag::after { content: ' ]'; color: var(--muted); }
h1 { font: 700 clamp(40px, 6.4vw, 76px)/0.98 var(--sans); letter-spacing: -0.045em; margin: 18px 0 20px; }
h1 em { font-style: normal; color: var(--accent); }
h2 { font: 700 clamp(26px, 3.4vw, 38px)/1.1 var(--sans); letter-spacing: -0.03em; margin: 12px 0 14px; }
h3 { font: 600 17px var(--sans); letter-spacing: -0.01em; margin: 0 0 6px; }
.lede { font-size: 19px; color: var(--muted); max-width: 54ch; margin: 0 0 28px; }
section { padding: 88px 0; border-top: 1px solid var(--line); }
section.hero { border-top: 0; padding: 72px 0 80px; }

/* --- buttons and inputs --- */
.btn { display: inline-flex; align-items: center; gap: 8px; font: 600 14px var(--mono); padding: 11px 18px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); text-decoration: none; cursor: pointer; transition: transform 0.12s, box-shadow 0.12s; }
.btn:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--accent); }
.btn.ghost { background: var(--panel); color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
input[type='text'], textarea { width: 100%; font: 15px var(--mono); padding: 12px 14px; border: 1px solid var(--ink); background: var(--panel); color: var(--ink); border-radius: 0; }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
::placeholder { color: #a3a19a; }

/* --- code panels --- */
.term { background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--ink); box-shadow: 8px 8px 0 var(--line); min-width: 0; }
.term header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #26262c; font: 12px var(--mono); color: var(--code-dim); }
.term header b { color: var(--accent); font-weight: 500; }
.term header span { margin-left: auto; }
.term pre { margin: 0; padding: 16px 18px; font-size: 13px; line-height: 1.65; overflow-x: auto; white-space: pre; }
.term pre.wrapping { white-space: pre-wrap; word-break: break-word; }
.k { color: #ffb38a; } .s { color: #b9e4c0; } .n { color: #9cc7ff; } .c { color: var(--code-dim); }
p code, li code, td code { font-size: 0.88em; background: #f0eee8; padding: 2px 5px; border: 1px solid var(--line); }

/* --- hero --- */
.try { display: flex; gap: 0; margin-bottom: 0; }
.try input { border-right: 0; }
.try .btn { white-space: nowrap; }
.hints { font: 12px var(--mono); color: var(--muted); margin: 10px 0 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { font: 12px var(--mono); padding: 4px 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.rise { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.rise:nth-child(2) { animation-delay: 0.07s; } .rise:nth-child(3) { animation-delay: 0.14s; } .rise:nth-child(4) { animation-delay: 0.21s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* --- grids --- */
.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--ink); background: var(--panel); margin-top: 36px; }
.cols > div { padding: 26px 24px 28px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cols > div:nth-child(3n) { border-right: 0; }
.cols > div:nth-last-child(-n + 3) { border-bottom: 0; }
.cols .num { font: 500 12px var(--mono); color: var(--accent-ink); display: block; margin-bottom: 14px; }
.cols p { margin: 0; color: var(--muted); font-size: 15px; }
.split { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 48px; align-items: start; }

/* --- the EPUB bench --- */
.bench { border: 1px solid var(--ink); background: var(--panel); margin-top: 32px; box-shadow: 8px 8px 0 var(--line); }
.drop { display: block; padding: 44px 24px; text-align: center; border-bottom: 1px solid var(--line); cursor: pointer; font: 14px var(--mono); color: var(--muted); transition: background 0.15s; }
.drop:hover, .drop.over { background: var(--accent-wash); color: var(--accent-ink); }
.drop b { display: block; font: 600 18px var(--sans); color: var(--ink); margin-bottom: 6px; }
.drop input { position: absolute; opacity: 0; pointer-events: none; }
.bench-body { padding: 24px; display: none; }
.bench-body.on { display: block; }
.found { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 20px; }
.found img { width: 72px; height: 108px; object-fit: cover; border: 1px solid var(--line); background: #eee; flex: none; }
.found p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--ink); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
td.field { font: 500 13px var(--mono); white-space: nowrap; }
.was { color: var(--muted); text-decoration: line-through; text-decoration-color: #c9c6bd; }
.pill { font: 500 11px var(--mono); padding: 2px 7px; border: 1px solid currentColor; white-space: nowrap; }
.pill.missing, .pill.low_resolution { color: var(--accent-ink); background: var(--accent-wash); }
.pill.differs { color: #7a5b00; background: #fff7d6; }
.pill.unfixed { color: var(--muted); }
.notes { margin: 16px 0 0; padding: 12px 14px; background: #f4f2ec; border-left: 3px solid var(--accent); font-size: 14px; }
.notes p { margin: 0 0 4px; } .notes p:last-child { margin: 0; }
.tell { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.tell label { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); display: block; margin-bottom: 8px; }
.actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.status { font: 13px var(--mono); color: var(--muted); }
.status.err { color: #b3261e; } .status.ok { color: var(--ok); }

footer { border-top: 1px solid var(--ink); padding: 28px 0 40px; font: 13px var(--mono); color: var(--muted); }
footer .wrap { display: flex; gap: 20px; flex-wrap: wrap; }
footer a { margin-left: auto; }

/* --- docs --- */
.docs { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 56px; padding-top: 48px; padding-bottom: 96px; }
.docs aside { position: sticky; top: 80px; align-self: start; font: 13px var(--mono); }
.docs aside a { display: block; padding: 5px 0; color: var(--muted); text-decoration: none; }
.docs aside a:hover { color: var(--accent-ink); }
.docs aside b { display: block; margin: 18px 0 6px; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink); }
.docs aside b:first-child { margin-top: 0; }
.docs article > h1 { font-size: clamp(34px, 4.6vw, 52px); margin-top: 10px; }
.docs article h2 { margin-top: 64px; padding-top: 28px; border-top: 1px solid var(--line); font-size: 26px; }
.docs article h3 { margin-top: 28px; }
.docs article p, .docs article li { max-width: 68ch; }
.docs .term { margin: 16px 0 22px; box-shadow: 6px 6px 0 var(--line); }
.route { font: 500 15px var(--mono); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; }
.verb { font: 600 11px var(--mono); padding: 3px 8px; background: var(--ink); color: var(--paper); }
.verb.post { background: var(--accent); color: #fff; }
.docs table { margin: 14px 0 22px; background: var(--panel); border: 1px solid var(--line); }
.docs th { background: #f4f2ec; }

@media (max-width: 860px) {
  .split, .docs { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .cols > div { border-right: 0 !important; border-bottom: 1px solid var(--line) !important; }
  .cols > div:last-child { border-bottom: 0 !important; }
  .docs aside { position: static; columns: 2; }
  .nav nav { gap: 14px; }
  .nav nav .wide { display: none; }
  section { padding: 64px 0; }
  .wrap { padding: 0 16px; }
  .try { flex-direction: column; } .try input { border-right: 1px solid var(--ink); border-bottom: 0; }
  td.field { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { .rise { animation: none; } .btn { transition: none; } html { scroll-behavior: auto; } }

/* --- landing page --- */
/* The ASCII field is the hero's picture; copy and controls sit on solid blocks. */
.landing { background: var(--paper); }
.landing .nav { background: rgba(251, 250, 247, .94); }
.landing .nav nav { gap: 0; align-self: stretch; }
.landing .nav nav a { display: flex; align-items: center; padding: 0 18px; border-left: 1px solid var(--line); transition: background 0.12s, color 0.12s; }
.landing .nav nav a:hover { background: var(--accent); color: var(--ink); }
.landing h2 { text-wrap: balance; }
.landing .lede { color: var(--ink); }
.landing .hints, .landing .chip { font-size: 13px; }
.landing .chip { min-height: 34px; }
.landing .term header { flex-wrap: wrap; overflow-wrap: anywhere; }
.landing section { border-top: 0; }
.landing #fix, .landing #api { background: #f0eee8; }
.landing footer { background: var(--paper); }

.landing .hero { position: relative; isolation: isolate; overflow: hidden; padding: 96px 0 80px; text-align: center; }
.hero canvas.ascii { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.landing h1 { font-size: clamp(36px, 6.2vw, 84px); line-height: 1.14; margin: 0 0 28px; }
.landing h1 span { background: var(--accent); padding: 0 0.16em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.landing .hero .lede { margin: 0 auto 32px; max-width: 50ch; }
.landing .hero .lede span { background: var(--paper); padding: 3px 6px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.landing .hero .try { max-width: 640px; margin: 0 auto; box-shadow: 8px 8px 0 var(--ink); }
.landing .hero .hints { justify-content: center; margin-top: 22px; }

/* the lookup's answer: the cover in characters, the record typeset, the raw JSON */
.console { display: grid; grid-template-columns: 240px minmax(0, 1fr) minmax(0, 1.1fr); margin-top: 56px; text-align: left; border: 1px solid var(--ink); background: var(--panel); box-shadow: 8px 8px 0 var(--line); }
.cover-art { position: relative; background: var(--code-bg); min-height: 360px; cursor: crosshair; }
.cover-art img, .cover-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-art img:not([src]) { visibility: hidden; }
.cover-art canvas { background: var(--code-bg); transition: opacity 0.25s; }
.cover-art:hover canvas, .cover-art:focus canvas { opacity: 0; }
.cover-art small { position: absolute; left: 0; bottom: 0; font: 11px var(--mono); padding: 3px 7px; background: var(--code-bg); color: var(--code-dim); }
.record { padding: 22px 24px; border-right: 1px solid var(--line); min-width: 0; }
.record h3 { font-size: 24px; letter-spacing: -0.02em; margin: 0; }
.record > p { margin: 2px 0 16px; color: var(--muted); }
.record dl { margin: 0; font: 13px/1.5 var(--mono); }
.record dl div { display: grid; grid-template-columns: 104px minmax(0, 1fr); padding: 7px 0; border-top: 1px solid var(--line); }
.record dt, .record dd.none { color: var(--muted); }
.record dd { margin: 0; overflow-wrap: anywhere; }
.console .term { border: 0; box-shadow: none; }
/* still scrolls; the bar itself is hidden */
.console .term pre { height: 318px; overflow: auto; white-space: pre-wrap; word-break: break-word; scrollbar-width: none; }
.console .term pre::-webkit-scrollbar { display: none; }

/* a rule drawn with the glyph ramp */
.rule { overflow: hidden; white-space: nowrap; font: 12px/1 var(--mono); color: #b9b5aa; letter-spacing: 2px; margin: 0; user-select: none; }
.rule::before { content: ' .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,. .,:;=+*#%@%#*+=;:,.'; }

/* record fields: cells that fill from the bottom on hover */
.landing .cols > div { background: linear-gradient(var(--ink), var(--ink)) no-repeat bottom / 100% 0; transition: background-size 0.22s, color 0.22s; }
.landing .cols > div:hover { background-size: 100% 100%; color: var(--paper); }
.landing .cols > div:hover p, .landing .cols > div:hover .num { color: var(--code-dim); }
.landing .cols code { display: block; margin-top: 14px; font-size: 12px; color: var(--accent-ink); overflow-wrap: anywhere; }
.landing .cols > div:hover code { color: var(--accent); }

.landing .drop input { width: 1px; height: 1px; }
.landing .drop:focus-within { outline: 2px solid var(--accent-ink); outline-offset: -4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 860px) {
  .landing .hero { padding: 56px 0 48px; }
  .landing .nav nav a { padding: 0 12px; }
  .console { grid-template-columns: minmax(0, 1fr); }
  .cover-art { height: 360px; }
  .cover-art img, .cover-art canvas { inset: 0 auto 0 50%; width: 240px; transform: translateX(-50%); }
  .record { border-right: 0; border-bottom: 1px solid var(--line); }
  .landing .term pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  .landing .bench-body { padding: 16px; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .landing .btn:hover:not(:disabled) { transform: none; }
  .landing .cols > div, .cover-art canvas { transition: none; }
}

/* EPUB queue: one review card, with paging and batch actions. */
.queue-toolbar { padding: 20px 24px; background: var(--paper); }
.queue-toolbar p { margin: 0; }
.queue-toolbar .actions { margin: 12px 0; }
.queue-hint, #zip-status { font-size: 14px; color: var(--muted); }
#zip-status:not(:empty) { margin-top: 12px; }
.queue-nav { display: flex; align-items: center; gap: 12px; padding: 20px 24px 0; }
.queue-heading { flex: 1; min-width: 0; }
.queue-heading span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
#queue-filename { font-size: 15px; overflow-wrap: anywhere; }
.queue-remove { width: 44px; height: 44px; flex: none; border: 0; background: var(--paper); color: var(--ink); font: 28px var(--sans); cursor: pointer; }
.queue-remove:hover { background: var(--accent-wash); color: var(--accent-ink); }
.queue-card { min-height: 110px; }
.queue-card td.field { min-width: 72px; }
[hidden] { display: none !important; }
@media (max-width: 600px) {
  .queue-toolbar { padding: 16px; }
  .queue-nav { gap: 6px; padding: 16px 12px 0; }
  .queue-nav .btn { padding: 10px; }
  .queue-toolbar .btn { font-size: 13px; }
}

/* --- find a book (landing page's closing block) --- */
/* the page's dot grid, redrawn light-on-dark; the heading is drawn in glyphs by ascii.js */
.landing .find-book { background: var(--code-bg) radial-gradient(circle at 1px 1px, #2e2e38 1px, transparent 0) 0 0 / 24px 24px; color: var(--code-ink); text-align: center; padding: 120px 0 128px; border-top: 0; }
.find-book canvas { display: block; width: 100%; height: clamp(96px, 17vw, 200px); margin: 0 0 18px; }
.find-book .eyebrow { font: 500 12px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin: 0 0 18px; }
.landing .find-book h2 { font-size: clamp(40px, 6vw, 76px); line-height: 1; letter-spacing: -0.03em; margin: 0 0 18px; color: #fff; }
.landing .find-book .lede { color: var(--code-dim); margin: 0 auto 40px; max-width: 60ch; text-wrap: balance; }
.find-book .try { max-width: 760px; margin: 0 auto; box-shadow: 8px 8px 0 #2c2c36; }
.find-book .try input { font-size: 18px; padding: 20px 22px; border-color: #fff; background: #fff; }
.find-book .try input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.find-book .try .btn { font-size: 16px; padding: 0 32px; background: var(--accent); border-color: var(--accent); color: #fff; justify-content: center; }
.find-book .try .btn:hover:not(:disabled) { transform: none; box-shadow: none; background: var(--accent-ink); border-color: var(--accent-ink); }
.find-book .hints { justify-content: center; margin: 36px 0 0; color: var(--code-dim); }
.landing .find-book .chip { display: inline-flex; align-items: center; text-decoration: none; background: transparent; border-color: #3a3a44; color: var(--code-ink); }
.landing .find-book .chip:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 860px) {
  .landing .find-book { padding: 80px 0 88px; }
  .find-book .try { box-shadow: 5px 5px 0 #2c2c36; }
  .find-book .try input { border-right: 1px solid #fff; }
  .find-book .try .btn { padding: 16px; }
}

/* A search under way */
.try.working { position: relative; overflow: hidden; }
.try.working .btn { cursor: progress; }
.try.working::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: 30%; background: var(--accent); animation: working 1s linear infinite; }
.find-book .try.working::after { background: var(--code-bg); }
.working-note { margin: 14px 0 0; }
.find-book .working-note { color: var(--code-dim); margin-top: 22px; }
@keyframes working { from { transform: translateX(-100%); } to { transform: translateX(334%); } }
@media (prefers-reduced-motion: reduce) { .try.working::after { animation: none; width: 100%; } }
