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


:root {
    --bg: #0c0a08;
    --surface: #14110d;
    --surface2: #1c1813;
    --border: rgba(255,196,130,0.08);
    --border-hover: rgba(255,196,130,0.18);
    --text: #f1e7d6;
    --text-muted: #8f8270;
    --text-dim: #5d5346;
    --accent: #ff7a1a;
    --accent-hover: #ff8f3d;
    --accent-glow: rgba(255,122,26,0.12);
    --gold: #f7c44d;
    --pink: #e05090;
    --purple: #9055e0;
    --green: #3fd06c;
    --radius: 10px;
    --radius-lg: 16px;
    --panel-w: 380px;
    --font: 'Schibsted Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Bricolage Grotesque', var(--font);
    --font-pixel: 'Silkscreen', monospace;
    /* BlockTool design system aliases */
    --coal: #14110d;
    --slate: #1c1813;
    --slate-2: #262019;
    --seam: rgba(255,196,130,0.10);
    --seam-strong: rgba(255,196,130,0.22);
    --bone: #c9bba4;
    --ember: #ff7a1a;
    --ember-hot: #ffa040;
    --emerald: #3fd06c;
    --diamond: #5ad2e6;
    /* stepped "pixel" corners */
    --pixel-clip: polygon(0 6px,3px 6px,3px 3px,6px 3px,6px 0,calc(100% - 6px) 0,calc(100% - 6px) 3px,calc(100% - 3px) 3px,calc(100% - 3px) 6px,100% 6px,100% calc(100% - 6px),calc(100% - 3px) calc(100% - 6px),calc(100% - 3px) calc(100% - 3px),calc(100% - 6px) calc(100% - 3px),calc(100% - 6px) 100%,6px 100%,6px calc(100% - 3px),3px calc(100% - 3px),3px calc(100% - 6px),0 calc(100% - 6px));
    --pixel-clip-sm: polygon(0 4px,2px 4px,2px 2px,4px 2px,4px 0,calc(100% - 4px) 0,calc(100% - 4px) 2px,calc(100% - 2px) 2px,calc(100% - 2px) 4px,100% 4px,100% calc(100% - 4px),calc(100% - 2px) calc(100% - 4px),calc(100% - 2px) calc(100% - 2px),calc(100% - 4px) calc(100% - 2px),calc(100% - 4px) 100%,4px 100%,4px calc(100% - 2px),2px calc(100% - 2px),2px calc(100% - 4px),0 calc(100% - 4px));
}

html { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100%;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── App Shell ───────────────────────────────────── */
#app-shell {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ── Viewport (always full-screen) ───────────────── */
#viewport {
    position: absolute;
    inset: 0;
    background: var(--bg);
    overflow: hidden;
    z-index: 1;
}

.voxel-marquee-selection {
    position: absolute;
    z-index: 90;
    pointer-events: none;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: rgba(255, 122, 26, 0.14);
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.28),
        0 0 18px rgba(255, 122, 26, 0.16);
}

.voxel-marquee-selection[data-mode="add"] {
    border-color: var(--green);
    background: rgba(61, 186, 110, 0.16);
}

.voxel-marquee-selection[data-mode="subtract"] {
    border-color: var(--pink);
    background: rgba(224, 80, 144, 0.16);
}

#dropzone {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 48px 40px;
    border: 2px dashed rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(8px);
    z-index: 5;
}
#dropzone.dragover { border-color: var(--accent); background: var(--accent-glow); }
#dropzone.hidden { display: none; }

.dropzone-text { font-size: 16px; color: var(--text-muted); font-weight: 500; }
.dropzone-sub { margin-top: 8px; font-size: 13px; color: var(--text-dim); }

.viewport-toolbar {
    position: absolute;
    top: 12px; left: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(12px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    z-index: 100;
}

.control-btn {
    padding: 6px 14px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}
.control-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.control-btn.active { background: var(--accent); color: #000; }
.control-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}
.control-btn:disabled:hover {
    background: transparent;
    color: var(--text-muted);
}
.history-btn {
    min-width: 62px;
}

.toggle-btn {
    padding: 6px 14px;
    background: var(--gold);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}
.toggle-btn:hover { filter: brightness(1.15); }

#status {
    position: absolute;
    bottom: 12px; left: 12px;
    padding: 6px 12px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    z-index: 100;
}

/* ── Creation Card (centered overlay) ────────────── */
#creation-card {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 440px;
    background: rgba(20, 20, 22, 0.92);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    z-index: 50;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.03);
}
#creation-card.hidden { display: none; }

.creation-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
    color: var(--text);
}

.creation-subtitle {
    font-size: 14px;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 24px;
}

/* Type selector tabs */
.type-selector {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.type-tab {
    flex: 1;
    padding: 10px 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.type-tab:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.type-tab.active { background: var(--accent); color: #000; }

.size-selector {
    margin-bottom: 16px;
}
.size-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.size-input {
    width: 56px;
    padding: 8px 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    -moz-appearance: textfield;
}
.size-input::-webkit-inner-spin-button,
.size-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.size-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.size-x {
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 600;
}
.size-label {
    color: var(--text-dim);
    font-size: 13px;
}

/* ── Controls Panel / Sidebar (bottom sheet mobile, side panel desktop) ── */
#sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    max-height: 38vh;
    background: rgba(20, 20, 22, 0.95);
    backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    transform: translateY(calc(100% - 56px));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: none;
}
#sidebar.hidden { display: none; }
#sidebar.sheet-half { transform: translateY(0); }
#sidebar.sheet-full { transform: translateY(0); }
#sidebar.sheet-collapsed { transform: translateY(calc(100% - 56px)); }

/* Drag handle */
.panel-handle {
    width: 100%;
    padding: 12px 0 8px;
    display: flex;
    justify-content: center;
    cursor: grab;
    flex-shrink: 0;
    border: 0;
    background: transparent;
    appearance: none;
}
.panel-handle::before {
    content: '';
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

/* Panel header */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px 12px;
    flex-shrink: 0;
}

.panel-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

/* Stepper — mobile: labeled tab pills; desktop: dots+lines */
.stepper {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.stepper-dot {
    flex: 1;
    padding: 6px 0;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-align: center;
}
.stepper-dot::after {
    content: attr(data-label);
}
.stepper-dot.active {
    border-color: var(--accent);
    background: rgba(255, 122, 26, 0.1);
    color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}
.stepper-dot.completed {
    border-color: var(--green);
    color: var(--green);
    background: rgba(0, 200, 83, 0.06);
}

.stepper-line {
    display: none;
}

.stepper-label {
    display: none;
}

/* Advanced toggle */
.advanced-toggle {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.advanced-toggle:hover { border-color: var(--border-hover); color: var(--text); }
.advanced-toggle.active { border-color: var(--accent); color: var(--accent); }

.save-btn {
    min-width: 96px;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text-muted);
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.top-save-btn {
    margin-left: 8px;
}
.top-prompt-btn {
    min-width: 118px;
}
.save-btn.clean {
    border-color: rgba(61, 186, 110, 0.35);
    color: var(--green);
}
.save-btn.dirty {
    background: var(--accent);
    border-color: var(--accent);
    color: #00110f;
    box-shadow: 0 0 12px var(--accent-glow);
}
.save-btn.saving {
    border-color: var(--accent);
    color: var(--accent);
}
.save-btn.error {
    border-color: var(--pink);
    color: var(--pink);
}
.save-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}
.save-status {
    min-width: 0;
    color: var(--text-muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.top-save-status {
    max-width: 180px;
    align-self: center;
}

/* Panel body */
.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 16px;
    -webkit-overflow-scrolling: touch;
}

/* Hide back button and settings on mobile — tabs handle navigation */
@media (max-width: 1023px) {
    :root { --mobile-sheet-peek: 78px; }

    .sidebar-header { display: none !important; }
    #tabNavigation { display: none !important; }
}

/* ── Simple/Advanced Mode ────────────────────────── */
[data-mode="simple"] [data-advanced] { display: none !important; }

/* ── Type-aware exports ──────────────────────────── */
[data-type="block"] .entity-only,
[data-type="block"] .item-only { display: none !important; }
[data-type="entity"] .block-only,
[data-type="entity"] .item-only { display: none !important; }
[data-type="item"] .block-only,
[data-type="item"] .entity-only { display: none !important; }

/* ── Sidebar header (inside scroll, only for settings gear) ── */
.sidebar-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 8px;
}

.logo-link {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.icon-btn {
    width: 34px; height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: grid; place-items: center;
    transition: all 0.15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border-hover); }

/* Settings drawer */
.settings-drawer {
    padding: 12px;
    background: var(--surface2);
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.api-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}

.api-row input { flex: 1; min-width: 0; }

.api-badge {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--text-dim);
}

/* ── Back button ─────────────────────────────────── */
.back-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--accent);
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 14px;
    text-align: left;
    margin-bottom: 16px;
    transition: all 0.15s;
}
.back-btn:hover { background: rgba(255,122,26,0.06); border-color: var(--accent); }

/* ── Tabs ────────────────────────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Generate Tab ────────────────────────────────── */
.prompt-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prompt-section textarea {
    width: 100%;
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s;
}
.prompt-section textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.prompt-section textarea::placeholder { color: var(--text-dim); }

