* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
#source-control { max-width: 100%; }
#select-source { max-width: min(240px, 50vw); }
#config-notice { position: fixed; bottom: 12px; left: 12px; right: 12px; z-index: 110; padding: 10px 14px; border: 1px solid #b7791f; border-radius: 8px; background: #30230b; color: #fff3cd; font-size: 13px; max-height: 25vh; overflow: auto; }
:root { color-scheme: dark; }
#scan-failures { flex-shrink:0; margin:10px 12px 0; padding:10px; border:1px solid #92400e; border-radius:8px; background:#291d0a; color:#fde68a; font-size:13px; overflow-wrap:anywhere; }
#scan-failures .btn { margin:6px 0 0; }
.brand-logo { display:block; width:120px; height:40px; object-fit:contain; flex:0 0 auto; }
.brand-home { display:flex; align-items:center; justify-content:center; flex:0 0 auto; min-height:44px; padding:0; border:0; border-radius:8px; background:transparent; cursor:pointer; }
.brand-home:hover { background:rgba(255,255,255,.06); }
.hide-filenames #media-title, .hide-filenames .grid-item-caption { display:none; }
.returned-tile { outline:3px solid #93c5fd; outline-offset:-3px; }
.loading-note { position:absolute; bottom:15%; left:50%; transform:translateX(-50%); z-index:6; display:flex; align-items:center; gap:10px; padding:10px 14px; border-radius:20px; background:rgba(15,23,42,.9); color:#cbd5e1; font-size:13px; max-width:90%; pointer-events:none; }
.scan-loading { display:flex; align-items:center; gap:10px; padding:12px 20px; color:#94a3b8; font-size:13px; flex-shrink:0; }
.scan-progress-track { flex:1 1 120px; max-width:220px; height:4px; border-radius:2px; background:rgba(255,255,255,.12); overflow:hidden; }
.scan-progress-fill { height:100%; width:0%; background:#3b82f6; border-radius:2px; transition:width .3s ease; }
.loading-spinner { display:inline-block; flex:0 0 16px; width:16px; height:16px; border:2px solid #475569; border-top-color:#93c5fd; border-radius:50%; animation:loading-spin 1s linear infinite; }
@keyframes loading-spin { to { transform:rotate(360deg); } }
.thumb-loading::after { content:''; position:absolute; inset:0; background:linear-gradient(110deg,#111827 20%,#263449 45%,#111827 70%); background-size:200% 100%; animation:thumbnail-shimmer 1.8s ease-in-out infinite; pointer-events:none; z-index:2; }
@keyframes thumbnail-shimmer { to { background-position:-200% 0; } }
.thumbnail-unavailable { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:#111827; color:#94a3b8; font-size:12px; padding:12px; z-index:2; }
.controls-free .loading-note, .controls-free .scan-loading { display:none!important; }
body { background:#050505; color:#f5f5f5; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; overflow:hidden; width:100%; height:100vh; height:100dvh; user-select:none; -webkit-user-select:none; }
button, select { font: inherit; }
/* Suppress double-tap control zoom without disabling page pinch zoom. */
button, select, .media-error-actions a { touch-action:manipulation; }
#gallery-wrapper { position:relative; width:100%; height:100%; display:flex; flex-direction:column; justify-content:space-between; }
#media-viewport { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; overflow:hidden; background:#000; z-index:1; }
#media-container { display:flex; align-items:center; justify-content:center; width:100%; height:100%; transform-origin:center center; will-change:transform; }
#media-container.dismiss-drag { transition:none; }
#media-container.dismiss-snapback { transition:transform .18s ease-out,opacity .18s ease-out; }
#gallery-image,#gallery-video { box-shadow:0 4px 30px rgba(0,0,0,.7); border-radius:4px; }
#gallery-image { pointer-events:auto; -webkit-user-drag:none; }
#media-container.grab-mode { touch-action:none; }
#gallery-image.mode-original { width:auto; height:auto; max-width:none; max-height:none; object-fit:none; }
#gallery-image.mode-fit { width:100%; height:100%; max-width:100%; max-height:100%; object-fit:contain; }
#gallery-video { width:100%; height:100%; max-width:100%; max-height:100%; object-fit:contain; z-index:2; pointer-events:auto; }
.overlay { position:absolute; background:rgba(15,15,15,.78); backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px); border:1px solid rgba(255,255,255,.1); border-radius:12px; padding:12px 20px; z-index:10; transition:opacity .35s,transform .35s; }
#overlay-header { top:max(10px,env(safe-area-inset-top)); left:max(12px,env(safe-area-inset-left)); right:max(12px,env(safe-area-inset-right)); display:flex; justify-content:space-between; align-items:center; min-height:54px; padding:8px 20px; background:rgba(8,8,8,.34); }
.header-left,.header-right { display:flex; align-items:center; gap:10px; }
.header-left { overflow:hidden; min-width:0; }
.header-right { flex-wrap:wrap; justify-content:flex-end; }
.title-text { font-size:16px; font-weight:600; color:#fff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:32vw; }
.index-text { font-size:12px; font-weight:700; color:#aaa; background:rgba(255,255,255,.08); padding:4px 10px; border-radius:999px; white-space:nowrap; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:7px; font-size:13px; font-weight:600; padding:8px 13px; border-radius:8px; border:1px solid transparent; cursor:pointer; transition:background .2s,border-color .2s,transform .15s,opacity .2s; outline:none; color:#fff; height:38px; white-space:nowrap; }
.btn:hover:not(:disabled) { transform:translateY(-1px); }
#btn-show-grid:hover:not(:disabled) { transform:none; }
.btn:disabled { opacity:.35; cursor:not-allowed; }
.btn-primary { background:#2563eb; }
.btn-primary:hover { background:#3b82f6; box-shadow:0 0 12px rgba(37,99,235,.35); }
.btn-secondary { background:rgba(255,255,255,.08); border-color:rgba(255,255,255,.1); }
.btn-secondary:hover:not(:disabled) { background:rgba(255,255,255,.16); border-color:rgba(255,255,255,.24); }
.btn.is-active { background:rgba(37,99,235,.22); border-color:rgba(96,165,250,.7); color:#bfdbfe; }
.btn-icon { background:rgba(255,255,255,.04); border-color:rgba(255,255,255,.1); width:38px; padding:0; }
.hide-viewer-button-labels #overlay-header .button-label { display:none; }
.hide-viewer-button-labels #overlay-header .btn { width:38px; min-width:38px; padding-left:0; padding-right:0; gap:0; }
.timer-control { display:flex; align-items:center; gap:7px; }
.timer-control label { font-size:12px; color:#bbb; font-weight:600; }
.custom-select { background:rgba(255,255,255,.08); color:#fff; border:1px solid rgba(255,255,255,.1); border-radius:6px; padding:6px 9px; font-size:12px; font-weight:600; height:38px; outline:none; }
.custom-select option { background:#111; color:#fff; }
.viewer-display-controls { display:flex; flex:0 0 auto; align-items:center; gap:6px; margin-left:auto; }
.viewer-display-controls .btn > span[class$="-mode-icon"] {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    line-height:0;
}
.viewer-display-controls .btn > svg,
.viewer-display-controls .btn > span[class$="-mode-icon"] > svg { display:block; }
.viewer-options { position:relative; flex:0 0 auto; }
.viewer-options-menu {
    position:absolute; top:calc(100% + 7px); right:0;
    display:flex; flex-direction:column; gap:7px;
    width:180px; padding:9px;
    border:1px solid rgba(255,255,255,.14); border-radius:10px;
    background:rgba(12,12,12,.97); box-shadow:0 12px 35px rgba(0,0,0,.65);
    z-index:20;
}
.viewer-options-menu .timer-control { justify-content:space-between; }
.viewer-options-menu .custom-select { width:72px; }
.viewer-options-menu .btn { width:100%; justify-content:flex-start; }
.photo-info-action-slot { display:inline-flex; flex:0 0 auto; }
.photo-info-menu-slot:empty { display:none; }
.photo-info-menu-slot:not(:empty) { display:block; }
.photo-info-menu-slot .btn { width:100%; justify-content:flex-start; }
.photo-info-panel {
    position:absolute;
    top:76px;
    right:max(12px, env(safe-area-inset-right));
    z-index:9;
    width:min(420px, calc(100vw - 24px));
    max-height:calc(100dvh - 96px - env(safe-area-inset-bottom));
    display:flex;
    flex-direction:column;
    overflow:hidden;
    border:1px solid rgba(255,255,255,.3);
    border-radius:12px;
    background:rgba(12,12,12,.88);
    box-shadow:0 14px 40px rgba(0,0,0,.68);
    backdrop-filter:blur(18px);
    -webkit-backdrop-filter:blur(18px);
    animation:photo-info-open .14s ease-out;
}
.photo-info-heading {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:12px 12px 10px 18px;
    border-bottom:1px solid rgba(255,255,255,.09);
}
.photo-info-heading h2 {
    font-size:13px;
    font-weight:600;
    color:var(--ff-accent-bright, #60a5fa);
    letter-spacing:.04em;
    text-transform:uppercase;
}
.photo-info-heading .ff-btn.btn {
    width:34px;
    min-width:34px;
    height:34px;
    padding:0;
    border:0;
    background:transparent;
    box-shadow:none;
    color:#aaa;
}
.photo-info-heading .ff-btn.btn:hover:not(:disabled) { border:0; background:var(--ff-glow-hover); color:#fff; box-shadow:none; }
.photo-info-heading .ff-btn.btn:active:not(:disabled) { background:var(--ff-glow-active); }
.photo-info-content { flex:1 1 auto; min-height:0; overflow:auto; padding:4px 18px 14px; }
.photo-info-state { color:#aaa; font-size:12px; line-height:1.45; }
.photo-info-retry { margin-top:10px; }
.photo-info-list { display:grid; grid-template-columns:minmax(112px, auto) minmax(0, 1fr); column-gap:16px; font-size:13px; line-height:1.35; }
.photo-info-list dt,
.photo-info-list dd { padding:9px 0; border-bottom:1px solid rgba(255,255,255,.12); }
.photo-info-list dt { color:rgba(255,255,255,.68); }
.photo-info-list dd { min-width:0; color:rgba(255,255,255,.94); overflow-wrap:anywhere; user-select:text; -webkit-user-select:text; }
.photo-info-link {
    color:var(--ff-accent-bright, #60a5fa);
    text-decoration:underline;
    text-decoration-color:rgba(96,165,250,.65);
    text-underline-offset:3px;
}
.photo-info-link:hover { color:#93c5fd; text-decoration-color:currentColor; }
.photo-info-link:focus-visible { outline:2px solid var(--ff-accent-bright, #60a5fa); outline-offset:3px; border-radius:2px; }
.photo-info-list dt:nth-last-of-type(1),
.photo-info-list dd:nth-last-of-type(1) { border-bottom:0; }
.photo-info-secondary { display:block; margin-top:2px; color:#888; font-size:11px; }
@keyframes photo-info-open { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
@media (prefers-reduced-motion:reduce) { .photo-info-panel { animation:none; } }
.hide-viewer-button-labels #overlay-header .viewer-options-menu .button-label { display:inline; }
.hide-viewer-button-labels #overlay-header .viewer-options-menu .btn {
    width:100%; min-width:0; padding:8px 10px; gap:7px;
}
.nav-arrow { position:absolute; top:50%; transform:translateY(-50%); background:rgba(15,15,15,.6); border:1px solid rgba(255,255,255,.1); color:#fff; width:60px; height:60px; border-radius:50%; cursor:pointer; display:flex; align-items:center; justify-content:center; z-index:8; transition:opacity .35s,background .2s,border-color .2s; backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px); }
.nav-arrow:hover { background:rgba(255,255,255,.15); border-color:rgba(255,255,255,.3); }
#nav-left { left:20px; } #nav-right { right:20px; }
#progress-container { position:absolute; bottom:0; left:0; right:0; height:4px; background:rgba(255,255,255,.1); z-index:9; overflow:hidden; transition:opacity .35s; }
#progress-bar { height:100%; width:0; background:linear-gradient(90deg,#3b82f6,#60a5fa); transition:width .1s linear; }
.grab-mode { cursor:grab; } .grabbing-mode { cursor:grabbing!important; }
#help-hint { position:absolute; bottom:20px; left:50%; transform:translateX(-50%); background:rgba(0,0,0,.62); padding:6px 14px; border-radius:20px; font-size:11px; color:#999; z-index:7; pointer-events:none; transition:opacity .35s; border:1px solid rgba(255,255,255,.05); white-space:nowrap; }
.ui-hidden { opacity:0!important; pointer-events:none!important; } .cursor-hidden { cursor:none!important; }

#grid-view-container { position:absolute; inset:0; background:#050505; z-index:5; overflow-y:scroll; scrollbar-gutter:stable; display:flex; flex-direction:column; }
#grid-header { position:fixed; top:18px; left:18px; right:18px; z-index:10; display:flex; justify-content:space-between; align-items:center; gap:18px; min-height:62px; padding:10px 16px; }
.grid-header-main { min-width:0; display:flex; flex-direction:row; flex-wrap:wrap; align-items:center; gap:8px; flex:1; }
.grid-title-row { overflow:visible; flex-wrap:wrap; }

.gallery-path-bar, #grid-count {
    display:flex;
    align-items:center;
    gap:8px;
    min-height:34px;
    width:fit-content;
    max-width:min(760px, 70vw);
    padding:6px 10px;
    border:1px solid rgba(255,255,255,.11);
    border-radius:9px;
    background:rgba(255,255,255,.045);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}
.path-icon {
    color:#60a5fa;
    display:flex;
    align-items:center;
    flex:0 0 auto;
}
.folder-path {
    font-size:12px;
    font-weight:600;
    color:#9ca3af;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    padding-left:8px;
    margin-left:2px;
    border-left:1px solid rgba(255,255,255,.11);
}
.breadcrumb {
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:3px;
    min-width:0;
}
.crumb {
    border:0;
    background:transparent;
    color:#dbeafe;
    font-size:13px;
    font-weight:650;
    cursor:pointer;
    padding:3px 5px;
    border-radius:5px;
}
.crumb:hover {
    color:#fff;
    background:rgba(96,165,250,.14);
    text-decoration:none;
}
.crumb:last-child {
    color:#fff;
}
.crumb-separator {
    color:#64748b;
    font-size:14px;
    font-weight:700;
}
.grid-actions { flex-shrink:0; }
.scan-status { font-size:11px; color:#777; min-width:72px; max-width:180px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:right; }
#thumbnail-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(var(--grid-tile-min,180px),1fr)); gap:18px; padding:116px 20px 40px; }
.grid-item { position:relative; aspect-ratio:1/1; border-radius:12px; overflow:hidden; background:#111; border:1px solid rgba(255,255,255,.08); cursor:pointer; transition:transform .2s,border-color .2s,box-shadow .2s; color:inherit; padding:0; }
.grid-item:hover { transform:scale(1.025); border-color:rgba(59,130,246,.55); box-shadow:0 10px 22px rgba(0,0,0,.5); }
.virtual-spacer { grid-column:1 / -1; width:100%; pointer-events:none; }
.virtual-window { display:contents; }
.back-to-top { position:fixed; right:max(18px,env(safe-area-inset-right)); bottom:max(18px,env(safe-area-inset-bottom)); z-index:30; box-shadow:0 8px 24px rgba(0,0,0,.6); }
.grid-item img,.grid-item video { width:100%; height:100%; object-fit:cover; display:block; }
.grid-item img { pointer-events:auto; -webkit-user-drag:none; }
.grid-item video { pointer-events:none; }
.grid-item-caption { position:absolute; bottom:0; left:0; right:0; background:linear-gradient(transparent,rgba(0,0,0,.95)); padding:28px 10px 10px; font-size:11px; font-weight:600; color:#eee; text-align:center; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; opacity:0; transition:opacity .2s; z-index:4; }
.grid-item.has-video-duration .grid-item-caption { padding-right:58px; }
.grid-item:hover .grid-item-caption,.grid-item:focus-visible .grid-item-caption { opacity:1; }
.video-badge { position:absolute; top:10px; right:10px; background:rgba(0,0,0,.72); border:1px solid rgba(255,255,255,.1); border-radius:50%; color:#fff; width:30px; height:30px; display:flex; align-items:center; justify-content:center; z-index:3; }
.video-duration-badge { position:absolute; right:8px; bottom:8px; z-index:5; border:1px solid rgba(255,255,255,.14); border-radius:5px; background:rgba(0,0,0,.78); color:#fff; padding:3px 5px; font-size:10px; font-weight:600; line-height:1; font-variant-numeric:tabular-nums; pointer-events:none; }
.album-card { display:flex; flex-direction:column; align-items:center; justify-content:center; background:linear-gradient(145deg,#111827,#0b0b0d); }
.album-icon { color:#60a5fa; opacity:.9; margin-bottom:8px; }
.album-name { max-width:85%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:15px; font-weight:700; }
.album-subtitle { color:#6b7280; font-size:11px; margin-top:4px; }
.album-card .album-cover { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; z-index:0; }
.has-album-cover .album-icon { position:absolute; top:10px; left:10px; margin:0; padding:6px; display:flex; background:rgba(5,10,20,.8); border:1px solid rgba(96,165,250,.5); border-radius:8px; z-index:2; opacity:1; }
.has-album-cover .album-icon svg { width:22px; height:22px; }
.has-album-cover .album-name { position:absolute; bottom:0; left:0; right:0; max-width:100%; padding:32px 10px 12px; background:linear-gradient(transparent,rgba(0,0,0,.92)); text-align:left; z-index:1; }
.has-album-cover .album-subtitle { display:none; }
.heic-thumb { opacity:.15; transition:opacity .25s; }
.heic-thumb.thumb-loaded { opacity:1; }
.heic-fallback { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:#555; font-size:12px; font-weight:800; letter-spacing:.08em; z-index:-1; }
.thumb-error .heic-fallback { z-index:1; }
.thumb-error .heic-thumb { display:none; }

.warning-container { position:absolute; inset:0; background:radial-gradient(circle at center,#111 0%,#050505 100%); display:flex; align-items:center; justify-content:center; z-index:100; padding:20px; text-align:center; }
.warning-card { background:rgba(20,20,20,.88); backdrop-filter:blur(20px); border:1px solid rgba(255,255,255,.1); border-radius:16px; padding:30px; max-width:550px; width:100%; box-shadow:0 20px 50px rgba(0,0,0,.6); }
.warning-card h2 { color:#ef4444; font-size:24px; margin-bottom:12px; }
.warning-card p { color:#aaa; font-size:14px; line-height:1.5; margin-bottom:20px; }
.warning-card code { background:rgba(255,255,255,.08); color:#60a5fa; padding:2px 6px; border-radius:4px; font-family:monospace; }
.warning-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; }
.instructions { text-align:left; background:rgba(0,0,0,.3); border:1px solid rgba(255,255,255,.05); border-radius:10px; padding:15px; margin-bottom:20px; }
.instructions h3 { font-size:14px; margin-bottom:8px; color:#eee; }
.offline-note { font-size:11px!important; font-style:italic; color:#777!important; }
.video-error-overlay { position:absolute; inset:0; background:rgba(0,0,0,.86); z-index:100; align-items:center; justify-content:center; padding:20px; }
.video-error-card { background:#111827; border:1px solid #475569; padding:clamp(16px,4vw,30px); border-radius:16px; width:100%; max-width:520px; max-height:calc(100dvh - 170px); overflow:auto; text-align:left; box-shadow:0 10px 40px rgba(0,0,0,.5); }
.video-error-card h3 { color:#ef4444; margin-bottom:10px; font-size:18px; }
.video-error-card p { color:#ccc; font-size:14px; margin-bottom:18px; line-height:1.5; }
.media-error-actions { display:flex; flex-wrap:wrap; gap:10px; }
.media-error-actions .btn { min-height:44px; text-decoration:none; }
#media-error-filename { overflow-wrap:anywhere; color:#93c5fd; }

@media (max-width:900px) {
    #overlay-header { top:10px; left:10px; right:10px; padding:8px 12px; flex-direction:column; gap:8px; align-items:stretch; }
    .header-left { justify-content:space-between; }
    .header-right { justify-content:center; }
    .title-text { max-width:60vw; }
    .nav-arrow { width:48px; height:48px; }
    #nav-left { left:10px; } #nav-right { right:10px; }
    #help-hint { display:none!important; }
    #thumbnail-grid { grid-template-columns:repeat(auto-fill,minmax(calc(var(--grid-tile-min,180px) * 0.778),1fr)); gap:12px; }
}
@media (max-width:560px) {
    #thumbnail-grid { grid-template-columns:repeat(auto-fill,minmax(calc(var(--grid-tile-min,180px) * 0.667),1fr)); }
    .btn { padding:8px 10px; }
}

/* Final specificity for glow controls after legacy responsive rules. */
#overlay-header,
#grid-header {
    background:transparent;
    border-color:transparent;
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
}
.ff-btn.btn:focus-visible {
    outline:none;
    box-shadow:0 0 0 2px #000,0 0 0 4px var(--ff-accent);
}

/* Shared two-pill header geometry for grid and viewer now lives in one
   consolidated block near the end of this file (search "Final header chrome"),
   which is the only place .ff-header/.ff-pill layout and sizing is defined. */

/* FolderFrame glow-only button system. */
:root {
    --ff-btn-fg:rgba(255,255,255,.88);
    --ff-btn-fg-muted:rgba(255,255,255,.55);
    --ff-btn-fg-on:#fff;
    --ff-accent:#3b82f6;
    --ff-accent-bright:#60a5fa;
    --ff-glow:rgba(255,255,255,.06);
    --ff-glow-hover:rgba(255,255,255,.12);
    --ff-glow-active:rgba(255,255,255,.18);
    --ff-glow-on:rgba(59,130,246,.22);
    --ff-btn-height:40px;
    --ff-btn-padding-x:12px;
    --ff-btn-radius:9px;
    --ff-btn-gap:4px;
    --ff-icon-size:18px;
    --ff-btn-ease:140ms ease;
}
@media (prefers-reduced-motion:reduce) {
    :root { --ff-btn-ease:0ms; }
}
.ff-btn.btn {
    display:inline-flex; align-items:center; justify-content:center; gap:7px;
    width:auto; min-width:0; height:var(--ff-btn-height); min-height:0;
    padding:0 var(--ff-btn-padding-x); border:0; border-radius:var(--ff-btn-radius);
    background:var(--ff-glow); color:var(--ff-btn-fg);
    font:inherit; font-size:13px; font-weight:500; line-height:1;
    white-space:nowrap; cursor:pointer; user-select:none;
    -webkit-tap-highlight-color:transparent;
    transition:background var(--ff-btn-ease),color var(--ff-btn-ease),transform var(--ff-btn-ease),box-shadow var(--ff-btn-ease);
}
.ff-btn.btn-secondary { border:0; background:var(--ff-glow); }
.ff-btn.btn:hover:not(:disabled) { background:var(--ff-glow-hover); border:0; transform:none; }
.ff-btn.btn:active:not(:disabled) { background:var(--ff-glow-active); transform:scale(.97); }
.ff-btn.btn:focus-visible { outline:0; box-shadow:0 0 0 2px #000,0 0 0 4px var(--ff-accent); }
.ff-btn.btn:disabled,
.ff-btn.btn[aria-disabled="true"] { opacity:.42; cursor:not-allowed; pointer-events:none; }
.ff-btn.btn svg { width:var(--ff-icon-size); height:var(--ff-icon-size); flex-shrink:0; }
.ff-btn.btn.ff-btn-icon { width:var(--ff-btn-height); padding:0; }
.ff-btn.btn[aria-pressed="true"],
.ff-btn.btn.is-on,
.ff-btn.btn.is-active { border:0; background:var(--ff-glow-active); color:var(--ff-btn-fg-on); }
.ff-btn.btn[aria-pressed="true"].ff-btn-accent,
.ff-btn.btn.is-on.ff-btn-accent { background:var(--ff-glow-on); color:#fff; }
/* .ff-btn-home no longer carries its own width/padding — it also gets the
   ff-btn-icon class now that it's icon-only, so it's sized identically to
   every other icon button (Play, Rotate, etc.) with nothing to drift out
   of sync. Its hover/active colors and the brand-logo icon sizing still
   live in the consolidated "Final header chrome" block below. */
.ff-btn-group { display:inline-flex; align-items:center; gap:var(--ff-btn-gap); }
.grid-refresh-slot .button-label { display:none; }
.grid-options-menu .grid-refresh-menu-slot .button-label { display:inline; }
.viewer-options-menu .ff-btn,
.grid-options-menu .ff-btn { width:100%; justify-content:flex-start; }
#overlay-header {
    background:transparent; border-color:transparent;
    backdrop-filter:none; -webkit-backdrop-filter:none;
}

@media (max-width:900px) and (pointer:coarse) {
    .ff-btn.btn,
    .ff-btn.btn.ff-btn-icon,
    .ff-btn.btn.ff-btn-home {
        width:auto; min-width:44px; height:44px; min-height:44px;
    }
    .ff-btn.btn.ff-btn-icon,
    .ff-btn.btn.ff-btn-home { width:44px; padding:0; }
    .viewer-options-menu .ff-btn,
    .grid-options-menu .ff-btn { width:100%; }
}


/* Modern interaction/accessibility refinements */
:focus-visible {
    outline: 2px solid rgba(96,165,250,.95);
    outline-offset: 3px;
}
.grid-item {
    content-visibility: auto;
    contain-intrinsic-size: 180px 180px;
}
.grid-item img {
    background: #0d0d0f;
}
.btn, .grid-item, .crumb, .custom-select {
    -webkit-tap-highlight-color: transparent;
}
@media (hover: none) {
    .grid-item-caption { opacity: 1; }
    .grid-item:hover { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}


@media (max-width: 900px) {
    .gallery-path-bar {
        width:100%;
        max-width:100%;
    }
    .folder-path {
        display:none;
    }
}

/* Content-sized grid header avoids overlap when sources or breadcrumbs wrap. */
#grid-header {
    position:relative; inset:auto; flex-shrink:0;
    margin: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}
#thumbnail-grid {
    overflow-anchor: none;
    flex-shrink:0; padding-top:12px;
    padding-left:max(12px, env(safe-area-inset-left));
    padding-right:max(12px, env(safe-area-inset-right));
    padding-bottom:max(30px, env(safe-area-inset-bottom));
}
.grid-header-main { max-width:100%; }
.grid-header-main .gallery-path-bar { width:auto; min-width:min(200px, 100%); max-width:100%; flex:0 1 auto; }
#grid-count { flex:0 0 auto; min-height:38px; }
.gallery-path-bar { min-width:0; min-height:38px; }
.breadcrumb { flex-wrap:nowrap; overflow-x:auto; max-width:100%; }
.crumb { flex-shrink:0; max-width:60vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.btn svg { flex-shrink:0; }
#grid-view-container { overscroll-behavior:contain; }

@media (max-width:900px), (pointer:coarse) {
    .btn, .custom-select, .crumb { min-height:44px; }
    .btn, .crumb { min-width:44px; }
    .custom-select { font-size:16px; }
    .grid-item-caption { opacity:1; }
    #overlay-header {
        top:max(10px, env(safe-area-inset-top));
        left:max(12px, env(safe-area-inset-left));
        right:max(12px, env(safe-area-inset-right));
        padding:8px; gap:8px; flex-direction:column; align-items:stretch;
    }
    #overlay-header .header-left { gap:8px; }
    #btn-show-grid, #media-index { flex-shrink:0; }
    #media-title { flex:1; min-width:0; max-width:none; font-size:14px; }
    #overlay-header .header-right {
        display:flex; flex-wrap:wrap; justify-content:flex-end; gap:6px;
        overflow:visible; padding:0;
    }
    #overlay-header .header-right > * { flex:0 0 auto; width:auto; }
    #overlay-header .header-right .btn { white-space:nowrap; height:44px; padding:6px 9px; }
    #overlay-header .timer-control { justify-content:center; flex-wrap:nowrap; gap:4px; }
    #overlay-header .timer-control label { font-size:11px; }
    #overlay-header .timer-control select { min-width:0; max-width:100%; }
    #nav-left { left:max(8px, env(safe-area-inset-left)); }
    #nav-right { right:max(8px, env(safe-area-inset-right)); }
    #progress-container { bottom:env(safe-area-inset-bottom); }
    .video-error-overlay { padding:230px 12px max(12px, env(safe-area-inset-bottom)); }
    .video-error-card { max-height:100%; }
    .warning-container { overflow-y:auto; }
    .warning-card { padding:20px; max-height:100%; overflow:auto; }
}
@media (max-width:560px) {
    #source-control { flex-basis:100%; }
    #select-source { flex:1; min-width:0; max-width:100%; }
    .gallery-path-bar { padding:2px 6px; }
    .grid-item-caption { font-size:12px; padding:24px 8px 8px; }
    .media-error-actions .btn { flex:1 1 40%; }
}

@media (max-width:560px) {
    #overlay-header .header-right .btn { font-size:12px; gap:4px; }
    #overlay-header .timer-control { flex-wrap:nowrap; }
    #overlay-header .timer-control label { display:none; }
}
@media (max-width:900px), (pointer:coarse) {
    /* Breadcrumb links already supply the 44px touch target. */
    #grid-header .gallery-path-bar { min-height:44px; padding-top:0; padding-bottom:0; }
    #overlay-header { flex-direction:row; flex-wrap:wrap; align-items:center; justify-content:flex-end; gap:6px; }
    #overlay-header .header-left { flex:0 1 auto; max-width:100%; margin-right:auto; justify-content:flex-start; }
    #overlay-header #media-title { flex:0 1 auto; max-width:clamp(72px, 24vw, 220px); }
    #overlay-header .header-right { display:contents; }
}
@media (max-width:560px) {
    #overlay-header { display:flex; flex-direction:column; align-items:stretch; gap:6px; }
    #overlay-header .header-left { flex:none; width:100%; margin-right:0; }
    #overlay-header #media-title { flex:1; min-width:0; max-width:none; }
    #overlay-header #media-index { margin-left:auto; }
    #overlay-header .header-right { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
    #overlay-header #btn-reset-zoom { display:none; }
    #overlay-header .header-right > * { min-width:0; width:100%; }
    #overlay-header .header-right .btn { padding:6px 4px; white-space:normal; height:auto; min-height:44px; }
    #overlay-header .timer-control select { width:100%; height:44px; }
}
@media (max-height:500px) and (orientation:landscape) {
    #overlay-header { max-height:45dvh; overflow-y:auto; }
}
/* Reserve desktop control space before allocating room to the filename. */
@media (min-width:901px) and (pointer:fine) {
    #overlay-header { gap:12px; }
    /* flex:0 1 auto (not flex-grow:1), same fix as the grid header's left
       pill — the pill should hug its content (home button + filename),
       not stretch to fill the row. #media-title's own max-width:32vw
       already handles long filenames via ellipsis truncation. */
    #overlay-header .header-left { flex:0 1 auto; min-width:0; }
    #overlay-header #media-title { flex:1 1 0; min-width:0; max-width:32vw; }
    #overlay-header #btn-show-grid, #overlay-header #media-index { flex:0 0 auto; }
    #overlay-header .header-right { flex:0 1 auto; width:max-content; min-width:0; }
    #overlay-header .header-right > * { flex:0 0 auto; }
}

/* Icon-only viewer controls pack into compact rows on phones and thin windows. */
@media (max-width:900px) {
    .photo-info-panel { right:max(6px, env(safe-area-inset-right)); width:min(340px, calc(100vw - 12px)); }
    .photo-info-content { padding-inline:14px; }
    .photo-info-list { grid-template-columns:minmax(90px, auto) minmax(0, 1fr); column-gap:12px; font-size:12px; }
    .hide-viewer-button-labels #overlay-header {
        flex-direction:column;
        align-items:stretch;
        justify-content:flex-start;
        gap:6px;
        padding:7px;
    }
    .hide-viewer-button-labels #overlay-header .header-left {
        flex:none;
        width:100%;
        max-width:100%;
        margin:0;
    }
    .hide-viewer-button-labels #overlay-header .header-right {
        display:flex;
        width:100%;
        flex-wrap:wrap;
        justify-content:flex-start;
        align-items:center;
        gap:6px;
    }
    .hide-viewer-button-labels #overlay-header .header-right > * {
        flex:0 0 auto;
        width:auto;
        min-width:0;
    }
    .hide-viewer-button-labels #overlay-header .header-right .btn {
        width:38px;
        min-width:38px;
        height:38px;
        min-height:38px;
        padding:0;
    }
    .hide-viewer-button-labels #overlay-header .viewer-options { margin-left:0; }
    .hide-viewer-button-labels #overlay-header .viewer-options-menu {
        width:min(180px, calc(100vw - 28px));
    }
    .hide-viewer-button-labels #overlay-header .viewer-options-menu .timer-control select {
        width:72px;
        min-width:72px;
        height:38px;
        min-height:38px;
        padding:4px 7px;
        font-size:14px;
    }
}
@media (max-width:900px) and (pointer:coarse) {
    .hide-viewer-button-labels #overlay-header .header-right .btn {
        width:44px;
        min-width:44px;
        height:44px;
        min-height:44px;
    }
    .hide-viewer-button-labels #overlay-header .viewer-options-menu .timer-control select {
        height:44px;
        min-height:44px;
    }
}
@media (max-width:560px) {
    .hide-viewer-button-labels #overlay-header {
        left:max(6px, env(safe-area-inset-left));
        right:max(6px, env(safe-area-inset-right));
        padding:6px;
    }
}
@media (max-width:900px) {
    #overlay-header .viewer-display-controls {
        display:flex;
        flex:0 0 auto;
        flex-wrap:nowrap;
        align-items:center;
        gap:6px;
        width:auto;
        min-width:0;
        margin-left:auto;
    }
    .hide-viewer-button-labels #overlay-header .viewer-options-menu .timer-control label {
        display:block;
    }
    .hide-viewer-button-labels #overlay-header .viewer-options-menu .btn {
        width:100%; min-width:0; height:44px; min-height:44px;
        padding:8px 10px; gap:7px;
    }
}
/* The current folder is plain text, not a duplicate navigation button. */
#grid-header .folder-path { display:block; min-width:0; max-width:none; }
.controls-free #overlay-header,
.controls-free .nav-arrow,
.controls-free #help-hint,
.controls-free #progress-container,
.controls-free #grid-view-container,
.controls-free #video-error-overlay,
.controls-free .warning-container button, .controls-free .warning-container a { display:none!important; }
.controls-free #media-container { touch-action:auto; cursor:default; }

/* Unified, persistent gallery navigation and compact secondary actions. */
#grid-header {
    position:sticky;
    top:0;
    z-index:40;
    display:flex;
    flex-direction:row;
    flex-wrap:nowrap;
    align-items:center;
    justify-content:flex-start;
    gap:8px;
    margin:max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}
#grid-header .grid-header-main {
    /* flex:0 1 auto (not flex-grow:1) so this pill hugs its content — logo,
       separator, breadcrumb — instead of stretching its pill background
       across whatever empty space is left before the right-side pill. */
    display:flex; flex:0 1 auto; min-width:0; max-width:none;
    flex-direction:row; flex-wrap:nowrap; align-items:center; gap:0;
}
#grid-header .gallery-path-bar {
    display:flex;
    flex:0 1 auto;
    width:auto;
    max-width:100%;
    min-width:0;
    padding:0;
    overflow:visible;
    min-height:0;
    border:0;
    border-radius:0;
    background:transparent;
    box-shadow:none;
    gap:0;
}
#grid-header .brand-home { min-width:0; min-height:40px; padding:0 5px 0 0; gap:0; }
#grid-header .brand-logo { width:120px; height:40px; }
#grid-header .path-group-separator { color:#64748b; flex:0 0 auto; font-weight:700; padding:0 5px; }
#grid-header .crumb-separator { color:#60a5fa; padding:0 3px; }
#grid-header .path-root-separator { flex:0 0 auto; order:0; }
#grid-header .source-root-label { color:#dbeafe; font-size:13px; font-weight:700; white-space:nowrap; }
#grid-header .brand-home:hover .source-root-label,
#grid-header .brand-home:focus-visible .source-root-label { color:#fff; }
#grid-header .breadcrumb { overflow:hidden; flex:0 1 auto; }
#grid-header .folder-path {
    flex:0 0 auto; min-width:0; max-width:none; padding:3px 5px; margin:0; border:0;
    font-size:13px; font-weight:650; line-height:normal; color:#dbeafe;
}
#grid-header .source-root-label,
#grid-header .crumb,
#grid-header .folder-path { font-family:inherit; font-size:13px; font-weight:650; color:#dbeafe; }
.grid-status-stack {
    display:flex; flex-direction:row; align-items:center; justify-content:center;
    position:fixed; left:50%; bottom:max(20px, env(safe-area-inset-bottom));
    transform:translateX(-50%); z-index:41;
    gap:4px; min-width:0; height:auto; padding:6px 14px;
    border:1px solid rgba(255,255,255,.05); border-radius:20px;
    background:rgba(0,0,0,.62); color:#999; pointer-events:none;
    font-size:11px; white-space:nowrap;
}
#grid-header .grid-actions {
    display:flex; flex:0 0 auto; min-width:0; width:auto;
    flex-wrap:nowrap; align-items:center; justify-content:flex-end;
    margin-left:auto; gap:6px;
}
#grid-header .grid-actions > .grid-action-slot,
#grid-header .grid-actions > .grid-density-slot,
#grid-header .grid-actions > .grid-options { display:inline-flex; flex:0 0 auto; }
.grid-menu-slot:empty,
.grid-density-menu-slot:empty { display:none; }
.grid-menu-slot:not(:empty),
.grid-density-menu-slot:not(:empty) { display:contents; }
.grid-menu-slot .btn,
.grid-density-menu-slot .btn { width:100%; justify-content:flex-start; }
.grid-status-stack .scan-status { margin-left:0; text-align:right; line-height:1; }
.worker-status-button {
    display:inline-flex; align-items:center; gap:5px; min-width:0; padding:0; border:0;
    background:transparent; color:#a8b3c5; font-size:11px; line-height:1; cursor:pointer;
    pointer-events:auto; white-space:nowrap;
}
.worker-status-button:hover { color:#fff; }
.worker-status-button:focus-visible { outline:2px solid #60a5fa; outline-offset:4px; border-radius:3px; }
.worker-status-dot { width:7px; height:7px; flex:0 0 7px; border-radius:50%; background:#64748b; }
.worker-status-button.is-running .worker-status-dot { background:#60a5fa; animation:worker-status-pulse 1.8s ease-in-out infinite; }
.worker-status-button.is-warning .worker-status-dot { background:#fbbf24; }
.worker-status-button.is-error .worker-status-dot { background:#f87171; }
.worker-status-button.is-complete .worker-status-dot { background:#86efac; }
@keyframes worker-status-pulse { 50% { opacity:.38; } }
@media (prefers-reduced-motion:reduce) {
    .worker-status-button.is-running .worker-status-dot { animation:none; }
}
.worker-status-details {
    position:absolute; left:50%; bottom:calc(100% + 8px); transform:translateX(-50%);
    width:min(330px, calc(100vw - 24px)); padding:11px 12px; border:1px solid rgba(255,255,255,.14);
    border-radius:10px; background:rgba(12,12,12,.97); color:#e5e7eb;
    box-shadow:0 12px 35px rgba(0,0,0,.65); pointer-events:auto; white-space:normal; text-align:left;
}
.worker-status-summary { font-size:12px; line-height:1.4; }
.worker-status-warnings { margin-top:8px; color:#fde68a; font-size:12px; line-height:1.45; }
.worker-status-warnings:empty { display:none; }
.worker-status-counts { margin-top:7px; color:#9ca3af; font-size:11px; line-height:1.45; }
.worker-status-counts:empty { display:none; }
.worker-status-actions { display:flex; justify-content:flex-end; margin-top:9px; }
.worker-status-actions:empty { display:none; }
.worker-status-actions .btn { min-height:36px; padding:6px 10px; font-size:12px; }
.sr-only { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:-1px!important; overflow:hidden!important; clip:rect(0,0,0,0)!important; white-space:nowrap!important; border:0!important; }
.controls-free .grid-status-stack { display:none!important; }
.grid-status-separator { color:#64748b; font-size:11px; line-height:1; }
.grid-status-stack #grid-count,
.grid-status-stack .scan-status {
    min-height:0; margin:0; padding:0; border:0; border-radius:0;
    background:transparent; box-shadow:none; color:#999;
    font-size:11px; font-weight:400; line-height:1; white-space:nowrap;
}
#grid-header #grid-count {
    flex:0 0 auto; min-height:0; padding:0; border:0; border-radius:0;
    background:transparent; box-shadow:none; white-space:nowrap;
    font-size:11px; line-height:1; color:#777; align-self:auto;
}
.crumb-ellipsis { display:none; align-items:center; color:#94a3b8; padding:0 2px; white-space:nowrap; }

/* Query the allocated header row rather than the viewport. This keeps path
   truncation responsive when the right-side controls consume more room. */
#grid-header.header-nav-container {
    container-type:inline-size;
    container-name:headernav;
}

@media (min-width: 901px) and (pointer: fine) {
    #overlay-header .viewer-options-menu .timer-control {
        justify-content: center;
        gap: 8px;
    }
    #overlay-header .viewer-options-menu .timer-control label {
        margin-left: 0;
        color: var(--ff-btn-fg);
        font-size: 13px;
        font-weight: 500;
        line-height: 1;
    }
}

/* Coarse-pointer viewer controls keep a 44px touch target in both pills.
   The legacy right-side rule is intentionally high-specificity; repeat that
   geometry here for the Back button so neither pill grows independently. */
@media (max-width: 900px) and (pointer: coarse) {
    #overlay-header.ff-header .ff-pill {
        height: 54px;
        min-height: 54px;
    }
    .hide-viewer-button-labels #overlay-header.ff-header .ff-header-left.ff-pill #btn-show-grid.ff-btn-home {
        width: 44px;
        min-width: 44px;
        height: 44px;
        min-height: 44px;
    }
}
@container headernav (max-width:520px) {
    #grid-header .crumb-middle { display:none; }
    #grid-header .crumb-ellipsis { display:inline-flex; }
    #grid-header .folder-path { font-weight:700; color:#fff; }
}
.grid-options { margin-left:0; }
.grid-options-menu { width:205px; }
.grid-options-menu .btn { width:100%; justify-content:flex-start; }

/*
 * Mobile grid browse bar (≤700px only):
 * - Options ⋮ stays on row 1, separate pill, reserved width
 * - Path stays on row 1 of the left pill when it fits
 * - Wraps to a tight second row inside the same path pill only when needed
 * - Desktop / Final header chrome otherwise unchanged
 */
@media (max-width:700px) {
    #grid-header,
    #grid-header.ff-header {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 6px;
        padding: 0;
    }

    #grid-header .grid-header-main,
    #grid-header .grid-header-main.ff-pill,
    #grid-header.ff-header .ff-header-left.ff-pill {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        max-width: calc(100% - 52px);
        flex-wrap: wrap;
        align-items: center;
        align-content: flex-start;
        row-gap: 2px;
        column-gap: 0;
        min-height: 0;
        padding: 4px 6px;
    }

    #grid-header .brand-home {
        flex: 0 0 auto;
        min-width: 0;
    }

    /* Share first row with brand; do NOT force 100% width (that always wraps) */
    #grid-header .gallery-path-bar {
        display: flex;
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        max-width: 100%;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: 0;
        padding: 0;
        overflow: hidden;
    }

    @supports not (container-type:inline-size) {
        #grid-header .crumb-middle { display: none; }
        #grid-header .crumb-ellipsis { display: inline-flex; }
    }
    #grid-header .breadcrumb {
        flex: 0 1 auto;
        min-width: 0;
        overflow: hidden;
    }
    #grid-header .folder-path {
        flex: 0 1 auto;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #grid-header .grid-actions,
    #grid-header .grid-actions.ff-pill,
    #grid-header.ff-header .ff-header-right.ff-pill {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
        margin-left: 0;
        gap: 4px;
        min-height: 0;
        padding: 4px;
        align-self: flex-start;
    }

    .grid-status-stack { min-width: 0; padding: 6px 10px; }
    #grid-header .grid-actions > .btn { flex: 0 0 auto; width: auto; }
    #grid-header .grid-options { margin-left: 0; width: auto; }
    #grid-header .grid-options > .btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
        min-height: 40px;
        padding: 0;
    }
    #grid-header .grid-options-menu .btn {
        width: 100%;
        min-width: 0;
        flex-direction: row;
    }
}

@media (max-width:420px) {
    #grid-header {
        margin-left: max(6px, env(safe-area-inset-left));
        margin-right: max(6px, env(safe-area-inset-right));
        gap: 5px;
    }
    #grid-header .grid-header-main,
    #grid-header .grid-header-main.ff-pill {
        max-width: calc(100% - 48px);
        padding: 3px 5px;
        row-gap: 1px;
    }
    #grid-header .gallery-path-bar { gap: 0; padding: 0; }
    #grid-header .source-root-label {
        max-width: 28vw;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #grid-header .crumb { padding-left: 2px; padding-right: 2px; }
    #grid-header .folder-path { max-width: 100%; }
    #grid-header #grid-count { padding: 0; }
    #grid-header .grid-actions { gap: 3px; padding: 3px; }
    #grid-header .grid-options > .btn {
        width: 38px;
        min-width: 38px;
        height: 38px;
        min-height: 38px;
    }
    .grid-status-stack { min-width: 0; padding: 5px 8px; }
}

/* Keep every compact viewer action on one row beneath the filename. */
@media (max-width:560px) {
    .hide-viewer-button-labels #overlay-header .header-right {
        display:flex;
        flex-wrap:nowrap;
        align-items:center;
        justify-content:flex-start;
        width:100%;
        gap:6px;
    }
    .hide-viewer-button-labels #overlay-header .viewer-display-controls {
        display:flex;
        flex-wrap:nowrap;
        width:auto;
        margin-left:auto;
        gap:6px;
    }
}

/* Keep the glow focus ring above the legacy global focus rule. */
.ff-btn.btn:focus-visible {
    outline:none;
    box-shadow:0 0 0 2px #000,0 0 0 4px var(--ff-accent);
}

/* The .ff-header/.ff-pill layout rules live in one place only — the
   "Final header chrome" block further down — to avoid the exact kind of
   drifting duplicate-definition bug that caused the back-button mismatch. */


/* ============================================================
   Final header chrome — matched heights, logos, path, glow
   ============================================================ */

:root {
    /* --ff-accent, --ff-glow*, --ff-btn-fg*, --ff-btn-height, --ff-btn-radius,
       and --ff-btn-ease are already defined once, above, in the glow-button
       system block — not repeated here, so there's one source of truth. */
    --ff-pill-bg: rgba(20, 20, 22, 0.72);
    --ff-pill-border: rgba(255, 255, 255, 0.08);
    --ff-pill-blur: 12px;
    --ff-pill-radius: 12px;
    --ff-pill-pad-y: 4px;
    --ff-pill-pad-x: 4px;
    /* Pill height = button height (40px, matches the brand logo's own
       height) + 2 * pad-y + 2 * border. Every pill and every button inside
       it share this one number, so the header can't change height when
       switching between grid and viewer. */
    --ff-header-pill-min: 50px;
    --ff-title-logo-h: 40px;
    --ff-title-logo-w: 120px;
}

@media (prefers-reduced-motion: reduce) {
    :root { --ff-btn-ease: 0ms; }
}

/* Kill legacy blue is-active on glow controls */
.btn.is-active {
    background: rgba(255, 255, 255, 0.08);
    border-color: transparent;
    color: #fff;
}
.ff-btn.btn.is-active,
.ff-btn.btn[aria-pressed="true"],
.ff-btn.btn.is-on {
    border: 0 !important;
    background: var(--ff-glow-active) !important;
    color: var(--ff-btn-fg-on) !important;
}
.ff-btn.btn.ff-btn-accent.is-active,
.ff-btn.btn.ff-btn-accent[aria-pressed="true"],
.ff-btn.btn.ff-btn-accent.is-on {
    background: var(--ff-glow-on) !important;
    color: #fff !important;
}

/* Shared header row + tight pills (grid + viewer) */
#overlay-header.ff-header,
#grid-header.ff-header {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 0;
    padding: 0;
    background: transparent;
    border: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
#overlay-header.ff-header .ff-pill,
#grid-header.ff-header .ff-pill {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 2px;
    min-height: var(--ff-header-pill-min);
    padding: var(--ff-pill-pad-y) var(--ff-pill-pad-x);
    border-radius: var(--ff-pill-radius);
    background: var(--ff-pill-bg);
    border: 1px solid var(--ff-pill-border);
    backdrop-filter: blur(var(--ff-pill-blur));
    -webkit-backdrop-filter: blur(var(--ff-pill-blur));
    box-sizing: border-box;
    width: max-content;
    max-width: 100%;
}
#overlay-header.ff-header .ff-header-right.ff-pill,
#grid-header.ff-header .ff-header-right.ff-pill {
    flex: 0 0 auto;
    margin-left: auto;
}

/* ---- Grid: title lockup + · Photos as one tight control ---- */
#grid-header .brand-home {
    display: inline-flex;
    align-items: center;
    gap: 0;
    height: 100%;
    padding: 0 6px 0 2px;
    margin: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}
#grid-header .brand-home:hover,
#grid-header .brand-home:focus-visible {
    background: var(--ff-glow-hover);
}
#grid-header .brand-logo {
    width: var(--ff-title-logo-w) !important;
    height: var(--ff-title-logo-h) !important;
    max-width: var(--ff-title-logo-w) !important;
    max-height: var(--ff-title-logo-h) !important;
    object-fit: contain;
    object-position: left center;
    display: block;
    flex: 0 0 auto;
}
/* Tight · Photos — reads as one control with the title logo */
#grid-header .path-group-separator {
    padding: 0 4px !important;
    margin: 0 !important;
    color: rgba(255, 255, 255, 0.35);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
}
#grid-header .source-root-label {
    padding: 0 !important;
    margin: 0 !important;
    font-size: 13px !important;
    font-weight: 650 !important;
    color: #dbeafe !important;
    line-height: 1.2;
    white-space: nowrap;
}

/* Path segments — uniform type + hover glow */
#grid-header .crumb,
#grid-header .folder-path {
    display: inline-flex;
    align-items: center;
    min-height: var(--ff-btn-height);
    height: var(--ff-btn-height);
    padding: 0 8px;
    border: 0;
    border-radius: var(--ff-btn-radius);
    background: transparent;
    font-family: inherit;
    font-size: 13px !important;
    font-weight: 650 !important;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.2;
}
#grid-header button.crumb {
    cursor: pointer;
}
#grid-header button.crumb:hover,
#grid-header button.crumb:focus-visible {
    background: var(--ff-glow-hover) !important;
    color: #fff !important;
}
#grid-header button.crumb:active {
    background: var(--ff-glow-active) !important;
}
#grid-header .folder-path {
    cursor: default;
    color: #fff !important;
    background: transparent !important;
}
#grid-header .crumb-separator {
    padding: 0 2px;
    color: rgba(255, 255, 255, 0.35);
    background: transparent !important;
    font-size: 13px;
    font-weight: 600;
}

/* Glow buttons inside pills */
.ff-pill .ff-btn.btn,
.ff-pill .ff-btn.btn-secondary {
    border: 0;
    background: transparent;
    height: var(--ff-btn-height);
    min-height: var(--ff-btn-height);
    border-radius: var(--ff-btn-radius);
    color: var(--ff-btn-fg);
    transition: background var(--ff-btn-ease), color var(--ff-btn-ease), transform var(--ff-btn-ease);
}
.ff-pill .ff-btn.btn:hover:not(:disabled) {
    background: var(--ff-glow-hover);
    transform: none;
}
.ff-pill .ff-btn.btn:active:not(:disabled) {
    background: var(--ff-glow-active);
    transform: scale(0.97);
}
.ff-btn.btn.ff-btn-icon {
    width: var(--ff-btn-height);
    padding: 0;
}

/* ---- Viewer: back-to-grid control — icon-only, same square sizing as
   every other .ff-btn-icon (Play, Rotate, etc.); no custom width/padding
   here anymore now that the button has no text label to make room for. */
#overlay-header #btn-show-grid.ff-btn-home:hover:not(:disabled) {
    background: var(--ff-glow-hover);
    color: #fff;
}
#overlay-header #btn-show-grid.ff-btn-home:active:not(:disabled) {
    background: var(--ff-glow-active);
    transform: scale(0.97);
}
/* 1.5:1 asset (1536x1024) scaled to sit inside the 40px square button with
   comfortable margin, same visual weight as the 18px SVG icons beside it. */
