:root {
    --bg: #0a0a0e;
    --bg-card: #121216;
    --bg-surface: #16161e;
    --bg-input: #1c1c24;
    --bg-hover: #1a1a22;
    --border: #2a2a32;
    --border-hover: #00ff9d;
    --text: #e0e0e0;
    --text-muted: #787888;
    --text-dim: #484858;
    --accent: #00ff9d;
    --accent-hover: #00cc7a;
    --accent-glow: 0 0 20px rgba(0,255,157,0.3);
    --danger: #ff5555;
    --warning: #ffb74d;
    --info: #00d4ff;
    --success: #00ff9d;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-pill: 24px;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', monospace;
    --toolbar-h: 42px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--font-sans);
    overflow: hidden;
}
body {
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Site Header ─── */

.site-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
}
.logo {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}
.logo-accent { color: var(--accent); }
.tagline {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.header-nav {
    display: flex;
    align-items: center;
    gap: 14px;
}
.nav-link {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    transition: color 0.15s;
}
.nav-link:hover { color: var(--accent); text-decoration: none; }
.nav-register {
    background: var(--accent);
    color: #000;
    padding: 5px 14px;
    border-radius: var(--radius-pill);
}
.nav-register:hover { color: #000; box-shadow: var(--accent-glow); }
.nav-user {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
}

/* ─── Toolbar ─── */

.toolbar {
    height: var(--toolbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    flex-shrink: 0;
}
.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.toolbar-left { flex: 0 0 auto; }
.toolbar-center { flex: 1 1 auto; justify-content: center; }
.toolbar-right {
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    gap: 6px;
}
.toolbar-upload {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.toolbar-upload:hover {
    border-color: var(--accent);
    background: rgba(0,255,157,0.08);
}
.toolbar-upload.drag-active {
    border-color: var(--accent);
    background: rgba(0,255,157,0.15);
}
.tbu-icon {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1;
}
.toolbar-upload input[type="file"] { display: none; }
.tbu-input {
    width: 200px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 4px 12px;
    font: 0.78rem/1.5 var(--font-sans);
    outline: none;
    transition: border-color 0.15s;
}
.tbu-input:focus { border-color: var(--accent); }

.tb-sep {
    color: var(--border);
    font-size: 0.7rem;
}
.tb-stat {
    white-space: nowrap;
}

.btn-render {
    padding: 5px 18px;
    border-radius: var(--radius-pill) !important;
    font-size: 0.82rem;
}

/* ─── Status Dot (in toolbar) ─── */

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: all 0.3s;
}
.status-dot.ready {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}
.status-dot.busy {
    background: var(--warning);
    box-shadow: 0 0 6px var(--warning);
    animation: blink 1s infinite;
}
.status-dot.error {
    background: var(--danger);
    box-shadow: 0 0 6px var(--danger);
}
@keyframes blink {
    50% { opacity: 0.3; }
}

/* ─── Main Split Layout ─── */

.main-split {
    flex: 1;
    min-height: 0;
    display: flex;
    position: relative;
}

/* ─── Editor Pane ─── */

.editor-pane {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    flex-shrink: 0;
}
.editor-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

/* ─── Params Bar ─── */

.params-bar {
    flex-shrink: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}
.params-bar.hidden { display: none; }
.param-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
}
.param-label {
    font-family: var(--font-mono);
    color: var(--text);
    min-width: 50px;
}
.param-value {
    font-family: var(--font-mono);
    color: var(--text-muted);
    min-width: 28px;
    text-align: right;
}

/* ─── Range Slider ─── */

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 5px;
    background: var(--bg-input);
    border-radius: 3px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
    cursor: pointer;
}

/* ─── Param Toggle ─── */

.param-toggle {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 18px;
    background: var(--bg-input);
    border-radius: 9px;
    border: 1px solid var(--border);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}
.param-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: all 0.2s;
}
.param-toggle:checked {
    background: rgba(0,255,157,0.2);
    border-color: var(--accent);
}
.param-toggle:checked::after {
    left: 16px;
    background: var(--accent);
}

/* ─── CodeMirror fills editor pane ─── */

