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

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface2: #1c1c1f;
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);
    --text: #ededef;
    --text-muted: #8b8b8f;
    --text-dim: #5a5a5e;
    --accent: #00d4aa;
    --accent-hover: #00e8bc;
    --accent-glow: rgba(0,212,170,0.12);
    --gold: #d4a54a;
    --pink: #e05090;
    --purple: #9055e0;
    --green: #3dba6e;
    --radius: 12px;
    --radius-lg: 20px;
    --panel-w: 380px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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;
}

#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;
    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; }

.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-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: -0.03em;
    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;
}
.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(0, 212, 170, 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); }

/* 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) {
    .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(0,212,170,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);
}

.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; width: 30%; }
    50% { opacity: 0.6; width: 60%; }
}

.progress-phase { font-size: 13px; color: var(--accent); }
.progress-elapsed { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* 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(0,212,170,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; }

/* ── 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: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(0,212,170,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) */
.edit-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;
}
.edit-tool-btn:hover { border-color: var(--border-hover); }
.edit-tool-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

/* 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(0,212,170,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; }

.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; }
.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(0,212,170,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(0,212,170,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; }
    .export-modal-content { width: 95%; max-height: 90vh; }
}
