:root {
  --bg: #14131f;
  --panel: #1c1a2b;
  --panel2: #232135;
  --ink: #f2efe6;
  --muted: #a7a2bb;
  --line: #322f47;
  --accent: #c9a227;
  --accent2: #e6c15a;
  --warn: #e0a34a;
  --bad: #e0685f;
  --good: #79b98a;
  --radius: 12px;
  --maxw: 900px;
}

:root[data-theme="light"] {
  --bg: #faf8f2;
  --panel: #ffffff;
  --panel2: #f3f0e7;
  --ink: #1f1d2b;
  --muted: #5f5b72;
  --line: #e0dccf;
  --accent: #8a6d10;
  --accent2: #a8851d;
  --warn: #8a5b12;
  --bad: #a33b33;
  --good: #326f45;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

h1, h2, h3, h4, legend, .brand, button, input, select, textarea, .chip, .credits {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 .6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 0 0 .5rem; }
h3 { font-size: 1.02rem; margin: 0 0 .5rem; letter-spacing: .01em; }
h4 { font-size: .95rem; margin: .8rem 0 .3rem; }
p { margin: 0 0 .8rem; }

a { color: var(--accent2); }
a:hover { color: var(--accent); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.sep { color: var(--muted); margin: 0 .4rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .2rem; font-size: .95rem; }
.backlink { text-decoration: none; color: var(--muted); }
.topactions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.credits { font-size: .85rem; color: var(--muted); }
.topup { font-size: .85rem; text-decoration: none; }

main { max-width: var(--maxw); margin: 0 auto; padding: 1.4rem 1rem 3rem; }

button {
  font-size: .92rem; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #14131f; border-color: var(--accent); font-weight: 600; }
:root[data-theme="light"] button.primary { color: #fff; }
button.big { padding: .7rem 1.2rem; font-size: 1rem; }
button.ghost { background: transparent; }
button.small { padding: .3rem .6rem; font-size: .82rem; }

input[type="text"], input[type="search"], textarea, select {
  width: 100%; padding: .55rem .7rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: .95rem;
}
textarea { resize: vertical; line-height: 1.55; font-family: ui-serif, Georgia, serif; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.hero { margin-bottom: 1.6rem; }
.lede { font-size: 1.06rem; color: var(--ink); max-width: 62ch; }
.herobtns { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 .5rem; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1.2rem;
}
fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; }
legend { font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 0 .4rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.col { display: block; }
.field { flex: 1 1 220px; display: block; }
.field.wide { flex: 1 1 100%; }
.field > span { display: block; font-size: .84rem; color: var(--muted); margin-bottom: .25rem; }
.field em { font-style: normal; opacity: .7; }
.blurb { flex: 1 1 100%; margin: .3rem 0 0; }
.checkline { display: flex; gap: .6rem; align-items: flex-start; margin-top: .8rem; font-size: .88rem; }
.checkline input { width: auto; margin-top: .3rem; }
.checkline em { display: block; font-style: normal; color: var(--muted); font-size: .84rem; margin-top: .2rem; }

.prescan { margin-top: .7rem; padding: .8rem; background: var(--panel2); border-radius: 8px; border: 1px solid var(--line); }
.prescan-head { font-weight: 600; margin-bottom: .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.chip {
  font-size: .78rem; padding: .18rem .5rem; border-radius: 99px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
}
.chip-name { border-color: var(--accent); color: var(--accent2); }
.chip-said { border-color: var(--good); color: var(--good); }
.chip-time, .chip-place { border-color: var(--line); }
.asks summary { cursor: pointer; font-size: .88rem; color: var(--muted); }
.asks ul { margin: .4rem 0 0; padding-left: 1.2rem; font-size: .88rem; color: var(--muted); }

.guardzone:empty { display: none; }
.guardblock {
  border: 1px solid var(--bad); border-left-width: 4px; border-radius: 8px;
  padding: .8rem; margin-bottom: .6rem; background: var(--panel2);
}
.guardblock h4 { margin-top: 0; color: var(--bad); }

.runrow { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.meter { font-size: .88rem; color: var(--muted); }

.progress { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.2rem; }
.progresshead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { padding: .25rem 0 .25rem 1.5rem; position: relative; color: var(--muted); font-size: .92rem; }
.steps li::before { content: "\25CB"; position: absolute; left: 0; }
.steps li.on { color: var(--ink); }
.steps li.on::before { content: "\25D0"; color: var(--accent); }
.steps li.done::before { content: "\25CF"; color: var(--good); }

.results { display: block; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem;
}
.card:empty { display: none; }
.card.error { border-color: var(--bad); }

.piecehead { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .8rem; }
.piecetitle { font-size: 1.35rem; margin: 0; }
.piecebody p {
  font-size: 1.12rem; line-height: 1.75; margin: 0 0 1rem; max-width: 60ch;
}
.piecebody.kind-vows p, .piecebody.kind-reading p { font-size: 1.16rem; }

.checks .reading { font-size: 1.06rem; font-weight: 600; }
.checks .reading.thin { color: var(--muted); font-weight: 500; }
.checks details { margin-top: .6rem; }
.checks summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.checks details.quiet summary { color: var(--good); }
.checks ul.floating li { color: var(--muted); font-size: .92rem; }
.warn { border: 1px solid var(--warn); border-left-width: 4px; border-radius: 8px; padding: .7rem; margin-top: .8rem; }
.warn h4 { margin-top: 0; color: var(--warn); }
.warn.hard { border-color: var(--bad); }
.warn.hard h4 { color: var(--bad); }
.frame { border-top: 1px solid var(--line); padding-top: .5rem; margin-top: .5rem; }
.frame-label { font-weight: 600; margin-bottom: .2rem; }
.frame-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; color: var(--muted); }

.alt { border-left: 3px solid var(--line); padding-left: .8rem; margin-bottom: .8rem; }
.alt-from { color: var(--muted); text-decoration: line-through; margin-bottom: .2rem; }
.alt-to { margin-bottom: .2rem; }

.declined { border-color: var(--warn); }
.declined .offer { color: var(--accent2); }

li.unsupported { color: var(--warn); }
.flag { font-size: .82rem; color: var(--warn); font-style: italic; }

.exports .btnrow, .btnrow { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .5rem; }
.revise textarea { margin-bottom: .6rem; }

.history .btnrow input { flex: 1 1 240px; }
.historylist { margin-top: .6rem; }
.hrow { border-top: 1px solid var(--line); padding: .6rem 0; display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; }
.hhead { flex: 1 1 auto; }

.prose p { max-width: 68ch; }

.foot { border-top: 1px solid var(--line); padding: 1rem; text-align: center; color: var(--muted); font-size: .88rem; }

/* api.html */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .5rem; }
.tabs button.active { border-color: var(--accent); color: var(--accent2); }
pre {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: .8rem; overflow-x: auto; font-size: .84rem; line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: .4rem .6rem; text-align: left; vertical-align: top; }
th { background: var(--panel2); }

.tokenline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.tokenbox { font-family: ui-monospace, Menlo, monospace; font-size: .84rem; word-break: break-all; }

@media (max-width: 620px) {
  h1 { font-size: 1.5rem; }
  .piecebody p { font-size: 1.05rem; }
  .row { flex-direction: column; align-items: stretch; }
  .field { flex: 1 1 auto; }
}

.notezone:empty { display: none; }
.notezone .note {
  border: 1px solid var(--warn); border-left-width: 4px; border-radius: 8px;
  padding: .7rem; margin-bottom: .6rem; background: var(--panel2); font-size: .9rem;
}
