/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================================
   DESIGN TOKENS — Minimal Black & White
   Typography does the work. Space is the luxury.
   Color only where it carries meaning.
   ============================================================ */
:root {
    /* ── Apple System Colors (Light) — kept for semantic use only ── */
    --system-red: rgb(255, 59, 48);
    --system-orange: rgb(255, 149, 0);
    --system-yellow: rgb(255, 204, 0);
    --system-green: rgb(52, 199, 89);
    --system-mint: rgb(0, 199, 190);
    --system-teal: rgb(48, 176, 199);
    --system-cyan: rgb(50, 173, 230);
    --system-blue: rgb(0, 122, 255);
    --system-indigo: rgb(88, 86, 214);
    --system-purple: rgb(175, 82, 222);
    --system-pink: rgb(255, 45, 85);
    --system-brown: rgb(162, 132, 94);

    /* ── Grays (Light) ── */
    --system-gray: rgb(142, 142, 147);
    --system-gray-2: rgb(174, 174, 178);
    --system-gray-3: rgb(199, 199, 204);
    --system-gray-4: rgb(209, 209, 214);
    --system-gray-5: rgb(229, 229, 234);
    --system-gray-6: rgb(242, 242, 247);

    /* ── Surfaces — Light ── */
    --bg: #ffffff;
    --bg-elevated: #f5f5f5;
    --bg-tertiary: #ebebeb;
    --text: #000000;
    --text-dim: #6e6e73;
    --text-muted: #aeaeb2;
    --header-bg: rgba(255, 255, 255, 0.88);
    --separator: rgba(0, 0, 0, 0.08);

    /* ── Glass — neutral ── */
    --glass-bg: rgba(120, 120, 128, 0.04);
    --glass-bg-hover: rgba(120, 120, 128, 0.08);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-border-hover: rgba(0, 0, 0, 0.18);

    /* ── Fill Colors ── */
    --fill-primary: rgba(120, 120, 128, 0.2);
    --fill-secondary: rgba(120, 120, 128, 0.16);
    --fill-tertiary: rgba(118, 118, 128, 0.12);
    --fill-quaternary: rgba(116, 116, 128, 0.08);

    /* ── Elevation ── */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.04);
    --shadow-elevated: 0 4px 16px rgba(0, 0, 0, 0.08), 0 12px 40px rgba(0, 0, 0, 0.06);
    --shadow-bento: 0 4px 16px rgba(0, 0, 0, 0.12), 0 12px 40px rgba(0, 0, 0, 0.08), 0 24px 80px rgba(0, 0, 0, 0.06);
    --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.15);
    --shadow-deck: 0 8px 32px rgba(0, 0, 0, 0.3);

    /* ── Layout ── */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* ── Spacing Scale ── */
    --space-0_5: 2px;
    --space-1: 4px;
    --space-1_5: 6px;
    --space-2: 8px;
    --space-2_5: 10px;
    --space-3: 12px;
    --space-3_5: 14px;
    --space-4: 16px;
    --space-4_5: 18px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 28px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;

    /* ── Type Scale ── */
    --text-2xs: 10px;
    --text-xs: 11px;
    --text-caption: 12px;
    --text-sm: 13px;
    --text-base: 15px;
    --text-lg: 17px;
    --text-xl: 20px;
    --text-2xl: 22px;
    --text-3xl: 28px;
    --text-4xl: 34px;
    --text-5xl: 48px;
    --text-6xl: 64px;

    /* ── Motion — Apple HIG curves ── */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-in-out: cubic-bezier(0.45, 0, 0.15, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
    --transition: var(--duration-normal) var(--ease-out-quart);

    /* ── Typography ── */
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
    --font-mono: 'SF Mono', ui-monospace, 'Fira Code', 'JetBrains Mono', monospace;
    --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', system-ui, sans-serif;

    /* ── Category colors — monochrome ── */
    --c-vibe: var(--text-dim);
    --c-grading: var(--text-dim);
    --c-time: var(--text-dim);
    --c-setting: var(--text-dim);
    --c-scene: var(--text-dim);
    --c-emotion: var(--text-dim);
    --c-camera: var(--text-dim);
    --c-style: var(--text-dim);

    /* ── Emotion colors — kept for Faces (semantic) ── */
    --emo-happy: var(--system-green);
    --emo-sad: var(--system-cyan);
    --emo-angry: var(--system-red);
    --emo-surprise: var(--system-orange);
    --emo-fear: var(--system-purple);
    --emo-disgust: var(--system-gray);
    --emo-neutral: var(--system-gray-2);
    --emo-contempt: var(--system-pink);

    /* ── Semantic colors ── */
    --color-error: var(--system-red);
    --color-success: var(--system-green);

    /* ── Depth layer visualization ── */
    --depth-near: rgba(50, 173, 230, 0.5);
    --depth-mid: rgba(52, 199, 89, 0.3);
    --depth-far: rgba(255, 59, 48, 0.3);
}

/* ============================================================
   DARK MODE — toggled via .dark class on <html>
   ============================================================ */
:root.dark {
    --system-red: rgb(255, 69, 58);
    --system-orange: rgb(255, 159, 10);
    --system-yellow: rgb(255, 214, 10);
    --system-green: rgb(48, 209, 88);
    --system-mint: rgb(99, 230, 226);
    --system-teal: rgb(64, 200, 224);
    --system-cyan: rgb(100, 210, 255);
    --system-blue: rgb(10, 132, 255);
    --system-indigo: rgb(94, 92, 230);
    --system-purple: rgb(191, 90, 242);
    --system-pink: rgb(255, 55, 95);
    --system-brown: rgb(172, 142, 104);

    --system-gray: rgb(142, 142, 147);
    --system-gray-2: rgb(99, 99, 102);
    --system-gray-3: rgb(72, 72, 74);
    --system-gray-4: rgb(58, 58, 60);
    --system-gray-5: rgb(44, 44, 46);
    --system-gray-6: rgb(28, 28, 30);

    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --text: #f5f5f7;
    --text-dim: #8e8e93;
    --text-muted: #636366;
    --header-bg: rgba(0, 0, 0, 0.88);
    --separator: rgba(255, 255, 255, 0.06);

    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-bg-hover: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.18);

    --fill-primary: rgba(120, 120, 128, 0.36);
    --fill-secondary: rgba(120, 120, 128, 0.32);
    --fill-tertiary: rgba(118, 118, 128, 0.24);
    --fill-quaternary: rgba(118, 118, 128, 0.18);

    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
    --shadow-elevated: 0 4px 16px rgba(0, 0, 0, 0.2), 0 12px 40px rgba(0, 0, 0, 0.15);
    --shadow-bento: 0 4px 16px rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.2), 0 24px 80px rgba(0, 0, 0, 0.15);
    --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-deck: 0 8px 32px rgba(0, 0, 0, 0.5);

    --depth-near: rgba(100, 210, 255, 0.5);
    --depth-mid: rgba(48, 209, 88, 0.3);
    --depth-far: rgba(255, 69, 58, 0.3);
}

/* All experiences use the active theme (light/dark) — no forced overrides. */

/* ============================================================
   ANIMATIONS — Only functional ones
   ============================================================ */
@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes blink {
    50% { opacity: 0; }
}

/* ── Image loading transitions ──
   Two-phase loading: start invisible, fade in once fully loaded.
   .img-loading  = not yet loaded (opacity 0, !important to beat
                    any specificity on the element's resting state)
   .img-loaded   = fully decoded, fade to 1. Class is auto-removed
                    after the transition ends (in JS) so it does not
                    permanently override other transitions on the
                    same element (e.g. grid-item img hover scale). */
.img-loading {
    opacity: 0 !important;
}
.img-loaded {
    opacity: 1;
    transition: opacity var(--duration-slow) var(--ease-out-quart) !important;
}

/* Face crop canvases: same two-phase pattern */
.face-crop-loading {
    opacity: 0;
}
.face-crop-loaded {
    opacity: 1;
    transition: opacity var(--duration-slow) var(--ease-out-quart);
}

/* ===== Base ===== */
html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow-wrap: break-word;
    -webkit-text-size-adjust: 100%;
}

/* ===== Header ===== */
#header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-6);
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--separator);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Menu button */
.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast) var(--ease-out-quart);
    flex-shrink: 0;
}

.logo {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: opacity var(--duration-fast) var(--ease-out-quart);
}

/* hover: see @media (hover: hover) guard */

.logo-mad {
    font-weight: 900;
}

.logo-photos {
    font-weight: 400;
}

.header-exp-name {
    font-size: var(--text-sm);
    color: var(--text-dim);
    font-weight: 400;
}

/* Header right group */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-dim);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
    flex-shrink: 0;
}

/* hover: see @media (hover: hover) guard */

/* Show sun in dark mode, moon in light mode */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
:root.dark .theme-icon-sun { display: block; }
:root.dark .theme-icon-moon { display: none; }

/* Fullscreen toggle — same style as theme toggle */
.fullscreen-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-dim);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
    flex-shrink: 0;
}