.btn-generate {
    font-size: 15px;
    padding: 14px;
    border-radius: var(--radius);
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Progress */
.progress-section {
    margin-top: 12px;
    padding: 14px;
    background: var(--surface2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.minecraft-loading {
    padding: 16px;
    background: rgba(21, 24, 25, 0.96);
    border-color: rgba(255,255,255,0.09);
}

.minecraft-loader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.loader-mosaic {
    display: grid;
    grid-template-columns: repeat(5, 14px);
    grid-auto-rows: 14px;
    gap: 3px;
    padding: 7px;
    background: rgba(0,0,0,0.24);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
}

.loader-block {
    width: 14px;
    height: 14px;
    border: 1px solid rgba(0,0,0,0.28);
    box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.18),
        inset 0 -2px 0 rgba(0,0,0,0.22);
    image-rendering: pixelated;
    animation: loader-step 1.4s steps(2, end) infinite;
}

.loader-block:nth-child(2n) { animation-delay: 0.15s; }
.loader-block:nth-child(3n) { animation-delay: 0.3s; }
.loader-block:nth-child(5n) { animation-delay: 0.45s; }

.loader-sky { background: #63a3d7; }
.loader-grass { background: #4fb45d; }
.loader-leaf { background: #287a43; }
.loader-dirt { background: #7a5435; }
.loader-stone { background: #7a8287; }
.loader-ore { background: #d7ad45; }

.loader-ascii {
    margin: 0;
    color: rgba(237,237,239,0.72);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    line-height: 1.2;
    text-align: right;
    white-space: pre;
    text-shadow: 0 0 10px rgba(255,122,26,0.18);
}

@keyframes loader-step {
    0%, 100% {
        opacity: 0.72;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.progress-bar-track {
    height: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar-fill {
    height: 100%;
    width: 30%;
    background: var(--accent);
    border-radius: 2px;
    animation: progress-pulse 1.5s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.58; }
}

.loading-status-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.progress-phase { font-size: 13px; color: var(--accent); }
.progress-elapsed {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--text-dim);
}
#generatePreview { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    .progress-bar-fill,
    .loader-block {
        animation: none;
    }
}

/* Divider */
.divider-or {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 12px;
    color: var(--text-dim);
    font-size: 12px;
}
.divider-or::before, .divider-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.alt-action {
    display: block;
    text-align: center;
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
    padding: 6px 0;
    transition: color 0.15s;
}
.alt-action:hover { color: var(--accent-hover); }

/* ── Upload Tab ──────────────────────────────────── */
.upload-section {
    text-align: center;
    padding: 20px 0;
}

.btn-upload {
    width: 100%;
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    background: var(--surface2);
    border: 2px dashed var(--border-hover);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-upload:hover { border-color: var(--accent); background: var(--accent-glow); }

.upload-hint { font-size: 12px; color: var(--text-dim); margin-top: 8px; }

/* Gallery */
.gallery-filter {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}
.gallery-filter-btn {
    flex: 1;
    padding: 6px 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
}
.gallery-filter-btn:hover { border-color: var(--border-hover); color: var(--text); }
.gallery-filter-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}
.gallery-grid::-webkit-scrollbar { width: 4px; }
.gallery-grid::-webkit-scrollbar-track { background: transparent; }
.gallery-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.gallery-item {
    aspect-ratio: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px;
    transition: all 0.15s;
    position: relative;
}
.gallery-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255,122,26,0.15); }

.gallery-item-icon {
    font-size: 28px;
    margin-bottom: 2px;
}
.gallery-item-label {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.gallery-item-type {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 8px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.gallery-item-type.block { background: var(--accent); color: #000; }
.gallery-item-type.entity { background: var(--purple); color: #fff; }
.gallery-item-type.item { background: var(--gold); color: #000; }

.gallery-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 12px;
}

.gallery-view-all-btn {
    display: block;
    text-align: center;
    margin-top: 12px;
    padding: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}
.gallery-view-all-btn:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-status {
    padding: 8px 12px;
    margin-top: 10px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
}

.model-info {
    margin: 16px 0;
    padding: 12px;
    background: var(--surface2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ── Cards ───────────────────────────────────────── */
.card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.card h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 10px;
}

.card-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Details/collapsible */
.card-details {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.card-details summary {
    padding: 12px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    list-style: none;
    user-select: none;
}
.card-details summary::before {
    content: '\25B6';
    display: inline-block;
    margin-right: 8px;
    font-size: 10px;
    transition: transform 0.2s;
}
.card-details[open] summary::before { transform: rotate(90deg); }
.card-details summary::-webkit-details-marker { display: none; }
.details-body { padding: 0 14px 14px; }

/* Blockbench-style studio dock */
.editor-studio {
    display: grid;
    gap: 12px;
    min-width: 0;
    overflow: hidden;
}

.editor-studio,
.editor-studio * {
    box-sizing: border-box;
}

.editor-studio > *,
.studio-panel,
.studio-panel > *,
.studio-panel .btn-row > * {
    min-width: 0;
}

.studio-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.studio-header > div {
    min-width: 0;
}

.studio-header h3 {
    margin-bottom: 3px;
}

.studio-header p,
.studio-note,
.studio-display-summary {
    margin: 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
}

.studio-mode-badge {
    flex: 0 1 auto;
    max-width: 82px;
    overflow: hidden;
    padding: 4px 7px;
    border-radius: 6px;
    background: rgba(255, 122, 26, 0.12);
    border: 1px solid rgba(255, 122, 26, 0.28);
    color: var(--accent);
    font-size: 10px;
    font-weight: 800;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.studio-mode-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 8px;
}

.studio-mode-btn,
.studio-display-btn {
    min-height: 32px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.studio-mode-btn:hover,
.studio-display-btn:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.studio-mode-btn.active,
.studio-display-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.studio-panel {
    display: none;
    gap: 10px;
    overflow-x: hidden;
}

.studio-panel.active {
    display: grid;
}

.studio-panel-head,
.studio-outliner-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.studio-panel-head span {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-panel-head strong {
    min-width: 0;
    overflow: hidden;
    color: var(--accent);
    font-size: 12px;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-outliner-list,
.studio-animation-presets {
    display: grid;
    gap: 6px;
}

.studio-outliner-row {
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.studio-outliner-row:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.04);
}

.studio-outliner-row.active {
    border-color: rgba(255, 122, 26, 0.5);
    background: rgba(255, 122, 26, 0.1);
}

.studio-outliner-row:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.studio-outliner-row span,
.studio-outliner-row small {
    display: block;
    min-width: 0;
}

.studio-outliner-row span {
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
}

.studio-outliner-row small {
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.3;
}

.studio-palette {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 5px;
}

.studio-color-chip {
    aspect-ratio: 1;
    min-width: 0;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: var(--chip-color);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.24);
}

.studio-empty {
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 11px;
    text-align: center;
}

.studio-texture-editor {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-uv-editor {
    display: grid;
    gap: 8px;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-uv-editor canvas {
    width: 100%;
    min-height: 86px;
    max-height: 148px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background:
        linear-gradient(45deg, rgba(255,255,255,0.05) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,0.05) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.05) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.05) 75%);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
    image-rendering: pixelated;
    object-fit: contain;
}

.studio-uv-input-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.studio-uv-input-grid label,
.studio-uv-rotate-row label {
    display: grid;
    gap: 3px;
    min-width: 0;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.studio-uv-input-grid input,
.studio-uv-rotate-row select {
    width: 100%;
    min-width: 0;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.22);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    padding: 0 7px;
}

.studio-uv-rotate-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.studio-uv-nudge-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.studio-texture-atlas {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-texture-atlas canvas {
    width: 100%;
    min-height: 72px;
    max-height: 160px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background:
        linear-gradient(45deg, rgba(255,255,255,0.05) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,0.05) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.05) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.05) 75%);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
    image-rendering: pixelated;
    object-fit: contain;
}

.studio-face-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.studio-face-btn {
    min-height: 32px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
}

.studio-face-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.studio-face-btn.active {
    border-color: var(--accent);
    background: rgba(255, 122, 26, 0.12);
    color: var(--accent);
}

.studio-texture-color-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
}

.studio-texture-color-row input[type="color"] {
    width: 100%;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.24);
    padding: 2px;
}

.studio-texture-editor .btn-row {
    flex-wrap: wrap;
}

.studio-texture-editor .btn-row > * {
    flex: 1 1 68px;
}

.studio-uv-editor .btn-row {
    flex-wrap: wrap;
}

.studio-uv-editor .btn-row > * {
    flex: 1 1 72px;
}

.studio-validation-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.studio-export-plan {
    display: grid;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-export-plan-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.studio-export-plan-metric,
.studio-validation-metric {
    min-width: 0;
}

.studio-export-plan-metric {
    display: grid;
    gap: 2px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.18);
}

.studio-export-plan-metric span,
.studio-export-file-group span {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.studio-export-plan-metric strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-export-plan-files {
    display: grid;
    gap: 6px;
}

.studio-export-file-group {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.studio-export-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 0;
}

.studio-export-file-chip {
    display: block;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.22);
    color: var(--text);
    font-size: 10px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-export-file-list .studio-export-file-chip,
.studio-export-dry-run-list .studio-export-file-chip {
    flex: 1 1 112px;
}

.studio-export-plan-notes {
    display: grid;
    gap: 4px;
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1.35;
}

.studio-export-note {
    min-width: 0;
    padding: 6px;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.16);
}

.studio-export-note.ready {
    color: var(--green);
}

.studio-export-note.review {
    color: #ffb84d;
}

.studio-export-note.blocked {
    color: #ff6b6b;
}

.studio-export-dry-run {
    display: none;
    min-width: 0;
    overflow: hidden;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1.35;
}

.studio-export-dry-run.has-result {
    display: grid;
    gap: 7px;
}

.studio-export-dry-run.ready {
    border-color: rgba(255, 122, 26, 0.35);
}

.studio-export-dry-run.review,
.studio-export-dry-run.running {
    border-color: rgba(255, 184, 77, 0.35);
}

.studio-export-dry-run.blocked {
    border-color: rgba(255, 107, 107, 0.45);
}

.studio-export-dry-run-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.studio-export-dry-run-head span {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-export-dry-run-head strong {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.studio-export-dry-run.ready .studio-export-dry-run-head strong {
    color: var(--green);
}

.studio-export-dry-run.review .studio-export-dry-run-head strong,
.studio-export-dry-run.running .studio-export-dry-run-head strong {
    color: #ffb84d;
}

.studio-export-dry-run.blocked .studio-export-dry-run-head strong {
    color: #ff6b6b;
}

.studio-export-dry-run-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
    gap: 5px;
}

.studio-export-dry-run-entry {
    min-width: 0;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-export-dry-run-entry span,
.studio-export-dry-run-list-title {
    display: block;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.studio-export-dry-run-entry strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-export-pack-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 6px;
    min-width: 0;
}

.studio-export-pack-card {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.035);
}

.studio-export-pack-card strong,
.studio-export-pack-card span,
.studio-export-pack-card small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-export-pack-card strong {
    color: var(--text);
    font-size: 10px;
}

.studio-export-pack-card span {
    color: var(--text-dim);
    font-size: 10px;
}

.studio-export-pack-card small {
    color: var(--green);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.studio-export-dry-run-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 0;
}

.studio-export-dry-run-message {
    min-width: 0;
    padding: 6px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-export-dry-run-message.blocked {
    color: #ff8f8f;
}

.studio-export-dry-run-message.review {
    color: #ffcf7a;
}

.studio-validation-status.ready {
    color: var(--green);
}

.studio-validation-status.review {
    color: #ffb84d;
}

.studio-validation-status.blocked {
    color: var(--danger);
}

.studio-validation-metric {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
}

.studio-validation-metric span {
    color: var(--text-dim);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.studio-validation-metric strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-validation-list {
    display: grid;
    gap: 6px;
}

.studio-validation-issue {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: flex-start;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
}

.studio-validation-issue::before {
    content: "";
    width: 8px;
    height: 8px;
    margin-top: 4px;
    border-radius: 999px;
    background: var(--text-dim);
}

.studio-validation-issue strong,
.studio-validation-issue span {
    display: block;
    min-width: 0;
}

.studio-validation-issue strong {
    color: var(--text);
    font-size: 12px;
}

.studio-validation-issue span {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.35;
}

.studio-validation-issue.error {
    border-color: rgba(244, 67, 54, 0.45);
    background: rgba(244, 67, 54, 0.08);
}

.studio-validation-issue.error::before {
    background: var(--danger);
}

.studio-validation-issue.warning {
    border-color: rgba(255, 184, 77, 0.4);
    background: rgba(255, 184, 77, 0.08);
}

.studio-validation-issue.warning::before {
    background: #ffb84d;
}

.studio-validation-issue.pass {
    border-color: rgba(61, 186, 110, 0.36);
    background: rgba(61, 186, 110, 0.08);
}

.studio-validation-issue.pass::before {
    background: var(--green);
}

.studio-animation-chip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.studio-animation-chip input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.studio-animation-chip strong,
.studio-animation-chip span {
    display: block;
}

.studio-animation-chip strong {
    color: var(--text);
    font-size: 12px;
}

.studio-animation-chip span {
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.35;
}

.studio-animation-chip.active {
    border-color: rgba(255, 122, 26, 0.45);
    background: rgba(255, 122, 26, 0.08);
}

.studio-animation-chip.custom {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0;
    overflow: hidden;
}

.studio-animation-chip.custom small {
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 900;
}

.studio-custom-animation {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.studio-clip-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.studio-animation-chip.custom.selected {
    box-shadow: inset 3px 0 0 var(--accent);
}

.studio-animation-main {
    min-width: 0;
    min-height: 42px;
    padding: 8px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.studio-animation-main:hover {
    background: rgba(255, 255, 255, 0.04);
}

.studio-animation-main span,
.studio-animation-main strong,
.studio-animation-main small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.studio-animation-main small {
    white-space: nowrap;
}

.studio-animation-delete {
    align-self: center;
    margin-right: 7px;
}

.studio-custom-animation input,
.studio-motion-editor select,
.studio-display-editor select,
.studio-rig-editor input,
.studio-rig-editor select {
    min-height: 32px;
    min-width: 0;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.24);
    color: var(--text);
    font: 600 12px/1 var(--font);
}

.studio-rig-editor {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-bone-list {
    display: grid;
    gap: 6px;
    max-height: 180px;
    overflow: auto;
    padding-right: 2px;
}

.studio-bone-chip {
    --bone-depth: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 34px;
    padding: 7px 9px 7px calc(9px + (var(--bone-depth) * 14px));
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.18);
    color: var(--text);
    text-align: left;
}

.studio-bone-chip.has-parent::before {
    content: "";
    position: absolute;
    left: calc(8px + ((var(--bone-depth) - 1) * 14px));
    width: 8px;
    height: 1px;
    background: var(--text-dim);
    opacity: 0.6;
}

.studio-bone-chip:hover {
    border-color: var(--border-hover);
}

.studio-bone-chip.active {
    border-color: rgba(255, 122, 26, 0.5);
    background: rgba(255, 122, 26, 0.1);
}

.studio-bone-chip.is-hidden {
    opacity: 0.58;
}

.studio-bone-chip.is-locked {
    border-style: dashed;
}

.studio-bone-chip span {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-bone-chip small {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--text-dim);
    font-size: 9px;
    font-weight: 800;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.studio-bone-transform-tools {
    display: grid;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.studio-bone-transform-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.studio-bone-transform-header label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.studio-bone-transform-header input {
    width: 48px;
    min-height: 28px;
    padding: 4px 6px;
    font-size: 12px;
    text-align: center;
}

.studio-motion-editor {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-animation-track-editor {
    display: grid;
    gap: 7px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.studio-animation-track-list {
    display: grid;
    gap: 5px;
    max-height: 112px;
    overflow: auto;
    padding-right: 2px;
}

.studio-animation-track-btn {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-height: 36px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.studio-animation-track-btn:hover {
    border-color: var(--border-hover);
}

.studio-animation-track-btn.active {
    border-color: rgba(255, 122, 26, 0.58);
    background: rgba(255, 122, 26, 0.1);
    box-shadow: inset 3px 0 0 var(--accent);
}

.studio-animation-track-btn span,
.studio-animation-track-btn small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-animation-track-btn div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.studio-animation-track-btn span {
    font-size: 12px;
    font-weight: 900;
}

.studio-animation-track-btn small {
    color: var(--text-dim);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.studio-animation-track-btn strong {
    color: var(--accent);
    font-size: 11px;
    font-weight: 900;
}

.studio-motion-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 8px;
    align-items: center;
}

.studio-keyframe-editor {
    display: grid;
    gap: 6px;
    padding-top: 2px;
}

.studio-keyframe-head {
    display: grid;
    grid-template-columns: minmax(36px, auto) minmax(0, 1fr);
    gap: 6px;
}

.studio-keyframe-head span {
    min-width: 36px;
    overflow: visible;
    text-overflow: clip;
}

.studio-keyframe-head button {
    justify-self: end;
    min-width: 0;
    padding-inline: 10px;
}

.studio-keyframe-list {
    display: grid;
    gap: 5px;
}

.studio-keyframe-row {
    display: grid;
    grid-template-columns: 0.85fr repeat(3, 1fr) 28px;
    gap: 5px;
    align-items: center;
    min-height: 30px;
    border-radius: 6px;
}

.studio-keyframe-row.active {
    background: rgba(255, 122, 26, 0.08);
    box-shadow: inset 3px 0 0 var(--accent);
}

.studio-keyframe-row input {
    min-width: 0;
    height: 30px;
    padding: 0 3px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.24);
    color: var(--text);
    font: 700 10px/1 var(--font);
    text-align: center;
}

.studio-keyframe-row input::-webkit-outer-spin-button,
.studio-keyframe-row input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.studio-keyframe-row input[type="number"] {
    appearance: textfield;
}

.studio-keyframe-remove {
    width: 28px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 900;
}

.studio-keyframe-remove:hover {
    border-color: var(--pink);
    color: var(--pink);
}

.studio-keyframe-remove:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.studio-animation-timeline {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
}

.studio-timeline-track {
    position: relative;
    height: 36px;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px) 0 0 / 25% 100%,
        rgba(0, 0, 0, 0.22);
    cursor: pointer;
}

.studio-timeline-track:focus-visible {
    outline: 2px solid rgba(255, 122, 26, 0.65);
    outline-offset: 2px;
}

.studio-timeline-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: linear-gradient(90deg, rgba(255, 122, 26, 0.2), rgba(255, 122, 26, 0.04));
    pointer-events: none;
}

.studio-timeline-cursor {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0%;
    width: 2px;
    border-radius: 99px;
    background: var(--accent);
    box-shadow: 0 0 12px rgba(255, 122, 26, 0.65);
    transform: translateX(-1px);
    pointer-events: none;
    z-index: 2;
}

.studio-timeline-markers {
    position: absolute;
    inset: 0;
    z-index: 3;
}

.studio-timeline-marker {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 18px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    background: var(--panel);
    color: transparent;
    transform: translate(-50%, -50%);
    cursor: pointer;
    touch-action: none;
}

.studio-timeline-marker::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 2px;
    background: var(--text-muted);
}

.studio-timeline-marker:hover {
    border-color: var(--accent);
}

.studio-timeline-marker:active,
.studio-timeline-dragging .studio-timeline-marker.active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.08);
}

.studio-timeline-marker.active {
    border-color: var(--accent);
    background: rgba(255, 122, 26, 0.18);
}

.studio-timeline-marker.active::after {
    background: var(--accent);
}

.studio-animation-preview {
    display: grid;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.studio-animation-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.studio-animation-preview-header strong {
    color: var(--accent);
    font-size: 12px;
}

.studio-animation-preview input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.studio-animation-chip.custom span small {
    display: block;
    margin-top: 2px;
    color: var(--text-dim);
    font-size: 9px;
    line-height: 1.25;
}

.studio-display-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.studio-display-slots {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
}

.studio-display-slot-btn {
    min-height: 28px;
    padding: 0 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.18);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
}

.studio-display-slot-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.studio-display-slot-btn.active {
    border-color: var(--accent);
    background: rgba(255, 122, 26, 0.12);
    color: var(--accent);
}

.studio-display-editor {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.studio-display-editor .field-label {
    margin-top: 2px;
}

.studio-display-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 0.8fr);
    gap: 6px;
}

.studio-display-toolbar select {
    width: 100%;
}

.studio-display-nudge-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
}

.studio-display-nudge-grid .btn-sm {
    min-height: 28px;
    padding: 5px 4px;
    font-size: 10px;
    font-weight: 800;
}

.compact-transform-row {
    margin-top: 10px;
}

.precision-transform-card {
    display: grid;
    gap: 10px;
}

.transform-nudge-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.transform-nudge-grid button {
    min-height: 32px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 11px;
    font-weight: 800;
}

.transform-nudge-grid button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Buttons ─────────────────────────────────────── */
button {
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: #000;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: var(--surface2); color: var(--text-dim); cursor: not-allowed; }

.btn-secondary {
    width: 100%;
    padding: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
}
.btn-secondary:hover { border-color: var(--border-hover); background: rgba(255,255,255,0.04); }
.btn-secondary.active { border-color: rgba(255, 122, 26, 0.5); background: rgba(255, 122, 26, 0.1); color: var(--accent); }
.btn-secondary:disabled { color: var(--text-dim); cursor: not-allowed; }

.btn-sm { padding: 7px 12px; font-size: 12px; }

.btn-accent-pink { width: 100%; padding: 12px; background: var(--pink); color: #fff; border-radius: var(--radius); font-size: 14px; font-weight: 600; }
.btn-accent-pink:hover { filter: brightness(1.15); }

.btn-accent-purple { width: 100%; padding: 12px; background: var(--purple); color: #fff; border-radius: var(--radius); font-size: 14px; font-weight: 600; }
.btn-accent-purple:hover { filter: brightness(1.15); }

.btn-stack { display: flex; flex-direction: column; gap: 8px; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }

.btn-icon-sm {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    display: grid; place-items: center;
}

/* ── Form Fields ─────────────────────────────────── */
.field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="number"], input[type="text"], select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    transition: border-color 0.15s;
}
input[type="number"]:focus, input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='%238b8b8f' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
}
input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
}

.color-picker-input {
    width: 100%;
    height: 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: var(--bg);
}

/* XYZ row */
.xyz-row { display: flex; gap: 8px; }
.xyz-field { flex: 1; }
.xyz-field label { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; display: block; text-align: center; }
.xyz-field input { text-align: center; }

/* Slider field */
.slider-field { margin-bottom: 12px; }
.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 6px;
}
.slider-header span:first-child { color: var(--text-muted); }
.slider-header span:last-child { color: var(--accent); font-weight: 600; }

/* Target elements row */
.target-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.target-row input[type="number"] {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
}
.target-row input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}
.btn-find {
    padding: 8px 16px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn-find:hover { opacity: 0.85; }

/* Live cuboid count */
.merge-count {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    text-align: right;
    margin-top: 4px;
}

/* Algorithm dropdown */
.algo-select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    cursor: pointer;
}
.algo-select:focus { outline: none; border-color: var(--accent); }

.slider-combo { display: flex; gap: 8px; align-items: center; }
.slider-combo input[type="number"] { width: 60px; flex-shrink: 0; }
.slider-combo input[type="range"] { flex: 1; }

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 8px;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] { margin: 0; accent-color: var(--accent); }

/* Info rows */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}
.info-row + .info-row { border-top: 1px solid var(--border); }
.info-label { color: var(--text-muted); }
.info-value { color: var(--text); font-weight: 500; }

/* Status message */
.status-msg {
    margin-top: 10px;
    padding: 10px;
    border-radius: var(--radius);
    font-size: 13px;
    text-align: center;
}
.status-msg.success, .status-message.success { background: rgba(61,186,110,0.12); color: var(--green); border: 1px solid rgba(61,186,110,0.25); }
.status-msg.error, .status-message.error { background: rgba(224,80,144,0.12); color: var(--pink); border: 1px solid rgba(224,80,144,0.25); }
.status-msg.loading, .status-message.loading { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(255,122,26,0.25); }

/* ── Sub-tabs ────────────────────────────────────── */
.sub-tab-buttons { display: flex; gap: 4px; margin-bottom: 12px; }

.sub-tab-btn {
    flex: 1;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}
.sub-tab-btn:hover { background: var(--surface2); }
.sub-tab-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

.sub-tab-content { display: none; }
.sub-tab-content.active { display: block; }

/* Paint tools */
.paint-tools { display: flex; gap: 4px; margin-bottom: 10px; }
.paint-tool-btn {
    flex: 1;
    padding: 8px 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 12px;
}
.paint-tool-btn:hover { border-color: var(--border-hover); }
.paint-tool-btn.active { background: var(--pink); color: #fff; border-color: var(--pink); }

/* Edit voxel tools (reuse paint-tools layout) */
.voxel-edit-card {
    display: grid;
    gap: 10px;
}

.voxel-tool-section {
    display: grid;
    gap: 8px;
    padding: 10px;
    background: rgba(255,255,255,0.026);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
}

.voxel-tool-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.voxel-tool-heading strong {
    min-width: 54px;
    max-width: 58%;
    padding: 3px 7px;
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent);
    font-size: 10px;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edit-tools {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.edit-tool-btn {
    min-width: 0;
    flex: 1;
    min-height: 34px;
    padding: 8px 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 12px;
}
.edit-tool-btn:hover { border-color: var(--border-hover); }
.edit-tool-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

.selection-tools {
    display: grid;
    gap: 8px;
    padding: 10px;
    background: rgba(56, 189, 248, 0.045);
    border: 1px solid rgba(56, 189, 248, 0.18);
    border-radius: 8px;
}

.selection-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 12px;
}

.selection-summary strong {
    min-width: 34px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.14);
    color: var(--accent);
    text-align: center;
    font-size: 12px;
}

.selection-click-mode {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.14);
}

.selection-mode-btn {
    min-width: 0;
    min-height: 30px;
    padding: 6px 4px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.selection-mode-btn:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.selection-mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.selection-inspector {
    display: grid;
    gap: 8px;
    padding: 9px;
    background: rgba(2, 6, 23, 0.32);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.selection-inspector-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.selection-inspector-head strong {
    max-width: 58%;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    text-align: right;
    overflow-wrap: anywhere;
}

.selection-inspector-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.selection-inspector-metric {
    min-width: 0;
    min-height: 44px;
    display: grid;
    align-content: center;
    gap: 2px;
    padding: 7px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 6px;
}

.selection-inspector-metric span {
    color: var(--text-dim);
    font-size: 10px;
    line-height: 1.2;
    text-transform: uppercase;
}

.selection-inspector-metric strong {
    color: var(--text);
    font-size: 12px;
    line-height: 1.25;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.selection-inspector-note {
    min-height: 17px;
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.selection-clipboard-status {
    min-height: 18px;
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1.35;
}

/* Friendly voxel editor: keep the everyday path short and reveal depth only on request. */
.voxel-edit-card {
    gap: 14px;
}

.voxel-editor-intro {
    display: grid;
    gap: 5px;
}

.voxel-editor-intro > div {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 10px;
}

.voxel-editor-intro h3 {
    margin: 0;
    color: var(--text);
    font-size: 18px;
}

.voxel-editor-intro p,
.voxel-action-hint,
.selection-friendly-help {
    margin: 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.45;
}

.voxel-editor-kicker {
    order: 2;
    padding: 3px 7px;
    border-radius: 999px;
    color: #ffd3a5;
    background: rgba(255, 122, 26, 0.13);
    font-family: var(--font-pixel);
    font-size: 7px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.voxel-edit-card > .voxel-tool-section,
.voxel-edit-card > .selection-tools {
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.095);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
}

.edit-tools {
    gap: 7px;
}

.edit-tool-btn {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    min-height: 62px;
    padding: 7px 3px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.24);
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.edit-tool-btn span {
    font-size: 21px;
    line-height: 1;
}

.edit-tool-btn b {
    font-size: 10px;
    font-weight: 800;
}

.edit-tool-btn:hover {
    transform: translateY(-1px);
}

.edit-tool-btn.active {
    border-color: #ff8a29;
    color: #17100a;
    background: linear-gradient(180deg, #ff9d43, #ff7418);
    box-shadow: 0 5px 14px rgba(255, 106, 17, 0.2);
}

.voxel-action-hint {
    min-height: 31px;
    padding: 8px 9px;
    border-radius: 8px;
    color: #e4d6c7;
    background: rgba(255, 122, 26, 0.07);
}

#editToolSection:not([data-edit-mode="select"]) > .selection-tools {
    display: none;
}

.selection-tools {
    gap: 10px;
}

.selection-summary {
    min-height: 48px;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.045);
}

.selection-summary > span {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 750;
}

.selection-summary strong {
    min-width: 28px;
    padding: 3px 7px;
    color: #fff1e3;
    background: rgba(255, 122, 26, 0.2);
}

.selection-clear-link {
    padding: 5px 7px;
    border: 0;
    color: #ffb16c;
    background: transparent;
    font-size: 10px;
    font-weight: 800;
}

.selection-clear-link:disabled {
    opacity: 0.34;
}

.selection-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.selection-quick-actions button {
    min-height: 36px;
}

.selection-tools:not(.has-selection) .selection-when-selected {
    display: none;
}

.selection-tools:not(.has-selection) #selectAllVoxelsBtn,
.selection-quick-actions .selection-danger {
    grid-column: 1 / -1;
}

.selection-danger:not(:disabled) {
    border-color: rgba(255, 103, 92, 0.36);
    color: #ffb5ae;
    background: rgba(255, 83, 70, 0.08);
}

.selection-more {
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.085);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.13);
}

.selection-more > summary {
    position: relative;
    padding: 11px 34px 11px 11px;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
    font-size: 11px;
    font-weight: 800;
}

.selection-more > summary::-webkit-details-marker {
    display: none;
}

.selection-more > summary::after {
    content: '+';
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: #ff9a43;
    font-size: 17px;
    font-weight: 500;
}

.selection-more[open] > summary::after {
    content: '−';
}

.selection-more[open] > summary {
    color: var(--text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.075);
}

.selection-more-content {
    display: grid;
    gap: 9px;
    padding: 10px;
}

.selection-click-mode {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.selection-inspector {
    border-radius: 10px;
}

.selection-inspector-metric {
    min-height: 40px;
}

.friendly-colour-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 750;
}

.friendly-colour-picker .color-picker-input {
    width: 64px;
    min-height: 38px;
    padding: 3px;
    border-radius: 9px;
}

.finish-voxel-edit-btn {
    min-height: 46px;
    margin-top: 2px;
    box-shadow: 0 8px 18px rgba(255, 106, 17, 0.15);
}

.paint-target-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin-top: 8px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
}

.paint-material-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
}

.paint-material-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
}

.paint-material-btn {
    min-height: 32px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 800;
}

.paint-material-btn:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.paint-material-btn.active {
    background: #52c7ec;
    border-color: #52c7ec;
    color: #061318;
}

.match-image-btn {
    border-color: rgba(82, 199, 236, 0.45) !important;
    color: #7edcf5 !important;
}

.match-image-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.paint-target-btn {
    min-height: 30px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
}

.paint-target-btn:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.paint-target-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.paint-menu {
    background: rgba(255, 122, 26, 0.045);
    border-color: rgba(255, 122, 26, 0.18);
}

.paint-menu .voxel-tool-heading strong {
    border-color: rgba(255, 122, 26, 0.28);
    background: rgba(255, 122, 26, 0.08);
    color: var(--accent);
}

.paint-selected-btn {
    width: 100%;
    min-height: 32px;
}

.selection-filter-tools,
.selection-transform-tools,
.selection-precise-tools,
.selection-builder-tools {
    display: grid;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.selection-tool-header,
.selection-transform-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.selection-tool-header {
    min-height: 24px;
    font-weight: 600;
}

.selection-tool-header strong,
.selection-transform-header strong {
    min-width: 44px;
    padding: 3px 7px;
    border: 1px solid rgba(255, 122, 26, 0.28);
    border-radius: 999px;
    background: rgba(255, 122, 26, 0.08);
    color: var(--accent);
    font-size: 10px;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

.selection-mini-label {
    color: var(--text-dim);
    font-size: 10px;
    line-height: 1.2;
    text-transform: uppercase;
}

.selection-transform-header label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.selection-transform-header input {
    width: 48px;
    min-height: 28px;
    padding: 4px 6px;
    font-size: 12px;
    text-align: center;
}

.selection-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.selection-gizmo-grid {
    gap: 6px;
}

.selection-gizmo-btn.active {
    box-shadow: inset 0 0 0 1px rgba(255, 122, 26, 0.24);
}

.selection-bounds-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.selection-axis-scale-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 6px;
    align-items: end;
}

.selection-flip-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.selection-bounds-grid label {
    display: grid;
    gap: 3px;
    color: var(--text-dim);
    font-size: 10px;
}

.selection-bounds-grid input,
.selection-axis-scale-grid input {
    width: 100%;
    min-height: 28px;
    padding: 4px 5px;
    font-size: 12px;
    text-align: center;
}

.selection-axis-scale-grid label {
    display: grid;
    gap: 3px;
    color: var(--text-dim);
    font-size: 10px;
}

.selection-axis-scale-grid button,
.selection-flip-grid button {
    min-height: 30px;
    white-space: nowrap;
}

.selection-transform-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 6px;
    align-items: end;
}

.selection-transform-row label {
    min-width: 0;
    display: grid;
    gap: 3px;
    color: var(--text-dim);
    font-size: 10px;
}

.selection-transform-row input,
.selection-transform-row select {
    width: 100%;
    min-height: 30px;
    padding: 5px 7px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
}

.selection-transform-row button {
    min-height: 30px;
    white-space: nowrap;
}

.selection-transform-row:last-child {
    grid-template-columns: minmax(0, 1fr) auto;
}

.selection-scale-row,
.selection-scale-row:last-child {
    grid-template-columns: minmax(0, 1fr) auto;
}

.selection-builder-shape-row,
.selection-builder-shape-row:last-child {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.selection-pivot-mode-row,
.selection-pivot-mode-row:last-child {
    grid-template-columns: minmax(0, 1fr) auto;
}

.selection-builder-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.selection-builder-options label {
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.2;
}

.selection-builder-options input {
    margin: 0;
    accent-color: var(--accent);
}

.selection-extrude-row,
.selection-extrude-row:last-child {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1fr);
}

.selection-extrude-options {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.selection-extrude-options button {
    min-height: 30px;
    white-space: nowrap;
}

/* Atlas */
#atlasViewport {
    width: 100%;
    height: 160px;
    overflow: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#atlasCanvas { image-rendering: pixelated; cursor: crosshair; }
.atlas-controls { display: flex; gap: 8px; margin-top: 6px; justify-content: center; align-items: center; }
.atlas-zoom-label { font-size: 12px; color: var(--text-dim); }

/* Quick colors */
#quickColorPalette { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.quick-color-swatch {
    width: 22px; height: 22px;
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s;
}
.quick-color-swatch:hover { transform: scale(1.15); border-color: var(--accent); }
.quick-color-swatch.selected { border-color: #fff; box-shadow: 0 0 4px var(--accent); }

/* ── Mobile toggle (bottom pill) ─────────────────── */
.mobile-toggle-btn {
    position: fixed;
    bottom: 16px; left: 50%;
    transform: translateX(-50%);
    padding: 12px 28px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    z-index: 150;
    box-shadow: 0 4px 20px rgba(255,122,26,0.3);
    display: none;
}
.mobile-toggle-btn:hover { background: var(--accent-hover); }

/* ── Export Modals ───────────────────────────────── */
.export-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.export-modal.show { display: flex; }

.export-modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.export-modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.export-modal-header h3 { margin: 0; font-size: 16px; }
.export-modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 22px;
    cursor: pointer;
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 6px;
}
.export-modal-close:hover { background: var(--surface2); color: var(--text); }

.export-modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.export-modal-body .form-group { margin-bottom: 14px; }

.export-modal-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-top: 14px;
}
.export-modal-preview h4 { margin: 0 0 8px; font-size: 13px; color: var(--text-muted); }
.export-modal-preview-item { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.export-modal-preview-item .label { color: var(--text-muted); }
.export-modal-preview-item .value { color: var(--text); font-weight: 500; }

.blocktool-magic-card {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin: 14px 0;
    padding: 11px 12px;
    border: 1px solid rgba(255, 122, 26, 0.48);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(255, 122, 26, 0.15), rgba(103, 232, 249, 0.05));
    cursor: pointer;
}
.blocktool-magic-card img { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; }
.blocktool-magic-card span { display: grid; gap: 3px; }
.blocktool-magic-card strong { color: var(--text); font-size: 13px; }
.blocktool-magic-card small { color: var(--text-muted); font-size: 11px; line-height: 1.4; }
.blocktool-magic-card input { width: 18px; height: 18px; accent-color: var(--accent); }

