/* Family archive — styled to match the Media Archive Manager desktop app: Segoe UI, flat panels,
   blue selection, and the same Light / Gray / Dark themes (colours copied from ThemeManager.cs). */

:root, :root[data-theme=light] {
    --window: #f4f2ed;      /* WindowBrush: page background */
    --surface: #ffffff;     /* SurfaceBrush: panels, inputs, menu */
    --preview: #e4e0d7;     /* PreviewBrush: behind images, hover, selected tab */
    --text: #000000;        /* TextBrush */
    --muted: #555555;       /* MutedBrush */
    --border: #c9c3b7;      /* BorderBrush: hairlines, splitters */
    --error: #9a3b24;       /* ErrorBrush */
    --link: #1764a0;
    color-scheme: light;
}
:root[data-theme=gray] {
    --window: #69696a; --surface: #717172; --preview: #626364;
    --text: #ffffff; --muted: #e0e0e0; --border: #a0a0a0; --error: #ffd0c4;
    --link: #cfe3ff;
    color-scheme: dark;
}
:root[data-theme=dark] {
    --window: #202124; --surface: #2b2d31; --preview: #35383e;
    --text: #f1f1f1; --muted: #c4c7cc; --border: #656970; --error: #ffb49f;
    --link: #8cc4f0;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root[data-theme=system] {
        --window: #202124; --surface: #2b2d31; --preview: #35383e;
        --text: #f1f1f1; --muted: #c4c7cc; --border: #656970; --error: #ffb49f;
        --link: #8cc4f0;
        color-scheme: dark;
    }
}
:root {
    --select: #1764a0;      /* selected rows, tree items and tiles (white text) */
    --focus: #398ac8;       /* hover and keyboard-focus borders */
    --stage: #101319;       /* behind a photo in the full view */
    --ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --nav-width: 236px;
    --shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
:root[data-nav=collapsed] { --nav-width: 52px; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--window);
    color: var(--text);
    font: 400 14px/1.45 var(--ui);
}
a { color: var(--link); text-underline-offset: .15em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

h1, h2 { font-weight: 600; line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .75em; max-width: 80ch; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.hint, .lede { color: var(--muted); }
.hint { font-size: .92em; }
.empty { color: var(--muted); padding: 1rem 0; }

/* ---------- controls (the desktop's square-ish buttons with a blue hover border) ---------- */

button, .button {
    font: 400 14px/1.2 var(--ui);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 5px 12px;
    min-height: 30px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex; align-items: center; gap: .4em;
}
button:hover:not(:disabled), .button:hover, button:focus-visible { border-color: var(--focus); }
button:active:not(:disabled) { opacity: .7; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--select); border-color: var(--select); color: #fff; }
.secondary, .quiet { background: var(--surface); color: var(--text); }
.danger { background: var(--error); border-color: var(--error); color: var(--surface); }
.linklike { background: none; border: 0; padding: 0; min-height: 0; color: var(--link); text-decoration: underline; text-underline-offset: .15em; }

input[type=text], input[type=search], input[type=password], textarea, select {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 5px 7px;
    min-height: 30px;
    width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--focus); outline: none; }
textarea { resize: vertical; min-height: 0; }
label { display: grid; gap: .25em; }
label.check { display: flex; align-items: center; gap: .5em; }
label.check input, input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--select); }

/* ---------- shell: the menu down the left edge, the heading and search, the content ---------- */

.shell { display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); height: 100vh; height: 100dvh; }

