:root {
  --paper: #f6f1e7; --paper2: #efe7d8; --ink: #1d1b16; --muted: #6b6458; --rule: #d9cfbd;
  --accent: #8a2c1d; --accent2: #b4472f; --ok: #2f6b3a; --warn: #9a6b00; --bad: #a32020;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.55 var(--serif); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 22px; }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: .85em; background: var(--paper2); padding: 1px 4px; border-radius: 3px; }

.masthead { border-bottom: 3px double var(--ink); padding: 34px 0 18px; background: linear-gradient(var(--paper), var(--paper2)); }
.kicker { font-variant: small-caps; letter-spacing: .08em; color: var(--accent); margin: 0 0 4px; font-size: .95rem; }
h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); line-height: 1.05; margin: 0 0 10px; font-weight: 600; letter-spacing: -.01em; }
.dek { max-width: 760px; color: #3a362e; margin: 0 0 16px; }
.steps-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-variant: small-caps; letter-spacing: .05em; }
.steps-nav a { text-decoration: none; color: var(--ink); border-bottom: 1px solid transparent; }
.steps-nav a:hover { border-color: var(--accent); }

.panel { padding: 30px 0 26px; border-bottom: 1px solid var(--rule); }
h2 { font-size: 1.55rem; margin: 0 0 14px; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
h2 .num { font-family: var(--mono); font-size: .9rem; color: var(--paper); background: var(--ink); border-radius: 50%; width: 1.8em; height: 1.8em; display: inline-grid; place-items: center; flex: none; }
.lbl { display: block; font-variant: small-caps; letter-spacing: .05em; color: var(--muted); margin: 14px 0 5px; font-size: .95rem; }
input[type=text], input[type=password], input[type=number], textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: #fffdf8; border: 1px solid var(--rule); border-radius: 4px; padding: 8px 10px;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent2); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid3 label { font-size: .9rem; color: var(--muted); display: grid; gap: 4px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.row.small { margin-top: 6px; }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0; }
.empty { color: var(--muted); font-style: italic; }

.btn { font: inherit; font-size: .98rem; cursor: pointer; border-radius: 4px; padding: 8px 16px; background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.btn:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.btn.link { background: none; border: none; color: var(--accent); padding: 2px 4px; text-decoration: underline; text-underline-offset: 3px; }
.btn.link:hover:not(:disabled) { background: none; color: var(--accent2); }
.linkish { color: var(--accent); text-decoration: underline; cursor: pointer; }

.drop { border: 2px dashed var(--rule); border-radius: 6px; padding: 18px; text-align: center; background: #fffdf8; transition: .15s; }
.drop.over { border-color: var(--accent); background: #fbefe6; }
.drop p { margin: 2px 0; }
.sample { background: var(--paper2); border: 1px solid var(--rule); border-radius: 6px; padding: 14px 16px; margin-top: 14px; }
.sample p { margin: 4px 0; }
.booklist { margin: 10px 0 0; padding-left: 18px; font-size: .9rem; color: var(--muted); }
.store-status { border-left: 4px solid var(--rule); padding: 8px 12px; background: #fffdf8; margin-bottom: 6px; }
.store-status.ready { border-color: var(--ok); }
.store-status b { font-weight: 600; }

table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-variant: small-caps; letter-spacing: .04em; color: var(--muted); font-weight: 400; }
.docs { margin-top: 16px; }
.progress { color: var(--muted); font-size: .95rem; font-family: var(--mono); }
.bar { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; width: 220px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.qlist { columns: 2; column-gap: 34px; padding-left: 26px; margin: 0 0 6px; font-size: .95rem; }
.qlist li { break-inside: avoid; margin-bottom: 2px; }
@media (max-width: 760px) { .qlist { columns: 1; } }
.settings { margin-top: 12px; }
.settings summary { cursor: pointer; color: var(--muted); font-variant: small-caps; letter-spacing: .05em; }
.runsteps { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 14px; font-size: .88rem; }
.runsteps li { display: flex; gap: 6px; align-items: baseline; }
.runsteps .st { font-family: var(--mono); width: 1.3em; flex: none; }
.st.wait { color: var(--rule); } .st.busy { color: var(--accent); } .st.ok { color: var(--ok); } .st.nis { color: var(--warn); } .st.err { color: var(--bad); }

.story { background: #fffdf8; border: 1px solid var(--rule); padding: 30px 38px; border-radius: 2px; box-shadow: 0 1px 0 var(--rule), 0 8px 24px -18px rgba(0,0,0,.35); }
.story h3 { font-size: 1.9rem; margin: 0 0 16px; text-align: center; font-weight: 600; }
.story p { margin: 0 0 1em; text-align: justify; hyphens: auto; }
.story p:first-of-type::first-letter { float: left; font-size: 3.4em; line-height: .8; padding: 6px 8px 0 0; color: var(--accent); }
.story .skipped { font-size: .9rem; color: var(--muted); font-style: italic; border-top: 1px solid var(--rule); padding-top: 10px; }
@media (max-width: 760px) { .story { padding: 20px; } }
.sent.flag { text-decoration: underline wavy var(--bad); text-underline-offset: 4px; }
.sent.warn { text-decoration: underline dotted var(--warn); text-underline-offset: 4px; }
.cite { font-family: var(--mono); font-size: .62em; vertical-align: super; color: var(--accent); background: none; border: none; cursor: pointer; padding: 0 1px; }
.cite:hover { text-decoration: underline; }
.cite.bad { color: var(--bad); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { background: #fffdf8; border: 1px solid var(--rule); border-radius: 4px; padding: 10px 12px; }
.card .big { font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.card .sub { color: var(--muted); font-size: .85rem; }
.pass { color: var(--ok); font-weight: 600; } .fail { color: var(--bad); font-weight: 600; }
.flaglist li { margin-bottom: 8px; }
.flaglist .why { color: var(--muted); font-size: .88rem; }

.qlog { border: 1px solid var(--rule); border-radius: 4px; margin-bottom: 8px; background: #fffdf8; }
.qlog > summary { cursor: pointer; padding: 9px 12px; display: flex; gap: 10px; align-items: baseline; }
.qlog > summary .tag { font-family: var(--mono); font-size: .78rem; padding: 1px 6px; border-radius: 3px; background: var(--paper2); flex: none; }
.tag.answered { color: var(--ok); } .tag.not_in_sources { color: var(--warn); } .tag.error { color: var(--bad); }
.qlog .body { padding: 4px 14px 14px; font-size: .92rem; }
.qlog pre { white-space: pre-wrap; word-break: break-word; background: var(--paper2); padding: 10px; border-radius: 4px; font: .78rem/1.45 var(--mono); max-height: 420px; overflow: auto; }
.qlog h4 { margin: 12px 0 4px; font-variant: small-caps; letter-spacing: .05em; color: var(--muted); font-weight: 400; }
.qlog td.id { font-family: var(--mono); white-space: nowrap; }

.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(520px, 100vw); background: #fffdf8; border-left: 3px double var(--ink); box-shadow: -10px 0 30px -20px rgba(0,0,0,.5); padding: 26px 26px 40px; overflow: auto; transform: translateX(105%); transition: transform .2s ease; z-index: 10; }
.drawer.open { transform: none; }
.drawer h3 { font-family: var(--mono); margin: 0 0 10px; font-size: 1.1rem; }
.drawer .close { position: absolute; top: 10px; right: 14px; font-size: 1.8rem; background: none; border: none; cursor: pointer; color: var(--ink); }
.drawer mark { background: #f4dcae; }
.how ol { padding-left: 22px; } .how li { margin-bottom: 6px; }
.foot { color: var(--muted); font-size: .85rem; padding: 18px 22px 40px; }