.export-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.export-modal-footer button { padding: 10px 20px; border-radius: var(--radius); font-size: 14px; }

.detail-rebuild-modal {
    padding: 20px;
    background: rgba(5, 4, 3, 0.76);
}

.detail-rebuild-modal-content {
    width: min(100%, 470px);
    overflow: hidden;
    border-color: rgba(255, 122, 26, 0.38);
    background:
        radial-gradient(circle at 88% 0%, rgba(255, 122, 26, 0.12), transparent 38%),
        var(--surface);
}

.detail-rebuild-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 24px 16px;
}

.detail-rebuild-hero h3 {
    margin: 3px 0 0;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 24px;
    line-height: 1.1;
}

.detail-rebuild-kicker {
    color: var(--accent);
    font-family: var(--font-pixel);
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.detail-rebuild-icon {
    position: relative;
    flex: 0 0 58px;
    width: 58px;
    height: 58px;
    border: 1px solid rgba(255, 122, 26, 0.4);
    border-radius: 14px;
    background: rgba(255, 122, 26, 0.09);
}

.detail-rebuild-icon i {
    position: absolute;
    width: 22px;
    height: 22px;
    background: linear-gradient(145deg, var(--ember-hot), var(--ember));
    box-shadow: inset -3px -3px 0 rgba(92, 38, 4, 0.28);
}

.detail-rebuild-icon i:nth-child(1) { left: 10px; top: 10px; }
.detail-rebuild-icon i:nth-child(2) { right: 8px; top: 18px; }
.detail-rebuild-icon i:nth-child(3) { left: 17px; bottom: 7px; }

.detail-rebuild-body {
    display: grid;
    gap: 16px;
    padding: 4px 24px 22px;
}

.detail-rebuild-body > p {
    margin: 0;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.6;
}

.detail-rebuild-body > p strong { color: var(--text); }

.detail-rebuild-warning {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 14px;
    border: 1px solid rgba(255, 122, 26, 0.28);
    border-radius: 12px;
    background: rgba(255, 122, 26, 0.08);
}

.detail-rebuild-warning > span {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #170a02;
    font-family: var(--font-display);
    font-weight: 800;
}

.detail-rebuild-warning p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.detail-rebuild-warning strong { color: var(--text); }

.detail-rebuild-actions {
    padding: 16px 24px 22px;
}

.detail-rebuild-actions button {
    min-height: 46px;
    font-weight: 700;
}

.detail-rebuild-actions .btn-primary {
    min-width: 160px;
}

@media (max-width: 520px) {
    .detail-rebuild-hero { padding: 20px 18px 14px; }
    .detail-rebuild-body { padding: 4px 18px 18px; }
    .detail-rebuild-actions {
        display: grid;
        grid-template-columns: 1fr;
        padding: 14px 18px 18px;
    }
    .detail-rebuild-actions button { width: 100%; }
    .detail-rebuild-actions .btn-primary { order: -1; }
}

.mcaddon-help-content {
    max-width: 560px;
}

.mcaddon-help-header {
    background: linear-gradient(135deg, rgba(255, 122, 26, 0.14), transparent 70%);
}

.mcaddon-help-heading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mcaddon-help-heading p {
    margin: 0 0 2px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.mcaddon-help-check {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid rgba(255, 122, 26, 0.45);
    border-radius: 12px;
    background: rgba(255, 122, 26, 0.16);
    color: var(--accent);
    font-size: 20px;
    font-weight: 900;
}

.mcaddon-help-body {
    padding-top: 16px;
}

.mcaddon-help-filename {
    margin: 0 0 16px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mcaddon-help-steps {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mcaddon-help-steps li {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.025);
}

.mcaddon-help-step-number {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 9px;
    background: var(--surface2);
    color: var(--accent);
    font-size: 13px;
    font-weight: 900;
}

.mcaddon-help-steps strong {
    display: block;
    margin: 1px 0 4px;
    color: var(--text);
    font-size: 13px;
}

.mcaddon-help-steps p {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.55;
}

.mcaddon-help-steps b {
    color: var(--text);
    font-weight: 700;
}

.mcaddon-help-command-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-top: 10px;
}

.mcaddon-help-magic {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 11px;
    padding: 9px 11px;
    border: 1px solid rgba(255, 122, 26, 0.42);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(255, 122, 26, 0.14), rgba(103, 232, 249, 0.05));
}
.mcaddon-help-magic img { width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; }
.mcaddon-help-magic div { display: grid; gap: 3px; }
.mcaddon-help-magic strong { margin: 0; color: var(--accent); font-family: var(--font-pixel); font-size: 10px; }
.mcaddon-help-magic span { color: #67e8f9; font-family: var(--font-pixel); font-size: 9px; }
.mcaddon-help-fallback-label {
    display: block;
    margin-top: 11px;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mcaddon-help-command-row code {
    min-width: 0;
    overflow-x: auto;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg);
    color: #ffd3b3;
    font-size: 12px;
    white-space: nowrap;
}

.mcaddon-help-command-row button {
    min-width: 64px;
}

.mcaddon-help-note {
    margin-top: 8px !important;
    color: var(--text-dim) !important;
    font-size: 11px !important;
}

.source-image-modal-content {
    max-width: min(920px, 94vw);
}

.source-image-modal-body {
    background: #fff;
    padding: 12px;
}

.source-image-preview {
    display: block;
    width: 100%;
    max-height: 72vh;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
}

.source-image-error {
    margin: 0;
    padding: 16px;
    color: var(--danger);
    background: rgba(244,67,54,0.08);
    border: 1px solid rgba(244,67,54,0.25);
    border-radius: var(--radius);
}

.source-image-open-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.btn-cancel { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-cancel:hover { background: rgba(255,255,255,0.06); }
.btn-export { background: var(--accent); color: #000; }
.btn-export:hover { background: var(--accent-hover); }
.btn-export:disabled { background: var(--surface2); color: var(--text-dim); cursor: not-allowed; }

/* ── Landing Page ────────────────────────────────── */
.landing-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: auto;
    background: var(--bg);
    background-image: radial-gradient(circle at 50% 0%, rgba(255,122,26,0.08), transparent 60%);
}

.landing-container { text-align: center; padding: 40px 20px; max-width: 1100px; width: 100%; }
.landing-header h1 { font-size: 36px; color: var(--text); font-weight: 700; margin-bottom: 8px; letter-spacing: -0.03em; }
.landing-subtitle { font-size: 16px; color: var(--text-muted); margin-bottom: 50px; }

.option-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    max-width: 800px;
    margin: 0 auto 50px;
}

.option-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 28px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.option-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 8px 30px rgba(255,122,26,0.1); }
.option-card.disabled { opacity: 0.4; cursor: not-allowed; }
.option-card.disabled:hover { transform: none; border-color: var(--border); box-shadow: none; }

.option-icon { font-size: 56px; margin-bottom: 4px; }
.option-card h2 { font-size: 20px; color: var(--text); margin: 0; }
.option-card p { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.5; }

.landing-footer { color: var(--text-dim); font-size: 13px; }
.landing-footer p { margin: 0; }

/* ── Viewport panels (used by JS) ────────────────── */
.viewport-panel-bottom-left {
    position: absolute;
    bottom: 50px; left: 10px;
    padding: 12px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    min-width: 200px;
    z-index: 100;
}
.viewport-panel-bottom-right {
    position: absolute;
    bottom: 50px; right: 10px;
    padding: 12px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    min-width: 180px;
    z-index: 100;
}
.viewport-panel-bottom-left h4,
.viewport-panel-bottom-right h4 { font-size: 12px; color: var(--accent); margin: 0 0 8px; font-weight: 600; }

.viewport-compact-input { display: flex; gap: 4px; margin-bottom: 8px; }
.viewport-compact-input label { font-size: 11px; color: var(--text-muted); min-width: 18px; }
.viewport-compact-input input[type="number"] {
    width: 48px; padding: 3px 5px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 4px; color: var(--text); font-size: 11px;
}

.viewport-slider-compact { margin-bottom: 8px; }
.viewport-slider-compact .slider-label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 4px; }
.viewport-slider-compact .slider-label span:first-child { color: var(--text-muted); }
.viewport-slider-compact .slider-label span:last-child { color: var(--accent); }
.viewport-slider-compact input[type="range"] { width: 100%; height: 4px; }

