/* ========================================
 * FCS Game Studio - Style Sheet
 * Dark IDE aesthetic matching portal palette
 * ======================================== */

/* ----------------------------------------
 * CSS Variables
 * ---------------------------------------- */
:root {
    /* Core studio palette */
    --studio-bg: #0a0a1a;
    --studio-panel: #12122a;
    --studio-panel-light: #1a1a35;
    --studio-border: #1e1e3a;
    --studio-border-light: #2a2a4a;
    --studio-accent: #a855f7;

    /* Portal palette (shared) */
    --accent-gold: #ffd700;
    --accent-pink: #ff6b9d;
    --accent-cyan: #00d4ff;
    --accent-purple: #a855f7;
    --accent-green: #22c55e;
    --accent-orange: #ff8c00;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.65);
    --text-muted: rgba(255, 255, 255, 0.35);

    /* Layout measurements */
    --topbar-height: 48px;
    --sidebar-width: 240px;
    --console-height: 120px;
    --console-collapsed-height: 32px;
    --preview-height: 0px; /* Updated dynamically when preview is open */

    /* Editor */
    --editor-tab-height: 36px;
    --file-subtab-height: 32px;

    /* Animation */
    --transition-fast: 0.15s ease;
    --transition-med: 0.25s ease;
    --transition-slow: 0.35s ease;
}

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

html,
body {
    height: 100%;
    overflow: hidden;
}

.studio-body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--studio-bg);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ----------------------------------------
 * Top Bar
 * ---------------------------------------- */
.studio-topbar {
    height: var(--topbar-height);
    background: var(--studio-panel);
    border-bottom: 1px solid var(--studio-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    flex-shrink: 0;
    gap: 8px;
    z-index: 100;
    position: relative;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.topbar-center {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    flex: 1;
}

.studio-logo {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    flex-shrink: 0;
}

.topbar-divider {
    color: var(--studio-border-light);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.project-name {
    font-family: 'Jua', sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.project-name:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.unsaved-indicator {
    font-size: 0.75rem;
    color: var(--accent-orange);
    background: rgba(255, 140, 0, 0.12);
    border: 1px solid rgba(255, 140, 0, 0.25);
    border-radius: 10px;
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
    animation: indicatorPulse 2s ease-in-out infinite;
}

@keyframes indicatorPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Topbar buttons */
.topbar-btn {
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--studio-border-light);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-family: 'Jua', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.topbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
}

.topbar-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-save {
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--accent-green);
}

.btn-save:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.2);
}

.btn-preview {
    border-color: rgba(0, 212, 255, 0.3);
    color: var(--accent-cyan);
}

.btn-preview:hover:not(:disabled) {
    background: rgba(0, 212, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.2);
}

.btn-publish {
    border-color: rgba(168, 85, 247, 0.3);
    color: var(--accent-purple);
}

.btn-publish:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.12);
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.2);
}

.btn-portal {
    border-color: rgba(255, 215, 0, 0.25);
    color: var(--accent-gold);
}

.btn-portal:hover {
    background: rgba(255, 215, 0, 0.08);
    border-color: rgba(255, 215, 0, 0.45);
}

/* ----------------------------------------
 * Auth Required Overlay
 * ---------------------------------------- */
.auth-required-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-med);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.auth-required-card {
    background: var(--studio-panel-light);
    border: 1px solid rgba(168, 85, 247, 0.25);
    border-radius: 20px;
    padding: 40px 36px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 40px rgba(168, 85, 247, 0.06);
    animation: slideUp var(--transition-med);
}

@keyframes slideUp {
    from { transform: translateY(24px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.auth-required-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.auth-required-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
    line-height: 1.6;
}

.btn-login-studio {
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    border: none;
    border-radius: 12px;
    color: white;
    font-family: 'Jua', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
    min-width: 160px;
    min-height: 44px;
}

.btn-login-studio:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.45);
}

/* ----------------------------------------
 * Studio Main — 3-Panel Grid
 * ---------------------------------------- */
.studio-main {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-width);
    grid-template-rows: 1fr;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
    flex: 1;
}

/* ----------------------------------------
 * Sidebar (Left & Right)
 * ---------------------------------------- */