.CodeMirror {
    flex: 1;
    min-height: 0;
    height: auto;
    background: var(--bg) !important;
    color: #e0e0e0 !important;
    font: 13px/1.5 var(--font-mono);
    border: none;
    border-radius: 0;
}
.CodeMirror-scroll {
    min-height: auto !important;
}
.CodeMirror-gutters {
    background: var(--bg-card) !important;
    border-right: 1px solid var(--border) !important;
}
.CodeMirror-linenumber {
    color: var(--text-dim) !important;
}
.CodeMirror-cursor {
    border-left: 2px solid var(--accent) !important;
}
.CodeMirror-selected {
    background: rgba(0,255,157,0.15) !important;
}
.CodeMirror-focused .CodeMirror-activeline-background {
    background: rgba(255,255,255,0.03) !important;
}
.CodeMirror-matchingbracket {
    outline: 1px solid var(--accent);
    color: var(--accent) !important;
}
.CodeMirror .cm-keyword { color: #ff79c6; }
.CodeMirror .cm-atom { color: #bd93f9; }
.CodeMirror .cm-number { color: #bd93f9; }
.CodeMirror .cm-def { color: #8be9fd; }
.CodeMirror .cm-variable { color: #e0e0e0; }
.CodeMirror .cm-variable-2 { color: #e0e0e0; }
.CodeMirror .cm-variable-3 { color: #e0e0e0; }
.CodeMirror .cm-comment { color: #6272a4; }
.CodeMirror .cm-string { color: #f1fa8c; }
.CodeMirror .cm-string-2 { color: #f1fa8c; }
.CodeMirror .cm-meta { color: #ffb86c; }
.CodeMirror .cm-builtin { color: #8be9fd; }
.CodeMirror .cm-tag { color: #ff5555; }
.CodeMirror .cm-attribute { color: #50fa7b; }
.CodeMirror .cm-operator { color: #ff79c6; }
.CodeMirror .cm-bracket { color: #e0e0e0; }

/* ─── Console Drawer ─── */

.console-drawer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.console-handle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: var(--bg-surface);
    cursor: pointer;
    user-select: none;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    transition: background 0.15s;
}
.console-handle:hover {
    background: var(--bg-hover);
}
.console-arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
}
.console-arrow.open {
    transform: rotate(180deg);
}
.console-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
}
.console-body.open {
    max-height: 130px;
}
.console-log {
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 0.73rem;
    line-height: 1.6;
    background: var(--bg);
    max-height: 130px;
    overflow-y: auto;
}
.console-log div {
    white-space: pre-wrap;
    word-break: break-word;
}
.console-log .log-info { color: var(--success); }
.console-log .log-warn { color: var(--warning); }
.console-log .log-error { color: var(--danger); }

/* ─── Split Divider ─── */

.split-divider {
    width: 6px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    transition: background 0.15s;
}
.split-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 32px;
    border-radius: 2px;
    background: var(--text-dim);
    transition: background 0.15s;
}
.split-divider:hover,
.split-divider.active {
    background: var(--accent);
}
.split-divider:hover::after,
.split-divider.active::after {
    background: #000;
}

/* ─── Viewport Pane ─── */

.viewport-pane {
    flex: 1;
    min-width: 400px;
    position: relative;
    overflow: hidden;
    background: radial-gradient(ellipse at center, #0e0e16, #08080c);
}
#viewerCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    position: absolute;
    top: 0;
    left: 0;
}
.viewport-hud {
    position: absolute;
    left: 12px;
    bottom: 12px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    pointer-events: none;
    z-index: 2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* ─── HUD Toggles ─── */

.hud-toggles {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 3;
}
.hud-btn {
    background: rgba(22,22,30,0.85);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 4px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sans);
    white-space: nowrap;
}
.hud-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}
.hud-btn.active {
    background: rgba(0,255,157,0.12);
    border-color: var(--accent);
    color: var(--accent);
}

/* ─── Empty State ─── */

.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    pointer-events: none;
    z-index: 1;
}
.empty-icon {
    font-size: 3rem;
    margin-bottom: 8px;
    opacity: 0.4;
}
.empty-state strong {
    font-size: 1.1rem;
    color: var(--text-muted);
}
.empty-state p {
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ─── Loading Overlay ─── */

.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10,10,14,0.85);
    backdrop-filter: blur(4px);
    z-index: 10;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-overlay .loading-sub {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

/* ─── Viewport Error Overlay ─── */

.viewport-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10,10,14,0.88);
    backdrop-filter: blur(4px);
    z-index: 9;
    text-align: center;
    padding: 20px;
}
.vp-error-icon {
    font-size: 2.5rem;
    color: var(--danger);
    margin-bottom: 8px;
}
.vp-error-text {
    font-size: 1rem;
    color: var(--danger);
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-word;
}
.vp-error-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ─── Input fields ─── */

.input {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font: 0.85rem/1.5 var(--font-sans);
    outline: none;
    transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--bg-input) inset !important;
    -webkit-text-fill-color: var(--text) !important;
    caret-color: var(--text);
}

/* ─── Buttons ─── */

.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sans);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover:not(:disabled) {
    box-shadow: var(--accent-glow);
}
.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent);
}
.btn-tb {
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 3px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sans);
    white-space: nowrap;
}
.btn-tb:hover {
    border-color: var(--accent);
    color: var(--text);
}
.btn-tb:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn-toggle {
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: 0.78rem;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
}
.btn-toggle:hover {
    border-color: var(--accent);
    color: var(--text);
}
.btn-toggle.active {
    background: rgba(0,255,157,0.1);
    border-color: var(--accent);
    color: var(--accent);
}
.btn-toggle-sm {
    font-size: 0.7rem;
    padding: 2px 10px;
}

/* ─── Auth Pages ─── */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 97px - 50px);
    padding: 20px;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    width: 100%;
    max-width: 420px;
}
.auth-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 14px;
}
.alert-error {
    background: rgba(255,85,85,0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}
.alert-success {
    background: rgba(0,255,157,0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
}
.auth-links {
    margin-top: 14px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

/* ─── Footer ─── */

.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.footer-links { display: flex; gap: 14px; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--accent); }

/* ─── Full-viewport editor mode ─── */

.main-split.full-editor .viewport-pane,
.main-split.full-editor .split-divider {
    display: none;
}
.main-split.full-editor .editor-pane .CodeMirror {
    min-height: 0;
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
    body { overflow-y: auto; }
    .site-header .tagline { display: none; }
    .tbu-input { width: 120px; }
    .toolbar { flex-wrap: wrap; height: auto; padding: 6px 8px; gap: 4px; }
    .toolbar-center { flex: 1 1 100%; justify-content: flex-start; }
    .toolbar-right { flex: 1 1 100%; justify-content: flex-start; }
    .toolbar-upload { width: 36px; height: 36px; }
    .btn-tb { padding: 6px 14px; font-size: 0.82rem; touch-action: manipulation; }
    .btn-render { padding: 6px 20px; }
    .main-split { flex-direction: column; }
    .editor-pane { min-width: 0; flex: 2; min-height: 0; }
    .viewport-pane { min-width: 0; flex: 1; min-height: 0; }
    .split-divider { display: none; }
    .hud-toggles { flex-direction: row; top: auto; bottom: 10px; }
    .site-footer { flex-direction: column; gap: 6px; text-align: center; }
    .editor-header { padding: 8px 12px; }
    .btn-toggle-sm { padding: 6px 16px; font-size: 0.82rem; min-height: 36px; touch-action: manipulation; }
    .btn { touch-action: manipulation; }
    .CodeMirror { font-size: 14px; }
    .params-bar { padding: 6px 8px; gap: 4px 8px; }
    input[type="range"] { width: 60px; }
    .tbu-input { width: 100px; }
}

/* ═══════════════════════════════════════════════════════════════════
   Phase 3 — Dashboard, Gallery, Model Pages
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Page Layout (non-editor pages) ─── */

.page-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}
body.page-dashboard,
body.page-gallery,
body.page-model {
    overflow: auto;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}
.page-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.page-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Stats Cards ─── */

.dash-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}
.stat-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--font-mono);
}
.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ─── Dashboard Sections ─── */