.viewport-checkbox { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text); margin-bottom: 8px; }
.viewport-checkbox input[type="checkbox"] { margin: 0; }

/* Hide removed element references gracefully */
#controls-info { display: none; }

/* ── Desktop (>=1024px) ──────────────────────────── */
@media (min-width: 1024px) {
    #sidebar {
        position: absolute;
        top: 12px; right: 12px; bottom: 12px;
        left: auto;
        width: var(--panel-w);
        max-height: none;
        border-radius: var(--radius-lg);
        border: 1px solid var(--border);
        border-top: 1px solid var(--border);
        transform: none !important;
        z-index: 50;
    }
    #sidebar.hidden { display: none; }

    .panel-handle { display: none; }

    .mobile-toggle-btn { display: none !important; }

    #status { bottom: 12px; }

    .sidebar-scroll { padding: 4px 16px 32px; }

    /* Desktop: restore dot stepper style */
    .stepper { gap: 0; flex: unset; }
    .stepper-dot {
        flex: unset;
        width: 10px; height: 10px;
        padding: 0;
        border-radius: 50%;
        border-width: 2px;
        font-size: 0;
    }
    .stepper-dot::after { content: none; }
    .stepper-dot.active { background: var(--accent); }
    .stepper-dot.completed { background: var(--green); }
    .stepper-line { display: block; width: 24px; height: 2px; background: var(--text-dim); }
    .stepper-line.completed { background: var(--green); }
    .stepper-label { display: inline; font-size: 13px; font-weight: 600; color: var(--text); margin-left: 12px; }
}

/* ── Mobile compact cards & touch-friendly sliders ─ */
@media (max-width: 1023px) {
    .card { padding: 12px; margin-bottom: 8px; }
    .card h3 { font-size: 13px; margin-bottom: 6px; }
    .card-hint { font-size: 11px; margin-top: 4px; }

    /* Bigger slider track */
    input[type="range"] {
        height: 8px;
        border-radius: 4px;
        padding: 12px 0;
        box-sizing: content-box;
        background-clip: content-box;
    }

    /* Bigger thumb for touch */
    input[type="range"]::-webkit-slider-thumb {
        width: 28px; height: 28px;
        border-width: 3px;
    }
    input[type="range"]::-moz-range-thumb {
        width: 28px; height: 28px;
        border-radius: 50%;
        background: var(--accent);
        border: 3px solid var(--bg);
        cursor: pointer;
    }
}

/* ── Small mobile ────────────────────────────────── */
@media (max-width: 480px) {
    #creation-card { padding: 24px 20px; }
    .creation-title { font-size: 20px; }
    .prompt-section textarea { min-height: 60px; font-size: 16px; /* prevent iOS zoom */ }
    .btn-generate { padding: 12px; font-size: 14px; }
    .xyz-row { gap: 4px; }
    .slider-combo input[type="number"] { width: 50px; }
    .studio-display-toolbar { grid-template-columns: 1fr; }
    .studio-display-nudge-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .export-modal-content { width: 95%; max-height: 90vh; }
    .mcaddon-help-steps li { padding: 11px; }
    .mcaddon-help-command-row { grid-template-columns: 1fr; }
    .mcaddon-help-command-row button { width: 100%; }
}

/* ── Forge account chip (top-right wallet) ────────── */
#forgeAccount {
    position: absolute;
    top: 12px; right: 12px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
}
.forge-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 14px;
    background: rgba(12,10,8,0.78);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.forge-chip:hover { border-color: var(--accent); background: rgba(255,122,26,0.08); }
.forge-chip .chip-credits {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--gold);
    letter-spacing: 0.08em;
}
.forge-chip .chip-plan {
    font-family: var(--font-pixel);
    font-size: 8.5px;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}
.forge-chip.chip-signin { color: var(--accent-hover); }

/* ════════════════════════════════════════════════════════════════════════
   BLOCKTOOL STUDIO — design reskin
   Brings the studio chrome in line with the BlockTool Studio design:
   pixel-stepped corners, numbered stepper, slate inspector cards,
   ember pixel buttons/sliders/swatches, floating viewport chrome.
   Layered on top of the base rules; DOM ids & JS bindings untouched.
   ════════════════════════════════════════════════════════════════════════ */

