:root {
  --bg: #faf7f2;
  --fg: #2b2620;
  --muted: #7a7064;
  --accent: #9a5b2e;
  --card: #ffffff;
  --border: #e6dfd4;
  --font-size: 19px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1b1916;
  --fg: #e6e0d6;
  --muted: #9b9184;
  --accent: #d9a066;
  --card: #24211d;
  --border: #36322c;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1916;
    --fg: #e6e0d6;
    --muted: #9b9184;
    --accent: #d9a066;
    --card: #24211d;
    --border: #36322c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky; top: 0; z-index: 1;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; color: var(--fg); }
.tools button {
  background: none; border: 1px solid var(--border); color: var(--fg);
  border-radius: 6px; padding: 4px 10px; margin-left: 4px; cursor: pointer; font-size: 14px;
}
.tools button:hover { border-color: var(--accent); }
.tools form { display: inline; }

.login { max-width: 360px; margin: 32px auto 0; display: flex; flex-direction: column; gap: 16px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.login input {
  font: inherit; font-size: 16px; color: var(--fg);
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login button {
  font: inherit; font-weight: 600; color: var(--bg); background: var(--accent);
  border: none; border-radius: 8px; padding: 11px; margin-top: 8px; cursor: pointer;
}
.login button:hover { filter: brightness(1.08); }
.login .error { padding: 0; margin: 0; text-align: left; }

main { max-width: 720px; margin: 0 auto; padding: 24px 16px 80px; }

h1.page-title { font-family: Georgia, "Iowan Old Style", serif; font-size: 2rem; margin: 8px 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 24px; }
.crumb { color: var(--muted); font-size: 14px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li a {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 14px 16px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg);
}
.list li a:hover { border-color: var(--accent); text-decoration: none; }
.list .meta { color: var(--muted); font-size: 14px; white-space: nowrap; }
.list .num { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }

.chapter {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-size: var(--font-size);
  line-height: 1.7;
}
.chapter h1, .chapter h2, .chapter h3 { line-height: 1.3; }
.chapter p { margin: 0 0 1em; text-align: justify; hyphens: auto; }
.chapter blockquote p { text-align: left; }
.chapter blockquote { margin: 1em 0; padding-left: 1em; border-left: 3px solid var(--border); color: var(--muted); }
.chapter hr { border: none; text-align: center; margin: 2em 0; }
.chapter hr::after { content: "⁂"; color: var(--muted); }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); }
.pager a, .pager span { flex: 1; }
.pager .next { text-align: right; }

.empty, .error { color: var(--muted); text-align: center; padding: 48px 0; }
.error { color: #c0392b; }

.progress { color: var(--muted); font-size: 14px; margin: -12px 0 16px; }
.list li.read a { color: var(--muted); }
.list .check { color: var(--accent); }
.read-status { text-align: center; margin-top: 32px; }
.read-status button {
  background: none; border: 1px solid var(--border); color: var(--fg);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; font-size: 14px;
}
.read-status button:hover { border-color: var(--accent); }
.read-status button.done { color: var(--muted); }
