/* VOIA reader — flowing text view (phone-first). No external fonts, no images. */
:root {
  --bg: #fbf8f2;
  --ink: #221e19;
  --muted: #6b6259;
  --rule: #e4ddd2;
  --accent: #7a4e24;
  --chip-bg: #efe7da;
  --chip-ink: #5a4224;
  --size: 1.0625rem;
  --lead: 1.72;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
body[data-theme="dark"] {
  --bg: #17140f;
  --ink: #ece5d8;
  --muted: #a39a8c;
  --rule: #322c24;
  --accent: #d9a56a;
  --chip-bg: #2a241c;
  --chip-ink: #d9c7a8;
}
body[data-size="1"] { --size: 0.98rem; }
body[data-size="2"] { --size: 1.0625rem; }
body[data-size="3"] { --size: 1.18rem; }
body[data-size="4"] { --size: 1.3rem; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-wrap: break-word;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
button, a { font: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--accent); z-index: 20; transition: width .15s linear;
}

/* Slim header: it scrolls away, so it never covers the page. */
.bar {
  display: flex; align-items: center; gap: .6rem;
  padding: calc(env(safe-area-inset-top) + .6rem) 1rem .6rem;
  font-family: var(--sans); font-size: .9rem; color: var(--muted);
  border-bottom: 1px solid var(--rule);
  max-width: 40rem; margin: 0 auto;
}
.back { text-decoration: none; white-space: nowrap; color: var(--accent); padding: .3rem 0; }
.bar-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-cover { flex: none; width: 28px; height: 40px; object-fit: cover; border-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,.25); background: var(--chip-bg); }
.bar-cover[hidden] { display: none; }

.chip {
  display: inline-block; font-family: var(--sans); font-size: .72rem;
  letter-spacing: .04em; text-transform: uppercase;
  background: var(--chip-bg); color: var(--chip-ink);
  border-radius: 999px; padding: .28rem .7rem; white-space: nowrap;
}

.reader { max-width: 36rem; margin: 0 auto; padding: 1.4rem 1.25rem 2rem; }
.status { font-family: var(--sans); color: var(--muted); font-size: .95rem; margin: 2rem 0; }

.text { font-size: var(--size); line-height: var(--lead); }
.text h2 {
  font-family: var(--serif); font-weight: 600; font-size: 1.35em; line-height: 1.3;
  margin: 1.8em 0 .7em; text-wrap: balance;
}
.text h3 { font-size: 1.1em; font-style: italic; font-weight: 600; margin: 1.6em 0 .5em; }
.text h2:first-child, .text h3:first-child { margin-top: .2em; }
.text p { margin: 0 0 1em; hyphens: manual; -webkit-hyphens: manual; text-wrap: pretty; }

.end {
  margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: .8rem; align-items: flex-start;
  font-family: var(--sans);
}
.end-line { margin: 0 0 .4rem; font-size: 1rem; color: var(--muted); }
.btn {
  display: inline-block; text-decoration: none; text-align: center;
  background: var(--accent); color: var(--bg);
  padding: .8rem 1.2rem; border-radius: 10px; font-size: .98rem; min-height: 44px;
  border: 0; cursor: pointer;
}
.btn-quiet { background: transparent; color: var(--accent); border: 1px solid var(--rule); }
.chip-licence { margin-top: .6rem; }

/* Bottom dock: one small control row, not a full chrome bar. */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: .45rem 1rem calc(.45rem + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--rule);
  font-family: var(--sans); font-size: .9rem;
}
.dock button {
  min-width: 44px; min-height: 40px; border: 1px solid var(--rule);
  background: transparent; color: var(--ink); border-radius: 10px; cursor: pointer;
}
.dock-pos { color: var(--muted); font-variant-numeric: tabular-nums; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bg); border-top: 1px solid var(--rule);
  border-radius: 16px 16px 0 0; padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(0,0,0,.12);
  font-family: var(--sans); display: flex; flex-direction: column; gap: .8rem;
  max-width: 40rem; margin: 0 auto;
}
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.sheet-row button {
  min-width: 52px; min-height: 44px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--rule); background: transparent; color: var(--ink);
}
#theme { min-width: 92px; }

/* Library */
.shelf { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.shelf a.card, .shelf .card-held {
  display: block; text-decoration: none; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 14px; padding: 1rem 1.1rem;
  background: transparent;
}
.shelf .card-held { opacity: .6; cursor: default; }
.shelf .card { display: flex; gap: .9rem; align-items: flex-start; }
.card-cover { width: 56px; height: 80px; object-fit: cover; flex: 0 0 56px; border-radius: 3px; background: var(--rule); }
.card-text { min-width: 0; flex: 1 1 auto; }
.card-title { font-size: 1.12rem; font-weight: 600; line-height: 1.3; }
.card-by { font-family: var(--sans); font-size: .88rem; color: var(--muted); margin-top: .25rem; }
.card-meta { margin-top: .6rem; }
.lib-intro { font-family: var(--sans); color: var(--muted); font-size: .95rem; margin: .2rem 0 1rem; }

@media (min-width: 720px) {
  :root { --size: 1.12rem; }
  .reader { padding-top: 2.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  #progress { transition: none; }
}