/* Show expand icon normally, collapse in fullscreen */
.fs-icon-expand { display: block; }
.fs-icon-collapse { display: none; }
:root.is-fullscreen .fs-icon-expand { display: none; }
:root.is-fullscreen .fs-icon-collapse { display: block; }

/* Tabs */
.tabs {
    display: flex;
    gap: var(--space-0_5);
}

.tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: var(--text-sm);
    padding: var(--space-1_5) var(--space-4);
    cursor: pointer;
    border-radius: var(--radius);
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

/* hover: see @media (hover: hover) guard */

.tab.active {
    color: var(--text);
    background: var(--glass-bg-hover);
    border-color: var(--glass-border);
}

/* ===== Views ===== */
#main {
    padding: 0;
}

.view {
    display: none;
    min-height: calc(100vh - 52px);
}

.view.active {
    display: block;
    animation: fade-up 0.4s var(--ease-out-expo) both;
}

/* ===== Side Menu — Floating popover ===== */
.side-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-out-quart);
}

.side-menu-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.side-menu {
    position: fixed;
    top: var(--space-16);
    left: var(--space-5);
    z-index: 95;
    min-width: 180px;
    background: var(--header-bg);
    backdrop-filter: saturate(200%) blur(40px);
    -webkit-backdrop-filter: saturate(200%) blur(40px);
    border: 1px solid var(--glass-border-hover);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top left;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-out-expo),
                transform var(--duration-normal) var(--ease-out-expo);
}

.side-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.side-menu-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.side-menu-item {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--text-dim);
    padding: var(--space-2) var(--space-3_5);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out-quart),
                color var(--duration-fast) var(--ease-out-quart);
}

/* hover: see @media (hover: hover) guard */

.side-menu-item.active {
    color: var(--text);
    font-weight: 600;
    background: var(--glass-bg);
}

.side-menu-about {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
    border-bottom: 1px solid var(--separator);
    padding-bottom: var(--space-2);
    border-radius: var(--radius) var(--radius) 0 0;
}

/* ===== Glass Tags — Monochrome Default ===== */
.glass-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-size: var(--text-xs);
    color: var(--text-dim);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out-quart),
                border-color var(--duration-fast) var(--ease-out-quart);
    white-space: nowrap;
    user-select: none;
    text-transform: capitalize;
}

/* hover: see @media (hover: hover) guard */

.glass-tag.active {
    background: var(--fill-secondary);
    border-color: var(--glass-border-hover);
    color: var(--text);
}

/* Category tags — all monochrome */
.glass-tag.tag-vibe,
.glass-tag.tag-grading,
.glass-tag.tag-time,
.glass-tag.tag-setting,
.glass-tag.tag-scene,
.glass-tag.tag-emotion,
.glass-tag.tag-camera,
.glass-tag.tag-style {
    border-color: var(--glass-border);
    color: var(--text-dim);
}

/* category tag hover: see @media (hover: hover) guard */

.glass-tag.tag-vibe.active,
.glass-tag.tag-grading.active,
.glass-tag.tag-time.active,
.glass-tag.tag-setting.active,
.glass-tag.tag-scene.active,
.glass-tag.tag-emotion.active,
.glass-tag.tag-camera.active,
.glass-tag.tag-style.active {
    background: var(--fill-secondary);
    border-color: var(--glass-border-hover);
    color: var(--text);
}

/* Exception: tags inside Faces keep emotion colors */
.faces-container .glass-tag.tag-emotion {
    border-color: color-mix(in srgb, var(--system-pink) 35%, transparent);
    color: var(--system-pink);
}
/* hover: see @media (hover: hover) guard */

.glass-tag .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1_5);
    padding: var(--space-3) var(--space-6);
    min-height: 44px;
    border-bottom: 1px solid var(--separator);
}

.filter-bar .filter-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-right: var(--space-1);
}

.filter-bar .clear-btn {
    font-family: var(--font);
    font-size: var(--text-xs);
    color: var(--text-dim);
    background: none;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 3px var(--space-2_5);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

/* hover: see @media (hover: hover) guard */

.filter-count {
    font-size: var(--text-caption);
    color: var(--text-dim);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* ===== Sort (was La Grille) ===== */
.sort-bar {
    display: flex;
    justify-content: center;
    padding: var(--space-4) var(--space-6);
    position: sticky;
    top: 52px;
    z-index: 10;
}

.sort-bar-inner {
    display: flex;
    align-items: center;
    gap: var(--space-0_5);
    padding: var(--space-1_5) var(--space-2_5);
    background: rgba(230, 230, 230, 0.35);
    backdrop-filter: saturate(150%) blur(40px);
    -webkit-backdrop-filter: saturate(150%) blur(40px);
    border: 1px solid var(--glass-border-hover);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
}

:root.dark .sort-bar-inner {
    background: rgba(28, 28, 30, 0.6);
}

.sort-btn {
    font-family: var(--font);
    font-size: var(--text-xs);
    color: var(--text);
    opacity: 0.55;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    padding: var(--space-1_5) var(--space-3_5);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), opacity var(--transition);
    white-space: nowrap;
}

/* hover: see @media (hover: hover) guard */

.sort-btn.active {
    color: var(--text);
    opacity: 1;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

:root.dark .sort-btn.active {
    background: rgba(255, 255, 255, 0.12);
}

.sort-sep {
    width: 1px;
    height: 20px;
    background: var(--glass-border);
    margin: 0 var(--space-1);
    flex-shrink: 0;
}

.sort-size-btn {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text);
    opacity: 0.45;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition), opacity var(--transition);
}

/* hover: see @media (hover: hover) guard */

.sort-size-btn.active {
    color: var(--text);
    opacity: 1;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

:root.dark .sort-size-btn.active {
    background: rgba(255, 255, 255, 0.12);
}

.sort-grid-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-6) var(--space-20);
}

.grid-container {
    padding: var(--space-2);
}

.grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.grid-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
    flex-grow: 1;
}

.grid-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--duration-slow) var(--ease-out-expo);
}

/* hover: see @media (hover: hover) guard */

/* Overlay gradient — always dark (on images) */
.grid-item .grid-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--space-2);
    gap: var(--space-1);
    pointer-events: none;
}

/* grid-item hover overlay: in @media (hover: hover) guard. Tap fallback below. */
.grid-item.tapped .grid-overlay {
    opacity: 1;
}

.grid-item .grid-overlay .glass-tag {
    pointer-events: auto;
    /* Force light text in overlay context */
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
}

.grid-overlay-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.filter-active-section {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    align-items: center;
}

.grid-item.filtered-out {
    opacity: 0;
    width: 0 !important;
    height: 0 !important;
    margin: 0;
    padding: 0;
    overflow: hidden;
    flex-grow: 0;
    flex-shrink: 1;
    flex-basis: 0;
}

/* Row-based layout */
.grid-row {
    display: flex;
    gap: var(--space-1);
    width: 100%;
}

.grid-row .grid-item {
    flex-grow: 0;
    flex-shrink: 0;
}

/* ===== Similarity / Drift shared ===== */
.drift-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-8) var(--space-6);
    min-height: calc(100vh - 52px);
}

.drift-center {
    position: relative;
    max-width: 1000px;
    width: 100%;
    margin-bottom: var(--space-10);
}

.drift-center img {
    width: 100%;
    border-radius: var(--radius);
    display: block;
    border: 1px solid var(--separator);
}

.drift-center-meta {
    padding: var(--space-4) 0;
}

.drift-center-alt {
    font-size: var(--text-base);
    color: var(--text);
    line-height: 1.6;
    margin-bottom: var(--space-3);
    font-style: italic;
}

.drift-center-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1_5);
}

.drift-center-palette {
    display: flex;
    gap: var(--space-1);
    margin-top: var(--space-2);
}

.palette-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
}

.drift-neighbors {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    max-width: 1000px;
    width: 100%;
}

.drift-neighbor {
    position: relative;
    cursor: pointer;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    transition: border-color var(--transition), transform var(--transition);
    background: var(--bg-elevated);
}

/* hover: see @media (hover: hover) guard */

.drift-neighbor img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
}

.drift-neighbor-label {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-dim);
    text-transform: capitalize;
}

.drift-score {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--fill-primary);
    transform-origin: left;
    transform: scaleX(var(--score, 0));
    transition: transform 0.3s var(--ease-out-quart);
}
/* hover: see @media (hover: hover) guard */

.drift-controls {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
    align-items: center;
}

.drift-btn {
    font-family: var(--font);
    font-size: var(--text-caption);
    color: var(--text-dim);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: var(--space-1_5) var(--space-3_5);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

/* hover: see @media (hover: hover) guard */

.drift-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.drift-breadcrumb-item {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    transition: border-color var(--transition), transform var(--duration-fast) var(--ease-spring);
    flex-shrink: 0;
}

/* hover: see @media (hover: hover) guard */

.drift-breadcrumb-item.current {
    border-color: var(--text);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--text) 20%, transparent);
}

.drift-breadcrumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drift-breadcrumb-arrow {
    color: var(--text-muted);
    font-size: var(--text-2xs);
    flex-shrink: 0;
}

/* ===== Couleurs (Les Couleurs) — Chromatic Bento ===== */
#view-couleurs { overflow: hidden; }