/* ── Viewport ambience: subtle ember vignette behind the model ── */
#viewport {
    background:
        radial-gradient(800px 500px at 50% 32%, rgba(255,196,130,0.04), transparent 70%),
        radial-gradient(1100px 560px at 60% -10%, rgba(255,122,26,0.05), transparent 60%),
        var(--bg);
}

/* ── Inspector / sidebar ── */
#sidebar {
    background: rgba(12,10,8,0.96);
    border-color: var(--seam-strong);
}
@media (min-width: 1024px) {
    #sidebar {
        border: 1px solid var(--seam);
        box-shadow: 0 24px 60px rgba(0,0,0,0.5);
    }
}

/* ── Inspector cards ── */
.card,
.card-details,
.settings-drawer {
    border: none;
    border-radius: 0;
    clip-path: var(--pixel-clip);
    box-shadow: inset 0 0 0 1px var(--seam);
    background: var(--slate);
}
.card h3 { font-family: var(--font-display); font-weight: 700; }
.card-hint { color: var(--text-muted); }

/* ── Primary (ember) buttons ── */
.btn-primary {
    border-radius: 0;
    clip-path: var(--pixel-clip);
    background: linear-gradient(180deg, var(--ember-hot), var(--accent) 55%, #d85f08);
    color: #1b0d02;
    font-family: var(--font-display);
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(255,255,255,0.22);
    box-shadow: 0 0 24px var(--accent-glow);
}
.btn-primary:hover {
    filter: brightness(1.1);
    background: linear-gradient(180deg, var(--ember-hot), var(--accent) 55%, #d85f08);
}
.btn-primary:disabled {
    background: var(--surface2);
    color: var(--text-dim);
    box-shadow: none;
    text-shadow: none;
    filter: none;
}

/* ── Secondary / control / tab buttons ── */
.btn-secondary,
.advanced-toggle,
.control-btn,
.save-btn,
.btn-icon-sm,
.type-tab,
.paint-tool-btn,
.studio-mode-btn,
.studio-display-btn {
    border-radius: 0;
    clip-path: var(--pixel-clip-sm);
}
.btn-secondary {
    background: var(--coal);
    border: none;
    box-shadow: inset 0 0 0 1px var(--seam-strong);
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 700;
}
.btn-secondary:hover { background: var(--slate-2); box-shadow: inset 0 0 0 1px var(--seam-strong); }
.btn-secondary.active { background: rgba(255,122,26,0.1); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }

.btn-sm { font-family: var(--font-display); }

/* Active pill states → ember gradient, dark ink */
.control-btn.active,
.type-tab.active,
.paint-tool-btn.active,
.studio-mode-btn.active {
    background: linear-gradient(180deg, var(--ember-hot), var(--accent));
    color: #1b0d02;
}

/* Paint tool row buttons */
.paint-tool-btn {
    background: var(--coal);
    box-shadow: inset 0 0 0 1px var(--seam-strong);
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--bone);
}

/* ── Viewport floating chrome ── */
.viewport-toolbar {
    border: none;
    border-radius: 0;
    clip-path: var(--pixel-clip-sm);
    background: rgba(12,10,8,0.8);
    box-shadow: inset 0 0 0 1px var(--seam-strong);
}

/* Status pill with live green dot, pixel micro-label */
#status {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 0;
    clip-path: var(--pixel-clip-sm);
    background: rgba(12,10,8,0.7);
    box-shadow: inset 0 0 0 1px var(--seam);
    font-family: var(--font-pixel);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}
#status::before {
    content: '';
    width: 7px;
    height: 7px;
    flex: none;
    background: var(--emerald);
    box-shadow: 0 0 8px var(--emerald);
}

/* ── Creation card ── */
#creation-card {
    border: none;
    border-radius: 0;
    clip-path: var(--pixel-clip);
    background: linear-gradient(170deg, var(--slate), var(--coal) 78%);
    box-shadow: inset 0 0 0 1px var(--seam-strong), 0 30px 70px rgba(0,0,0,0.6);
}
.creation-title { font-family: var(--font-display); }
.type-selector { border-radius: 0; clip-path: var(--pixel-clip-sm); background: #0a0806; }

/* ── Inputs & range sliders ── */
input[type="number"], input[type="text"], select {
    border: none;
    border-radius: 0;
    background: #0a0806;
    box-shadow: inset 0 0 0 1px var(--seam-strong);
}
input[type="number"]:focus, input[type="text"]:focus, select:focus {
    box-shadow: inset 0 0 0 1px var(--accent), 0 0 14px var(--accent-glow);
}
input[type="range"] {
    background: #0a0806;
    border-radius: 2px;
    box-shadow: inset 0 0 0 1px var(--seam-strong);
}
input[type="range"]::-webkit-slider-thumb {
    border-radius: 0;
    clip-path: var(--pixel-clip-sm);
    background: var(--accent);
    border: none;
}
input[type="range"]::-moz-range-thumb {
    border-radius: 0;
    background: var(--accent);
    border: none;
}

/* ── Studio dock chrome ── */
.studio-mode-badge { border-radius: 0; clip-path: var(--pixel-clip-sm); border: none; box-shadow: inset 0 0 0 1px rgba(255,122,26,0.3); }
.studio-mode-tabs { border-radius: 0; clip-path: var(--pixel-clip-sm); background: #0a0806; }
.studio-mode-btn { background: transparent; color: var(--bone); }

/* Color swatches → pixel chips */
.quick-color-swatch,
.studio-palette > * {
    border-radius: 0 !important;
    clip-path: var(--pixel-clip-sm);
}

/* ── Stepper → numbered pixel squares (desktop) ── */
@media (min-width: 1024px) {
    .stepper { counter-reset: step; gap: 3px; flex: unset; }
    .stepper-dot {
        display: flex;
        align-items: center;
        gap: 7px;
        width: auto;
        height: auto;
        flex: unset;
        padding: 0;
        border: none;
        background: none;
        border-radius: 0;
        box-shadow: none;
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 12.5px;
        color: var(--text-dim);
        white-space: nowrap;
    }
    .stepper-dot::before {
        counter-increment: step;
        content: counter(step);
        width: 20px;
        height: 20px;
        flex: none;
        display: grid;
        place-items: center;
        font-family: var(--font-pixel);
        font-size: 9px;
        background: var(--coal);
        color: var(--text-muted);
        box-shadow: inset 0 0 0 1px var(--seam-strong);
        clip-path: var(--pixel-clip-sm);
    }
    .stepper-dot::after { content: ''; }
    .stepper-dot.active::after { content: attr(data-label); }
    .stepper-dot.active,
    .stepper-dot.completed { background: none; }
    .stepper-dot.active { color: var(--text); }
    .stepper-dot.active::before { background: var(--accent); color: #1b0d02; box-shadow: none; }
    .stepper-dot.completed { color: var(--text-muted); }
    .stepper-dot.completed::before {
        content: '\2713';
        background: rgba(63,208,108,0.16);
        color: var(--emerald);
        box-shadow: inset 0 0 0 1px var(--seam-strong);
    }
    .stepper-line { display: block; width: 14px; height: 2px; background: var(--seam-strong); }
    .stepper-line.completed { background: var(--emerald); }
    .stepper-label { display: none; }
}

/* ════════════════════════════════════════════════════════════════════════
   BEDROCK STARTER JOURNEY
   A friendly first-model route layered over the existing editor hooks.
   ════════════════════════════════════════════════════════════════════════ */

:root {
    --text-dim: #827563;
    --homebar-h: 56px;
}

:where(a, button, input, textarea, select, summary):focus-visible {
    outline: 2px solid var(--diamond);
    outline-offset: 3px;
}

button { font-family: inherit; }

.studio-homebar {
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 260;
    height: var(--homebar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    background: linear-gradient(180deg, rgba(12,10,8,0.98), rgba(12,10,8,0.88));
    border-bottom: 1px solid var(--seam);
    backdrop-filter: blur(16px);
}

.studio-homebar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: -0.02em;
}

.studio-homebar-brand strong span { color: var(--accent); }

.studio-homebar-logo {
    width: 28px;
    height: 28px;
    flex: none;
    object-fit: contain;
    image-rendering: pixelated;
}

.studio-homebar-cube {
    position: relative;
    width: 18px;
    height: 18px;
    flex: none;
    background: var(--accent);
    clip-path: var(--pixel-clip-sm);
    box-shadow: 7px -5px 0 rgba(255,160,64,0.28), 7px 5px 0 rgba(137,59,4,0.3);
    transform: rotate(30deg) skew(-5deg);
}

.studio-homebar-product {
    padding-left: 14px;
    border-left: 1px solid var(--seam-strong);
    color: var(--text-muted);
    font-family: var(--font-pixel);
    font-size: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.studio-homebar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.studio-homebar-nav a {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
    font-size: 12px;
    clip-path: var(--pixel-clip-sm);
}

.studio-homebar-nav a:hover {
    color: var(--text);
    background: var(--slate-2);
}

.studio-developer-link { color: var(--text-dim) !important; }

#forgeAccount {
    top: 10px;
    right: 160px;
    z-index: 280;
}

.viewport-toolbar { top: calc(var(--homebar-h) + 10px); }

[data-workflow="start"] .viewport-toolbar { display: none; }
[data-workflow="start"] #dropzone {
    inset: var(--homebar-h) 0 0;
    width: auto;
    height: auto;
    transform: none;
    padding: 0;
    border: 0;
    border-radius: 0;
    background:
        linear-gradient(rgba(255,196,130,0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,196,130,0.035) 1px, transparent 1px),
        radial-gradient(500px 260px at 18% 25%, rgba(255,122,26,0.12), transparent 70%),
        radial-gradient(520px 360px at 82% 72%, rgba(90,210,230,0.06), transparent 72%);
    background-size: 44px 44px, 44px 44px, auto, auto;
    backdrop-filter: none;
}

[data-workflow="start"] #dropzone::before,
[data-workflow="start"] #dropzone::after {
    content: '';
    position: absolute;
    width: 86px;
    height: 86px;
    opacity: 0.14;
    background:
        linear-gradient(var(--accent) 0 0) 0 0 / 28px 28px,
        linear-gradient(var(--accent) 0 0) 58px 0 / 28px 28px,
        linear-gradient(var(--accent) 0 0) 29px 29px / 28px 28px,
        linear-gradient(var(--accent) 0 0) 0 58px / 28px 28px,
        linear-gradient(var(--accent) 0 0) 58px 58px / 28px 28px;
    background-repeat: no-repeat;
    transform: rotate(12deg);
}

[data-workflow="start"] #dropzone::before { left: 6vw; top: 16vh; }
[data-workflow="start"] #dropzone::after { right: 7vw; bottom: 12vh; transform: rotate(-11deg); }
[data-workflow="start"] #dropzone .dropzone-text,
[data-workflow="start"] #dropzone .dropzone-sub { display: none; }

#dropzone.dragover {
    z-index: 240;
    border: 2px dashed var(--accent);
    background: rgba(12,10,8,0.88);
}

#dropzone.dragover .dropzone-text,
#dropzone.dragover .dropzone-sub {
    display: block;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(90%, 520px);
    text-align: center;
}

#dropzone.dragover .dropzone-text { top: 44%; color: var(--text); font: 800 24px/1.2 var(--font-display); }
#dropzone.dragover .dropzone-sub { top: 51%; color: var(--accent); }

/* First model card */
#creation-card {
    top: calc(var(--homebar-h) + 14px);
    left: 50%;
    transform: translateX(-50%);
    width: min(940px, calc(100% - 32px));
    max-width: 940px;
    max-height: calc(100dvh - var(--homebar-h) - 28px);
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--seam-strong) transparent;
    overscroll-behavior: contain;
    background: linear-gradient(150deg, rgba(38,32,25,0.98), rgba(15,12,9,0.99) 72%);
}

.creation-header {
    position: relative;
    padding: 26px 32px 20px;
    border-bottom: 1px solid var(--seam);
    background:
        radial-gradient(340px 180px at 9% 0%, rgba(255,122,26,0.13), transparent 76%),
        rgba(255,255,255,0.015);
}

.creation-eyebrow,
.creation-kicker,
.workflow-intro-step {
    display: block;
    color: var(--accent);
    font-family: var(--font-pixel);
    font-size: 8.5px;
    line-height: 1.4;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.creation-title {
    margin: 5px 0 3px;
    text-align: left;
    font-size: clamp(28px, 4vw, 39px);
    line-height: 1.05;
    letter-spacing: -0.045em;
}

.creation-subtitle {
    max-width: 720px;
    margin: 0;
    color: var(--bone);
    text-align: left;
    font-size: 14px;
    line-height: 1.55;
}

.creation-roadmap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.creation-roadmap li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 700;
}

.creation-roadmap li:not(:last-child)::after {
    content: '';
    width: 24px;
    height: 1px;
    margin-left: 4px;
    background: var(--seam-strong);
}

.creation-roadmap li span {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    background: var(--coal);
    box-shadow: inset 0 0 0 1px var(--seam-strong);
    clip-path: var(--pixel-clip-sm);
    font-family: var(--font-pixel);
    font-size: 8px;
}

.creation-roadmap li.active { color: var(--text); }
.creation-roadmap li.active span { color: #1b0d02; background: var(--accent); box-shadow: none; }

.resume-model-btn {
    position: absolute;
    top: 24px;
    right: 30px;
    min-height: 38px;
    padding: 0 12px;
    border: 0;
    color: var(--accent);
    background: rgba(255,122,26,0.08);
    box-shadow: inset 0 0 0 1px rgba(255,122,26,0.32);
    clip-path: var(--pixel-clip-sm);
    font-weight: 700;
    cursor: pointer;
}
.resume-model-btn:hover { color: var(--text); background: rgba(255,122,26,0.15); }

.creation-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 26px;
    padding: 22px 32px 30px;
}

.creation-main,
.creation-alternatives { min-width: 0; }

.creation-alternatives {
    padding-left: 26px;
    border-left: 1px solid var(--seam);
}

.creation-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.creation-section-head.compact { align-items: center; }
.creation-step-note,
.size-helper {
    color: var(--text-dim);
    font-size: 10.5px;
}

.type-selector {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin: 0 0 18px;
    padding: 5px;
}

.type-tab {
    min-width: 0;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    text-align: left;
}

.type-tab > span:last-child { display: grid; min-width: 0; }
.type-tab strong { font-family: var(--font-display); font-size: 14px; }
.type-tab small { color: inherit; font-size: 9.5px; font-weight: 500; opacity: 0.72; }
.type-tab.active small { color: rgba(27,13,2,0.72); }

