/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; }
body { background: #0a0a12; color: #e2e8f0; }
.hidden { display: none !important; }

/* ===== MODE SELECTOR ===== */
.mode-selector { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.selector-container { max-width: 640px; width: 100%; text-align: center; }
.selector-container h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.selector-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 32px; }
@media (max-width: 600px) { .selector-cards { grid-template-columns: 1fr; } }
.selector-card { background: #12121e; border: 1px solid #1e1e30; border-radius: 12px; padding: 36px 24px; cursor: pointer; transition: all 0.15s; text-align: center; color: #e2e8f0; font-family: inherit; }
.selector-card:hover { border-color: #7c3aed; background: #7c3aed10; }
.card-icon { font-size: 2.5rem; margin-bottom: 12px; }
.selector-card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
.selector-card p { font-size: 0.85rem; color: #94a3b8; }

/* ===== EDITOR LAYOUT ===== */
.editor-layout { max-width: 1200px; margin: 0 auto; padding: 24px; }
.editor-header { margin-bottom: 24px; }
.editor-header h1 { font-size: 1.6rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.badge { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; background: #7c3aed; color: #fff; padding: 2px 8px; border-radius: 4px; }
.subtitle { font-size: 0.85rem; color: #94a3b8; margin-top: 4px; }
.btn-back { margin-bottom: 12px; font-size: 0.78rem; padding: 6px 12px; }

.editor-body { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 800px) { .editor-body { grid-template-columns: 1fr; } }

/* ===== CONTROLS ===== */
.controls-panel { background: #12121e; border: 1px solid #1e1e30; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.control-group { display: flex; flex-direction: column; gap: 8px; }
.control-group h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: #7c3aed; font-weight: 600; margin-bottom: 4px; }
label { font-size: 0.8rem; color: #cbd5e1; font-weight: 500; }
input[type="text"], input[type="number"], select { background: #0a0a14; border: 1px solid #2a2a40; color: #e2e8f0; border-radius: 8px; padding: 8px 12px; font-size: 0.85rem; font-family: inherit; outline: none; transition: border-color 0.15s; width: 100%; }
input[type="text"]:focus, input[type="number"]:focus, select:focus { border-color: #7c3aed; }
input[type="color"] { width: 100%; height: 40px; border: 1px solid #2a2a40; border-radius: 8px; background: #0a0a14; cursor: pointer; }
input[type="range"] { width: 100%; accent-color: #7c3aed; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== IDENTITY ===== */
.identity-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.identity-value { background: #0a0a14; border: 1px solid #2a2a40; border-radius: 8px; padding: 8px 12px; font-family: 'Roboto Mono', monospace; font-size: 0.78rem; color: #e2e8f0; word-break: break-all; }
.id-value { color: #7c3aed; font-weight: 600; }

/* ===== PRESETS ===== */
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.preset-btn { padding: 10px 4px; background: #0a0a14; border: 1px solid #2a2a40; color: #94a3b8; border-radius: 8px; font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.preset-btn:hover { border-color: #7c3aed; color: #e2e8f0; }
.preset-btn.active { background: #7c3aed; border-color: #7c3aed; color: #fff; }

/* ===== MODES ===== */
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode-option { display: flex; align-items: flex-start; gap: 8px; padding: 10px; background: #0a0a14; border: 1px solid #2a2a40; border-radius: 8px; cursor: pointer; transition: border-color 0.15s; font-size: 0.75rem; }
.mode-option:has(input:checked) { border-color: #7c3aed; background: #7c3aed15; }
.mode-option input { margin-top: 2px; }
.mode-option span { line-height: 1.3; }
.mode-option small { color: #64748b; }
.future-tag { color: #f59e0b !important; font-weight: 600; text-transform: uppercase; font-size: 0.62rem; letter-spacing: 0.03em; }
.mode-config { margin-top: 8px; padding: 12px; background: #0a0a14; border: 1px solid #1e1e30; border-radius: 8px; }
.future-notice { display: flex; flex-direction: column; gap: 8px; }
.future-notice strong { color: #f59e0b; font-size: 0.8rem; }
.future-notice p { font-size: 0.75rem; color: #94a3b8; line-height: 1.5; }

/* ===== PREVIEW ===== */
.preview-panel { display: flex; flex-direction: column; gap: 16px; }
.preview-header { display: flex; align-items: baseline; justify-content: space-between; }
.preview-header h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: #7c3aed; font-weight: 600; }
.hint { font-size: 0.7rem; color: #64748b; }
.preview-stage { background: repeating-conic-gradient(#1a1a2e 0% 25%, #12121e 0% 50%) 0 0 / 24px 24px; border: 1px solid #1e1e30; border-radius: 12px; min-height: 220px; padding: 24px; display: flex; align-items: center; justify-content: center; overflow: hidden; }

/* ===== LINK SECTION ===== */
.link-section { background: #12121e; border: 1px solid #1e1e30; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.link-section h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: #7c3aed; font-weight: 600; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; font-family: 'Roboto Mono', monospace; font-size: 0.72rem; }
#btn-copy, #btn-scene-copy { background: #7c3aed; color: #fff; border: none; border-radius: 8px; padding: 8px 16px; font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background 0.15s; }
#btn-copy:hover, #btn-scene-copy:hover { background: #6d28d9; }
#btn-copy.copied, #btn-scene-copy.copied { background: #16a34a; }
.btn-secondary.copied { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-secondary { background: transparent; color: #94a3b8; border: 1px solid #2a2a40; border-radius: 8px; padding: 8px 16px; font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.btn-secondary:hover { border-color: #7c3aed; color: #e2e8f0; }

/* ===== SCENE LIBRARY ===== */
.scene-library-body { display: flex; flex-direction: column; gap: 16px; }
.scene-library-toolbar { display: flex; gap: 8px; }
.scene-library-list { display: flex; flex-direction: column; gap: 8px; }
.scene-library-item { background: #12121e; border: 1px solid #1e1e30; border-radius: 12px; padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.scene-item-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.scene-item-name { font-size: 1rem; font-weight: 600; color: #e2e8f0; }
.scene-item-meta { font-size: 0.72rem; color: #64748b; font-family: 'Roboto Mono', monospace; }
.scene-item-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.btn-sm { padding: 6px 10px; font-size: 0.72rem; }
.scene-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== SCENE EDITOR ===== */
.scene-body { display: grid; grid-template-columns: 1fr 380px; gap: 24px; height: calc(100vh - 120px); }
@media (max-width: 900px) { .scene-body { grid-template-columns: 1fr; height: auto; } }

.scene-canvas-panel { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.scene-toolbar { display: flex; gap: 8px; align-items: center; }
.btn-add { background: #7c3aed; color: #fff; border: none; border-radius: 8px; padding: 8px 16px; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: background 0.15s; font-family: inherit; }
.btn-add:hover { background: #6d28d9; }
.scene-zoom-info { margin-left: auto; font-size: 0.72rem; color: #64748b; font-family: 'Roboto Mono', monospace; }

.scene-canvas-wrapper { background: repeating-conic-gradient(#1a1a2e 0% 25%, #12121e 0% 50%) 0 0 / 24px 24px; border: 1px solid #1e1e30; border-radius: 12px; padding: 12px; display: flex; justify-content: center; align-items: center; overflow: hidden; flex: 1; min-height: 300px; }
.scene-canvas-viewport { position: relative; overflow: hidden; border-radius: 8px; background: rgba(0, 0, 0, 0.3); }
.scene-canvas { width: 1920px; height: 1080px; position: relative; transform-origin: top left; touch-action: none; }

.scene-element { position: absolute; cursor: move; border: 2px dashed transparent; border-radius: 4px; touch-action: none; }
.scene-element:hover { border-color: rgba(124, 58, 237, 0.5); }
.scene-element.selected { border-color: #7c3aed; border-style: solid; }
.scene-element .goal-overlay { max-width: none; width: 100%; height: 100%; }
.scene-element .text-widget { width: 100%; height: 100%; }
.resize-handle { position: absolute; bottom: 0; right: 0; width: 16px; height: 16px; cursor: nwse-resize; background: #7c3aed; border-radius: 3px 0 4px 0; opacity: 0; transition: opacity 0.15s; touch-action: none; }
.scene-element.selected .resize-handle { opacity: 1; }

.scene-config-panel { background: #12121e; border: 1px solid #1e1e30; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 20px; max-height: calc(100vh - 120px); overflow-y: auto; }

.element-list-item { padding: 8px 12px; background: #0a0a14; border: 1px solid #2a2a40; border-radius: 8px; cursor: pointer; transition: border-color 0.15s; margin-bottom: 4px; font-size: 0.8rem; }
.element-list-item:hover { border-color: #7c3aed; }
.element-list-item.selected { border-color: #7c3aed; background: #7c3aed15; }
.element-label { color: #e2e8f0; }

.layer-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-danger { background: transparent; color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.25); border-radius: 8px; padding: 8px 16px; font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); border-color: #ef4444; }

/* ===== TEXT WIDGET ===== */
.text-widget { background: transparent; padding: 4px; overflow: hidden; line-height: 1.3; }

/* ===== RENDERER ===== */
.renderer { position: fixed; inset: 0; background: transparent; }
#overlay-container { width: 100%; height: 100%; }

/* ===== GOAL OVERLAY ===== */
.goal-overlay { width: 100%; max-width: 500px; padding: 16px 20px; border-radius: 12px; font-family: 'Inter', sans-serif; display: flex; flex-direction: column; gap: 10px; }
.goal-title { font-weight: 700; line-height: 1.2; word-break: break-word; }
.goal-values { display: flex; align-items: baseline; justify-content: space-between; font-weight: 600; }
.goal-current { font-size: 1.3em; }
.goal-max { font-size: 1em; opacity: 0.7; }
.goal-percent { font-size: 0.85em; opacity: 0.6; margin-left: 8px; }
.goal-bar-track { width: 100%; height: 14px; border-radius: 7px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.goal-bar-fill { height: 100%; border-radius: 7px; transition: width 0.6s ease-out; }

.goal-overlay.preset-clean { background: #1a1a2e; border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); }
.goal-overlay.preset-glass { background: rgba(255, 255, 255, 0.08); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25); }
.goal-overlay.preset-minimal { background: transparent; border: none; box-shadow: none; padding: 8px 0; }
.goal-overlay.preset-minimal .goal-bar-track { height: 6px; border-radius: 3px; }
.goal-overlay.preset-minimal .goal-bar-fill { border-radius: 3px; }
.goal-overlay.preset-neon { background: #0a0a14; border: 1.5px solid; box-shadow: 0 0 20px currentColor, inset 0 0 20px rgba(0, 0, 0, 0.5); }
.goal-overlay.preset-neon .goal-title, .goal-overlay.preset-neon .goal-values { text-shadow: 0 0 10px currentColor; }
.goal-overlay.preset-neon .goal-bar-track { background: rgba(255, 255, 255, 0.05); border: 1px solid; }
.goal-overlay.preset-neon .goal-bar-fill { box-shadow: 0 0 12px currentColor; }

/* ===== ANIMATIONS ===== */
@keyframes enter-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes enter-slide { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes enter-zoom { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
@keyframes enter-pop { 0% { opacity: 0; transform: scale(0.6); } 60% { opacity: 1; transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
@keyframes exit-fade { from { opacity: 1; } to { opacity: 0; } }
@keyframes exit-slide { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }
.anim-enter-fade { animation: enter-fade 0.4s ease-out forwards; }
.anim-enter-slide { animation: enter-slide 0.4s ease-out forwards; }
.anim-enter-zoom { animation: enter-zoom 0.4s ease-out forwards; }
.anim-enter-pop { animation: enter-pop 0.5s ease-out forwards; }
.anim-exit-fade { animation: exit-fade 0.4s ease-in forwards; }
.anim-exit-slide { animation: exit-slide 0.4s ease-in forwards; }