.studio-sidebar {
    background: var(--studio-panel);
    border-color: var(--studio-border);
    border-style: solid;
    border-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.studio-sidebar-left {
    border-right-width: 1px;
}

.studio-sidebar-right {
    border-left-width: 1px;
}

.sidebar-header {
    height: var(--editor-tab-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid var(--studio-border);
    flex-shrink: 0;
}

.sidebar-title {
    font-family: 'Jua', sans-serif;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-icon-btn {
    width: 22px;
    height: 22px;
    border: 1px solid var(--studio-border-light);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    padding: 0;
}

.sidebar-icon-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.4);
    color: var(--accent-purple);
}

/* ----------------------------------------
 * File Tree (Left Sidebar)
 * ---------------------------------------- */
.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.file-tree::-webkit-scrollbar {
    width: 4px;
}

.file-tree::-webkit-scrollbar-track {
    background: transparent;
}

.file-tree::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.file-tree::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* File tree items (created via DOM methods in JS) */
.file-tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.file-tree-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.file-tree-item.active {
    background: rgba(168, 85, 247, 0.15);
    color: var(--accent-purple);
    border-right: 2px solid var(--accent-purple);
}

.file-tree-item.is-folder {
    font-weight: 700;
    color: var(--accent-cyan);
}

.file-tree-item.is-folder:hover {
    color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.06);
}

.file-tree-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
    opacity: 0.75;
}

.file-tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-tree-folder-contents {
    padding-left: 14px;
}

/* ----------------------------------------
 * Center Panel
 * ---------------------------------------- */
.studio-center {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0d0d20;
    min-width: 0;
}

/* ----------------------------------------
 * Editor Tabs (Code / Sprite / Sound / Map)
 * ---------------------------------------- */
.editor-tabs {
    height: var(--editor-tab-height);
    display: flex;
    align-items: stretch;
    background: var(--studio-panel);
    border-bottom: 1px solid var(--studio-border);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.editor-tabs::-webkit-scrollbar {
    display: none;
}

.editor-tab {
    padding: 0 18px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-family: 'Jua', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition: color var(--transition-fast), background var(--transition-fast);
    border-right: 1px solid var(--studio-border);
    min-width: 80px;
    min-height: 44px;
}

.editor-tab:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.editor-tab.active {
    color: var(--accent-purple);
    background: rgba(168, 85, 247, 0.08);
}

.editor-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-purple);
    border-radius: 2px 2px 0 0;
}

/* ----------------------------------------
 * Editor Panels
 * ---------------------------------------- */
.editor-panel {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.editor-panel.active {
    display: flex;
}

/* File sub-tabs (index.html / script.js / style.css) */
.file-sub-tabs {
    height: var(--file-subtab-height);
    display: flex;
    align-items: stretch;
    background: #0d0d20;
    border-bottom: 1px solid var(--studio-border);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.file-sub-tabs::-webkit-scrollbar {
    display: none;
}

/* File sub-tab items (created via DOM in code-editor.js) */
.file-sub-tab {
    padding: 0 14px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition: color var(--transition-fast), background var(--transition-fast);
    border-right: 1px solid var(--studio-border);
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.file-sub-tab:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.file-sub-tab.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.file-sub-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-cyan);
}

.file-sub-tab-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-orange);
    flex-shrink: 0;
}

.file-sub-tab-dot.clean {
    display: none;
}

/* Monaco container */
.monaco-container {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ----------------------------------------
 * Coming Soon Panels
 * ---------------------------------------- */
.coming-soon-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    padding: 24px;
    text-align: center;
}

.coming-soon-icon {
    font-size: 3rem;
    opacity: 0.5;
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.coming-soon-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.coming-soon-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 280px;
    line-height: 1.6;
}

/* ----------------------------------------
 * Console Area
 * ---------------------------------------- */
.console-area {
    height: calc(var(--console-height) + var(--console-collapsed-height));
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--studio-border);
    background: #08081a;
    flex-shrink: 0;
    transition: height var(--transition-med);
    overflow: hidden;
}

.console-area.collapsed {
    height: var(--console-collapsed-height);
}

.console-header {
    height: var(--console-collapsed-height);
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 8px;
    border-bottom: 1px solid var(--studio-border);
    flex-shrink: 0;
    background: var(--studio-panel);
}

.console-title {
    font-family: 'Jua', sans-serif;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex: 1;
}