.type-glyph {
    position: relative;
    width: 27px;
    height: 27px;
    flex: none;
    background: currentColor;
    clip-path: var(--pixel-clip-sm);
    opacity: 0.82;
}

.type-glyph::before,
.type-glyph::after { content: ''; position: absolute; background: #0a0806; opacity: 0.74; }
.type-glyph-block::before { inset: 6px; }
.type-glyph-block::after { width: 5px; height: 5px; top: 3px; left: 3px; }
.type-glyph-mob::before { width: 5px; height: 5px; top: 7px; left: 5px; box-shadow: 12px 0 0 #0a0806; }
.type-glyph-mob::after { width: 11px; height: 4px; left: 8px; bottom: 5px; }
.type-glyph-item { transform: rotate(-45deg) scale(0.75); }
.type-glyph-item::before { width: 6px; height: 22px; left: 10px; top: 2px; }
.type-glyph-item::after { width: 19px; height: 5px; left: 4px; bottom: 4px; }
.type-tab.active .type-glyph { color: #1b0d02; }

.prompt-section { gap: 9px; }
.prompt-section textarea {
    min-height: 92px;
    resize: vertical;
    border: 0;
    border-radius: 0;
    background: #0a0806;
    box-shadow: inset 0 0 0 1px var(--seam-strong);
    line-height: 1.45;
}
.prompt-section textarea:focus {
    box-shadow: inset 0 0 0 1px var(--accent), 0 0 18px var(--accent-glow);
}

.prompt-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.prompt-error {
    margin: -1px 0 1px;
    padding: 8px 10px;
    color: #ffaaa6;
    background: rgba(239,74,68,0.1);
    box-shadow: inset 0 0 0 1px rgba(239,74,68,0.35);
    font-size: 11px;
}

#generateProgress.error .minecraft-loader,
#generateProgress.error .progress-bar-track { display: none; }

.prompt-suggestions button {
    min-height: 30px;
    padding: 5px 9px;
    border: 0;
    color: var(--text-muted);
    background: rgba(255,255,255,0.035);
    box-shadow: inset 0 0 0 1px var(--seam);
    clip-path: var(--pixel-clip-sm);
    font-size: 10.5px;
    cursor: pointer;
}

.prompt-suggestions button:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }

.size-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 5px 0 2px;
}

.size-selector > div:first-child { display: grid; gap: 2px; }
.size-inputs { margin: 0; flex: none; }
.size-input { width: 58px; height: 38px; }

/* Fixed-resolution voxel envelope.
   The benchmarked contract is always 30 voxels per Minecraft block; these
   controls choose the available block envelope rather than changing detail. */
.voxel-envelope-control,
.editor-envelope-card {
    --envelope-line: var(--seam-strong);
    --envelope-fill: rgba(8, 7, 6, 0.48);
    min-width: 0;
}

.voxel-envelope-control {
    display: grid;
    gap: 10px;
    margin: 5px 0 2px;
    padding: 13px;
    background:
        linear-gradient(135deg, rgba(255, 122, 26, 0.055), transparent 58%),
        var(--envelope-fill);
    box-shadow: inset 0 0 0 1px var(--envelope-line);
    clip-path: var(--pixel-clip);
    transition: box-shadow 160ms ease, background 160ms ease;
}

.voxel-envelope-heading,
.editor-envelope-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    min-width: 0;
}

.voxel-envelope-heading > div,
.editor-envelope-title > div {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.voxel-envelope-heading .size-helper {
    display: block;
    max-width: 430px;
    line-height: 1.42;
}

.voxel-envelope-density {
    flex: none;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 7px;
    color: #0b1b10;
    background: var(--emerald);
    box-shadow: 0 0 14px rgba(63, 208, 108, 0.14);
    clip-path: var(--pixel-clip-sm);
    font-family: var(--font-pixel);
    font-size: 7px;
    line-height: 1;
    letter-spacing: 0.07em;
    white-space: nowrap;
}

.voxel-envelope-presets {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
}

.voxel-envelope-preset {
    min-width: 0;
    min-height: 44px;
    padding: 6px 7px;
    border: 0;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.035);
    box-shadow: inset 0 0 0 1px var(--seam);
    clip-path: var(--pixel-clip-sm);
    font-size: 10px;
    font-weight: 750;
    cursor: pointer;
    transition: color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.voxel-envelope-preset:hover {
    color: var(--text);
    background: rgba(255, 122, 26, 0.07);
    box-shadow: inset 0 0 0 1px rgba(255, 122, 26, 0.48);
}

.voxel-envelope-preset.active,
.voxel-envelope-preset[aria-pressed="true"] {
    color: #1b0d02;
    background: linear-gradient(180deg, var(--ember-hot), var(--accent));
    box-shadow: none;
}

.voxel-envelope-preset:disabled,
.voxel-envelope-preset[aria-disabled="true"] {
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.018);
    box-shadow: inset 0 0 0 1px rgba(255, 196, 130, 0.055);
    cursor: not-allowed;
    opacity: 0.58;
}

.voxel-envelope-custom-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.022);
    box-shadow: inset 0 0 0 1px var(--seam);
    clip-path: var(--pixel-clip-sm);
}

.voxel-envelope-custom-heading > div {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.voxel-envelope-custom-heading strong {
    color: var(--text);
    font-size: 10px;
    line-height: 1.25;
}

.voxel-envelope-custom-heading > div > span {
    color: var(--text-dim);
    font-size: 8.5px;
    line-height: 1.35;
}

.voxel-envelope-mode {
    flex: none;
    min-width: 54px;
    padding: 5px 7px;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.035);
    box-shadow: inset 0 0 0 1px rgba(255, 196, 130, 0.12);
    clip-path: var(--pixel-clip-sm);
    font-family: var(--font-pixel);
    font-size: 6.5px;
    line-height: 1;
    letter-spacing: 0.06em;
    text-align: center;
}

.voxel-envelope-control.custom-envelope .voxel-envelope-mode,
.editor-envelope-card.custom-envelope .voxel-envelope-mode {
    color: #0b1b10;
    background: var(--emerald);
    box-shadow: none;
}

.voxel-envelope-control.invalid .voxel-envelope-mode,
.editor-envelope-card.invalid .voxel-envelope-mode {
    color: #ffaaa6;
    background: rgba(239, 74, 68, 0.1);
    box-shadow: inset 0 0 0 1px rgba(239, 74, 68, 0.42);
}

.voxel-envelope-body {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: stretch;
    gap: 10px;
    min-width: 0;
}

.voxel-envelope-inputs {
    align-self: stretch;
    justify-content: flex-start;
    gap: 5px;
}

.voxel-envelope-inputs label {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 2px;
}

.voxel-envelope-inputs label > span {
    color: var(--text-dim);
    font-family: var(--font-pixel);
    font-size: 7px;
    line-height: 1;
    letter-spacing: 0.08em;
}

.voxel-envelope-inputs .size-x {
    align-self: end;
    height: 44px;
    display: grid;
    place-items: center;
    color: var(--text-dim);
    font-size: 12px;
}

.voxel-envelope-inputs .size-input {
    width: 52px;
    height: 44px;
    padding-inline: 4px;
    font-family: var(--font-pixel);
    font-size: 11px;
}

.voxel-envelope-inputs .size-input:invalid,
.voxel-envelope-inputs .size-input[aria-invalid="true"] {
    color: #ffaaa6;
    box-shadow: inset 0 0 0 1px rgba(239, 74, 68, 0.72), 0 0 12px rgba(239, 74, 68, 0.1);
}

.voxel-envelope-result {
    min-width: 0;
    display: grid;
    align-content: center;
    gap: 1px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.025);
    box-shadow: inset 0 0 0 1px var(--seam);
    clip-path: var(--pixel-clip-sm);
}

.voxel-envelope-result span,
.editor-envelope-metrics span {
    color: var(--text-dim);
    font-family: var(--font-pixel);
    font-size: 7px;
    line-height: 1.35;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.voxel-envelope-result strong {
    overflow: hidden;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 12.5px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voxel-envelope-result small {
    color: var(--text-muted);
    font-size: 9px;
    line-height: 1.3;
}

.voxel-envelope-error {
    margin: 0;
    padding: 8px 9px;
    color: #ffaaa6;
    background: rgba(239, 74, 68, 0.1);
    box-shadow: inset 0 0 0 1px rgba(239, 74, 68, 0.4);
    clip-path: var(--pixel-clip-sm);
    font-size: 10px;
    line-height: 1.4;
}

.voxel-envelope-error[hidden] { display: none !important; }

.voxel-envelope-control.invalid,
.voxel-envelope-control.is-invalid,
.editor-envelope-card.invalid,
.editor-envelope-card.is-invalid {
    --envelope-line: rgba(239, 74, 68, 0.55);
    background:
        linear-gradient(135deg, rgba(239, 74, 68, 0.09), transparent 62%),
        var(--envelope-fill);
}

.voxel-envelope-control[aria-disabled="true"],
.voxel-envelope-control.is-disabled,
.editor-envelope-card[aria-disabled="true"],
.editor-envelope-card.is-disabled {
    opacity: 0.64;
}

.voxel-envelope-control[aria-disabled="true"] :is(button, input),
.voxel-envelope-control.is-disabled :is(button, input),
.editor-envelope-card[aria-disabled="true"] :is(button, input),
.editor-envelope-card.is-disabled :is(button, input) {
    cursor: not-allowed;
}

.btn-generate {
    min-height: 49px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 12px 18px;
    font-size: 14px;
}

.generation-cost {
    padding: 5px 7px;
    color: #1b0d02;
    background: rgba(255,255,255,0.25);
    clip-path: var(--pixel-clip-sm);
    font-family: var(--font-pixel);
    font-size: 8px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.generation-note {
    color: var(--text-dim);
    font-size: 10.5px;
    text-align: center;
}

.generation-auth-prompt {
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 13px;
    color: var(--text);
    background: rgba(255, 122, 26, 0.09);
    box-shadow: inset 0 0 0 1px rgba(255, 160, 64, 0.42);
    clip-path: var(--pixel-clip-sm);
}

.generation-auth-prompt > div {
    display: grid;
    gap: 3px;
}

.generation-auth-prompt strong {
    font-size: 12px;
}

.generation-auth-prompt span {
    color: var(--text-muted);
    font-size: 10.5px;
    line-height: 1.4;
}

.generation-signin-link {
    flex: none;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 13px;
    color: #1b0d02;
    background: var(--accent);
    clip-path: var(--pixel-clip-sm);
    font-weight: 800;
    font-size: 11px;
    text-decoration: none;
}

.generation-signin-link:hover {
    background: var(--accent-hi);
}

@media (max-width: 560px) {
    .generation-auth-prompt {
        align-items: stretch;
        flex-direction: column;
    }

    .generation-signin-link {
        width: 100%;
    }
}

.starter-example-card {
    position: relative;
    width: 100%;
    min-height: 182px;
    display: block;
    margin-bottom: 10px;
    padding: 0;
    overflow: hidden;
    border: 0;
    color: var(--text);
    background: var(--coal);
    box-shadow: inset 0 0 0 1px var(--seam-strong);
    clip-path: var(--pixel-clip);
    cursor: pointer;
    text-align: left;
}

.starter-example-card::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px var(--seam-strong);
}

.starter-example-card:hover { box-shadow: inset 0 0 0 1px var(--accent), 0 12px 30px rgba(0,0,0,0.3); }
.starter-example-card img {
    display: block;
    width: 100%;
    height: 112px;
    object-fit: cover;
    background: #080706;
    transition: transform 0.25s ease;
}
.starter-example-card:hover img { transform: scale(1.035); }

.starter-example-copy {
    display: grid;
    gap: 1px;
    padding: 10px 12px 12px;
}
.starter-example-copy small { color: var(--accent); font-family: var(--font-pixel); font-size: 7px; letter-spacing: 0.08em; }
.starter-example-copy strong { font-family: var(--font-display); font-size: 13px; }
.starter-example-copy > span { color: var(--text-muted); font-size: 10px; }
.starter-example-copy b { color: var(--accent); }

.btn-upload {
    min-height: 58px;
    display: grid;
    place-items: center;
    gap: 1px;
    padding: 10px;
    border-radius: 0;
    clip-path: var(--pixel-clip);
}
.btn-upload strong { font-family: var(--font-display); font-size: 12px; }
.btn-upload span { color: var(--text-dim); font-family: var(--font-pixel); font-size: 7px; letter-spacing: 0.06em; }
.upload-hint { margin: 5px 0 10px; text-align: center; font-size: 9.5px; }

.gallery-view-all-btn {
    min-height: 39px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-radius: 0;
    clip-path: var(--pixel-clip-sm);
    font-size: 11px;
    font-weight: 700;
}

#generateProgress { margin: 4px 0 0; }

/* One-click text-to-model flow */
#creation-card.is-generating {
    width: min(650px, calc(100% - 32px));
}

#creation-card.is-generating .creation-header {
    padding: 34px 38px 24px;
    text-align: center;
}

#creation-card.is-generating .creation-eyebrow,
#creation-card.is-generating .resume-model-btn {
    display: none !important;
}

#creation-card.is-generating .creation-title,
#creation-card.is-generating .creation-subtitle {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

#creation-card.is-generating .creation-subtitle {
    max-width: 520px;
}

#creation-card.is-generating .creation-roadmap {
    justify-content: center;
}

#creation-card.is-generating .creation-body {
    display: block;
    padding: 26px 38px 38px;
}

#creation-card.is-generating .creation-main > :not(.prompt-section),
#creation-card.is-generating .prompt-section > :not(#generateProgress),
#creation-card.is-generating .creation-alternatives {
    display: none !important;
}

#creation-card.is-generating #generateProgress {
    display: grid !important;
}

.creation-progress {
    gap: 20px;
    padding: 26px;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background:
        radial-gradient(260px 150px at 0% 0%, rgba(255, 122, 26, 0.16), transparent 75%),
        rgba(8, 7, 6, 0.66);
    box-shadow: inset 0 0 0 1px var(--seam-strong);
    clip-path: var(--pixel-clip);
}

.creation-progress-hero {
    display: flex;
    align-items: center;
    gap: 22px;
}

.building-cube {
    position: relative;
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
    filter: drop-shadow(0 12px 18px rgba(0,0,0,0.34));
    animation: building-cube-float 1.8s ease-in-out infinite;
}

.building-cube span {
    position: absolute;
    display: block;
}

.building-cube-top {
    top: 5px;
    left: 18px;
    width: 37px;
    height: 37px;
    background: #ffad5a;
    transform: rotate(45deg) skew(-8deg, -8deg);
}

