:root {
  --bg: #FFFFFF;
  --card: #F6F8F2;
  --line: #E3E9DA;
  --track: #EDF1E7;
  --ink: #2E2A26;
  --ink-2: #3D3732;
  --muted: #6F655C;
  --faint: #8C8279;
  --sage: #4F6447;
  --sage-soft: #E4EBDD;
  --print: #4E7A70;
  --print-bar: #6E958B;
  --audio: #A15F4B;
  --audio-bar: #D3A06A;
  --terracotta: #A95F4E;
  --danger: #A3524A;
  --chip-genre-bg: #F4E2D9; --chip-genre-fg: #8E4F43;
  --chip-mood-bg: #E4EBDD; --chip-mood-fg: #4F6447;
  --chip-tag-bg: #E2ECE9; --chip-tag-fg: #355B54;
  --chip-theme-bg: #EFE8DD; --chip-theme-fg: #5E554D;
  --nav-h: 64px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: var(--bg); z-index: 35; }
.date3 { display: grid; grid-template-columns: 74px minmax(0, 1fr) 96px; gap: 8px; }
.date3 label { display: block; }
.result .cover-fallback { padding: 5px 4px; }
.result .cover-fallback b { font-size: 8px; }
.result .cover-fallback i { font-size: 6px; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea { font-size: 16px; }
a { color: var(--print); }
h1, h2, h3 { font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: calc(var(--top) + 80px) 24px; text-align: center; color: var(--muted); }

/* Page shell */
.page { min-height: 100vh; padding: calc(var(--top) + 20px) 20px calc(var(--nav-h) + var(--bottom) + 32px); max-width: 640px; margin: 0 auto; }
.page.no-nav { padding-bottom: calc(var(--bottom) + 32px); }
.page-title { font-size: 28px; color: var(--sage); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }

/* Bottom nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + var(--bottom)); padding: 8px 8px var(--bottom);
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
}
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.nav a[aria-current="page"] { color: var(--sage); }
.nav svg { width: 24px; height: 24px; }

/* Buttons */
.btn { min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--terracotta); border-color: var(--terracotta); color: #FFFFFF; }
.btn.big { width: 100%; min-height: 54px; border-radius: 27px; font-size: 17px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.6; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.link-btn { min-height: 44px; border: 0; background: transparent; padding: 0; color: var(--print); font-weight: 600; font-size: 15px; text-align: left; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; border: 0; background: transparent; padding: 0; color: var(--muted); font-weight: 600; text-decoration: none; }
.back svg { width: 20px; height: 20px; }
.fab { position: fixed; right: max(20px, calc(50vw - 300px)); bottom: calc(var(--nav-h) + var(--bottom) + 18px); z-index: 15; width: 58px; height: 58px; border-radius: 29px; border: 0; background: var(--terracotta); color: #FFFFFF; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(46,42,38,0.25); text-decoration: none; }
.fab svg { width: 26px; height: 26px; }

/* Inputs */
.search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; flex: 1; min-width: 0; }
.search svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 10px 0; }
.search.focus { border: 2px solid var(--print); }
.field { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 10px; align-items: center; }
.field > span { font-size: 14px; color: var(--muted); }
.input, .textarea, .select { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
.textarea { min-height: 120px; font-weight: 400; line-height: 1.5; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--print); outline-offset: -1px; }
.hm { display: flex; gap: 8px; align-items: center; }
.hm .input { width: 72px; }
.seg { padding: 3px; border-radius: 12px; background: var(--track); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }
.seg button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--sage); box-shadow: 0 1px 3px rgba(46,42,38,0.12); }
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; }