.console-clear-btn,
.console-toggle-btn {
    height: 22px;
    padding: 0 8px;
    border: 1px solid var(--studio-border-light);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.console-clear-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.console-toggle-btn {
    width: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.console-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.console-area.collapsed .console-toggle-btn {
    transform: rotate(180deg);
}

.console-output {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
    font-family: 'Noto Sans KR', monospace, sans-serif;
    font-size: 0.78rem;
    line-height: 1.5;
}

.console-output::-webkit-scrollbar {
    width: 4px;
}

.console-output::-webkit-scrollbar-track {
    background: transparent;
}

.console-output::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* Console log entries (created via DOM in preview.js) */
.console-entry {
    padding: 1px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.console-entry-time {
    color: var(--text-muted);
    font-size: 0.72rem;
    flex-shrink: 0;
    padding-top: 1px;
}

.console-entry-text {
    flex: 1;
    min-width: 0;
    word-break: break-all;
    color: var(--text-secondary);
}

.console-entry.log .console-entry-text {
    color: var(--text-secondary);
}

.console-entry.warn .console-entry-text {
    color: var(--accent-orange);
}

.console-entry.error .console-entry-text {
    color: #ef4444;
}

.console-entry.info .console-entry-text {
    color: var(--accent-cyan);
}

/* ----------------------------------------
 * Properties Panel (Right Sidebar)
 * ---------------------------------------- */
.props-panel {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.props-panel::-webkit-scrollbar {
    width: 4px;
}

.props-panel::-webkit-scrollbar-track {
    background: transparent;
}

.props-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.prop-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.prop-label {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.prop-input,
.prop-textarea,
.prop-select {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--studio-border-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.82rem;
    padding: 8px 10px;
    width: 100%;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    resize: none;
}

.prop-input:focus,
.prop-textarea:focus,
.prop-select:focus {
    outline: none;
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(168, 85, 247, 0.07);
}

.prop-input::placeholder,
.prop-textarea::placeholder {
    color: var(--text-muted);
}

.prop-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(255,255,255,0.35)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.prop-select option {
    background: #1a1a35;
    color: var(--text-primary);
}

.prop-textarea {
    min-height: 70px;
}

/* Storage bar */
.storage-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 2px;
}

.storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
    border-radius: 3px;
    transition: width var(--transition-med);
    min-width: 0;
}

.storage-bar-fill.warning {
    background: linear-gradient(90deg, var(--accent-orange), #ff4444);
}

.storage-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ----------------------------------------
 * Preview Panel (bottom, collapsible)
 * ---------------------------------------- */
.preview-panel {
    height: 300px;
    border-top: 1px solid var(--studio-border);
    background: var(--studio-panel);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: height var(--transition-med);
}

.preview-header {
    height: 34px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    border-bottom: 1px solid var(--studio-border);
    flex-shrink: 0;
}

.preview-title {
    font-family: 'Jua', sans-serif;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex: 1;
}

.preview-btn {
    height: 24px;
    padding: 0 10px;
    border: 1px solid var(--studio-border-light);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: 24px;
}

.preview-btn:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.3);
    color: var(--accent-cyan);
}

.preview-btn-close:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.preview-frame {
    flex: 1;
    border: none;
    background: white;
    width: 100%;
}

/* ----------------------------------------
 * Template Modal
 * ---------------------------------------- */
.template-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-med);
}

.template-modal {
    background: var(--studio-panel-light);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 20px;
    padding: 32px 28px;
    max-width: 600px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp var(--transition-med);
}

.template-modal::-webkit-scrollbar {
    width: 4px;
}

.template-modal::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.template-modal-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.template-modal-desc {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 20px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

/* Template cards (created via DOM in studio.js) */
.template-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--studio-border-light);
    border-radius: 14px;
    padding: 18px 14px;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.template-card:hover {
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.15);
}

.template-card:focus {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

.template-card-icon {
    font-size: 2rem;
}

.template-card-name {
    font-family: 'Jua', sans-serif;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.template-card-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.template-modal-close {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--studio-border-light);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-family: 'Jua', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
}

.template-modal-close:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* ----------------------------------------
 * Toast Notification
 * ---------------------------------------- */
.studio-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--studio-panel-light);
    border: 1px solid var(--studio-border-light);
    border-radius: 12px;
    padding: 10px 20px;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.88rem;
    color: var(--text-primary);
    z-index: 9999;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    animation: toastIn 0.25s ease forwards;
    max-width: 90vw;
    text-align: center;
    pointer-events: none;
}