.building-cube-left,
.building-cube-right {
    top: 30px;
    width: 34px;
    height: 35px;
}

.building-cube-left {
    left: 4px;
    background: #d85a08;
    transform: skewY(30deg);
}

.building-cube-right {
    right: 4px;
    background: #ff7a1a;
    transform: skewY(-30deg);
}

.creation-progress-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.creation-progress-copy > span {
    color: var(--accent);
    font-family: var(--font-pixel);
    font-size: 8px;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.creation-progress-copy strong {
    color: var(--text);
    font-family: var(--font-display);
    font-size: clamp(19px, 3vw, 25px);
    line-height: 1.18;
}

.creation-progress-copy small {
    min-height: 1.2em;
    color: var(--text-dim);
    font-size: 11px;
}

.creation-progress .progress-bar-track {
    height: 7px;
    margin: 0;
    overflow: hidden;
    border-radius: 0;
    background: rgba(255,255,255,0.07);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.025);
}

.creation-progress .progress-bar-fill {
    border-radius: 0;
    background: linear-gradient(90deg, #ff6a0b, #ffad5a);
    box-shadow: 0 0 18px rgba(255,122,26,0.42);
    transition: width 0.5s ease;
}

.creation-progress-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.creation-progress-steps span {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-dim);
    font-size: 10px;
}

.creation-progress-steps span::before {
    content: '';
    width: 8px;
    height: 8px;
    flex: none;
    background: var(--seam-strong);
    clip-path: var(--pixel-clip-sm);
}

.creation-progress-steps span.active {
    color: var(--text);
}

.creation-progress-steps span.active::before {
    background: var(--accent);
    box-shadow: 0 0 10px rgba(255,122,26,0.65);
}

.creation-progress-steps span.done {
    color: var(--text-muted);
}

.creation-progress-steps span.done::before {
    background: var(--green);
    box-shadow: none;
}

.creation-progress .progress-reassurance {
    margin: -4px 0 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
}

.creation-progress.error {
    background: rgba(68, 22, 20, 0.45);
    box-shadow: inset 0 0 0 1px rgba(239,74,68,0.4);
}

.creation-progress.error .building-cube {
    animation: none;
    filter: grayscale(0.4) opacity(0.72);
}

.creation-progress.error .creation-progress-copy > span,
.creation-progress.error .creation-progress-copy strong {
    color: #ffaaa6;
}

.creation-progress.review {
    background:
        radial-gradient(260px 150px at 0% 0%, rgba(255, 181, 61, 0.14), transparent 75%),
        rgba(47, 34, 9, 0.58);
    box-shadow: inset 0 0 0 1px rgba(255, 181, 61, 0.42);
}

.creation-progress.review .building-cube {
    animation: none;
    filter: saturate(0.82) drop-shadow(0 12px 18px rgba(0,0,0,0.34));
}

.creation-progress.review .creation-progress-copy > span,
.creation-progress.review .creation-progress-copy strong {
    color: #ffd482;
}

.reference-review {
    display: grid;
    grid-template-columns: minmax(150px, 0.72fr) minmax(0, 1.28fr);
    gap: 16px;
    padding: 14px;
    background: rgba(7, 7, 6, 0.58);
    box-shadow: inset 0 0 0 1px rgba(255, 181, 61, 0.28);
    clip-path: var(--pixel-clip);
}

.reference-review[hidden] {
    display: none;
}

.reference-review-preview {
    min-height: 172px;
    padding: 8px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background-color: #d9ddd8;
    background-image:
        linear-gradient(45deg, rgba(86, 96, 89, 0.18) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(86, 96, 89, 0.18) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(86, 96, 89, 0.18) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(86, 96, 89, 0.18) 75%);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}

.reference-review-preview img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 230px;
    object-fit: contain;
    image-rendering: pixelated;
}

.reference-review-copy {
    min-width: 0;
    display: grid;
    align-content: start;
    gap: 8px;
}

.reference-review-kicker {
    color: #ffd482;
    font-family: var(--font-pixel);
    font-size: 7px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.reference-review-copy > strong {
    color: var(--text);
    font-family: var(--font-display);
    font-size: 17px;
    line-height: 1.18;
}

.reference-review-copy > p {
    margin: 0;
    color: var(--text-muted);
    font-size: 10.5px;
    line-height: 1.45;
}

.reference-review-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.reference-review-reasons span {
    padding: 5px 7px;
    color: #ffdca0;
    background: rgba(255, 181, 61, 0.09);
    box-shadow: inset 0 0 0 1px rgba(255, 181, 61, 0.24);
    font-size: 9px;
    line-height: 1.2;
}

.reference-review-cost {
    color: var(--text-dim) !important;
}

.reference-review-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 2px;
}

.reference-review-actions button {
    min-height: 38px;
    padding: 8px 11px;
    font-size: 10px;
}

.reference-review-actions button span {
    margin-left: 6px;
    opacity: 0.75;
}

.creation-progress.success .building-cube {
    animation: none;
    filter: hue-rotate(65deg) drop-shadow(0 12px 18px rgba(0,0,0,0.34));
}

@keyframes building-cube-float {
    0%, 100% { transform: translateY(0) rotate(0.001deg); }
    50% { transform: translateY(-5px) rotate(0.001deg); }
}

@media (prefers-reduced-motion: reduce) {
    .building-cube { animation: none; }
}

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

    .reference-review-preview {
        min-height: 150px;
        max-height: 210px;
    }

    .reference-review-actions {
        display: grid;
        grid-template-columns: 1fr;
    }
}

.prompt-recipe {
    margin: -2px 0 1px;
    color: var(--text-dim);
    font-size: 10.5px;
    line-height: 1.45;
}
.prompt-recipe strong { color: var(--text-muted); }

.progress-reassurance {
    margin: 9px 0 0;
    color: var(--text-dim);
    font-size: 10px;
    line-height: 1.4;
}

.turnaround-review {
    gap: 12px;
    margin-top: 4px;
    padding: 14px;
    background: rgba(61, 186, 110, 0.075);
    box-shadow: inset 0 0 0 1px rgba(61, 186, 110, 0.32);
    clip-path: var(--pixel-clip);
}

.turnaround-review-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.quality-check-badge {
    flex: none;
    padding: 5px 6px;
    color: #07160c;
    background: var(--green);
    clip-path: var(--pixel-clip-sm);
    font-family: var(--font-pixel);
    font-size: 7px;
    letter-spacing: 0.06em;
}

.turnaround-review h3 {
    margin: 0 0 3px;
    font-family: var(--font-display);
    font-size: 14px;
}

.turnaround-review p {
    margin: 0;
    color: var(--text-muted);
    font-size: 10.5px;
    line-height: 1.45;
}

#turnaroundReview #generatePreview {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: block !important;
    object-fit: contain;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2), 0 9px 24px rgba(0,0,0,0.24);
    image-rendering: auto;
}

.model-builder-choice {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
}

.model-builder-option {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 58px;
    padding: 9px 10px;
    color: var(--text-muted);
    background: rgba(255,255,255,0.035);
    box-shadow: inset 0 0 0 1px var(--seam-strong);
    clip-path: var(--pixel-clip-sm);
    cursor: pointer;
}

.model-builder-option:has(input:checked),
.model-builder-option.selected {
    color: var(--text);
    background: rgba(255, 145, 45, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 151, 60, 0.7);
}

.model-builder-option input { accent-color: var(--orange); }
.model-builder-option span { display: grid; gap: 2px; min-width: 0; }
.model-builder-option strong { font-size: 11px; }
.model-builder-option small { color: var(--text-dim); font-size: 9px; line-height: 1.35; }
.model-builder-option b {
    color: var(--amber);
    font-family: var(--font-pixel);
    font-size: 7px;
    white-space: nowrap;
}

.turnaround-review-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
}

.turnaround-review-actions .btn-primary {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px 10px 15px;
}

.generation-complete-toast {
    position: fixed;
    top: 68px;
    left: 22px;
    right: calc(var(--panel-w) + 38px);
    z-index: 140;
    width: min(720px, calc(100vw - var(--panel-w) - 72px));
    min-height: 64px;
    margin: 0 auto;
    align-items: center;
    gap: 8px;
    padding: 10px 11px 10px 15px;
    color: var(--text);
    background: rgba(17, 30, 21, 0.97);
    box-shadow: inset 0 0 0 1px rgba(61, 186, 110, 0.48), 0 16px 38px rgba(0,0,0,0.4);
    clip-path: var(--pixel-clip);
}

.generation-complete-toast > div {
    min-width: 0;
    display: grid;
    gap: 2px;
    margin-right: auto;
}

.generation-complete-toast strong {
    display: -webkit-box;
    overflow: hidden;
    font-family: var(--font-display);
    font-size: 14px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.generation-complete-toast span {
    overflow: hidden;
    color: #a9c9b0;
    font-size: 10.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.generation-complete-toast button {
    min-height: 38px;
    flex: none;
    padding: 8px 11px;
    font-size: 10.5px;
}

/* Friendly editor wayfinding */
.workflow-intro {
    display: flex;
    gap: 11px;
    margin: 3px 0 12px;
    padding: 2px 2px 0;
}
.workflow-intro-step {
    flex: none;
    align-self: flex-start;
    margin-top: 3px;
    padding: 4px 6px;
    color: #1b0d02;
    background: var(--accent);
    clip-path: var(--pixel-clip-sm);
}
.workflow-intro h2 {
    margin: 0 0 2px;
    font-family: var(--font-display);
    font-size: 17px;
    line-height: 1.2;
}
.workflow-intro p { color: var(--text-muted); font-size: 11px; line-height: 1.45; }

.editor-envelope-card {
    display: grid;
    gap: 11px;
    overflow: hidden;
    background:
        radial-gradient(220px 120px at 100% 0%, rgba(63, 208, 108, 0.075), transparent 72%),
        var(--slate);
    transition: box-shadow 160ms ease, opacity 160ms ease;
}

.editor-envelope-title h3 {
    margin: 0;
    font-size: 15px;
    line-height: 1.2;
}

.editor-envelope-title p {
    margin: 0;
    color: var(--text-muted);
    font-size: 10.5px;
    line-height: 1.42;
}

.editor-envelope-presets {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.editor-envelope-inputs {
    width: 100%;
    justify-content: center;
    padding: 9px 8px;
    background: rgba(8, 7, 6, 0.42);
    box-shadow: inset 0 0 0 1px var(--seam);
    clip-path: var(--pixel-clip-sm);
}

.editor-envelope-inputs .size-input {
    width: min(62px, 17vw);
}

.editor-envelope-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.editor-envelope-metrics > div {
    min-width: 0;
    display: grid;
    align-content: center;
    gap: 3px;
    min-height: 52px;
    padding: 8px 9px;
    background: rgba(255, 255, 255, 0.025);
    box-shadow: inset 0 0 0 1px var(--seam);
    clip-path: var(--pixel-clip-sm);
}

.editor-envelope-metrics strong {
    overflow: hidden;
    color: var(--text);
    font-size: 10.5px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-envelope-metrics > div:last-child strong {
    color: var(--emerald);
    overflow: visible;
    font-size: 9.5px;
    text-overflow: clip;
    white-space: normal;
}

.editor-envelope-apply {
    width: 100%;
    min-height: 44px;
}

.editor-envelope-apply:disabled,
.editor-envelope-apply[aria-disabled="true"] {
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.02);
    box-shadow: inset 0 0 0 1px var(--seam);
    cursor: not-allowed;
    opacity: 0.72;
}

.editor-envelope-card.is-processing .editor-envelope-apply,
.editor-envelope-card[aria-busy="true"] .editor-envelope-apply {
    color: #1b0d02;
    background:
        linear-gradient(90deg, var(--accent) 0 38%, var(--ember-hot) 50%, var(--accent) 62% 100%);
    background-size: 220% 100%;
    box-shadow: none;
    animation: envelope-build-sweep 1.2s linear infinite;
    pointer-events: none;
}

.voxel-engine-status {
    min-height: 25px;
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: -2px;
    padding: 5px 7px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.16);
    box-shadow: inset 0 0 0 1px var(--seam);
    clip-path: var(--pixel-clip-sm);
    font-family: var(--font-pixel);
    font-size: 7px;
    line-height: 1.35;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.voxel-engine-status::before {
    content: '';
    width: 7px;
    height: 7px;
    flex: none;
    background: var(--emerald);
    box-shadow: 0 0 8px rgba(63, 208, 108, 0.55);
}

.voxel-engine-status.loading::before,
.voxel-engine-status.is-processing::before,
.editor-envelope-card[aria-busy="true"] .voxel-engine-status::before {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(255, 122, 26, 0.62);
    animation: envelope-status-pulse 0.8s ease-in-out infinite alternate;
}

.voxel-engine-status.error {
    color: #ffaaa6;
    box-shadow: inset 0 0 0 1px rgba(239, 74, 68, 0.35);
}

.voxel-engine-status.error::before {
    background: #ef4a44;
    box-shadow: 0 0 8px rgba(239, 74, 68, 0.55);
}

@keyframes envelope-build-sweep {
    to { background-position: -120% 0; }
}

@keyframes envelope-status-pulse {
    to { opacity: 0.38; }
}

@media (prefers-reduced-motion: reduce) {
    .editor-envelope-card.is-processing .editor-envelope-apply,
    .editor-envelope-card[aria-busy="true"] .editor-envelope-apply,
    .voxel-engine-status.loading::before,
    .voxel-engine-status.is-processing::before,
    .editor-envelope-card[aria-busy="true"] .voxel-engine-status::before {
        animation: none;
    }
}

.quick-voxel-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin: 2px 0 4px;
}
.quick-voxel-action {
    min-width: 0;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--seam-strong);
    background: #0c0907;
    color: var(--text);
    font: 700 13px/1.15 var(--font-body);
    cursor: pointer;
    clip-path: var(--pixel-clip-sm);
}
.quick-voxel-action span {
    color: var(--accent);
    font: 800 21px/1 var(--font-display);
}
.quick-voxel-action:hover,
.quick-voxel-action:focus-visible {
    border-color: var(--accent);
    background: var(--surface-raised);
    color: #fff;
}
.skip-gameplay-btn { width: 100%; margin: 10px 0 2px; }

.export-card-hint { margin-top: -3px; }
.item-fit-card {
    border-color: rgba(103, 232, 249, 0.34);
    background: linear-gradient(145deg, rgba(103, 232, 249, 0.07), rgba(255, 122, 26, 0.06));
}
.item-fit-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.item-fit-heading img { width: 46px; height: 46px; flex: none; object-fit: contain; image-rendering: pixelated; }
.item-fit-heading h3 { margin: 1px 0 2px; }
.item-fit-heading .card-hint { margin: 0; }
.item-fit-kicker { color: var(--diamond); font-family: var(--font-pixel); font-size: 9px; letter-spacing: 0.08em; }
.item-fit-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 13px; }
.item-fit-slot {
    min-height: 38px;
    border: 1px solid var(--seam-strong);
    background: #0c0907;
    color: var(--text-muted);
    font-weight: 700;
    cursor: pointer;
}
.item-fit-slot.active { border-color: var(--diamond); color: #0b1618; background: var(--diamond); }
.item-fit-scale-row { display: grid; grid-template-columns: auto minmax(80px, 1fr) auto auto; align-items: center; gap: 7px; }
.item-fit-scale-row input { min-width: 0; accent-color: var(--diamond); }
.item-fit-scale-row output { min-width: 42px; color: var(--diamond); font-family: var(--font-pixel); font-size: 10px; text-align: right; }
.item-fit-actions { margin-top: 12px; }
.item-fit-actions button { flex: 1; }
.item-fit-status { margin: 10px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.item-fit-card.previewing { box-shadow: inset 0 0 0 1px rgba(103, 232, 249, 0.3), 0 0 24px rgba(103, 232, 249, 0.08); }
.item-fit-card.previewing #itemFitPreviewBtn { background: var(--diamond); color: #071214; }
.export-path-btn {
    min-height: 57px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 14px;
    text-align: left;
}
.export-path-btn > span { display: grid; gap: 1px; }
.export-path-btn strong { font-size: 13px; }
.export-path-btn small { color: currentColor; font-size: 10px; font-weight: 500; opacity: 0.72; }
.export-path-btn > b { font-size: 18px; }
.education-server-install-btn {
    border-color: rgba(164, 235, 83, 0.48);
    background: linear-gradient(135deg, rgba(164, 235, 83, 0.12), rgba(103, 232, 249, 0.07));
    color: var(--lime);
}
.education-server-install-btn:hover:not(:disabled),
.education-server-install-btn:focus-visible {
    border-color: var(--lime);
    background: linear-gradient(135deg, rgba(164, 235, 83, 0.2), rgba(103, 232, 249, 0.1));
}
.education-install-status {
    margin-top: 10px;
    line-height: 1.45;
}

[data-mode="simple"] #tabNavigation { display: none !important; }

@media (min-width: 1024px) {
    #sidebar { top: calc(var(--homebar-h) + 10px); }
    .panel-header { padding-top: 14px; }
}

@media (max-width: 1023px) {
    body, #app-shell { min-height: 100dvh; height: 100dvh; }

    .studio-homebar { padding: 0 12px; }
    .studio-homebar-product { display: none; }
    .studio-homebar-nav a { min-height: 40px; padding-inline: 10px; }
    .studio-developer-link { display: none !important; }
    #forgeAccount { top: calc(var(--homebar-h) + 8px); right: 10px; }

    .viewport-toolbar {
        top: calc(var(--homebar-h) + 8px);
        left: 8px;
        right: 8px;
        max-width: calc(100vw - 16px);
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .viewport-toolbar::-webkit-scrollbar { display: none; }
    .viewport-toolbar .control-btn,
    .viewport-toolbar .save-btn { min-height: 40px; flex: none; }

    #creation-card {
        top: calc(var(--homebar-h) + 8px);
        width: calc(100% - 16px);
        max-height: calc(100dvh - var(--homebar-h) - 16px);
    }

    .creation-header { padding: 22px 22px 18px; }
    .creation-title { font-size: 30px; }
    .creation-body { grid-template-columns: 1fr; gap: 22px; padding: 20px 22px 26px; }
    .creation-alternatives { padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--seam); }
    .starter-example-card { display: grid; grid-template-columns: 128px 1fr; min-height: 110px; }
    .starter-example-card img { width: 128px; height: 100%; min-height: 110px; }
    .starter-example-copy { align-content: center; }

    #sidebar {
        height: 46dvh;
        max-height: none;
        padding-bottom: env(safe-area-inset-bottom, 0);
        touch-action: pan-y;
        border-radius: 14px 14px 0 0;
    }
    #sidebar.sheet-half { height: 46dvh; transform: translateY(0); }
    #sidebar.sheet-full { height: 88dvh; transform: translateY(0); }
    #sidebar.sheet-collapsed { height: 46dvh; transform: translateY(calc(100% - var(--mobile-sheet-peek))); }
    #sidebar.sheet-collapsed .sidebar-scroll {
        visibility: hidden;
        pointer-events: none;
    }
    .panel-handle { touch-action: none; }
    .panel-handle:focus-visible { outline: none; }
    .panel-handle:focus-visible::before { background: var(--accent); box-shadow: 0 0 0 3px rgba(255,122,26,0.18); }
    .sidebar-scroll { overscroll-behavior: contain; }
    .panel-header { padding-inline: 14px; gap: 8px; }
    .stepper-dot { min-height: 34px; }
    .advanced-toggle { min-height: 34px; padding-inline: 9px; }
}