.dash-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}
.dash-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.dash-section-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}
.dash-filters {
    display: flex;
    gap: 6px;
}
.empty-section {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-section p {
    font-size: 0.95rem;
}
.text-muted { color: var(--text-muted); }

/* ─── Dashboard Table ─── */

.dash-table-wrap {
    overflow-x: auto;
}
.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.dash-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.dash-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.dash-table tr:hover td {
    background: var(--bg-hover);
}
.model-name {
    font-weight: 600;
    color: var(--text);
}
.model-name:hover { color: var(--accent); }
.model-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 4px;
}

/* ─── Badges ─── */

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-public {
    background: rgba(0,255,157,0.12);
    color: var(--accent);
    border: 1px solid rgba(0,255,157,0.3);
}
.badge-private {
    background: rgba(120,120,136,0.12);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ─── Danger Button ─── */

.btn-danger {
    background: rgba(255,85,85,0.1);
    color: var(--danger);
    border: 1px solid rgba(255,85,85,0.3);
}
.btn-danger:hover:not(:disabled) {
    background: rgba(255,85,85,0.2);
    border-color: var(--danger);
}

/* ─── Pagination ─── */

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.15s;
}
.page-link:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.page-link.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* ─── Gallery Grid ─── */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.gallery-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.2s;
}
.gallery-card:hover {
    border-color: var(--accent);
    box-shadow: var(--accent-glow);
    text-decoration: none;
}
.gallery-card-preview {
    aspect-ratio: 4/3;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.gallery-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.gallery-card-icon {
    font-size: 2.5rem;
    color: var(--text-dim);
    opacity: 0.3;
}
.gallery-card-body {
    padding: 12px 14px;
}
.gallery-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.gallery-card-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 6px;
}
.gallery-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* ─── Gallery Search ─── */