.studio-toast.toast-success {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.1);
    color: var(--accent-green);
}

.studio-toast.toast-error {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.studio-toast.toast-warning {
    border-color: rgba(255, 140, 0, 0.4);
    background: rgba(255, 140, 0, 0.1);
    color: var(--accent-orange);
}

.studio-toast.toast-info {
    border-color: rgba(0, 212, 255, 0.4);
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-cyan);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(12px);
    }
}

.studio-toast.hiding {
    animation: toastOut 0.2s ease forwards;
}

/* ----------------------------------------
 * Scrollbar — global for studio panels
 * ---------------------------------------- */
.studio-body ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.studio-body ::-webkit-scrollbar-track {
    background: transparent;
}

.studio-body ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.studio-body ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ----------------------------------------
 * Focus Visible — accessibility
 * ---------------------------------------- */
:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* ----------------------------------------
 * Responsive — Mobile (collapse sidebars)
 * ---------------------------------------- */
@media (max-width: 900px) {
    :root {
        --sidebar-width: 200px;
    }
}

@media (max-width: 768px) {
    .studio-main {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }

    .studio-sidebar-left {
        display: none;
    }

    .studio-sidebar-right {
        display: none;
    }

    .studio-logo {
        font-size: 0.88rem;
    }

    .topbar-divider,
    .project-name {
        display: none;
    }

    .topbar-btn {
        height: 28px;
        padding: 0 8px;
        font-size: 0.75rem;
    }

    .preview-panel {
        height: 220px;
    }
}

@media (max-width: 480px) {
    .topbar-center {
        gap: 4px;
    }

    .btn-save,
    .btn-preview,
    .btn-publish {
        padding: 0 8px;
        font-size: 0.72rem;
    }

    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ----------------------------------------
 * Studio sidebar toggle (mobile)
 * ---------------------------------------- */
.studio-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 70px;
    right: 14px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(168, 85, 247, 0.4);
    background: rgba(168, 85, 247, 0.2);
    color: var(--accent-purple);
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 500;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all var(--transition-fast);
}

.studio-sidebar-toggle:hover {
    background: rgba(168, 85, 247, 0.35);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
}

@media (max-width: 768px) {
    .studio-sidebar-toggle {
        display: flex;
    }
}

/* ----------------------------------------
 * Mobile drawer — sidebars as overlay
 * ---------------------------------------- */
@media (max-width: 768px) {
    .studio-sidebar-left.drawer-open,
    .studio-sidebar-right.drawer-open {
        display: flex;
        position: fixed;
        top: var(--topbar-height);
        bottom: 0;
        width: 85vw;
        max-width: 280px;
        z-index: 600;
        background: var(--studio-panel);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
        animation: drawerSlideIn var(--transition-med);
    }

    .studio-sidebar-left.drawer-open {
        left: 0;
        border-right: 1px solid var(--studio-border);
    }

    .studio-sidebar-right.drawer-open {
        right: 0;
        border-left: 1px solid var(--studio-border);
    }

    @keyframes drawerSlideIn {
        from { transform: translateX(-100%); opacity: 0; }
        to { transform: translateX(0); opacity: 1; }
    }

    .studio-sidebar-right.drawer-open {
        animation-name: drawerSlideInRight;
    }

    @keyframes drawerSlideInRight {
        from { transform: translateX(100%); opacity: 0; }
        to { transform: translateX(0); opacity: 1; }
    }
}

/* ----------------------------------------
 * Loading state
 * ---------------------------------------- */
.studio-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 10px;
    color: var(--text-muted);
    font-family: 'Jua', sans-serif;
    font-size: 0.9rem;
}

.studio-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(168, 85, 247, 0.2);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ----------------------------------------
 * Resize handle (future drag-to-resize)
 * ---------------------------------------- */
.resize-handle {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.resize-handle:hover,
.resize-handle.dragging {
    background: rgba(168, 85, 247, 0.4);
}

/* ----------------------------------------
 * Utility classes
 * ---------------------------------------- */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
