:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665d;
  --border: #ddd8cc;
  --accent: #8a2b52;
  --accent-soft: #f3e4ea;
  --root: #b5523b;
  --word: #3b5fa0;
  --text-c: #6d7a2a;
  --hl: #ffe9a8;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #211f1c;
    --text: #ebe6dc;
    --muted: #a39d91;
    --border: #3a3631;
    --accent: #e28fb0;
    --accent-soft: #3a2630;
    --root: #e49a85;
    --word: #92b2ea;
    --text-c: #c1cf73;
    --hl: #5c4b17;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 0 14px; }
.header-inner { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.brand { font-size: 1.6rem; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }
.brand span { font-size: 0.9rem; font-weight: 400; color: var(--muted); margin-left: 6px; }
.brand:hover { text-decoration: none; }
.main-nav { display: flex; gap: 18px; font-family: var(--ui); font-size: 0.95rem; }
.main-nav a { color: var(--muted); }
.main-nav a.active { color: var(--accent); font-weight: 600; }

.search { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.search input { flex: 1 1 260px; min-width: 0; }
.search input, .search select, .search button {
  font: inherit; font-family: var(--ui); font-size: 0.95rem;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text);
}
.search button { background: var(--accent); color: var(--surface); border-color: var(--accent); cursor: pointer; }

main { padding-top: 20px; padding-bottom: 40px; min-height: 60vh; }
h1 { font-size: 1.9rem; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 28px 0 8px; font-family: var(--ui); font-weight: 600; }
.kind { font-family: var(--ui); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.kind.root { color: var(--root); }
.kind.word { color: var(--word); }
.kind.text { color: var(--text-c); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; margin: 12px 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.facts dt { color: var(--muted); font-family: var(--ui); font-size: 0.85rem; padding-top: 2px; }
.facts dd { margin: 0; }
.nah { font-size: 1.05em; }
h1.nah { font-size: 1.9rem; }
.comment { white-space: pre-line; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { font-family: var(--ui); font-size: 0.8rem; color: var(--muted); font-weight: 600; background: var(--bg); }
table.list tr:last-child td { border-bottom: none; }
table.list td.code { font-family: var(--ui); font-size: 0.85rem; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

.letters { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 16px; font-family: var(--ui); }
.letters a { padding: 3px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); font-size: 0.9rem; }
.letters a.active { background: var(--accent); color: var(--surface); border-color: var(--accent); }

.folio-nav { display: flex; justify-content: space-between; gap: 8px; font-family: var(--ui); font-size: 0.9rem; margin: 8px 0 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; font-family: var(--ui); font-size: 0.9rem; margin-bottom: 8px; flex-wrap: wrap; }
.tabs button { font: inherit; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }

.sentence { display: grid; grid-template-columns: 44px 1fr; gap: 4px 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.sentence:last-child { border-bottom: none; }
.sentence.current { background: var(--accent-soft); }
.sentence .no { font-family: var(--ui); font-size: 0.8rem; color: var(--muted); padding-top: 3px; }
.sentence .line { min-width: 0; overflow-wrap: anywhere; }
.sentence .line + .line { margin-top: 2px; }
.line.pal { color: var(--muted); font-style: italic; }
.line.eng { color: var(--muted); }
.tok { border-radius: 3px; }
a.tok { color: inherit; border-bottom: 1px dotted var(--muted); }
a.tok:hover { color: var(--accent); text-decoration: none; border-bottom-color: var(--accent); }
.tok.hl, mark { background: var(--hl); color: inherit; padding: 0 2px; }

.kwic td.line { overflow-wrap: anywhere; }
details summary { cursor: pointer; font-family: var(--ui); font-weight: 600; margin: 10px 0; }
.abbr-table td:first-child { white-space: nowrap; font-family: var(--ui); font-size: 0.9rem; }

.site-footer { color: var(--muted); font-size: 0.85rem; padding: 20px 16px 40px; border-top: 1px solid var(--border); font-family: var(--ui); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .brand span { display: block; margin: 0; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 8px; }
  table.list th, table.list td { padding: 6px 7px; }
}
.line sup { font-size: 0.65em; line-height: 0; }
.pal-mark { color: var(--muted); font-style: normal; font-size: 0.8em; cursor: help; }
