/* DailyBookRead: one stylesheet, light and dark, phone first. */
:root {
  --bg: #f7f7f5; --surface: #ffffff; --text: #1d1d1f; --muted: #6b6b70; --line: #e3e3e0;
  --accent: #2357c6; --ok: #11845b; --ok-bg: #e3f4ec; --bad: #c2352b; --bad-bg: #fbe7e5;
  --warn: #8a5a00; --warn-bg: #fff4d6; --soft: #ececec; --code-bg: #f3f3f1; --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214; --surface: #1c1c1f; --text: #ececee; --muted: #9a9aa2; --line: #2e2e33;
    --accent: #7ea6ff; --ok: #4cc690; --ok-bg: #12342a; --bad: #ff7b70; --bad-bg: #3d1c1a;
    --warn: #f0c35a; --warn-bg: #3a2e10; --soft: #2b2b30; --code-bg: #26262b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0.4rem 0 0.8rem; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 0.6rem; }
.card h2 { margin-top: 0; }
main { max-width: 920px; margin: 0 auto; padding: 0 16px 40px; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.num { text-align: right; white-space: nowrap; }
.name { color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.eyebrow { margin: 0; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.crumbs { margin: 10px 0 0; font-size: 0.9rem; }
.empty { padding: 8px 16px; }

/* header */
.top {
  display: flex; align-items: center; gap: 18px; padding: 10px 16px; margin-bottom: 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 14px; }
.top nav a { color: var(--muted); }
.top nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.dot { color: var(--warn); font-size: 0.7rem; vertical-align: middle; }
.who { margin-left: auto; font-size: 0.9rem; }
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; color: var(--muted); }
.menu-items {
  position: absolute; right: 0; top: 1.8rem; z-index: 10; min-width: 170px; padding: 8px 12px;
  display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 6px 20px rgb(0 0 0 / 0.12);
}

/* bits */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
}
.card > p:first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.narrow { max-width: 380px; margin: 24px auto; }
.narrow-left { max-width: 520px; }
.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.msg { padding: 8px 12px; border-radius: 8px; background: var(--soft); margin: 8px 0; }
.msg.success { background: var(--ok-bg); }
.msg.error { background: var(--bad-bg); }
.msg.warning { background: var(--warn-bg); color: var(--warn); }
.banner { display: flex; align-items: center; gap: 6px; }
.banner button.link { color: inherit; text-decoration: underline; }
.flag, .badge {
  display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  background: var(--warn-bg); color: var(--warn); vertical-align: middle;
}
.badge.next { background: var(--accent); color: #fff; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }

.status { font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.status.reading, .status.sent { color: var(--ok); }
.status.review, .status.queued { color: var(--accent); }
.status.waiting, .status.processing, .status.sending { color: var(--warn); }
.status.failed { color: var(--bad); }
.status.finished { color: var(--muted); }

progress {
  width: 100%; height: 8px; border: 0; border-radius: 4px; overflow: hidden; vertical-align: middle;
  background: var(--soft); appearance: none; -webkit-appearance: none;
}
progress::-webkit-progress-bar { background: var(--soft); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
td progress { width: 90px; }
.now h1 { margin: 0.2rem 0 0.8rem; }
.next-title { font-size: 1.1rem; font-weight: 600; margin: 0 0 4px; }
.queue { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.queue li { display: flex; gap: 8px; }
.queue .actions { margin-left: auto; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
th.num, td.num { text-align: right; }
table.compact td, table.compact th { padding: 5px 6px; font-size: 0.9rem; }
.actions { text-align: right; white-space: nowrap; }
.actions form { display: inline; }
.actions a { margin-left: 6px; }
.books .title { font-weight: 600; }

/* book page */
.chapter { margin-top: 18px; }
.chapter-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; border-bottom: 2px solid var(--line); padding-bottom: 4px; }
.chapter-head h2 { margin: 0; font-size: 1rem; }
.push { margin-left: auto; }
.chapter.skipped .chapter-head h2, tr.skipped td { color: var(--muted); }
tr.skipped a { color: var(--muted); text-decoration: line-through; }
tr.upcoming td { background: var(--warn-bg); }
td.odd { color: var(--bad); font-weight: 600; }
.issues { table-layout: fixed; }
.issues td { overflow: hidden; text-overflow: ellipsis; }
.issues .n { width: 2.8em; }
.issues .min { width: 5.5em; }
.issues .state { width: 6.5em; }
.issues .actions { width: 10.5em; }
.more { margin-top: 24px; }
.more summary { cursor: pointer; font-weight: 600; }
.more form.stack { margin: 12px 0; max-width: 520px; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 12px; }

/* forms */
input, button, select, textarea { font: inherit; }
input:not([type="checkbox"]):not([type="file"]), textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
textarea { font-family: var(--mono); font-size: 0.86rem; line-height: 1.45; }
button, .button {
  display: inline-block; padding: 8px 14px; border: 1px solid transparent; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; line-height: 1.3;
}
button.secondary, .button.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
button.danger { background: var(--bad); }
.button:hover { text-decoration: none; }
button.link { background: none; border: 0; color: var(--accent); padding: 0 4px; font-weight: 400; }
button:disabled { opacity: 0.6; cursor: progress; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.buttons form { display: inline; }
.stack { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 0.85rem; font-weight: 600; }
.has-error input, .has-error textarea { border-color: var(--bad); }
.errorlist { list-style: none; padding: 0; margin: 0; color: var(--bad); font-size: 0.85rem; }
.check { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; }

/* upload */
.upload { display: grid; gap: 10px; }
.drop {
  display: grid; gap: 4px; justify-items: center; text-align: center; padding: 26px 12px;
  border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer;
}
.drop.over { border-color: var(--accent); background: var(--soft); }
.drop input { max-width: 100%; font-size: 0.85rem; }
.linkish { color: var(--accent); }
.upload-progress { height: 6px; }

/* reading */
.reader { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px clamp(16px, 5vw, 48px) 28px; margin: 8px 0 14px; }
.reader header h1 { font-size: 1.7rem; margin-bottom: 4px; }
.prose { font-family: var(--serif); font-size: 1.12rem; line-height: 1.65; max-width: 68ch; }
.prose h2, .prose h3, .prose h4 { font-family: system-ui, -apple-system, sans-serif; line-height: 1.3; }
.prose h2 { font-size: 1.3rem; margin-top: 1.8rem; }
.prose h3 { font-size: 1.12rem; margin-top: 1.5rem; }
.prose h4 { font-size: 1rem; }
.prose img { display: block; max-width: 100%; height: auto; margin: 12px auto; border-radius: 4px; background: #fff; }
.prose pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  overflow-x: auto; font-size: 0.86rem; line-height: 1.45;
}
.prose code { font-family: var(--mono); font-size: 0.86em; background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose blockquote { margin: 0 0 1em; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }
.prose table { font-family: system-ui, sans-serif; font-size: 0.9rem; margin: 1em 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); }
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 14px; }

/* split */
.split .block { position: relative; padding: 2px 70px 2px 0; }
.split .block .prose { font-size: 1rem; }
.split .running { position: absolute; right: 0; top: 6px; }
.split .cut { border-top: 1px dashed var(--line); margin: 4px 0; text-align: center; }
.split .cut button { background: var(--bg); position: relative; top: -0.8em; padding: 0 8px; }

/* phones: tables become cards */
@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 10px; }
  table.books thead, table.deliveries thead { display: none; }
  table.books tr, table.deliveries tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  table.books td, table.deliveries td { border: 0; padding: 2px 0; text-align: left; }
  table.books td:first-child, table.deliveries td:nth-child(2) { grid-column: 1 / -1; }
  table.books td[data-label]::before, table.deliveries td[data-label]::before {
    content: attr(data-label); display: block; font-size: 0.7rem; color: var(--muted);
  }
  .issues .state { display: none; }
  .issues .actions { width: 7.5em; }
  .issues .min { width: 4.5em; }
  .issues .actions a, .issues .actions button { margin-left: 2px; }
  .split .block { padding-right: 0; }
  .split .running { position: static; display: block; text-align: right; }
}
