/* The Kowallis Family: shared styles. Colors are tokens with a dark theme. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #1b1e22;
  --muted: #5e6772;
  --border: #dce1e7;
  --accent: #2c6bd1;
  --accent-text: #ffffff;
  --accent-soft: #e6eefb;
  --danger: #b4321f;
  --star: #e2a400;
  --ok: #1d7a3d;
  --ok-soft: #e3f4e8;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 4px 16px rgba(20, 30, 40, .06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --surface: #1a1d22; --surface-2: #23272e; --text: #e7e9ec; --muted: #9aa3ae;
    --border: #2f343c; --accent: #6aa2ff; --accent-text: #0d1420; --accent-soft: #1b2a42;
    --danger: #ff8b78; --star: #ffc93d; --ok: #7fd49a; --ok-soft: #1b3325; --warn: #f0cf7a; --warn-soft: #3a3017; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --surface: #1a1d22; --surface-2: #23272e; --text: #e7e9ec; --muted: #9aa3ae;
  --border: #2f343c; --accent: #6aa2ff; --accent-text: #0d1420; --accent-soft: #1b2a42;
  --danger: #ff8b78; --star: #ffc93d; --ok: #7fd49a; --ok-soft: #1b3325; --warn: #f0cf7a; --warn-soft: #3a3017; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- Buttons & fields ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="search"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
}
textarea { min-height: 84px; resize: vertical; }

.error { color: var(--danger); font-size: .92rem; margin: 8px 0 0; }

/* ---- Sign-in page ---- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 24px;
}
.auth-card h1 { font-size: 1.5rem; margin: 0 0 4px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 20px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; margin-top: 6px; }

/* ---- Plain text pages (privacy policy) ---- */
.doc-page { max-width: 720px; margin: 0 auto; padding: 32px 16px 64px; }
.doc-page h1 { margin: 0 0 4px; }
.doc-page h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.doc-page .sub { color: var(--muted); margin: 0 0 20px; }
.doc-page li { margin: 6px 0; }
.doc-page code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; }

/* ---- Admin ---- */
.admin-page { max-width: 820px; margin: 0 auto; padding: 24px 16px 64px; }
.admin-page h1 { margin: 0 0 16px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: grid; gap: 12px;
}
.panel h2 { margin: 0; font-size: 1.15rem; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .9rem; }
.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.badge.ok, .notice.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice { margin: 0; padding: 10px 14px; border-radius: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.admin-page .panel + .panel { margin-top: 16px; }
.history-heading { margin: 4px 0 0; font-size: 1rem; }
.table-scroll { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.history-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 12px 6px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.history-table td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.history-table td:nth-child(-n+3) { white-space: nowrap; }
.history-table tr:last-child td { border-bottom: 0; }
@media (max-width: 600px) {
  .history-table thead { display: none; }
  .history-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .history-table tr:last-child { border-bottom: 0; }
  .history-table td { padding: 0; border: 0; }
  .history-table td:nth-child(4) { flex-basis: 100%; color: var(--muted); }
  .history-table td:nth-child(1)::after { content: ' ·'; }
  .history-table td:nth-child(2)::before { content: 'for '; color: var(--muted); }
}
.email-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }

/* ---- Upload ---- */
.upload-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.upload-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.upload-top { display: flex; justify-content: space-between; gap: 12px; }
.upload-name { font-weight: 600; overflow-wrap: anywhere; }
.upload-item progress { width: 100%; height: 8px; accent-color: var(--accent); }
.upload-item.done .upload-msg { color: var(--ok); }
.upload-item.failed .upload-msg, .upload-item.invalid .upload-msg { color: var(--danger); }
.upload-item.duplicate .upload-msg { color: var(--warn); }
.upload-item.duplicate, .upload-item.invalid { opacity: .8; }

/* ---- Add details ---- */
.details-page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
.details-page h1 { margin: 0 0 16px; }
.details-layout { display: grid; gap: 16px; grid-template-columns: minmax(220px, 300px) 1fr; align-items: start; }
.waiting h2 { display: flex; align-items: center; gap: 8px; }
.waiting-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 70vh; overflow-y: auto; }
.waiting-item {
  width: 100%; text-align: left; display: grid; gap: 2px; padding: 8px 10px; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
}
.waiting-item:hover { background: var(--surface-2); }
.waiting-item[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); }
.waiting-name { font-weight: 600; overflow-wrap: anywhere; }
.preview { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; }
.preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid select + input { margin-top: 6px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 0; }
legend { font-size: .85rem; color: var(--muted); padding: 0 4px; }
fieldset .row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
fieldset .row > input, fieldset .row > select { flex: 1 1 180px; width: auto; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .95rem; margin: 0; }
label.check input { width: 18px; height: 18px; }
.member-list { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-top: 8px; }
.saved { color: var(--muted); font-size: .9rem; align-self: center; }
@media (max-width: 760px) {
  .details-layout { grid-template-columns: 1fr; }
  .waiting-list { max-height: 240px; }
}

/* ---- Frames with people ---- */
.btn-small { min-height: 32px; padding: 4px 12px; font-size: .88rem; }
.frames-panel { display: grid; gap: 8px; margin-bottom: 14px; }
.frames-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); }
.frames-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filmstrip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.frame-thumb {
  position: relative; flex: 0 0 auto; width: 160px; aspect-ratio: 16 / 9; padding: 0; cursor: pointer;
  border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--surface-2); scroll-snap-align: start;
}
.frame-thumb:hover, .frame-thumb:focus-visible { border-color: var(--accent); }
.frame-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame-thumb img.missing { visibility: hidden; }
.frame-time {
  position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.7); color: #fff;
  font-size: .75rem; padding: 0 5px; border-radius: 4px;
}
dialog.lightbox {
  width: min(1400px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0;
  border: 0; border-radius: var(--radius); background: #000; color: #fff;
}
dialog.lightbox::backdrop { background: rgba(0, 0, 0, .85); }
.lightbox img { display: block; width: 100%; max-height: calc(100vh - 90px); object-fit: contain; background: #000; }
.lightbox-bar { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; }
.lightbox-bar .btn { background: #222; border-color: #444; color: #fff; }
.lightbox-bar .btn-ghost { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); }
.lightbox-bar span { min-width: 220px; text-align: center; font-size: .92rem; }

/* ---- App header ---- */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.app-header .brand { font-weight: 700; font-size: 1.1rem; margin-right: auto; }
.app-header .who { color: var(--muted); font-size: .92rem; }

/* Admin ▾ menu in the header (js/nav-menu.js closes it on outside click / Esc). */
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after {
  content: ""; border: 4px solid transparent; border-top-color: currentColor; border-bottom: 0;
  margin-top: 3px; opacity: .7;
}
.nav-menu[open] > summary { background: var(--surface-2); }
.nav-menu-list {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; min-width: 170px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.nav-menu-list a { padding: 8px 12px; border-radius: 6px; color: var(--text); text-decoration: none; }
.nav-menu-list a:hover { background: var(--surface-2); }
.nav-menu-list a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ---- Backups page ---- */
.backup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: .82rem; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.facts dd small { display: block; font-weight: 400; color: var(--muted); }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.meter.warn > span { background: var(--warn); }
.backup-log {
  margin: 0; padding: 10px 12px; max-height: 320px; overflow: auto; border-radius: 8px;
  background: var(--surface-2); font: .82rem/1.55 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.backup-log .failed { color: var(--danger); font-weight: 600; }
.backup-log .backup { color: var(--ok); }
.backup-files td:nth-child(n+2) { white-space: nowrap; }
.backup-files .newest td:first-child { font-weight: 600; }

/* ---- Library layout ---- */
.library { max-width: 1280px; margin: 0 auto; padding: 16px; }
.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
}
.banner .btn { min-height: 34px; padding: 4px 12px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; min-height: 36px;
}
.tab[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.filters {
  display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.filters .wide { grid-column: 1 / -1; }
.filters-actions { display: flex; gap: 8px; align-items: end; }

/* People picker: a button that opens a checkbox list. */
.multi { position: relative; }
.multi-button {
  display: flex; align-items: center; width: 100%; min-height: 40px; padding: 8px 32px 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer;
  text-align: left; position: relative;
}
.multi-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-button::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.multi-button[aria-expanded="true"]::after { transform: rotate(-135deg); margin-top: -2px; }
.multi-button.active { border-color: var(--accent); background: var(--accent-soft); }
.multi-panel {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0;
  width: max(100%, 280px); max-width: calc(100vw - 32px);
  display: grid; gap: 8px; padding: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.multi-match { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .9rem; }
.multi-match label { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: inherit; cursor: pointer; }
.multi-list { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; }
.multi-heading { margin: 8px 4px 2px; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.multi-group:first-child .multi-heading { margin-top: 0; }
.multi-list label {
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 6px 4px; border-radius: 6px;
  color: var(--text); font-size: .95rem; cursor: pointer;
}
.multi-list label:hover { background: var(--surface-2); }
.multi-list input, .multi-match input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.multi-list label > span:first-of-type { flex: 1; }
.multi-count { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.multi-foot { display: flex; justify-content: space-between; gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px;
  border-radius: 999px; background: var(--accent-soft); font-size: .9rem;
}
.chip button { border: 0; background: transparent; cursor: pointer; padding: 2px 6px; border-radius: 999px; }

.result-line { color: var(--muted); margin: 8px 2px 14px; font-size: .92rem; }

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.card .thumb-btn { display: block; border: 0; padding: 0; background: var(--surface-2); cursor: pointer; }
.card .thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); }
.card .duration {
  position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.7); color: #fff;
  font-size: .78rem; padding: 1px 6px; border-radius: 4px;
}
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .title { font-weight: 600; margin: 0; line-height: 1.3; }
.card .title button { all: unset; cursor: pointer; }
.card .title button:focus-visible { outline: 3px solid var(--accent); border-radius: 4px; }
.card .meta { color: var(--muted); font-size: .85rem; }
.card .people { font-size: .85rem; }
.fav {
  position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border-radius: 999px;
  border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.fav[aria-pressed="true"] { color: var(--star); }

.empty, .loading { text-align: center; color: var(--muted); padding: 48px 16px; }
.more { display: flex; justify-content: center; margin: 24px 0; }

/* ---- Player dialog ---- */
dialog.player {
  width: min(980px, calc(100vw - 24px)); max-height: calc(100vh - 24px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog.player::backdrop { background: rgba(0, 0, 0, .65); }
.player .frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.player .frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player .frame .no-source { position: absolute; inset: 0; display: grid; place-items: center; color: #ccc; }
.player .details { padding: 14px 18px 18px; display: grid; gap: 10px; }
.player .head { display: flex; gap: 10px; align-items: start; }
.player .head h2 { margin: 0; font-size: 1.2rem; flex: 1; }
.player .facts { color: var(--muted); font-size: .92rem; }
.player .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.player .notes-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.player .saved { color: var(--muted); font-size: .88rem; }

/* ---- Slideshow ---- */
.slideshow-body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.slideshow {
  position: relative; flex: 1; min-height: 0;
  background: #000; color: #fff; overflow: hidden; touch-action: pan-y;
}
.slide {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 0; transition: opacity .9s ease;
}
.slide.visible { opacity: 1; }
.slide:not([src]) { visibility: hidden; }
.slideshow-empty {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center;
  gap: 12px; padding: 16px; text-align: center; color: #ccc;
}
.slideshow-bar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  width: max-content; max-width: calc(100% - 32px); padding: 8px 10px; border-radius: var(--radius);
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px); transition: opacity .4s ease;
}
.slideshow-bar .btn, .slideshow-bar select {
  min-height: 36px; background: #222; border-color: #444; color: #fff;
}
.slideshow-bar select { width: auto; padding: 4px 8px; }
.slideshow-bar .btn[aria-pressed="true"] { background: #2c6bd1; border-color: #2c6bd1; }
.slideshow-bar #prev, .slideshow-bar #next { font-size: 1.4rem; line-height: 1; padding: 4px 14px; }
.slideshow-count { min-width: 64px; text-align: center; font-size: .92rem; font-variant-numeric: tabular-nums; }
.slideshow.idle { cursor: none; }
.slideshow.idle .slideshow-bar { opacity: 0; pointer-events: none; }

/* ---- Admin: slideshow folder ---- */
.folder-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 12px; }
.folder-form > div { flex: 1 1 320px; }
.photo-upload { display: grid; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.photo-upload h3 { margin: 0; font-size: 1rem; }
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px 16px;
  display: grid; justify-items: center; gap: 8px; text-align: center;
}
.drop-zone p { margin: 0; }
.drop-zone.over { border-color: var(--accent); background: var(--surface-2); }
.drop-zone:has(input:focus-visible) label { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-manage { display: grid; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; }
.photo-manage-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.photo-manage h3 { margin: 0; font-size: 1rem; }
.photo-grid {
  list-style: none; margin: 0; padding: 2px; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); max-height: 520px; overflow-y: auto;
}
.photo-tile { position: relative; }
.photo-tile label { display: grid; gap: 4px; cursor: pointer; }
.photo-tile img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--surface-2);
  border: 3px solid transparent;
}
.photo-tile input { position: absolute; z-index: 1; top: 8px; left: 8px; width: 18px; height: 18px; accent-color: var(--danger); }
.photo-tile input:checked + img { border-color: var(--danger); opacity: .75; }
.photo-tile input:focus-visible + img { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-tile .photo-name { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; color: var(--text); font-size: .95rem; cursor: pointer; }
.check-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* ---- Birthdays ---- */
/* Season colors (date badges, month cards) and avatar colors, light and dark. */
:root {
  --winter: #2f6fb3; --spring: #2e8b57; --summer: #b07400; --fall: #c0562a; --party: #d64f7a;
  --av0: #2c6bd1; --av1: #1d7a3d; --av2: #a86b00; --av3: #c0365f;
  --av4: #6a45c2; --av5: #0f7d77; --av6: #c2551d; --av7: #4d5a6a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --winter: #86b8f0; --spring: #7fd49a; --summer: #f0c46a; --fall: #f09a73; --party: #f59bb8;
    --av0: #8ab4ff; --av1: #7fd49a; --av2: #f0c46a; --av3: #f59bb8;
    --av4: #bba2ff; --av5: #6fd6cf; --av6: #f5a77e; --av7: #b0bbc8;
  }
}
:root[data-theme="dark"] {
  --winter: #86b8f0; --spring: #7fd49a; --summer: #f0c46a; --fall: #f09a73; --party: #f59bb8;
  --av0: #8ab4ff; --av1: #7fd49a; --av2: #f0c46a; --av3: #f59bb8;
  --av4: #bba2ff; --av5: #6fd6cf; --av6: #f5a77e; --av7: #b0bbc8;
}
.season-winter { --season: var(--winter); }
.season-spring { --season: var(--spring); }
.season-summer { --season: var(--summer); }
.season-fall { --season: var(--fall); }

.birthdays-page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
.birthdays-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.birthdays-head h1 { margin: 0; }
.birthdays-tools { display: flex; align-items: center; gap: 10px; }
.view-toggle { display: flex; gap: 4px; }
.birthdays-search { width: 260px; }

/* Avatars: a photo, or initials in the person's own color. */
.avatar {
  --av: var(--av7);
  position: relative; flex: none; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
  background: color-mix(in srgb, var(--av) 18%, var(--surface)); color: var(--av);
  font-weight: 700; font-size: .85rem; letter-spacing: .02em; user-select: none;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.05rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2rem; box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--av); }
.avatar-xl.has-photo { box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--star); }
.av-0 { --av: var(--av0); } .av-1 { --av: var(--av1); } .av-2 { --av: var(--av2); } .av-3 { --av: var(--av3); }
.av-4 { --av: var(--av4); } .av-5 { --av: var(--av5); } .av-6 { --av: var(--av6); } .av-7 { --av: var(--av7); }

.milestone {
  display: inline-block; justify-self: start; margin-top: 3px; padding: 1px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--star) 24%, var(--surface)); color: var(--warn);
  font-size: .75rem; font-weight: 700; white-space: nowrap;
}

/* Today: a big banner per birthday person. */
.today-hero { display: grid; gap: 12px; margin-bottom: 24px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.hero-card {
  display: flex; align-items: center; gap: 20px; padding: 20px 22px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--star) 45%, var(--border));
  background:
    radial-gradient(circle at 90% 10%, color-mix(in srgb, var(--party) 20%, transparent), transparent 55%),
    linear-gradient(135deg, color-mix(in srgb, var(--star) 22%, var(--surface)), var(--surface));
  box-shadow: var(--shadow);
}
.hero-text { display: grid; gap: 4px; min-width: 0; }
.hero-eyebrow { margin: 0; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--warn); }
.hero-card h2 { margin: 0; font-size: clamp(1.3rem, 2.2vw, 1.7rem); line-height: 1.2; }
.hero-sub { margin: 0; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; display: none; }
.confetti.on { display: block; }

