/* Slophistry — minimalist editorial reader */
:root {
  --paper: #f6f3ec;
  --paper-deep: #efebe0;
  --ink: #211d17;
  --ink-soft: #57503f;
  --muted: #8d8471;
  --hairline: #ddd6c6;
  --accent: #7c2d24;
  --accent-soft: #a4544a;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--paper); color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}
::selection { background: #e8d3b8; }

.frame { display: flex; min-height: 100vh; }

/* ---------- left rail ---------- */
#rail {
  width: 292px; flex: 0 0 292px;
  border-right: 1px solid var(--hairline);
  background: var(--paper);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.masthead { padding: 30px 26px 18px; }
.wordmark {
  font-family: var(--sans); font-weight: 700; font-size: 19px;
  letter-spacing: .34em; text-decoration: none; color: var(--ink);
}
.wordmark::first-letter { color: var(--accent); }
.tagline {
  margin: 7px 0 0; font-style: italic; font-size: 12.5px; color: var(--muted); line-height: 1.5;
}
#index { flex: 1; overflow-y: auto; padding: 6px 0 12px; scrollbar-width: thin; }

.toc-item {
  display: block; padding: 11px 26px 11px 22px;
  text-decoration: none; color: inherit;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.toc-item:hover { background: var(--paper-deep); }
.toc-item.active { border-left-color: var(--accent); background: var(--paper-deep); }
.toc-num {
  font-family: var(--sans); font-size: 10px; letter-spacing: .22em;
  color: var(--accent-soft); text-transform: uppercase;
}
.toc-title { font-size: 15px; line-height: 1.35; margin-top: 2px; }
.toc-meta { font-family: var(--sans); font-size: 11px; color: var(--muted); margin-top: 3px; }
.toc-form { color: var(--accent-soft); letter-spacing: .08em; text-transform: uppercase; font-size: 10px; }
.toc-empty { padding: 14px 26px; font-style: italic; color: var(--muted); font-size: 14px; }

.rail-foot { padding: 16px 26px 22px; border-top: 1px solid var(--hairline); }
.mill-note { font-family: var(--sans); font-size: 10.5px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }

/* ---------- buttons ---------- */
button {
  font-family: var(--sans); font-size: 12px; letter-spacing: .06em;
  padding: 9px 16px; cursor: pointer;
  background: transparent; color: var(--ink);
  border: 1px solid var(--ink); border-radius: 2px;
  transition: background .15s, color .15s;
}
button:hover { background: var(--ink); color: var(--paper); }
button.ghost { border-color: var(--hairline); color: var(--ink-soft); }
button.ghost:hover { background: transparent; border-color: var(--ink); color: var(--ink); }
button:disabled { opacity: .45; cursor: wait; }

/* ---------- reading column ---------- */
#page { flex: 1; min-width: 0; }
#reader { max-width: 70ch; margin: 0 auto; padding: 64px 48px 140px; }

.kicker {
  font-family: var(--sans); font-size: 10.5px; letter-spacing: .24em;
  text-transform: uppercase; color: var(--muted);
  display: flex; gap: 14px; flex-wrap: wrap;
}
.kicker .form-chip { color: var(--accent); }
h1.title {
  font-size: clamp(30px, 4vw, 42px); line-height: 1.12;
  font-weight: 500; margin: 18px 0 10px; letter-spacing: -.01em;
}
.byline { font-style: italic; font-size: 16px; color: var(--ink-soft); margin: 0; }
.byline b { font-style: normal; font-weight: 600; }
.responds {
  font-family: var(--sans); font-size: 12.5px; color: var(--muted);
  margin: 20px 0 0; line-height: 1.7;
}
.responds a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent-soft); }
.responds a:hover { border-bottom-style: solid; }
.rule { border: 0; border-top: 1px solid var(--hairline); margin: 34px 0 0; }

/* ---------- body typography ---------- */
.body { margin-top: 34px; font-size: 17.5px; line-height: 1.72; }
.body p { margin: 0 0 1.15em; }
.body h2, .body h3, .body h4 {
  font-weight: 600; line-height: 1.25; letter-spacing: -.005em; margin: 1.9em 0 .7em;
}
.body h2 { font-size: 26px; } .body h3 { font-size: 21px; } .body h4 { font-size: 18px; }
.body blockquote {
  margin: 1.4em 0; padding: 2px 0 2px 22px;
  border-left: 2px solid var(--accent-soft);
  font-style: italic; color: var(--ink-soft);
}
.body blockquote p { margin-bottom: .5em; }
.body hr { border: 0; text-align: center; margin: 2.2em 0; }
.body hr::after { content: "§"; color: var(--accent-soft); font-size: 15px; }
.body code { font-family: var(--mono); font-size: .82em; background: var(--paper-deep); padding: 2px 5px; border-radius: 2px; }
.body ul, .body ol { padding-left: 1.4em; margin: 0 0 1.15em; }
.body li { margin-bottom: .35em; }
.body a { color: var(--accent); }

p.speech { margin-bottom: 1.05em; }
p.speech .speaker {
  font-family: var(--sans); font-size: 12px; font-weight: 700;
  letter-spacing: .18em; color: var(--accent);
}
p.stage { font-style: italic; color: var(--muted); font-size: 15.5px; margin: .9em 0 1.2em; }
.dropcap::first-letter {
  float: left; font-size: 3.35em; line-height: .84;
  padding: .06em .09em 0 0; color: var(--accent); font-weight: 600;
}

/* ---------- marginalia ---------- */
.marginalia { margin-top: 76px; }
.marginalia h2 {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: .28em; text-transform: uppercase; color: var(--ink-soft);
}
.comment { padding: 18px 0 4px; border-top: 1px solid var(--hairline); }
.comment-head { font-family: var(--sans); font-size: 12px; color: var(--muted); }
.comment-head b { color: var(--accent); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; }
.comment-body { margin: 7px 0 14px; font-size: 16px; line-height: 1.6; white-space: pre-wrap; }
.no-comments { font-style: italic; color: var(--muted); padding: 14px 0; border-top: 1px solid var(--hairline); }

.cform { margin-top: 26px; }
.cform textarea, .cform input {
  width: 100%; background: transparent; color: var(--ink);
  border: 0; border-bottom: 1px solid var(--hairline);
  font-family: var(--serif); font-size: 16px; padding: 8px 2px;
  resize: vertical;
}
.cform textarea:focus, .cform input:focus { outline: none; border-bottom-color: var(--accent); }
.cform-row { display: flex; gap: 18px; align-items: baseline; margin-bottom: 6px; }
.cform-row input { max-width: 260px; }
.cform-actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 10px; }
.cform textarea { min-height: 74px; }

