/* Roots: the shelf, Roots' pages in the shared book, the GEDCOM viewer, dialogs.
   The book itself (covers, edges, arrows, the turn, the themes and their papers) and the fonts
   (EB Garamond and Cinzel for the app's own lettering too) are the shared book's: vendor/book/book.css. */

:root {
  --bg: #2a211a;
  --ink: #2b2118;
  --muted: #7a6a58;
  --accent: #8a5a2b;
  --ui-font: "EB Garamond", Georgia, serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(ellipse at 50% 30%, #3b2e23, var(--bg)); color: #f3e9d8; font: 17px/1.4 var(--ui-font); overflow: hidden; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.error { color: #b3261e; min-height: 1.2em; margin: 0.4em 0; }

/* ---- the gate: login, setup, invite ---- */
.gate { display: grid; place-items: center; height: 100%; padding: 16px; }
.card { background: #f6eedf; color: var(--ink); padding: 28px; border-radius: 10px; width: min(380px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.45); display: grid; gap: 10px; }
.card label { display: grid; gap: 4px; }
.card input { padding: 8px 10px; border: 1px solid #c9b79c; border-radius: 6px; background: #fffaf2; }
.brand { font-family: "Cinzel", serif; font-weight: 400; margin: 0; text-align: center; letter-spacing: .08em; }
button.primary { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 9px 14px; cursor: pointer; }
button.primary:disabled { opacity: .6; }

/* ---- the bar ---- */
.bar { position: fixed; z-index: 20; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: linear-gradient(rgba(20,14,9,.85), rgba(20,14,9,0)); }
.bar-title { font-family: "Cinzel", serif; letter-spacing: .06em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
button.icon { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); color: inherit; border-radius: 6px; min-width: 36px; height: 34px; cursor: pointer; position: relative; }
.tool { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); color: inherit; border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: .9em; }
.tool:hover, button.icon:hover { background: rgba(255,255,255,.18); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e0a43a; margin-left: 4px; vertical-align: top; }
button.icon .dot { position: absolute; top: 3px; right: 3px; margin: 0; }
.menu { position: absolute; right: 12px; top: calc(52px + env(safe-area-inset-top)); background: #f6eedf; color: var(--ink); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.4); display: grid; min-width: 170px; overflow: hidden; }
.menu button { background: none; border: 0; text-align: left; padding: 10px 14px; cursor: pointer; }
.menu button:hover { background: #eadcc4; }

/* ---- the shelf ---- */
.shelf-root { position: fixed; inset: 0; }
.shelf-empty-msg { position: fixed; top: 40%; left: 0; right: 0; text-align: center; color: #d8c8b0; padding: 0 20px; }
.spine { --spine-font: "Cinzel", serif; }

/* ---- the book: the shared book (vendor/book), on the stage below the bar ---- */
.stage { position: fixed; inset: calc(52px + env(safe-area-inset-top)) 0 0 0; display: flex; align-items: center; justify-content: center; }
body.with-gedcom .stage { right: min(420px, 45vw); }
/* Book settings: the shared book's panel, over everything but the bar's menu and notes. */
.panels { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.panels > * { pointer-events: auto; }
/* Where Roots' pages are measured to fit (app.js fit()): a page's size, out of sight. */
.r-measure { position: absolute; left: 0; top: 0; width: var(--page-w); height: var(--page-h); visibility: hidden; pointer-events: none; overflow: hidden; }
/* Edit belongs to the page at rest: never on a turning leaf, and not mid-turn. */
.zb-fx .edit-btn, .zb.turning .edit-btn { display: none; }

/* Roots' pages (.rp) on the book's paper (.zb-paper, its theme's), in its parts' lettering: titles
   in the title font, dates in the date font, the rest in the small text's, colors the paper's own
   unless set apart. Padding in page widths, so a page on the turning leaf is the page at rest. */
.rp { padding: calc(var(--page-w) * .07) calc(var(--page-w) * .09) calc(var(--page-w) * .09); font-size: calc(var(--page-w) * 0.033); line-height: 1.35;
  display: flex; flex-direction: column; font-family: var(--small-font, Georgia, serif); color: var(--text-ink, var(--ink)); --muted: var(--ink-soft); }
.rp .scroll { overflow: hidden; flex: 1; min-height: 0; }      /* a page never scrolls: app.js fit() makes it fit */
.rp h1, .rp h2, .rp h3 { font-family: var(--title-font, Georgia, serif); font-weight: 400; margin: 0; color: var(--title-ink, var(--ink)); }
.rp a, .rp .link { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; padding: 0; font: inherit; text-align: left; }
.rp .link:hover { color: var(--title-ink, var(--ink)); border-bottom-style: solid; }
.rp.title-page, .rp.dedication, .rp.appendix-title { justify-content: center; align-items: center; text-align: center; }
.title-page h1 { font-size: 2.6em; letter-spacing: .04em; text-wrap: balance; overflow-wrap: break-word; }
.title-page .zb-ornament { font-size: 2.2em; margin: .4em 0; }
.title-page .sub { font-style: italic; font-size: 1.1em; }
.dedication .for { font-style: italic; font-size: 1.5em; margin-bottom: 1em; }
.dedication .readers { display: grid; gap: .3em; }
.contents h2 { text-align: center; font-size: 1.6em; margin-bottom: .8em; }
.contents ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .15em; }
.contents li { display: flex; align-items: baseline; gap: .4em; }
.contents li .fill { flex: 1; border-bottom: 1px dotted currentColor; opacity: .45; transform: translateY(-.25em); }
.contents li .years { color: var(--muted); font-size: .85em; font-family: var(--date-font, inherit); }
.empty-note { text-align: center; color: var(--muted); font-style: italic; margin-top: 2em; }

.person .gen { text-transform: uppercase; letter-spacing: .14em; font-size: .7em; color: var(--muted); text-align: center; }
.person .kin { text-align: center; font-style: italic; color: var(--muted); margin-top: .3em; }
.person h2 { text-align: center; font-size: 1.7em; line-height: 1.1; margin: .1em 0 0; }
.person .span { text-align: center; color: var(--muted); }
.person .aka { text-align: center; font-style: italic; color: var(--muted); font-size: .92em; margin-top: .15em; }
/* A person's page is a column: the hero takes the room left after the name, dates and family,
   whatever the photo's shape (contained, never cropped or bigger than the page allows). */
.person .scroll { display: flex; flex-direction: column; }
.person .scroll > * { flex: none; }
.person .scroll > .hero-box { flex: 1 1 0; min-height: 0; position: relative; margin: .5em 0; }
.person .hero { position: absolute; inset: 0; margin: auto; display: block; width: auto; height: auto; max-width: 64%; max-height: 100%; object-fit: contain;
  border: 6px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.3); background: #ddd; cursor: zoom-in; }
.person .hero.none { display: grid; place-items: center; height: min(100%, 12em); max-height: none; aspect-ratio: 4 / 5; font-family: var(--title-font); font-size: 1em; color: #a8977c; background: rgba(0,0,0,.05); border: 2px dashed rgba(0,0,0,.15); box-shadow: none; cursor: default; }
.person .hero.none span { font-size: 2.6em; }
.person .facts { margin: .2em 0 .5em; text-align: center; font-family: var(--date-font, inherit); }
.person .facts div { margin: .1em 0; }
.rp .place { cursor: help; border-bottom: 1px dotted currentColor; }
.rp .place:focus { outline: none; background: rgba(138,90,43,.08); }
.person .fam { display: grid; grid-template-columns: auto 1fr; gap: .15em .7em; font-size: .92em; }
.person .fam dt { color: var(--muted); font-variant: small-caps; letter-spacing: .04em; }
.person .fam dd { margin: 0; }
.person .fam dd span + span::before { content: ", "; }
/* (Roots #15) The family line along a couple's spread (app.js familyLine): a band at the foot of
   each page, out to just short of the gutter, everything in it placed by the spread's plan (in
   the band's own font and width), so the two halves meet as one line. */
.person .fline { flex: none; position: relative; margin-top: .3em; font-family: var(--small-font, Georgia, serif); line-height: 1.15; }
.person .fline.side-l { margin-right: calc(var(--page-w) * -.07); }
.person .fline.side-r { margin-left: calc(var(--page-w) * -.07); }
.fline .fl-rule { position: absolute; left: 0; right: 0; border-top: 1px solid var(--text-ink, var(--ink)); }
.fline .fl-row { opacity: .75; }
.fline .fl-join { position: absolute; border-left: 1px solid var(--text-ink, var(--ink)); opacity: .75; }
.fline.side-l .fl-join { right: 0; }
.fline.side-r .fl-join { left: 0; }
.fline .fl-drop { position: absolute; width: 0; border-left: 1px solid var(--text-ink, var(--ink)); }
.fline .fl-text { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-end; line-height: 1.25; }
.fline .fl-text > span { padding-bottom: .1em; }
.fline .fl-name { position: absolute; white-space: nowrap; text-align: center; line-height: 1.15; }
.rp .fline .link.fl-name { text-align: center; border-bottom: 0; }
.fline .fl-name span { display: block; }
.rp .fline .link.fl-name span { text-decoration: underline dotted; text-underline-offset: .15em; }
.rp .fline .link.fl-name:hover span { text-decoration-style: solid; }
.fl-probe { position: absolute; left: 0; top: 0; visibility: hidden; white-space: nowrap; font-size: 100px; line-height: 1; font-family: var(--small-font, Georgia, serif); }
.person .docs { display: flex; gap: .5em; flex-wrap: wrap; margin-top: .6em; justify-content: center; }
.doc-thumb { width: 3.6em; height: 4.6em; border: 1px solid #b8a688; background: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb .pdf, .doc-big .pdf { font-family: var(--title-font); color: #8a2b1e; font-size: .9em; }
.edit-btn { position: absolute; top: 0.9%; right: 1.4%; z-index: 4; font-size: 12px; padding: 3px 8px; border-radius: 5px; border: 1px solid #b8a688; background: #fffaf2; color: var(--ink); cursor: pointer; }
.photos h3 { text-align: center; margin-bottom: .6em; }
/* Extra photos: prints in the book's mounting, placed by app.js printBoxes() (grid or collage). */
.r-prints { position: relative; flex: 1; min-height: 0; }
.appendix-title h2 { font-size: 2em; }
.document h3 { text-align: center; margin-bottom: .4em; }
.doc-big { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; }
.doc-big img { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: zoom-in; }
.doc-big .pdf-tile { display: grid; gap: .5em; place-items: center; padding: 2em; border: 1px solid #b8a688; background: #fff; }
.document .back { text-align: center; margin-top: .5em; }

/* ---- the GEDCOM viewer ---- */
.gedcom { position: fixed; z-index: 15; top: 52px; right: 0; bottom: 0; width: min(420px, 45vw); background: #f6eedf; color: var(--ink); display: flex; flex-direction: column; gap: 8px; padding: 12px; box-shadow: -10px 0 30px rgba(0,0,0,.4); }
@media (max-width: 800px) { .gedcom { width: 100%; } body.with-gedcom .stage { right: 0; } }
.gedcom-head { display: flex; justify-content: space-between; align-items: center; }
.gedcom .icon { color: var(--ink); background: #eadcc4; }
.gedcom-files { display: flex; gap: 6px; }
.gedcom-files select { flex: 1; min-width: 0; }
.gedcom .tool, .card .tool, dialog .tool { color: var(--ink); background: #eadcc4; border-color: #c9b79c; }
.file-btn { display: inline-block; }
.gedcom input[type=search] { padding: 6px 8px; border: 1px solid #c9b79c; border-radius: 6px; }
.gedcom-results { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 34%; border-bottom: 1px solid #d8c8ac; }
.gedcom-results li button, .gedcom-person button.g-link { background: none; border: 0; padding: 3px 2px; cursor: pointer; text-align: left; color: #6b3f16; width: 100%; }
.gedcom-results li button:hover { background: #eadcc4; }
.gedcom-person { overflow-y: auto; flex: 1; }
.gedcom-person h3 { margin: .2em 0; font-weight: 400; font-size: 1.3em; }
.gedcom-person h4 { margin: .8em 0 .2em; font-variant: small-caps; color: var(--muted); font-weight: 400; }
.gedcom-person ul { margin: 0; padding-left: 1em; }
.gedcom-person .note { white-space: pre-wrap; font-size: .9em; }

/* ---- dialogs ---- */
/* Everything inside a dialog fits its width: padding all round, fields that shrink, rows that
   stack on a phone, long words that wrap. Nothing scrolls sideways. */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100vh - 40px); overflow-x: hidden; overflow-wrap: anywhere; background: #f6eedf; color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(10,6,3,.55); }
dialog form { padding: 22px 24px; display: grid; gap: 10px; min-width: 0; }
dialog form > *, #dialog-body > *, dialog .row > *, dialog .row3 > *, dialog fieldset > *, dialog label > * { min-width: 0; }
#dialog-body { display: grid; gap: 10px; }
#dialog-error { margin: 0; }
#dialog-error:empty { display: none; }
dialog h2 { margin: 0 0 4px; font-weight: 400; font-family: "Cinzel", serif; }
dialog label { display: grid; gap: 3px; font-size: .95em; }
dialog input, dialog select, dialog textarea { padding: 6px 8px; border: 1px solid #c9b79c; border-radius: 6px; background: #fffaf2; width: 100%; min-width: 0; max-width: 100%; }
dialog input[type=radio], dialog input[type=checkbox] { width: auto; padding: 0; }
dialog input[type=file] { padding: 4px; }
dialog .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: end; }
dialog .row3 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr); gap: 8px; }
dialog span.row { align-items: center; grid-template-columns: minmax(0, 1fr) auto; }
dialog fieldset { border: 1px solid #d8c8ac; border-radius: 8px; padding: 8px 12px 12px; margin: 0; display: grid; gap: 6px; min-width: 0; }
dialog legend { color: var(--muted); padding: 0 4px; }
dialog .list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
dialog .list li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; }
dialog .list li .name { flex: 1 1 8em; min-width: 0; }
dialog .list li input { width: auto; }
dialog .list li .name > span { margin-right: .4em; }
dialog .marriage-fields { display: grid; gap: 8px; }
dialog .marriage-block { display: grid; gap: 4px; }
dialog .marriage-block + .marriage-block { border-top: 1px solid #e2d5bd; padding-top: 10px; margin-top: 4px; }
dialog label.check { align-self: end; padding-bottom: 8px; }
dialog .list li input[data-doc-year] { flex: 0 0 4.5em; }
dialog .list li.other-name select { flex: 0 1 9em; width: auto; }
dialog .list li.other-name input[data-on=name] { flex: 2 1 8em; }
dialog .list li.other-name input[data-on=from] { flex: 1 1 6em; }
@media (max-width: 480px) {
  dialog form { padding: 18px 16px; }
  dialog .row, dialog .row3 { grid-template-columns: minmax(0, 1fr); }
  dialog span.row { grid-template-columns: minmax(0, 1fr) auto; }
}
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.actions button, dialog .mini { border-radius: 6px; padding: 6px 12px; border: 1px solid #c9b79c; background: #eadcc4; cursor: pointer; color: var(--ink); }
dialog .mini { padding: 2px 8px; font-size: .85em; }
.actions .primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.actions .danger, dialog .mini.danger { color: #9b2c1f; }
.guide-page h1 { font-family: "Cinzel", serif; font-weight: 400; font-size: 1.3em; }
.guide-page h2 { font-size: 1.1em; margin: 1em 0 .2em; }
.guide-page { max-height: 60vh; overflow-y: auto; }

.lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.85); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 94vh; }
.toast { position: fixed; z-index: 50; inset: auto auto 20px 50%; margin: 0; transform: translateX(-50%); border: 0; background: #f6eedf; color: var(--ink); padding: 8px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: calc(100vw - 24px); }
.toast { display: none; }
.toast.open { display: block; }
.toast-undo { margin-left: 12px; border: 1px solid var(--accent); background: none; color: var(--accent); border-radius: 5px; padding: 2px 10px; cursor: pointer; }
dialog .thumb-small { max-width: 90px; }
/* Known places, suggested under a place field as you type */
dialog label:has(> .place-suggest) { position: relative; }
dialog .place-suggest { position: absolute; z-index: 6; top: 100%; left: 0; right: 0; list-style: none; margin: 2px 0 0; padding: 4px; border: 1px solid #c9b79c; border-radius: 6px; background: #fffaf2; display: grid; gap: 1px; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
dialog .place-suggest button { width: 100%; text-align: left; background: none; border: 0; padding: 4px 6px; border-radius: 4px; cursor: pointer; color: var(--ink); font-size: .92em; }
dialog .place-suggest li.active button, dialog .place-suggest button:hover { background: #eadcc4; }
dialog .hero-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
dialog .replace { display: grid; gap: 6px; border-top: 1px solid #e2d5bd; padding-top: 8px; }
dialog .picks { display: flex; gap: 6px; flex-wrap: wrap; }
dialog .pick { width: 64px; height: 64px; padding: 0; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); background: #ddd; cursor: pointer; }
dialog .pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
dialog .pick:hover { outline: 2px solid var(--accent); }