/* Library */
.sortline { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); margin: 12px 0 10px; gap: 8px; }
.sortline strong { color: var(--ink); font-weight: 600; }
.chips-active { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cover-tile { position: relative; display: block; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; box-shadow: 0 2px 6px rgba(46,42,38,0.18); text-decoration: none; background: var(--track); }
.cover-tile img, .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-fallback { width: 100%; height: 100%; padding: 12px 10px; display: flex; flex-direction: column; justify-content: space-between; }
.cover-fallback b { font-weight: 600; font-size: 14px; line-height: 1.15; }
.cover-fallback i { font-style: normal; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.corner { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 12px; background: #FFFFFF; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.corner svg { width: 12px; height: 12px; }
.section-rule { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.section-rule span { font-size: 17px; font-weight: 600; color: var(--sage); }
.section-rule::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.empty { text-align: center; padding: 48px 12px; color: var(--muted); }
.empty h2 { color: var(--ink); font-size: 19px; margin-bottom: 6px; }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 14px; font-size: 14px; font-weight: 600; border: 0; }
.chip.genres { background: var(--chip-genre-bg); color: var(--chip-genre-fg); }
.chip.moods { background: var(--chip-mood-bg); color: var(--chip-mood-fg); }
.chip.tags { background: var(--chip-tag-bg); color: var(--chip-tag-fg); }
.chip.themes, .chip.writing_style, .chip.plain, .chip.audience, .chip.pacing { background: var(--chip-theme-bg); color: var(--chip-theme-fg); }
.chip.toggle { background: var(--bg); border: 1px solid var(--line); color: var(--ink); min-height: 36px; }
.chip.toggle[aria-pressed="true"] { background: var(--sage); border-color: var(--sage); color: #FFFFFF; }
.chip .x { width: 20px; height: 20px; border: 0; background: transparent; padding: 0; margin-right: -6px; display: inline-flex; align-items: center; justify-content: center; color: inherit; opacity: 0.8; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* Pick list */
.pick { display: flex; flex-direction: column; gap: 6px; }
.pick-box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 44px; padding: 5px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.pick-box input { flex: 1; min-width: 120px; border: 0; background: transparent; outline: none; padding: 6px 4px; }
.pick-menu { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); box-shadow: 0 6px 18px rgba(46,42,38,0.12); max-height: 240px; overflow-y: auto; }
.pick-menu button { display: block; width: 100%; text-align: left; min-height: 44px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--track); background: transparent; }
.pick-menu button:last-child { border-bottom: 0; }
.pick-menu .add { color: var(--print); font-weight: 600; }

/* Sheet */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(46,42,38,0.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 10px 20px calc(var(--bottom) + 24px); display: flex; flex-direction: column; gap: 18px; }
.grabber { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); flex: none; }
.sheet h2 { font-size: 22px; color: var(--sage); }
.filter-group { display: flex; flex-direction: column; gap: 8px; }
.fold-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); text-align: left; color: var(--ink); }
.fold-hint { display: flex; align-items: center; gap: 4px; color: var(--print); font-weight: 600; font-size: 14px; flex: none; }
.fold-hint svg { width: 16px; height: 16px; transition: transform 0.15s; }
.fold-btn[aria-expanded="true"] .fold-hint svg { transform: rotate(180deg); }

/* Add book */
.result { display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.result .cover { width: 46px; height: 68px; flex: none; border-radius: 4px; overflow: hidden; box-shadow: 0 1px 3px rgba(46,42,38,0.2); background: var(--track); }
.result-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.result-text b { font-weight: 600; }
.result svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.owned-wrap { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.owned-wrap .result { border-bottom: 0; text-decoration: none; color: inherit; padding-bottom: 4px; }
.owned-badge { align-self: flex-start; margin-top: 4px; padding: 3px 9px; border-radius: 999px; background: var(--sage-soft); color: var(--sage); font-size: 12px; font-weight: 600; }
.add-anyway { min-height: 32px; font-size: 13px; color: var(--muted); padding-left: 58px; }
.confirm-top { display: flex; gap: 16px; align-items: flex-end; }
.confirm-cover { flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.confirm-cover .cover { width: 104px; height: 156px; border-radius: 6px; overflow: hidden; box-shadow: 0 4px 12px rgba(46,42,38,0.2); background: var(--track); }
.collapse { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 56px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); text-align: left; }
.collapse svg { width: 18px; height: 18px; color: var(--muted); transition: transform 0.15s; }
.collapse[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Book page */
.book-head { display: flex; gap: 16px; align-items: flex-start; margin: 4px 0 18px; }
.book-head .cover { flex: none; width: 118px; height: 177px; border-radius: 6px; overflow: hidden; box-shadow: 0 4px 12px rgba(46,42,38,0.25); background: var(--track); }
.book-head h1 { font-size: 23px; line-height: 1.15; }
.badge { display: inline-flex; align-self: flex-start; padding: 4px 10px; border-radius: 12px; background: var(--sage-soft); color: var(--sage); font-size: 13px; font-weight: 600; }
.tabs { padding: 4px; border-radius: 22px; background: var(--track); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-bottom: 20px; }
.tabs button { min-height: 38px; border: 0; border-radius: 18px; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); }
.tabs.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tabs.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tabs button[aria-selected="true"] { background: var(--bg); color: var(--sage); box-shadow: 0 1px 3px rgba(46,42,38,0.15); }
.info-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--track); font-size: 15px; }
.info-row span:first-child { color: var(--muted); }
.info-row span:last-child { font-weight: 600; }
.h2 { font-size: 19px; color: var(--sage); }
.synopsis { white-space: pre-line; color: var(--ink-2); line-height: 1.55; margin: 0; }
.soon { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px 18px; text-align: center; color: var(--muted); }
.soon h2 { color: var(--ink); font-size: 18px; margin-bottom: 6px; }

