:root {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #f4ede3;
    background: #111412;
    color-scheme: dark;
    --ink: #f4ede3;
    --muted: #b7b2a7;
    --paper: #191d19;
    --surface: #222822;
    --line: #41453b;
    --accent: #d7ad75;
    --accent-bright: #f2c995;
    --dark: #171913;
    --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
    --round: .2rem;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
img { display: block; max-width: 100%; }
a { color: var(--accent-bright); text-underline-offset: .21em; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 4px; }
h1:focus, main:focus, #gallery-title:focus { outline: none; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.1; }
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -.035em; }
h1 { font-size: clamp(2.4rem, 5vw, 4.65rem); }
h2 { font-size: clamp(1.7rem, 4vw, 2.8rem); }
p { line-height: 1.6; }
.shell { max-width: 92rem; margin-inline: auto; padding-inline: clamp(1rem, 4vw, 4rem); }
main { min-height: 70vh; scroll-margin-top: 4.5rem; }
.muted, .fine-print { color: var(--muted); }
.fine-print { font-size: .82rem; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: .5rem; left: 1rem; z-index: 20; transform: translateY(-160%); padding: .8rem 1rem; color: var(--dark); background: var(--accent-bright); }
.skip-link:focus { transform: none; }

.masthead { position: sticky; z-index: 5; top: 0; background: rgb(17 20 18 / .94); backdrop-filter: blur(1rem); border-bottom: 1px solid var(--line); }
.masthead-inner { min-height: 3.9rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.brand { display: inline-flex; align-items: center; min-height: 2.5rem; text-decoration: none; color: var(--ink); font: 1.65rem/.95 var(--serif); letter-spacing: -.08em; }
.brand-amp { color: var(--accent); margin-inline: .16em; font-size: .77em; font-style: italic; }
.masthead-actions { display: flex; align-items: center; gap: clamp(.2rem, 3vw, 1.2rem); }
.nav-link, .private-label { padding: .55rem .35rem; font-size: .85rem; white-space: nowrap; }
.nav-link { color: var(--muted); background: transparent; border: 0; text-decoration: none; font-weight: 650; }
.nav-link:hover { color: var(--accent-bright); text-decoration: underline; }
.private-label { color: var(--muted); }
.footer { border-top: 1px solid var(--line); margin-top: clamp(2rem, 8vw, 6rem); min-height: 4.5rem; display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; color: var(--muted); font-size: .8rem; }

.eyebrow { color: var(--accent); display: flex; align-items: center; gap: .52rem; flex-wrap: wrap; font-size: .73rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow-line { display: inline-block; flex: 0 0 1.8rem; height: 1px; background: var(--accent); }
.album-intro, .entry-grid { display: grid; align-items: center; gap: clamp(1.75rem, 5.5vw, 6rem); }
.album-intro { margin-block: clamp(2.1rem, 5vw, 4.6rem) clamp(2.1rem, 6vw, 5.4rem); }
.intro-title { min-width: 0; }
.intro-title h1, .entry-title h1 { font-size: clamp(3.2rem, 8.5vw, 8.7rem); margin-block: .58rem 1.45rem; line-height: .88; letter-spacing: -.08em; }
.intro-title em, .entry-title em { color: var(--accent); font-size: .74em; font-weight: 400; }
.welcome-note { max-width: 38ch; padding-top: 1.15rem; border-top: 1px solid var(--line); color: var(--muted); }
.greeting { margin-bottom: .4rem; font-weight: 650; color: var(--ink); }
.personal-link { margin-top: 1.2rem; }
.album-cover { min-width: 0; margin: 0; padding: .6rem; border: 1px solid #766449; }
.cover-stage { position: relative; isolation: isolate; overflow: hidden; aspect-ratio: 4 / 3; background: #0a0c0b; }
.cover-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .65s ease; }
.cover-stage img.cover-visible { opacity: 1; z-index: 1; }
.markdown { line-height: 1.65; overflow-wrap: anywhere; }
.markdown > * + * { margin-top: .55rem; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { font-family: var(--serif); font-weight: 400; font-size: 1.3rem; margin-bottom: .3rem; }
.markdown pre { max-width: 100%; overflow: auto; padding: .65rem; background: var(--surface); }
.markdown blockquote { border-inline-start: 2px solid var(--accent); margin-inline: 0; padding-inline-start: 1rem; }

.gallery-toolbar, .viewer-top, .viewer-info, .section-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; }
.gallery-toolbar { align-items: center; padding-block: 1rem; border-block: 1px solid var(--line); }
.gallery-toolbar h2, .admin-heading h1 { margin-top: .24rem; }
#gallery-title { scroll-margin-top: 5rem; }
.gallery-controls, .viewer-actions, .viewer-neighbors, .row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.search { display: flex; gap: .45rem; min-width: 0; }
.search select { width: clamp(10rem, 21vw, 18rem); }
.gallery-meta { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; padding-block: .75rem; gap: .3rem 1rem; color: var(--muted); font-size: .87rem; }
.gallery-meta:not(:has(p:not(.gallery-loading))) { padding-block: .4rem; }
.gallery-loading { visibility: hidden; }
.gallery[aria-busy="true"] .gallery-loading { visibility: visible; }
.subtle-link { color: var(--accent-bright); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: .18em; }
.gallery-selection, .person-links { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.gallery-selection { margin-top: .8rem; color: var(--muted); font-size: .85rem; }
.person-links { list-style: none; margin: 0; padding: 0; }
.person-links a { display: inline-flex; gap: .6rem; align-items: center; border: 1px solid var(--line); padding: .32rem .62rem; color: var(--ink); font-size: .85rem; text-decoration: none; overflow-wrap: anywhere; }
.person-links a:hover { border-color: var(--accent); color: var(--accent-bright); }

input:not([type="checkbox"]):not([type="hidden"]), select, textarea {
    display: block; min-width: 0; max-width: 100%; min-height: 2.7rem; border: 1px solid var(--line); border-radius: var(--round);
    background: var(--paper); color: var(--ink); padding: .52rem .7rem;
}
textarea { width: 100%; resize: vertical; }
.button, .segmented a, .segmented button, .page-number {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.7rem; padding: .48rem .8rem;
    border: 1px solid var(--line); border-radius: var(--round); background: transparent; color: var(--ink);
    text-decoration: none; font-weight: 620; font-size: .88rem; line-height: 1.3;
}
.button:not(:disabled):hover, .page-number:hover { border-color: var(--accent); background: var(--surface); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--dark); }
.button.primary:not(:disabled):hover { background: var(--accent-bright); border-color: var(--accent-bright); }
.button.danger { color: #ffc0ad; border-color: #915e51; }
.account-removal { border-top: 1px solid var(--line); padding-top: .8rem; }
.account-removal .row-actions { margin-top: .6rem; }
.segmented { display: inline-flex; align-items: center; gap: .12rem; padding: .14rem; border: 1px solid var(--line); border-radius: var(--round); background: var(--paper); }
.segmented a, .segmented button { border-color: transparent; background: transparent; min-height: 2.3rem; white-space: nowrap; }
.segmented a:hover, .segmented button:hover { color: var(--accent-bright); }
.segmented [aria-pressed="true"], .segmented [aria-current="true"] { border-color: #736248; background: #30291f; color: var(--accent-bright); }

.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(.35rem, 1.05vw, .95rem); }
.photo-tile { min-width: 0; aspect-ratio: 4 / 3; display: block; overflow: hidden; background: var(--paper); text-decoration: none; color: var(--ink); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .24s ease; }
.photo-tile:hover img { transform: scale(1.035); }
.photo-unavailable { height: 100%; display: grid; place-items: center; text-align: center; padding: .5rem; font-size: .8rem; color: var(--muted); }
.pager, .admin-pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .5rem; margin-top: clamp(1.4rem, 4vw, 2.8rem); }
.page-numbers { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: .22rem; }
.page-number { min-width: 2.65rem; padding-inline: .5rem; }
.page-number.selected { color: var(--dark); background: var(--accent); border-color: var(--accent); }
.ellipsis, .pager-disabled { color: var(--muted); font-size: .85rem; padding: .4rem; }
.pager-disabled { opacity: .66; }

.viewer { padding-top: clamp(1.1rem, 3vw, 2.45rem); }
.viewer-stage { margin-block: .85rem 1.3rem; background: #080a09; min-height: 8rem; display: grid; place-items: center; overflow: hidden; }
.viewer-stage img { width: 100%; height: auto; max-height: 70svh; object-fit: contain; }
.viewer-info { padding-block: 1rem; border-top: 1px solid var(--line); }
.viewer-info h1 { font-size: clamp(1.85rem, 4vw, 3.15rem); margin-block: .24rem; }
.viewer-info .person-links { margin-block: .65rem; }
.viewer-actions { justify-content: flex-start; }
.photo-analysis { margin-top: 1rem; }
.photo-analysis h2 { font-size: 1.5rem; }
.photo-analysis > p, .photo-analysis-confirm { margin-top: .75rem; }
.photo-analysis-confirm .row-actions { margin-top: .5rem; }
.photo-face-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: .45rem; }
.photo-face-list li + li { margin-top: 0; }

.entry-grid { padding-block: clamp(1.7rem, 7vw, 6rem); }
.entry-title { align-self: stretch; display: grid; align-content: center; border-block: 1px solid var(--line); padding-block: clamp(1.4rem, 4vw, 3.25rem); }
.entry-title h1 { font-size: clamp(2.9rem, 6.3vw, 6.9rem); }
.panel, .empty { min-width: 0; border: 1px solid var(--line); border-radius: var(--round); background: var(--paper); padding: clamp(1rem, 3vw, 2rem); }
.empty { text-align: center; padding-block: clamp(1.5rem, 8vw, 4rem); }
.empty.small { margin-top: 1rem; padding: 1rem; background: var(--surface); }
.empty p { margin-block: .4rem .8rem; }
.entry-panel { display: grid; gap: .95rem; }
.entry-panel h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
.confirmation { width: min(100%, 37rem); margin: clamp(1.7rem, 8vw, 6rem) auto; }
.form-stack { display: grid; gap: .48rem; }
.form-stack label, .name-editor label, .move-form label { font-size: .87rem; font-weight: 660; }
.form-stack .button { margin-top: .3rem; }
.notice { padding: .65rem .8rem; border-radius: var(--round); color: #dce8ca; border: 1px solid #55664b; background: #283426; font-size: .88rem; }
.notice.problem { color: #ffe0d2; border-color: #915e51; background: #38241f; }

.admin-heading { padding-block: clamp(1.3rem, 4vw, 2.7rem) 1.2rem; }
.admin-nav { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.admin-nav a { padding: .58rem .8rem; font-weight: 630; border: 1px solid var(--line); background: var(--paper); border-radius: var(--round); text-decoration: none; }
.admin-nav a:hover, .admin-nav a.active { color: var(--dark); background: var(--accent); border-color: var(--accent); }
.admin-heading + .notice { margin-bottom: 1rem; }
.admin-split, .welcome-editor { display: grid; align-items: start; gap: .9rem; }
.panel > .muted, .panel > .fine-print { margin-block: .55rem 1rem; }
.checkbox { display: flex; align-items: center; gap: .42rem; margin-block: .35rem; font-size: .9rem; }
.checkbox input { width: 1.12rem; height: 1.12rem; accent-color: var(--accent); }
.clean-list { list-style: none; margin: .85rem 0 0; padding: 0; }
.clean-list li + li { margin-top: .42rem; }
.list-item { display: grid; gap: .25rem; width: 100%; text-align: left; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: var(--round); background: var(--paper); color: var(--ink); overflow-wrap: anywhere; }
button.list-item:hover, a.list-item:hover, .list-item[aria-current="true"] { border-color: var(--accent); background: var(--surface); }
.list-item span { font-size: .81rem; color: var(--muted); }
.group-list .section-top, .merged-link { margin-bottom: .8rem; }
.group-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; margin-bottom: .55rem; }
.group-filter { margin-bottom: .65rem; }
.group-filter select { width: 100%; }
.group-selection { justify-content: space-between; margin-block: .7rem; }
.group-row-link { grid-template-columns: 2.8rem minmax(0, 1fr); align-items: center; gap: .65rem; text-decoration: none; }
button.group-row-link { grid-template-columns: 2.8rem minmax(0, 1fr) auto; }
.group-row-link[aria-pressed="true"] { border-color: var(--accent); background: var(--surface); }
.group-row-link[aria-pressed="true"]::after { content: "\2713"; color: var(--accent-bright); }
.group-row-label { display: grid; gap: .18rem; }
.group-row-label strong { color: var(--ink); }
.group-avatar { display: block; width: 100%; aspect-ratio: 1; background: var(--surface); overflow: hidden; }
.group-detail > .subtle-link { display: inline-block; margin-bottom: .75rem; }
.merge-dialog { position: fixed; inset: 0; width: min(39rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); margin: auto; overflow: auto; color: var(--ink); }
.merge-dialog[open] { display: grid; gap: 1rem; }
.merge-dialog::backdrop { background: rgb(8 10 9 / .8); }
.merge-direction { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.3fr); align-items: start; gap: .65rem; }
.merge-source, .merge-destination { min-width: 0; padding: .8rem; border: 1px solid var(--line); background: var(--surface); }
.merge-direction h3, .merge-direction label { display: block; font-size: .9rem; font-weight: 650; }
.merge-direction h3 span, .merge-direction label span { color: var(--muted); font-weight: 400; }
.merge-source ul { max-height: 8rem; overflow: auto; margin: .5rem 0 0; padding-left: 1.1rem; overflow-wrap: anywhere; }
.merge-destination select, .people-merge .merge-source select { width: 100%; margin-top: .5rem; }
.merge-arrow { margin-top: 1.1rem; color: var(--accent); }
.merge-dialog > p { overflow-wrap: anywhere; }
.people-merge { display: grid; gap: .85rem; max-width: 62rem; }
.people-merge > .button { justify-self: start; }
.people-merge-preview { display: flex; align-items: center; gap: .6rem; margin-top: .65rem; text-decoration: none; }
.people-merge-preview .group-avatar { width: 3.2rem; flex: 0 0 3.2rem; }
.people-merge-preview span { display: grid; gap: .2rem; overflow-wrap: anywhere; }
.people-merge-preview small { color: var(--muted); }
.people-merge-preview:hover strong { text-decoration: underline; }
.rematch-intro, .rematch-results { display: grid; gap: .75rem; }
.rematch-intro { justify-items: start; }
.rematch-intro p { max-width: 70ch; }
.rematch-intro > .muted { margin: 0; }
.rematch-results { margin-top: 1.5rem; }
.rematch-results > .segmented { justify-self: start; flex-wrap: wrap; }
.rematch-list { margin-top: 0; }
.rematch-card, .rematch-comparison { display: flex; flex-wrap: wrap; align-items: center; gap: .85rem; }
.rematch-card { justify-content: space-between; }
.rematch-person { min-width: 0; display: flex; align-items: center; gap: .65rem; text-decoration: none; }
.rematch-person .group-avatar { width: 3.6rem; flex: 0 0 3.6rem; }
.rematch-person span { display: grid; gap: .15rem; overflow-wrap: anywhere; }
.rematch-person:hover strong { text-decoration: underline; }
.rematch-person small { color: var(--muted); }
.rematch-card .merge-arrow { margin: 0; }
.rematch-reopen { flex: 1 0 100%; }
.rematch-reopen .row-actions { margin-top: .55rem; }
.admin-pager { margin-top: .85rem; font-size: .84rem; }
.name-editor { margin-block: .85rem 1.1rem; }
.name-editor .button { justify-self: start; }
.face-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: .65rem; }
.face-card { align-self: start; overflow: hidden; border: 1px solid var(--line); border-radius: var(--round); background: var(--surface); }
.face-image { display: block; position: relative; }
.face-image img { width: 100%; }
.face-image svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.face-content { padding: .68rem; }
.face-review-actions, .move-form { margin-top: .5rem; }
.face-review-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; justify-items: start; }
.face-reject { grid-column: 2; justify-self: end; }
.move-form .button, .move-form .subtle-link { justify-self: start; }
.move-form .subtle-link { font-size: .84rem; }
.preview { margin-top: 1rem; }
.journal li { padding: .75rem; background: var(--surface); border-radius: var(--round); overflow-wrap: anywhere; }

@media (min-width: 45rem) {
    .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .entry-grid, .welcome-editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .album-intro { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
    .cover-stage { aspect-ratio: 3 / 2; }
    .admin-split { grid-template-columns: minmax(15rem, 1fr) minmax(0, 2fr); }
}

@media (min-width: 72rem) {
    .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 33rem) {
    .gallery-controls, .search { width: 100%; }
    .search select { flex: 1; width: auto; }
    .page-numbers { order: -1; width: 100%; }
    .viewer-top, .viewer-actions { gap: .4rem; }
    .merge-direction { grid-template-columns: minmax(0, 1fr); }
    .merge-arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .photo-tile img, .cover-stage img { transition: none; }
    .photo-tile:hover img { transform: none; }
}