.couleurs-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 52px);
    padding: var(--space-6);
    gap: var(--space-4);
}

.couleurs-spectrum {
    display: flex;
    height: 28px;
    border-radius: var(--radius-full);
    overflow: hidden;
    flex-shrink: 0;
}

.couleurs-band {
    flex: 1;
    cursor: pointer;
    transition: opacity var(--transition);
    min-width: 2px;
    opacity: 0.4;
}

/* hover: see @media (hover: hover) guard */

.couleurs-band.active {
    opacity: 1;
    flex: 3;
}

.couleurs-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-bento);
    min-height: 0;
}

.couleurs-row {
    display: flex;
    gap: 3px;
    flex: 1;
    min-height: 0;
}

.couleurs-tile {
    flex: 1;
    overflow: hidden;
    cursor: pointer;
    min-width: 0;
    min-height: 0;
}

.couleurs-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== Bento (Le Bento) — Irregular mosaic grid ===== */
.bento-view {
    overflow: hidden;
}

.bento-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 52px);
    padding: var(--space-16);
    position: relative;
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(var(--bento-cols, 4), 1fr);
    grid-template-rows: repeat(var(--bento-rows, 3), 1fr);
    gap: 4px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-bento);
    height: calc(100vh - 180px);
    max-width: calc(100vw - 160px);
}

.bento-tile {
    overflow: hidden;
    cursor: pointer;
    transition: opacity 800ms ease;
    min-width: 0;
    min-height: 0;
}

.bento-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Navigation arrows — left/right of grid */
.bento-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    z-index: 10;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--duration-fast) var(--ease-spring);
}

/* hover: see @media (hover: hover) guard */

.bento-nav-prev { left: var(--space-5); }
.bento-nav-next { right: var(--space-5); }

/* hover: see @media (hover: hover) guard */

.bento-regen {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background var(--transition), border-color var(--transition), transform var(--duration-fast) var(--ease-spring);
}

/* hover: see @media (hover: hover) guard */

/* ===== Shared: game-title, game-desc, game-start-btn ===== */
.game-title {
    font-family: var(--font-display);
    font-size: var(--text-4xl);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-3);
}

.game-desc {
    font-size: var(--text-sm);
    color: var(--text-dim);
    margin-bottom: var(--space-8);
}

.game-start-btn {
    font-family: var(--font);
    font-size: var(--text-base);
    color: var(--text);
    background: var(--glass-bg-hover);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-8);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

/* hover: see @media (hover: hover) guard */

.game-end {
    padding: var(--space-12) 0;
    text-align: center;
}

.game-final-score {
    font-family: var(--font-display);
    font-size: var(--text-6xl);
    font-weight: 700;
    margin-bottom: var(--space-1);
    letter-spacing: -0.04em;
}

.game-final-label {
    font-size: var(--text-base);
    color: var(--text-dim);
    margin-bottom: var(--space-6);
}

/* ===== Le Jeu — Viewport-fixed image pairs ===== */
#view-game { overflow: hidden; }

.jeu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 52px);
    padding: var(--space-6);
    gap: 0;
    position: relative;
}

.jeu-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    max-width: 100%;
    max-height: calc(100vh - 140px);
    min-height: 0;
    flex: 1;
    align-content: center;
    transition: opacity 300ms var(--ease-out-quart), transform 300ms var(--ease-out-quart);
}

.jeu-pair-exit {
    opacity: 0;
    transform: scale(0.97);
}

.jeu-pair-enter {
    opacity: 0;
    transform: scale(0.97);
}

.jeu-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 0;
}

.jeu-img {
    width: 100%;
    height: 100%;
    aspect-ratio: 3/2;
    object-fit: cover;
    display: block;
}

/* Fixed glass bar at bottom */
.jeu-bar {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-5);
    padding: var(--space-2_5) var(--space-5);
    background: rgba(120, 120, 128, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    z-index: 10;
}

.jeu-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    transition: transform var(--duration-fast) var(--ease-spring);
}

/* hover: see @media (hover: hover) guard */

.jeu-btn:active {
    transform: scale(0.9);
}

/* ===== Faces (Les Visages) — Viewport-fixed with elevated container ===== */
#view-faces { overflow: hidden; }

.faces-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 52px);
    padding: var(--space-5);
    gap: var(--space-4);
}

.faces-filter-bar {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.faces-filter-btn {
    font-family: var(--font);
    font-size: var(--text-sm);
    color: var(--text-dim);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: var(--space-1_5) var(--space-4_5);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-1_5);
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

/* hover: see @media (hover: hover) guard */

.faces-filter-btn.active {
    color: var(--text);
    background: var(--fill-secondary);
    border-color: var(--glass-border-hover);
}

.faces-filter-count {
    font-size: var(--text-2xs);
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.faces-card {
    flex: 1;
    min-height: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 2px;
    padding: var(--space-3);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-elevated);
}

.face-card {
    width: var(--face-size, 80px);
    height: var(--face-size, 80px);
    border-radius: var(--radius-xs);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: transform var(--duration-fast) var(--ease-spring), border-color var(--transition);
}

/* hover: see @media (hover: hover) guard */

.face-crop-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ===== Compass (La Boussole) — CSS Grid cross layout ===== */
#view-compass {
    overflow: hidden;
}

.compass-grid {
    display: grid;
    grid-template-areas:
        ".     north  ."
        "west  center east"
        ".     south  .";
    grid-template-columns: 1fr 5fr 1fr;
    grid-template-rows: 1fr 5fr 1fr;
    gap: 2px;
    height: calc(100vh - 52px);
    padding: 0;
    background: var(--bg);
}

/* Arms — shared */
.compass-arm {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-radius: 0;
    opacity: 0;
}

/* Direction-specific enter transforms */
.compass-north { transform: translateY(-20px); }
.compass-south { transform: translateY(20px); }
.compass-east  { transform: translateX(20px); }
.compass-west  { transform: translateX(-20px); }

.compass-arm.compass-arm-enter {
    opacity: 1;
    transform: translate(0, 0);
    transition: opacity 400ms var(--ease-out-quart), transform 400ms var(--ease-out-expo);
}

.compass-arm-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.35;
    transition: opacity var(--duration-normal) var(--ease-out-quart);
}

.compass-arm-img.img-loaded {
    opacity: 0.35;
}

/* hover: see @media (hover: hover) guard */

.compass-arm-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    pointer-events: none;
}

.compass-arm-label {
    font-size: var(--text-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.6);
}

.compass-arm-trait {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.compass-arm-empty {
    background: var(--bg-elevated);
}

/* Center hero image */
.compass-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 0;
}

.compass-center-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
}

/* Random button */
.compass-random {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    font-family: var(--font);
    font-size: var(--text-caption);
    color: var(--text-dim);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: var(--space-1_5) var(--space-3_5);
    cursor: pointer;
    z-index: 10;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

/* hover: see @media (hover: hover) guard */

/* ===== Observatory (L'Observatoire) ===== */
.observatory-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: var(--space-4);
    padding: var(--space-6);
}

.obs-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: var(--space-5);
}

.obs-panel-title {
    font-size: var(--text-caption);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: var(--space-4);
    font-weight: 600;
}

.obs-panel-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-1_5);
}

.obs-bar-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-caption);
}

.obs-bar-label {
    color: var(--text);
    min-width: 100px;
    font-size: var(--text-caption);
}

.obs-bar {
    height: 8px;
    background: var(--fill-quaternary);
    border-radius: 4px;
    flex: 1;
    max-width: 200px;
}

/* Neutral fill instead of purple tint */
.obs-bar-style { background: var(--fill-tertiary); }

.obs-bar-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    min-width: 30px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.obs-histogram {
    display: flex;
    align-items: flex-end;
    gap: var(--space-0_5);
    height: 100px;
}

.obs-hist-bar {
    flex: 1;
    background: var(--fill-tertiary);
    border-radius: 2px 2px 0 0;
    min-height: 1px;
    transition: background var(--transition);
}

/* hover: see @media (hover: hover) guard */

.obs-inline-count {
    font-size: var(--text-2xs);
    color: var(--text-muted);
    margin-left: var(--space-0_5);
}

.obs-outlier-row {
    display: flex;
    align-items: center;
    gap: var(--space-2_5);
    padding: var(--space-1_5) 0;
}

.obs-outlier-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.obs-outlier-label {
    font-size: var(--text-caption);
    color: var(--text-dim);
}

/* ===== Map (La Carte) ===== */
.map-container {
    padding: var(--space-6);
}

.map-header {
    font-size: var(--text-sm);
    color: var(--text-dim);
    margin-bottom: var(--space-4);
}

.map-canvas {
    width: 100%;
    max-width: 1200px;
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    cursor: crosshair;
}

.map-strip {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-4);
    overflow-x: auto;
    padding-bottom: var(--space-2);
}

.map-strip-card {
    flex-shrink: 0;
    width: 180px;
    height: 120px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: border-color var(--transition), transform var(--transition);
}

/* hover: see @media (hover: hover) guard */

.map-strip-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* ===== NYU — Multi-view experience ===== */
#view-nyu { overflow: hidden; }

