@font-face {
    font-family: "Lay Grotesk";
    src: url("assets/lg.otf") format("opentype");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

        :root {
            color-scheme: dark;
            --black: #111111;
            --white: #FFFFFF;
            --red: #E3001B;
            --grey: #8C8C86;
            --grey-dark: #6E6E68;
            --line: #2A2A28;
            --bg: #0E0E0D;
            --surface: #171715;
            --text: #F2F2EE;
            --border: #2A2A28;
            --font: "Lay Grotesk", sans-serif;
            --font-heading: "Lay Grotesk", sans-serif;
            padding-top: env(safe-area-inset-top, 0px);
            padding-bottom: env(safe-area-inset-bottom, 0px);
        }

        html {
            scroll-padding-top: env(safe-area-inset-top, 0px);
        }

        * {
            box-sizing: border-box;
        }

        html,
        body {
            height: 100%;
        }

        body {
            margin: 0;
            background: var(--bg);
            color: var(--text);
            font-family: var(--font);
            -webkit-font-smoothing: antialiased;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        button {
            font-family: inherit;
            cursor: pointer;
            background: none;
            border: none;
            color: inherit;
        }

        button:focus-visible,
        input:focus-visible {
            outline: 2px solid var(--red);
            outline-offset: 1px;
        }

        @media (prefers-reduced-motion: reduce) {
            * {
                animation-duration: .001ms !important;
                transition-duration: .001ms !important;
            }
        }

        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        ::-webkit-scrollbar-thumb {
            background: var(--grey);
        }

        /* ---------- Masthead ---------- */
        .topbar {
            display: grid;
            grid-template-columns: 1fr auto;
            align-items: end;
            padding: 18px 24px 14px;
            border-bottom: 3px solid var(--text);
            background: var(--bg);
            gap: 10px;
            flex: none;
        }

        .masthead-row {
            display: flex;
            align-items: baseline;
            gap: 14px;
            grid-column: 1/-1;
            flex-wrap: wrap;
        }

        .brand {
            font-family: var(--font-heading);
            font-weight: 700;
            font-size: 26px;
            letter-spacing: -0.5px;
            line-height: 1;
        }

        .brand sup {
            color: var(--red);
            font-size: 12px;
            font-weight: 700;
            vertical-align: super;
            margin-left: 2px;
        }

        .util-row {
            display: flex;
            align-items: center;
            grid-column: 1/-1;
            margin-top: 12px;
            flex-wrap: wrap;
        }

        .search-wrap {
            flex: 1;
            min-width: 180px;
            display: flex;
            align-items: center;
            border: 1px solid var(--text);
        }

        .search-wrap span {
            font-size: 11px;
            font-weight: 700;
            padding: 0 10px;
            border-right: 1px solid var(--text);
            color: var(--grey-dark);
        }

        .search-wrap input {
            flex: 1;
            padding: 9px 10px;
            border: none;
            background: var(--bg);
            color: var(--text);
            font-size: 13px;
            font-family: var(--font);
        }

        .back-btn {
            display: none;
            align-items: center;
            gap: 8px;
            border: 1px solid var(--text);
            padding: 9px 14px;
            font-size: 12px;
            font-weight: 700;
            letter-spacing: .3px;
            text-transform: uppercase;
            flex: none;
        }

        .back-btn:hover {
            background: var(--text);
            color: var(--bg);
        }

        .topbar-right {
            margin-left: auto;
            display: flex;
            align-items: center;
            min-width: 0;
        }

        .viewer-meta {
            font-size: 11px;
            color: var(--grey-dark);
            padding: 0 14px;
            display: none;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* ---------- Library: thumbnail-first card grid ---------- */
        .wrap {
            padding: 28px 24px 80px;
            flex: 1;
            min-height: 0;
            overflow-y: auto;
        }

        #deckGrid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 32px 24px;
        }

        .card {
            display: flex;
            flex-direction: column;
            text-align: left;
            color: var(--text);
            background: var(--bg);
            -webkit-tap-highlight-color: transparent;
        }

        .card-thumb {
            width: 100%;
            aspect-ratio: 16/9;
            background: var(--surface);
            overflow: hidden;
            position: relative;
            border-radius: 12px;
            transition: box-shadow .18s ease;
        }

        .card:hover .card-thumb {
            box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
        }

        .card-thumb img {
            width: 100%;
            height: 100%;
            display: block;
            object-fit: cover;
            transition: transform .3s ease;
        }

        .card:hover .card-thumb img {
            transform: scale(1.05);
        }

        .card-thumb .card-idx {
            position: absolute;
            top: 6px;
            left: 6px;
            background: rgba(17, 17, 17, .78);
            color: #fff;
            font-size: 10.5px;
            font-weight: 700;
            padding: 2px 7px;
            letter-spacing: .3px;
            border-radius: 4px;
        }

        .card-thumb .badge-wrap {
            position: absolute;
            bottom: 6px;
            right: 6px;
        }

        .card-thumb .badge {
            background: rgba(17, 17, 17, .82);
            color: #fff;
            border: none;
            border-radius: 4px;
        }

        .card-thumb .hover-icon {
            position: absolute;
            top: 6px;
            right: 6px;
            width: 26px;
            height: 26px;
            border-radius: 50%;
            background: rgba(17, 17, 17, .75);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transform: translateY(-3px);
            transition: opacity .15s ease, transform .15s ease;
            pointer-events: none;
        }

        .card:hover .hover-icon,
        .card:focus-visible .hover-icon {
            opacity: 1;
            transform: translateY(0);
        }

        .card-body {
            padding: 10px 2px 0;
        }

        .card-title {
            font-family: var(--font-heading);
            font-weight: 700;
            font-size: 15px;
            letter-spacing: -.2px;
            line-height: 1.32;
            display: block;
            margin-bottom: 5px;
        }

        .card:hover .card-title {
            color: var(--red);
        }

        .card-meta-group {
            display: flex;
            gap: 12px;
        }

        .card-meta {
            font-size: 11.5px;
            color: var(--grey-dark);
            white-space: nowrap;
        }

        @media (max-width:680px) {
            #deckGrid {
                grid-template-columns: 1fr;
                gap: 22px;
            }
        }

        .badge {
            font-size: 10px;
            font-weight: 700;
            letter-spacing: .3px;
            text-transform: uppercase;
            border: 1px solid var(--text);
            padding: 3px 8px;
        }

        .empty-msg {
            padding: 30px 0;
            font-size: 13px;
            color: var(--grey-dark);
        }

        /* ---------- Viewer ---------- */
        .viewer {
            display: none;
            flex: 1;
            min-height: 0;
        }

        .viewer.active {
            display: grid;
            grid-template-columns: 190px 1fr 280px;
        }

        .filmstrip {
            border-right: 1px solid var(--border);
            overflow-y: auto;
            padding: 14px 12px;
            background: var(--surface);
        }

        .film-idx {
            font-family: var(--font-heading);
            font-size: 10px;
            font-weight: 700;
            color: var(--grey-dark);
            margin: 0 0 6px 2px;
            letter-spacing: .3px;
        }

        .film-slide {
            border: 1px solid var(--border);
            margin-bottom: 10px;
            cursor: pointer;
            overflow: hidden;
            position: relative;
            background: var(--surface);
        }

        .film-slide img {
            width: 100%;
            display: block;
        }

        .film-slide .num {
            position: absolute;
            bottom: 0;
            left: 0;
            font-size: 9px;
            font-weight: 700;
            background: var(--text);
            color: var(--bg);
            padding: 1px 4px;
        }

        .film-slide.active {
            border-color: var(--red);
            border-width: 2px;
        }

        .stage {
            display: flex;
            flex-direction: column;
            min-width: 0;
            min-height: 0;
            border-right: 1px solid var(--border);
        }

        .stage-toolbar {
            display: flex;
            align-items: center;
            border-bottom: 1px solid var(--border);
        }

        .stage-toolbar .title {
            font-family: var(--font-heading);
            font-weight: 700;
            font-size: 12.5px;
            padding: 12px 16px;
            border-right: 1px solid var(--border);
            white-space: nowrap;
        }

        .toolbar-actions {
            margin-left: auto;
            display: flex;
        }

        .icon-btn {
            border-left: 1px solid var(--border);
            width: 44px;
            height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex: none;
        }

        .icon-btn:hover {
            background: var(--text);
            color: var(--bg);
        }

        .icon-btn.text {
            width: auto;
            padding: 0 16px;
            font-size: 11px;
            font-weight: 700;
            letter-spacing: .4px;
            text-transform: uppercase;
        }

        .stage-canvas {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 30px;
            overflow: auto;
            background: var(--bg);
        }

        .slide-frame {
            width: min(900px, 100%);
            aspect-ratio: 16/9;
            background: var(--surface);
            border: 1px solid var(--text);
            position: relative;
            overflow: hidden;
            flex-shrink: 0;
        }

        .slide-frame img {
            width: 100%;
            height: 100%;
            display: block;
            object-fit: contain;
            animation: slideFade .18s ease-out;
        }

        @keyframes slideFade {
            from {
                opacity: .35;
            }

            to {
                opacity: 1;
            }
        }

        .film-slide {
            transition: border-color .12s ease;
        }

        .notes-panel {
            padding: 18px 20px;
            overflow-y: auto;
        }

        .notes-panel h3 {
            font-family: var(--font-heading);
            font-size: 10.5px;
            letter-spacing: .5px;
            text-transform: uppercase;
            color: var(--grey-dark);
            margin: 0 0 10px;
            font-weight: 700;
            border-bottom: 1px solid var(--border);
            padding-bottom: 8px;
        }

        .notes-panel p {
            font-size: 13px;
            line-height: 1.55;
            margin: 0 0 16px;
            color: var(--text);
        }

        .pipeline-step {
            font-size: 11.5px;
            color: var(--grey-dark);
            display: flex;
            gap: 8px;
            padding: 6px 0;
            border-top: 1px solid var(--border);
        }

        .pipeline-step b {
            color: var(--text);
        }

        .flag-note {
            font-size: 11px;
            border: 1px solid var(--red);
            color: var(--red);
            padding: 8px 10px;
            margin-top: 4px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: .3px;
        }

        .notes-panel.hidden {
            display: none;
        }

        /* ---------- Presentation mode ---------- */
        .present {
            position: fixed;
            inset: 0;
            background: #000;
            z-index: 100;
            display: none;
            align-items: center;
            justify-content: center;
            padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
        }

        .present.active {
            display: flex;
        }

        .present .slide-frame {
            width: min(1200px, 94vw);
            border: none;
            background: #000;
        }

        .present-exit {
            position: absolute;
            top: calc(18px + env(safe-area-inset-top, 0px));
            right: 22px;
            color: #999;
            font-size: 11px;
            font-weight: 700;
            letter-spacing: .4px;
            text-transform: uppercase;
        }

        .present-nav {
            position: absolute;
            bottom: calc(22px + env(safe-area-inset-bottom, 0px));
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 16px;
            align-items: center;
            color: #777;
            font-size: 12px;
            font-weight: 700;
        }

        .present-nav button {
            border: 1px solid #333;
            color: #eee;
            width: 34px;
            height: 34px;
        }

        .present-nav button:hover {
            background: var(--red);
            border-color: var(--red);
        }

        .swipe-hint {
            position: absolute;
            bottom: 10px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 10px;
            color: var(--grey-dark);
            letter-spacing: .3px;
            opacity: .8;
            pointer-events: none;
            display: none;
        }

        /* ---------- Tablet: keep side filmstrip, drop notes rail to a toggleable drawer ---------- */
        @media (max-width:980px) {
            .viewer.active {
                grid-template-columns: 120px 1fr;
            }

            .notes-panel {
                display: none;
                position: fixed;
                inset: auto 0 0 0;
                max-height: 55vh;
                z-index: 30;
                border-top: 3px solid var(--text);
                box-shadow: 0 -8px 24px rgba(0, 0, 0, .18);
            }

            .notes-panel:not(.hidden) {
                display: block;
            }
        }

        /* ---------- Phone: filmstrip becomes a horizontal strip along the bottom ---------- */
        @media (max-width:620px) {
            .topbar {
                padding: 12px 14px 10px;
            }

            .brand {
                font-size: 21px;
            }

            .search-wrap span {
                padding: 0 8px;
            }

            .search-wrap input {
                font-size: 16px;
            }

            .wrap {
                padding: 18px 14px 60px;
            }

            .viewer.active {
                grid-template-columns: 1fr;
                grid-template-rows: 1fr auto;
            }

            .stage {
                border-right: none;
                order: 1;
                min-height: 0;
            }

            .filmstrip {
                order: 2;
                border-right: none;
                border-top: 1px solid var(--border);
                display: flex;
                flex-direction: row;
                align-items: flex-start;
                overflow-x: auto;
                overflow-y: hidden;
                padding: 10px 12px;
                gap: 10px;
                -webkit-overflow-scrolling: touch;
            }

            .film-idx {
                display: none;
            }

            .film-slide {
                flex: 0 0 76px;
                margin-bottom: 0;
            }

            .stage-canvas {
                padding: 14px;
            }

            .slide-frame {
                touch-action: pan-y;
            }

            .swipe-hint {
                display: block;
            }

            .stage-toolbar .title {
                padding: 10px 12px;
                font-size: 12px;
            }
        }

        /* ---------- Short viewports: phone landscape, or a resized short window ---------- */
        @media (max-height:480px) {
            .topbar {
                padding: 8px 16px;
            }

            .brand {
                font-size: 18px;
            }

            .stage-canvas {
                padding: 10px;
            }

            .filmstrip {
                padding: 6px 10px;
            }

            .film-slide {
                flex: 0 0 56px;
            }

            .present-exit {
                top: calc(8px + env(safe-area-inset-top, 0px));
                font-size: 10px;
            }

            .present-nav {
                bottom: calc(10px + env(safe-area-inset-bottom, 0px));
                gap: 10px;
            }

            .present-nav button {
                width: 28px;
                height: 28px;
            }
        }

        /* ---------- Very narrow phones ---------- */
        @media (max-width:360px) {
            .film-slide {
                flex: 0 0 64px;
            }

            .present-nav {
                gap: 10px;
            }
        }
    