/* Layout: one catalog column. Sticky header with status chips, cover grid grouped by author/genre/location,
   action bar fixed at thumb height, bottom sheets for detail and add, full-screen camera scanner. */
:root {
  --paper: #F3F5F4; --card: #FFFFFF; --ink: #1A2125; --muted: #5B666B; --line: #D7DDDB; --sunk: #E8ECEA;
  --stamp: #4535A6; --stamp-soft: #EAE7F9; --on-stamp: #FFFFFF;
  --read: #2C7549; --read-soft: #E1F0E6;
  --unread: #8A5E0B; --unread-soft: #F5ECD6;
  --donate: #A32F66; --donate-soft: #F7E2EC;
  --lent: #1F5F8B; --lent-soft: #E0EDF6;
  --danger: #B42318;
  --scrim: rgba(18, 22, 26, .45); --shadow: 0 12px 32px rgba(20, 24, 40, .16); --cover-shadow: 0 1px 2px rgba(20, 24, 40, .18), 0 6px 14px rgba(20, 24, 40, .10);
  --display: "Young Serif", Georgia, "Times New Roman", serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111517; --card: #192024; --ink: #E4E9E7; --muted: #97A2A7; --line: #2A3337; --sunk: #20282C;
    --stamp: #A99DF3; --stamp-soft: #28234A; --on-stamp: #15112B;
    --read: #72C493; --read-soft: #173024;
    --unread: #E2B65E; --unread-soft: #352A12;
    --donate: #EE8AB8; --donate-soft: #3A1C2B;
    --lent: #7DB8E3; --lent-soft: #142A3A;
    --danger: #F97066;
    --scrim: rgba(0, 0, 0, .6); --shadow: 0 12px 32px rgba(0, 0, 0, .55); --cover-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 14px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111517; --card: #192024; --ink: #E4E9E7; --muted: #97A2A7; --line: #2A3337; --sunk: #20282C;
  --stamp: #A99DF3; --stamp-soft: #28234A; --on-stamp: #15112B;
  --read: #72C493; --read-soft: #173024;
  --unread: #E2B65E; --unread-soft: #352A12;
  --donate: #EE8AB8; --donate-soft: #3A1C2B;
  --lent: #7DB8E3; --lent-soft: #142A3A;
  --danger: #F97066;
  --scrim: rgba(0, 0, 0, .6); --shadow: 0 12px 32px rgba(0, 0, 0, .55); --cover-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 14px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.mono { font-family: var(--mono); }
.label { font-family: var(--mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

/* ---------- header ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--paper); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px 10px; }
.brand { min-width: 0; }
.brand h1 { font-family: var(--display); font-weight: 400; font-size: 27px; line-height: 1.05; margin: 0; letter-spacing: -.01em; overflow-wrap: anywhere; }
.tally { margin: 4px 0 0; font-family: var(--mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-variant-numeric: tabular-nums; }
.top-actions { position: relative; flex: 0 0 auto; }
.icon-btn { appearance: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; padding: 0; overflow: hidden; }
.icon-btn img { width: 100%; height: 100%; object-fit: cover; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 12; min-width: 250px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; }
.menu-user { margin: 0; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.menu-user b { display: block; color: var(--ink); font-size: 14px; }
.menu button, .menu a { appearance: none; text-align: left; background: none; border: 0; border-radius: 8px; padding: 10px; font-size: 14.5px; cursor: pointer; text-decoration: none; color: var(--ink); }
.menu button:hover, .menu a:hover { background: var(--sunk); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { appearance: none; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px; padding: 7px 13px; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip .n { font-family: var(--mono); font-weight: 500; font-size: 12px; font-variant-numeric: tabular-nums; }
.chip[data-status="read"] i { background: var(--read); }
.chip[data-status="unread"] i { background: var(--unread); }
.chip[data-status="donate"] i { background: var(--donate); }
.chip[data-status="lent"] i { background: var(--lent); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.demo-bar { background: var(--unread-soft); color: var(--ink); font-size: 12.5px; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); text-align: center; }

/* ---------- tools ---------- */
main { padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)); min-height: 60vh; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-block: 16px 4px; }
.search { flex: 1 1 260px; min-width: 0; }
input[type="search"], input[type="text"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
  width: 100%; font-size: 16px; line-height: 1.3; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
textarea { resize: vertical; min-height: 84px; }
.tool-row { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.sel { display: flex; align-items: center; gap: 8px; }
.sel select { width: auto; padding: 9px 30px 9px 11px; font-size: 14px; font-weight: 600; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg button { appearance: none; border: 0; background: transparent; padding: 9px 11px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- shelf ---------- */
.group { padding-top: 22px; }
.group-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1.5px solid var(--ink); }
.group-h h2 { font-family: var(--display); font-weight: 400; font-size: 19px; line-height: 1.25; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.group-h .c { font-family: var(--mono); font-size: 11.5px; color: var(--muted); flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 22px 14px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 28px 20px; } }
.tile-btn { appearance: none; background: none; border: 0; padding: 0; width: 100%; text-align: left; cursor: pointer; display: grid; gap: 7px; border-radius: 6px; }
.cover { position: relative; display: block; aspect-ratio: 2 / 3; width: 100%; max-width: 100%; border-radius: 4px; overflow: hidden; box-shadow: var(--cover-shadow); background: var(--sunk); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-btn:hover .cover { transform: translateY(-2px); }
.cover { transition: transform .15s ease; }
.tile-t { font-weight: 600; font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tile-a { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: -4px; }
.dot { position: absolute; top: 6px; right: 6px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.dot.s-read { background: var(--read); } .dot.s-unread { background: var(--unread); } .dot.s-donate { background: var(--donate); }
.cover.is-lent .gen { padding-bottom: 24%; }
.lent-tag { position: absolute; left: 0; right: 0; bottom: 0; background: var(--lent); color: #fff; font-size: 11px; font-weight: 600; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root[data-theme="dark"] .lent-tag { color: #0B1A26; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lent-tag { color: #0B1A26; } }

/* Generated cloth cover for books without art */
.gen { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 12% 10% 10%; color: #F3EBDD; background: var(--cloth, #2F5D50); }
.gen::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 7%; background: rgba(0, 0, 0, .18); }
.gen b { font-family: var(--display); font-weight: 400; font-size: clamp(11px, 3.4vw, 17px); line-height: 1.15; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; text-wrap: balance; }
.gen span { font-size: clamp(9px, 2.4vw, 12px); letter-spacing: .04em; opacity: .85; border-top: 1px solid rgba(243, 235, 221, .5); padding-top: 6%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (min-width: 720px) { .gen b { font-size: 16px; } .gen span { font-size: 11.5px; } }

.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 10px; padding-block: 10px; border-bottom: 1px solid var(--line); }
.row-btn { appearance: none; flex: 1 1 auto; min-width: 0; display: flex; gap: 12px; align-items: center; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; border-radius: 6px; }
.row .cover { flex: 0 0 44px; width: 44px; border-radius: 3px; }
.row .gen { padding: 10% 8%; } .row .gen b { font-size: 7px; -webkit-line-clamp: 4; } .row .gen span { display: none; }
.row-meta { min-width: 0; display: grid; gap: 2px; }
.row-t { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.row-a { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row-loc { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .03em; }
.pill { appearance: none; flex: 0 0 auto; border: 1px solid transparent; border-radius: 999px; padding: 6px 11px 6px 9px; font-weight: 600; font-size: 12.5px; line-height: 1; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-read.pill { background: var(--read-soft); color: var(--read); }
.s-unread.pill { background: var(--unread-soft); color: var(--unread); }
.s-donate.pill { background: var(--donate-soft); color: var(--donate); }
.s-lent.pill { background: var(--lent-soft); color: var(--lent); cursor: default; }

.state { padding: 44px 2px; max-width: 36rem; }
.state h2 { font-family: var(--display); font-weight: 400; font-size: 23px; margin: 0 0 8px; text-wrap: balance; }
.state p { margin: 0 0 10px; color: var(--muted); }
.steps { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: baseline; }
.steps li span { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--stamp); flex: 0 0 auto; }

/* ---------- buttons ---------- */
.btn { appearance: none; border-radius: 11px; padding: 12px 16px; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; }
.btn-primary { background: var(--stamp); border-color: var(--stamp); color: var(--on-stamp); }
.btn-sm { padding: 8px 12px; font-size: 13.5px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-link { appearance: none; background: none; border: 0; padding: 8px 2px; color: var(--stamp); font-weight: 600; cursor: pointer; font-size: 14.5px; }
.btn-danger { appearance: none; background: none; border: 0; color: var(--danger); font-weight: 600; font-size: 14.5px; padding: 10px 2px; cursor: pointer; }

.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; background: var(--paper); border-top: 1px solid var(--line); padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.actionbar .in { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.actionbar .btn-primary { flex: 1 1 auto; padding-block: 14px; font-size: 16px; }

/* ---------- sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 620px; max-height: calc(100% - 12px - env(safe-area-inset-top, 0px)); overflow: auto; overscroll-behavior: contain; border-radius: 18px 18px 0 0; box-shadow: var(--shadow); padding-top: 18px; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(28px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .overlay { align-items: center; padding: 24px; } .sheet { border-radius: 18px; padding-bottom: 22px; } }
.sheet h2 { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1.2; margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.sheet-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.x { appearance: none; border: 1px solid var(--line); background: var(--paper); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; padding: 0; }
.eyebrow { margin: 0 0 4px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--stamp); }
.stack { display: grid; gap: 16px; }
.f { display: grid; gap: 6px; min-width: 0; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.three { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, .8fr) minmax(0, .8fr); gap: 10px; }
@media (max-width: 400px) { .three { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .three > :first-child { grid-column: 1 / -1; } }
.err { margin: 0; color: var(--danger); font-size: 13.5px; }
.warn { margin: 0; font-size: 13.5px; padding: 9px 11px; border-radius: 9px; background: var(--unread-soft); color: var(--ink); }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions .sp { flex: 1 1 auto; }

.status-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.status-seg button { appearance: none; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 4px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--paper); color: var(--muted); white-space: nowrap; }
.status-seg button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-seg button[data-v="read"][aria-pressed="true"] { background: var(--read-soft); color: var(--read); border-color: var(--read); }
.status-seg button[data-v="unread"][aria-pressed="true"] { background: var(--unread-soft); color: var(--unread); border-color: var(--unread); }
.status-seg button[data-v="donate"][aria-pressed="true"] { background: var(--donate-soft); color: var(--donate); border-color: var(--donate); }

/* detail */
.d-head { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 16px; align-items: start; margin-bottom: 18px; }
@media (min-width: 700px) { .d-head { grid-template-columns: 150px minmax(0, 1fr) auto; } }
.d-cover { appearance: none; border: 0; padding: 0; background: none; cursor: pointer; display: grid; gap: 6px; text-align: center; }
.d-cover .cover { width: 100%; }
.d-cover small { font-size: 12px; color: var(--stamp); font-weight: 600; }
.d-meta { min-width: 0; display: grid; gap: 4px; }
.d-sub { margin: 0; font-size: 14px; color: var(--muted); }
.d-auth { margin: 2px 0 0; font-size: 15px; }
.d-facts { margin: 6px 0 0; font-family: var(--mono); font-size: 11.5px; color: var(--muted); line-height: 1.6; overflow-wrap: anywhere; }
.d-sec { display: grid; gap: 8px; padding-block: 14px; border-top: 1px solid var(--line); }
.d-sec-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.saved { font-size: 12px; color: var(--read); font-weight: 600; opacity: 0; transition: opacity .2s; }
.saved.on { opacity: 1; }
.stars { display: flex; gap: 2px; }
.stars button { appearance: none; background: none; border: 0; padding: 4px; cursor: pointer; color: var(--line); line-height: 0; }
.stars button[aria-pressed="true"] { color: var(--unread); }
.stars button svg { width: 26px; height: 26px; }
.loan-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px; border-radius: 11px; background: var(--lent-soft); }
.loan-box p { margin: 0; min-width: 0; }
.loan-box b { color: var(--lent); }
.overdue { color: var(--danger); font-weight: 600; }
.history { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
details.desc summary { cursor: pointer; font-weight: 600; font-size: 14px; padding-block: 4px; }
details.desc p { color: var(--muted); font-size: 14px; margin: 8px 0 0; white-space: pre-line; }

/* search results */
.results { list-style: none; margin: 0; padding: 0; display: grid; }
.result { display: flex; gap: 12px; align-items: center; padding-block: 10px; border-bottom: 1px solid var(--line); }
.result .cover { flex: 0 0 46px; width: 46px; }
.result button.result-main { appearance: none; background: none; border: 0; padding: 0; flex: 1 1 auto; min-width: 0; display: flex; gap: 12px; align-items: center; text-align: left; cursor: pointer; }
.result-meta { min-width: 0; display: grid; gap: 2px; }
.result-t { font-weight: 600; overflow-wrap: anywhere; }
.result-a { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.in-lib { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--stamp); }
.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1 1 auto; min-width: 0; }
.searchbar .btn { white-space: nowrap; flex: 0 0 auto; }
.busy { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--stamp); animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- scanner (always dark: it frames live video) ---------- */
.scanner { position: fixed; inset: 0; z-index: 40; background: #050607; color: #F2F4F3; display: flex; flex-direction: column; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-top { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); padding-bottom: 12px; background: linear-gradient(rgba(0, 0, 0, .65), transparent); }
.scan-top p { margin: 0; font-weight: 600; font-size: 15px; }
.scan-top .count { font-family: var(--mono); font-size: 12px; color: #C9C3F8; font-weight: 500; display: block; }
.round { appearance: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(6px); }
.round[aria-pressed="true"] { background: #F2D16B; color: #1A1A1A; }
.frame-wrap { position: relative; z-index: 1; flex: 1 1 auto; display: grid; place-items: center; pointer-events: none; }
.frame { width: min(78vw, 360px); aspect-ratio: 16 / 9; border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .38); position: relative; }
.frame::before { content: ""; position: absolute; inset: 0; border-radius: 14px; border: 2.5px solid rgba(255, 255, 255, .9); }
.frame::after { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #F2D16B; opacity: .9; animation: sweep 1.8s ease-in-out infinite; }
@keyframes sweep { 0%, 100% { transform: translateY(-34px); } 50% { transform: translateY(34px); } }
.frame-hint { position: absolute; top: calc(100% + 14px); left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 13.5px; color: rgba(255, 255, 255, .85); text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.scan-panel { position: relative; z-index: 2; background: #12161A; border-radius: 18px 18px 0 0; padding-top: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 12px; max-width: 640px; width: 100%; margin: 0 auto; }
.scan-panel .label { color: #9AA4A8; }
.scan-panel input { background: #1C2226; border-color: #2E373C; color: #F2F4F3; }
.scan-panel .status-seg button { background: #1C2226; border-color: #2E373C; color: #A9B2B6; }
.scan-panel .status-seg button[data-v="read"][aria-pressed="true"] { background: #173024; color: #72C493; border-color: #72C493; }
.scan-panel .status-seg button[data-v="unread"][aria-pressed="true"] { background: #352A12; color: #E2B65E; border-color: #E2B65E; }
.scan-panel .status-seg button[data-v="donate"][aria-pressed="true"] { background: #3A1C2B; color: #EE8AB8; border-color: #EE8AB8; }
.scan-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; }
.scard { display: flex; gap: 12px; align-items: center; background: #1C2226; border: 1px solid #2E373C; border-radius: 14px; padding: 10px; }
.scard .cover { flex: 0 0 52px; width: 52px; box-shadow: none; }
.scard-meta { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.scard-t { font-weight: 600; overflow-wrap: anywhere; }
.scard-a { font-size: 13px; color: #A9B2B6; overflow-wrap: anywhere; }
.scard-w { font-size: 12.5px; color: #E2B65E; }
.scard-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.scan-msg { margin: 0; font-size: 14px; color: #C8D0D3; }
.scan-panel .btn { background: #1C2226; border-color: #2E373C; color: #F2F4F3; }
.scan-panel .btn-primary { background: #A99DF3; border-color: #A99DF3; color: #15112B; }
.batch summary { cursor: pointer; font-size: 13.5px; color: #C8D0D3; }
.batch .two { margin-top: 8px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 14px; justify-items: start; }
.login-card h1 { font-family: var(--display); font-weight: 400; font-size: 36px; line-height: 1.05; margin: 0; text-wrap: balance; }
.login-card p { margin: 0; color: var(--muted); }
.shelf-art { display: flex; gap: 5px; align-items: flex-end; height: 64px; margin-bottom: 6px; }
.shelf-art span { width: 14px; border-radius: 2px 2px 0 0; background: var(--cloth); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--ink); color: var(--paper); border-radius: 11px; padding: 10px 10px 10px 14px; display: flex; gap: 12px; align-items: center; width: max-content; max-width: calc(100% - 32px); box-shadow: var(--shadow); font-size: 14px; }
.toast span { min-width: 0; overflow-wrap: anywhere; }
.toast button { appearance: none; background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 7px; padding: 6px 10px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.scanner-open .toast { bottom: calc(50% - 20px); }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; } .busy { animation: none; } .frame::after { animation: none; } .cover { transition: none; }
}
.d-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* family */
.fam-intro { margin: 0; color: var(--muted); font-size: 14.5px; }
.fam-row { display: flex; align-items: center; gap: 12px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.fam-av { flex: 0 0 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #F3EBDD; background: var(--cloth, #2F5D50); text-transform: uppercase; }
.fam-meta { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.fam-email { font-weight: 600; overflow-wrap: anywhere; }
.fam-sub { font-size: 13px; color: var(--muted); }
.fam-role { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--stamp); }