#overlay-header .viewer-back-logo {
    width: 26px;
    height: 17px;
    object-fit: contain;
    display: block;
}
#overlay-header .viewer-file-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    flex: 1 1 auto;
}
#overlay-header #media-title {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
}
#overlay-header #media-index.index-text {
    flex: 0 0 auto;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.45);
}

/* Refresh stays menu-only with label */
#grid-refresh-slot { display: none !important; }
.grid-options-menu .button-label,
.viewer-options-menu .button-label {
    display: inline !important;
}
.grid-options-menu .ff-btn,
.viewer-options-menu .ff-btn {
    width: 100%;
    justify-content: flex-start;
}

@media (max-width: 900px) {
    #overlay-header.ff-header {
        flex-wrap: nowrap;
        gap: 8px;
    }
    #overlay-header.ff-header .ff-header-left.ff-pill {
        flex: 0 1 auto;
        min-width: 0;
        max-width: calc(100% - 160px);
    }
}

/* Mobile path wrap wins over Final header chrome nowrap (grid only) */
@media (max-width: 700px) {
    #grid-header.ff-header {
        flex-wrap: nowrap !important;
        align-items: flex-start !important;
    }
    #grid-header.ff-header .ff-header-left.ff-pill,
    #grid-header .grid-header-main.ff-pill {
        flex-wrap: wrap !important;
        width: auto !important;
        max-width: calc(100% - 52px) !important;
        flex: 1 1 auto !important;
    }
    #grid-header .gallery-path-bar {
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    #grid-header.ff-header .ff-header-right.ff-pill,
    #grid-header .grid-actions.ff-pill {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: none !important;
        margin-left: 0 !important;
        align-self: flex-start !important;
    }
}
