/* Book of Life – the app is a book: leather cover, paper pages, index tabs and page turns.
   Colours: navy & emerald. Fonts: Red Hat Display (headings), Red Hat Text (body). */
:root {
  /* desk & leather */
  --desk-1: #080B10;
  --desk-2: #0B1C19;
  --leather: #161616;
  --leather-2: #0A0A0A;
  --leather-3: #262626;
  --leather-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --gold: #D9B04A;
  --gold-foil: linear-gradient(180deg, #FFF3C4 0%, #F1D27A 25%, #C8962E 52%, #8A6312 70%, #E9C766 88%, #FBEFB8 100%);
  /* paper */
  --paper: #FCF8EF;
  --paper-2: #F6EFE0;
  --paper-3: #EFE6D2;
  --rule: #E6DBC4;
  --ink: #14223A;
  /* brand */
  --blue-800: #123A7A;
  --blue-700: #1747A6;
  --blue-600: #1F5EDB;
  --blue-500: #3B7BF0;
  --blue-100: #E2EBFB;
  --blue-50: #EFF4FC;
  --green-700: #0B7A50;
  --green-600: #0E9F67;
  --green-500: #16B97A;
  --green-100: #D9F2E5;
  --green-50: #EDF8F1;
  --foil: linear-gradient(180deg, #E4FFF2 0%, #7FF0BF 28%, #19B57A 55%, #0C7D52 72%, #9BF3CC 100%);
  --red-600: #C53E3E;
  --red-100: #FBE9E6;
  --amber-700: #946007;
  --amber-100: #FCF0D4;
  /* component tokens (warm, paper-friendly) */
  --bg: var(--paper-2);
  --surface: #FFFDF8;
  --text: var(--ink);
  --muted: #5E6878;
  --border: var(--rule);
  --border-strong: #D3C6A9;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06);
  --shadow-lg: 0 18px 40px rgba(6, 18, 34, .28);
  --grad: linear-gradient(135deg, var(--blue-600) 0%, var(--green-500) 100%);
  --font-text: 'Red Hat Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Red Hat Display', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-text); font-size: 15px; line-height: 1.55; color: var(--text); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; font-weight: 800; }
h2 { font-size: 1.08rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code, .mono { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; justify-content: center; }
.nowrap { white-space: nowrap; }
.upper { text-transform: uppercase; }
.pre { white-space: pre-wrap; }
.warn-text { color: var(--amber-700) !important; font-weight: 600; }
.lucide { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
.inline-icon { width: 15px; height: 15px; vertical-align: -2px; }
.inline-icon.ok { color: var(--green-600); }
.print-only { display: none; }
.overlay { display: none; }
:focus-visible { outline: 3px solid rgba(31, 94, 219, .35); outline-offset: 2px; }

/* =========================================================
   The desk, the book and its pages
   ========================================================= */
.book-body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(22, 185, 122, .16), transparent 60%),
    radial-gradient(900px 700px at 110% 110%, rgba(59, 123, 240, .22), transparent 60%),
    linear-gradient(160deg, var(--desk-1), var(--desk-2));
  background-attachment: fixed;
}
.desk { padding: 28px 76px 18px 28px; max-width: 1480px; margin: 0 auto; }
.desk-note { display: flex; align-items: center; justify-content: center; gap: 6px; color: rgba(214, 226, 243, .6); font-size: .78rem; margin: 14px 0 0; }
.desk-note .lucide { width: 13px; height: 13px; }
.desk-note a { color: rgba(214, 226, 243, .8); }

/* Leather binding around the pages */
.book {
  position: relative;
  padding: 14px 14px 18px 14px;
  border-radius: 10px 16px 16px 10px;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 255, 255, .07), transparent 55%),
    var(--leather-grain),
    linear-gradient(135deg, var(--leather-3), var(--leather) 40%, var(--leather-2));
  background-size: auto, 180px 180px, auto;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .55), 0 2px 0 rgba(255, 255, 255, .06) inset, 0 0 0 1px rgba(0, 0, 0, .5);
}
/* Gold stitching along the leather */
.book::before {
  content: ''; position: absolute; inset: 6px; border-radius: 7px 12px 12px 7px; pointer-events: none;
  border: 1px dashed rgba(217, 176, 74, .38);
}

/* The page block with stacked page edges */
.book-inner {
  position: relative;
  min-height: calc(100vh - 110px);
  background: var(--paper);
  border-radius: 4px 8px 8px 4px;
  display: flex; flex-direction: column;
  box-shadow:
    1px 1px 0 var(--paper-3), 2px 2px 0 #fffaf0, 3px 3px 0 var(--paper-3), 4px 4px 0 #fffaf0, 5px 5px 0 var(--rule),
    0 0 0 1px rgba(0, 0, 0, .08);
}
.book-inner::after { /* paper grain */
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; opacity: .5;
  background:
    radial-gradient(circle at 20% 30%, rgba(160, 130, 80, .05), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(160, 130, 80, .05), transparent 45%);
}

/* Running head (top of every page) */
.running-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 28px;
  background: rgba(252, 248, 239, .92); backdrop-filter: blur(6px);
  border-bottom: 3px double var(--rule);
  border-radius: 4px 8px 0 0;
}
.rh-title { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: .78rem; color: var(--blue-800); text-decoration: none !important; white-space: nowrap; }
.rh-title .lucide { color: var(--green-600); }
.rh-chapter { font-family: var(--font-display); font-style: italic; font-weight: 500; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rh-chapter::before { content: '·'; margin-right: 12px; color: var(--border-strong); font-style: normal; }
.search { margin-left: auto; width: 280px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--rule); border-radius: 999px; padding: 0 14px; height: 38px; color: var(--muted); }
.search:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59, 123, 240, .15); }
.search input { flex: 1; border: 0 !important; outline: 0; background: transparent !important; font: inherit; color: var(--text); min-width: 0; height: 100%; padding: 0 !important; min-height: 0 !important; box-shadow: none !important; }
.search-inline { margin-left: 0; width: 100%; max-width: 320px; }
.running-head .nav-toggle { display: none; }

.pages { position: relative; flex: 1; padding: 30px 40px 0; view-transition-name: page; display: flex; flex-direction: column; }
.pages > .folio { margin-top: auto; }
.announcement { display: flex; align-items: center; gap: 10px; padding: 9px 28px; background: var(--green-50); color: var(--green-700); font-weight: 600; font-size: .9rem; border-bottom: 1px solid var(--rule); }