.nyu-shell {
    position: relative;
    height: calc(100vh - 52px);
    overflow: hidden;
}

.nyu-viewport {
    height: 100%;
    overflow: hidden;
}

/* Nav bar — floating glass pill at bottom */
.nyu-nav {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: rgba(230, 230, 230, 0.35);
    backdrop-filter: saturate(150%) blur(40px);
    -webkit-backdrop-filter: saturate(150%) blur(40px);
    border: 1px solid var(--glass-border-hover);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-float);
    z-index: 50;
}

:root.dark .nyu-nav {
    background: rgba(28, 28, 30, 0.6);
}

.nyu-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.55;
    transition: opacity var(--transition), background var(--transition);
    position: relative;
}

/* hover: see @media (hover: hover) guard */

.nyu-nav-btn.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

.nyu-nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text);
}

:root.dark .nyu-nav-btn.active {
    background: rgba(255, 255, 255, 0.15);
}

/* Counter */
.nyu-counter {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    text-align: center;
    padding: var(--space-4) 0;
}

/* ===== Reel ===== */
.nyu-reel {
    display: flex;
    align-items: center;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    gap: var(--space-8);
    padding: 0 max(var(--space-6), calc(50vw - 250px));
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.nyu-reel::-webkit-scrollbar { display: none; }
.nyu-reel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--duration-fast) var(--ease-spring);
}
.nyu-reel-prev { left: var(--space-5); }
.nyu-reel-next { right: var(--space-5); }
.nyu-reel-counter { position: absolute; bottom: var(--space-6); left: 50%; transform: translateX(-50%); }

.nyu-reel-item {
    scroll-snap-align: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.nyu-reel-item img {
    max-height: 80vh;
    max-width: min(600px, 85vw);
    object-fit: contain;
    display: block;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-deck);
}

/* ===== Grid ===== */
.nyu-vp-grid { overflow-y: auto; }

.nyu-grid {
    padding: var(--space-1);
    padding-bottom: 100px;
}

.nyu-grid-row {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-1);
}

.nyu-grid-row[data-type="hero"] .nyu-grid-cell { height: 55vh; }
.nyu-grid-row[data-type="pair"] .nyu-grid-cell { height: 38vh; }
.nyu-grid-row[data-type="triplet"] .nyu-grid-cell { height: 28vh; }

.nyu-grid-cell {
    flex: 1;
    overflow: hidden;
    border-radius: var(--radius-sm);
    cursor: pointer;
    min-width: 0;
}

.nyu-grid-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--duration-slow) var(--ease-out-expo);
}

/* hover: see @media (hover: hover) guard */

/* ===== Deck ===== */
.nyu-vp-deck {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.nyu-accent {
    position: absolute;
    inset: 0;
    pointer-events: none;
    transition: background 800ms var(--ease-out-quart);
}

.nyu-stack {
    position: relative;
    width: min(85vw, 700px);
    aspect-ratio: 3/2;
    cursor: pointer;
}

.nyu-card {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-xl);
    overflow: hidden;
    transform-origin: center bottom;
    transform:
        translateY(calc(var(--card-index) * -14px))
        scale(calc(1 - var(--card-index) * 0.05));
    opacity: calc(1 - var(--card-index) * 0.15);
    transition: transform 400ms var(--ease-spring),
                opacity 400ms var(--ease-out-quart);
    box-shadow: var(--shadow-deck);
}

.nyu-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.nyu-card-exit {
    transform: translateX(120%) rotate(8deg) !important;
    opacity: 0 !important;
    transition: transform 350ms var(--ease-out-expo),
                opacity 300ms var(--ease-out-quart) !important;
}

.nyu-card-exit-left {
    transform: translateX(-120%) rotate(-8deg) !important;
    opacity: 0 !important;
    transition: transform 350ms var(--ease-out-expo),
                opacity 300ms var(--ease-out-quart) !important;
}

/* ===== Canvas ===== */
.nyu-canvas {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 1s var(--ease-out-quart);
    padding: var(--space-10);
}

.nyu-canvas-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    width: 100%;
}

.nyu-canvas-img {
    max-width: 90%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-deck);
    cursor: pointer;
    transition: transform var(--duration-fast) var(--ease-spring);
}

/* hover: see @media (hover: hover) guard */

.nyu-canvas-counter { color: var(--text-dim); }

/* ===== Overview — Assembled mosaic ===== */
.nyu-vp-overview {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.nyu-mosaic {
    display: grid;
    grid-template-columns: repeat(var(--m-cols), 1fr);
    grid-template-rows: repeat(var(--m-rows), 1fr);
    width: min(78vh, 78vw);
    height: min(78vh, 78vw);
    gap: 1px;
}

.nyu-mosaic.assembled {
    animation: mosaic-settle 2.4s var(--ease-out-quart) 1.6s both;
}

@keyframes mosaic-settle {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.006); }
    100% { transform: scale(1); }
}

.nyu-mosaic-cell {
    overflow: hidden;
    cursor: pointer;
    contain: layout style paint;
    transform: translate(var(--sx), var(--sy)) rotate(var(--sr)) scale(0);
    opacity: 0;
    transition: transform 1.2s var(--ease-spring),
                opacity 0.6s var(--ease-out-quart);
    transition-delay: var(--d);
    will-change: transform, opacity;
}

.nyu-mosaic.assembled .nyu-mosaic-cell {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
}

.nyu-mosaic-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--duration-normal) var(--ease-spring),
                opacity var(--duration-normal) var(--ease-out-quart);
}

/* hover: see @media (hover: hover) guard */

/* ===== Confetti — Vertical nav + viewport mosaic ===== */
#view-confetti {
    height: calc(100vh - 52px);
    overflow: hidden;
}

/* Shell: full viewport */
.confetti-shell {
    display: flex;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Mosaic wrapper */
.confetti-mosaic-wrap {
    position: relative;
}

/* ===== Confetti Radial Dial ===== */
.confetti-dial {
    position: absolute;
    left: var(--space-5);
    top: 50%;
    translate: 0 -50%;
    width: 160px;
    height: 160px;
    z-index: 20;
    pointer-events: none;
}

/* Bomb — center of the dial */
.confetti-bomb {
    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: transform var(--duration-normal) var(--ease-spring);
    z-index: 2;
    pointer-events: auto;
}

.confetti-bomb:active {
    transform: scale(0.92);
}

/* Orbiting emoji buttons */
.confetti-dial-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.45;
    transition: opacity var(--transition), background var(--transition);
    transform: rotate(var(--dial-angle)) translateX(66px) rotate(calc(-1 * var(--dial-angle)));
    pointer-events: auto;
}

.confetti-dial-btn.active {
    opacity: 1;
    background: var(--fill-secondary);
    box-shadow: var(--shadow-sm);
}

/* Viewport: flex center for mosaic */
.confetti-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
}

/* Label at bottom center */
.confetti-label {
    position: absolute;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    pointer-events: none;
}

/* ===== Confetti Mosaic ===== */
.confetti-mosaic {
    display: grid;
    grid-template-columns: repeat(var(--m-cols), 1fr);
    grid-template-rows: repeat(var(--m-rows), 1fr);
    width: min(75vh, 75vw);
    height: min(75vh, 75vw);
    gap: 2px;
    cursor: pointer;
}

/* Settle pulse after assembly */
.confetti-mosaic.assembled {
    animation: confetti-settle 2s var(--ease-out-quart) 1.4s both;
}

@keyframes confetti-settle {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.008); }
    100% { transform: scale(1); }
}

/* Cell: scattered state (default) */
.confetti-cell {
    position: relative;
    overflow: hidden;
    contain: layout style paint;
    transform: translate(var(--sx), var(--sy)) rotate(var(--sr)) scale(0);
    opacity: 0;
    transition: transform 1.2s var(--ease-spring),
                opacity 0.6s var(--ease-out-quart);
    transition-delay: var(--d);
    will-change: transform, opacity;
}

/* Cell: assembled state */
.confetti-mosaic.assembled .confetti-cell {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
}

/* Cell: scattering out (fast burst) */
.confetti-mosaic.scattering .confetti-cell {
    transform: translate(var(--sx), var(--sy)) rotate(var(--sr)) scale(0);
    opacity: 0;
    transition: transform 0.45s var(--ease-out-expo),
                opacity 0.3s var(--ease-out-quart);
    transition-delay: var(--d-out);
}

.confetti-cell {
    border-radius: 3px;
}

.confetti-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--duration-normal) var(--ease-spring);
}

/* Soft gradient overlay — disappears on hover to reveal */
.confetti-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0.04) 40%, rgba(0,0,0,0.18) 100%);
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-out-quart);
    border-radius: 3px;
}

/* hover: see @media (hover: hover) guard */

/* Cell: floating state (blow — lift to nearby random spot) */
.confetti-mosaic.floating .confetti-cell {
    transform: translate(var(--fx), var(--fy)) rotate(var(--fr));
    opacity: 0.85;
    transition: transform 0.5s var(--ease-out-expo),
                opacity 0.3s var(--ease-out-quart);
    transition-delay: var(--fd);
}

