/* BookVoyage — app styles. Warm paper palette, system type, phone-first with a comfortable desktop column. */
:root {
  --bg: #f4f1ea; --card: #ffffff; --ink: #1d1a16; --muted: #6f6a60; --line: #e6e1d6; --chip: #efe9dc;
  --accent: #8a3b2f; --accent-ink: #ffffff; --accent-soft: #f3e3df; --ok: #2f6b3a; --ok-soft: #e4f1e6;
  --warn: #8a5a00; --warn-soft: #f6ecd2; --star: #c9a227;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 10px 30px rgba(0,0,0,.06);
  --r: 16px; --r-sm: 10px; --tab-h: 64px;
  --sa-top: env(safe-area-inset-top, 0px); --sa-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15130f; --card: #201d18; --ink: #f1ece2; --muted: #a39d90; --line: #332e26; --chip: #2a251e;
          --accent: #d9735f; --accent-ink: #1a0d0a; --accent-soft: #3a221c; --ok: #7fc18c; --ok-soft: #1f3324;
          --warn: #e0b35a; --warn-soft: #3a2f12; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
       font: 16px/1.4 -apple-system, "SF Pro Text", Inter, system-ui, sans-serif; overscroll-behavior-y: none; }
a { color: var(--accent); }
a.card, a.item { color: inherit; text-decoration: none; }     /* cards that happen to be links look like cards */
button { font: inherit; cursor: pointer; }
img { display: block; }

/* layout */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); padding-top: var(--sa-top); }
.top-inner { max-width: 640px; margin: 0 auto; padding: 10px 18px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 28px; letter-spacing: -.02em; margin: 0; line-height: 1.15; }
.sub { color: var(--muted); font-size: 13px; min-height: 16px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px; display: grid; place-items: center; flex: none; }
main { max-width: 640px; margin: 0 auto; padding: 4px 16px calc(var(--tab-h) + var(--sa-bottom) + 28px); min-height: 60vh; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: center; gap: 0; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + var(--sa-bottom)); }
.tabs a { flex: 1; max-width: 128px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; padding: 4px 0; }
.tabs a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--accent); }
.tabs a.cap { color: var(--muted); position: relative; }
.tabs a.cap.dot .cap-btn::after { content: ''; position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--warn); border: 2px solid var(--bg); }
.cap-btn { position: relative; }
.tabs .cap-btn { width: 46px; height: 46px; margin-top: -22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: var(--shadow); }
.tabs .cap-btn svg { stroke: currentColor; stroke-width: 2.4; }
.offline { background: var(--warn-soft); color: var(--warn); font-size: 13px; text-align: center; padding: 8px 12px; }

/* building blocks */
.card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.tap { cursor: pointer; transition: transform .08s ease; }
.card.tap:active { transform: scale(.985); }
.row { display: flex; gap: 12px; align-items: center; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title { font-weight: 600; font-size: 16px; line-height: 1.25; }
.by { color: var(--muted); font-size: 13px; margin-top: 2px; }
.meta { color: var(--muted); font-size: 12.5px; margin-top: 5px; line-height: 1.5; }
.h { font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 20px 0 10px; }
.h small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.cover { width: 52px; height: 78px; border-radius: 6px; background: var(--chip); object-fit: cover; flex: none; }
.cover.lg { width: 72px; height: 108px; border-radius: 8px; }
.cover.ph { display: grid; place-items: center; font-size: 11px; color: var(--muted); text-align: center; padding: 4px; line-height: 1.2; }
.chip { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); margin: 2px 4px 0 0; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.acc { background: var(--accent-soft); color: var(--accent); }
.stars { color: var(--star); letter-spacing: 1px; font-size: 14px; }
.stars.pick span { cursor: pointer; font-size: 30px; padding: 2px; }
.btn svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* any inline icon inside a card or row is an icon, never a hero image */
.card > svg, .row > svg, .empty > svg { width: 26px; height: 26px; flex: none; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 600; font-size: 16px; background: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--chip); color: var(--ink); font-weight: 500; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.link { background: none; color: var(--accent); padding: 6px 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
input[type=text], input[type=search], input[type=url], input[type=email], textarea, select { width: 100%; box-sizing: border-box; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 12px 13px; font: inherit; -webkit-appearance: none; appearance: none; }
input[type=search]::-webkit-search-decoration, input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px var(--card) inset; -webkit-text-fill-color: var(--ink); caret-color: var(--ink); transition: background-color 9999s ease-out 0s; }
/* recent searches under a search field */
.recent { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 15; overflow: hidden; }
.recent button { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; background: none; border: 0; padding: 11px 14px; color: var(--ink); font: inherit; border-top: 1px solid var(--line); }
.recent button:first-child { border-top: 0; } .recent button span { color: var(--muted); font-size: 12px; margin-left: auto; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 72px; resize: vertical; }
label.lbl { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
.seg { display: flex; background: var(--chip); border-radius: 12px; padding: 3px; margin: 6px 0 14px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 0; border-radius: 10px; font-size: 13.5px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.search { position: relative; margin: 4px 0 12px; }
.search input { padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }
.bar { height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; margin: 10px 0; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 15px; }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
details summary { cursor: pointer; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--chip); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.quiet { color: var(--muted); font-size: 13px; }

/* skeletons and empty states */
.skel { background: linear-gradient(90deg, var(--chip) 25%, color-mix(in srgb, var(--chip) 60%, var(--card)) 50%, var(--chip) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-row { display: flex; gap: 12px; align-items: center; padding: 14px; background: var(--card); border-radius: var(--r); margin-bottom: 12px; }
.skel-row .skel.cover { width: 52px; height: 78px; }
.skel-row .lines { flex: 1; } .skel-row .lines .skel { height: 12px; margin: 6px 0; }
.empty { text-align: center; padding: 44px 24px; color: var(--muted); }
.empty svg { width: 72px; height: 72px; stroke: var(--muted); fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; opacity: .7; margin-bottom: 10px; }
.empty .title { color: var(--ink); margin-bottom: 4px; }

/* sheets and toasts */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; border-radius: 22px 22px 0 0; padding: 10px 18px calc(26px + var(--sa-bottom)); max-height: 90vh; overflow-y: auto; animation: up .2s ease; }
.sheet .handle { width: 40px; height: 4px; background: var(--line); border-radius: 2px; margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } } @keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + var(--sa-bottom) + 12px); z-index: 30; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); max-width: 560px; animation: up .2s ease; }

