/* Fonts are stored with the app so it looks the same offline. */
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces.woff2) format("woff2"); font-weight: 300 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-italic.woff2) format("woff2"); font-weight: 300 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/atkinson-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/atkinson-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/atkinson-700.woff2) format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Caveat"; src: url(fonts/caveat-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --ground: #f5efe4;
  --surface: #fffdf8;
  --surface-2: #efe6d6;
  --ink: #2a2118;
  --muted: #6b5d4d;
  --line: #e2d6c3;
  --brand: #23413c;
  --accent: #b4532a;
  --accent-ink: #ffffff;
  --accent-soft: #f5dfcf;
  --mark: #f6d77a;
  --mark-ink: #2a2118;
  --danger: #a4262c;
  --ok: #2f6b4f;
  --warn-bg: #fbecc8;
  --warn-ink: #6a4a08;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 18px rgba(60, 40, 20, .07);
  --radius: 16px;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --serif: var(--display);
  --sans: "Atkinson Hyperlegible", system-ui, -apple-system, sans-serif;
  --hand: "Caveat", "Bradley Hand", cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #17130f;
    --surface: #221c16;
    --surface-2: #2c251d;
    --ink: #f1e8da;
    --muted: #bcad97;
    --line: #3b3128;
    --brand: #a9d3c6;
    --accent: #e58a5f;
    --accent-ink: #1a120c;
    --accent-soft: #3b2519;
    --mark: #7a5c00;
    --mark-ink: #fff5d6;
    --danger: #ff8f84;
    --ok: #7fd1a8;
    --warn-bg: #3a2d10;
    --warn-ink: #ffe3a0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #17130f;
  --surface: #221c16;
  --surface-2: #2c251d;
  --ink: #f1e8da;
  --muted: #bcad97;
  --line: #3b3128;
  --brand: #a9d3c6;
  --accent: #e58a5f;
  --accent-ink: #1a120c;
  --accent-soft: #3b2519;
  --mark: #7a5c00;
  --mark-ink: #fff5d6;
  --danger: #ff8f84;
  --ok: #7fd1a8;
  --warn-bg: #3a2d10;
  --warn-ink: #ffe3a0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 18px/1.5 var(--sans);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top, 0px) 0 0;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }

main { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.view {
  max-width: 800px;
  margin: 0 auto;
  padding: 8px 16px 40px;
}
.view.wide { max-width: 1400px; }
.wrap { max-width: 1400px; margin: 8px auto 0; }
@media (min-width: 900px) { main { padding-bottom: 0; } .view { padding-inline: 28px; } }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding-block: 14px 10px;
}
.topbar h1 {
  flex: 1; margin: 0;
  font: 600 28px/1.15 var(--display);
  font-variation-settings: "opsz" 72, "SOFT" 50;
  color: var(--brand);
  letter-spacing: -.01em;
  text-wrap: balance;
}
.spacer { width: 48px; }
.brand { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 46px; height: 46px; flex: none; border-radius: 12px; background: var(--brand); color: var(--ground); display: grid; place-items: center; }
.brand-mark svg { width: 26px; height: 26px; }
.brand h1 { flex: none; }
.brand-sub { display: block; font: 600 20px/1 var(--hand); color: var(--accent); margin-top: 2px; }
.icon-btn {
  width: 48px; height: 48px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--brand); font-size: 24px; line-height: 1;
  cursor: pointer;
}
.icon-btn svg, .btn svg { width: 24px; height: 24px; flex: none; }
.btn svg { margin-right: 10px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 10px 18px;
  border-radius: 14px; border: 1px solid transparent;
  font-weight: 700; font-size: 18px; text-decoration: none;
  cursor: pointer; text-align: center;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.big { min-height: 60px; font-size: 20px; }
.btn.small { min-height: 44px; font-size: 16px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: var(--line); }
.btn:disabled { opacity: .55; }
.link-btn {
  background: none; border: 0; padding: 8px 4px; cursor: pointer;
  color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- search & filters ---------- */
.search-wrap { display: flex; gap: 8px; align-items: center; }
#q {
  flex: 1; min-width: 0;
  height: 58px; padding: 0 16px 0 48px;
  border: 2px solid var(--line); border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a7a66' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 16px center / 22px;
  font-size: 19px; box-shadow: var(--shadow);
}
#q:focus { border-color: var(--accent); outline: none; }
.filters {
  margin-top: 12px; padding: 16px;
  display: grid; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .label-sm { font-weight: 600; font-size: 16px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.field textarea { font: 19px/1.6 var(--sans); resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; font-size: 17px; min-height: 44px; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--accent); }
.stack .check { align-items: flex-start; }
.stack .check input { margin-top: 3px; }
.reader-note { margin-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--ground);
  border-radius: 999px; padding: 6px 14px; min-height: 40px;
  font-size: 16px; cursor: pointer;
}
.chip { background: var(--surface-2); border-color: transparent; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.result-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-block: 12px 4px; color: var(--muted); font-size: 16px;
}

/* ---------- list ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.item {
  display: grid; grid-template-columns: 84px 1fr; gap: 16px;
  padding: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%;
}
.item img, .item .thumb-ph {
  width: 84px; height: 110px; object-fit: cover; border-radius: 8px;
  background: var(--ground); border: 1px solid var(--line);
}
.item-body { min-width: 0; display: grid; gap: 4px; align-content: start; }
.item-title { font: 600 20px/1.25 var(--display); color: var(--brand); margin: 0; overflow-wrap: anywhere; }
.item-meta { font-size: 15px; color: var(--muted); }
.item-snip { font-size: 16px; line-height: 1.45; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item mark, .mark { background: var(--mark); color: var(--mark-ink); border-radius: 3px; padding: 0 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 14px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.badge.busy { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.empty .btn { margin-top: 8px; }
.empty-title { font: 600 26px/1.2 var(--display); color: var(--brand); margin: 0 0 4px; }
.empty-hand { font: 600 26px/1.1 var(--hand); color: var(--accent); margin: 0 0 18px; }
.steps { list-style: none; counter-reset: step; margin: 0 auto 20px; padding: 0; display: grid; gap: 10px; max-width: 420px; text-align: left; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font: 700 20px var(--display); }

/* ---------- adjust / crop ---------- */
.hint { margin: 0 0 10px; color: var(--muted); font-size: 16px; }
.crop-stage {
  position: relative; margin: 0 auto; overflow: hidden;
  border-radius: 10px; background: #000; touch-action: none; user-select: none; -webkit-user-select: none;
  max-width: 100%;
}
#adj-canvas { display: block; width: 100%; height: auto; }
.crop-rect {
  position: absolute; border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5);
}
.crop-rect .h {
  position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; background: rgba(42, 93, 176, .35); border: 3px solid #fff;
  touch-action: none;
}
.h.tl { left: 0; top: 0; } .h.tr { left: 100%; top: 0; }
.h.bl { left: 0; top: 100%; } .h.br { left: 100%; top: 100%; }
.adj-tools { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; align-items: center; margin-top: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.seg-btn { border: 0; background: none; padding: 10px 14px; min-height: 52px; font-weight: 600; font-size: 16px; cursor: pointer; }
.seg-btn.on { background: var(--accent); color: var(--accent-ink); }
.adj-actions { display: grid; gap: 10px; margin-top: 16px; }

/* ---------- page detail ---------- */
.page-img { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.page-img img { display: block; margin: 0 auto; max-height: 55vh; border-radius: 6px; }
.page-img figcaption { text-align: center; }
.note { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--warn-bg); color: var(--warn-ink); font-size: 16px; }
.note.info { background: var(--surface-2); color: var(--ink); border: 0; }
.form { display: grid; gap: 16px; margin-top: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
.tip { margin: 0; font-size: 15px; color: var(--muted); }
.page-actions { display: grid; gap: 10px; margin-top: 20px; }
.confirm { margin-top: 12px; padding: 14px; border: 2px solid var(--danger); border-radius: 12px; background: var(--surface); }
.confirm p { margin: 0 0 10px; font-weight: 600; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.row-btns .btn { flex: 1; }

/* ---------- menu ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 8px; font: 600 23px/1.2 var(--display); color: var(--brand); }
.card .kicker { font: 600 22px/1 var(--hand); color: var(--accent); margin: 0 0 2px; }
.card p { margin: 0 0 12px; }
.stack { display: grid; gap: 10px; }
.help ol { padding-left: 22px; margin: 0 0 12px; display: grid; gap: 10px; }

/* ---------- overlays ---------- */
.zoom { position: fixed; inset: 0; z-index: 20; background: #000; overflow: auto; -webkit-overflow-scrolling: touch; }
.zoom img { display: block; width: 100%; max-width: none; }
.zoom-close { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 21; background: #fff; color: #000; }
.busy { position: fixed; inset: 0; z-index: 30; background: rgba(10, 15, 22, .55); display: grid; place-items: center; padding: 16px; }
.busy-box { background: var(--surface); border-radius: 16px; padding: 24px 28px; text-align: center; max-width: 340px; }
.busy-box p { margin: 12px 0 0; }
.spinner { width: 44px; height: 44px; margin: 0 auto; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  max-width: 520px; margin: 0 auto; padding: 14px 18px; border-radius: 12px;
  background: var(--ink); color: var(--ground); font-weight: 600; text-align: center; box-shadow: var(--shadow);
}
.sheet { position: fixed; inset: 0; z-index: 35; background: rgba(10, 15, 22, .55); display: grid; align-items: end; }
.sheet-box { background: var(--surface); padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); border-radius: 18px 18px 0 0; display: grid; gap: 10px; max-width: 760px; width: 100%; margin: 0 auto; }
.sheet-box p { margin: 0 0 4px; font-weight: 600; }

/* ---------- line by line ---------- */
.lines-wrap { margin-top: 16px; }
.lines-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.lines-head h2 { margin: 0; font: 600 23px var(--display); color: var(--brand); }
.lines-wrap .tip { margin: 6px 0 12px; }
.lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.line-row { display: grid; gap: 6px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.line-row.done { border-color: var(--ok); }
.line-row img { display: block; width: 100%; height: auto; max-height: 90px; object-fit: contain; object-position: left center; background: #fff; border-radius: 6px; }
.line-input { width: 100%; min-height: 50px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: 19px/1.4 var(--sans); }

.card-intro { color: var(--muted); }
#claude-card label { font-weight: 600; font-size: 16px; }
#claude-card input, #claude-card select, #claude-card textarea {
  width: 100%; min-height: 50px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
#claude-card textarea { resize: vertical; }


/* =========================================================
   App bar and sections
   ========================================================= */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--ground); border-bottom: 1px solid var(--line);
}
.brand-name { display: block; font: 600 26px/1.1 var(--display); color: var(--brand); letter-spacing: -.01em; }
.brand-sub { font-size: 19px; }
.tabs { display: flex; gap: 6px; margin-left: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid transparent; background: none; color: var(--muted);
  font-weight: 700; font-size: 17px; cursor: pointer;
}
.tab svg { width: 22px; height: 22px; }
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.on { background: var(--brand); color: var(--ground); }
/* Phones: the sections move to a bar along the bottom */
@media (max-width: 899px) {
  .appbar { padding-block: 8px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand-name { font-size: 22px; }
  .brand-sub { font-size: 17px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tab { flex-direction: column; gap: 2px; border-radius: 12px; padding: 6px 4px; font-size: 14px; min-height: 58px; }
  .tab.on { background: var(--accent-soft); color: var(--accent); }
}
.icon-btn svg, .btn svg, .seg-btn svg { width: 22px; height: 22px; flex: none; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn.small { width: 40px; height: 40px; border-radius: 12px; }
.icon-btn.small svg { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 18px 0 14px; }
.section-head p { margin: 0; flex-basis: 100%; }
.h-display { margin: 0; font: 600 32px/1.15 var(--display); color: var(--brand); letter-spacing: -.01em; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--jc, var(--muted)); margin-right: 7px; vertical-align: 1px; flex: none; }
.search-wrap { margin-top: 14px; }
.filters { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-items: end; }
.filters .span-all { grid-column: 1 / -1; }
.badge.star { background: var(--accent-soft); color: var(--accent); }
.item { border-left: 6px solid var(--jc, var(--line)); }
.item-meta { display: flex; align-items: center; flex-wrap: wrap; }
@media (min-width: 900px) { #list { grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); } }

/* ---------- Shelf of journals ---------- */
.shelf { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.jcard {
  width: 100%; display: grid; grid-template-columns: 110px 1fr; gap: 16px; align-items: center;
  padding: 14px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.jcard:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(60, 40, 20, .14); }
.jcover {
  position: relative; display: block; width: 110px; height: 146px; border-radius: 6px 12px 12px 6px; overflow: hidden;
  background: var(--jc); box-shadow: inset -6px 0 12px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .2);
}
.jcover img { position: absolute; inset: 10px 10px 10px 18px; width: calc(100% - 28px); height: calc(100% - 20px); object-fit: cover; border-radius: 3px; opacity: .92; }
.jspine { position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: rgba(0, 0, 0, .25); }
.jlabel {
  position: absolute; left: 18px; right: 8px; bottom: 10px; padding: 3px 6px; border-radius: 4px;
  background: rgba(255, 253, 248, .92); color: #2a2118; font: 600 17px/1.1 var(--hand);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.jinfo { display: grid; gap: 4px; min-width: 0; }
.jname { font: 600 22px/1.2 var(--display); color: var(--brand); overflow-wrap: anywhere; }
.jspan { font: 600 24px/1 var(--hand); color: var(--accent); }

/* ---------- One journal ---------- */
.journal-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 12px; }
.jr-title { flex: 1; min-width: 180px; }
.jr-title p { margin: 2px 0 0; }
.swatch { width: 16px; height: 44px; border-radius: 4px; flex: none; }
.hint { color: var(--muted); }
.arrange-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.arrange-bar select { min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.arrange { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.tile {
  position: relative; display: grid; gap: 4px; padding: 8px; cursor: grab;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; user-select: none; -webkit-user-select: none;
}
.tile img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; background: var(--surface-2); pointer-events: none; }
.tile-no { font: 700 18px var(--display); color: var(--brand); }
.tile-date { font-size: 13px; color: var(--muted); line-height: 1.25; }
.tile-date.dated { color: var(--ok); font-weight: 700; }
.tile-date.odd, .leaf-date.odd { color: var(--danger); }
.tile-check { position: absolute; top: 12px; left: 12px; background: var(--surface); border-radius: 8px; padding: 6px; line-height: 0; box-shadow: var(--shadow); }
.tile-check input { width: 22px; height: 22px; accent-color: var(--accent); }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }

/* ---------- The page viewer ---------- */
.reader { display: grid; gap: 10px; }
.rd-bar { display: flex; align-items: center; gap: 10px; }
.rd-where { flex: 1; min-width: 0; text-align: center; display: grid; }
.rd-pos { font-weight: 700; }
.rd-when { font: 600 22px/1.2 var(--hand); color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-track {
  display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  height: 60vh; min-height: 340px;
  border-radius: var(--radius); background: var(--surface-2); scrollbar-width: none;
}
.rd-track::-webkit-scrollbar { display: none; }
.rd-track:focus { outline: none; }
.rd-track:focus-visible { outline: 3px solid var(--accent); }
.leaf {
  flex: 0 0 100%; scroll-snap-align: start; min-width: 0;
  display: grid; grid-template-rows: 1fr auto; gap: 8px; padding: 12px 12px 10px;
  border-top: 5px solid var(--jc);
}
@media (min-width: 820px) {
  .leaf { flex-basis: 50%; }
  .leaf:nth-child(odd) { box-shadow: inset -12px 0 18px -14px rgba(0, 0, 0, .35); }   /* the book's fold */
  .leaf:nth-child(even) { box-shadow: inset 12px 0 18px -14px rgba(0, 0, 0, .35); }
}
.leaf-sheet { min-height: 0; display: grid; grid-template-rows: 1fr; }
.leaf-img { width: 100%; height: 100%; min-height: 0; object-fit: contain; cursor: zoom-in; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .18)); }
.leaf-text { display: none; overflow-y: auto; padding: 14px 16px; background: var(--surface); border-radius: 10px; white-space: pre-wrap; font-size: 17px; line-height: 1.55; }
.leaf-title { margin: 0 0 8px; font: 600 20px var(--display); color: var(--brand); white-space: normal; }
.show-text .leaf-sheet { grid-template-rows: 45% 1fr; gap: 10px; }
.show-text .leaf-text { display: block; }
.leaf-cap { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 15px; }
.leaf-info { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; min-width: 0; }
.leaf-date { font-weight: 700; color: var(--ok); }
.leaf-date.between, .leaf-date.after, .leaf-date.before { color: var(--muted); font-style: italic; font-weight: 400; }
.leaf-date.none { color: var(--muted); }
.leaf-where { color: var(--muted); display: inline-flex; align-items: center; }
.leaf-acts { display: flex; gap: 6px; }
.leaf-star.on { color: var(--accent); border-color: var(--accent); }
.rd-scrub { position: relative; padding-top: 26px; }
.rd-years { position: absolute; left: 12px; right: 12px; top: 0; height: 24px; }
.rd-year {
  position: absolute; transform: translateX(-50%); border: 0; background: none; cursor: pointer;
  font: 700 14px var(--sans); color: var(--brand); padding: 2px 4px;
}
.rd-year::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 6px; background: var(--line); }
.rd-range { width: 100%; accent-color: var(--accent); height: 32px; cursor: pointer; }
.rd-empty { padding: 60px 12px; }
#tl-journals { margin: 0 0 12px; }
.jchip { display: inline-flex; align-items: center; }
.jchip.on { background: var(--surface); color: var(--ink); border-color: var(--jc); box-shadow: inset 0 0 0 1px var(--jc); }
.jchip:not(.on) { opacity: .55; text-decoration: line-through; }

/* ---------- Scan ---------- */
.journal-picks { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 8px; }
.jpick {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 8px; text-align: left;
  min-height: 60px; padding: 10px 14px; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--line); background: var(--surface);
}
.jpick span:nth-child(2) { font-weight: 700; }
.jpick .small { grid-column: 2; }
.jpick.on { border-color: var(--jc); box-shadow: inset 0 0 0 2px var(--jc); background: var(--surface-2); }
.scan-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scan-buttons .btn { flex-direction: column; gap: 4px; min-height: 76px; }
.scan-buttons .btn svg { margin: 0; width: 26px; height: 26px; }
.dropzone { margin-top: 12px; padding: 22px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: 14px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
@media (hover: none) { .dropzone { display: none; } }
.strip { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.strip-item { width: 100%; display: grid; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: 13px; text-align: left; }
.strip-item img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; }
.strip-item .badge { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Page details ---------- */
#view-page .topbar h1 { font-size: 24px; }
@media (min-width: 1000px) {
  .page-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .page-layout .page-img { position: sticky; top: 90px; }
  .page-layout .page-img img { max-height: calc(100vh - 160px); }
  .page-layout .form { margin-top: 0; }
}
.warn-text { color: var(--danger); }

/* ---------- Journal dialog ---------- */
.sheet { align-items: center; padding: 16px; }
.sheet-box { border-radius: 18px; max-width: 480px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.swatch-btn { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
.swatch-btn.on { border-color: var(--ink); }

@media (max-width: 599px) {
  .h-display { font-size: 26px; }
  .journal-head { gap: 8px; }
  .jr-title { min-width: 0; flex-basis: calc(100% - 120px); }
  .rd-text span { display: none; }
  .rd-text svg { margin: 0; }
  .rd-when { font-size: 20px; }
  .jcard { grid-template-columns: 84px 1fr; }
  .jcover { width: 84px; height: 112px; }
}
@media (max-width: 599px) { .jlabel { display: none; } }