.gallery-search form {
    display: flex;
    gap: 6px;
    align-items: center;
}
.search-input {
    width: 240px;
}

/* ─── Model Detail Page ─── */

.model-layout {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}
.model-viewer {
    flex: 1;
    min-width: 0;
}
.model-preview-img {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: block;
}
.model-stl-viewer {
    width: 100%;
    aspect-ratio: 4/3;
    background: radial-gradient(ellipse at center, #0e0e16, #08080c);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.model-viewer-prompt {
    position: absolute;
    bottom: 8px;
    left: 8px;
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    pointer-events: none;
}
.model-preview-placeholder {
    width: 100%;
    aspect-ratio: 4/3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-dim);
}
.model-preview-placeholder span {
    font-size: 3rem;
    opacity: 0.3;
}
.model-preview-placeholder p {
    margin-top: 8px;
    font-size: 0.85rem;
}
.model-description {
    margin-top: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}
.model-description h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.model-description p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}
.model-sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.model-meta-card,
.model-downloads {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}
.model-meta-card h3,
.model-downloads h3 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
}
.model-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    font-size: 0.82rem;
}
.model-dl dt {
    color: var(--text-muted);
}
.model-dl dd {
    color: var(--text);
}
.model-downloads .btn-block + .btn-block {
    margin-top: 6px;
}
.model-source-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.model-source {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.model-by {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ─── API Token Card ─── */

.api-token-card {
    padding: 4px 0;
}
.token-display {
    display: flex;
    align-items: center;
    gap: 8px;
}
.token-value {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    word-break: break-all;
    flex: 1;
}

/* ─── Modal ─── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-card-sm {
    max-width: 420px;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.modal-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

/* ─── Model Picker (within modal) ─── */

.model-picker-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 50vh;
    overflow-y: auto;
}
.model-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.model-picker-item:hover {
    background: var(--bg-hover);
}
.model-picker-name {
    font-weight: 600;
    font-size: 0.88rem;
}
.model-picker-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ─── Responsive for dash/gallery/model ─── */

@media (max-width: 768px) {
    .page-main { padding: 16px; }
    .dash-stats { grid-template-columns: repeat(2, 1fr); }
    .model-layout { flex-direction: column; }
    .model-sidebar { width: 100%; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .search-input { width: 140px; }
    .actions-cell { flex-wrap: wrap; }
    .dash-table { font-size: 0.78rem; }
    .modal-card { width: 95%; }
}