/* Coming up: a card each, with a countdown. */
.coming-up { margin-bottom: 24px; }
.coming-up h2 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; font-size: 1.15rem; }
.coming-up h2 .muted { font-weight: 400; }
.up-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.up-card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease;
}
.up-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20, 30, 40, .08), 0 10px 24px rgba(20, 30, 40, .1); }
.up-main { display: grid; gap: 1px; min-width: 0; }
.countdown {
  display: grid; place-items: center; align-content: center; width: 58px; height: 58px; border-radius: 50%;
  border: 3px solid var(--season); background: color-mix(in srgb, var(--season) 10%, var(--surface));
  color: var(--muted); font-size: .7rem; line-height: 1.05; text-transform: uppercase; letter-spacing: .03em;
}
.countdown strong { color: var(--season); font-size: 1.35rem; letter-spacing: 0; }

/* By month. */
.months { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); align-items: start; }
.month {
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--season);
  border-radius: var(--radius); padding: 12px 14px 14px; transition: opacity .2s ease;
}
.month.past { opacity: .6; }
.month.past:hover, .month.past:focus-within { opacity: 1; }
.month.current { box-shadow: 0 0 0 2px var(--season), var(--shadow); }
.month h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 1.1rem; color: var(--season); }
.month-now {
  padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: var(--season); color: var(--surface);
}
.month-count { margin-left: auto; color: var(--muted); font-size: .85rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.bday-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.bday {
  display: grid; grid-template-columns: 24px 40px 1fr; align-items: center; gap: 10px;
  padding: 5px 6px; border-radius: 10px; transition: background .15s ease, transform .15s ease;
}
.bday:hover { background: var(--surface-2); transform: translateX(2px); }
.bday.today, .bday-row.today { background: var(--warn-soft); }
.bday-day { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.bday-main { display: grid; min-width: 0; }
.bday-name { font-weight: 600; justify-self: start; text-align: left; overflow-wrap: anywhere; }
.bday-detail { color: var(--muted); font-size: .85rem; }
.bday.today .bday-detail, .bday-row.today .bday-detail { color: var(--warn); font-weight: 600; }
.link-button { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; }
.link-button:hover { text-decoration: underline; }

/* List: everyone, by next birthday. */
.bday-rows {
  list-style: none; margin: 0; padding: 6px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.bday-row {
  display: grid; grid-template-columns: 48px 40px 1fr auto; align-items: center; gap: 12px;
  padding: 6px 10px; border-radius: 10px; transition: background .15s ease;
}
.bday-row:hover { background: var(--surface-2); }
.bday-date {
  display: grid; place-items: center; align-content: center; height: 48px; border-radius: 10px;
  background: color-mix(in srgb, var(--season, var(--muted)) 13%, var(--surface));
  font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.list-sort { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 0 0 10px; }
.list-sort label { margin: 0; font-size: .9rem; font-weight: 600; color: var(--text); }
.list-sort select { width: auto; }
.age-badge { background: var(--accent-soft); }
.age-badge .bday-month { color: var(--accent); }
.bday-month { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--season, var(--muted)); }

/* Contact card. */
dialog.contact {
  width: min(460px, calc(100vw - 24px)); padding: 20px 22px 22px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog.contact::backdrop { background: rgba(0, 0, 0, .55); }
.contact-top { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; }
.contact-photo { padding: 6px; }
.contact-title { min-width: 0; }
.contact-title h2 { margin: 0; font-size: 1.3rem; line-height: 1.25; overflow-wrap: anywhere; }
.contact .facts { color: var(--muted); font-size: .9rem; margin: 4px 0 0; }
.contact-buttons { display: flex; gap: 4px; align-self: start; }
.contact .saved { color: var(--muted); font-size: .88rem; min-height: 1.3em; margin: 4px 0 8px; }
.contact-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 4px; }
.contact-list dt { color: var(--muted); font-size: .9rem; }
.contact-list dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.contact-phone { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; }
.photo-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.photo-tools label.btn { margin: 0; color: var(--text); font-size: .88rem; }
.photo-tools .saved { margin: 0; }

/* Add a person (administrators). */
dialog.add-dialog { width: min(600px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
.add-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.add-head h2 { margin: 0; font-size: 1.3rem; }
.add-grid { margin-bottom: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.add-contact { margin-bottom: 14px; }
.add-contact .add-grid { margin: 4px 0 2px; }
.add-state-zip { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.optional { color: var(--muted); font-size: .78rem; font-weight: 400; margin-left: 4px; }
.add-photo { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.add-photo label.btn { margin: 0; color: var(--text); font-size: .88rem; }
.add-actions { margin-top: 14px; }
.add-actions #deletePerson { margin-left: auto; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--accent-text); }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn-danger-outline:hover { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
dialog.confirm-dialog { width: min(420px, calc(100vw - 24px)); }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
.confirm-dialog p { margin: 0 0 16px; color: var(--muted); }
.confirm-dialog .error { margin: -6px 0 12px; color: var(--danger); }
.page-notice { margin: 0 0 16px; }

/* Families: the filter bar, and the administrators' Families dialog. */
.family-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: -6px 0 20px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.family-bar.filtered { border-color: var(--accent); background: var(--accent-soft); }
.family-bar > label:first-child { margin: 0; font-size: .9rem; font-weight: 600; color: var(--text); }
.family-bar select { width: auto; max-width: 100%; flex: 0 1 360px; }
.family-tag {
  /* Its color comes from an .av-N class (one per family). */
  display: inline-block; justify-self: start; max-width: 100%; text-align: left;
  margin-top: 3px; padding: 1px 9px 1px 7px; border: 0; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--av) 12%, var(--surface)); color: var(--av);
  font-size: .72rem; font-weight: 600; letter-spacing: .02em; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.family-tag::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 5px 1px 0;
  border-radius: 50%; background: var(--av); vertical-align: middle;
}
.family-tag:hover { background: color-mix(in srgb, var(--av) 22%, var(--surface)); }
.bday-main .family-tag + .milestone, .up-main .family-tag + .milestone { margin-top: 3px; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: .9rem; cursor: pointer; }
.check-inline input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
dialog.families-dialog { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
.families-dialog > .muted { margin: -4px 0 14px; }
.family-form { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); margin-bottom: 14px; }
.family-form h3 { margin: 0 0 8px; font-size: 1rem; }
.family-form .error { margin: 0 0 8px; }
.family-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.family-row {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 10px;
  padding: 6px 8px 6px calc(8px + var(--depth, 0) * 22px); border-radius: 8px;
}
.family-row:hover { background: var(--surface-2); }
.family-name { font-weight: 600; overflow-wrap: anywhere; }
.family-row .btn:disabled { opacity: .4; }
.family-address { display: block; font-weight: 400; font-size: .82rem; color: var(--muted); }
#familySharingNote { margin: 0 0 8px; }
.same-address { margin: 2px 0 6px; align-items: flex-start; }
.same-address input { margin-top: 3px; }
.same-address .muted { font-size: .85rem; }
input.locked { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

/* Google address lookup under a street box. */
.address-lookup { position: relative; }
.address-suggest {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px; max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.address-suggest [role="option"] {
  display: grid; gap: 1px; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: .92rem;
}
.address-suggest [role="option"] span { color: var(--muted); font-size: .82rem; }
.address-suggest [role="option"]:hover, .address-suggest [aria-selected="true"] { background: var(--accent-soft); }
.address-suggest-note { padding: 7px 10px; color: var(--muted); font-size: .88rem; }
.address-suggest-credit { padding: 4px 10px 2px; text-align: right; color: var(--muted); font-size: .72rem; }
.family-address-note {
  display: inline-block; margin-left: 8px; padding: 0 7px; border-radius: 999px; vertical-align: 1px;
  background: var(--accent-soft); color: var(--accent); font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.birthdays-tools #addPerson { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  .up-card, .bday, .month { transition: none; }
  .up-card:hover, .bday:hover { transform: none; }
}

@media (max-width: 600px) {
  .app-header .who { display: none; }
  .birthdays-page { padding: 16px 12px 48px; }
  .birthdays-tools { flex: 1 1 100%; flex-wrap: wrap; }
  .birthdays-search { order: 3; flex: 1 1 100%; width: auto; }
  .birthdays-tools #manageFamilies { margin-left: auto; }
  .birthdays-tools .btn, .birthdays-tools .tab { min-height: 36px; padding: 6px 11px; font-size: .92rem; }
  .family-bar { margin-top: -10px; }
  .family-bar select { flex: 1 1 100%; }
  .family-row { grid-template-columns: 1fr auto auto; padding-left: calc(8px + var(--depth, 0) * 14px); }
  .family-row .muted { display: none; }
  .today-hero { grid-template-columns: 1fr; }
  .hero-card { gap: 14px; padding: 14px; }
  .hero-card h2 { font-size: 1.2rem; }
  .hero-card .avatar-xl { width: 64px; height: 64px; font-size: 1.4rem; }
  .hero-actions { margin-top: 6px; }
  .bday-row { grid-template-columns: 44px 36px 1fr; gap: 10px; padding: 6px; }
  .bday-row .milestone { grid-column: 3; margin-top: -4px; }
  .bday-row .avatar { width: 36px; height: 36px; font-size: .8rem; }
  .contact-top { grid-template-columns: 1fr auto; }
  .contact-photo { grid-column: 1 / -1; grid-row: 1; justify-self: center; }
  .contact-title { grid-column: 1 / -1; text-align: center; }
  .contact-buttons { grid-column: 2; grid-row: 1; }
  .library { padding: 12px; }
  .app-header { gap: 4px 6px; padding: 8px 12px; }
  .app-header .brand { font-size: 1rem; }
  .app-header .btn-ghost { padding: 8px 10px; }
  /* Phones: one row of controls; full screen and speed stay desktop-only. */
  .slideshow-bar { bottom: 8px; gap: 6px; flex-wrap: nowrap; }
  .slideshow-bar #fullscreen, .slideshow-bar #speed { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}

/* ---- Users & Roles (administrators) ---- */
.users-page { max-width: 960px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.users-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.users-tools input[type="search"] { flex: 1 1 240px; }
.users-tools .check-row { margin: 0; }
.user-list, .role-list { list-style: none; margin: 0; padding: 0; display: grid; }
.user-row {
  display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(140px, 1fr) auto auto auto;
  align-items: center; gap: 6px 14px; padding: 10px 2px; border-top: 1px solid var(--border);
}
.user-row:first-child { border-top: 0; }
.user-row.inactive .user-main { opacity: .6; }
.user-main { display: grid; min-width: 0; }
.user-name { font-weight: 600; overflow-wrap: anywhere; }
.user-email { overflow-wrap: anywhere; }
.user-roles { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.user-roles .chip { padding: 2px 10px; font-size: .82rem; background: var(--surface-2); }
.user-roles .chip-admin { background: var(--accent-soft); color: var(--accent); }
.user-last { white-space: nowrap; }
/* On/off switch: a checkbox drawn as a sliding track. */
.switch { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: .9rem; cursor: pointer; white-space: nowrap; position: relative; }
.switch input { position: absolute; opacity: 0; width: 34px; height: 20px; margin: 0; cursor: pointer; }
.switch-track { width: 34px; height: 20px; border-radius: 999px; background: var(--border); position: relative; flex: none; transition: background .15s; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled, .switch input:disabled + .switch-track { cursor: not-allowed; opacity: .5; }
.switch.small { font-size: .85rem; color: var(--muted); }
@media (max-width: 640px) {
  .user-row { grid-template-columns: 1fr auto; }
  .user-roles, .user-last, .user-row > .switch { grid-column: 1; }
  .user-row > .btn { grid-column: 2; grid-row: 1; }
}
.role-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; padding: 10px 2px; border-top: 1px solid var(--border); }
.role-row:first-child { border-top: 0; }
.role-row strong { margin-right: 8px; }
.role-row p { margin: 4px 0 0; }
.user-dialog .new-only, .user-dialog .edit-only { display: none; }
.user-dialog.adding .new-only { display: block; }
.user-dialog:not(.adding) .edit-only { display: grid; }
.password-row { display: flex; gap: 8px; align-items: center; }
.password-row .btn { white-space: nowrap; }
.password-row input { flex: 1 1 auto; min-width: 0; font-family: ui-monospace, Consolas, monospace; }
.role-picks { margin: 0 0 4px; display: grid; gap: 6px; }
.role-pick { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 6px 2px; color: var(--text); font-size: .95rem; cursor: pointer; }
.role-pick input { width: 16px; height: 16px; margin: 3px 0 0; flex: none; accent-color: var(--accent); }
.copy-access { margin-top: 12px; }
.field-error { margin: 4px 0 0; }
.account-tools { gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.account-tools h3 { margin: 0; font-size: 1rem; }
.account-tools p { margin: 0; }

/* ---- Families: the family tree ---- */
.families-page { max-width: none; padding: 24px 16px 64px; }
.families-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; max-width: 1100px; margin: 0 auto; }
.families-head h1 { margin: 0; }
.families-page > .muted, .families-page > .notice { max-width: 1100px; margin: 8px auto 0; }
.ft-scroll { overflow-x: auto; margin-top: 16px; padding: 8px 0 24px; }
.ft { --ft-line: color-mix(in srgb, var(--muted) 45%, var(--border)); width: max-content; min-width: 100%; }
.ft ul { display: flex; justify-content: center; margin: 0; padding: 26px 0 0; position: relative; list-style: none; }
.ft > ul { padding-top: 0; }
.ft li { position: relative; padding: 26px 8px 0; text-align: center; display: flex; flex-direction: column; align-items: center; }
/* Connectors: each card hangs from a line across its brothers and sisters. */
.ft li::before, .ft li::after {
  content: ''; position: absolute; top: 0; right: 50%; width: 50%; height: 26px; border-top: 2px solid var(--ft-line);
}
.ft li::after { right: auto; left: 50%; border-left: 2px solid var(--ft-line); }
.ft li:only-child::before, .ft li:only-child::after { display: none; }
.ft li:only-child { padding-top: 0; }
.ft li:first-child::before, .ft li:last-child::after { border: 0 none; }
.ft li:last-child::before { border-right: 2px solid var(--ft-line); border-radius: 0 8px 0 0; }
.ft li:first-child::after { border-radius: 8px 0 0 0; }
.ft ul ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 26px; border-left: 2px solid var(--ft-line); }
.ft > ul > li { padding-top: 0; }
.ft > ul > li::before, .ft > ul > li::after { display: none; }

.ft-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 14px 12px; min-width: 150px; max-width: 240px; display: grid; gap: 8px; justify-items: center;
}
.ft-root { padding: 18px 26px 14px; max-width: none; border-color: color-mix(in srgb, var(--star) 55%, var(--border)); }
.ft-couple { display: flex; align-items: flex-start; justify-content: center; gap: 8px; }
.ft-person { display: grid; justify-items: center; gap: 6px; }
.ft-amp { align-self: center; margin-top: -18px; color: var(--muted); font-weight: 600; }
.ft-name { font-weight: 600; font-size: .95rem; }
.ft-person:not(.ft-lead) .ft-name { font-weight: 500; color: var(--muted); font-size: .88rem; }
.ft-surname { font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-decoration: none; }
.ft-surname:hover, .ft-surname:focus-visible { color: var(--accent); text-decoration: underline; }
.ft-root .ft-surname { font-size: 1rem; color: var(--text); }
.ft-photo { flex: none; }
.ft-xl { width: 112px; height: 112px; font-size: 2.2rem; box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--star); }
.ft-lg { width: 80px; height: 80px; font-size: 1.6rem; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--av, var(--border)); }
.ft-md { width: 58px; height: 58px; font-size: 1.15rem; margin-top: 11px; }
.ft-sm { width: 36px; height: 36px; font-size: .78rem; }
.ft-empty { background: var(--surface-2); color: var(--muted); border: 2px dashed var(--ft-line, var(--border)); }
.ft-silhouette { width: 62%; height: 62%; fill: currentColor; opacity: .55; }
.ft-kids { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; padding-top: 8px; border-top: 1px solid var(--border); width: 100%; }
.ft-kid { display: grid; justify-items: center; gap: 2px; width: 46px; }
.ft-kid-name { font-size: .72rem; color: var(--muted); max-width: 46px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-pick-label { display: grid; gap: 4px; margin: 0; font-size: .78rem; width: 100%; text-align: left; }
.ft-pick { font-size: .85rem; padding: 4px 6px; }

/* Phones: the same tree as an indented list, top to bottom. */
@media (max-width: 720px) {
  .ft { width: auto; }
  .ft ul { display: block; padding: 0 0 0 22px; }
  .ft > ul { padding-left: 0; }
  .ft li { display: block; padding: 12px 0 0 0; text-align: left; }
  .ft ul ul::before { display: none; }
  .ft ul ul > li::before {
    display: block; content: ''; position: absolute; left: -14px; top: 0; width: 12px; height: 46px; right: auto;
    border: 0; border-left: 2px solid var(--ft-line); border-bottom: 2px solid var(--ft-line); border-radius: 0 0 0 8px;
  }
  .ft ul ul > li::after {
    display: block; content: ''; position: absolute; left: -14px; top: 0; bottom: 0; width: 0; height: auto;
    border: 0; border-left: 2px solid var(--ft-line); border-radius: 0;
  }
  .ft ul ul > li:last-child::after { display: none; }
  .ft ul ul > li:only-child { padding-top: 12px; }
  .ft-card { max-width: none; justify-items: start; }
  .ft-couple { justify-content: flex-start; }
  .ft-kids { justify-content: flex-start; }
}

/* Families: administrators' photo menu. */
.ft-photo[data-photo-for] { cursor: context-menu; }
.ft-photo[data-photo-for]:hover { filter: brightness(1.05); outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
.ft-photo[data-photo-for]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.ft-photo[aria-expanded="true"] { outline: 3px solid var(--accent); outline-offset: 3px; }
.ft-photo.ft-drop { outline: 3px dashed var(--accent); outline-offset: 3px; filter: brightness(1.1); }
.ft-photo.ft-busy::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  border: 3px solid transparent; border-top-color: var(--accent); animation: ft-spin .8s linear infinite;
}
@keyframes ft-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ft-photo.ft-busy::after { animation: none; } }
.ft-menu {
  position: fixed; z-index: 50; min-width: 190px; padding: 6px; display: grid;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.ft-menu[hidden] { display: none; }
.ft-menu-title { margin: 2px 8px 6px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.ft-menu [role="menuitem"] {
  display: block; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px; background: none;
  color: inherit; font: inherit; font-size: .95rem; text-decoration: none; cursor: pointer;
}
.ft-menu [role="menuitem"][hidden] { display: none; }
.ft-menu [role="menuitem"]:hover, .ft-menu [role="menuitem"]:focus-visible { background: var(--surface-2); outline: none; }
.ft-menu [data-act="remove"] { color: var(--danger); }

/* ---------- On this day (library home) ---------- */
.otd { margin-bottom: 18px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.otd-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.otd-head h2 { margin: 0; font-size: 1.1rem; }
.otd-head .btn { margin-left: auto; }
.otd-strip { display: flex; gap: 12px; overflow-x: auto; padding: 12px 2px 4px; scroll-snap-type: x proximity; }
.otd-card {
  flex: 0 0 240px; scroll-snap-align: start; display: grid; gap: 4px; text-align: left;
  padding: 0 0 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  color: var(--text); font: inherit; cursor: pointer; overflow: hidden;
}
.otd-card:hover { border-color: var(--accent); }
.otd-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.otd-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--border); }
.otd-photo img { aspect-ratio: 4 / 3; }
.otd-when { padding: 0 10px; font-size: .8rem; font-weight: 600; color: var(--accent); }
.otd-title { padding: 0 10px; font-size: .9rem; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.photo-view { padding: 0; border: 0; border-radius: var(--radius); background: #000; max-width: min(96vw, 1400px); max-height: 94vh; }
.photo-view::backdrop { background: rgba(0, 0, 0, .8); }
.photo-view img { display: block; max-width: 100%; max-height: calc(94vh - 52px); margin: 0 auto; }
.photo-view-bar { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; color: #eee; }
.photo-view-bar span { flex: 1; }
.photo-view-bar .btn { color: #eee; }

/* ---------- Users: the morning email's two switches ---------- */
.user-emails { display: grid; gap: 4px; }

/* ---------- Person page ---------- */
.person-page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.person-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 24px; margin-bottom: 16px; }
.person-title h1 { margin: 0 0 4px; font-size: 1.7rem; }
.person-title .facts { margin: 0 0 6px; color: var(--muted); }
.person-links { margin: 0; }
.person-links a { color: var(--accent); }
.person-contact { max-width: 640px; margin-bottom: 24px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.person-videos-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.person-videos-head h2 { margin: 0; font-size: 1.3rem; }
.person-link-box { margin-bottom: 16px; background: var(--surface-2); }
.person-link-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
#linkEditor { margin-top: 10px; display: grid; gap: 8px; }
.link-picks { max-height: 260px; overflow-y: auto; display: grid; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.link-picks .check-row { margin: 0; }
.person-year { margin-bottom: 22px; }
.person-year h3 { margin: 0 0 10px; font-size: 1.1rem; display: flex; gap: 8px; align-items: baseline; }
.person-video-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.person-video { position: relative; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.person-video-link { display: grid; gap: 4px; padding-bottom: 8px; color: var(--text); text-decoration: none; }
.person-video:hover { border-color: var(--accent); }
.person-video-link:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.person-video img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--surface-2); }
.person-video-title, .person-video .small { padding: 0 10px; }
.person-video-title { font-weight: 600; font-size: .92rem; line-height: 1.3; }

/* Names on the Families tree and (for guests) Contacts open the person page. */
a.ft-name, a.ft-kid-name, a.bday-name { color: inherit; text-decoration: none; }
a.ft-name:hover, a.ft-kid-name:hover, a.bday-name:hover { text-decoration: underline; }

/* Person page: Growing up strip and the Pick face dialog */
.growing-up { margin-bottom: 26px; }
.growing-up h2 { margin: 0 0 10px; font-size: 1.3rem; }
.gu-strip { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; }
.gu-item { flex: 0 0 auto; display: grid; justify-items: center; gap: 2px; color: var(--text); text-decoration: none; scroll-snap-align: start; }
.gu-face { width: 96px; height: 96px; border-radius: 50%; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent-soft); background: var(--surface-2); }
.gu-item:hover .gu-face { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }
.gu-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 12px; }
.gu-age { font-weight: 600; font-size: .9rem; margin-top: 4px; }
.face-pick { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s; }
.person-video:hover .face-pick, .face-pick:focus-visible, .face-pick.picked { opacity: .95; }
@media (hover: none) { .face-pick { opacity: .9; } }
.face-pick.picked { background: var(--accent-soft); color: var(--accent); }
dialog.face-dialog {
  width: min(860px, calc(100vw - 24px)); padding: 16px 18px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog.face-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.face-head { display: flex; align-items: start; gap: 10px; }
.face-head h2 { flex: 1; margin: 0; font-size: 1.1rem; }
.face-stage { position: relative; line-height: 0; }
.face-stage img { width: 100%; height: auto; border-radius: 8px; }
.face-box { position: absolute; border: 3px solid #fff; border-radius: 8px; background: transparent; cursor: pointer; box-shadow: 0 0 0 2px rgba(0,0,0,.45); }
.face-box:hover, .face-box:focus-visible { border-color: var(--star); outline: none; }
.face-box.current { border-color: var(--ok); }
.face-actions { margin-top: 10px; }

/* ---------- Home page header ---------- */
.home-hero {
  position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: 14px 24px; min-height: clamp(300px, 34vw, 440px); margin-bottom: 18px; padding: 28px 28px 24px; border-radius: var(--radius);
  background: linear-gradient(135deg, #24476f, #2c6bd1 55%, #6a9be0); color: #fff; box-shadow: var(--shadow);
}
.hero-photos, .hero-shade { position: absolute; inset: 0; }
.hero-slide { position: absolute; inset: 0; opacity: 0; transition: opacity 1.6s ease; }
.hero-slide.shown { opacity: 1; }
.hero-back { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(24px) brightness(.7) saturate(1.2); transform: scale(1.15); }
/* The whole photo, never cropped, gently drifting in. */
.hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.hero-slide.shown .hero-photo { animation: hero-drift 9s ease-out both; }
@keyframes hero-drift { from { transform: scale(1.04); } to { transform: scale(1); } }
.hero-shade { background: linear-gradient(to top, rgba(8, 14, 24, .78) 0%, rgba(8, 14, 24, .35) 45%, rgba(8, 14, 24, .05) 75%); }
.home-hero:not(.has-photo) .hero-shade { background: none; }
.hero-text, .hero-birthday { position: relative; }
.hero-greeting { margin: 0; font-size: 1.05rem; opacity: .92; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.home-hero h1 { margin: 2px 0 4px; font-size: clamp(1.8rem, 4.5vw, 2.8rem); line-height: 1.1; text-shadow: 0 2px 8px rgba(0,0,0,.45); }
.hero-stats { margin: 0; font-size: .95rem; opacity: .9; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.hero-birthday {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .35); color: #fff; text-decoration: none;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hero-birthday:hover { background: rgba(255, 255, 255, .26); }
.hero-birthday:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.hero-birthday.today { background: rgba(226, 164, 0, .35); border-color: rgba(255, 220, 120, .8); }
.hero-birthday-text { display: grid; line-height: 1.25; }
.hero-birthday-text span { font-size: .88rem; opacity: .92; }
@media (prefers-reduced-motion: reduce) {
  .hero-slide { transition: none; }
  .hero-slide.shown .hero-photo { animation: none; }
}
@media (max-width: 600px) {
  /* Phones: the photo in its own band at the top, the greeting below it
     (on the blurred fill) rather than over faces. */
  .home-hero { min-height: 0; flex-direction: column; align-items: stretch; padding: 238px 16px 16px; }
  .hero-photo { height: 222px; object-position: center; }
  .hero-shade { background: linear-gradient(to bottom, rgba(8, 14, 24, 0) 210px, rgba(8, 14, 24, .7) 250px, rgba(8, 14, 24, .8) 100%); }
  .hero-birthday { width: 100%; }
}

/* Search & filter, tucked away until opened */
.filters.collapsed { display: none; }
.filters-toggle { margin-left: auto; }
.filters-toggle.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ---- Help (user manual) ---- */
.help-page {
  max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px;
  display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px; align-items: start;
}
.help-toc { position: sticky; top: 76px; display: grid; gap: 10px; }
.help-toc input { width: 100%; }
.help-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.help-toc a { display: block; padding: 5px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .95rem; }
.help-toc a:hover { background: var(--surface-2); }
.help-body {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 28px 32px; box-shadow: var(--shadow); min-width: 0;
}
.help-body h1 { margin: 0 0 4px; }
.help-body .sub { color: var(--muted); margin: 0 0 8px; }
.help-body section { scroll-margin-top: 76px; }
.help-body h2 { font-size: 1.15rem; margin: 28px 0 8px; padding-top: 18px; border-top: 1px solid var(--border); }
.help-body li { margin: 6px 0; line-height: 1.5; }
.help-body li ul { margin-top: 4px; }
.role-tag {
  display: inline-block; vertical-align: middle; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: var(--accent-soft); color: var(--accent);
}
@media (max-width: 760px) {
  .help-page { grid-template-columns: 1fr; gap: 14px; padding: 16px 12px 48px; }
  .help-toc { position: static; }
  .help-toc ol { display: flex; flex-wrap: wrap; gap: 4px; }
  .help-toc a { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: .88rem; }
  .help-body { padding: 18px 16px 24px; }
}

/* ---- Chat ---- */
.chat-body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.chat-body .app-header { position: static; }
.chat-page {
  flex: 1; min-height: 0; width: 100%; max-width: 1280px; margin: 0 auto; padding: 16px;
  display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px;
}
.chat-list, .chat-convo {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  min-height: 0; display: flex; flex-direction: column;
}
.chat-list { padding: 14px 10px; gap: 8px; overflow-y: auto; }
.chat-list-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.chat-list-head h1 { margin: 0; font-size: 1.3rem; }
.chat-conn { font-size: .8rem; color: var(--warn); background: var(--warn-soft); padding: 2px 8px; border-radius: 999px; }
.chat-list > input { margin: 0 4px; width: auto; }
.chat-list-label { margin: 8px 8px 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.chat-rooms { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.chat-room {
  width: 100%; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; grid-template-rows: auto auto;
  column-gap: 10px; align-items: center; text-align: left; padding: 8px; border: 0; border-radius: 10px;
  background: none; cursor: pointer;
}
.chat-room:hover { background: var(--surface-2); }
.chat-room[aria-current="true"] { background: var(--accent-soft); }
.chat-room .chat-avatar { grid-row: 1 / 3; }
.chat-room-text { display: grid; min-width: 0; grid-row: 1 / 3; }
.chat-room-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room-sub { color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room-sub.typing { color: var(--accent); font-style: italic; }
.chat-room-time { grid-column: 3; grid-row: 1; font-size: .75rem; color: var(--muted); justify-self: end; }
.chat-unread {
  grid-column: 3; grid-row: 2; justify-self: end; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-size: .75rem; font-weight: 700; display: grid; place-items: center;
}
.chat-avatar {
  position: relative; width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .9rem; background: var(--muted);
}
.chat-avatar.family { background: var(--accent-soft); font-size: 1.3rem; }
.chat-avatar.small { width: 30px; height: 30px; font-size: .72rem; }
.chat-avatar-space { width: 30px; flex: none; }
.chat-dot {
  position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--border); border: 2px solid var(--surface);
}
.chat-dot.on { background: #2fb45a; }

.chat-convo { position: relative; overflow: hidden; }
.chat-convo-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-convo-title { display: grid; min-width: 0; }
.chat-convo-title h2 { margin: 0; font-size: 1.1rem; }
.chat-convo-title .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-back { display: none; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; }
.chat-more { align-self: center; margin-bottom: 8px; }
.chat-empty { margin: auto; text-align: center; }
.chat-messages { display: flex; flex-direction: column; gap: 2px; margin-top: auto; }
.chat-day, .chat-new { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; font-size: .78rem; color: var(--muted); }
.chat-day::before, .chat-day::after, .chat-new::before, .chat-new::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.chat-new { color: var(--danger); font-weight: 700; }
.chat-new::before, .chat-new::after { border-color: var(--danger); }
.chat-msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; max-width: 78%; }
.chat-msg.grouped { margin-top: 0; }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.mine .chat-avatar-space { display: none; }
.chat-msg-body { display: grid; gap: 2px; min-width: 0; }
.chat-msg-meta { display: flex; gap: 8px; align-items: baseline; font-size: .78rem; color: var(--muted); padding: 0 4px; }
.chat-msg.mine .chat-msg-meta { justify-content: flex-end; }
.chat-msg-meta strong { color: var(--text); font-size: .82rem; }
.chat-bubble-row { display: flex; align-items: center; gap: 4px; }
.chat-msg.mine .chat-bubble-row { flex-direction: row-reverse; }
.chat-bubble {
  padding: 8px 12px; border-radius: 16px; background: var(--surface-2); white-space: pre-wrap;
  overflow-wrap: anywhere; line-height: 1.4; min-width: 0;
}
.chat-msg.mine .chat-bubble { background: var(--accent); color: var(--accent-text); }
.chat-msg.mine .chat-bubble a { color: inherit; }
.chat-bubble.deleted, .chat-msg.mine .chat-bubble.deleted { background: none; border: 1px dashed var(--border); color: var(--muted); font-style: italic; }
.chat-delete {
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px;
  font-size: .8rem; opacity: 0; transition: opacity .15s;
}
.chat-msg:hover .chat-delete, .chat-delete:focus-visible { opacity: 1; }
.chat-delete:hover { color: var(--danger); background: var(--surface-2); }
@media (hover: none) { .chat-delete { opacity: .5; } }
.chat-jump { position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; box-shadow: var(--shadow); }
.chat-typing { min-height: 1.4em; margin: 0; padding: 0 18px; font-style: italic; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px 12px; }
.chat-compose textarea { flex: 1; min-height: 42px; max-height: 160px; resize: none; border-radius: 20px; padding: 9px 14px; line-height: 1.4; }
.chat-compose .btn { border-radius: 20px; min-height: 42px; }
.chat-error { margin: 0 12px 12px; background: var(--warn-soft); color: var(--warn); }

/* The menu's Chat link with unread messages, and the "new message" note on other pages */
.app-header a.has-unread { color: var(--accent); font-weight: 700; }
.chat-toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 50; max-width: min(360px, calc(100vw - 32px));
  display: grid; gap: 2px; padding: 12px 16px; border-radius: var(--radius); text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  transform: translateY(150%); opacity: 0; transition: transform .25s, opacity .25s; pointer-events: none;
}
.chat-toast.shown { transform: none; opacity: 1; pointer-events: auto; }
.chat-toast span { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .chat-page { grid-template-columns: 1fr; padding: 8px; }
  .chat-page.show-convo .chat-list { display: none; }
  .chat-page:not(.show-convo) .chat-convo { display: none; }
  .chat-back { display: inline-flex; }
  .chat-convo-head { padding: 8px 10px; gap: 8px; }
  .chat-scroll { padding: 8px 10px; }
  .chat-msg { max-width: 88%; }
  .chat-compose { padding: 6px 8px 8px; }
}
@media (prefers-reduced-motion: reduce) { .chat-toast { transition: none; } }

/* ---- Video access (administrators) ---- */
.result-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.result-row .result-line { margin-right: auto; }
.result-row .btn { margin: 0 0 14px; }
.access-tag {
  display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--warn-soft); color: var(--warn);
}
.access-box { border-top: 1px solid var(--border); padding-top: 10px; display: grid; gap: 8px; }
.access-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.access-head span { flex: 1; min-width: 200px; }
.access-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.access-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 12px;
  max-height: 260px; overflow-y: auto; padding: 8px; margin: 6px 0; border: 1px solid var(--border); border-radius: 8px;
}
.access-list label { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; }
.access-group { grid-column: 1 / -1; margin: 8px 0 0; }
dialog.access-dialog {
  width: min(640px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 18px 20px;
}
dialog.access-dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog.access-dialog p { margin: 8px 0; }