/* Folio (page number + page turns) */
.folio { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 22px 0 18px; margin-top: 28px; border-top: 1px solid var(--rule); }
.folio-no { font-family: var(--font-display); font-style: italic; font-weight: 500; color: var(--muted); letter-spacing: .08em; }
.page-turn { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-display); font-weight: 600; font-size: .88rem; color: var(--blue-700); max-width: 100%; min-width: 0; }
.page-turn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folio-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.folio-right { align-items: flex-end; }
.folio-left { align-items: flex-start; }
.btn-contents {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 700; font-size: .84rem; letter-spacing: .04em; text-decoration: none !important;
  color: #F6E7B0; background: linear-gradient(180deg, #232323, #0B0B0B); border: 1px solid rgba(217, 176, 74, .6);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
.btn-contents .lucide { width: 15px; height: 15px; color: #19B57A; }
.btn-contents:hover { border-color: var(--gold); color: #fff; }

/* Curled page corners – click to turn */
.corner { position: absolute; bottom: 0; width: 46px; height: 46px; z-index: 5; transition: width .2s, height .2s; }
.corner-next { right: 0; border-radius: 0 0 8px 0; background: linear-gradient(315deg, transparent 49%, rgba(0, 0, 0, .12) 50%, #efe4cc 52%, #fffaf0 75%, var(--paper-3) 100%); box-shadow: -3px -3px 6px rgba(0, 0, 0, .06); }
.corner-prev { left: 0; border-radius: 0 0 0 4px; background: linear-gradient(45deg, transparent 49%, rgba(0, 0, 0, .12) 50%, #efe4cc 52%, #fffaf0 75%, var(--paper-3) 100%); box-shadow: 3px -3px 6px rgba(0, 0, 0, .06); }
.corner:hover { width: 70px; height: 70px; }

/* Index tabs sticking out of the book's edge */
.book-tabs { position: absolute; top: 70px; right: -46px; bottom: 30px; width: 46px; display: flex; flex-direction: column; gap: 4px; z-index: 30; }
.tabs-head { display: none; }
.tab-gap { height: 10px; flex-shrink: 0; }
.tab {
  position: relative; display: flex; align-items: center; gap: 10px; height: 36px; flex-shrink: 1; min-height: 28px;
  padding: 0 0 0 11px; width: 46px; border-radius: 0 10px 10px 0; color: #fff; text-decoration: none !important;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, .25), inset 1px 0 0 rgba(0, 0, 0, .15);
  transition: width .2s ease, transform .2s ease, background .2s;
}
.tab .lucide { width: 18px; height: 18px; }
.tab > span { display: none; white-space: nowrap; font-weight: 600; font-size: .86rem; }
.tab > span em { font-family: var(--font-display); font-style: normal; font-weight: 800; opacity: .75; margin-right: 4px; }
.tab-blue { background: linear-gradient(90deg, #1A4FB8, #2563EB); }
.tab-green { background: linear-gradient(90deg, #0B8656, #10A96D); }
.tab-contents { background: linear-gradient(90deg, #0A1E3A, #183A6B); }
.tab-appendix { background: linear-gradient(90deg, #5E6878, #7A8596); }
.tab-admin { background: linear-gradient(90deg, #6B4E16, #946007); }
.tab:hover { width: auto; padding-right: 14px; transform: translateX(2px); z-index: 2; }
.tab:hover > span { display: inline; }
.tab.active { background: var(--paper); color: var(--blue-800); transform: translateX(-4px); width: 52px; box-shadow: 2px 2px 6px rgba(0, 0, 0, .2); }
.tab.active:hover { width: auto; }
.tab-count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #fff; color: var(--blue-800); font-size: .66rem; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.tab-count.warn { background: #F5B942; color: #3A2500; }
.tab:hover .tab-count { display: none; }

/* =========================================================
   Two-page spreads
   ========================================================= */
.spread, .grid-main { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 88px; align-items: start; }
/* the gutter / spine shadow between the two pages */
.spread::before, .grid-main::before {
  content: ''; position: absolute; top: -30px; bottom: -40px; left: 50%; width: 88px; transform: translateX(-50%); pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, rgba(120, 95, 50, .05) 30%, rgba(80, 60, 25, .16) 49%, rgba(255, 255, 255, .6) 50.5%, rgba(120, 95, 50, .06) 70%, transparent 100%);
}
.grid-main { margin-bottom: 8px; }
.grid-main + .card, .grid-main + section { margin-top: 26px; }
.leaf { min-width: 0; position: relative; }
.grid-main > .card, .grid-main > section, .grid-main > form, .grid-main > div { margin-bottom: 0; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > .card { margin-bottom: 0; }

/* Bookplate */
.bookplate { position: relative; text-align: center; padding: 26px 22px 22px; border: 2px solid var(--blue-800); outline: 1px solid var(--blue-800); outline-offset: -8px; border-radius: 6px; background: radial-gradient(circle at 50% 0%, rgba(22, 185, 122, .08), transparent 60%); }
.ex-libris { display: block; font-family: var(--font-display); font-style: italic; font-weight: 500; font-size: 1rem; letter-spacing: .3em; text-transform: uppercase; color: var(--green-700); }
.plate-emblem { display: inline-grid; place-items: center; width: 58px; height: 58px; margin: 14px 0 6px; border-radius: 50%; background: var(--grad); color: #fff; }
.plate-emblem .lucide { width: 28px; height: 28px; }
.plate-line { margin: 10px 0 4px; color: var(--muted); font-style: italic; }
.plate-name { display: block; min-height: 1.6em; margin: 0 auto 6px; padding-bottom: 4px; max-width: 360px; border-bottom: 1px solid var(--border-strong); font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; letter-spacing: .03em; color: var(--blue-800); }
.plate-meta { margin: 8px 0 0; color: var(--muted); font-size: .88rem; }
.bookplate-inline { margin-bottom: 20px; }
.plate-list { list-style: none; margin: 22px 0 16px; padding: 0; text-align: left; display: inline-flex; flex-direction: column; gap: 10px; }
.plate-list li { display: flex; align-items: center; gap: 10px; }
.plate-list .lucide { color: var(--green-600); }
.plate-foot { display: block; font-size: .8rem; color: var(--muted); letter-spacing: .06em; }

/* Ledger (net worth) */
.ledger { padding: 14px 16px; margin-bottom: 20px; border-radius: 10px; background: repeating-linear-gradient(180deg, transparent 0 31px, rgba(31, 94, 219, .08) 31px 32px), var(--surface); border: 1px solid var(--rule); }
.ledger-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.ledger-total { align-items: baseline; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 2px solid var(--ink); }
.ledger-total span { font-weight: 600; }
.ledger-total strong { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.pos { color: var(--green-700); font-weight: 600; }
.neg { color: var(--red-600); font-weight: 600; }
.leaf-title { display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; font-size: 1rem; color: var(--blue-800); }
.leaf-title .lucide { color: var(--green-600); }

/* Contents (table of contents) */
.contents-title { font-size: 2rem; font-weight: 800; text-align: center; letter-spacing: .02em; margin: 6px 0 4px; }
.contents-title::after { content: ''; display: block; width: 120px; height: 10px; margin: 10px auto 18px; background: radial-gradient(circle, var(--green-600) 2px, transparent 3px) center / 12px 10px repeat-x; }
.toc { list-style: none; margin: 0; padding: 0; }
.toc-row { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-radius: 8px; color: var(--ink); text-decoration: none !important; transition: background .15s; }
.toc-row:hover { background: var(--blue-50); }
.toc-row:hover .toc-name { color: var(--blue-700); }
.toc-num { width: 34px; text-align: right; font-family: var(--font-display); font-weight: 800; color: var(--green-700); font-size: .9rem; flex-shrink: 0; }
.toc-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.toc-icon .lucide { width: 15px; height: 15px; }
.toc-name { display: flex; flex-direction: column; line-height: 1.25; font-family: var(--font-display); font-weight: 600; min-width: 0; }
.toc-name small { font-family: var(--font-text); font-weight: 400; font-size: .76rem; color: var(--muted); }
.toc-dots { flex: 1; min-width: 20px; align-self: flex-end; margin-bottom: 8px; border-bottom: 2px dotted var(--border-strong); }
.toc-page { font-family: var(--font-display); font-weight: 700; color: var(--muted); min-width: 22px; text-align: right; }
.toc-sub { margin: 22px 0 6px; padding-top: 14px; border-top: 1px solid var(--rule); font-size: .8rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); text-align: center; }

/* Chapter opener */
.leaf-opener { text-align: center; }
.chapter-no { display: block; font-family: var(--font-display); font-style: italic; font-weight: 500; letter-spacing: .3em; text-transform: uppercase; color: var(--green-700); font-size: .9rem; margin-top: 8px; }
.chapter-medal { display: inline-grid; place-items: center; width: 84px; height: 84px; margin: 18px 0 14px; border-radius: 50%; box-shadow: 0 0 0 6px var(--paper), 0 0 0 7px var(--border-strong); }
.chapter-medal .lucide { width: 38px; height: 38px; }
.chapter-title { font-size: 2.2rem; letter-spacing: -.02em; }
.flourish { display: block; width: 160px; height: 14px; margin: 14px auto; background: linear-gradient(var(--border-strong), var(--border-strong)) center / 100% 1px no-repeat, radial-gradient(circle, var(--green-600) 3px, transparent 4px) center / 14px 14px no-repeat; }
.chapter-intro { font-size: 1.02rem; color: #3A465A; max-width: 420px; margin: 0 auto 8px; }
.chapter-intro { font-style: italic; }
.chapter-stats { color: var(--muted); font-size: .88rem; }
.leaf-opener .leaf-title { justify-content: center; margin-top: 28px; }
.type-list { display: flex; flex-direction: column; gap: 6px; text-align: left; max-width: 420px; margin: 0 auto; }
.type-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--ink); font-weight: 600; text-decoration: none !important; background: rgba(255, 255, 255, .45); transition: border-color .15s, background .15s; }
.type-row span:first-of-type { flex: 1; }
.type-row .lucide { color: var(--green-600); }
.type-row:hover { border-style: solid; border-color: var(--green-500); background: var(--green-50); }
.blank-page { text-align: center; padding: 70px 20px; color: var(--muted); }
.blank-page .lucide { width: 44px; height: 44px; color: var(--border-strong); }
.blank-page h2 { margin: 14px 0 6px; color: var(--ink); font-size: 1.3rem; }

/* =========================================================
   Components (restyled for paper)
   ========================================================= */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.page-head h1 { letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; }
.page-title { display: flex; align-items: center; gap: 16px; }
.page-actions, .row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.page-actions form, .row-actions form { margin: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 14px; font-style: italic; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-style: normal; }
.crumbs .lucide { width: 14px; height: 14px; }
.card { background: rgba(255, 253, 248, .75); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { display: flex; align-items: center; gap: 9px; color: var(--blue-800); }
.card-head h2 .lucide { color: var(--green-600); }
.link { font-weight: 600; font-size: .88rem; display: inline-flex; align-items: center; gap: 4px; }
.link .lucide { width: 15px; height: 15px; }
.with-icon { display: inline-flex; align-items: center; gap: 8px; }
.with-icon .lucide { width: 16px; height: 16px; color: var(--muted); }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none !important; flex-shrink: 0; }
.icon-btn:hover { background: var(--blue-50); color: var(--blue-600); }
.icon-btn.danger:hover { background: var(--red-100); color: var(--red-600); }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn-sm .lucide { width: 15px; height: 15px; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: #F5A524; border: 2px solid var(--paper); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--grad); color: #fff; display: inline-grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: .82rem; flex-shrink: 0; text-decoration: none !important; cursor: pointer; list-style: none; }
.avatar::-webkit-details-marker { display: none; }
.avatar-sm { width: 34px; height: 34px; font-size: .76rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; }

.cat-icon { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; flex-shrink: 0; }
.cat-sm { width: 32px; height: 32px; border-radius: 9px; }
.cat-sm .lucide { width: 16px; height: 16px; }
.cat-lg { width: 52px; height: 52px; border-radius: 15px; }
.cat-lg .lucide { width: 24px; height: 24px; }
.cat-xl { width: 72px; height: 72px; border-radius: 20px; }
.cat-xl .lucide { width: 34px; height: 34px; }
.cat-blue { background: var(--blue-100); color: var(--blue-700); }
.cat-green { background: var(--green-100); color: var(--green-700); }
.cat-red { background: var(--red-100); color: var(--red-600); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font: 600 .93rem var(--font-text); cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, box-shadow .15s, transform .05s; user-select: none; }
.btn:active { transform: translateY(1px); }
.btn-lg { height: 52px; padding: 0 26px; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--blue-700); color: #fff; box-shadow: 0 3px 10px rgba(23, 71, 166, .25); }
.btn-primary:hover { background: var(--blue-800); }
.btn-green { background: var(--green-600); color: #fff; box-shadow: 0 3px 10px rgba(14, 159, 103, .25); }
.btn-green:hover { background: var(--green-700); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--blue-500); color: var(--blue-700); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn-ghost-light { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .28); }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .16); }
.btn-foil { background: var(--foil); color: #06291B; font-weight: 700; box-shadow: 0 6px 20px rgba(22, 185, 122, .35); }
.btn-foil:hover { filter: brightness(1.06); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: #A83232; }
.btn-danger-outline { background: var(--surface); border-color: #EDBDB5; color: var(--red-600); }
.btn-danger-outline:hover { background: var(--red-100); }
.dropdown { position: relative; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 240px; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; color: var(--ink); font: 500 .92rem var(--font-text); background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--blue-50); color: var(--blue-700); text-decoration: none; }
.dropdown-menu .lucide { width: 16px; height: 16px; color: var(--muted); }
.dropdown-menu form { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--rule); }
.menu-who { display: flex; flex-direction: column; padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--rule); }
.menu-who small { color: var(--muted); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: .88rem; display: flex; align-items: center; gap: 6px; }
.label-link { margin-left: auto; font-weight: 500; }
.req { color: var(--red-600); }
.tag-lock { color: var(--green-700); display: inline-flex; }
.tag-lock .lucide { width: 13px; height: 13px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #FFFEFA;
  border: 1px solid var(--border-strong); border-radius: 9px; padding: 10px 12px; min-height: 44px;
  transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235E6878' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59, 123, 240, .15); }
input:disabled { background: var(--paper-2); color: var(--muted); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red-600); }
.error-text { color: var(--red-600); font-weight: 500; }
.help { color: var(--muted); }
.said-hint { font-weight: 500; min-height: 1em; }
.said-hint.ok { color: var(--green-700); }
.said-hint.bad { color: var(--red-600); }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: grid; place-items: center; padding: 0 12px; background: var(--paper-2); border: 1px solid var(--border-strong); border-right: 0; border-radius: 9px 0 0 9px; font-weight: 700; color: var(--muted); }
.input-prefix input { border-radius: 0 9px 9px 0; }
.input-reveal { position: relative; }
.input-reveal input { padding-right: 48px; }
.input-reveal .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.form-card { padding: 26px; background: rgba(255, 253, 248, .8); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 22px; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--rule); }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); border-top: 0; padding-bottom: 12px; }
.narrow { max-width: 620px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--green-600); flex-shrink: 0; }
.check.has-error span { color: var(--red-600); }
.strength { height: 5px; border-radius: 99px; background: var(--rule); overflow: hidden; }
.strength span { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .2s, background .2s; }
.code-input { font-size: 1.5rem !important; letter-spacing: .4em; text-align: center; font-family: var(--font-display); font-weight: 700; }
.inline-form { display: flex; gap: 10px; align-items: center; }
.inline-form select { flex: 1; }
.inline-filter select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: .88rem; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.switch-row:last-of-type { border-bottom: 0; }
.switch-row > span { display: flex; flex-direction: column; }
.switch-row > span.with-icon { flex-direction: row; }
.switch-row small { color: var(--muted); }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; flex-shrink: 0; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch:checked { background: var(--green-600); }
.switch:checked::after { transform: translateX(18px); }

/* Alerts & badges */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; border: 1px solid transparent; }
.alert .lucide { margin-top: 2px; }
.alert > span { flex: 1; }
.alert-success { background: var(--green-50); border-color: #B6E2CB; color: #0A5C3C; }
.alert-error { background: var(--red-100); border-color: #F0C2BA; color: #972B2B; }
.alert-info { background: var(--blue-50); border-color: #C8D8F5; color: var(--blue-800); }
.alert-close { border: 0; background: transparent; color: inherit; cursor: pointer; opacity: .6; padding: 0; }
.alert-close:hover { opacity: 1; }
.temp-pw code { font-size: 1.1rem; background: #fff; padding: 3px 8px; border-radius: 6px; border: 1px solid #B6E2CB; margin: 0 4px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge .lucide { width: 12px; height: 12px; }
.badge-ok { background: var(--green-100); color: var(--green-700); }
.badge-info { background: var(--blue-100); color: var(--blue-700); }
.badge-warn { background: var(--amber-100); color: var(--amber-700); }
.badge-danger { background: var(--red-100); color: var(--red-600); }
.badge-neutral { background: var(--paper-2); color: var(--muted); border: 1px solid var(--rule); }

/* Stats, lists, checklists */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { background: rgba(255, 253, 248, .75); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 6px; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.stat-sub { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.progress { height: 8px; border-radius: 99px; background: var(--blue-100); overflow: hidden; margin: 6px 0 2px; }
.progress span { display: block; height: 100%; background: var(--grad); border-radius: 99px; }
.storage { min-width: 220px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px dashed var(--rule); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; color: var(--ink); text-decoration: none !important; border-radius: 9px; }
.list-row:hover { background: var(--blue-50); }
.list-row > .lucide { color: var(--muted); }
.list-main { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.list-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.checklist a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; border: 1px dashed var(--border-strong); color: var(--ink); font-weight: 500; text-decoration: none !important; transition: border-color .15s, background .15s; }
.checklist a:hover { border-style: solid; border-color: var(--blue-500); background: var(--blue-50); }
.checklist .chev { margin-left: auto; color: var(--muted); }
.check-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-100); color: var(--blue-700); flex-shrink: 0; }
.check-dot .lucide { width: 14px; height: 14px; }
.checklist .done a { background: var(--green-50); border-style: solid; border-color: #C7EBD9; color: var(--muted); }
.checklist .done span:not(.check-dot) { text-decoration: line-through; }
.checklist .done .check-dot { background: var(--green-600); color: #fff; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px dashed var(--rule); font-size: .9rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline small { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.tl-warn .tl-dot { background: #F5A524; box-shadow: 0 0 0 3px var(--amber-100); }
.empty-sm { display: flex; gap: 12px; align-items: center; color: var(--muted); padding: 8px 0; }
.empty-sm p { margin: 0; }
.empty-sm .lucide { width: 28px; height: 28px; color: var(--green-600); }
.empty { text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 48px 20px; background: rgba(255, 255, 255, .35); }
.empty h2 { margin: 16px 0 6px; font-size: 1.3rem; }
.type-picker { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.type-chip { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px; background: var(--blue-50); border: 1px solid #C8D8F5; color: var(--blue-700); font-weight: 600; font-size: .9rem; text-decoration: none !important; }
.type-chip:hover { background: var(--blue-100); }

/* Entries (record cards look like index cards) */
.group { margin-bottom: 26px; }
.group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.group-head h2 { display: flex; align-items: center; gap: 8px; color: var(--blue-800); }
.count { font-family: var(--font-text); font-size: .74rem; font-weight: 700; background: var(--blue-100); color: var(--blue-700); border-radius: 999px; padding: 1px 8px; }
.record-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.record-card {
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 12px 20px; position: relative; overflow: hidden;
  color: var(--ink); text-decoration: none !important; border-radius: 6px;
  background: repeating-linear-gradient(180deg, transparent 0 27px, rgba(31, 94, 219, .07) 27px 28px) 0 44px / 100% calc(100% - 44px) no-repeat, #FFFEFA;
  border: 1px solid var(--rule); box-shadow: 0 1px 0 rgba(0, 0, 0, .03), 0 4px 10px rgba(80, 60, 25, .06);
  transition: transform .15s, box-shadow .15s;
}
.record-card::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 1px; background: rgba(197, 62, 62, .25); }
.record-card:hover { transform: translateY(-2px) rotate(-.3deg); box-shadow: 0 10px 22px rgba(80, 60, 25, .14); }
.record-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.record-top strong { font-family: var(--font-display); font-size: 1.02rem; font-weight: 700; }
.record-title { flex: 1; min-width: 0; }
.value { font-weight: 700; color: var(--green-700); white-space: nowrap; font-size: .9rem; }
.value.neg { color: var(--red-600); }
.mini { margin: 0; display: grid; gap: 4px; }
.mini div { display: flex; justify-content: space-between; gap: 10px; font-size: .85rem; }
.mini dt { color: var(--muted); }
.mini dd { margin: 0; font-weight: 600; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--rule); color: var(--muted); }
.record-empty { display: flex; align-items: center; gap: 8px; padding: 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); font-weight: 500; text-decoration: none !important; }
.details { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.detail { padding: 11px 0; border-bottom: 1px dashed var(--rule); min-width: 0; }
.detail-wide { grid-column: 1 / -1; }
.detail dt { font-size: .74rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px; }
.detail dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 1.02rem; }
.secret { display: inline-flex; align-items: center; gap: 2px; font-family: ui-monospace, Consolas, monospace; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 8px; padding: 2px 4px 2px 10px; }
.said-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.doc-list { list-style: none; margin: 0 0 14px; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px dashed var(--rule); }
.doc-list form { margin: 0; }
.doc-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--blue-50); color: var(--blue-600); display: grid; place-items: center; flex-shrink: 0; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 22px 14px; border: 2px dashed #B9CBEE; border-radius: 12px; background: rgba(239, 244, 252, .7); cursor: pointer; color: var(--blue-700); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--green-500); background: var(--green-50); color: var(--green-700); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone .lucide { width: 28px; height: 28px; }
.dropzone span { font-weight: 600; overflow-wrap: anywhere; }
.dropzone small { color: var(--muted); }
.upload-inline { display: flex; flex-direction: column; gap: 10px; }

/* Photos & birthdays */
.photo-sm { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--rule); }
.photo-lg { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--green-500), 0 4px 10px rgba(0, 0, 0, .1); }
.photo-empty { display: inline-grid; place-items: center; align-content: center; background: var(--blue-100); color: var(--blue-700); font-family: var(--font-display); font-weight: 800; font-size: .8rem; text-decoration: none !important; }
a.photo-lg.photo-empty { box-shadow: none; border: 2px dashed #B9CBEE; }
a.photo-lg.photo-empty small { font-family: var(--font-text); font-size: .62rem; font-weight: 600; }
a.photo-lg.photo-empty:hover { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }
.photo-field { display: flex; align-items: center; gap: 18px; padding: 4px 0 20px; margin-bottom: 20px; border-bottom: 1px dashed var(--rule); }
.photo-pick { position: relative; cursor: pointer; flex-shrink: 0; }
.photo-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-circle { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--blue-50); border: 2px dashed #B9CBEE; color: var(--blue-600); transition: border-color .15s, background .15s; }
.photo-circle img { width: 100%; height: 100%; object-fit: cover; }
.photo-circle .lucide { width: 30px; height: 30px; }
.photo-pick:hover .photo-circle { border-color: var(--green-500); background: var(--green-50); }
.photo-pick:focus-within .photo-circle { box-shadow: 0 0 0 3px rgba(59, 123, 240, .25); }
.photo-badge { position: absolute; right: 2px; bottom: 2px; width: 28px; height: 28px; border-radius: 50%; background: var(--green-600); color: #fff; display: grid; place-items: center; border: 3px solid #fff; }
.photo-badge .lucide { width: 14px; height: 14px; }
.photo-text { display: flex; flex-direction: column; gap: 4px; }
.photo-field.has-error .photo-circle { border-color: var(--red-600); }
.birthday-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px !important; }
.birthday-alert { display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin-bottom: 14px; border-radius: 10px; color: var(--ink); text-decoration: none !important; background: linear-gradient(90deg, #FFF3D6, var(--green-50)); border: 1px solid #EFD9A0; }
.birthday-alert:hover { border-color: var(--green-500); }
.birthday-alert > .lucide { color: var(--muted); }
.birthday-icon { width: 40px; height: 40px; border-radius: 50%; background: #F5B942; color: #3A2500; display: grid; place-items: center; flex-shrink: 0; }

/* Tables */
.table-card { padding: 0; overflow: hidden; }
.table-card > .card-head { padding: 16px 20px 0; }
.table-card > .doc-list, .table-card > .empty-sm { padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 12px 16px; background: var(--paper-2); border-bottom: 1px solid var(--rule); }
.table td { padding: 12px 16px; border-bottom: 1px dashed var(--rule); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr:hover td { background: var(--blue-50); }
.user-cell { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none !important; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 4px; }
.tabs .tab-btn, .tabs > a { padding: 7px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: .88rem; text-decoration: none !important; }
.tabs > a.active { background: var(--blue-700); color: #fff; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bars li { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr 40px; gap: 10px; align-items: center; font-size: .88rem; }
.bar-label { display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bar-label .lucide { width: 15px; height: 15px; color: var(--muted); }
.bar { height: 10px; background: var(--blue-50); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--grad); border-radius: 99px; }
.bar-n { text-align: right; font-weight: 700; }
.action-list { display: flex; flex-direction: column; gap: 8px; }
.action-list form { margin: 0; }
.danger-zone { border-color: #EDBDB5; }
.danger-zone .card-head h2 .lucide { color: var(--red-600); }

/* Emergency card */
.ice-card { background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 10px 26px rgba(80, 60, 25, .16); border: 1px solid var(--rule); }
.ice-head { background: linear-gradient(135deg, #A8281E, var(--red-600)); color: #fff; padding: 18px 20px; }
.ice-head h2 { font-size: 1.4rem; font-weight: 800; margin-top: 6px; }
.ice-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; background: rgba(255, 255, 255, .18); padding: 3px 10px; border-radius: 99px; }
.ice-badge .lucide { width: 14px; height: 14px; }
.ice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--rule); }
.ice-cell { background: #fff; padding: 12px 18px; display: flex; flex-direction: column; gap: 2px; }
.ice-cell > span { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ice-cell small { color: var(--muted); }
.ice-wide { grid-column: 1 / -1; }
.ice-blood strong { font-family: var(--font-display); font-size: 1.8rem; color: var(--red-600); }
.ice-alert { background: #FFF8F7; }
.ice-alert strong { color: #972B2B; }
.ice-contacts { padding: 14px 18px 18px; }
.ice-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ice-contact { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none !important; }
.ice-contact:last-child { border-bottom: 0; }
.ice-phone { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--green-700); background: var(--green-50); padding: 6px 12px; border-radius: 99px; white-space: nowrap; }
.ice-phone .lucide { width: 14px; height: 14px; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; margin-bottom: 14px; }
.qr-wrap img { border-radius: 12px; border: 1px solid var(--rule); padding: 8px; background: #fff; }
.copy-field { display: flex; gap: 6px; width: 100%; }
.copy-field input { font-size: .85rem; }
.secret-key { font-size: 1rem; letter-spacing: .06em; background: var(--paper-2); padding: 8px 12px; border-radius: 8px; border: 1px solid var(--rule); overflow-wrap: anywhere; }
.ice-public { background: linear-gradient(160deg, var(--desk-1), var(--desk-2)); }
.ice-public-wrap { max-width: 520px; margin: 0 auto; padding: 20px 16px 40px; }
.ice-public-wrap > p { margin-top: 16px; color: rgba(214, 226, 243, .8); }
.ice-public-wrap > p a { color: #9BF3CC; }

/* =========================================================
   Sign-in (inside cover) & simple pages
   ========================================================= */
.auth-body .desk { padding-right: 28px; max-width: 1180px; }
.auth-body .book-inner { min-height: calc(100vh - 110px); }
.auth-body .pages { padding-top: 40px; }
.auth-body .spread { align-items: center; flex: 1; }
.leaf-plate { display: flex; justify-content: center; }
.leaf-plate .bookplate { width: 100%; max-width: 420px; padding: 34px 26px 26px; }
.leaf-form { display: flex; flex-direction: column; align-items: center; }
.title-mark { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 800; letter-spacing: .16em; text-transform: uppercase; font-size: .8rem; color: var(--blue-800); margin-bottom: 18px; text-decoration: none !important; }
.title-mark .lucide { color: var(--green-600); }
.leaf-form > .alert { width: 100%; max-width: 420px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { margin-bottom: 6px; font-size: 1.9rem; }
.auth-card > .muted { margin-bottom: 22px; }
.auth-switch { text-align: center; margin: 20px 0 0; color: var(--muted); font-size: .92rem; }
.big-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--grad); color: #fff; display: grid; place-items: center; margin-bottom: 16px; }
.big-icon .lucide { width: 28px; height: 28px; }
.steps { padding-left: 20px; margin: 0 0 16px; }
.steps li { margin-bottom: 8px; }
.plain-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, var(--desk-1), var(--desk-2)); }
.plain-card { max-width: 560px; width: 100%; background: var(--paper); border-radius: 6px 12px 12px 6px; box-shadow: var(--shadow-lg), 4px 4px 0 var(--paper-3); padding: 34px; }
.plain-card h1 { margin-bottom: 8px; }
.brand-link { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none !important; }
.brand-link.dark { color: var(--ink); margin-bottom: 1.2rem; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; color: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-display); font-weight: 800; font-size: 1.12rem; }
.prose { max-width: 720px; }
.prose h2 { margin: 22px 0 8px; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 6px; }

/* =========================================================
   The front cover (landing page): black leather, gold & green foil, passport crest
   ========================================================= */
.cover-body {
  min-height: 100vh; color: #fff;
  background:
    radial-gradient(800px 480px at 50% 8%, rgba(217, 176, 74, .12), transparent 60%),
    radial-gradient(700px 600px at 100% 100%, rgba(22, 185, 122, .12), transparent 60%),
    radial-gradient(600px 500px at 0% 100%, rgba(59, 123, 240, .08), transparent 60%),
    linear-gradient(180deg, #0B0B0C, #050505);
}
.cover-stage { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px 30px; gap: 22px; }
.cover-3d { perspective: 2000px; }
.cover {
  position: relative; display: block; width: min(410px, 82vw); aspect-ratio: 3 / 4.25;
  border-radius: 6px 14px 14px 6px; color: #fff; text-decoration: none !important;
  background:
    radial-gradient(ellipse at 32% 12%, rgba(255, 255, 255, .10), transparent 50%),
    radial-gradient(ellipse at 80% 95%, rgba(0, 0, 0, .55), transparent 55%),
    var(--leather-grain),
    linear-gradient(145deg, #232323 0%, #121212 45%, #070707 100%);
  background-size: auto, auto, 180px 180px, auto;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .08), inset -1px 0 0 rgba(255, 255, 255, .05), inset 0 -2px 6px rgba(0, 0, 0, .6),
    /* gilded page edges */
    5px 1px 0 -1px #F4DD8C, 7px 2px 0 -1px #B88A22, 9px 3px 0 -1px #EFD27A, 11px 4px 0 -1px #9C7318, 13px 5px 0 -1px #E4C263,
    30px 40px 70px rgba(0, 0, 0, .75), 0 0 0 1px rgba(0, 0, 0, .8);
  transform-origin: left center; transform: rotateY(-9deg) rotateX(3deg);
  transition: transform .7s ease;
  cursor: pointer;
}
.cover:hover { transform: rotateY(-17deg) rotateX(3deg); }
/* raised spine with bands */
.cover-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 30px; border-radius: 6px 0 0 6px;
  background:
    linear-gradient(180deg, transparent 14%, rgba(217, 176, 74, .55) 14.3%, transparent 14.9%, transparent 16%, rgba(217, 176, 74, .4) 16.3%, transparent 16.9%,
                    transparent 83%, rgba(217, 176, 74, .4) 83.3%, transparent 83.9%, transparent 85%, rgba(217, 176, 74, .55) 85.3%, transparent 85.9%),
    linear-gradient(90deg, rgba(0, 0, 0, .7), rgba(255, 255, 255, .06) 40%, rgba(0, 0, 0, .5) 85%, rgba(0, 0, 0, .8));
  box-shadow: 2px 0 3px rgba(0, 0, 0, .6);
}
/* gold metal corner protectors */
.metal { position: absolute; right: -1px; width: 38px; height: 38px; background: linear-gradient(135deg, #FBEFB8, #D9B04A 35%, #8A6312 70%, #E9C766); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); }
.metal-tr { top: -1px; clip-path: polygon(0 0, 100% 0, 100% 100%); border-top-right-radius: 14px; }
.metal-br { bottom: -1px; clip-path: polygon(100% 0, 100% 100%, 0 100%); border-bottom-right-radius: 14px; }
.cover-frame {
  position: absolute; inset: 26px 26px 26px 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px 14px;
  border: 1.5px solid rgba(217, 176, 74, .75); border-radius: 3px; outline: 1px solid rgba(22, 185, 122, .55); outline-offset: -7px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .6);
}
.cover-country { font-family: var(--font-display); font-weight: 700; font-size: .7rem; letter-spacing: .42em; text-transform: uppercase; background: var(--gold-foil); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 14px; }
.cover-emblem { display: block; width: 120px; height: 120px; margin-bottom: 14px; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .8)) drop-shadow(0 0 10px rgba(217, 176, 74, .18)); }
.cover-emblem .crest { width: 100%; height: 100%; display: block; }
.cover-title { display: flex; flex-direction: column; align-items: center; line-height: .95; font-family: var(--font-display); font-weight: 800; text-transform: uppercase; letter-spacing: .14em; font-size: clamp(2.2rem, 8.5vw, 3.3rem); filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .85)); }
.gold-foil { background: var(--gold-foil); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cover-title em { font-style: italic; font-weight: 500; font-size: .4em; letter-spacing: .45em; margin: 6px 0 4px; text-transform: lowercase; background: var(--foil); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cover-kind { margin-top: 12px; font-family: var(--font-display); font-weight: 600; font-size: .72rem; letter-spacing: .38em; text-transform: uppercase; color: #7FF0BF; }
.cover-holder { margin-top: 10px; font-family: var(--font-display); font-weight: 700; font-size: .95rem; letter-spacing: .22em; text-transform: uppercase; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .9)); }
.cover-rule { width: 120px; height: 12px; margin: 14px 0 10px; background: linear-gradient(90deg, transparent, #D9B04A 20%, #D9B04A 80%, transparent) center / 100% 1px no-repeat, radial-gradient(circle, #19B57A 3px, transparent 4px) center / 12px 12px no-repeat; }
.cover-sub { font-style: italic; color: #D9C58E; font-size: .92rem; line-height: 1.5; }
.cover-chip { display: block; width: 40px; margin-top: 14px; opacity: .9; }
.cover-chip svg { width: 100%; display: block; }
.cover-foot { position: absolute; bottom: 12px; font-family: var(--font-display); letter-spacing: .4em; text-transform: uppercase; font-size: .6rem; color: rgba(217, 176, 74, .7); }
.cover-ribbon { position: absolute; bottom: -46px; right: 64px; width: 22px; height: 54px; background: linear-gradient(90deg, #0B7A50, #19B57A 50%, #0B7A50); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%); filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5)); }
.cover-stage .cover-actions { margin-top: 50px; }
.cover.is-opening { transition: transform 1.5s cubic-bezier(.45, .05, .25, 1); transform: rotateY(-168deg) rotateX(0deg); }
/* Coming back from inside the book: the cover swings shut */
html[data-closing] .cover { animation: cover-close 1.5s cubic-bezier(.45, .05, .25, 1) backwards; }
@keyframes cover-close {
  from { transform: rotateY(-168deg) rotateX(0deg); }
  to { transform: rotateY(-9deg) rotateX(3deg); }
}
@media (prefers-reduced-motion: reduce) { html[data-closing] .cover { animation: none; } }
.cover-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.cover-hint { color: rgba(217, 197, 142, .5); font-size: .85rem; margin: 0; letter-spacing: .04em; }
.btn-gold { background: var(--gold-foil); color: #1F1604; font-weight: 700; box-shadow: 0 6px 20px rgba(217, 176, 74, .3), inset 0 1px 0 rgba(255, 255, 255, .5); }
.btn-gold:hover { filter: brightness(1.06); }
.back-cover { max-width: 1060px; margin: 0 auto; padding: 50px 20px 40px; text-align: center; border-top: 1px solid rgba(217, 176, 74, .15); }
.blurb-kicker { font-family: var(--font-display); font-style: italic; letter-spacing: .3em; text-transform: uppercase; color: #D9B04A; font-size: .82rem; }
.back-cover h2 { font-size: clamp(1.4rem, 3.4vw, 2.1rem); font-weight: 800; margin: 8px auto 34px; max-width: 760px; }
.blurb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; text-align: left; }
.blurb { padding: 20px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(217, 176, 74, .16); }
.blurb .lucide { color: #19B57A; width: 26px; height: 26px; }
.blurb h3 { margin: 12px 0 6px; color: #F1DC9A; }
.blurb p { color: #C9CCD2; margin: 0; font-size: .93rem; }
.blurb-chapters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin: 34px 0 20px; color: #C9CCD2; font-size: .9rem; }
.blurb-chapters em { font-family: var(--font-display); font-style: normal; font-weight: 800; color: #D9B04A; margin-right: 4px; }
.back-foot { color: rgba(214, 214, 214, .5); font-size: .85rem; }
.back-foot a { color: rgba(217, 197, 142, .8); }

/* Fit the whole cover (plus ribbon and buttons) inside the first screen: the book is sized from the
   viewport height and everything on it scales with the cover itself (container query units). */
.cover-stage { min-height: 100vh; min-height: 100dvh; padding: 22px 16px 18px; gap: 12px; }
.cover {
  width: auto;
  height: clamp(340px, calc(100dvh - 190px), 660px);
  max-width: 88vw;
  container-type: size;
}
.cover-frame { inset: 4.2cqh 6cqw 4.2cqh 11.5cqw; padding: 2.4cqh 3cqw; }
.cover-country { font-size: max(8px, 1.55cqh); margin-bottom: 2.2cqh; }
.cover-emblem { width: 20cqh; height: 20cqh; margin-bottom: 2cqh; }
.cover-title { font-size: 8.4cqh; }
.cover-kind { font-size: max(8px, 1.65cqh); margin-top: 1.8cqh; }
.cover-holder { font-size: max(9px, 2.1cqh); margin-top: 1.4cqh; }
.cover-rule { margin: 2cqh 0 1.5cqh; }
.cover-sub { font-size: max(10px, 2.15cqh); }
.cover-chip { width: 6.4cqh; margin-top: 2cqh; }
.cover-foot { font-size: max(7px, 1.35cqh); bottom: 2cqh; }
.cover-stage .cover-actions { margin-top: 44px; }
.cover-hint { font-size: .8rem; }
@media (max-width: 640px) {
  .cover { height: auto; width: min(410px, 84vw); aspect-ratio: 3 / 4.25; }
}

/* =========================================================
   Page turning (cross-document view transitions) – slow, like a real page
   ========================================================= */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-group(page) { animation: none; }
::view-transition-old(page), ::view-transition-new(page) {
  animation-duration: 1.4s; animation-timing-function: cubic-bezier(.33, .02, .2, 1); animation-fill-mode: both;
  mix-blend-mode: normal; backface-visibility: hidden;
}
html[data-flip=forward]::view-transition-old(page) { transform-origin: left center; animation-name: page-flip-away; z-index: 2; }
html[data-flip=forward]::view-transition-new(page) { animation-name: page-under-in; }
html[data-flip=back]::view-transition-new(page) { transform-origin: left center; animation-name: page-flip-in; z-index: 2; }
html[data-flip=back]::view-transition-old(page) { animation-name: page-under-out; }
@keyframes page-flip-away {
  0% { transform: perspective(2400px) rotateY(0) skewY(0); filter: brightness(1) drop-shadow(0 0 0 rgba(0, 0, 0, 0)); }
  30% { transform: perspective(2400px) rotateY(-22deg) skewY(-1deg); filter: brightness(.97) drop-shadow(-18px 10px 22px rgba(0, 0, 0, .25)); }
  70% { transform: perspective(2400px) rotateY(-70deg) skewY(-1.5deg); filter: brightness(.82) drop-shadow(-30px 14px 30px rgba(0, 0, 0, .3)); }
  100% { transform: perspective(2400px) rotateY(-98deg) skewY(0); filter: brightness(.6) drop-shadow(0 0 0 rgba(0, 0, 0, 0)); }
}
@keyframes page-flip-in {
  0% { transform: perspective(2400px) rotateY(-98deg) skewY(0); filter: brightness(.6) drop-shadow(0 0 0 rgba(0, 0, 0, 0)); }
  30% { transform: perspective(2400px) rotateY(-70deg) skewY(-1.5deg); filter: brightness(.82) drop-shadow(-30px 14px 30px rgba(0, 0, 0, .3)); }
  70% { transform: perspective(2400px) rotateY(-22deg) skewY(-1deg); filter: brightness(.97) drop-shadow(-18px 10px 22px rgba(0, 0, 0, .25)); }
  100% { transform: perspective(2400px) rotateY(0) skewY(0); filter: brightness(1) drop-shadow(0 0 0 rgba(0, 0, 0, 0)); }
}
@keyframes page-under-in { 0% { filter: brightness(.7); } 60% { filter: brightness(.9); } 100% { filter: brightness(1); } }
@keyframes page-under-out { 0% { filter: brightness(1); } 40% { filter: brightness(.9); } 100% { filter: brightness(.7); } }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .cover, .cover.is-opening { transition: none; }
}

/* =========================================================
   Responsive: tablets & phones become a single page
   ========================================================= */
@media (max-width: 1100px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .search { width: 200px; }
}
@media (max-width: 960px) {
  .desk { padding: 0; }
  .desk-note { padding: 0 16px 16px; }
  .book { padding: 6px 0 0; border-radius: 0; box-shadow: none; }
  .book::before { display: none; }
  .book-inner { border-radius: 0; min-height: calc(100vh - 6px); box-shadow: none; }
  .running-head { padding: 10px 14px; border-radius: 0; gap: 8px; }
  .rh-chapter { display: none; }
  .search { width: auto; flex: 1; margin-left: 4px; }
  .running-head .nav-toggle { display: inline-grid; }
  .pages { padding: 20px 16px 0; }
  .announcement { padding-left: 16px; padding-right: 16px; }
  .spread, .grid-main { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .spread::before, .grid-main::before { display: none; }
  .spread > .leaf + .leaf { padding-top: 22px; border-top: 3px double var(--rule); }
  .corner { display: none; }
  /* index tabs become a drawer */
  .book-tabs { position: fixed; top: 0; bottom: 0; left: 0; right: auto; width: 290px; padding: 14px 12px; gap: 4px; overflow-y: auto; background: linear-gradient(180deg, var(--leather-3), var(--leather-2)); transform: translateX(-102%); transition: transform .25s ease; z-index: 60; box-shadow: none; }
  body.nav-open .book-tabs { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open { overflow: hidden; }
  body.nav-open .overlay { display: block; position: fixed; inset: 0; background: rgba(6, 18, 34, .55); z-index: 55; }
  .tabs-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 12px; margin-bottom: 6px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
  .tabs-head .icon-btn { color: #CFE3F7; }
  .brand-mini { display: inline-flex; align-items: center; gap: 8px; color: #fff; font-family: var(--font-display); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: .8rem; }
  .brand-mini .lucide { color: #7FF0BF; }
  .tab, .tab:hover, .tab.active, .tab.active:hover { width: 100%; height: 42px; min-height: 42px; flex-shrink: 0; padding: 0 12px; border-radius: 10px; transform: none; box-shadow: none; }
  .tab > span, .tab:hover > span { display: inline; flex: 1; }
  .tab-count { position: static; }
  .tab:hover .tab-count { display: grid; }
  .tab-blue, .tab-green, .tab-appendix, .tab-contents, .tab-admin { background: rgba(255, 255, 255, .06); }
  .tab-blue .lucide { color: #8FB4FF; }
  .tab-green .lucide { color: #7FF0BF; }
  .tab.active { background: var(--paper); color: var(--blue-800); }
  .tab.active .lucide { color: var(--green-700); }
  .auth-body .desk { padding: 0; }
  .leaf-plate { display: none; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.4rem; }
  .rh-title span { display: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 1.35rem; }
  .form-grid, .grid-2, .details { grid-template-columns: 1fr; }
  .form-card { padding: 18px; }
  .form-actions { position: sticky; bottom: 0; background: var(--paper); margin: 18px -18px -18px; padding: 12px 18px; border-radius: 0 0 var(--radius) var(--radius); }
  .form-actions .btn { flex: 1; }
  .page-head { align-items: stretch; }
  .page-title { gap: 12px; }
  .page-actions { width: 100%; }
  .page-actions > * { flex: 1; }
  .page-actions .btn, .page-actions summary.btn { width: 100%; }
  .dropdown-menu { right: -8px; }
  .hide-sm { display: none; }
  .record-grid { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 14px 1fr; }
  .timeline small { grid-column: 2; }
  .tabs { width: 100%; overflow-x: auto; }
  .search-inline { max-width: none; }
  .bars li { grid-template-columns: 1fr 1fr 32px; }
  .storage { width: 100%; }
  .chapter-title { font-size: 1.8rem; }
  .contents-title { font-size: 1.6rem; }
  .toc-num { width: 26px; }
  .ledger-total strong { font-size: 1.4rem; }
  .page-turn span { max-width: 38vw; }
  .cover { transform: none; }
  .cover:hover { transform: none; }
  .auth-card h1 { font-size: 1.6rem; }
}

/* Print (emergency card) */
@media print {
  .book-tabs, .running-head, .desk-note, .announcement, .no-print, .alert, .folio, .corner, .grid-main > .card { display: none !important; }
  .book-body, .book, .book-inner { background: #fff !important; box-shadow: none !important; padding: 0 !important; }
  .desk { padding: 0; }
  .pages { padding: 0; }
  .grid-main { display: block; }
  .grid-main::before { display: none; }
  .ice-card { box-shadow: none; max-width: 480px; border: 2px solid #000; }
  .print-only { display: flex; }
  .print-qr { align-items: center; gap: 12px; margin-top: 16px; }
}

/* =========================================================
   Desktop: the open book always fits the screen (no window scrolling).
   The book is as tall as the window; long pages scroll inside the page.
   ========================================================= */
@media (min-width: 961px) and (min-height: 520px) {
  .book-body { height: 100vh; height: 100dvh; overflow: hidden; }
  .book-body .desk { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 14px 64px 12px 20px; }
  .book-body .desk-note { display: none; }
  .book-body .book { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 12px 14px; }
  .book-body .book-inner { flex: 1; min-height: 0; }
  .book-body .running-head { position: relative; padding: 9px 26px; flex-shrink: 0; }
  .book-body .search { height: 34px; }
  .book-body .announcement { flex-shrink: 0; }
  .book-body .pages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 34px 0; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
  /* two-page spreads: each page scrolls on its own, the book stays put */
  .book-body .pages:has(> .spread) { overflow: hidden; }
  .book-body .pages > .spread { flex: 1; min-height: 0; }
  .book-body .pages > .spread > .leaf { height: 100%; overflow-y: auto; padding: 0 8px 12px 2px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
  .book-body .pages > .spread::before { top: -20px; bottom: 0; }
  .book-body .folio { flex-shrink: 0; margin-top: 0; padding: 8px 0 10px; position: sticky; bottom: 0; background: var(--paper); z-index: 3; }
  .book-body .folio .btn-contents { padding: 5px 12px; }
  .book-body .folio-side { flex-direction: row; align-items: center; gap: 12px; }
  .book-body .folio-right { flex-direction: row-reverse; justify-content: flex-start; }
  .book-body .book-tabs { top: 56px; bottom: 16px; }
  .book-body .tab { height: 34px; }
  .auth-body .pages { padding-top: 24px; }
  .auth-body .pages > .spread > .leaf { display: flex; flex-direction: column; justify-content: center; }
  .auth-body .leaf-plate .bookplate { padding: 24px 22px 20px; }

  /* compact Contents spread */
  .bookplate-inline { padding: 12px 16px 12px; margin-bottom: 12px; outline-offset: -6px; }
  .bookplate-inline .ex-libris { font-size: .78rem; }
  .bookplate-inline .plate-line { margin: 2px 0 0; font-size: .85rem; }
  .bookplate-inline .plate-name { font-size: 1.45rem; margin-bottom: 2px; padding-bottom: 2px; }
  .bookplate-inline .plate-meta { margin-top: 4px; font-size: .8rem; }
  .birthday-alert { padding: 8px 12px; margin-bottom: 10px; }
  .ledger { padding: 10px 14px; margin-bottom: 8px; background: var(--surface); }
  .ledger-total { padding-bottom: 6px; }
  .ledger-total strong { font-size: 1.45rem; }
  .ledger-mini { font-size: .85rem; color: var(--muted); }
  .ledger-mini b { color: var(--ink); margin-left: 4px; }
  .ledger-mini b.pos { color: var(--green-700); }
  .ledger-mini b.neg { color: var(--red-600); }
  .leaf-title { margin: 12px 0 4px; font-size: .92rem; }
  .spread .list-row { padding: 6px 4px; }
  .spread .checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .spread .checklist a { padding: 6px 8px; font-size: .84rem; gap: 8px; }
  .spread .checklist .check-dot { width: 24px; height: 24px; }
  .spread .checklist .chev { display: none; }
  .contents-title { font-size: 1.6rem; margin: 0; }
  .contents-title::after { margin: 6px auto 8px; }
  .toc-row { padding: 3px 6px; gap: 8px; }
  .toc-icon { width: 24px; height: 24px; border-radius: 7px; }
  .toc-icon .lucide { width: 13px; height: 13px; }
  .toc-name { flex-direction: row; align-items: baseline; gap: 8px; font-size: .95rem; white-space: nowrap; }
  .toc-name small { font-size: .74rem; }
  .toc-dots { margin-bottom: 6px; }
  .toc-sub { margin: 8px 0 2px; padding-top: 8px; font-size: .72rem; }
  /* chapter opener */
  .chapter-medal { width: 64px; height: 64px; margin: 10px 0 8px; }
  .chapter-medal .lucide { width: 30px; height: 30px; }
  .chapter-title { font-size: 1.9rem; }
  .flourish { margin: 8px auto; }
  .leaf-opener .leaf-title { margin-top: 16px; }
  .type-row { padding: 8px 12px; }
}

/* Wide but short screens (e.g. laptops with display scaling): use the width, save height */
@media (min-width: 961px) and (min-height: 520px) {
  .book-body .desk { max-width: 1720px; }
}
@media (min-width: 961px) and (min-height: 520px) and (max-height: 780px) {
  .book-body .desk { padding-top: 10px; padding-bottom: 8px; }
  .book-body .running-head { padding: 6px 24px; }
  .book-body .pages { padding-top: 12px; }
  .book-body .folio { padding: 6px 0 7px; }
  .bookplate-inline { padding: 8px 14px; margin-bottom: 8px; }
  .bookplate-inline .plate-name { font-size: 1.25rem; }
  .bookplate-inline .plate-line { display: none; }
  .birthday-alert { padding: 6px 12px; margin-bottom: 8px; }
  .ledger { padding: 7px 12px; }
  .ledger-total strong { font-size: 1.25rem; }
  .leaf-title { margin: 8px 0 2px; }
  .spread .list-row { padding: 4px; }
  .contents-title { font-size: 1.3rem; }
  .contents-title::after { margin: 4px auto 4px; height: 8px; }
  .toc-row { padding: 2px 6px; }
  .toc-icon { width: 22px; height: 22px; }
  .toc-sub { margin: 4px 0 0; padding-top: 5px; }
}

/* =========================================================
   Phones & small tablets: the book fits the screen, one page at a time.
   Spreads become a swipeable row of pages; the page-turn bar stays at the bottom.
   ========================================================= */
.page-turn[hidden] { display: none !important; }
.folio-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.leaf-dots { display: flex; gap: 5px; }
.leaf-dots:empty { display: none; }
.leaf-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); transition: background .2s, transform .2s; }
.leaf-dots i.on { background: var(--green-600); transform: scale(1.3); }
@media (max-width: 960px) {
  .book-body { height: 100vh; height: 100dvh; overflow: hidden; }
  .book-body .desk { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 0; }
  .book-body .desk-note { display: none; }
  .book-body .book { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .book-body .book-inner { flex: 1; min-height: 0; }
  .book-body .running-head { position: relative; flex-shrink: 0; }
  .book-body .announcement { flex-shrink: 0; }
  .book-body .pages { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 0; -webkit-overflow-scrolling: touch; }
  /* spreads: one page per screen, swipe sideways to turn */
  .book-body .pages:has(> .spread) { overflow: hidden; padding: 0; }
  .book-body .pages > .spread {
    flex: 1; min-height: 0; display: flex; gap: 0; grid-template-columns: none;
    overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
  }
  .book-body .pages > .spread::-webkit-scrollbar { display: none; }
  .book-body .pages > .spread > .leaf {
    flex: 0 0 100%; width: 100%; height: 100%; overflow-y: auto; scroll-snap-align: start; scroll-snap-stop: always;
    padding: 16px 16px 16px !important; border-top: 0 !important;
    background: linear-gradient(90deg, rgba(80, 60, 25, .07), transparent 14px);
  }
  .book-body .pages > .spread > .leaf + .leaf { box-shadow: inset 1px 0 0 var(--rule); }
  /* the page-turn bar */
  .book-body .folio {
    flex-shrink: 0; position: sticky; bottom: 0; z-index: 3; background: var(--paper);
    margin: 0; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); gap: 6px; border-top: 1px solid var(--rule);
    grid-template-columns: 1fr auto 1fr;
  }
  .book-body .pages:has(> .spread) > .folio { padding-left: 12px; padding-right: 12px; }
  .book-body .folio-side { flex-direction: row; align-items: center; gap: 6px; }
  .book-body .folio-right { flex-direction: row-reverse; justify-content: flex-start; }
  .book-body .page-turn { font-size: .82rem; padding: 6px 2px; }
  .book-body .page-turn span { max-width: 28vw; }
  .book-body .btn-contents { padding: 6px 9px; }
  .book-body .btn-contents .bc-label { display: none; }
  .book-body .folio-no { font-size: .8rem; }
  /* single pages that are longer than the screen scroll inside the page */
  .book-body .form-actions { margin-bottom: 0; }
  /* auth (inside cover) on phones */
  .auth-body .pages > .spread > .leaf-form { justify-content: flex-start; }
}
/* Pages gently turn as you swipe (browsers with scroll-driven animations) */
@supports (animation-timeline: view()) {
  @media (max-width: 960px) and (prefers-reduced-motion: no-preference) {
    .book-body .pages > .spread > .leaf {
      animation: leaf-turn linear both;
      animation-timeline: view(inline);
      transform-origin: left center;
    }
    @keyframes leaf-turn {
      0% { transform: perspective(1400px) rotateY(28deg); filter: brightness(.8); }
      30%, 70% { transform: none; filter: none; }
      100% { transform: perspective(1400px) rotateY(-28deg); filter: brightness(.8); }
    }
  }
}

/* Phones: compact Contents / Ex Libris so each fits one screen */
@media (max-width: 960px) {
  .contents-title { font-size: 1.35rem; margin: 0; }
  .contents-title::after { margin: 4px auto 6px; height: 8px; }
  .toc-row { padding: 4px 2px; gap: 7px; }
  .toc-num { width: 26px; font-size: .8rem; }
  .toc-icon { width: 22px; height: 22px; border-radius: 6px; }
  .toc-icon .lucide { width: 12px; height: 12px; }
  .toc-name { flex-direction: row; align-items: baseline; gap: 6px; font-size: .9rem; white-space: nowrap; min-width: 0; }
  .toc-name small { font-size: .7rem; }
  .toc-dots { margin-bottom: 5px; min-width: 8px; }
  .toc-page { font-size: .85rem; min-width: 18px; }
  .toc-sub { margin: 6px 0 0; padding-top: 6px; font-size: .68rem; }
  .bookplate-inline { padding: 12px 12px; margin-bottom: 10px; outline-offset: -6px; }
  .bookplate-inline .plate-line { margin: 2px 0 0; font-size: .82rem; }
  .bookplate-inline .plate-name { font-size: 1.3rem; }
  .bookplate-inline .plate-meta { font-size: .78rem; margin-top: 4px; }
  .ledger { padding: 9px 12px; margin-bottom: 8px; }
  .ledger-total strong { font-size: 1.3rem; }
  .ledger-mini { font-size: .78rem; color: var(--muted); flex-wrap: wrap; }
  .ledger-mini b { color: var(--ink); margin-left: 3px; }
  .ledger-mini b.pos { color: var(--green-700); }
  .ledger-mini b.neg { color: var(--red-600); }
  .leaf-title { margin: 10px 0 4px; font-size: .9rem; }
  .spread .list-row { padding: 6px 2px; }
  .spread .checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .spread .checklist a { padding: 6px 8px; font-size: .8rem; gap: 6px; }
  .spread .checklist .check-dot { width: 22px; height: 22px; }
  .spread .checklist .chev { display: none; }
  .chapter-medal { width: 60px; height: 60px; margin: 8px 0 6px; }
  .chapter-medal .lucide { width: 28px; height: 28px; }
  .chapter-title { font-size: 1.6rem; }
  .flourish { margin: 8px auto; }
  .leaf-opener .leaf-title { margin-top: 14px; }
  .type-row { padding: 9px 12px; }
}

/* Short phones: trim the Ex Libris page a little more */
@media (max-width: 960px) and (max-height: 740px) {
  .bookplate-inline { padding: 8px 10px; }
  .bookplate-inline .plate-line { display: none; }
  .bookplate-inline .plate-meta { font-size: .72rem; margin-top: 2px; }
  .birthday-alert { padding: 6px 10px; margin-bottom: 8px; }
  .birthday-alert .photo-sm, .birthday-alert .birthday-icon { width: 30px; height: 30px; }
  .ledger { padding: 7px 10px; }
  .ledger-total strong { font-size: 1.15rem; }
  .leaf-title { margin: 8px 0 2px; }
  .spread .list-row { padding: 4px 2px; }
  .spread .list-row .cat-sm, .spread .list-row .photo-sm { width: 28px; height: 28px; }
  .book-body .pages > .spread > .leaf { padding: 12px 14px !important; }
}

/* =========================================================
   Document copies & sharing: sheets (centred on laptops, bottom sheets on phones)
   ========================================================= */
.btn-sm { height: 34px; padding: 0 12px; font-size: .85rem; border-radius: 9px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue-700); font: 600 .82rem var(--font-text); cursor: pointer; text-decoration: underline; }
.grow { flex: 1; }
dialog.sheet {
  padding: 0; border: 0; border-radius: 18px; width: min(560px, calc(100vw - 32px)); max-height: min(88dvh, 820px);
  background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .45); overflow: hidden;
}
dialog.sheet[open] { display: flex; animation: sheet-in .28s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::backdrop { background: rgba(6, 12, 22, .55); backdrop-filter: blur(3px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.sheet-form { display: flex; flex-direction: column; width: 100%; min-height: 0; max-height: inherit; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 10px; border-bottom: 1px solid var(--rule); background: linear-gradient(180deg, #fffdf6, var(--paper)); }
.sheet-head h2 { font-size: 1.25rem; margin-top: 2px; }
.sheet-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--green-700); }
.sheet-kicker .lucide { width: 14px; height: 14px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); background: #fffdf6; flex-wrap: wrap; }
.stepper { list-style: none; display: flex; gap: 6px; margin: 0; padding: 10px 20px 0; }
.stepper li { flex: 1; display: flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600; color: var(--muted); padding-bottom: 8px; border-bottom: 3px solid var(--rule); transition: color .2s, border-color .2s; }
.stepper li span { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--rule); color: var(--muted); font-size: .7rem; flex-shrink: 0; }
.stepper li.on { color: var(--blue-800); border-color: var(--blue-600); }
.stepper li.on span { background: var(--blue-600); color: #fff; }
.stepper li.done { color: var(--green-700); border-color: var(--green-500); }
.stepper li.done span { background: var(--green-600); color: #fff; }
.step { display: flex; flex-direction: column; gap: 14px; }
.step[hidden] { display: none; }
.step-q { font-size: 1.1rem; }
.dropzone-lg { padding: 30px 16px; gap: 8px; }
.dropzone-lg .lucide { width: 36px; height: 36px; }
.dropzone-lg strong { font-size: 1rem; }
.file-preview, .summary-card, .doc-chip { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 12px; background: #fff; }
.file-preview[hidden] { display: none; }
.fp-thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--blue-50); color: var(--blue-600); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.fp-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fp-info, .doc-chip > span:last-child { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fp-info strong, .doc-chip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-info small, .doc-chip small { color: var(--muted); }
.doc-chip .fp-thumb { width: 42px; height: 42px; }
.chip-set { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip-set legend { font-weight: 600; font-size: .88rem; margin-bottom: 8px; padding: 0; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: #fff; font-weight: 600; font-size: .88rem; cursor: pointer; transition: all .15s; }
.chip input:checked + span { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid rgba(31, 94, 219, .35); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; height: 100%; padding: 16px; border: 2px solid var(--rule); border-radius: 14px; background: #fff; transition: border-color .15s, box-shadow .15s, transform .1s; }
.choice-card strong { font-family: var(--font-display); font-size: 1rem; }
.choice-card small { color: var(--muted); line-height: 1.35; }
.choice-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; }
.choice input:checked + .choice-card { border-color: var(--green-600); box-shadow: 0 0 0 4px rgba(22, 185, 122, .15); }
.choice input:focus-visible + .choice-card { outline: 3px solid rgba(31, 94, 219, .35); }
.choice:hover .choice-card { transform: translateY(-1px); }
.choice-row .choice-card { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
.choice-row .choice-card > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.rec { font-style: normal; font-size: .68rem; font-weight: 700; color: var(--green-700); background: var(--green-100); padding: 1px 7px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; }
.send-how { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.send-how legend { font-weight: 600; font-size: .88rem; margin-bottom: 8px; padding: 0; }
.cert-fields[hidden] { display: none; }
.cert-fields { padding: 12px; border-radius: 12px; background: var(--blue-50); border: 1px solid #C8D8F5; }
.summary-card { align-items: flex-start; }
.summary-list { margin: 0; display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.summary-list div { display: flex; gap: 10px; font-size: .9rem; }
.summary-list dt { color: var(--muted); width: 48px; flex-shrink: 0; }
.summary-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.summary-list div[hidden] { display: none; }
.upload-progress[hidden] { display: none; }
.upload-progress small { color: var(--muted); }
.step-error[hidden] { display: none; }
.quick-to { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--rule); background: #fff; font: 600 .8rem var(--font-text); color: var(--ink); cursor: pointer; }
.chip-btn small { color: var(--muted); font-weight: 400; }
.chip-btn .lucide { width: 13px; height: 13px; color: var(--green-600); }
.chip-btn:hover { border-color: var(--blue-500); }
.sheet-done { align-items: center; text-align: center; padding: 34px 24px; }
.sheet-done[hidden] { display: none; }
.done-tick { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--green-600); color: #fff; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
.done-tick .lucide { width: 32px; height: 32px; stroke-width: 3; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-foot[hidden] { display: none; }

/* document rows */
.copies-card .card-head { margin-bottom: 6px; }
.copies-empty { text-align: center; padding: 22px 10px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.copies-empty h3 { font-size: 1.1rem; }
.copies-empty p { max-width: 360px; }
.copies-illus { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue-600); border: 2px dashed #B9CBEE; }
.copies-illus .lucide { width: 30px; height: 30px; }
.doc-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--rule); }
.doc-row:last-child { border-bottom: 0; }
.doc-thumb { position: relative; width: 44px; height: 54px; border-radius: 6px; background: #fff; border: 1px solid var(--rule); color: var(--blue-600); display: grid; place-items: center; flex-shrink: 0; box-shadow: 2px 2px 0 var(--paper-3); }
.doc-thumb.is-certified { border-color: #C8D8F5; }
.doc-stamp { position: absolute; right: -8px; bottom: -6px; width: 24px; height: 24px; border-radius: 50%; background: var(--blue-700); color: #fff; display: grid; place-items: center; border: 2px solid var(--paper); transform: rotate(-12deg); }
.doc-stamp .lucide { width: 12px; height: 12px; }
.doc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-name { font-weight: 700; overflow-wrap: anywhere; }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.doc-meta small { color: var(--muted); font-size: .78rem; }
.doc-cert { align-self: flex-start; white-space: normal; }
.doc-link { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .78rem; color: var(--green-700); }
.doc-link .lucide { width: 13px; height: 13px; }
.doc-link form { margin: 0; }
.doc-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.doc-actions form { margin: 0; }
.btn-send { height: 34px; padding: 0 12px; font-size: .84rem; border-radius: 9px; background: var(--blue-50); color: var(--blue-700); border: 1px solid #C8D8F5; margin-right: 4px; }
.btn-send:hover { background: var(--blue-100); }
.btn-send .lucide { width: 15px; height: 15px; }
.doc-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 22px; margin-bottom: 14px; font-size: .9rem; color: var(--muted); }
.doc-stats strong { color: var(--ink); font-family: var(--font-display); font-size: 1.05rem; }
.doc-stats .storage { display: flex; flex-direction: column; gap: 2px; min-width: 180px; }
.doc-stats .inline-filter { margin-left: auto; }
.copy-status { display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 5px 8px; border-radius: 8px; }
.copy-status .lucide { width: 14px; height: 14px; }
.copy-status.no-copy { color: var(--muted); background: var(--paper-2); border: 1px dashed var(--border-strong); }
.copy-status.has-copy { color: var(--blue-700); background: var(--blue-50); }
.copy-status.is-certified { color: var(--green-700); background: var(--green-50); }
.copy-status.is-stale { color: var(--amber-700); background: var(--amber-100); }
.test-email { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.share-card { max-width: 480px; }
.share-from { margin: 8px 0 14px; }
.share-doc { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border: 1px solid var(--rule); border-radius: 12px; background: #fff; margin-bottom: 16px; }
.share-doc > span:last-child { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 0; }
.share-note { margin-top: 12px; }
.big-icon-muted { background: var(--paper-3); color: var(--muted); }

@media (max-width: 640px) {
  dialog.sheet { width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  dialog.sheet[open] { animation: sheet-up .3s cubic-bezier(.2, .8, .2, 1); }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
  .sheet-head::before { content: ''; position: absolute; left: 50%; top: 7px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--border-strong); }
  .sheet-head { position: relative; padding-top: 20px; }
  .sheet-foot .btn { flex: 1; }
  .sheet-foot .grow { display: none; }
  .choice-grid { grid-template-columns: 1fr; }
  .choice-grid .choice-card { flex-direction: row; align-items: center; gap: 12px; }
  .doc-row { flex-wrap: wrap; }
  .doc-actions { width: 100%; padding-left: 56px; }
  .btn-send { flex: 1; justify-content: center; }
  .doc-stats .inline-filter { margin-left: 0; width: 100%; }
}

/* "No copy yet" banner on an entry, and the "Saved ✓" intro in the Add-a-copy sheet */
.copy-nudge { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin: -6px 0 18px; border-radius: 14px; background: linear-gradient(90deg, var(--blue-50), var(--green-50)); border: 1px dashed #9FC0EE; }
.copy-nudge-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: var(--blue-600); flex-shrink: 0; box-shadow: var(--shadow); }
.copy-nudge-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.copy-nudge-text small { color: var(--muted); }
.saved-intro { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--green-50); border: 1px solid #B6E2CB; }
.saved-intro[hidden] { display: none; }
.saved-intro > span:last-child { display: flex; flex-direction: column; }
.saved-intro small { color: var(--muted); }
.done-tick-sm { width: 34px; height: 34px; flex-shrink: 0; }
.done-tick-sm .lucide { width: 18px; height: 18px; }
@media (max-width: 640px) {
  .copy-nudge { flex-wrap: wrap; margin-top: 0; }
  .copy-nudge .btn { width: 100%; }
}

/* Chapter pages: whole card opens the entry; the upload button sits on top of that link */
.record-card { cursor: pointer; }
.record-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.record-link:focus-visible { outline: 3px solid rgba(31, 94, 219, .35); outline-offset: 2px; }
.copy-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.copy-row .copy-status { flex: 1; min-width: 0; }
.card-upload {
  position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid #C8D8F5; background: var(--blue-50); color: var(--blue-700);
  font: 700 .8rem var(--font-text); cursor: pointer; white-space: nowrap;
}
.card-upload .lucide { width: 15px; height: 15px; }
.card-upload:hover { background: var(--blue-100); }
.card-upload.is-primary { background: var(--green-600); border-color: var(--green-600); color: #fff; box-shadow: 0 3px 8px rgba(14, 159, 103, .25); }
.card-upload.is-primary:hover { background: var(--green-700); }
.type-row-upload { width: 100%; border-style: solid; border-color: #B6E2CB; background: var(--green-50); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.type-row-upload .lucide { color: var(--green-700); }
.type-row-upload:hover { border-color: var(--green-500); background: var(--green-100); }
.chip-set[hidden] { display: none; }

/* =========================================================
   Family tree (Ex Libris page)
   ========================================================= */
.tree-card { margin: 4px 0 6px; padding: 10px 10px 8px; border: 1px solid var(--rule); border-radius: 14px;
  background: radial-gradient(circle at 50% 0%, rgba(22, 185, 122, .07), transparent 60%), var(--surface); }
.tree-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tree-head .leaf-title { margin: 0; }
.tree-actions { display: flex; gap: 6px; }
.tree { overflow-x: auto; overflow-y: hidden; padding: 6px 0 4px; scrollbar-width: thin; }
.tree ul { position: relative; display: flex; justify-content: center; margin: 0; padding: 16px 0 0; }
.tree > ul { padding-top: 0; min-width: max-content; margin: 0 auto; }
.tree li { position: relative; list-style: none; display: flex; flex-direction: column; align-items: center; padding: 16px 5px 0; }
.tree > ul > li { padding-top: 0; }
/* connectors: horizontal bar across siblings + vertical drop to each child */
.tree li::before, .tree li::after { content: ''; position: absolute; top: 0; width: 50%; height: 16px; border-top: 2px solid var(--border-strong); }
.tree li::before { right: 50%; }
.tree li::after { left: 50%; border-left: 2px solid var(--border-strong); }
.tree li:only-child::before, .tree li:only-child::after { display: none; }
.tree li:only-child { padding-top: 16px; }
.tree li:first-child::before, .tree li:last-child::after { border: 0 none; }
.tree li:last-child::before { border-right: 2px solid var(--border-strong); border-radius: 0 8px 0 0; }
.tree li:first-child::after { border-radius: 8px 0 0 0; }
.tree > ul > li::before, .tree > ul > li::after { display: none; }
.tree > ul > li { padding-top: 0; }
.tree ul ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 16px; border-left: 2px solid var(--border-strong); }
.tree li:only-child::after { display: block; left: 50%; width: 0; border-top: 0; border-left: 2px solid var(--border-strong); }
.couple { display: flex; align-items: flex-start; gap: 2px; position: relative; }
.couple-link { align-self: center; margin-top: -18px; color: #E07A8B; }
.couple-link .lucide { width: 14px; height: 14px; fill: currentColor; }
.tp { display: flex; flex-direction: column; align-items: center; width: 66px; text-align: center; }
.tp-photo { position: relative; width: 46px; height: 46px; border-radius: 50%; padding: 0; border: 2px solid #fff; background: var(--blue-100); color: var(--blue-700);
  box-shadow: 0 0 0 2px var(--border-strong), 0 3px 8px rgba(0, 0, 0, .08); cursor: pointer; overflow: visible; display: grid; place-items: center; }
.tp-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.tp-initials { font-family: var(--font-display); font-weight: 800; font-size: .8rem; }
.tp-cam { position: absolute; right: -4px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%; background: var(--green-600); color: #fff; display: grid; place-items: center; border: 2px solid #fff; opacity: 0; transition: opacity .15s; }
.tp-cam .lucide { width: 10px; height: 10px; }
.tp-photo:hover .tp-cam, .tp-photo:focus-visible .tp-cam, .tp-photo.is-uploading .tp-cam { opacity: 1; }
.tp-photo:not(:has(img)) .tp-cam { opacity: 1; }
.tp-me .tp-photo { width: 54px; height: 54px; box-shadow: 0 0 0 3px #D9B04A, 0 4px 12px rgba(217, 176, 74, .35); background: var(--green-100); color: var(--green-700); }
.tp-partner .tp-photo { box-shadow: 0 0 0 2px #E7A9B4, 0 3px 8px rgba(0, 0, 0, .08); }
.tp-name { margin-top: 4px; font-family: var(--font-display); font-weight: 700; font-size: .8rem; color: var(--ink); line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-rel { font-size: .66rem; color: var(--muted); line-height: 1.2; white-space: nowrap; }
.tree-empty, .tree-hidden { margin: 4px 4px 0; text-align: center; }
.arrange-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.arrange-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 12px; background: #fff; }
.arrange-list select { width: auto; max-width: 52%; min-height: 38px; font-size: .88rem; }
.arrange-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.arrange-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-photo-sm { width: 36px; height: 36px; cursor: default; flex-shrink: 0; }
@media (max-width: 640px) {
  .tp { width: 58px; }
  .tp-photo { width: 40px; height: 40px; }
  .tp-me .tp-photo { width: 48px; height: 48px; }
  .arrange-list li { flex-wrap: wrap; }
  .arrange-list select { max-width: 100%; width: 100%; }
}

/* no connector above the top of the tree */
.tree > ul > li:only-child::after, .tree > ul > li:only-child::before { display: none; }
.tree > ul > li:only-child { padding-top: 0; }

/* Net-worth ledger on the Money & Banking chapter opener */
.ledger-chapter { text-align: left; max-width: 420px; margin: 14px auto 4px; }
.ledger-chapter .ledger-total strong.neg { color: var(--red-600); }
.ledger-group { display: flex; flex-direction: column; margin-top: 8px; }
.ledger-head { display: flex; justify-content: space-between; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 4px 0 2px; }
.ledger-line { font-size: .88rem; color: var(--ink); text-decoration: none !important; border-radius: 6px; padding: 4px 4px; }
a.ledger-line:hover { background: var(--blue-50); }
.ledger-line > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.ledger-line .lucide { width: 14px; height: 14px; color: var(--muted); }
.ledger-empty { margin: 8px 0 0; }

/* Why this document matters (e.g. bank letter) */
.doc-hint { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--blue-50); border: 1px solid #C8D8F5; color: var(--blue-800); font-size: .85rem; line-height: 1.45; }
.doc-hint[hidden] { display: none; }
.doc-hint .lucide { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }
