:root {
  --bg: #f9f9f9;
  --rail: #1b1b1b;
  --rail-text: #b5b5b5;
  --header-h: 70px;
  --rail-w: 76px;
  --surface: #ffffff;
  --surface-2: #f2f2f2;
  --text: #222222;
  --heading: #7b7b7b;
  --muted: #666666;
  --subtle: #989898;
  --line: #e4e4e4;
  --accent: #920000;
  --accent-hover: #a40000;
  --accent-soft: #f7e6e6;
  --accent-text: #ffffff;
  --ok: #1f7a4d;
  --ok-soft: #e7f3ec;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warn-soft: #fff7e8;
  --warn-line: #e8c57e;
  --shadow-sm: none;
  --shadow-md: 0 8px 28px rgb(0 0 0 / .12);
  --radius: 4px;
  --radius-sm: 2px;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: light;
}
/* Titillium Web (SIL OFL), served from this server. */
@font-face { font-family: "Titillium Web"; font-weight: 300; font-display: swap; src: url("/vendor/fonts/300.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-weight: 400; font-display: swap; src: url("/vendor/fonts/400.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-weight: 600; font-display: swap; src: url("/vendor/fonts/600.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-weight: 700; font-display: swap; src: url("/vendor/fonts/700.woff2") format("woff2"); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 15px/1.5 "Titillium Web", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; letter-spacing: .02em; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.input, select.input {
  height: 40px; width: 100%; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Header and side rail (styled after the main website) ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: #fff;
  box-shadow: 0 0 4px rgb(0 0 0 / .5);
}
.appbar-inner {
  display: flex; align-items: center; gap: 16px; height: var(--header-h);
  padding: 0 var(--gutter) 0 20px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-logo { height: 46px; width: auto; display: block; flex: none; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-text); flex: none;
}
.brand-mark .icon { width: 20px; height: 20px; }
.brand-text { display: grid; line-height: 1.15; min-width: 0; padding-left: 12px; border-left: 1px solid var(--line); }
.brand-name { font-size: 20px; font-weight: 600; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: var(--subtle); font-size: 12px; font-weight: 300; letter-spacing: .04em; text-transform: uppercase; }
.utility { margin-left: auto; display: flex; align-items: center; font-size: 14.5px; font-weight: 300; }
.utility > * { all: unset; cursor: pointer; color: var(--muted); padding: 2px 10px; white-space: nowrap; }
.utility > [hidden] { display: none; }
/* A thin divider before every visible link except the first. */
.utility > :not([hidden]) ~ :not([hidden]) { border-left: 1px solid #c8c8c8; }
.utility .account-name { cursor: default; color: var(--text); font-weight: 400; }
.utility a:hover, .utility button:hover { color: var(--accent); }
.utility > :last-child { padding-right: 0; }
.utility a[aria-current="page"] { color: var(--accent); }
.utility :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rail {
  position: fixed; z-index: 25; left: 0; top: var(--header-h); bottom: 0; width: var(--rail-w);
  background: var(--rail); display: flex; flex-direction: column; padding-top: 18px; overflow-y: auto;
}
.rail-item {
  all: unset; box-sizing: border-box; display: grid; justify-items: center; gap: 4px; width: 100%;
  padding: 12px 4px; color: var(--rail-text); font-size: 12.5px; font-weight: 300; line-height: 1.2; text-align: center; cursor: pointer;
  transition: background .15s, color .15s;
}
.rail-item .icon { width: 26px; height: 26px; stroke-width: 1.4; }
.rail-item:hover { color: #fff; }
.rail-item[aria-current="page"], .rail-item[aria-selected="true"] { background: var(--accent); color: #fff; }
.rail-item:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
body:has(.rail:not([hidden])) .page, body:has(.rail:not([hidden])) .footer { padding-left: calc(var(--rail-w) + var(--gutter)); }
.page, .footer-inner { max-width: none; }

.hero { text-align: center; padding: 28px 0 32px; }
.hero-kicker { margin: 0; color: var(--heading); font-size: 20px; font-weight: 300; }
.hero-title { margin: 6px 0 22px; color: var(--accent); font-size: clamp(24px, 3.4vw, 34px); font-weight: 400; line-height: 1.2; }
.hero .search { margin: 0 auto; }

.search { position: relative; max-width: 820px; display: flex; gap: 8px; text-align: left; }
.search-field { position: relative; flex: 1; min-width: 0; }
.search-field > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; }
.search-field input {
  width: 100%; height: 44px; padding: 0 40px 0 42px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search-field input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 999px; border: 0; background: transparent; color: var(--subtle);
  display: grid; place-items: center; cursor: pointer;
}
.search-clear:hover { background: var(--line); color: var(--text); }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; max-height: min(420px, 60vh); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 12px 32px rgba(0,0,0,.14); padding: 6px;
}
.suggest-head { padding: 8px 10px 4px; font-size: 11.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--subtle); }
.suggest-item {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px;
  border-radius: 6px; cursor: pointer;
}
.suggest-item:hover, .suggest-item.active { background: var(--accent-soft); }
.suggest-item .face-avatar { width: 36px; height: 36px; flex: none; font-size: 13px; }
.suggest-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 999px; background: var(--bg, #f3f3f3); color: var(--accent); }
.suggest-text { display: grid; min-width: 0; }
.suggest-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.suggest-text small { font-size: 12px; color: var(--subtle); }
.suggest-none { padding: 12px 10px; color: var(--muted); font-size: 14px; }
.search .btn { height: 44px; border-radius: var(--radius-sm); padding: 0 18px; font-size: 14px; letter-spacing: .01em; }

/* ---------- Layout ---------- */
.page { flex: 1; width: 100%; margin: 0; padding: 24px var(--gutter) 56px; }
.footer { border-top: 1px solid var(--line); color: var(--subtle); font-size: 12.5px; }
.footer-inner { max-width: 1440px; margin: 0 auto; padding: 18px var(--gutter); display: flex; gap: 8px 24px; flex-wrap: wrap; justify-content: space-between; }

/* ---------- Banners ---------- */
.banner {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px; margin-bottom: 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm);
}
.banner .icon { margin-top: 2px; }
.banner.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.banner.info { background: var(--accent-soft); border-color: transparent; }
.banner.info .icon { color: var(--accent); }
.banner.ok { background: var(--ok-soft); border-color: transparent; }
.banner.ok .icon { color: var(--ok); }
.banner.error { background: var(--danger-soft); border-color: transparent; }
.banner.error .icon { color: var(--danger); }
.banner strong { display: block; margin-bottom: 2px; }
.banner > div { min-width: 0; overflow-wrap: anywhere; }
.banner p { margin: 0; color: var(--muted); }
.banner ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.banner li { margin: 2px 0; }
code { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }

/* ---------- Filters ---------- */
.filters { display: grid; gap: 14px; margin-bottom: 24px; }
.filter-row { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: start; }
.filter-label { color: var(--subtle); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding-top: 8px; }
/* Rows scroll sideways; the fade at the right edge shows there is more. */
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0 48px 4px 0;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.slider { display: grid; gap: 8px; min-width: 0; }
.slider-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.slider-row .chips { flex: 1; min-width: 0; }
.slide-btn { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--text); display: grid; place-items: center; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.slide-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.slide-btn:disabled { opacity: .3; cursor: default; }
.slide-btn .icon { width: 16px; height: 16px; }
.slider-bar { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: 0; border-radius: 999px; background: var(--line); cursor: pointer; }
.slider-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 44px; height: 14px; border-radius: 999px; background: var(--accent); border: none; }
.slider-bar::-moz-range-thumb { width: 44px; height: 14px; border-radius: 999px; background: var(--accent); border: none; }
.slider-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.slider.fits .slide-btn, .slider.fits .slider-bar { display: none; }
/* Phones swipe the row; the bar stays for big jumps and the arrows make room for names. */
@media (max-width: 640px) { .slide-btn { display: none; } }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 400; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip .count { color: var(--subtle); font-size: 12px; font-variant-numeric: tabular-nums; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.active .count { color: inherit; opacity: .7; }

/* ---------- Results ---------- */
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 28px; }
.summary { margin: 0; font-size: 14px; color: var(--muted); }
.summary strong { color: var(--accent); font-weight: 600; }
.results-tools { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--line); transition: background .15s; flex: none; }
.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,.25); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.best { margin-bottom: 8px; }
.best-title { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; font-size: 16px; font-weight: 600; color: var(--accent); }
.best-title .icon { width: 18px; height: 18px; fill: currentColor; }
.best .all-title { margin-top: 28px; color: var(--text); }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(45%, 220px), 1fr)); gap: 8px; }

.card { position: relative; margin: 0; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); aspect-ratio: 1; box-shadow: var(--shadow-sm); }
.card .thumb { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.card .thumb:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.card:hover img { transform: scale(1.03); }
.card .overlay {
  position: absolute; inset: auto 0 0 0; display: flex; align-items: flex-end; gap: 8px;
  padding: 28px 10px 10px 12px; color: #fff; pointer-events: none;
  background: linear-gradient(to top, rgb(0 0 0 / .72), rgb(0 0 0 / 0));
  opacity: 0; transition: opacity .2s;
}
.card:hover .overlay, .card:focus-within .overlay { opacity: 1; }
/* How many near-identical shots are folded into this one. */
.similar-note {
  position: absolute; top: 8px; right: 8px; padding: 2px 8px; border-radius: 999px;
  background: rgb(0 0 0 / .62); color: #fff; font-size: 12px; font-weight: 600; pointer-events: none;
}
.overlay .meta { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.35; }
.overlay .meta b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay .meta span { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.icon-btn {
  pointer-events: auto; flex: none; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 999px; background: rgb(255 255 255 / .92); color: #111; text-decoration: none;
  box-shadow: 0 2px 6px rgb(0 0 0 / .25); transition: transform .15s;
}
.icon-btn:hover { transform: scale(1.06); }
.icon-btn .icon { width: 16px; height: 16px; }
@media (hover: none) { .card .overlay { opacity: 1; } }
.no-thumb { display: grid; place-items: center; align-content: center; gap: 6px; height: 100%; color: var(--subtle); font-size: 12.5px; }
.no-thumb .icon { width: 28px; height: 28px; }

.skeleton { border-radius: var(--radius); aspect-ratio: 1; background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .card img { transition: none; } }

.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 72px 16px; color: var(--muted); }
.empty .empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--radius); background: var(--surface-2); color: var(--subtle); margin-bottom: 8px; }
.empty .empty-icon .icon { width: 26px; height: 26px; }
.empty h2 { margin: 0; font-size: 22px; color: var(--text); font-weight: 300; }
.empty p { margin: 0; max-width: 420px; }
.more { display: flex; margin: 32px auto 0; }