/* ===== Confetti Glass Preview ===== */
.confetti-preview {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s var(--ease-out-quart);
    pointer-events: none;
}

.confetti-preview.open {
    opacity: 1;
    pointer-events: auto;
}

.confetti-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: saturate(180%) blur(30px);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
}

.confetti-preview-img {
    position: relative;
    max-width: 85vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.92);
    transition: transform 0.4s var(--ease-out-expo);
}

.confetti-preview.open .confetti-preview-img {
    transform: scale(1);
}

/* ===== Square — Scrabble-board tile grid ===== */
#view-square {
    overflow: hidden;
}

.square-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    padding: var(--space-6);
    position: relative;
    gap: var(--space-4);
}

.square-score {
    font-family: var(--font-mono);
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    text-align: center;
}

.square-board {
    display: grid;
    grid-template-columns: repeat(var(--sq-cols, 5), 1fr);
    gap: 3px;
    width: min(70vh, 70vw);
    height: min(70vh, 70vw);
    background: repeating-linear-gradient(
        0deg,
        var(--separator) 0px,
        var(--separator) 1px,
        transparent 1px,
        transparent 60px
    ),
    repeating-linear-gradient(
        90deg,
        var(--separator) 0px,
        var(--separator) 1px,
        transparent 1px,
        transparent 60px
    );
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.square-tile {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xs);
    cursor: pointer;
    aspect-ratio: 1;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.5s var(--ease-spring), opacity 0.4s var(--ease-out-quart);
    transition-delay: var(--sq-delay, 0ms);
    box-shadow: var(--shadow-sm);
}

.square-board.assembled .square-tile {
    transform: scale(1);
    opacity: 1;
}

.square-board.shaking .square-tile {
    transform: translate(var(--shake-x, 0), var(--shake-y, 0)) rotate(var(--shake-r, 0));
    transition: transform 0.15s ease;
}

.square-tile-premium {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--system-yellow) 40%, transparent);
}

.square-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.square-badge {
    position: absolute;
    bottom: var(--space-0_5);
    right: var(--space-0_5);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.5);
    padding: 1px 4px;
    border-radius: var(--radius-xs);
    line-height: 1.2;
}

.square-shake {
    position: absolute;
    bottom: var(--space-6);
    right: var(--space-6);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform var(--duration-fast) var(--ease-spring), background var(--transition), border-color var(--transition);
}

.square-rack {
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    padding: var(--space-1) var(--space-2);
    max-width: 100%;
    flex-shrink: 0;
}

.square-rack::-webkit-scrollbar { display: none; }

.square-pill {
    font-family: var(--font);
    font-size: var(--text-xs);
    color: var(--text-dim);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-3);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.square-pill.active {
    color: var(--text);
    background: var(--fill-secondary);
    border-color: var(--glass-border-hover);
}

/* ===== Caption — Typographic tapestry ===== */
#view-caption {
    overflow-y: auto;
    overflow-x: hidden;
}

.caption-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-12) var(--space-8);
    min-height: calc(100vh - 52px);
}

.caption-wall {
    font-family: var(--font-display);
    line-height: 2.2;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    letter-spacing: -0.01em;
    cursor: default;
}

/* Each caption phrase — inline, flows as continuous text.
   JS sets inline style.opacity for the resting-state brightness (0.3–1.0).
   Before reveal: forced invisible via !important.
   After reveal: the !important is removed so inline opacity takes over. */
.caption-phrase {
    display: inline;
    cursor: pointer;
    color: var(--text);
    transition: opacity var(--duration-normal) var(--ease-out-quart),
                color var(--duration-fast) var(--ease-out-quart);
}

/* Pre-reveal: everything hidden */
.caption-wall:not(.revealed) .caption-phrase {
    opacity: 0 !important;
}

/* Size tiers based on aesthetic score */
.caption-phrase[data-tier="0"] { font-size: var(--text-xs); font-weight: 300; letter-spacing: 0.02em; }
.caption-phrase[data-tier="1"] { font-size: var(--text-sm); font-weight: 400; }
.caption-phrase[data-tier="2"] { font-size: var(--text-base); font-weight: 400; }
.caption-phrase[data-tier="3"] { font-size: var(--text-lg); font-weight: 500; letter-spacing: -0.01em; }
.caption-phrase[data-tier="4"] { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; font-style: italic; }

/* Revealed state — staggered fade-in from JS inline opacity */
.caption-wall.revealed .caption-phrase {
    transition: opacity 0.8s var(--ease-out-quart);
    transition-delay: var(--caption-delay, 0ms);
}

/* Separator dots — very muted */
.caption-sep {
    color: var(--text-muted);
    font-size: var(--text-xs);
    opacity: 0.3;
    user-select: none;
}

/* Hover: the hovered phrase brightens, all siblings dim dramatically */
.caption-wall.revealed:hover .caption-phrase {
    opacity: 0.12 !important;
    transition: opacity var(--duration-normal) var(--ease-out-quart);
    transition-delay: 0ms;
}

.caption-wall.revealed:hover .caption-phrase:hover,
.caption-wall.revealed .caption-phrase.caption-touched {
    opacity: 1 !important;
    color: var(--text);
}

/* On hover, also dim the separators */
.caption-wall.revealed:hover .caption-sep {
    opacity: 0.06;
}

/* ── Floating Preview ── */
.caption-preview {
    position: fixed;
    z-index: 150;
    width: 180px;
    height: 130px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-float);
    opacity: 0;
    transform: scale(0.85) translateY(8px);
    transition: opacity var(--duration-normal) var(--ease-out-quart),
                transform var(--duration-normal) var(--ease-out-expo);
    pointer-events: none;
    border: 1px solid var(--glass-border-hover);
}

.caption-preview.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.caption-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ===== Cinema — Full-screen Ken Burns slideshow ===== */
#view-cinema {
    overflow: hidden;
    padding: 0;
}

.cinema-shell {
    position: relative;
    width: 100%;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    background: #000;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.cinema-layer {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1.5s var(--ease-out-quart);
    z-index: 0;
}

.cinema-layer.active {
    opacity: 1;
    z-index: 1;
}

.cinema-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Ken Burns drift animations — 6 variations */
@keyframes kb-1 { from { transform: scale(1.0) translate(0, 0); } to { transform: scale(1.15) translate(-2%, -1%); } }
@keyframes kb-2 { from { transform: scale(1.05) translate(-1%, 0); } to { transform: scale(1.18) translate(2%, -2%); } }
@keyframes kb-3 { from { transform: scale(1.1) translate(1%, 1%); } to { transform: scale(1.0) translate(-1%, 0); } }
@keyframes kb-4 { from { transform: scale(1.0) translate(0, 1%); } to { transform: scale(1.12) translate(1%, -1%); } }
@keyframes kb-5 { from { transform: scale(1.15) translate(-2%, -1%); } to { transform: scale(1.02) translate(1%, 1%); } }
@keyframes kb-6 { from { transform: scale(1.08) translate(2%, 0); } to { transform: scale(1.0) translate(-2%, -1%); } }

.cinema-layer.kb-1 .cinema-img { animation: kb-1 8s var(--ease-out-quart) both; }
.cinema-layer.kb-2 .cinema-img { animation: kb-2 8s var(--ease-out-quart) both; }
.cinema-layer.kb-3 .cinema-img { animation: kb-3 8s var(--ease-out-quart) both; }
.cinema-layer.kb-4 .cinema-img { animation: kb-4 8s var(--ease-out-quart) both; }
.cinema-layer.kb-5 .cinema-img { animation: kb-5 8s var(--ease-out-quart) both; }
.cinema-layer.kb-6 .cinema-img { animation: kb-6 8s var(--ease-out-quart) both; }

/* Chapter title card */
.cinema-chapter {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    font-family: var(--font-display);
    font-size: clamp(24px, 5vw, 56px);
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 40px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.8s var(--ease-out-quart);
    pointer-events: none;
    white-space: nowrap;
}

.cinema-chapter.visible {
    opacity: 1;
}

/* Progress bar — thin line at bottom */
.cinema-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 10;
}

.cinema-progress-fill {
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.4);
}

/* Counter — bottom right */
.cinema-counter {
    position: absolute;
    bottom: var(--space-4);
    right: var(--space-5);
    z-index: 10;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.05em;
    pointer-events: none;
}

/* Pause flash indicator */
.cinema-pause {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    z-index: 10;
    font-size: 32px;
    color: rgba(255, 255, 255, 0.8);
    opacity: 0;
    pointer-events: none;
    transition: none;
}

@keyframes cinema-flash {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

.cinema-pause.flash {
    animation: cinema-flash 0.6s var(--ease-out-quart) forwards;
}

/* ===== Reveal — Clip-path morphing transitions ===== */
#view-reveal {
    overflow: hidden;
    padding: 0;
}

.reveal-shell {
    position: relative;
    width: 100%;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    background: #000;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.reveal-layer {
    position: absolute;
    inset: 0;
}

.reveal-current {
    z-index: 1;
}

.reveal-incoming {
    z-index: 2;
    will-change: clip-path;
}

.reveal-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Set label — top center */
.reveal-label {
    position: absolute;
    top: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-family: var(--font-display);
    font-size: var(--text-sm);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.5s var(--ease-out-quart);
}