/* ---------- empty state ---------- */
.empty-state { padding-top: 40px; }
.empty-state p { font-size: 18px; font-style: italic; color: var(--ink-soft); }

/* ---------- commission dialog ---------- */
dialog {
  border: 1px solid var(--hairline); border-radius: 3px;
  background: var(--paper); color: var(--ink);
  padding: 30px 32px; width: min(560px, calc(100vw - 48px));
  box-shadow: 0 24px 80px rgba(33, 29, 23, .28);
}
dialog::backdrop { background: rgba(33, 29, 23, .45); }
dialog h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0 0 6px; }
.dlg-note { font-family: var(--sans); font-size: 12.5px; color: var(--muted); margin: 0 0 22px; line-height: 1.55; }
.field { display: block; margin-bottom: 18px; border: 0; padding: 0; }
.field > span {
  display: block; font-family: var(--sans); font-size: 10.5px; font-weight: 700;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 7px;
}
.field em { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; }
.field select, .field input[type="text"], .field textarea {
  width: 100%; background: transparent; border: 1px solid var(--hairline);
  border-radius: 2px; padding: 9px 10px; font-family: var(--serif);
  font-size: 15px; color: var(--ink);
}
.field select:focus, .field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
#cReact { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
#cReact label {
  font-family: var(--sans); font-size: 13px; color: var(--ink-soft);
  display: flex; gap: 8px; align-items: baseline; cursor: pointer;
}
#cReact input { accent-color: var(--accent); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.dlg-status { font-family: var(--sans); font-size: 12.5px; color: var(--accent); margin: 14px 0 0; line-height: 1.5; }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 26px; right: 26px;
  background: var(--ink); color: var(--paper);
  font-family: var(--sans); font-size: 13px;
  padding: 12px 18px; border-radius: 2px;
  box-shadow: 0 10px 30px rgba(33,29,23,.35);
  opacity: 0; transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  pointer-events: none; max-width: 340px; line-height: 1.5;
}
#toast.show { opacity: 1; transform: none; }
#toast.error { background: var(--accent); }

@media (max-width: 900px) {
  .frame { flex-direction: column; }
  #rail { position: static; width: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--hairline); }
  #index { max-height: 40vh; }
  #reader { padding: 40px 22px 90px; }
}
