:root {
  --paper: #FBF7F0;
  --paper-2: #F4EDE2;
  --card: #FFFDF9;
  --ink: #2E2A26;
  --ink-2: #6B625A;
  --ink-3: #9A8F84;
  --line: #E8DFD2;
  --accent: #C8664A;
  --accent-ink: #A44E35;
  --accent-soft: #F6E3DB;
  --sage: #7F9C7C;
  --sage-soft: #E5EDE3;
  --danger: #B3412F;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(46, 42, 38, .06), 0 4px 16px rgba(46, 42, 38, .06);
  --shadow-lg: 0 10px 40px rgba(46, 42, 38, .16);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Caveat", "Segoe Print", cursive;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-ink); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 3.5vw, 2.5rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* header */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(251, 247, 240, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; color: var(--paper); }
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; line-height: 1; }
.brand-name small { display: block; font-family: var(--sans); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin-top: 3px; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { text-decoration: none; color: var(--ink-2); font-weight: 600; padding: 8px 12px; border-radius: 10px; font-size: .95rem; }
.nav a:hover { background: var(--paper-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.fam-switch { font: inherit; font-weight: 600; font-size: .9rem; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 10px; color: var(--ink); max-width: 200px; }

.bottom-nav { display: none; }

@media (max-width: 820px) {
  .nav { display: none; }
  .topbar-in { padding: 10px 14px; gap: 10px; }
  .brand-name small { display: none; }
  .topbar-right .btn-label { display: none; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; text-decoration: none; color: var(--ink-3); font-size: .72rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; }
  .bottom-nav a.active { color: var(--accent-ink); background: var(--accent-soft); }
  .bottom-nav svg { width: 22px; height: 22px; }
  main.wrap { padding-bottom: 96px; }
}

/* layout */
main.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.narrow { max-width: 760px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 14px; }

/* buttons */
.btn {
  font: inherit; font-weight: 700; font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, transform .05s, border-color .15s;
  background: var(--card); color: var(--ink); border-color: var(--line);
  white-space: nowrap;
}
.btn:hover { border-color: #D8CCBB; background: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #FBEAE6; border-color: #EFC9C0; }
.btn.sm { padding: 6px 10px; font-size: .85rem; border-radius: 9px; }
.btn.icon { padding: 8px; width: 38px; height: 38px; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* forms */
label.field { display: block; }
label.field > span { display: block; font-weight: 700; font-size: .85rem; color: var(--ink-2); margin-bottom: 6px; }
.input, textarea.input, select.input {
  font: inherit; width: 100%; padding: 11px 13px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.6; }
textarea.story { font-family: var(--serif); font-size: 1.05rem; min-height: 200px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 22px; }

/* chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--ink-2); background: var(--paper-2); padding: 3px 10px; border-radius: 999px; }
.tag .dot { width: 8px; height: 8px; border-radius: 50%; }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  background: var(--paper-2);
  display: flex; flex-direction: column; justify-content: center; padding: 60px;
  position: relative; overflow: hidden;
}
.auth-art h1 { font-size: clamp(2rem, 4vw, 3.2rem); max-width: 12ch; }
.auth-art p { max-width: 38ch; color: var(--ink-2); font-size: 1.1rem; }
.polaroids { position: relative; height: 230px; margin-top: 30px; }
.polaroid {
  position: absolute; width: 170px; background: #fff; padding: 10px 10px 34px; box-shadow: var(--shadow-lg);
  border-radius: 3px;
}
.polaroid .ph { aspect-ratio: 1; border-radius: 2px; }
.polaroid .cap { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-family: var(--hand); font-size: 1.2rem; color: var(--ink-2); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form .card { width: 100%; max-width: 410px; }
.tabs { display: flex; background: var(--paper-2); border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.tabs button { flex: 1; font: inherit; font-weight: 700; border: 0; background: transparent; padding: 9px; border-radius: 9px; cursor: pointer; color: var(--ink-2); }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 36px 24px 10px; }
  .polaroids { display: none; }
}

/* timeline */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 26px; }
.toolbar .search { max-width: 280px; }
.year { margin: 8px 0 30px; }
.year-head { display: flex; align-items: baseline; gap: 12px; position: sticky; top: 58px; z-index: 5; background: var(--paper); padding: 8px 0; }
.year-head h2 { font-size: 2rem; margin: 0; }
.year-head .muted { font-weight: 600; font-size: .9rem; }
.month { display: grid; grid-template-columns: 110px 1fr; gap: 18px; padding: 10px 0; border-top: 1px dashed var(--line); }
.month-label { font-family: var(--serif); font-style: italic; color: var(--ink-2); font-size: 1.1rem; padding-top: 10px; }
.mem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
@media (max-width: 640px) {
  .month { grid-template-columns: 1fr; gap: 6px; }
  .month-label { padding-top: 4px; }
  .year-head { top: 54px; }
}
.mem-card { text-decoration: none; color: inherit; overflow: hidden; transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.mem-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.mosaic { display: grid; gap: 2px; aspect-ratio: 4/3; background: var(--paper-2); }
.mosaic.n1 { grid-template-columns: 1fr; }
.mosaic.n2 { grid-template-columns: 1fr 1fr; }
.mosaic.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.mosaic.n3 > :first-child { grid-row: span 2; }
.mosaic img, .mosaic .ph-empty { width: 100%; height: 100%; object-fit: cover; }
.ph-empty { display: grid; place-items: center; color: var(--ink-3); background: var(--paper-2); }
.ph-empty svg { width: 34px; height: 34px; opacity: .6; }
.mem-body { padding: 14px 16px 16px; }
.mem-body h3 { margin-bottom: 4px; }
.mem-meta { font-size: .82rem; color: var(--ink-3); font-weight: 600; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.mem-excerpt { font-size: .92rem; color: var(--ink-2); margin: 8px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mem-ages { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.more-count { position: relative; }
.more-count::after { content: attr(data-more); position: absolute; inset: 0; display: grid; place-items: center; background: rgba(46,42,38,.45); color: #fff; font-weight: 700; font-size: 1.2rem; }

.empty { text-align: center; padding: 60px 20px; }
.empty .art { width: 120px; height: 120px; margin: 0 auto 18px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; color: var(--accent); }
.empty .art svg { width: 54px; height: 54px; }

/* memory detail */
.mem-hero h1 { margin-bottom: 8px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 24px 0; }
.gallery.single { grid-template-columns: 1fr; }
.gallery figure { margin: 0; cursor: zoom-in; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--paper-2); }
.gallery.single img { aspect-ratio: auto; max-height: 70vh; object-fit: contain; }
.gallery figcaption { font-family: var(--hand); font-size: 1.25rem; color: var(--ink-2); margin-top: 4px; line-height: 1.2; }
.story-text { font-family: var(--serif); font-size: 1.2rem; line-height: 1.75; white-space: pre-wrap; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(20, 18, 16, .94); display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 82vh; object-fit: contain; border-radius: 4px; }
.lightbox .cap { color: #EDE5DA; font-family: var(--hand); font-size: 1.6rem; margin-top: 12px; text-align: center; }
.lightbox .lb-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; font-size: 1.6rem; }
.lightbox .lb-prev { left: 16px; } .lightbox .lb-next { right: 16px; }
.lightbox .lb-close { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,.12); color: #fff; border: 0; width: 42px; height: 42px; border-radius: 50%; cursor: pointer; font-size: 1.3rem; }

/* editor */
.editor-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 900px) { .editor-grid { grid-template-columns: 1fr; } }
.dropzone {
  display: block; border: 2px dashed #D9CCBA; border-radius: var(--radius); padding: 28px 20px; text-align: center; background: var(--paper-2);
  cursor: pointer; transition: border-color .15s, background .15s; color: var(--ink-2);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 36px; height: 36px; color: var(--accent); margin-bottom: 6px; }
.photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 14px; }
.photo-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; position: relative; }
.photo-item img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo-item .pi-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.photo-item .pi-tools button { width: 28px; height: 28px; border-radius: 8px; border: 0; background: rgba(255,255,255,.92); cursor: pointer; display: grid; place-items: center; color: var(--ink); box-shadow: var(--shadow); }
.photo-item .pi-tools button svg { width: 15px; height: 15px; }
.photo-item input { border: 0; border-top: 1px solid var(--line); width: 100%; font: inherit; font-size: .85rem; padding: 8px 10px; background: transparent; }
.photo-item input:focus { outline: none; background: var(--accent-soft); }
.photo-item .badge { position: absolute; left: 6px; top: 6px; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.progress { height: 6px; background: var(--paper-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* people */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.person { display: flex; gap: 14px; align-items: center; padding: 16px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--serif); font-weight: 600; font-size: 1.2rem; flex: none; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff; }

/* modal */
.modal-back { position: fixed; inset: 0; z-index: 90; background: rgba(46, 42, 38, .45); display: flex; align-items: center; justify-content: center; padding: 18px; animation: fade .15s; }
.modal { background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 24px; animation: pop .18s ease-out; }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* toasts */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: .92rem; box-shadow: var(--shadow-lg); animation: pop .2s; max-width: 90vw; }
.toast.err { background: var(--danger); }
@media (max-width: 820px) { #toasts { bottom: 90px; } }

/* books list */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 26px; }
.book-tile { text-decoration: none; color: inherit; }
.book-tile .bk { aspect-ratio: 1; border-radius: 4px 10px 10px 4px; overflow: hidden; box-shadow: -4px 0 0 rgba(0,0,0,.08) inset, var(--shadow-lg); transition: transform .2s; position: relative; }
.book-tile:hover .bk { transform: translateY(-4px) rotate(-1deg); }
.book-tile h3 { margin: 12px 0 2px; }

/* ====== BOOK PAGES (shared render) ====== */
.bpage {
  container-type: inline-size;
  aspect-ratio: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: var(--bp-bg);
  color: var(--bp-ink);
  --bp-bg: #FBF7F0; --bp-ink: #2E2A26; --bp-soft: #8A7F74; --bp-accent: #C8664A;
}
.theme-mata .bpage, .bpage.theme-mata { --bp-bg: #EEF3EC; --bp-ink: #23332A; --bp-soft: #6E8273; --bp-accent: #4F7A5A; }
.theme-noc .bpage, .bpage.theme-noc { --bp-bg: #1F2430; --bp-ink: #F2ECE2; --bp-soft: #A9A296; --bp-accent: #E3A46E; }
.theme-bila .bpage, .bpage.theme-bila { --bp-bg: #FFFFFF; --bp-ink: #1E1E1E; --bp-soft: #8C8C8C; --bp-accent: #1E1E1E; }
.bp-in { position: absolute; inset: 6cqw; display: flex; flex-direction: column; gap: 2.4cqw; }
.bp-photos { flex: 1; display: grid; gap: 2cqw; min-height: 0; grid-auto-rows: 1fr; }
.bp-photos.l-one { grid-template-columns: 1fr; }
.bp-photos.l-two { grid-template-columns: 1fr 1fr; }
.bp-photos.l-three { grid-template-columns: 1.4fr 1fr; grid-template-rows: 1fr 1fr; }
.bp-photos.l-three > :first-child { grid-row: span 2; }
.bp-photos.l-four { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.bp-photos.l-photo_text { grid-template-columns: 1fr; }
.bp-slot { position: relative; min-height: 0; background: color-mix(in srgb, var(--bp-ink) 7%, transparent); border-radius: .8cqw; overflow: hidden; }
.bp-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bp-slot .bp-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 5cqw 2.5cqw 1.6cqw; font-family: var(--hand); font-size: 3.6cqw; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.45)); line-height: 1.1; }
.bp-slot.empty { display: grid; place-items: center; color: var(--bp-soft); font-size: 3cqw; border: .3cqw dashed color-mix(in srgb, var(--bp-ink) 18%, transparent); background: transparent; }
.bp-heading { font-family: var(--serif); font-weight: 600; font-size: 5.6cqw; line-height: 1.15; margin: 0; }
.bp-sub { font-size: 2.6cqw; letter-spacing: .14em; text-transform: uppercase; color: var(--bp-soft); font-weight: 700; }
.bp-body { font-family: var(--serif); font-size: 3.1cqw; line-height: 1.6; white-space: pre-wrap; margin: 0; overflow: hidden; }
.bp-text-only { justify-content: center; padding: 0 4cqw; }
.bp-text-only .bp-heading { font-size: 7cqw; margin-bottom: 2cqw; }
.bp-text-only .bp-body { font-size: 3.6cqw; }
.bp-text-only::before { content: "❦"; color: var(--bp-accent); font-size: 6cqw; line-height: 1; }
.bp-num { position: absolute; bottom: 2.2cqw; left: 0; right: 0; text-align: center; font-size: 2.2cqw; color: var(--bp-soft); font-weight: 700; }
/* cover */
.bp-cover .bp-cover-img { position: absolute; inset: 0; }
.bp-cover .bp-cover-img img { width: 100%; height: 100%; object-fit: cover; }
.bp-cover .bp-cover-band { position: absolute; left: 0; right: 0; bottom: 0; padding: 7cqw 7cqw 8cqw; background: var(--bp-bg); }
.bp-cover .bp-cover-band::before { content: ""; display: block; width: 10cqw; height: .8cqw; background: var(--bp-accent); margin-bottom: 3cqw; border-radius: 1cqw; }
.bp-cover h1 { font-family: var(--serif); font-size: 8.4cqw; margin: 0 0 1.4cqw; line-height: 1.05; }
.bp-cover.no-img .bp-cover-band { top: 0; display: flex; flex-direction: column; justify-content: center; }
.bp-back-in { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2cqw; color: var(--bp-soft); }
.bp-back-in .mk { width: 10cqw; height: 10cqw; border-radius: 2.4cqw; background: var(--bp-accent); color: var(--bp-bg); display: grid; place-items: center; font-family: var(--serif); font-size: 5cqw; }
.bp-back-in span { font-size: 2.6cqw; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }

/* ====== BOOK EDITOR ====== */
.be { display: grid; grid-template-columns: 230px 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .be { grid-template-columns: 180px 1fr; } .be-side { grid-column: 1 / -1; } }
@media (max-width: 700px) { .be { grid-template-columns: 1fr; } .be-pages { order: 2; } }
.be-pages { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; padding: 4px; }
.be-pages .pg { cursor: pointer; border-radius: 6px; border: 2px solid transparent; padding: 3px; margin-bottom: 8px; position: relative; }
.be-pages .pg.on { border-color: var(--accent); }
.be-pages .pg .bpage { box-shadow: var(--shadow); border-radius: 3px; }
.be-pages .pg .n { position: absolute; left: 8px; top: 8px; background: var(--ink); color: #fff; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; z-index: 2; }
@media (max-width: 700px) {
  .be-pages { position: static; max-height: none; display: flex; gap: 8px; overflow-x: auto; }
  .be-pages .pg { width: 96px; flex: none; margin: 0; }
}
.be-stage { background: var(--paper-2); border-radius: var(--radius); padding: 26px; }
.be-stage .bpage { box-shadow: var(--shadow-lg); border-radius: 3px; max-width: 620px; margin: 0 auto; }
.be-stage .bp-slot { cursor: pointer; }
.be-stage .bp-slot:hover { outline: .5cqw solid var(--bp-accent); outline-offset: -.5cqw; }
.layouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layout-btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px; cursor: pointer; font: inherit; font-size: .75rem; font-weight: 700; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 5px; }
.layout-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.layout-btn .ic { width: 42px; height: 42px; display: grid; gap: 2px; padding: 3px; background: var(--paper-2); border-radius: 4px; }
.layout-btn .ic i { background: #CDBFAD; border-radius: 1px; }
.layout-btn.on .ic i { background: var(--accent); }

.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.picker-grid button { border: 3px solid transparent; padding: 0; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--paper-2); aspect-ratio: 1; }
.picker-grid button img { width: 100%; height: 100%; object-fit: cover; }
.picker-grid button.on { border-color: var(--accent); }
.picker-group h3 { font-size: .95rem; margin: 18px 0 8px; font-family: var(--sans); font-weight: 700; color: var(--ink-2); }

/* ====== BOOK READER ====== */
.reader { min-height: calc(100vh - 60px); background: radial-gradient(ellipse at center, #EFE6D8 0%, #E2D6C4 100%); display: flex; flex-direction: column; }
.reader-bar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; flex-wrap: wrap; }
.reader-bar h2 { margin: 0; font-size: 1.2rem; }
.reader-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px 20px 30px; position: relative; }
.spread { position: relative; display: flex; perspective: 2400px; width: min(1100px, 92vw, calc((100vh - 190px) * 2)); }
.spread .half { width: 50%; position: relative; }
.spread .half .bpage { box-shadow: 0 18px 40px rgba(46,42,38,.22); }
.spread .half.l .bpage { border-radius: 4px 0 0 4px; }
.spread .half.r .bpage { border-radius: 0 4px 4px 0; }
.spread .half.l .bpage::after { content: ""; position: absolute; inset: 0 0 0 auto; width: 9%; background: linear-gradient(to left, rgba(0,0,0,.14), transparent); pointer-events: none; }
.spread .half.r .bpage::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 9%; background: linear-gradient(to right, rgba(0,0,0,.14), transparent); pointer-events: none; }
.spread .half.blank { visibility: hidden; }
.leaf { position: absolute; top: 0; width: 50%; height: 100%; transform-style: preserve-3d; transition: transform .75s cubic-bezier(.45,.05,.3,1); z-index: 10; }
.leaf.fwd { left: 50%; transform-origin: left center; }
.leaf.back { left: 0; transform-origin: right center; }
.leaf .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.leaf .face.b { transform: rotateY(180deg); }
.leaf .face .bpage { height: 100%; }
.leaf.fwd.go { transform: rotateY(-180deg); }
.leaf.back.go { transform: rotateY(180deg); }
.reader-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.75); cursor: pointer; box-shadow: var(--shadow); display: grid; place-items: center; z-index: 20; }
.reader-nav:hover { background: #fff; }
.reader-nav svg { width: 24px; height: 24px; }
.reader-nav.p { left: 14px; } .reader-nav.n { right: 14px; }
.reader-count { text-align: center; color: var(--ink-2); font-weight: 700; font-size: .85rem; padding-bottom: 20px; }
.single-view { width: min(560px, 90vw); position: relative; }
.single-view .bpage { box-shadow: 0 14px 34px rgba(46,42,38,.22); border-radius: 4px; }
.single-view.anim-n { animation: slideN .35s ease-out; }
.single-view.anim-p { animation: slideP .35s ease-out; }
@keyframes slideN { from { opacity: 0; transform: translateX(30px); } }
@keyframes slideP { from { opacity: 0; transform: translateX(-30px); } }

/* ====== PRINT ====== */
.print-bar { position: sticky; top: 0; z-index: 30; background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.print-sheets { padding: 30px; display: flex; flex-direction: column; align-items: center; gap: 24px; background: var(--paper-2); }
.print-sheet { width: 210mm; max-width: 100%; }
.print-sheet .bpage { box-shadow: var(--shadow-lg); }
@page { size: 210mm 210mm; margin: 0; }
@media print {
  html, body { background: #fff; }
  .topbar, .bottom-nav, .print-bar, .print-note, #toasts { display: none !important; }
  main.wrap { padding: 0; max-width: none; }
  .print-sheets { padding: 0; gap: 0; background: none; display: block; }
  .print-sheet { width: 210mm; height: 210mm; max-width: none; page-break-after: always; break-after: page; }
  .print-sheet .bpage { box-shadow: none; width: 210mm; height: 210mm; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* misc */
.members li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.members { list-style: none; margin: 0; padding: 0; }
.invite-link { font-family: ui-monospace, monospace; font-size: .8rem; background: var(--paper-2); padding: 8px 10px; border-radius: 8px; word-break: break-all; flex: 1; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 30px 0 12px; }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.note { background: var(--sage-soft); border-radius: 12px; padding: 12px 14px; font-size: .9rem; color: #3E5640; }