/* Settings + sign-in */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.signin { max-width: 400px; margin: 0 auto; padding: calc(var(--top) + 64px) 24px 40px; display: flex; flex-direction: column; gap: 16px; }
.signin h1 { font-size: 30px; color: var(--sage); }
.signin label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--bottom) + 90px); transform: translateX(-50%); z-index: 60; background: var(--ink); color: #FFFFFF; padding: 10px 16px; border-radius: 20px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }

/* Reading log */
.month-pick { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 8px; margin-bottom: 16px; }
.day-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day-head h2 { font-size: 18px; }
.day-totals { display: flex; gap: 12px; font-size: 14px; font-weight: 600; }
.log-table { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.log-row { display: grid; grid-template-columns: minmax(0, 1fr) 56px 70px; gap: 8px; padding: 9px 0; align-items: baseline; text-decoration: none; color: var(--ink); font-size: 15px; border-bottom: 1px solid var(--track); }
.log-row:last-child { border-bottom: 0; }
.log-row span:nth-child(2), .log-row span:nth-child(3) { text-align: right; }
.log-head { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 8px 0 4px; }
.log-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash { color: var(--faint); }
.book-choices { display: flex; flex-direction: column; gap: 8px; }
.book-pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); text-align: left; }
.book-pick[aria-pressed="true"] { border-color: var(--print); }
.book-pick.new { border-style: dashed; background: var(--bg); }
.book-pick .plus { width: 34px; height: 50px; border-radius: 4px; background: var(--track); display: flex; align-items: center; justify-content: center; color: var(--print); flex: none; }
.book-pick .plus svg { width: 18px; height: 18px; }
.cover.mini { width: 34px; height: 50px; border-radius: 4px; overflow: hidden; flex: none; background: var(--track); }
.cover.mini .cover-fallback { padding: 4px; }
.cover.mini .cover-fallback b { font-size: 6px; }
.cover.mini .cover-fallback i { display: none; }
.pick-text { display: flex; flex-direction: column; min-width: 0; }
.pick-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-line { display: flex; align-items: center; gap: 8px; }
.input.pos { width: 110px; font-size: 24px; min-height: 52px; }
.input.pos.short { width: 66px; }
.input.pos.print { border: 2px solid var(--print); }
.input.pos.audio { border: 2px solid var(--audio-bar); }
.hist-row { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.hist-nums { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1.2fr); gap: 8px; align-items: end; }
.hist-time { display: flex; flex-direction: column; gap: 3px; }
.hist-time label { flex: 1; min-width: 0; }
.hist-nums .input, .hist-nums .select { padding: 8px; }
.hist-nums label { display: flex; flex-direction: column; gap: 3px; }
.tiny { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; }