@media (max-width: 560px) {
    .studio-homebar-brand { font-size: 15px; }
    .studio-homebar-nav a { font-size: 11px; }
    .creation-header { padding: 19px 18px 16px; }
    .creation-title { margin-top: 7px; font-size: 27px; }
    .creation-subtitle { font-size: 12.5px; }
    .creation-roadmap { gap: 5px; }
    .creation-roadmap li { gap: 4px; font-size: 9.5px; }
    .creation-roadmap li:not(:last-child)::after { width: 9px; margin-left: 1px; }
    .resume-model-btn { position: static; width: 100%; margin-top: 12px; }
    .creation-body { padding: 18px; }
    .creation-section-head { display: grid; gap: 2px; }
    .creation-step-note,
    .prompt-suggestions { display: none; }
    .type-tab { justify-content: center; min-height: 54px; padding: 7px 5px; text-align: center; }
    .type-glyph { width: 22px; height: 22px; }
    .type-tab small { display: none; }
    .type-tab strong { font-size: 12.5px; }
    .prompt-section textarea { min-height: 86px; }
    .size-selector {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
        gap: 8px;
    }
    .size-helper { max-width: none; }
    .size-inputs {
        width: 100%;
        justify-content: flex-start;
        gap: 6px;
    }
    .size-input { width: min(58px, 17vw); }
    .size-label { margin-left: 2px; }
    .voxel-envelope-control {
        gap: 9px;
        padding: 11px;
    }
    .voxel-envelope-heading,
    .editor-envelope-title {
        gap: 9px;
    }
    .voxel-envelope-heading .size-helper {
        font-size: 9.5px;
    }
    .voxel-envelope-density {
        min-height: 22px;
        padding-inline: 6px;
        font-size: 6.5px;
    }
    .voxel-envelope-presets,
    .editor-envelope-presets {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .voxel-envelope-preset {
        min-height: 44px;
    }
    .voxel-envelope-body {
        grid-template-columns: minmax(0, 1fr);
        gap: 7px;
    }
    .voxel-envelope-inputs,
    .editor-envelope-inputs {
        width: 100%;
        justify-content: center;
    }
    .voxel-envelope-inputs .size-input,
    .editor-envelope-inputs .size-input {
        width: min(66px, 18vw);
    }
    .voxel-envelope-result {
        min-height: 54px;
    }
    .editor-envelope-card {
        gap: 9px;
    }
    .editor-envelope-title {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .editor-envelope-title p {
        font-size: 10px;
    }
    .editor-envelope-inputs {
        padding: 8px 5px;
    }
    .editor-envelope-metrics {
        grid-template-columns: minmax(0, 1fr);
    }
    .editor-envelope-metrics > div {
        min-height: 46px;
    }
    .editor-envelope-apply {
        min-height: 44px;
    }
    .generation-cost { font-size: 7px; }
    .starter-example-card { grid-template-columns: 112px 1fr; }
    .starter-example-card img { width: 112px; }
    #generateProgress { margin: 4px 0 0; }
    #creation-card.is-generating .creation-header { padding: 28px 20px 20px; }
    #creation-card.is-generating .creation-body { padding: 20px; }
    .creation-progress { gap: 16px; padding: 20px; }
    .creation-progress-hero { gap: 15px; }
    .creation-progress-steps { gap: 4px; }
    .creation-progress-steps span { gap: 5px; font-size: 9px; }
    .turnaround-review-head { display: grid; }
    .model-builder-choice { grid-template-columns: 1fr; }
    .turnaround-review-actions { grid-template-columns: 1fr; }
    .generation-complete-toast {
        top: 62px;
        left: 10px;
        right: 10px;
        width: auto;
        flex-wrap: wrap;
    }
    .generation-complete-toast > div { width: 100%; }
    .generation-complete-toast button { flex: 1; }
    .quick-voxel-actions { gap: 5px; }
    .quick-voxel-action { min-height: 44px; padding: 8px 5px; gap: 5px; font-size: 11px; }
    .quick-voxel-action span { font-size: 18px; }
}

@media (max-height: 680px) and (min-width: 700px) {
    .creation-header { padding-top: 18px; padding-bottom: 14px; }
    .creation-roadmap { margin-top: 10px; }
    .creation-body { padding-top: 16px; padding-bottom: 20px; }
    .starter-example-card { min-height: 154px; }
    .starter-example-card img { height: 90px; }
}

/* ---- Claude voxel author: creation-card inputs and the refine card ---- */
.reference-image-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin: 8px 0 4px;
}
.reference-image-hint {
    flex: 1 1 240px;
    color: var(--text-dim);
    font-size: 10.5px;
    line-height: 1.4;
}
.reference-image-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px 4px 4px;
    border: 1px solid var(--seam);
    background: var(--surface-2, rgba(255, 255, 255, 0.04));
    font-size: 11px;
}
.reference-image-chip[hidden] { display: none; }
.reference-image-chip img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    image-rendering: pixelated;
}
.reference-image-chip button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.item-style-choice {
    display: grid;
    gap: 6px;
    margin: 10px 0 4px;
}
.item-style-choice[hidden] { display: none; }
.item-style-choice label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--seam);
    cursor: pointer;
    font-size: 12px;
}
.item-style-choice label:has(input:checked) { border-color: var(--emerald); }
.item-style-choice label span { display: grid; gap: 2px; }
.item-style-choice label small { color: var(--text-dim); font-size: 10.5px; }
.voxel-envelope-control.sprite-mode .voxel-envelope-presets,
.voxel-envelope-control.sprite-mode .voxel-envelope-custom-heading,
.voxel-envelope-control.sprite-mode .voxel-envelope-inputs { opacity: 0.45; pointer-events: none; }
.full-brief-editor {
    margin: 10px 0 6px;
    padding: 8px 10px;
    border: 1px solid var(--seam);
}
.full-brief-editor > summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}
.full-brief-note {
    margin: 8px 0;
    color: var(--text-dim);
    font-size: 10.5px;
    line-height: 1.4;
}
.full-brief-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 6px 0;
}
.full-brief-status {
    flex: 1 1 200px;
    color: var(--text-dim);
    font-size: 10.5px;
    line-height: 1.4;
}
.full-brief-editor textarea {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 11px;
    line-height: 1.45;
    margin: 4px 0;
}
.full-brief-use {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    margin: 4px 0 6px;
}
.full-brief-system pre {
    max-height: 260px;
    overflow: auto;
    padding: 8px;
    background: rgba(0, 0, 0, 0.25);
    font-size: 10.5px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Studio plan prompts (public/app/plan-prompt.js): the plan choice when free models are used, and a quiet note after a free model. */
.plan-prompt .plan-prompt-content { max-width: 760px; }
.plan-prompt-head { padding: 22px 24px 6px; }
.plan-prompt-kicker { font-family: 'Silkscreen', monospace; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.plan-prompt-head h3 { margin: 6px 0 8px; font-size: 22px; }
.plan-prompt-head p { margin: 0; color: var(--text-muted); line-height: 1.5; }
.plan-prompt-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 18px 24px; }
.plan-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--border-hover); border-radius: var(--radius); background: var(--surface2); }
.plan-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow), 0 10px 30px var(--accent-glow); }
.plan-name { font-family: 'Silkscreen', monospace; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.plan-price { font-size: 28px; font-weight: 800; color: var(--text); }
.plan-price small { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.plan-models { color: var(--text); }
.plan-each { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.plan-card button { margin-top: auto; }
.plan-prompt-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 13px; }
.plan-prompt-offline { grid-column: 1 / -1; color: var(--text-muted); }
/* Bottom-left, over the 3D view: on the right it covered the editor panel and its Next button (Joe, 12 November 2026). */
.plan-nudge { position: fixed; left: 20px; bottom: 20px; z-index: 900; display: flex; align-items: center; gap: 14px; max-width: 560px; padding: 14px 16px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface); box-shadow: 0 16px 40px rgba(0,0,0,.45); }
.plan-nudge div { display: flex; flex: 1; min-width: 260px; flex-direction: column; gap: 3px; }
.plan-nudge strong { color: var(--text); font-size: 14px; }
.plan-nudge .btn-primary { white-space: nowrap; }
.plan-nudge span { color: var(--text-muted); font-size: 13px; }
.plan-nudge-close { background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; }
@media (max-width: 720px) { .plan-prompt-cards { grid-template-columns: 1fr; } .plan-nudge { left: 12px; right: 12px; bottom: 12px; } }
@media (min-width: 721px) { body[data-native-studio] .plan-nudge { max-width: min(560px, calc(100vw - var(--native-panel, 360px) - 40px)); } }

/* Signed-out offer in the studio header (step-02-account.js shows it). */
.free-offer-banner { display: flex; align-items: center; gap: 14px; margin: 16px 0 4px; padding: 12px 14px; border: 2px solid #3f8f2f; border-radius: 4px; background: #17241a; color: var(--text); text-decoration: none; }
.free-offer-banner[hidden] { display: none; }
.free-offer-banner:hover { background: #1c2d20; }
.free-offer-count { flex: none; padding: 6px 10px; border-radius: 3px; background: #3c8527; color: #fff; font-weight: 800; font-size: 15px; white-space: nowrap; }
.free-offer-text { flex: 1; font-size: 14px; line-height: 1.4; color: #c8d3c9; }
.free-offer-text strong { display: block; color: #fff; font-size: 16px; }
/* White text needs 4.5:1: #4caf3a was 2.8:1 (owner, 13 Nov 2026); #3c8527 is the brand grass at 4.6:1. */
.free-offer-action { flex: none; padding: 8px 14px; border: 2px solid #1f1f1f; border-radius: 2px; background: #3c8527; color: #fff; font-weight: 700; white-space: nowrap; }
@media (max-width: 720px) { .free-offer-banner { flex-wrap: wrap; } .free-offer-action { width: 100%; text-align: center; } }