@keyframes reveal-flash {
    0% { opacity: 0; transform: translateX(-50%) translateY(4px); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-4px); }
}

.reveal-label.flash {
    animation: reveal-flash 2.5s var(--ease-out-quart) forwards;
}

.reveal-label-shape {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

.reveal-label-sep {
    opacity: 0.4;
}

.reveal-label-theme {
    font-weight: 300;
    font-style: italic;
}

/* Counter — bottom right */
.reveal-counter {
    position: absolute;
    bottom: var(--space-4);
    right: var(--space-5);
    z-index: 10;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.05em;
    pointer-events: none;
}

/* Hint — bottom center, fades out */
.reveal-hint {
    position: absolute;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-family: var(--font-display);
    font-size: var(--text-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    transition: opacity 1s var(--ease-out-quart);
    pointer-events: none;
}

.reveal-hint.faded {
    opacity: 0;
}

/* ===== Pulse — Breathing mosaic grid ===== */
#view-pulse {
    overflow: hidden;
    padding: 0;
}

.pulse-shell {
    position: relative;
    width: 100%;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    overflow: hidden;
    cursor: crosshair;
}

.pulse-grid {
    display: grid;
    grid-template-columns: repeat(var(--pulse-cols, 10), 1fr);
    width: min(70vh, 70vw);
    height: min(70vh, 70vw);
    gap: 2px;
}

.pulse-cell {
    overflow: hidden;
    border-radius: 3px;
    will-change: transform, opacity;
    opacity: 0;
    transform: scale(0.6);
    cursor: pointer;
}

.pulse-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* Stagger reveal from center outward */
.pulse-grid.revealed .pulse-cell {
    opacity: 1;
    transform: scale(1);
    transition: transform 0.5s var(--ease-out-expo),
                opacity 0.5s var(--ease-out-quart);
    transition-delay: var(--pulse-delay, 0ms);
}

/* Category pills at bottom */
.pulse-rack {
    position: absolute;
    bottom: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-1_5);
    padding: var(--space-1_5);
    overflow-x: auto;
    max-width: 90vw;
    scrollbar-width: none;
    -ms-overflow-style: none;
    z-index: 10;
}

.pulse-rack::-webkit-scrollbar { display: none; }

.pulse-pill {
    flex-shrink: 0;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out-quart),
                border-color var(--duration-fast) var(--ease-out-quart),
                color var(--duration-fast) var(--ease-out-quart);
    white-space: nowrap;
}

.pulse-pill.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

/* ===== Drift — Visual similarity explorer ===== */
#view-drift {
    overflow: hidden;
    padding: 0;
}

.drift-shell {
    position: relative;
    width: 100%;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    overflow: hidden;
}

/* Center hero image */
.drift-center-wrap {
    position: relative;
    width: min(50vh, 50vw);
    height: min(50vh, 50vw);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-float);
    z-index: 2;
    cursor: pointer;
}

.drift-hero {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.5s var(--ease-out-quart),
                transform 0.5s var(--ease-out-quart);
}

.drift-hero-entering {
    opacity: 0;
    transform: scale(1.05);
}

.drift-hero-exiting {
    opacity: 0;
    transform: scale(0.95);
}

/* Neighbor cards ring */
.drift-ring {
    position: absolute;
    inset: 0;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-5);
    z-index: 1;
    pointer-events: none;
}

.drift-card {
    width: 120px;
    height: 90px;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--glass-border);
    opacity: 0;
    transform: scale(0.8) translateY(12px);
    transition: opacity 0.4s var(--ease-out-quart),
                transform 0.4s var(--ease-out-expo),
                border-color var(--duration-fast) var(--ease-out-quart);
    transition-delay: var(--drift-delay, 0ms);
    pointer-events: auto;
    animation: drift-card-in 0.5s var(--ease-out-expo) forwards;
    animation-delay: var(--drift-delay, 0ms);
}

@keyframes drift-card-in {
    from { opacity: 0; transform: scale(0.8) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.drift-card-exit {
    opacity: 0 !important;
    transform: scale(0.7) !important;
    transition-delay: 0ms !important;
    pointer-events: none !important;
}

.drift-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.drift-card-score {
    position: absolute;
    bottom: var(--space-1);
    right: var(--space-1);
    font-family: var(--font-mono);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.5);
    padding: 1px 4px;
    border-radius: 3px;
    pointer-events: none;
}

/* Breadcrumb trail — bottom center */
.drift-trail {
    position: absolute;
    bottom: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-1_5);
    z-index: 10;
    max-width: 90vw;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.drift-trail::-webkit-scrollbar { display: none; }

.drift-trail-dot {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--glass-border);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--duration-fast) var(--ease-out-quart),
                border-color var(--duration-fast) var(--ease-out-quart);
}

.drift-trail-dot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.drift-trail-current {
    opacity: 1;
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text);
}

/* Random button — top right */
.drift-random {
    position: absolute;
    top: var(--space-5);
    right: var(--space-5);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--duration-fast) var(--ease-out-quart),
                background var(--duration-fast) var(--ease-out-quart);
}

/* Score label — top center */
.drift-score-label {
    position: absolute;
    top: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-family: var(--font-display);
    font-size: var(--text-xs);
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.5s var(--ease-out-quart);
    pointer-events: none;
    white-space: nowrap;
}

@keyframes drift-label-flash {
    0% { opacity: 0; }
    20% { opacity: 1; }
    100% { opacity: 0.6; }
}

.drift-score-label.flash {
    animation: drift-label-flash 2s var(--ease-out-quart) forwards;
}

/* ===== Lightbox — Always dark overlay ===== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity var(--duration-normal) var(--ease-out-quart);
}

.lightbox.hidden {
    opacity: 0;
    pointer-events: none;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(1) translateY(0);
    transition: transform var(--duration-slow) var(--ease-out-expo),
                opacity var(--duration-normal) var(--ease-out-quart);
}

.lightbox.hidden .lightbox-content {
    transform: scale(0.95) translateY(12px);
    opacity: 0;
}

/* Lightbox navigation arrows */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 56px;
    font-weight: 200;
    cursor: pointer;
    padding: var(--space-5);
    transition: color var(--duration-fast) var(--ease-out-quart);
    font-family: var(--font);
    line-height: 1;
}

.lightbox-prev { left: 0; }
.lightbox-next { right: 0; }
.lightbox-nav[hidden] { display: none; }

.lightbox-close {
    position: absolute;
    top: -44px;
    right: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    cursor: pointer;
    font-family: var(--font);
    transition: color var(--transition);
}

/* hover: see @media (hover: hover) guard */

.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
}

.lightbox-meta {
    display: none;
}

.lightbox-alt {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
    margin-bottom: var(--space-2_5);
    line-height: 1.6;
}

.lightbox-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-1_5);
    margin-bottom: var(--space-2);
}

/* Force light text in lightbox (always dark backdrop) */
.lightbox-tags .glass-tag {
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
}

.lightbox-palette {
    display: flex;
    justify-content: center;
    gap: var(--space-1_5);
}

.lightbox-palette .palette-dot {
    border-color: rgba(255, 255, 255, 0.15);
}

/* ===== Loading — simple text indicator ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    height: calc(100vh - 52px);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-family: var(--font-display);
}

.loading.error {
    color: var(--color-error);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--fill-tertiary);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--fill-primary);
}

/* ===== Utility: Clickable Images ===== */
.clickable-img { cursor: pointer; }

/* ===== Utility: Color Swatch (small inline dot) ===== */
.color-swatch-sm {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: var(--space-2);
    vertical-align: middle;
}

/* ===== Utility: Empty State ===== */
.empty-state {
    padding: var(--space-10);
    color: var(--text-muted);
    text-align: center;
}