.sidenav {
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.sidenav-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }
.nav-item {
    display: flex; align-items: center; gap: 14px;
    margin: 1px 6px; padding: 8px 12px; border-radius: 4px; border: 0;
    background: transparent; color: var(--text); text-decoration: none;
    width: calc(100% - 12px); min-height: 0; font: inherit; text-align: left; white-space: nowrap;
}
.nav-item:hover, .nav-item:focus-visible { background: var(--preview); outline: none; }
.nav-item.current { background: var(--preview); font-weight: 600; }
.nav-item.current .nav-icon { color: var(--select); }
:root:not([data-theme=light]) .nav-item.current .nav-icon { color: var(--link); }
.nav-toggle { margin-top: 10px; margin-bottom: 6px; font-weight: 600; }
.nav-icon { flex: none; width: 20px; height: 20px; }
.nav-heading { color: var(--muted); font-size: 11px; font-weight: 600; margin: 14px 0 4px 20px; letter-spacing: .02em; }
.nav-bottom { border-top: 1px solid var(--border); padding: 6px 0 12px; }
.nav-bottom form { margin: 0; }
.nav-user { color: var(--muted); margin: 6px 0 2px 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-theme { display: flex; align-items: center; gap: 14px; margin: 1px 6px; padding: 4px 12px; }
.nav-theme select { width: auto; flex: 1; min-height: 28px; padding: 2px 4px; }
:root[data-nav=collapsed] .nav-label,
:root[data-nav=collapsed] .nav-heading,
:root[data-nav=collapsed] .nav-user,
:root[data-nav=collapsed] .nav-theme select { display: none; }
:root[data-nav=collapsed] .nav-heading + .nav-item { margin-top: 14px; }

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 20px; }
.apphead { display: flex; align-items: center; gap: 24px; margin-bottom: 14px; }
.appname { font-size: 28px; font-weight: 600; margin: 0; white-space: nowrap; color: var(--text); text-decoration: none; }
.appsearch { flex: 1; min-width: 0; }
.nav-open { display: none; }
.content { flex: 1; min-height: 0; overflow: auto; }
.content.fill { overflow: hidden; }

/* ---------- ordinary pages inside the content area ---------- */

