    html,
    body {
        margin: 0;
        height: 100%;
        overflow: hidden;
        background: #000;
        font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #bgStage {
        position: fixed;
        inset: 0;
        z-index: 0;
        pointer-events: none;
        user-select: none;
        overflow: hidden;
    }

    #bg {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
        z-index: 0;
        pointer-events: none;
        user-select: none;
        opacity: 1;
        transition: opacity .06s linear;
    }

    .bgLayer {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
        pointer-events: none;
        user-select: none;
        opacity: 0;
        transition: opacity .06s linear;
        will-change: opacity;
        contain: strict;
        backface-visibility: hidden;
        transform: translateZ(0);
    }

    .bgLayer.active {
        opacity: 1;
    }

    canvas {
        position: fixed;
        inset: 0;
        z-index: 1;
        display: block;
    }

    #togglePanel {
        position: fixed;
        left: 12px;
        top: 12px;
        z-index: 4;
        width: 38px;
        height: 38px;
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .55);
        color: #fff;
        display: grid;
        place-items: center;
        cursor: pointer;
        backdrop-filter: blur(8px);
        font: 18px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
        user-select: none;
    }

    #togglePanel:hover {
        background: rgba(0, 0, 0, .68);
    }

    #panel {
        position: fixed;
        left: 12px;
        top: 12px;
        z-index: 3;
        width: 520px;
        max-width: calc(100vw - 24px);
        color: #fff;
        background: rgba(0, 0, 0, .55);
        border-radius: 12px;
        padding: 10px 12px;
        backdrop-filter: blur(8px);
        font: 12px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
        transform: translateX(0);
        transition: transform .18s ease, opacity .18s ease;
        will-change: transform, opacity;
        margin-left: 46px;
        max-height: calc(100vh - 24px);
        overflow: auto;
    }

    #panel.hidden {
        transform: translateX(calc(-100% - 24px));
        opacity: 0;
        pointer-events: none;
    }

    #panel h3 {
        margin: 0 0 6px 0;
        font-size: 13px;
    }

    #panel .row {
        display: grid;
        grid-template-columns: 140px 1fr 82px;
        gap: 6px 10px;
        align-items: center;
        margin: 6px 0;
    }

    #panel input[type="range"] {
        width: 100%;
    }

    #panel select {
        width: 100%;
    }

    #panel code {
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    }

    #panel .help {
        opacity: .85;
        margin-top: 8px;
    }

    #panel details.sect {
        margin: 8px 0;
    }

    #panel summary {
        cursor: pointer;
        font-weight: 700;
        user-select: none;
    }

    #panel hr {
        opacity: .25;
        border: 0;
        border-top: 1px solid rgba(255, 255, 255, .15);
        margin: 10px 0;
    }

    #hline {
        position: fixed;
        left: 0;
        right: 0;
        height: 1px;
        background: rgba(0, 255, 255, .8);
        z-index: 2;
        pointer-events: none;
        opacity: 0;
    }

    /* Infinite mouse drag via PointerLock + virtual cursor */

    body.dragging {
        cursor: none;
    }

    body.dragging #panel,
    body.dragging #togglePanel,
    body.dragging #panel * {
        cursor: auto;
    }

    html,
    body,
    button,
    input,
    select,
    textarea {
        font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif !important;
    }

    /* --- Timeline / Transport --- */
    #transport {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 12px;
        z-index: 5;
        display: grid;
        grid-template-columns: auto auto auto auto minmax(240px, 1fr) auto auto;
        grid-template-areas:
            "rew play rec lamp local readout actions"
            "sceneStart scenePrev sceneNext sceneEnd scene sceneReadout actions";
        gap: 10px;
        align-items: center;
        padding: 10px 12px;
        border-radius: 14px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .55);
        backdrop-filter: blur(10px);
        color: #fff;
        font: 12px/1.2 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
        user-select: none;
        width: calc(100vw - 24px);
        box-sizing: border-box;
        transition: width .18s ease, max-width .18s ease, right .18s ease, padding .18s ease;
    }

    #rewBtn {
        grid-area: rew;
    }

    #playBtn {
        grid-area: play;
    }

    #recBtn {
        grid-area: rec;
    }

    #recLamp {
        grid-area: lamp;
    }

    #timeSlider {
        grid-area: local;
        min-width: 220px;
    }

    #timeReadout {
        grid-area: readout;
        justify-self: end;
        text-align: right;
        min-width: 96px;
        white-space: nowrap;
    }

    #sceneReadout {
        grid-area: sceneReadout;
        justify-self: start;
        text-align: left;
        min-width: max-content;
        white-space: nowrap;
        opacity: .82;
        font-variant-numeric: tabular-nums;
        margin-left: -6px;
    }

    #sceneStartBtn,
    #scenePrevBtn,
    #sceneNextBtn,
    #sceneEndBtn {
        width: 56px;
        min-width: 56px;
    }

    #timeSlider,
    #sceneSlider {
        align-self: stretch;
    }

    #sceneStartBtn {
        grid-area: sceneStart;
    }

    #scenePrevBtn {
        grid-area: scenePrev;
    }

    #sceneNextBtn {
        grid-area: sceneNext;
    }

    #sceneEndBtn {
        grid-area: sceneEnd;
    }

    #sceneSlider {
        grid-area: scene;
        accent-color: #39d353;
        min-width: 220px;
    }

    #recBtn.toggle {
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .28);
        color: rgba(255, 255, 255, .9);
        padding: 8px 10px;
        border-radius: 10px;
        font-weight: 700;
        letter-spacing: .3px;
        cursor: pointer;
        user-select: none;
    }

    #recBtn.toggle.active {
        border-color: rgba(255, 80, 80, .55);
        background: rgba(255, 50, 50, .20);
        box-shadow: 0 0 0 2px rgba(255, 80, 80, .12) inset;
    }

    #recLamp.armed #recDot {
        background: rgba(255, 80, 80, .85);
    }

    #transport button {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .35);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
        font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif !important;
    }

    #transport button:hover {
        background: rgba(0, 0, 0, .5);
    }

    #transport button:active {
        transform: translateY(1px);
    }

    #transport input[type="range"] {
        width: 100%;
    }

    body.cleanfeed-hide #togglePanel,
    body.cleanfeed-hide #fileMenuWrap,
    body.cleanfeed-hide #panel,
    body.cleanfeed-hide #transport,
    body.cleanfeed-hide #takeManagerWrap,
    body.cleanfeed-hide #animMenu,
    body.cleanfeed-hide #bgBrowserModal,
    body.cleanfeed-hide #onionSkinModal,
    body.cleanfeed-hide #shortcutModal,
    body.cleanfeed-hide #projectLoadOverlay,
    body.cleanfeed-hide #hline {
        display: none !important;
    }

    #recLamp {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 10px;
        border-radius: 999px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .35);
        white-space: nowrap;
    }

    #recDot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: #ff2d2d;
        box-shadow: 0 0 0 2px rgba(255, 45, 45, .25);
        opacity: .25;
        transition: opacity .12s ease;
    }

    #recLamp.recording #recDot {
        opacity: 1;
    }

    #timeReadout {
        opacity: .85;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }



    /* --- File Menu --- */
    #fileMenuWrap {
        position: fixed;
        left: 58px;
        top: 12px;
        z-index: 5;
        user-select: none;
    }

    #fileMenuBtn {
        height: 38px;
        padding: 0 12px;
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .55);
        color: #fff;
        cursor: pointer;
        backdrop-filter: blur(8px);
        font: 13px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #fileMenuBtn:hover {
        background: rgba(0, 0, 0, .68);
    }

    #fileMenu {
        margin-top: 6px;
        min-width: 220px;
        background: rgba(0, 0, 0, .85);
        color: #fff;
        border: 1px solid rgba(255, 255, 255, .18);
        border-radius: 12px;
        padding: 6px;
        backdrop-filter: blur(10px);
        box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
        display: none;
    }

    #fileMenu .menuItem {
        width: 100%;
        text-align: left;
        padding: 8px 10px;
        border-radius: 10px;
        cursor: pointer;
        background: transparent;
        border: none;
        color: inherit;
        font: 12px/1.25 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #fileMenu .menuItem:hover {
        background: rgba(255, 255, 255, .10);
    }




    /* --- Background Browser --- */
    #bgBrowserModal {
        position: fixed;
        inset: 0;
        z-index: 20;
        display: none;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, .45);
        backdrop-filter: blur(6px);
    }

    #bgBrowserModal.open {
        display: flex;
    }

    #bgBrowserPanel {
        width: min(980px, calc(100vw - 32px));
        max-height: calc(100vh - 32px);
        overflow: hidden;
        display: grid;
        grid-template-rows: auto auto 1fr;
        gap: 10px;
        padding: 14px;
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .82);
        color: #fff;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
        backdrop-filter: blur(12px);
        font: 12px/1.3 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #bgBrowserTop {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    #bgBrowserTitle {
        font-size: 15px;
        font-weight: 700;
    }

    #bgBrowserSub {
        opacity: .75;
        margin-top: 2px;
    }

    #bgBrowserActions,
    #bgBrowserPager {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
    }

    .bgBrowserBtn {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
        font: inherit;
    }

    .bgBrowserBtn:hover {
        background: rgba(255, 255, 255, .12);
    }

    .bgBrowserBtn:disabled {
        opacity: .4;
        cursor: default;
    }

    #bgBrowserStatus {
        opacity: .78;
        white-space: nowrap;
    }

    #bgBrowserGrid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
        overflow: auto;
        padding-right: 2px;
        min-height: 240px;
    }

    .bgTile {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .14);
        background: rgba(255, 255, 255, .04);
        color: #fff;
        border-radius: 14px;
        padding: 8px;
        text-align: left;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        gap: 8px;
        min-height: 0;
    }

    .bgTile:hover {
        background: rgba(255, 255, 255, .09);
    }

    .bgTileThumb {
        width: 100%;
        aspect-ratio: 16 / 9;
        object-fit: cover;
        border-radius: 10px;
        background: rgba(255, 255, 255, .06);
        border: 1px solid rgba(255, 255, 255, .08);
    }

    .bgTileName {
        font-weight: 700;
        font-size: 13px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bgTileMeta {
        opacity: .72;
        font-size: 11px;
        display: flex;
        justify-content: space-between;
        gap: 8px;
    }

    .bgTileHint {
        opacity: .72;
        font-size: 11px;
    }

    .bgTile.is-selected {
        border-color: rgba(80, 180, 255, .55);
        box-shadow: 0 0 0 1px rgba(80, 180, 255, .25) inset;
        background: rgba(80, 180, 255, .14);
    }

    .bgTileEmpty {
        border: 1px dashed rgba(255, 255, 255, .12);
        border-radius: 14px;
        min-height: 120px;
        opacity: .35;
    }


    /* --- Character Animation Context Menu --- */
    #animMenu {
        position: fixed;
        z-index: 9999;
        min-width: 180px;
        background: rgba(0, 0, 0, .85);
        color: #fff;
        border: 1px solid rgba(255, 255, 255, .18);
        border-radius: 12px;
        padding: 6px;
        font: 12px/1.25 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
        backdrop-filter: blur(10px);
        box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
        display: none;
        user-select: none;
        max-height: 70vh;
        overflow: auto;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
    }

    #animMenu .item {
        padding: 8px 10px;
        border-radius: 10px;
        cursor: pointer;
        white-space: nowrap;
    }

    #animMenu .item:hover {
        background: rgba(255, 255, 255, .10);
    }

    #animMenu .item.active {
        background: rgba(80, 180, 255, .22);
        border: 1px solid rgba(80, 180, 255, .30);
    }

    #animMenu .sep {
        height: 1px;
        background: rgba(255, 255, 255, .12);
        margin: 6px 4px;
    }



    #projectLoadOverlay {
        position: fixed;
        inset: 0;
        z-index: 30;
        display: none;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, .62);
        backdrop-filter: blur(6px);
        color: #fff;
        font: 13px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #projectLoadOverlay.open {
        display: flex;
    }

    #projectLoadOverlay .box {
        width: min(560px, calc(100vw - 32px));
        background: rgba(15, 15, 15, .92);
        border: 1px solid rgba(255, 255, 255, .12);
        border-radius: 14px;
        box-shadow: 0 18px 80px rgba(0, 0, 0, .45);
        padding: 16px 18px;
    }

    #projectLoadOverlay .title {
        font-size: 15px;
        font-weight: 700;
        margin-bottom: 8px;
    }

    #projectLoadOverlay .mode {
        opacity: .82;
        margin-bottom: 10px;
    }

    #projectLoadOverlay .file,
    #projectLoadOverlay .detail {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 6px 10px;
        border-radius: 8px;
        background: rgba(255, 255, 255, .06);
        margin-bottom: 8px;
    }

    #projectLoadOverlay .detail {
        opacity: .9;
    }

    #projectLoadOverlay .bar {
        height: 12px;
        border-radius: 999px;
        overflow: hidden;
        background: rgba(255, 255, 255, .10);
        border: 1px solid rgba(255, 255, 255, .08);
        margin-top: 10px;
    }

    #projectLoadOverlay .fill {
        width: 0%;
        height: 100%;
        border-radius: 999px;
        background: linear-gradient(90deg, rgba(115, 185, 255, .95), rgba(125, 255, 210, .95));
        transition: width .12s linear;
    }

    #projectLoadOverlay .pct {
        margin-top: 8px;
        font-variant-numeric: tabular-nums;
        opacity: .9;
    }

    #bgWarmHost {
        position: fixed;
        left: -20000px;
        top: -20000px;
        width: 8px;
        height: 8px;
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
        z-index: -1;
    }

    #bgWarmHost img {
        width: 8px;
        height: 8px;
        object-fit: cover;
        display: block;
    }



    /* --- Onion Skin Popup --- */
    #onionSkinModal {
        position: fixed;
        inset: 0;
        z-index: 25;
        display: none;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, .45);
        backdrop-filter: blur(6px);
    }

    #onionSkinModal.open {
        display: flex;
    }

    #onionSkinPanel {
        width: min(520px, calc(100vw - 32px));
        max-height: calc(100vh - 32px);
        overflow: auto;
        padding: 14px;
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .82);
        color: #fff;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
        backdrop-filter: blur(12px);
        font: 12px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #onionSkinPanel h3 {
        margin: 0 0 4px 0;
        font-size: 15px;
    }

    #onionSkinPanel .sub {
        opacity: .78;
        margin-bottom: 10px;
    }

    #onionSkinPanel .row {
        display: grid;
        grid-template-columns: 160px 1fr 72px;
        gap: 8px 10px;
        align-items: center;
        margin: 8px 0;
    }

    #onionSkinPanel input[type="range"] {
        width: 100%;
    }

    #onionSkinPanel .actions {
        margin-top: 12px;
        display: flex;
        justify-content: flex-end;
        gap: 8px;
    }

    .onionBtn {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
        font: inherit;
    }

    .onionBtn:hover {
        background: rgba(255, 255, 255, .12);
    }

    #onionSkinHint {
        opacity: .72;
        margin-top: 8px;
    }



    /* --- Flatplate Options Modal --- */
    #flatplateOptionsModal {
        position: fixed;
        inset: 0;
        z-index: 28;
        display: none;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, .45);
        backdrop-filter: blur(6px);
    }

    #flatplateOptionsModal.open {
        display: flex;
    }

    #flatplateOptionsPanel {
        width: min(460px, calc(100vw - 32px));
        max-height: calc(100vh - 32px);
        overflow: auto;
        padding: 14px;
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .82);
        color: #fff;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
        backdrop-filter: blur(12px);
        font: 12px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #flatplateOptionsPanel h3 {
        margin: 0 0 4px 0;
        font-size: 15px;
    }

    #flatplateOptionsPanel .sub {
        opacity: .78;
        margin-bottom: 10px;
    }

    #flatplateOptionsPanel .row {
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: 8px 10px;
        align-items: center;
        margin: 10px 0;
    }

    #flatplateOptionsPanel .groupRow {
        align-items: start;
    }

    #flatplateOptionsPanel label {
        cursor: pointer;
        user-select: none;
    }

    #flatplateOptionsPanel input:not([type="checkbox"]):not([type="radio"]),
    #flatplateOptionsPanel select {
        width: 100%;
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .16);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        font: inherit;
        box-sizing: border-box;
    }

    #flatplateOptionsPanel input[type="checkbox"],
    #flatplateOptionsPanel input[type="radio"] {
        appearance: auto;
        -webkit-appearance: auto;
        width: 16px;
        height: 16px;
        margin: 0;
        padding: 0;
        border: none;
        background: transparent;
        border-radius: 0;
        box-sizing: border-box;
        cursor: pointer;
        accent-color: auto;
        flex: 0 0 auto;
    }

    #flatplateOptionsPanel .radioGroup {
        display: grid;
        gap: 8px;
    }

    #flatplateOptionsPanel .radioOption {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 18px;
    }

    #flatplateOptionsPanel .radioOption span {
        flex: 1 1 auto;
    }

    #flatplateOptionsPanel select option {
        background: #101318;
        color: #fff;
    }

    #flatplateOptionsPanel .actions {
        margin-top: 12px;
        display: flex;
        justify-content: flex-end;
        gap: 8px;
    }

    .flatplateOptionsBtn {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
        font: inherit;
    }

    .flatplateOptionsBtn:hover {
        background: rgba(255, 255, 255, .12);
    }

    #flatplateOptionsHint {
        opacity: .72;
        margin-top: 8px;
    }




    /* --- Language Modal --- */
    #languageModal {
        position: fixed;
        inset: 0;
        z-index: 27;
        display: none;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, .45);
        backdrop-filter: blur(6px);
    }

    #languageModal.open {
        display: flex;
    }

    #languagePanel {
        width: min(520px, calc(100vw - 32px));
        max-height: calc(100vh - 32px);
        overflow: auto;
        padding: 14px;
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .82);
        color: #fff;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
        backdrop-filter: blur(12px);
        font: 12px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #languagePanel h3 {
        margin: 0 0 4px 0;
        font-size: 15px;
    }

    #languagePanel .sub {
        opacity: .78;
        margin-bottom: 10px;
    }

    #languagePanel .row {
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: 8px 10px;
        align-items: center;
        margin: 8px 0;
    }

    #languageSelect {
        width: 100%;
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .16);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        font: inherit;
        box-sizing: border-box;
    }

    #languageSelect option {
        background: #101318;
        color: #fff;
    }

    #languagePanel .actions {
        margin-top: 12px;
        display: flex;
        justify-content: flex-end;
        gap: 8px;
    }

    .languageBtn {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
        font: inherit;
    }

    .languageBtn:hover {
        background: rgba(255, 255, 255, .12);
    }

    /* --- Shortcut Manager --- */
    #shortcutModal {
        position: fixed;
        inset: 0;
        z-index: 26;
        display: none;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, .45);
        backdrop-filter: blur(6px);
    }

    #shortcutModal.open {
        display: flex;
    }

    #shortcutPanel {
        width: min(980px, calc(100vw - 32px));
        max-height: calc(100vh - 32px);
        overflow: auto;
        padding: 14px;
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .82);
        color: #fff;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
        backdrop-filter: blur(12px);
        font: 12px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #shortcutTop {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 12px;
    }

    #shortcutTop h3 {
        margin: 0 0 4px 0;
        font-size: 15px;
    }

    #shortcutTop .sub {
        opacity: .78;
    }

    #shortcutActions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        align-items: center;
    }

    .shortcutBtn {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
        font: inherit;
    }

    .shortcutBtn:hover {
        background: rgba(255, 255, 255, .12);
    }

    #shortcutLegend {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        margin-bottom: 12px;
    }

    .shortcutLegendItem {
        padding: 6px 10px;
        border-radius: 999px;
        border: 1px solid rgba(255, 255, 255, .12);
        background: rgba(255, 255, 255, .04);
        opacity: .88;
    }

    #shortcutGrid {
        display: grid;
        grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
        gap: 12px;
        align-items: start;
    }

    #shortcutGrid>.shortcutCard:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    #shortcutGrid>.shortcutCard:nth-child(2) {
        grid-column: 2;
        grid-row: 1 / span 2;
        align-self: stretch;
    }

    #shortcutGrid>.shortcutCard:nth-child(3) {
        grid-column: 1;
        grid-row: 2;
    }

    .shortcutCard {
        border: 1px solid rgba(255, 255, 255, .14);
        background: rgba(255, 255, 255, .04);
        border-radius: 14px;
        padding: 12px;
        min-width: 0;
    }

    .shortcutCard h4 {
        margin: 0 0 10px 0;
        font-size: 13px;
        opacity: .95;
    }

    .shortcutRow {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px 14px;
        align-items: start;
        padding: 10px 0;
        border-top: 1px solid rgba(255, 255, 255, .08);
    }

    .shortcutRow:first-of-type {
        border-top: 0;
        padding-top: 0;
    }

    .shortcutActionLabel {
        min-width: 0;
        padding-top: 2px;
    }

    .shortcutActionTitle {
        font-weight: 700;
    }

    .shortcutActionDesc {
        opacity: .68;
        font-size: 11px;
        margin-top: 2px;
    }

    .shortcutKeyBtn {
        justify-self: start;
        min-width: 140px;
        text-align: center;
        padding: 8px 10px;
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, .16);
        background: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .03));
        color: #fff;
        font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        letter-spacing: .02em;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(0, 0, 0, .22);
    }

    .shortcutKeyBtn:hover {
        background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .06));
    }

    .shortcutKeyBtn.is-listening {
        border-color: rgba(80, 180, 255, .65);
        box-shadow: 0 0 0 1px rgba(80, 180, 255, .28) inset, 0 0 0 4px rgba(80, 180, 255, .14);
        background: linear-gradient(180deg, rgba(80, 180, 255, .24), rgba(80, 180, 255, .10));
    }

    .shortcutGhostBtn {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .12);
        background: rgba(255, 255, 255, .04);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
        font: inherit;
        opacity: .9;
    }

    .shortcutGhostBtn:hover {
        background: rgba(255, 255, 255, .10);
    }

    .shortcutControls {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        flex-wrap: wrap;
        min-width: 0;
    }

    .shortcutConflict {
        grid-column: 1 / -1;
        margin-top: 4px;
        padding: 8px 10px;
        border-radius: 10px;
        background: rgba(255, 120, 120, .14);
        border: 1px solid rgba(255, 120, 120, .18);
        color: #ffd8d8;
        font-size: 11px;
    }

    #shortcutHint {
        opacity: .72;
        margin-top: 12px;
    }

    @media (max-width: 860px) {
        #shortcutGrid {
            grid-template-columns: 1fr;
        }

        #shortcutGrid>.shortcutCard:nth-child(1),
        #shortcutGrid>.shortcutCard:nth-child(2),
        #shortcutGrid>.shortcutCard:nth-child(3) {
            grid-column: auto;
            grid-row: auto;
            align-self: auto;
        }
    }

    @media (max-width: 640px) {
        .shortcutRow {
            grid-template-columns: 1fr;
        }

        .shortcutControls {
            justify-content: stretch;
        }

        .shortcutKeyBtn,
        .shortcutGhostBtn {
            width: 100%;
        }
    }


    /* --- Take Manager --- */
    body.timeline-compact #transport {
        right: auto;
        width: max-content;
        max-width: calc(100vw - 24px);
        grid-template-columns: auto auto auto auto auto;
        grid-template-areas:
            "rew play rec lamp actions"
            "sceneStart scenePrev sceneNext sceneEnd actions";
    }

    body.timeline-compact #timeSlider,
    body.timeline-compact #timeReadout,
    body.timeline-compact #sceneReadout,
    body.timeline-compact #sceneSlider,
    body.timeline-compact #sceneLabel {
        display: none;
    }

    #sceneLabel {
        display: none;
    }

    #transportActions {
        grid-area: actions;
        justify-self: end;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    #takeManagerBtn {
        font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif !important;
    }

    #sceneLabel,
    #transport,
    #transport button,
    #transport input,
    #transport select,
    #takeManagerWrap,
    #takeManagerWrap button,
    #takeManagerWrap input,
    #takeManagerWrap select {
        font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif !important;
    }

    #timelineFoldBtn {
        margin-left: 2px;
        min-width: 36px;
        padding: 8px 9px;
    }

    #transportBottomRow {
        display: contents;
    }

    @media (max-width: 980px) {
        #transport {
            grid-template-columns: auto auto auto auto 1fr auto;
            grid-template-areas:
                "rew play rec lamp readout actions"
                "local local local local local local"
                "sceneStart scenePrev sceneNext sceneEnd sceneReadout actions"
                "scene scene scene scene scene scene";
        }

        body.timeline-compact #transport {
            right: 12px;
            width: calc(100vw - 24px);
            max-width: none;
            grid-template-columns: auto auto auto auto auto;
            grid-template-areas:
                "rew play rec lamp takeBtn"
                "sceneStart scenePrev sceneNext sceneEnd takeBtn";
        }

        #takeManagerBtn {
            justify-self: end;
        }
    }

    #takeManagerWrap {
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 6;
        width: min(360px, calc(100vw - 24px));
        color: #fff;
        background: rgba(0, 0, 0, .55);
        border: 1px solid rgba(255, 255, 255, .18);
        border-radius: 14px;
        backdrop-filter: blur(10px);
        box-shadow: 0 12px 36px rgba(0, 0, 0, .35);
        overflow: hidden;
        transition: opacity .18s ease, transform .18s ease;
        transform-origin: top right;
        font: 12px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #takeManagerWrap.hidden {
        opacity: 0;
        transform: translateY(-8px) scale(.985);
        pointer-events: none;
    }

    #takeManagerHeader {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 12px 14px 8px;
        border-bottom: 1px solid rgba(255, 255, 255, .10);
        cursor: move;
        touch-action: none;
    }

    #takeManagerTitle {
        font-size: 13px;
        font-weight: 700;
    }

    #takeManagerSceneMeta {
        opacity: .7;
        font-size: 11px;
        margin-top: 2px;
    }

    #takeManagerClose {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .16);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 6px 9px;
        cursor: pointer;
        font: inherit;
    }

    #takeManagerClose:hover {
        background: rgba(255, 255, 255, .12);
    }

    #takeManagerBody {
        padding: 12px 14px 14px;
        display: grid;
        gap: 10px;
    }

    .takeManagerRow {
        display: grid;
        grid-template-columns: 88px 1fr;
        gap: 8px 10px;
        align-items: center;
    }

    .takeManagerRow label {
        opacity: .84;
    }

    #takeSelect,
    #takeNameInput {
        width: 100%;
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .16);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        font: inherit;
        box-sizing: border-box;
        caret-color: #fff;
    }

    #takeSelect option {
        background: #101318;
        color: #fff;
    }

    #takeSelect:focus,
    #takeNameInput:focus {
        outline: none;
        border-color: rgba(80, 180, 255, .72);
        box-shadow: 0 0 0 1px rgba(80, 180, 255, .28) inset, 0 0 0 4px rgba(80, 180, 255, .14);
    }

    #takeStars {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
        align-items: center;
    }

    .takeStar {
        appearance: none;
        border: none;
        background: transparent;
        color: rgba(255, 255, 255, .32);
        font: inherit;
        font-size: 20px;
        line-height: 1;
        padding: 0;
        cursor: pointer;
    }

    .takeStar.active {
        color: #ffd966;
    }

    #takeManagerActions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    .takeManagerAction {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .16);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
        font: inherit;
    }

    .takeManagerAction:hover {
        background: rgba(255, 255, 255, .12);
    }

    #takeManagerWrap,
    #takeManagerWrap * {
        font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif !important;
    }

    #takeSummary {
        opacity: .78;
        font-size: 11px;
        line-height: 1.4;
        padding-top: 2px;
    }


    /* --- Export Modal --- */
    #exportModal {
        position: fixed;
        inset: 0;
        z-index: 28;
        display: none;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, .45);
        backdrop-filter: blur(6px);
    }

    #exportModal.open {
        display: flex;
    }

    #exportPanel {
        width: min(620px, calc(100vw - 32px));
        max-height: calc(100vh - 32px);
        overflow: auto;
        padding: 14px;
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(0, 0, 0, .82);
        color: #fff;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
        backdrop-filter: blur(12px);
        font: 12px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    }

    #exportTop {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 12px;
    }

    #exportTop h3 {
        margin: 0 0 4px 0;
        font-size: 15px;
    }

    #exportPanel .sub {
        opacity: .78;
    }

    #exportPanel .exportGrid {
        display: grid;
        gap: 8px;
    }

    #exportProgressWrap {
        display: grid;
        gap: 6px;
        margin-top: 10px;
        padding: 10px 12px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, .12);
        background: rgba(255, 255, 255, .05);
    }

    #exportProgressBar {
        width: 100%;
        height: 10px;
        appearance: none;
        -webkit-appearance: none;
    }

    #exportProgressBar::-webkit-progress-bar {
        background: rgba(255, 255, 255, .10);
        border-radius: 999px;
    }

    #exportProgressBar::-webkit-progress-value {
        background: linear-gradient(90deg, #74b9ff, #7bed9f);
        border-radius: 999px;
    }

    #exportProgressBar::-moz-progress-bar {
        background: linear-gradient(90deg, #74b9ff, #7bed9f);
        border-radius: 999px;
    }

    #exportProgressMeta {
        opacity: .82;
        font-size: 11px;
        text-align: right;
    }

    #exportPanel .row {
        display: grid;
        grid-template-columns: 160px 1fr 72px;
        gap: 8px 10px;
        align-items: center;
        margin: 0;
    }

    #exportPanel .row input[type="number"],
    #exportPanel .row input[type="text"],
    #exportPanel .row select {
        width: 100%;
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .16);
        background: rgba(24, 28, 36, .96);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        font: inherit;
        box-sizing: border-box;
    }

    #exportPanel .row select {
        color-scheme: dark;
        background-image: linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, .78) 50%), linear-gradient(135deg, rgba(255, 255, 255, .78) 50%, transparent 50%);
        background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
        background-size: 6px 6px, 6px 6px;
        background-repeat: no-repeat;
        padding-right: 34px;
    }

    #exportPanel .row select option,
    #exportPanel .row select optgroup {
        background: #1b1f27;
        color: #fff;
    }

    #exportPanel .row input[type="number"]:focus,
    #exportPanel .row input[type="text"]:focus,
    #exportPanel .row select:focus {
        outline: 1px solid rgba(116, 185, 255, .55);
        border-color: rgba(116, 185, 255, .55);
    }

    #exportPanel .row input[type="range"] {
        width: 100%;
    }

    #exportPanel .actions {
        margin-top: 12px;
        display: flex;
        justify-content: flex-end;
        gap: 8px;
    }

    .exportBtnAction {
        appearance: none;
        border: 1px solid rgba(255, 255, 255, .18);
        background: rgba(255, 255, 255, .06);
        color: #fff;
        border-radius: 10px;
        padding: 8px 10px;
        cursor: pointer;
        font: inherit;
    }

    .exportBtnAction:hover {
        background: rgba(255, 255, 255, .12);
    }

    .exportBtnAction.primary {
        background: rgba(80, 180, 255, .18);
        border-color: rgba(80, 180, 255, .45);
    }

    .exportBtnAction.primary:hover {
        background: rgba(80, 180, 255, .28);
    }

    #exportHint {
        opacity: .72;
        margin-top: 10px;
    }

    #exportStatus {
        margin-top: 10px;
        min-height: 18px;
        opacity: .92;
        font-variant-numeric: tabular-nums;
    }