/* ===== Hover Guard — only apply hover effects on devices with pointer ===== */
@media (hover: hover) and (pointer: fine) {
    .logo:hover { opacity: 0.6; }
    .fullscreen-toggle:hover { color: var(--text); border-color: var(--glass-border-hover); }
    .theme-toggle:hover { color: var(--text); border-color: var(--glass-border-hover); }
    .tab:hover { color: var(--text); background: var(--glass-bg); }
    .side-menu-item:hover { color: var(--text); background: var(--glass-bg-hover); }
    .glass-tag:hover { background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .glass-tag.tag-vibe:hover, .glass-tag.tag-grading:hover, .glass-tag.tag-time:hover,
    .glass-tag.tag-setting:hover, .glass-tag.tag-scene:hover, .glass-tag.tag-emotion:hover,
    .glass-tag.tag-camera:hover, .glass-tag.tag-style:hover { border-color: var(--glass-border-hover); }
    .faces-container .glass-tag.tag-emotion:hover { border-color: color-mix(in srgb, var(--system-pink) 60%, transparent); }
    .filter-bar .clear-btn:hover { color: var(--text); border-color: var(--glass-border-hover); background: var(--glass-bg); }
    .sort-btn:hover { opacity: 0.85; background: var(--glass-bg); }
    .sort-size-btn:hover { opacity: 0.85; background: var(--glass-bg); }
    .grid-item:hover img { transform: scale(1.03); }
    .grid-item:hover .grid-overlay { opacity: 1; }
    .drift-neighbor:hover { border-color: var(--glass-border-hover); transform: translateY(-3px); box-shadow: var(--shadow-sm); }
    .drift-neighbor:hover .drift-score { background: var(--text); }
    .drift-btn:hover { color: var(--text); background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .drift-breadcrumb-item:hover { border-color: var(--glass-border-hover); transform: scale(1.15); }
    .couleurs-band:hover { opacity: 0.75; flex: 2; }
    .bento-nav:hover { color: var(--text); background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .bento-nav-prev:hover { transform: translateY(-50%) scale(1.1); }
    .bento-nav-next:hover { transform: translateY(-50%) scale(1.1); }
    .bento-regen:hover { background: var(--glass-bg-hover); border-color: var(--glass-border-hover); transform: scale(1.1); }
    .game-start-btn:hover { background: var(--fill-primary); border-color: var(--glass-border-hover); }
    .jeu-btn:hover { transform: scale(1.25); }
    .faces-filter-btn:hover { color: var(--text); background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .face-card:hover { transform: scale(1.12); z-index: 2; box-shadow: var(--shadow-sm); }
    .compass-arm:hover .compass-arm-img, .compass-arm:hover .compass-arm-img.img-loaded { opacity: 0.7; }
    .compass-random:hover { color: var(--text); background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .obs-hist-bar:hover { background: var(--fill-primary); }
    .map-strip-card:hover { border-color: var(--glass-border-hover); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
    .nyu-nav-btn:hover { opacity: 1; }
    .nyu-reel-nav:hover { color: var(--text); background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .nyu-reel-prev:hover { transform: translateY(-50%) scale(1.1); }
    .nyu-reel-next:hover { transform: translateY(-50%) scale(1.1); }
    .nyu-grid-cell:hover img { transform: scale(1.03); }
    .nyu-canvas-img:hover { transform: scale(1.01); }
    .nyu-mosaic-cell:hover img { transform: scale(1.25); opacity: 1; }
    .square-shake:hover { transform: scale(1.1); background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .square-pill:hover { color: var(--text); background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .caption-phrase:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
    .confetti-bomb:hover { transform: scale(1.08); box-shadow: var(--shadow-lg); }
    .confetti-dial-btn:hover { opacity: 0.85; }
    .confetti-cell:hover::after { opacity: 0; }
    .confetti-cell:hover img { transform: scale(1.3); }
    .pulse-pill:hover { color: var(--text); background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .pulse-cell:hover { border-radius: 5px; }
    .drift-card:hover { transform: scale(1.08) translateY(-4px); border-color: var(--glass-border-hover); box-shadow: var(--shadow-sm); }
    .drift-trail-dot:hover { opacity: 0.9; border-color: var(--glass-border-hover); }
    .drift-random:hover { transform: scale(1.1); background: var(--glass-bg-hover); }
    .lightbox-close:hover { color: rgb(255, 255, 255); }
    .lightbox-nav:hover { color: rgba(255, 255, 255, 0.9); }
    .menu-btn:hover { color: var(--text); }
}

/* ===== dvh fallbacks for all viewport-height containers ===== */
.view { min-height: calc(100vh - 52px); min-height: calc(100dvh - 52px); }
.drift-container { min-height: calc(100vh - 52px); min-height: calc(100dvh - 52px); }
.couleurs-wrap { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.bento-wrap { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.bento-grid { height: calc(100vh - 180px); height: calc(100dvh - 180px); }
.jeu-container { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.jeu-pair { max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); }
.faces-container { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.compass-grid { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.nyu-shell { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
#view-confetti { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
#view-square { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.caption-wrap { min-height: calc(100vh - 52px); min-height: calc(100dvh - 52px); }
.cinema-shell { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.reveal-shell { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.pulse-shell { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.drift-shell { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.loading { height: calc(100vh - 52px); height: calc(100dvh - 52px); }

/* ===== Responsive — Tablet (max-width: 768px) ===== */
@media (max-width: 768px) {
    /* Font floor — nothing smaller than 13px on mobile */
    :root {
        --text-2xs: 13px;
        --text-xs: 13px;
        --text-caption: 13px;
        --text-sm: 14px;
    }

    /* Header: keep row, tighten */
    #header {
        padding: var(--space-2_5) var(--space-4);
        padding-top: calc(var(--space-2_5) + env(safe-area-inset-top));
    }

    .side-menu { left: var(--space-3); right: var(--space-3); min-width: auto; }

    /* Drift/Similarity */
    .drift-container { padding: var(--space-5) var(--space-4); }
    .drift-neighbors { grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
    .drift-center { margin-bottom: var(--space-6); }

    .grid-container { padding: var(--space-1); }

    /* Bento: reduce padding, full-width grid */
    .bento-wrap { padding: var(--space-3); }
    .bento-grid { height: calc(100dvh - 120px); max-width: calc(100vw - 24px); }
    .bento-nav { width: 44px; height: 44px; font-size: 20px; }
    .bento-nav-prev { left: var(--space-2); }
    .bento-nav-next { right: var(--space-2); }
    .bento-regen {
        bottom: var(--space-6);
        bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
        right: auto;
        left: 50%;
        translate: -50% 0;
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    /* Game */
    .jeu-pair { gap: var(--space-1); }
    .jeu-bar { bottom: var(--space-6); bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); }

    /* Couleurs */
    .couleurs-wrap { padding: var(--space-3); gap: var(--space-2_5); }
    .couleurs-spectrum { height: 24px; }

    /* Faces */
    .faces-container { padding: var(--space-3); gap: var(--space-2_5); }
    .faces-filter-bar { gap: var(--space-1); }
    .faces-filter-btn { padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }

    /* Compass: stack vertically on tablet */
    .compass-grid {
        grid-template-areas:
            "north  north"
            "west   east"
            "center center"
            "south  south";
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr 3fr auto;
        padding: 0;
    }
    .compass-random { bottom: var(--space-4); right: var(--space-4); }

    /* NYU */
    .nyu-nav { bottom: var(--space-4); bottom: calc(var(--space-4) + env(safe-area-inset-bottom)); padding: var(--space-1_5) var(--space-2_5); }
    .nyu-nav-btn { width: 44px; height: 44px; font-size: 18px; }
    .nyu-reel { gap: var(--space-4); padding: 0 var(--space-4); }
    .nyu-reel-item img { max-width: 90vw; }
    .nyu-reel-nav { display: none; }
    .nyu-reel-counter { bottom: var(--space-4); }
    .nyu-grid-row[data-type="hero"] .nyu-grid-cell { height: 40vh; height: 40dvh; }
    .nyu-grid-row[data-type="pair"] .nyu-grid-cell { height: 28vh; height: 28dvh; }
    .nyu-grid-row[data-type="triplet"] .nyu-grid-cell { height: 20vh; height: 20dvh; }
    .nyu-mosaic { width: min(90dvh, 90vw); height: min(90dvh, 90vw); }
    .nyu-stack { width: min(90vw, 700px); }
    .nyu-canvas { padding: var(--space-5); }
    .nyu-canvas-img { max-width: 95%; max-height: 70dvh; }

    /* Square */
    .square-wrap { padding: var(--space-3); gap: var(--space-2); }
    .square-board { width: min(80dvh, 85vw); height: min(80dvh, 85vw); }
    .square-shake {
        bottom: var(--space-5);
        bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
        right: auto;
        left: 50%;
        translate: -50% 0;
    }

    /* Cinema */
    .cinema-counter { right: var(--space-4); bottom: var(--space-3); }

    /* Reveal */
    .reveal-label { font-size: var(--text-xs); top: var(--space-4); }
    .reveal-counter { right: var(--space-4); bottom: var(--space-3); }

    /* Pulse */
    .pulse-grid { width: min(75dvh, 85vw); height: min(75dvh, 85vw); }
    .pulse-rack { bottom: calc(var(--space-4) + env(safe-area-inset-bottom)); }

    /* Drift */
    .drift-center-wrap { width: min(45dvh, 55vw); height: min(45dvh, 55vw); }
    .drift-card { width: 100px; height: 75px; }
    .drift-ring { gap: var(--space-2); padding: var(--space-3); }
    .drift-trail { bottom: calc(var(--space-4) + env(safe-area-inset-bottom)); }
    .drift-random { top: var(--space-4); right: var(--space-4); }

    /* Caption */
    .caption-wrap { padding: var(--space-6) var(--space-5); }
    .caption-wall { line-height: 2; }
    .caption-preview { width: 140px; height: 100px; }

    /* Confetti */
    .confetti-dial {
        left: 50%;
        top: auto;
        bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
        translate: -50% 0;
        width: 140px;
        height: 140px;
    }
    .confetti-bomb { width: 46px; height: 46px; font-size: 20px; }
    .confetti-dial-btn { width: 30px; height: 30px; margin: -15px 0 0 -15px; font-size: 14px; transform: rotate(var(--dial-angle)) translateX(56px) rotate(calc(-1 * var(--dial-angle))); }
    .confetti-mosaic { width: min(85dvh, 88vw); height: min(85dvh, 88vw); }
    .confetti-label { font-size: var(--text-sm); bottom: var(--space-3); }

    /* Lightbox */
    .lightbox-content { max-width: 95vw; }
    .lightbox-img { max-width: 95vw; max-height: 85dvh; }
    .lightbox-close { top: -44px; font-size: 28px; }
    .lightbox-nav { font-size: 36px; padding: var(--space-2); }

    /* Observatory */
    .observatory-container { grid-template-columns: 1fr; padding: var(--space-4); }

    /* Sort bar — fixed bottom for thumb reach */
    .sort-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        padding: var(--space-2) var(--space-3) calc(var(--space-2) + env(safe-area-inset-bottom));
        z-index: 20;
        overflow: hidden;
    }
    .sort-bar-inner {
        gap: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        background: rgba(230, 230, 230, 0.7);
    }
    :root.dark .sort-bar-inner {
        background: rgba(28, 28, 30, 0.85);
    }
    .sort-bar-inner::-webkit-scrollbar { display: none; }
    .sort-btn { padding: var(--space-1_5) var(--space-2_5); font-size: var(--text-sm); }
    .sort-grid-wrap { padding: 0 var(--space-3) calc(var(--space-20) + 60px); }

    /* Filter bar */
    .filter-bar { padding: var(--space-2_5) var(--space-4); }
}

/* ===== Responsive — Phone (max-width: 480px) ===== */
@media (max-width: 480px) {
    #header { padding: var(--space-2) var(--space-3); padding-top: calc(var(--space-2) + env(safe-area-inset-top)); }
    .header-exp-name { font-size: var(--text-sm); }
    .logo { font-size: var(--text-base); }

    /* Drift/Similarity: single column neighbors on phone */
    .drift-container { padding: var(--space-4) var(--space-3); }
    .drift-neighbors { grid-template-columns: 1fr; gap: var(--space-2); }
    .drift-neighbor img { aspect-ratio: 16/9; }
    .drift-controls { flex-wrap: wrap; gap: var(--space-2); }

    /* Bento: minimal padding */
    .bento-wrap { padding: var(--space-2); }
    .bento-grid { height: calc(100dvh - 80px); max-width: calc(100vw - 16px); }

    /* Game: stack images vertically on phone */
    .jeu-pair { grid-template-columns: 1fr; gap: var(--space-1); }
    .jeu-img { aspect-ratio: 16/9; }

    /* Compass: simplified single-column */
    .compass-grid {
        grid-template-areas:
            "center"
            "north"
            "south"
            "west"
            "east";
        grid-template-columns: 1fr;
        grid-template-rows: 3fr repeat(4, 1fr);
        gap: 2px;
        padding: 0;
    }

    /* Faces: even tighter */
    .faces-container { padding: var(--space-2); gap: var(--space-2); }
    .faces-filter-bar { gap: 2px; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: var(--space-1); }
    .faces-filter-btn { flex-shrink: 0; }

    /* Square: minimal */
    .square-wrap { padding: var(--space-2); }
    .square-board { width: min(85dvh, 94vw); height: min(85dvh, 94vw); }
    .square-score { font-size: var(--text-xl); }

    /* Drift: compact */
    .drift-center-wrap { width: min(40dvh, 60vw); height: min(40dvh, 60vw); }
    .drift-card { width: 80px; height: 60px; }
    .drift-ring { gap: var(--space-1_5); padding: var(--space-2); }
    .drift-trail-dot { width: 28px; height: 28px; }

    /* Cinema: smaller chapter text */
    .cinema-chapter { font-size: clamp(20px, 6vw, 36px); }

    /* Pulse: smaller grid */
    .pulse-grid { width: min(80dvh, 94vw); height: min(80dvh, 94vw); gap: 1px; }
    .pulse-pill { font-size: 12px; padding: var(--space-1) var(--space-2); }
    .pulse-rack { gap: var(--space-1); }

    /* Caption: compact */
    .caption-wrap { padding: var(--space-4) var(--space-3); }
    .caption-wall { line-height: 1.9; }
    .caption-phrase[data-tier="3"] { font-size: var(--text-base); }
    .caption-phrase[data-tier="4"] { font-size: var(--text-lg); }
    .caption-preview { display: none; }

    /* Confetti: tighter dial */
    .confetti-dial { width: 120px; height: 120px; bottom: calc(var(--space-3) + env(safe-area-inset-bottom)); }
    .confetti-bomb { width: 40px; height: 40px; font-size: 18px; }
    .confetti-dial-btn { width: 26px; height: 26px; margin: -13px 0 0 -13px; font-size: 12px; transform: rotate(var(--dial-angle)) translateX(48px) rotate(calc(-1 * var(--dial-angle))); }
    .confetti-mosaic { width: min(80dvh, 92vw); height: min(80dvh, 92vw); }

    /* Sort */
    .sort-bar-inner { flex-wrap: nowrap; justify-content: center; }
    .sort-sep { display: none; }
    .sort-size-btn { width: 40px; height: 40px; }
    .sort-btn { font-size: var(--text-xs); padding: var(--space-1) var(--space-2); }

    /* Pendulum: stack vertically */
    .pendulum-pair { flex-direction: column !important; }
}

/* ===== Content Visibility — off-screen sections don't render ===== */
.view:not(.active) {
    content-visibility: hidden;
}

/* ===== Reduced Motion — respect accessibility preference ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .grid-item:hover img { transform: none; }
    .drift-neighbor:hover { transform: none; box-shadow: none; }
    .glass-tag:hover { transform: none; }
    .compass-arm:hover .compass-arm-img { opacity: 0.35; }
    .face-card:hover { transform: none; box-shadow: none; }
    .map-strip-card:hover { transform: none; box-shadow: none; }
    .nyu-card { transition-duration: 0.01ms !important; }
    .nyu-card-exit, .nyu-card-exit-left { transition-duration: 0.01ms !important; }
    .nyu-mosaic-cell { transition-duration: 0.01ms !important; }
    .nyu-mosaic.assembled { animation-duration: 0.01ms !important; }
    .square-tile { transition-duration: 0.01ms !important; }
    .caption-phrase { transition-duration: 0.01ms !important; }
    .caption-preview { transition-duration: 0.01ms !important; }
    .confetti-cell { transition-duration: 0.01ms !important; }
    .confetti-mosaic.assembled { animation-duration: 0.01ms !important; }
    .confetti-mosaic.scattering .confetti-cell { transition-duration: 0.01ms !important; }
    .confetti-mosaic.floating .confetti-cell { transition-duration: 0.01ms !important; }
    .confetti-preview { transition-duration: 0.01ms !important; }
    .confetti-preview-img { transition-duration: 0.01ms !important; }
    .cinema-layer { transition-duration: 0.01ms !important; }
    .cinema-chapter { transition-duration: 0.01ms !important; }
    .cinema-layer .cinema-img { animation-duration: 0.01ms !important; }
    .reveal-label { animation-duration: 0.01ms !important; }
    .pulse-cell { transition-duration: 0.01ms !important; }
    .drift-hero { transition-duration: 0.01ms !important; }
    .drift-card { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== Tier B — disable backdrop-filter on weaker devices (Chrome Android, low-end) ===== */
:root.tier-b #header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(245, 245, 247, 0.95);
}
:root.tier-b.dark #header {
    background: rgba(20, 20, 22, 0.95);
}
:root.tier-b .side-menu {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(245, 245, 247, 0.97);
}
:root.tier-b.dark .side-menu {
    background: rgba(28, 28, 30, 0.97);
}
:root.tier-b .sort-bar-inner {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(230, 230, 230, 0.92);
}
:root.tier-b.dark .sort-bar-inner {
    background: rgba(28, 28, 30, 0.92);
}
:root.tier-b .bento-nav,
:root.tier-b .bento-regen,
:root.tier-b .compass-random,
:root.tier-b .nyu-reel-nav {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(245, 245, 247, 0.9);
}
:root.tier-b.dark .bento-nav,
:root.tier-b.dark .bento-regen,
:root.tier-b.dark .compass-random,
:root.tier-b.dark .nyu-reel-nav {
    background: rgba(28, 28, 30, 0.9);
}
:root.tier-b .jeu-bar,
:root.tier-b .nyu-nav {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(245, 245, 247, 0.92);
}
:root.tier-b.dark .jeu-bar,
:root.tier-b.dark .nyu-nav {
    background: rgba(28, 28, 30, 0.92);
}
:root.tier-b .square-shake {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(245, 245, 247, 0.9);
}
:root.tier-b.dark .square-shake {
    background: rgba(28, 28, 30, 0.9);
}
:root.tier-b .drift-random {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(245, 245, 247, 0.9);
}
:root.tier-b.dark .drift-random {
    background: rgba(28, 28, 30, 0.9);
}
:root.tier-b .confetti-bomb {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(245, 245, 247, 0.85);
}
:root.tier-b.dark .confetti-bomb {
    background: rgba(28, 28, 30, 0.85);
}
:root.tier-b .confetti-preview-backdrop,
:root.tier-b .lightbox-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(0, 0, 0, 0.85);
}