/* home */
.hero { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000)); color: #fff; border-radius: 20px; padding: 18px; margin: 6px 0 16px; }
.hero h2 { margin: 0 0 4px; font-size: 20px; } .hero p { margin: 0 0 12px; opacity: .9; font-size: 14px; }
.hero .btn { background: #fff; color: var(--accent); }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.quick .card { margin: 0; display: flex; gap: 10px; align-items: center; }
.quick svg { width: 26px; height: 26px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shelf { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x mandatory; }
.shelf .item { flex: none; width: 92px; scroll-snap-align: start; text-decoration: none; color: inherit; }
.shelf .item .cover { width: 92px; height: 138px; border-radius: 8px; box-shadow: var(--shadow); }
.shelf .item .t { font-size: 12px; margin-top: 6px; line-height: 1.25; max-height: 2.5em; overflow: hidden; }

/* capture */
.cand .ev { font-style: italic; }
.scan { position: relative; border-radius: var(--r); overflow: hidden; background: #000; aspect-ratio: 3/4; max-height: 60vh; }
.scan video { width: 100%; height: 100%; object-fit: cover; }
.scan .frame { position: absolute; inset: 18% 12%; border: 2px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan .hint { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: #fff; font-size: 13px; text-shadow: 0 1px 2px #000; }

/* desktop frame */
@media (min-width: 900px) {
  body { background: #0f0e0c; }
  .top, main, .tabs { max-width: 440px; margin-left: auto; margin-right: auto; left: 0; right: 0; }
  main { background: var(--bg); min-height: calc(100vh - 20px); }
  .top { border-radius: 26px 26px 0 0; margin-top: 10px; }
  .tabs { border-radius: 0 0 26px 26px; }
  .tabs { position: sticky; }
  body { display: flex; flex-direction: column; align-items: stretch; }
}
/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; margin-top: 10px; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -.01em; } .stat .l { font-size: 12px; color: var(--muted); }
.months { display: flex; align-items: flex-end; gap: 4px; height: 110px; margin-top: 12px; }
.months .m { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.months .bar-v { width: 100%; max-width: 26px; flex: 1; display: flex; align-items: flex-end; background: var(--chip); border-radius: 6px; overflow: hidden; }
.months .bar-v i { display: block; width: 100%; background: var(--accent); border-radius: 6px; min-height: 2px; }
.months .n { font-size: 11px; color: var(--muted); height: 14px; margin-top: 3px; } .months .l { font-size: 11px; color: var(--muted); }
.donut-wrap { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.donut { width: 118px; height: 118px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; }
.donut .hole { width: 70px; height: 70px; border-radius: 50%; background: var(--card); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.legend { display: grid; gap: 5px; font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.tagrow { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; } .tagrow::-webkit-scrollbar { display: none; }
.tagrow .chip { white-space: nowrap; text-decoration: none; font-size: 12.5px; padding: 5px 11px; }