.page { padding: 0 2px 2rem; max-width: 1400px; }
.crumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; color: var(--muted); }
.section-heading { margin: 1.5rem 0 .6rem; font-size: 1rem; }
.notice { background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: .7rem 1rem; margin: 0 0 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.notice .password { font: 600 1.05rem/1 ui-monospace, Consolas, monospace; background: var(--preview); padding: .35em .6em; border-radius: 2px; user-select: all; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: 12px 14px; }

/* ---------- panes and splitters (like the desktop's GridSplitters) ---------- */

.panes {
    display: grid; height: 100%; min-height: 0;
    grid-template-columns: minmax(160px, 1fr) 8px minmax(240px, var(--preview-width, 42%));
}
.panes.with-side { grid-template-columns: minmax(0, var(--tree-width, 230px)) 6px minmax(160px, 1fr) 8px minmax(240px, var(--preview-width, 38%)); }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pane-title { font-weight: 600; margin: 0 0 6px; font-size: 14px; display: flex; align-items: center; gap: 8px; min-height: 30px; }
.pane-title .grow { flex: 1; }
.splitter { background: var(--border); touch-action: none; }
.splitter.v { cursor: ew-resize; }
.splitter.h { cursor: ns-resize; }
.splitter:hover, .splitter.dragging { background: var(--focus); }
.pane-heading { display: flex; align-items: center; min-height: 30px; margin-bottom: 8px; }
.pane-heading h1 { font-size: 14px; margin: 0; }

/* ---------- folder tree ---------- */

.tree-scroll { flex: 1; overflow: auto; background: var(--surface); border: 1px solid var(--border); padding: 2px 0; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 18px; }
.tree-row { display: flex; align-items: center; min-height: 26px; white-space: nowrap; }
.tree-toggle {
    flex: none; width: 18px; height: 22px; min-height: 0; padding: 0; border: 0; background: transparent; color: var(--text);
    display: grid; place-items: center;
}
.tree-toggle svg { width: 12px; height: 12px; }
.tree-toggle.leaf { visibility: hidden; }
.tree-link {
    display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 2px; flex: 1;
    color: var(--text); text-decoration: none; min-width: 0;
}
.tree-link:hover { background: var(--preview); }
.tree-link.selected { background: var(--select); color: #fff; }
.tree-link.selected .tree-name { font-weight: 600; }
.tree-link.selected .tree-count { color: #dbe8f5; }
.tree-folder { flex: none; width: 20px; height: 20px; }
.tree-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.tree-count { color: var(--muted); font-size: 12px; }

/* ---------- file list: toolbar, the seven views, people filter ---------- */

.listbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; }
.listbar > * { margin-bottom: 6px; }
.location { color: var(--muted); margin: 0 0 6px; overflow-wrap: anywhere; }
.dropdown { position: relative; }
.dropdown > button .caret { font-size: 10px; margin-left: 4px; }
.dropdown-panel {
    position: absolute; z-index: 40; top: calc(100% + 2px); left: 0; min-width: 220px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 3px; box-shadow: var(--shadow); padding: 4px;
}
.menu-option {
    display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-radius: 2px; background: transparent;
    padding: 6px 10px; min-height: 0; text-align: left;
}
.menu-option:hover { background: var(--preview); }
.menu-option .tick { width: 14px; text-align: center; }
.view-icon { width: 20px; height: 20px; flex: none; }
.pfilter-panel { padding: 10px; min-width: 260px; }
.pfilter-modes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 8px; }
.pfilter-modes label { display: flex; align-items: center; gap: 5px; }
.pfilter-list { max-height: 340px; overflow: auto; display: grid; gap: 4px; margin-bottom: 8px; }
.pfilter-list label { display: flex; align-items: center; gap: 8px; }
.pfilter-list .hint { margin-left: auto; padding-left: 10px; }

.files-scroll { flex: 1; min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--border); outline: none; }
.files-scroll:focus-visible { border-color: var(--focus); }
.files { list-style: none; margin: 0; padding: 2px; display: grid; align-content: start; }
.file {
    display: grid; gap: 4px; padding: 4px; margin: 1px; border-radius: 3px; cursor: default;
    user-select: none; -webkit-user-select: none; min-width: 0; color: var(--text);
}
.file:hover { background: var(--preview); }
.file.selected { background: var(--select); color: #fff; }
.file.selected .file-kind { color: #dbe8f5; }
.file-thumb { position: relative; display: grid; place-items: center; background: var(--preview); overflow: hidden; }
.file-thumb img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.file-thumb img.broken { visibility: hidden; }
.file-text { min-width: 0; align-self: center; }
.file-name { overflow-wrap: anywhere; }
.file-kind { color: var(--muted); font-size: 12px; }
.file-group { grid-column: 1 / -1; font-weight: 600; padding: 10px 6px 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.file .video-mark { position: absolute; left: 4px; bottom: 4px; }

/* Thumbnail sizes match MainWindow.FileBrowser.cs: list 24, tiles 64, small 32, medium 80, large 140, extra-large 220. */
.files.view-1 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.files.view-1 .file, .files.view-2 .file { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; }
.files.view-1 .file-thumb { width: 24px; height: 24px; }
.files.view-1 .file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.files.view-2 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.files.view-2 .file-thumb { width: 64px; height: 64px; }
.files.view-3 { grid-template-columns: repeat(auto-fill, 70px); }
.files.view-3 .file-thumb { width: 32px; height: 24px; justify-self: center; }
.files.view-4 { grid-template-columns: repeat(auto-fill, 118px); }
.files.view-4 .file-thumb { width: 80px; height: 60px; justify-self: center; }
.files.view-5 { grid-template-columns: repeat(auto-fill, 178px); }
.files.view-5 .file-thumb { width: 140px; height: 105px; justify-self: center; }
.files.view-6 { grid-template-columns: repeat(auto-fill, 258px); }
.files.view-6 .file-thumb { width: 220px; height: 165px; justify-self: center; }
.files.view-3 .file-text, .files.view-4 .file-text, .files.view-5 .file-text, .files.view-6 .file-text { text-align: center; font-size: 12.5px; }
.files.view-3 .file-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.files.view-4 .file-name, .files.view-5 .file-name, .files.view-6 .file-name { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.files.view-1 .video-mark, .files.view-3 .video-mark { display: none; }

.details-table { width: 100%; min-width: 640px; border-collapse: collapse; table-layout: fixed; } /* scrolls sideways when narrow, like the desktop */
.details-table th {
    position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 400;
    padding: 6px 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.details-table td { padding: 4px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.details-table tr.file { display: table-row; }
.details-table tr.file td:first-child { border-radius: 3px 0 0 3px; }
.details-table tr.file td:last-child { border-radius: 0 3px 3px 0; }
.details-table .group-row th { position: static; font-weight: 600; border-right: 0; padding-top: 10px; }
.details-table .file-icon { width: 18px; height: 18px; vertical-align: -4px; margin-right: 6px; }
.col-name { width: 34%; }
.col-date { width: 20%; }
.col-type { width: 9%; }
.col-size { width: 11%; }

.more { display: flex; justify-content: center; padding: 1rem 0; grid-column: 1 / -1; }

/* ---------- preview pane and its tabs ---------- */

.preview-pane { display: grid; grid-template-rows: minmax(120px, 1fr) 8px minmax(120px, var(--details-height, 40%)); min-height: 0; }
.preview-stage {
    position: relative; background: var(--preview); padding: 8px; min-height: 0;
    display: grid; place-items: center; overflow: hidden;
    container-type: size;   /* lets the image fit the stage exactly (cqw/cqh below) */
}
.preview-stage .photo img, .preview-stage video { display: block; max-width: calc(100cqw - 16px); max-height: calc(100cqh - 16px); }
.preview-fit { display: grid; place-items: center; width: 100%; height: 100%; min-height: 0; }
.preview-empty { color: var(--muted); text-align: center; padding: 1rem; }

.tabs { display: flex; flex-direction: column; min-height: 0; }
.tablist { display: flex; flex-wrap: wrap; gap: 2px; padding-top: 4px; }
.tab {
    border: 1px solid var(--border); border-bottom: 0; border-radius: 4px 4px 0 0; padding: 6px 12px; min-height: 0;
    background: var(--surface); color: var(--text);
}
.tab[aria-selected=true] { background: var(--preview); }
.tabpanel { flex: 1; min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--border); padding: 10px; }
.field-label { margin: 0 0 3px; }
.field-value {
    background: var(--surface); border: 1px solid var(--border); border-radius: 2px; padding: 5px 7px; margin: 0 0 10px;
    min-height: 30px; white-space: pre-line; overflow-wrap: anywhere;
}
.field-value.empty-value { color: var(--muted); font-style: italic; }
.path-label { color: var(--muted); margin-bottom: 10px; overflow-wrap: anywhere; }
.tab-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.meta-note { color: var(--muted); margin-bottom: 8px; }
.meta-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.meta-table th, .meta-table td { text-align: left; padding: 3px 6px; border: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.meta-table th { font-weight: 400; background: var(--surface); }
.meta-table td:nth-child(1) { width: 22%; }
.meta-table td:nth-child(2) { width: 30%; }
.people-list { list-style: none; margin: 0 0 10px; padding: 0; border: 1px solid var(--border); border-radius: 2px; min-height: 60px; }
.people-list li a { display: block; padding: 4px 8px; color: var(--text); text-decoration: none; }
.people-list li a:hover { background: var(--preview); }

.video-mark {
    position: absolute; left: 8px; bottom: 8px; width: 22px; height: 22px; border-radius: 50%;
    background: rgba(16, 19, 25, .72);
}
.video-mark::after {
    content: ""; position: absolute; left: 8px; top: 6px;
    border-left: 8px solid #fff; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}

.photo { position: relative; display: inline-block; line-height: 0; }
.photo.turn-90 img { transform: rotate(90deg); }
.photo.turn-180 img { transform: rotate(180deg); }
.photo.turn-270 img { transform: rotate(270deg); }
.facebox {
    position: absolute; border: 2px solid #ffd54f; border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .45); line-height: 1.2; text-decoration: none;
}
.facebox span {
    position: absolute; left: 50%; top: calc(100% + 3px); transform: translateX(-50%);
    background: rgba(16, 19, 25, .82); color: #fff; font: 600 12px/1.2 var(--ui);
    padding: .2em .5em; border-radius: 2px; white-space: nowrap;
}
.facebox:hover { border-color: var(--focus); }

/* ---------- full view (opened by double-click) ---------- */

.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 100%; min-height: 0; border: 1px solid var(--border); }
.stage { background: var(--stage); color: #e9ecf2; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; padding: .5rem .8rem; }
.stage-back { color: #e9ecf2; text-decoration: none; font-weight: 600; }
.stage-back::before { content: "‹ "; }
.stage-nav { display: flex; gap: .5rem; }
.stage-step {
    display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    color: #fff; text-decoration: none; font-size: 1.7rem; line-height: 1; background: rgba(255, 255, 255, .1);
}
.stage-step:hover { background: rgba(255, 255, 255, .22); }
.stage-frame { flex: 1; display: grid; place-items: center; padding: .5rem 1rem 1rem; min-height: 0; }
.stage-frame video, .stage-frame .photo img { max-width: 100%; max-height: calc(100vh - 190px); max-height: calc(100dvh - 190px); background: #222; }

.details { background: var(--surface); border-left: 1px solid var(--border); padding: 1rem 1.1rem 2rem; overflow: auto; overflow-wrap: anywhere; }
.details-title { font-size: 1.25rem; }
.details-date { color: var(--muted); }
.details-description { white-space: pre-line; }
.details-heading { font-size: 13px; font-weight: 600; color: var(--muted); margin: 1.1rem 0 .4rem; }
.details-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.1rem 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.chips { list-style: none; margin: 0 0 .6rem; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
    display: inline-flex; gap: .4em; align-items: baseline; padding: .2em .7em; border-radius: 3px;
    background: var(--preview); border: 1px solid var(--border); color: var(--text); text-decoration: none;
}
.chip:hover { border-color: var(--focus); }

/* ---------- album viewer (like the desktop's AlbumViewerWindow) ---------- */

.album-viewer {
    display: flex; flex-direction: column; height: 100%; min-height: 0;
    background: var(--preview); color: var(--text); padding: 16px; outline: none; border: 1px solid var(--border);
}
.album-viewer:fullscreen { border: 0; padding: 20px; }
.av-head { position: relative; text-align: center; margin-bottom: 12px; }
.av-back { position: absolute; left: 0; top: 4px; }
.av-title { font-size: 24px; margin: 0; padding: 0 120px; overflow-wrap: anywhere; }
.av-description { color: var(--muted); font-size: 13px; max-width: 900px; margin: 6px auto 0; white-space: pre-line; }
.av-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; display: grid; place-items: center; touch-action: pan-y pinch-zoom; }
.av-photo { display: flex; flex-direction: column; align-items: center; max-width: 100%; }
.av-viewport { position: relative; overflow: hidden; line-height: 0; touch-action: none; }
.av-viewport.zoomed { cursor: grab; }
.av-viewport.dragging { cursor: grabbing; }
.av-frame { position: relative; transform-origin: 0 0; }
.av-image, .av-video { display: block; user-select: none; -webkit-user-select: none; }
.av-image[hidden], .av-video[hidden] { display: none; }
.av-names { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.av-name {
    position: absolute; padding: 2px 6px; border-radius: 3px; background: rgba(0, 0, 0, .72); color: #fff;
    font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.av-caption { font-size: 20px; font-weight: 600; text-align: center; margin: 10px 0 0; max-width: 100%; overflow-wrap: anywhere; white-space: pre-line; }
.av-caption[hidden] { display: none; }
.av-message { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 15px; margin: 0; pointer-events: none; }
.av-message:empty { display: none; }
.av-countdown { height: 4px; border-radius: 2px; background: var(--border); margin-top: 12px; visibility: hidden; overflow: hidden; }
.av-fill { height: 100%; background: var(--text); border-radius: 2px; transform: scaleX(0); transform-origin: 0 50%; }
.av-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 12px; }
.av-zoom, .av-nav { display: flex; align-items: center; gap: 4px; }
.av-zoom button { min-width: 36px; justify-content: center; padding: 6px 10px; }
.av-zoom-text { min-width: 48px; text-align: center; color: var(--muted); }
.av-zoom-fit { margin-left: 4px; }
.av-nav { justify-content: center; flex-wrap: wrap; }
.av-prev, .av-next { min-width: 130px; justify-content: center; padding: 8px 18px; }
.av-play { margin-left: 24px; min-width: 104px; justify-content: center; padding: 8px 14px; }
.av-position { min-width: 90px; text-align: center; margin: 0 12px; }
.av-spinner { display: inline-flex; height: 30px; margin: 0 6px 0 10px; }
.av-seconds { width: 44px !important; min-height: 0; height: 30px; text-align: center; padding: 2px 4px; }
.av-arrows { display: grid; grid-template-rows: 1fr 1fr; gap: 1px; width: 20px; margin-left: 2px; }
.av-arrows button { min-height: 0; padding: 0; font-size: 8px; justify-content: center; border-radius: 2px; }
.av-seconds-label { color: var(--muted); }
.av-fullscreen { margin-left: 16px; }
.av-names-toggle { justify-self: end; display: flex; align-items: center; gap: 6px; }
.av-names-toggle[hidden] { display: none; }

@media (max-width: 900px) {
    .av-bar { grid-template-columns: 1fr auto; }
    .av-nav { grid-column: 1 / -1; order: -1; }
    .av-play { margin-left: 8px; }
    .av-fullscreen { margin-left: 8px; }
}
@media (max-width: 760px) {
    .album-viewer { height: calc(100dvh - 80px); padding: 10px; }
    .av-title { font-size: 19px; padding: 0; margin-top: 22px; }
    .av-prev, .av-next { min-width: 0; padding: 8px 12px; }
    .av-position { min-width: 0; margin: 0 6px; }
    .av-caption { font-size: 16px; }
}

/* ---------- family tree (like the desktop's FamilyTreeWindow: 156 × 258 cards, 130 × 160 photos) ---------- */

.tree-page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tree-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; }
.tree-person { display: flex; align-items: center; gap: 8px; }
.tree-person select { width: auto; min-width: 320px; max-width: 100%; }
.tree-summary { color: var(--muted); }
.tree-grow { flex: 1; }
.tree-zoom { display: flex; align-items: center; gap: 4px; }
.tree-zoom button { min-width: 36px; justify-content: center; }
.tree-zoom-text { min-width: 48px; text-align: center; color: var(--muted); }
.tree-zoom button[data-zoom=fit] { margin-left: 4px; }
.tree-canvas { flex: 1; min-height: 0; overflow: auto; background: var(--preview); border: 1px solid var(--border); cursor: default; user-select: none; -webkit-user-select: none; }
.tree-canvas.dragging, .tree-canvas.dragging .tree-card { cursor: move; }
.tree-sizer { position: relative; overflow: hidden; }
.tree-chart { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tree-lines { position: absolute; left: 0; top: 0; }
.tree-lines line { stroke: var(--muted); stroke-width: 2; shape-rendering: crispEdges; }
.tree-card {
    position: absolute; width: 156px; height: 258px; padding: 8px; display: flex; flex-direction: column; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text); text-decoration: none; cursor: pointer;
}
.tree-card:hover { border-color: var(--focus); }
.tree-card.chosen { border: 3px solid var(--focus); padding: 6px; }
.tree-relation { font-size: 11px; color: var(--muted); margin-bottom: 4px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-photo { position: relative; width: 130px; height: 160px; flex: none; border-radius: 4px; overflow: hidden; background: var(--preview); display: grid; place-items: center; }
.tree-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.tree-initials { font-size: 40px; font-weight: 300; color: var(--muted); }
.tree-name { font-size: 13px; font-weight: 600; text-align: center; margin-top: 6px; line-height: 1.3; max-height: 34px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tree-years { font-size: 11px; color: var(--muted); }

@media (max-width: 760px) {
    .tree-page { height: calc(100dvh - 80px); }
    .tree-person select { min-width: 0; }
}

/* ---------- folders and albums shown as tiles (albums list) ---------- */

.stacks { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stack-card { display: grid; gap: 2px; padding: 6px; border-radius: 3px; color: var(--text); text-decoration: none; }
.stack-card:hover { background: var(--preview); }
.stack { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--preview); overflow: hidden; margin-bottom: 4px; }
.stack img { max-width: 100%; max-height: 100%; object-fit: contain; }
.stack img.broken { visibility: hidden; }
.stack-name { font-weight: 600; }
.stack-count { color: var(--muted); font-size: 12.5px; }
.album-view-link { display: inline-block; margin: 0 6px 6px; font-size: 13px; }

/* ---------- album page grid ---------- */

.gridbar { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.gridbar-count { color: var(--muted); margin-right: .25rem; }
.prints { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
.print-cell { min-width: 0; padding: 6px; border-radius: 3px; }
.print-cell:hover { background: var(--preview); }
.print { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; padding: 0; margin: 0; background: var(--preview); border: 0; border-radius: 0; overflow: hidden; }
.print img { max-width: 100%; max-height: 100%; object-fit: contain; }
.print img.broken { visibility: hidden; }
.print-caption { font-size: 12.5px; margin: .35rem 2px 0; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cover-mark { position: absolute; left: 6px; top: 6px; background: var(--select); color: #fff; font-size: 12px; font-weight: 600; padding: .1em .5em; border-radius: 2px; }
.arrange { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.arrange button { min-height: 26px; padding: 2px 8px; font-size: 12.5px; }
.caption-edit { margin-top: .4rem; font-size: 12.5px; }

/* ---------- add to album ---------- */

.addto { position: relative; display: inline-flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.addto-panel {
    position: absolute; z-index: 30; top: calc(100% + 4px); left: 0;
    width: min(320px, 86vw); background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 3px; box-shadow: var(--shadow); padding: .6rem;
}
.addto-list { list-style: none; margin: 0 0 .5rem; padding: 0; max-height: 260px; overflow: auto; }
.addto-choice { width: 100%; justify-content: space-between; border: 0; background: none; padding: 6px 8px; }
.addto-choice:hover:not(:disabled) { background: var(--preview); }
.addto-new { display: grid; gap: .45rem; border-top: 1px solid var(--border); padding-top: .55rem; }
.addto-status { color: var(--muted); }

/* ---------- people ---------- */

.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.25rem; margin: .5rem 0; }
.filterbar input[type=search] { max-width: 320px; }
.people-grid { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.person-card { display: grid; justify-items: center; text-align: center; gap: 1px; padding: 8px 6px; border-radius: 3px; color: var(--text); text-decoration: none; }
a.person-card:hover { background: var(--preview); }
.portrait { display: grid; place-items: center; width: 104px; aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: var(--preview); border: 1px solid var(--border); margin-bottom: .4rem; }
.portrait.large { width: 160px; }
.portrait img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.6); }
.portrait img.broken { visibility: hidden; }
.initials { font-size: 1.5rem; font-weight: 600; color: var(--muted); }
.person-name { font-weight: 600; }
.person-years, .person-count { color: var(--muted); font-size: 12.5px; }

.person-page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.person-page .panes { flex: 1; height: auto; min-height: 360px; }
.person-head { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: flex-start; margin: .25rem 0 .75rem; }
.person-head .person-card { pointer-events: none; padding: 0; }
.person-head .person-name, .person-head .person-years, .person-head .person-count { display: none; }
.person-facts { flex: 1 1 320px; }
.person-facts h1 { margin-bottom: .2em; }
.person-facts p { margin-bottom: .3em; }
.person-notes { white-space: pre-line; color: var(--muted); }
.family { display: flex; flex-wrap: wrap; gap: .25rem 2rem; margin-bottom: .5rem; }
.family-group .details-heading { margin-top: .3rem; }

/* ---------- search, albums ---------- */

.searchform, .inline-form { display: flex; gap: .5rem; max-width: 560px; margin: .5rem 0 .75rem; }
.form-stack { display: grid; gap: .8rem; }
.album-edit { max-width: 560px; margin-bottom: 1rem; }
.row { display: flex; gap: .5rem; }
.confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .25rem .5rem; border-radius: 3px; background: var(--preview); }
.list-page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.list-page > .panes { flex: 1; height: auto; min-height: 320px; }

/* ---------- accounts ---------- */

.account-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 16px; }
.account-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1.5rem 1.5rem 1.25rem; }
.account-title { font-size: 1.1rem; font-weight: 600; color: var(--muted); margin-bottom: 1rem; }
.account-card h1 { font-size: 1.5rem; }
.account-card .primary { justify-content: center; margin-top: .25rem; min-height: 34px; }
.account-note { color: var(--muted); font-size: .92rem; margin-top: 1.1rem; }
.form-error { color: var(--error); font-weight: 600; }
.form-ok { color: var(--link); font-weight: 600; }
.validation-message { color: var(--error); font-size: .9rem; margin-top: -.4rem; }

.account-create {
    display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end;
    background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: .9rem 1.1rem; margin: .75rem 0 1.25rem;
}
.account-create h2 { grid-column: 1 / -1; margin: 0; }
.accounts { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); }
.accounts th, .accounts td { text-align: left; padding: .5rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.accounts th { color: var(--muted); font-weight: 400; }
.accounts .actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.accounts .actions button { min-height: 26px; padding: 2px 8px; font-size: 12.5px; }

/* ---------- connection problems ---------- */

#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    background: var(--text); color: var(--window); padding: .7rem 20px;
}
#blazor-error-ui a { color: inherit; }

/* ---------- phones and narrow windows: the menu slides in, panes stack ---------- */

@media (max-width: 760px) {
    :root, :root[data-nav=collapsed] { --nav-width: 0px; }
    body { font-size: 15px; }
    input[type=text], input[type=search], input[type=password], textarea, select { font-size: 16px; } /* stops iOS zooming in */
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidenav {
        position: fixed; z-index: 60; inset: 0 auto 0 0; width: min(280px, 82vw);
        transform: translateX(-102%); transition: transform .18s ease-out; box-shadow: var(--shadow);
    }
    :root[data-navopen] .sidenav { transform: none; }
    :root[data-navopen] .shell::after { content: ""; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .35); }
    :root[data-nav=collapsed] .nav-label, :root[data-nav=collapsed] .nav-heading,
    :root[data-nav=collapsed] .nav-user, :root[data-nav=collapsed] .nav-theme select { display: revert; }
    .nav-toggle { display: none; }
    .workspace { padding: 10px 12px; }
    .apphead { gap: 10px; margin-bottom: 10px; }
    .appname { font-size: 20px; }
    .nav-open { display: inline-flex; padding: 4px 8px; }
    .nav-open svg { width: 22px; height: 22px; }

    .panes, .panes.with-side { display: flex; flex-direction: column; height: auto; }
    .content.fill { overflow: auto; }
    .splitter, .preview-pane { display: none; }
    .tree-pane { margin-bottom: 10px; }
    .tree-pane .tree-scroll { max-height: 40vh; }
    .tree-pane.closed .tree-scroll { display: none; }
    .files-pane .files-scroll { flex: none; height: 78vh; height: 78dvh; }
    .files.view-3 { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
    .files.view-4 { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
    .files.view-6 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .files.view-6 .file-thumb { width: 100%; height: auto; aspect-ratio: 4 / 3; }
    .files.view-5 { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .files.view-5 .file-thumb { width: 100%; height: auto; aspect-ratio: 4 / 3; }
    .details-table .col-type, .details-table .col-size, .details-table td:nth-child(3), .details-table td:nth-child(4),
    .details-table th:nth-child(3), .details-table th:nth-child(4) { display: none; }
    .person-page, .list-page { height: auto; }

    .viewer { grid-template-columns: 1fr; height: auto; }
    .details { border-left: 0; border-top: 1px solid var(--border); }
    .stage-frame video, .stage-frame .photo img { max-height: 70vh; }
    .accounts thead { display: none; }
    .accounts tr { display: grid; padding: .4rem 0; border-bottom: 1px solid var(--border); }
    .accounts td { border: 0; padding: .15rem .8rem; }
}
@media (min-width: 761px) {
    .tree-pane-toggle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