/* Journal, quotes, archive */
.review { min-height: 140px; font-style: italic; }
.note-card { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.note-body { white-space: pre-line; line-height: 1.5; font-size: 15px; }
.note-row { display: flex; align-items: stretch; gap: 4px; position: relative; }
.note-row .note-card { flex: 1; min-width: 0; }
.grip { flex: none; width: 30px; display: flex; align-items: center; justify-content: center; color: var(--faint); touch-action: none; cursor: grab; border-radius: 10px; }
.grip svg { width: 20px; height: 20px; }
.note-row.dragging { z-index: 5; }
.note-row.dragging .note-card { box-shadow: 0 6px 18px rgba(46,42,38,0.18); border-color: var(--print-bar); }
.note-row.dragging .grip { color: var(--print); cursor: grabbing; }
mark { background: #F6E3B8; color: inherit; border-radius: 3px; padding: 0 1px; }
.quote-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 8px 6px 16px; display: flex; flex-direction: column; gap: 6px; }
.quote-text { border: 0; background: transparent; padding: 0 8px 0 0; text-align: left; font-style: italic; font-size: 17px; line-height: 1.5; color: var(--ink); white-space: pre-line; }
.quote-input { font-style: italic; }
.star-btn { width: 44px; height: 44px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; }
.fab-inline { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--terracotta); color: #FFFFFF; display: flex; align-items: center; justify-content: center; flex: none; }
.fab-inline svg { width: 20px; height: 20px; }
.arch-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.arch-card > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; }
.arch-card > summary::-webkit-details-marker, details.sub > summary::-webkit-details-marker { display: none; }
.arch-card > summary svg { width: 18px; height: 18px; color: var(--muted); flex: none; transition: transform 0.15s; }
.arch-card[open] > summary svg { transform: rotate(180deg); }
details.sub > summary { list-style: none; color: var(--print); font-weight: 600; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat b { font-size: 26px; font-weight: 600; color: var(--print); }
.stat span { font-size: 13px; color: var(--muted); }
.caw-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 28px; gap: 10px; align-items: center; font-size: 14px; }
.caw-row b { text-align: right; font-weight: 600; }
.caw-bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.caw-bar span { display: block; height: 8px; border-radius: 4px; background: var(--audio-bar); }
.fav-author { border-bottom: 1px solid var(--line); }
.fav-head { width: 100%; min-height: 62px; border: 0; background: transparent; padding: 0; display: flex; justify-content: space-between; align-items: center; text-align: left; }
.fav-head svg { width: 20px; height: 20px; color: var(--muted); transition: transform 0.15s; }
.fav-head[aria-expanded="true"] svg { transform: rotate(90deg); }
.fav-book { width: 100%; border: 0; background: transparent; padding: 6px 0; display: flex; align-items: center; gap: 12px; text-align: left; }
.fav-book svg { width: 18px; height: 18px; color: var(--muted); transition: transform 0.15s; }
.fav-book[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Stats */
.st-boxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.st-boxes.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.st-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; text-align: left; font: inherit; color: var(--ink); }
.st-box b { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.st-box span { font-size: 13px; color: var(--muted); }
.st-box .tiny { font-size: 12px; font-weight: 400; }
.st-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.st-card h2 { margin: 0; font-size: 17px; font-weight: 600; }
.st-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.legend { display: flex; gap: 10px; font-size: 12px; color: var(--muted); flex: none; }
.legend span { display: flex; align-items: center; gap: 4px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.st-detail { background: #FFFFFF; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.mbars { display: flex; gap: 4px; align-items: flex-end; overflow-x: auto; }
.mbar { flex: 1; min-width: 22px; padding: 4px 0; border: 0; border-radius: 8px; background: transparent; display: flex; flex-direction: column; align-items: stretch; gap: 3px; font: inherit; }
.mbars.dense .mbar { min-width: 30px; }
.mbar[aria-pressed="true"] { background: #E4EBDD; }
.mbar-plot { display: flex; align-items: flex-end; padding: 0 2px; }
.mcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; }
.mcol i { font-style: normal; font-size: 10px; font-weight: 600; }
.mcol > span { align-self: stretch; display: block; }
.mbar-plot > span:not(.mcol) { display: block; }
.mlabel { font-size: 11px; color: var(--muted); text-align: center; }
.st-fold { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.fold-head { width: 100%; min-height: 52px; padding: 0 14px; border: 0; background: var(--card); display: flex; justify-content: space-between; align-items: center; font: inherit; color: var(--ink); }
.fold-head svg { width: 20px; height: 20px; color: var(--muted); transition: transform 0.15s; }
.fold-head[aria-expanded="true"] svg { transform: rotate(180deg); }
.fold-body { padding: 12px 0 14px 14px; display: flex; flex-direction: column; gap: 8px; background: #FFFFFF; }
.day-cards { display: flex; gap: 10px; overflow-x: auto; padding-right: 14px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.day-chart { flex: none; width: min(320px, calc(100vw - 72px)); scroll-snap-align: start; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--card); display: flex; flex-direction: column; gap: 6px; }
.drow { display: grid; grid-template-columns: 22px minmax(0, 1fr) 78px; gap: 6px; align-items: center; height: 20px; border-bottom: 1px solid transparent; }
.drow.wk { border-bottom-color: var(--line); }
.dnum { font-size: 11px; color: var(--muted); text-align: right; }
.dbars { display: flex; flex-direction: column; }
.dbars span { display: block; height: 7px; }
.dtext { font-size: 11px; font-weight: 600; white-space: nowrap; }
.st-pies { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.st-card.pie { padding: 12px; }
.st-card.pie h2 { font-size: 15px; }
.pie-disc { align-self: center; width: 96px; height: 96px; border-radius: 48px; }
.pie-row { display: flex; align-items: center; gap: 6px; font: inherit; font-size: 12px; border: 0; background: transparent; padding: 3px 0; text-align: left; color: var(--ink); min-height: 28px; }
.pie-row .sw { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.seg.mini { padding: 2px; border-radius: 10px; flex: none; }
.seg.mini button { min-height: 28px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.big-pie { display: flex; align-items: center; gap: 16px; }
.big-pie .pie-disc { width: 120px; height: 120px; border-radius: 60px; flex: none; }
.big-pie .pie-row { font-size: 13px; min-height: 30px; }
.rank-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 26px; gap: 8px; align-items: center; font: inherit; font-size: 13px; border: 0; background: transparent; padding: 4px 0; text-align: left; color: var(--ink); min-height: 30px; }
.rank-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row b { text-align: right; font-weight: 600; }
.st-card.wide .rank-row { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 26px; }
.rank-track { height: 10px; border-radius: 5px; background: #EDF1E7; overflow: hidden; display: block; }
.rank-track span { display: block; height: 10px; border-radius: 5px; }
.sheet-book { display: flex; align-items: center; gap: 12px; padding: 8px 0; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); min-height: 60px; }
.sheet-book svg { width: 18px; height: 18px; color: var(--muted); flex: none; }

.pick-sep { border: 0; border-top: 2px solid #C5CDBA; margin: 0 10px; }
.pick-menu button:has(+ .pick-sep) { border-bottom: 0; }

/* Progress bar */
.pbar-wrap { position: relative; padding: 0 2px; }
.pb-labels { position: relative; height: 16px; font-size: 11px; color: var(--muted); }
.pb-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-weight: 600; }
.pb-labels.bot span { font-weight: 400; }
.pbar { position: relative; display: flex; height: 30px; border-radius: 6px; background: #EDF1E7; overflow: hidden; touch-action: pan-y; cursor: pointer; margin: 2px 0; }
.pb-chunk { flex: none; height: 100%; border-right: 2px solid var(--card); box-sizing: border-box; transition: filter 0.1s; }
.pb-chunk.on { filter: brightness(1.18) saturate(1.1); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.75); }
.pb-tip { position: absolute; top: -50px; transform: translateX(-50%); background: #2E2A26; color: #FFFFFF; border-radius: 10px; padding: 6px 10px; font-size: 12px; display: flex; flex-direction: column; align-items: center; white-space: nowrap; pointer-events: none; z-index: 2; box-shadow: 0 4px 12px rgba(0,0,0,0.18); }
.pb-tip[hidden] { display: none; }
.pb-tip b { font-weight: 600; font-size: 13px; }

.pb-chunk:last-child { border-right: 0; }

/* Year at a glance */
.cal-months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 8px; }
.cal-month { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-month > b { font-size: 12px; font-weight: 600; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 1px; font-size: 9px; text-align: center; }
.cal-grid i { font-style: normal; font-weight: 600; color: var(--muted); background: #D6E3DD; line-height: 13px; }
.cal-grid span, .cal-dot { line-height: 15px; height: 15px; display: flex; align-items: center; justify-content: center; }
.cal-dot { border: 0; padding: 0; font: inherit; font-size: 9px; font-weight: 600; color: #FFFFFF; background: #9CA37E; border-radius: 50%; width: 15px; margin: 0 auto; }
.cal-dot.two { background: #7A8450; color: #FFFFFF; }
.days-grid { display: grid; grid-template-columns: 18px repeat(12, minmax(0, 1fr)); gap: 1px; }
.days-grid > * { height: 15.6px; }
.dg-num { font-size: 9px; color: var(--muted); text-align: right; padding-right: 3px; line-height: 15.6px; }
.dg-on { border: 0; padding: 0; background: #B7B98A; border-radius: 2px; }
.dg-off { background: #EDF1E7; border-radius: 2px; }
.dg-off.future { background: transparent; outline: 1px solid #EDF1E7; outline-offset: -1px; }
.dg-none { background: transparent; }
.days-grid .dg-mon { height: auto; font-size: 9px; color: var(--muted); text-align: center; padding-top: 3px; }
.cal-grid i:first-child { border-radius: 7px 0 0 7px; }
.cal-grid i:nth-child(7) { border-radius: 0 7px 7px 0; }
.cal-grid i:nth-child(-n+7) { margin-bottom: 2px; }

.st-card.glance { padding: 14px 0 10px; }
.glance-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; align-items: flex-start; overflow-y: hidden; transition: height 0.25s ease; }
.glance-track::-webkit-scrollbar { display: none; }
.glance-panel { flex: 0 0 100%; scroll-snap-align: start; box-sizing: border-box; padding: 0 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.glance-dots { display: flex; justify-content: center; gap: 4px; }
.glance-dots button { width: 28px; height: 28px; border: 0; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; }
.glance-dots button::after { content: ''; width: 8px; height: 8px; border-radius: 4px; background: #D5DCCB; }
.glance-dots button[aria-selected="true"]::after { background: #4F6447; width: 18px; }

.dnf-link-row { display: flex; justify-content: center; margin: 22px 0 8px; }
.dnf-link-row .link-btn { color: var(--muted); font-weight: 600; font-size: 14px; }

/* Genre taste (update 32) */
.gt-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.gt-key { display: flex; align-items: center; gap: 8px; font: inherit; font-size: 13px; border: 0; background: transparent; padding: 2px 0; text-align: left; color: var(--ink); min-height: 36px; min-width: 0; }
.gt-key .gt-kname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gt-key b { font-weight: 600; }
.gt-tick { width: 4px; height: 26px; border-radius: 2px; flex: none; }
.gt-chart { width: 100%; height: auto; display: block; overflow: visible; }
.gt-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.gt-axis { font-size: 11px; fill: var(--muted); font-family: inherit; }
.gt-line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.gt-dot { stroke: var(--card); stroke-width: 1.5; }
.gt-rows { display: flex; flex-direction: column; gap: 4px; }
.gt-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 40px; gap: 8px; align-items: center; font: inherit; font-size: 13px; border: 0; background: transparent; padding: 4px 0; text-align: left; color: var(--ink); min-height: 34px; }
.gt-row .gt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gt-row b { text-align: right; font-weight: 600; }
.gt-bars { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.gt-bar { display: block; height: 9px; border-radius: 4px; background: #7A8450; }
.gt-bar.prev { height: 6px; background: #D5DCCB; }

/* Series tracker */
.sr-row { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-top: 1px solid var(--line); background: transparent; padding: 10px 0; text-align: left; font: inherit; color: var(--ink); }
.sr-row:first-child { border-top: 0; padding-top: 2px; }
.sr-row b { font-weight: 600; font-size: 15px; }
.sr-dots { display: flex; flex-wrap: wrap; gap: 3px; max-width: 96px; justify-content: flex-end; flex: none; }
.sr-dots i { width: 10px; height: 10px; border-radius: 3px; background: var(--track); border: 1px solid var(--line); }
.sr-dots i.done { background: #7A8450; border-color: #7A8450; }
.sr-dots i.now { background: #D3A06A; border-color: #D3A06A; }

/* Best and worst */
.bw-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.bw-row:first-child { border-top: 0; padding-top: 0; }
.bw-month { width: 44px; flex: none; font-size: 13px; font-weight: 600; color: var(--muted); padding-top: 4px; }
.bw-line { display: flex; align-items: center; gap: 8px; min-height: 30px; text-decoration: none; color: var(--ink); font-size: 14px; }
.bw-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bw-tag { flex: none; width: 44px; text-align: center; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 0; }
.bw-tag.best { background: var(--sage-soft); color: var(--sage); }
.bw-tag.worst { background: #F4E2D9; color: #8E4F43; }
.bw-top { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; margin-bottom: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.bw-top .label { margin-bottom: 4px; }
.bw-fold { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); }
.bw-fold svg { width: 18px; height: 18px; color: var(--muted); transition: transform 0.15s; }
.bw-fold[aria-expanded="true"] svg { transform: rotate(180deg); }
.bw-top { margin-bottom: 0; }
.bw-tag.wide { width: 66px; }
.miss-badge { position: absolute; left: 6px; bottom: 6px; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,0.92); color: #8E4F43; font-size: 11px; font-weight: 600; box-shadow: 0 1px 3px rgba(46,42,38,0.2); }
.soon-pie .pie-disc { background: var(--track); border: 2px dashed var(--line); box-sizing: border-box; }
.soon-pie h2 { color: var(--muted); }
.rev-head { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 0; text-align: left; font: inherit; color: var(--ink); }
.rev-head svg { width: 20px; height: 20px; color: var(--muted); flex: none; transition: transform 0.15s; }
.rev-head[aria-expanded="true"] svg { transform: rotate(180deg); }
.rev-peek { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-quote { font-style: italic; font-size: 15px; line-height: 1.5; color: var(--ink-2); border-left: 3px solid var(--audio-bar); padding: 2px 0 2px 10px; white-space: pre-line; }

/* Reading log as one table */
.log-sheet { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.sheet-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 40px 50px 54px; gap: 6px; align-items: center; padding: 7px 10px; text-decoration: none; color: var(--ink); font-size: 14px; min-height: 36px; box-sizing: border-box; }
.sheet-row.first { border-top: 1px solid var(--line); }
.sheet-row.alt { background: #FFFFFF; }
.sheet-head { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); min-height: 32px; background: var(--sage-soft); }
.sheet-total { border-top: 2px solid var(--line); font-weight: 600; background: var(--sage-soft); }
.sh-date { display: flex; flex-direction: column; line-height: 1.1; }
.sh-date b { font-size: 15px; font-weight: 600; }
.sh-date i { font-style: normal; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sh-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-num { text-align: right; font-variant-numeric: tabular-nums; }
.sh-num.aud { color: var(--audio); }
.sheet-row > :nth-child(5) { border-left: 1px solid var(--line); padding-left: 6px; align-self: stretch; margin: -7px 0; padding-top: 7px; padding-bottom: 7px; }
.sh-tot { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; line-height: 1.15; font-variant-numeric: tabular-nums; }
.sh-tot b { font-weight: 600; font-size: 14px; }
.sh-tot b.aud { color: var(--audio); font-size: 13px; }
.book-pick[hidden] { display: none !important; }

/* ---------- Tarot Journal ---------- */
.nav.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.faint { color: var(--faint); }
.deck-tile { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); min-width: 0; }
.deck-tile .cover-tile { box-shadow: 0 2px 6px rgba(46,42,38,0.18); }
.deck-tile-name { font-weight: 600; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.deck-tile-sub { font-size: 12px; color: var(--muted); }
.grid { row-gap: 16px; }

.deck-head { display: flex; gap: 14px; align-items: flex-start; margin: 4px 0 14px; }
.deck-head .cover { position: relative; flex: none; width: 84px; height: 126px; border-radius: 6px; overflow: hidden; box-shadow: 0 3px 10px rgba(46,42,38,0.22); background: var(--track); }
.deck-head h1 { font-size: 22px; line-height: 1.15; }
.about { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; }
.about summary { color: var(--print); font-weight: 600; cursor: pointer; min-height: 28px; }
.about p { margin-top: 8px; }
.sticky-search { position: sticky; top: var(--top); z-index: 10; background: var(--bg); padding: 8px 0; margin: 0 -4px; padding-left: 4px; padding-right: 4px; display: flex; }

.clist { display: flex; flex-direction: column; }
.crow { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 0; border-bottom: 1px solid var(--track); text-decoration: none; color: var(--ink); }
.crow:last-child { border-bottom: 0; }
.crow > svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.crow-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.crow-text b { font-weight: 600; }
.snip { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.snip b { font-weight: 600; color: var(--ink-2); }
.snip.faint { color: var(--faint); }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--terracotta); flex: none; }

.cthumb { position: relative; flex: none; width: 36px; height: 60px; border-radius: 4px; overflow: hidden; background: color-mix(in srgb, var(--c) 14%, #FFFFFF); border: 1px solid color-mix(in srgb, var(--c) 30%, #FFFFFF); display: flex; align-items: center; justify-content: center; }
.cthumb span { font-size: 11px; font-weight: 600; color: var(--c); }
.cthumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cthumb.small { width: 26px; height: 43px; }
.cthumb.small span { font-size: 9px; }

.add-extra { margin-top: 12px; width: 100%; color: var(--print); }

.card-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; margin-top: 6px; }
.card-head h1 { font-size: 25px; color: var(--sage); margin-top: 8px; }
.card-photo { width: min(62vw, 250px); aspect-ratio: 7 / 12; object-fit: cover; border-radius: 10px; box-shadow: 0 4px 14px rgba(46,42,38,0.25); background: var(--track); }
.empty-photo { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--c); background: color-mix(in srgb, var(--c) 10%, #FFFFFF); border: 2px dashed color-mix(in srgb, var(--c) 35%, #FFFFFF); box-shadow: none; font-weight: 600; font-size: 14px; }
.empty-photo svg { width: 28px; height: 28px; }
.card-head .empty-photo { width: 150px; }
.nfield { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.chip.kw { background: var(--chip-tag-bg); color: var(--chip-tag-fg); }
.chip.kw b { font-weight: 600; opacity: 0.7; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 26px; }
.pager .btn { flex: 1; min-width: 0; font-size: 14px; padding: 0 10px; }
.pager .btn svg { width: 18px; height: 18px; flex: none; }
.pager .btn:last-child { justify-content: flex-end; }
.pager .btn:first-child { justify-content: flex-start; }
.btn svg { width: 18px; height: 18px; flex: none; }

.photo-pick { display: flex; gap: 16px; align-items: center; }
.photo-preview { position: relative; display: flex; width: 96px; height: 164px; flex: none; border-radius: 8px; overflow: hidden; object-fit: cover; box-shadow: 0 3px 10px rgba(46,42,38,0.2); background: var(--track); }
.photo-preview.empty-photo { box-shadow: none; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview.cover { height: 144px; }
#kw-box input { min-width: 140px; }

.hit { border-bottom: 1px solid var(--line); padding: 10px 0; }
.hit-head { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 48px; }
.hit-head b { flex: 1; font-size: 17px; color: var(--sage); }
.hit-head > svg { width: 18px; height: 18px; color: var(--muted); }
.hit-row { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); padding: 8px 0 8px 36px; }
.hit-deck { font-weight: 600; font-size: 14px; }

.compare-seg { margin: 4px 0 14px; }
.compare-seg button { font-size: 13px; padding: 0 2px; }
.shared { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.cmp-card { border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cmp-card .nfield { background: var(--bg); border: 0; border-top: 1px solid var(--track); border-radius: 0; padding: 8px 2px 0; }
.cmp-head { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.cmp-head b { font-size: 17px; color: var(--sage); }
.cmp-head > svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.cmp-photo { width: 60px; height: 103px; object-fit: cover; border-radius: 6px; flex: none; box-shadow: 0 2px 6px rgba(46,42,38,0.2); }
a.btn { text-decoration: none; color: var(--ink); }
a.btn.primary { color: #FFFFFF; }
a.btn.add-extra { color: var(--print); }
.input::placeholder, .textarea::placeholder, .pick-box input::placeholder { color: var(--faint); font-weight: 400; }
