:root {
    --primary: #d4af37;
    --bg-dark: #0f172a;
    --panel-bg: #1e293b;
    --border: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
    margin: 0; padding: 0;
    background: var(--bg-dark); color: var(--text-main);
    font-family: 'Inter', sans-serif;
    height: 100vh; display: flex; flex-direction: column;
}

/* --- HEADER --- */
.app-header {
    height: 60px; background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px; z-index: 100;
}
.logo { font-family: 'Montserrat', sans-serif; font-weight: 900; font-size: 20px; color: var(--primary); display: flex; gap: 10px; align-items: center; }
.badge { background: var(--primary); color: #000; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }

/* --- LAYOUT --- */
.app-wrapper { flex: 1; position: relative; overflow: hidden; }

.studio-container {
    display: flex; height: 100%;
    overflow-y: auto;
}

.panel-left, .panel-right {
    padding: 25px; overflow-y: auto;
}

.panel-left {
    width: 400px; background: var(--panel-bg);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 25px;
}

.panel-right { flex: 1; display: flex; flex-direction: column; gap: 15px; }

/* --- COMPONENTS --- */
.section-title {
    font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
    font-weight: 700; color: var(--text-muted); margin-bottom: 10px;
    display: flex; justify-content: space-between; align-items: center;
}

.control-group label { display: block; font-size: 11px; font-weight: 600; margin-bottom: 8px; color: var(--text-muted); }

/* Toggle Buttons */
.toggle-row { display: flex; gap: 10px; }
.toggle-btn {
    flex: 1; background: var(--bg-dark); border: 1px solid var(--border);
    color: var(--text-muted); padding: 12px; border-radius: 8px;
    cursor: pointer; font-weight: 600; font-size: 13px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: 0.2s;
}
.toggle-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(212, 175, 55, 0.1); }

/* Theme Grid */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.t-card {
    background: var(--bg-dark); border: 1px solid var(--border);
    padding: 10px 5px; text-align: center; border-radius: 6px;
    font-size: 11px; color: var(--text-muted); cursor: pointer; transition: 0.2s;
}
.t-card:hover { border-color: #fff; }
.t-card.active { background: var(--primary); color: #000; border-color: var(--primary); font-weight: 700; }

/* Upload Zones */
.upload-zone {
    border: 2px dashed var(--border); border-radius: 10px;
    padding: 20px; display: flex; align-items: center; gap: 15px;
    cursor: pointer; transition: 0.2s; background: rgba(0,0,0,0.2);
}
.upload-zone:hover { border-color: var(--primary); background: rgba(212, 175, 55, 0.05); }
.zone-icon { font-size: 24px; color: var(--primary); }
.z-title { display: block; font-weight: 700; font-size: 14px; }
.z-sub { font-size: 11px; color: var(--text-muted); }

.gallery-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 10px;
}
.thumb { aspect-ratio: 1; background: #000; position: relative; border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb-close {
    position: absolute; top: 2px; right: 2px;
    background: rgba(220, 38, 38, 0.9); width: 18px; height: 18px;
    display: flex; justify-content: center; align-items: center;
    border-radius: 50%; font-size: 10px; color: white; cursor: pointer;
}

.upload-row { display: flex; gap: 10px; margin-top: 10px; }
.upload-mini {
    flex: 1; background: var(--bg-dark); border: 1px solid var(--border);
    border-radius: 8px; padding: 12px; display: flex; align-items: center; gap: 10px;
    cursor: pointer; position: relative; transition: 0.2s;
}
.upload-mini:hover { border-color: #fff; }
.mini-text { display: flex; flex-direction: column; }
.mini-text span { font-size: 12px; font-weight: 700; }
.mini-text small { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
.clear-icon { position: absolute; right: 8px; top: 8px; color: #ef4444; font-size: 12px; }

/* Script Area */
.toggle-text-wrapper { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--primary); cursor: pointer; }
textarea {
    flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--border);
    border-radius: 8px; padding: 15px; color: #cbd5e1; font-family: monospace;
    line-height: 1.5; resize: none; min-height: 300px;
}
textarea:focus { border-color: var(--primary); outline: none; }

.action-bar { display: flex; gap: 15px; margin-top: auto; }
.big-btn {
    flex: 1; padding: 16px; border: none; border-radius: 8px;
    font-weight: 800; text-transform: uppercase; font-size: 14px;
    cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 10px;
    transition: transform 0.1s;
}
.big-btn:active { transform: scale(0.98); }
.primary { background: var(--primary); color: #000; }
.danger { background: #e11d48; color: #fff; }

/* --- CINEMA MODE --- */
.cinema-overlay {
    position: absolute; inset: 0; background: #000; z-index: 200;
    display: flex; flex-direction: column;
}
.cinema-header {
    height: 60px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    position: absolute; top: 0; width: 100%; z-index: 210;
}
.back-btn {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    color: white; padding: 8px 16px; border-radius: 20px; cursor: pointer;
    font-weight: 600; display: flex; align-items: center; gap: 5px;
    backdrop-filter: blur(10px);
}
.rec-badge {
    background: rgba(220, 38, 38, 0.9); padding: 5px 12px; border-radius: 20px;
    font-size: 11px; font-weight: 700; color: white; display: flex; align-items: center; gap: 6px;
}
.rec-dot { width: 8px; height: 8px; background: white; border-radius: 50%; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

.viewport-container {
    flex: 1; display: flex; justify-content: center; align-items: center;
    background: #050505;
}
#frame {
    height: 100%; aspect-ratio: 9/16; position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}
#previewCanvas { width: 100%; height: 100%; display: block; }

.replay-layer {
    position: absolute; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    color: var(--primary); font-size: 40px; cursor: pointer;
    opacity: 0; pointer-events: none; transition: 0.3s;
}
.replay-layer.active { opacity: 1; pointer-events: all; }
.replay-layer span { font-size: 14px; font-weight: 700; margin-top: 10px; text-transform: uppercase; }

/* --- FOOTER --- */
footer {
    height: 40px; background: var(--bg-dark); border-top: 1px solid var(--border);
    display: flex; justify-content: center; align-items: center;
    font-size: 11px; color: var(--text-muted);
}
.dev-name { color: var(--primary); font-weight: 700; margin-left: 4px; }

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 900px) {
    .studio-container { flex-direction: column; }
    .panel-left { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 20px; height: auto; max-height: 40vh; }
    .panel-right { flex: 1; }
    #frame { width: 100%; height: auto; aspect-ratio: 9/16; max-height: 80vh; }
    .action-bar { padding-bottom: 20px; }
}

.hidden { display: none !important; }
/* --- ASPECT RATIO FIX --- */
#frame.wide-mode {
    aspect-ratio: 16/9 !important;
    max-height: 60vh;
}

/* Ensure mobile view adapts */
@media (max-width: 900px) {
    #frame.wide-mode {
        width: 100%;
        height: auto;
    }
}

