:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d1f24; --soft: #5b606b; --line: #e3e0d8;
  --accent: #e2711d; --accent-ink: #ffffff; --chip: #efece4; --good: #2f8f4e; --bad: #b8433a;
  --shadow: 0 2px 10px rgba(0,0,0,.07);
}
:root[data-theme="dark"] {
  --bg: #14161c; --card: #1e2129; --ink: #eceae4; --soft: #a3a7b1; --line: #2e323c;
  --accent: #f08a3e; --accent-ink: #14161c; --chip: #272b35; --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c; --card: #1e2129; --ink: #eceae4; --soft: #a3a7b1; --line: #2e323c;
    --accent: #f08a3e; --accent-ink: #14161c; --chip: #272b35; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 19px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-size: 21px; margin: 0; flex: 1; }
.streak { font-weight: 700; color: var(--accent); }
.iconbtn { background: none; border: 0; font-size: 22px; padding: 4px 6px; }
main { max-width: 680px; margin: 0 auto; padding: 12px 16px; }
.h { font-size: 22px; margin: 8px 0 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.row.sticky { position: sticky; top: 58px; z-index: 4; background: var(--bg); padding: 8px 0; }
.row button, .small-print button, .linkbtn {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px;
}
button.big { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.loader { text-align: center; color: var(--soft); padding: 26px 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  margin: 0 0 18px; box-shadow: var(--shadow);
}
.card img.pic { width: 100%; max-height: 260px; object-fit: cover; display: block; background: var(--chip); }
.card .body { padding: 16px 18px 12px; }
.tag { display: inline-block; font-size: 14px; background: var(--chip); color: var(--soft); padding: 3px 10px; border-radius: 99px; }
.why { font-size: 14px; color: var(--soft); margin-left: 6px; }
.card h2 { font-size: 24px; line-height: 1.25; margin: 10px 0 8px; }
.card p { margin: 0 0 10px; }
.card .more { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.card .more h3 { font-size: 20px; margin: 18px 0 6px; }
.card .more h4 { font-size: 18px; margin: 14px 0 4px; color: var(--soft); }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.actions button {
  border: 1px solid var(--line); background: transparent; border-radius: 12px; padding: 8px 12px; min-width: 48px; min-height: 44px;
}
.actions button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.actions .read { margin-left: auto; font-weight: 700; }
.card.gone .body > *:not(.gonemsg) { display: none; }
.card.gone img { display: none; }
.gonemsg { color: var(--soft); font-size: 16px; }
.mini { font-size: 15px; color: var(--soft); }

.group { margin: 18px 0 6px; font-size: 17px; color: var(--soft); text-transform: uppercase; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 9px 14px; font-size: 17px;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.welcome h2 { margin: 6px 0 4px; }
.small-print { color: var(--soft); font-size: 15px; margin: 30px 0; }
.otd { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-bottom: 10px; }
.otd b { color: var(--accent); }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; background: none; border: 0; padding: 8px 0 6px; font-size: 20px; display: flex; flex-direction: column; align-items: center; color: var(--soft); }
.tabs button span { font-size: 12px; }
.tabs button.on { color: var(--accent); }
.tabs button[hidden] { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 16px; z-index: 9; max-width: 90vw;
}
input[type=search], input[type=text], textarea {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
}

/* books */
.searchrow { display: flex; gap: 8px; margin-bottom: 12px; }
.searchrow input { flex: 1; }
.sub { font-size: 19px; margin: 20px 0 8px; }
.bookrow { display: flex; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 8px; align-items: center; }
.bookrow .cover, .bookrow .nocover { width: 54px; height: 80px; object-fit: cover; border-radius: 6px; flex: none; background: var(--chip); display: flex; align-items: center; justify-content: center; }
.bk { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bk b { font-size: 18px; line-height: 1.3; }
.bk span { font-size: 15px; color: var(--soft); }
.badge { font-size: 13px !important; color: var(--accent) !important; }
.bookhead { display: flex; gap: 14px; margin: 12px 0; align-items: flex-start; }
.bookhead h2 { margin: 0 0 4px; font-size: 23px; line-height: 1.25; }
.bookhead p { margin: 0; color: var(--soft); }
.bigcover { width: 110px; border-radius: 8px; flex: none; }
.bigcover.nocover { height: 160px; background: var(--chip); display: flex; align-items: center; justify-content: center; font-size: 40px; }
a.linkbtn { text-decoration: none; color: var(--ink); display: inline-block; }
.cardform { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.cardform .sub { margin: 4px 0 0; }
.reader { font-size: 20px; line-height: 1.7; }
.reader h3 { margin: 22px 0 8px; }
.readnav { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 0; }
.readnav button { flex: 1; }

/* my shelf */
.pdfpage { display: block; width: 100%; border-radius: 8px; background: #fff; }
.epub { width: 100%; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.bk.plain { background: none; border: 0; text-align: left; flex: 1; padding: 0; }