/* ---------- Viewer ---------- */
.viewer {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #0b0c0f; color: #f2f3f5;
}
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer::backdrop { background: #0b0c0f; }
.viewer-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.viewer-count { font-size: 13px; color: #a7acb6; font-variant-numeric: tabular-nums; }
.viewer-stage { position: relative; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; min-height: 0; overflow: hidden; padding: 0 64px; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border-radius: 4px; }
.viewer-missing { display: grid; justify-items: center; gap: 10px; text-align: center; color: #a7acb6; max-width: 360px; }
.viewer-missing .icon { width: 32px; height: 32px; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%); display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgb(255 255 255 / .1); color: #fff; transition: background .15s;
}
.nav:hover { background: rgb(255 255 255 / .2); }
.nav:disabled { opacity: .25; cursor: default; }
.nav.prev { left: 12px; } .nav.next { right: 12px; }
.viewer .btn.ghost { color: #c9cdd4; }
.viewer .btn.ghost:hover { background: rgb(255 255 255 / .1); color: #fff; }
.viewer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 20px 18px; border-top: 1px solid rgb(255 255 255 / .08); }
.viewer-meta { flex: 1 1 260px; min-width: 0; }
.viewer-meta .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-meta .sub { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; color: #a7acb6; font-size: 13px; }
.viewer-meta .sub span { display: inline-flex; align-items: center; gap: 6px; }
.viewer-meta .sub .icon { width: 14px; height: 14px; }
.viewer .btn.primary { background: #fff; border-color: #fff; color: #111; }
.viewer .btn.primary:hover { background: #e6e8ec; }
@media (max-width: 640px) {
  .viewer-stage { padding: 0 8px; }
  .nav { top: auto; bottom: 8px; transform: none; background: rgb(0 0 0 / .55); }
}

/* ---------- Owner interface ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button {
  height: 36px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 400; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.appbar .spacer { flex: 1; }
.panel h2 { font-size: 28px; font-weight: 400; letter-spacing: 0; margin: 0; color: var(--accent); }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; max-width: 760px; }
.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.box-head { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.box-body { padding: 16px; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 550; }
.field .help { font-weight: 400; color: var(--subtle); font-size: 12.5px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--muted); }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
fieldset.sections { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; }
fieldset.sections legend { padding: 0 4px; }
fieldset.sections[disabled] { opacity: .5; }
fieldset.sections .check span { display: inline; }
.access-list { display: flex; flex-wrap: wrap; gap: 4px; }
.error-text { color: var(--danger); font-size: 13px; margin: 0; min-height: 1.2em; }

.login-wrap { display: grid; place-items: center; padding: 8vh 0; }
.login-card { width: min(400px, 100%); }
.login-card .box-body { padding: 28px; }
.login-card h2 { margin: 12px 0 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
th { font-weight: 600; color: var(--subtle); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
td .input { height: 34px; min-width: 110px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.muted { color: var(--muted); font-size: 13px; }
td.empty-cell { text-align: center; color: var(--muted); padding: 32px 16px; }
.path { font-weight: 550; }
.path .sep { color: var(--subtle); margin: 0 4px; font-weight: 400; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.no { background: var(--danger-soft); color: var(--danger); }
.badge.plain::before { display: none; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; margin-bottom: 16px;
  position: sticky; top: calc(var(--header-h) + 4px); z-index: 10;
}
.toolbar .group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .divider { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.toolbar select.input, .toolbar .input { width: auto; min-width: 160px; }
.toolbar .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; }

.pick { cursor: pointer; aspect-ratio: auto; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); }
.pick .pick-img { position: relative; aspect-ratio: 1; background: var(--surface-2); overflow: hidden; }
.pick .tick {
  position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: var(--radius-sm);
  border: 2px solid #fff; background: rgb(0 0 0 / .25); display: grid; place-items: center; color: transparent;
}
.pick .tick .icon { width: 14px; height: 14px; stroke-width: 3; }
.pick.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pick.selected .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick .pick-body { padding: 8px 10px 10px; display: grid; gap: 6px; font-size: 12.5px; }
.pick .pick-title { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick .tags { display: flex; flex-wrap: wrap; gap: 4px; min-height: 22px; }
.pick .tags .badge.no { text-decoration: line-through; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px; }
.stat .label { color: var(--subtle); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 24px; font-weight: 300; color: var(--accent); margin-top: 4px; letter-spacing: -.01em; }
.stat .value.small { font-size: 14.5px; font-weight: 550; }

.modal { border: 0; padding: 0; border-radius: var(--radius); width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }
.modal::backdrop { background: rgb(10 12 16 / .5); }
.modal .box-body { display: grid; gap: 14px; }
.modal h3 { margin: 0; font-size: 16px; }
.modal p { margin: 0; color: var(--muted); font-size: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--text); color: var(--surface); box-shadow: var(--shadow-md); font-size: 14px; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); color: #fff; }

/* ---------- Faces ---------- */
.face-avatar {
  display: inline-block; flex: none; width: 96px; height: 96px; border-radius: 999px;
  background-color: var(--surface-2); background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .06);
}
.face-avatar.lg { width: 64px; height: 64px; }
.face-avatar.sm { width: 28px; height: 28px; }
.face-avatar.initials { display: inline-grid; place-items: center; font-weight: 650; color: var(--muted); }
.scan-box { padding: 16px; margin-bottom: 16px; display: grid; gap: 12px; }
.scan-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.scan-text { flex: 1 1 260px; min-width: 0; }
.scan-box .hint { margin: 0; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.face-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.face-card { display: grid; justify-items: center; gap: 6px; padding: 16px 10px 12px; text-align: center; }
.face-card .face-open { all: unset; cursor: pointer; border-radius: 999px; }
.face-card .face-open:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.face-card .face-open:hover .face-avatar { box-shadow: 0 0 0 3px var(--accent-soft); }
.face-name { font-weight: 600; color: var(--text); font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.face-name.unnamed { color: var(--subtle); font-weight: 500; }
.face-card .hint { margin: 0; font-size: 12.5px; }
.face-card .row-actions { justify-content: center; margin-top: 4px; }
.danger-zone { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); }
.danger-zone .hint { margin: 0; }
.modal.wide { width: min(860px, calc(100vw - 32px)); }
.name-head { display: flex; gap: 14px; align-items: center; }
.name-head > div { flex: 1; min-width: 0; }
.face-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.face-tile { position: relative; justify-self: center; }
.face-tile .face-avatar { width: 76px; height: 76px; }
.face-tile button {
  position: absolute; top: -2px; right: -2px; width: 24px; height: 24px; border-radius: 999px; border: 0;
  background: var(--danger); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-sm);
}
.face-tile button .icon { width: 14px; height: 14px; }
td .person-cell { display: flex; align-items: center; gap: 10px; }

/* Public "choose a face" row */
.face-row { display: flex; gap: 14px; overflow-x: auto; padding: 2px 48px 6px 2px; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent); }
.face-pick { all: unset; flex: none; display: grid; justify-items: center; gap: 6px; width: 84px; cursor: pointer; text-align: center; }
.face-pick .face-avatar { width: 72px; height: 72px; transition: box-shadow .15s, transform .15s; }
.face-pick:hover .face-avatar { transform: scale(1.04); }
.face-pick:focus-visible .face-avatar { outline: 3px solid var(--accent); outline-offset: 2px; }
.face-pick.active .face-avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }
.face-pick .face-label { font-size: 13px; font-weight: 400; line-height: 1.25; max-width: 84px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.face-pick .face-count { font-size: 11.5px; color: var(--subtle); }
.face-pick.active .face-label { color: var(--accent); }

/* Reference-photo search */
.banner .ref-crop { width: 48px; height: 48px; flex: none; margin: 0; }
#face-find-note .banner { margin: 0 0 16px; }
.search .btn .label { white-space: nowrap; }
@media (max-width: 640px) {
  .search { flex-wrap: wrap; }
  .search-field { flex-basis: 100%; }
  .search .btn { flex: 1; }
}

/* Sync schedule and backup */
.sched-box { margin-bottom: 20px; }
.sched-box .box-head .hint { margin: 0; font-weight: 400; }
.sched-box .form { max-width: 520px; }
.input.inline { display: inline-block; width: 84px; height: 32px; margin: 0 6px; }
.check span { display: inline-flex; align-items: center; flex-wrap: wrap; }
.danger-zone .spacer { flex: 1; }
.scan-box .check { margin: 0; }
.regroup { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.regroup label { font-weight: 600; }
.regroup .input { width: auto; max-width: 100%; }
.regroup .hint { margin: 0; flex-basis: 100%; }
.modal.wide .face-strip { max-height: 40vh; }
.similar { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.similar h4 { margin: 0 0 4px; font-size: 15px; }
.similar .hint { margin: 0 0 10px; }
.similar-list { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 6px; }
.similar-card { flex: 0 0 104px; display: grid; justify-items: center; gap: 4px; text-align: center; }
.similar-card .face-open { all: unset; cursor: pointer; border-radius: 999px; }
.similar-card .face-open:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.similar-card .face-avatar { width: 64px; height: 64px; }
.similar-card .hint { margin: 0; font-size: 12px; }
.similar-name { font-size: 13px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal.wide { max-height: calc(100dvh - 32px); overflow-y: auto; }
.dupes-note { margin: 0 0 12px; align-items: center; }
.dupes-note > div { flex: 1; min-width: 0; }
.dupes-note p { margin: 2px 0 0; }
.dupes .hint { margin: 0 0 10px; }
.dupes-list { display: grid; gap: 8px; }
.dupes-list .count { margin: 0; }
.dupes-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.dupes-thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 2px; background: var(--line); }
.dupes-face { all: unset; position: relative; cursor: pointer; border-radius: 999px; }
.dupes-face:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.dupes-face .face-avatar { width: 68px; height: 68px; transition: opacity .15s, box-shadow .15s; }
.dupes-face.marked .face-avatar { opacity: .45; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--danger, #c0392b); }
.dupes-flag { display: none; position: absolute; top: -4px; right: -4px; width: 22px; height: 22px; border-radius: 999px; background: var(--danger, #c0392b); color: #fff; place-items: center; }
.dupes-flag .icon { width: 12px; height: 12px; }
.dupes-face.marked .dupes-flag { display: grid; }
.dupes-actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; position: sticky; bottom: -1px; background: var(--surface); padding: 10px 0 2px; }
.dupes-actions .spacer { flex: 1; }

/* Phones: the rail becomes a bar along the bottom. */
@media (max-width: 760px) {
  :root { --header-h: 60px; }
  .rail { top: auto; left: 0; right: 0; width: auto; height: 62px; flex-direction: row; padding: 0; overflow-x: auto; }
  .rail-item { flex: 1 0 64px; padding: 8px 2px; font-size: 11px; }
  .rail-item .icon { width: 22px; height: 22px; }
  body:has(.rail:not([hidden])) .page, body:has(.rail:not([hidden])) .footer { padding-left: var(--gutter); }
  body:has(.rail:not([hidden])) { padding-bottom: 62px; }
  .brand small, .brand-text { border: 0; padding-left: 0; }
  .brand small { display: none; }
  .brand-logo { height: 34px; }
  .utility { flex: none; }
  body:has(#logout:not([hidden])) #main-site { display: none; }
  body:has(#logout:not([hidden])) #main-site + * { border-left: 0; }
  .utility { font-size: 13.5px; }
  .utility a[aria-current="page"] { display: none; }
  .brand:has(.brand-logo:not([hidden])) .brand-text { display: none; }
  .utility a, .utility button { padding: 2px 7px; }
  .hero { padding: 12px 0 20px; }
  .hero-kicker { font-size: 16px; }
}
.login-page .login-card { margin: 0 auto; }
.login-page .hero { padding-bottom: 20px; }
.form-error { margin: 0; color: var(--danger); font-size: 13.5px; min-height: 0; }
.form-error:empty { display: none; }
.sources-box { margin-bottom: 20px; }
.sources-box .box-body .hint { margin: 0 0 12px; }
.source-form { display: flex; gap: 8px; flex-wrap: wrap; }
.source-form .input { flex: 1 1 320px; min-width: 0; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }

/* Faces first: people are the main way into the gallery. */
.filters #people-row .face-pick { width: 104px; }
.filters #people-row .face-pick .face-avatar { width: 92px; height: 92px; }
.filters #people-row .face-pick .face-label { max-width: 104px; font-size: 14px; }
@media (max-width: 760px) {
  .utility .account-name, .utility #password-link { display: none; }
  .filters #people-row .face-pick { width: 84px; }
  .filters #people-row .face-pick .face-avatar { width: 72px; height: 72px; }
}

/* People order, visibility and face picture */
.box-hint { margin: 0; padding: 12px 16px 0; }
.people-table .order-col { width: 1%; padding-right: 0; }
.order-tools { display: flex; align-items: center; gap: 2px; }
.drag-handle { display: grid; place-items: center; width: 24px; height: 30px; color: var(--subtle); cursor: grab; border-radius: 4px; }
.drag-handle:hover { color: var(--text); background: var(--surface-2); }
.drag-handle:active { cursor: grabbing; }
.btn.xs { width: 26px; height: 26px; padding: 0; justify-content: center; }
.btn.xs .icon { width: 16px; height: 16px; }
.people-table tr.dragging { opacity: .45; }
.people-table tr.is-hidden .person-cell { opacity: .5; }
.cover-pick { all: unset; cursor: pointer; border-radius: 50%; display: inline-flex; }
.cover-pick .face-avatar { width: 40px; height: 40px; transition: box-shadow .15s; }
.cover-pick:hover .face-avatar, .cover-pick:focus-visible .face-avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.cover-option { all: unset; cursor: pointer; display: grid; place-items: center; border-radius: 50%; }
.cover-option .face-avatar { width: 80px; height: 80px; transition: box-shadow .15s, transform .15s; }
.cover-option:hover .face-avatar, .cover-option:focus-visible .face-avatar { transform: scale(1.04); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }

/* Deep scan switch in the Faces tab */
.deep-row { display: grid; gap: 4px; margin: 10px 0 4px; }
.deep-row .switch { color: var(--text); }

/* Name suggestions in the Faces tab */
.suggest-pair { display: flex; align-items: center; justify-content: center; gap: 8px; }
.suggest-pair .face-avatar { width: 64px; height: 64px; }
.suggest-arrow { color: var(--subtle); font-size: 18px; }
