:root {
    --bg: #141414;
    --bg2: #1c1c1c;
    --bg3: #242424;
    --border: #2e2e2e;
    --text: #d4d4d4;
    --text-muted: #6b6b6b;
    --text-dim:   #444444;
    --accent: #4f9eff;
    --accent-dim: #1a3a5c;
    --green: #3dd68c;
    --font-ui: 'Space Grotesk', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
    --topbar-height: 38px;
}

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

body {
    height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    overflow: hidden;
}

/* ── LAUNCHER ─────────────────────────────────────────────── */
.launcher-overlay {
    position: fixed;
    inset: 0;
    background: #0d0d0d;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.launcher-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    padding: 48px 52px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 32px 80px rgba(0,0,0,0.6);
    min-width: 380px;
}

.launcher-logo {
    font-family: var(--font-code);
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -2px;
    margin-bottom: 12px;
    line-height: 1;
}

.logo-sky  { color: #fff; }
.logo-dev  { color: var(--accent); }
.logo-version {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0;
    vertical-align: top;
    margin-left: 6px;
    margin-top: 8px;
    display: inline-block;
}

.launcher-card p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
    font-family: var(--font-ui);
}

.btn-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-p, .btn-s {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 8px;
    border: none;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-p {
    background: var(--accent);
    color: #fff;
}
.btn-p:hover { background: #6aadff; transform: translateY(-1px); }

.btn-s {
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-s:hover { background: #2e2e2e; transform: translateY(-1px); }

/* ── MAIN LAYOUT ──────────────────────────────────────────── */
#app-container {
    display: grid;
    grid-template-columns: 220px 1fr 1fr;
    width: 100%;
    height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.sidebar-top {
    padding: 0 14px;
    height: var(--topbar-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.folder-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg3); color: var(--text); }

#file-list {
    overflow-y: auto;
    padding: 8px 8px;
    flex: 1;
    min-height: 0;
}

#file-list::-webkit-scrollbar { width: 4px; }
#file-list::-webkit-scrollbar-track { background: transparent; }
#file-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.file-item {
    padding: 7px 10px;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: 13px;
    font-family: var(--font-code);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.12s;
}

.file-item::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.12s;
}

.file-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-delete-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    border-radius: 4px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.file-item:hover .file-delete-btn { display: block; }
.file-delete-btn:hover {
    opacity: 1;
    color: #ff5f5f;
    background: rgba(255, 95, 95, 0.1);
}

.file-item:hover {
    background: var(--bg3);
    color: var(--text);
}
.file-item:hover::before { background: var(--text-muted); }

.file-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}
.file-item.active::before { background: var(--accent); }

/* ── EDITOR WRAPPER ───────────────────────────────────────── */
.editor-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.editor-topbar, .preview-topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
    flex-shrink: 0;
    gap: 8px;
}

.file-tab {
    font-family: var(--font-code);
    font-size: 12px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 3px 12px;
    border-radius: 4px;
    border-bottom: 1px solid var(--bg);
    margin-bottom: -1px;
}

.editor-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.topbar-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}
.topbar-btn:hover { background: var(--bg3); color: var(--text); border-color: #444; }

.save-btn { color: var(--green); border-color: #1e4d38; }
.save-btn:hover { background: #162e23; color: var(--green); border-color: var(--green); }
.export-btn { color: var(--accent); border-color: #1a3a5c; }
.export-btn:hover { background: #111e2e; color: var(--accent); border-color: var(--accent); }
.export-btn.loading { opacity: 0.6; pointer-events: none; }


#monaco-editor {
    flex: 1;
    overflow: hidden;
}

/* ── PREVIEW ──────────────────────────────────────────────── */
.preview-section {
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
    z-index: 10;
}

.copyright {
    position: fixed;
    bottom: 0;
    font-size: smaller;
    color: #555;
    padding-bottom: 10px;
}

.preview-topbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}

.preview-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

#preview-window {
    flex: 1;
    width: 100%;
    border: none;
}

/* ── SAVE FLASH ───────────────────────────────────────────── */
.save-flash {
    position: fixed;
    bottom: 20px;
    right: 24px;
    background: var(--bg2);
    border: 1px solid var(--green);
    color: var(--green);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    z-index: 999;
    animation: flashIn 0.2s ease, flashOut 0.3s ease 1.2s forwards;
}

@keyframes flashIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes flashOut { from { opacity: 1; } to { opacity: 0; } }

/* ── NEW FILE MODAL ───────────────────────────────────────── */
#new-file-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
}

.nfm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    pointer-events: all;
    animation: nfm-fade-in 0.18s ease forwards;
}

.nfm-panel {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 220px; /* matches sidebar width */
    background: #1a1a1a;
    border: 1px solid #333;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    pointer-events: all;
    transform: translateY(100%);
    transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.nfm-panel--visible {
    transform: translateY(0);
}

.nfm-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 14px 12px;
    border-bottom: 1px solid #2a2a2a;
}

.nfm-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    color: var(--accent);
    flex-shrink: 0;
}

.nfm-title {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.2px;
    flex: 1;
}

.nfm-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.nfm-close:hover { background: #2e2e2e; color: var(--text); }

.nfm-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nfm-label {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.nfm-input-row {
    display: flex;
    align-items: center;
    background: #111;
    border: 1px solid #333;
    border-radius: 7px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.nfm-input-row:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79, 158, 255, 0.12);
}

.nfm-slug-prefix {
    padding: 0 4px 0 10px;
    font-family: var(--font-code);
    font-size: 13px;
    color: var(--text-muted);
    user-select: none;
}

.nfm-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    padding: 9px 10px 9px 2px;
    font-family: var(--font-code);
    font-size: 13px;
    color: var(--text);
    caret-color: var(--accent);
    width: 0; /* flex takes over */
}
.nfm-input::placeholder { color: #444; }

.nfm-hint {
    font-family: var(--font-ui);
    font-size: 11px;
    color: #555;
    line-height: 1.5;
    min-height: 16px;
    transition: color 0.15s;
}
.nfm-hint--active { color: #666; }
.nfm-hint strong { color: var(--text-muted); font-weight: 600; }
.nfm-hint code {
    font-family: var(--font-code);
    font-size: 10.5px;
    color: #4f9eff88;
}
.nfm-hint--error { color: #ff6b6b; }

.nfm-footer {
    display: flex;
    gap: 8px;
    padding: 12px 14px 14px;
    border-top: 1px solid #222;
}

.nfm-btn-cancel,
.nfm-btn-create {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    border-radius: 7px;
    border: none;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.nfm-btn-cancel {
    background: #222;
    color: var(--text-muted);
    border: 1px solid #2e2e2e;
}
.nfm-btn-cancel:hover { background: #2a2a2a; color: var(--text); }

.nfm-btn-create {
    background: var(--accent);
    color: #fff;
}
.nfm-btn-create:hover:not(:disabled) {
    background: #6aadff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 158, 255, 0.3);
}
.nfm-btn-create:disabled {
    background: #1e2a3a;
    color: #2a4a6a;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.nfm-btn-delete {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    border-radius: 7px;
    border: none;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    background: #4a1a1a;
    color: #ff6b6b;
    border: 1px solid #6b2222;
}
.nfm-btn-delete:hover {
    background: #ff4444;
    color: #fff;
    border-color: #ff4444;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3);
}

.scd-panel { max-width: 340px; }
.scd-icon  { color: #ff6b6b !important; border-color: #4a1a1a !important; background: #2a1010 !important; }
.scd-body  { padding: 16px 16px 8px; }
.scd-message { color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.scd-message strong { color: var(--text); font-weight: 600; }

@keyframes nfm-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── SIDEBAR LOGO ─────────────────────────────────────────── */
.sidebar-logo {
    padding: 18px 16px 14px;
    font-family: var(--font-code);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -1px;
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.logo-sky { color: #ffffff; }
.logo-dev { color: var(--accent); }

/* ── SIDEBAR FOOTER ───────────────────────────────────────── */
/* ── RENAME INPUT ─────────────────────────────────────────── */
.file-rename-input {
    flex: 1;
    background: var(--bg3);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text);
    font-family: var(--font-code);
    font-size: 12px;
    padding: 2px 6px;
    outline: none;
    width: 100%;
    min-width: 0;
}

/* Equal-height panes for pages and assets */
.sidebar-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
#modules-pane .sidebar-top { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* ── ASSET PANEL ──────────────────────────────────────────── */
.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: var(--topbar-height);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#asset-list {
    padding: 0 6px 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

#module-list {
    padding: 0 6px 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.asset-empty {
    font-size: 11px;
    color: var(--text-dim);
    padding: 8px 8px;
    line-height: 1.6;
}

.asset-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 2px;
}
.asset-item:hover { background: var(--bg3); }
.asset-item:hover .asset-delete-btn { display: block; }

.asset-thumb {
    width: 32px;
    height: 32px;
    border-radius: 5px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg3);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}
.asset-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.asset-thumb-icon { font-size: 16px; }
.asset-thumb-font {
    font-size: 13px;
    font-weight: 700;
    color: #bd93f9;
    letter-spacing: -0.5px;
}

.asset-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.asset-name {
    font-size: 12px;
    font-family: var(--font-code);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.asset-hint {
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-code);
}

.asset-delete-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    border-radius: 4px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.asset-delete-btn:hover {
    opacity: 1;
    color: #ff5f5f;
    background: rgba(255, 95, 95, 0.1);
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg2);
}

.sidebar-footer-copy {
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--muted2);
    line-height: 1.5;
}

/* ── LAUNCHER NAV ─────────────────────────────────────────── */
.launcher-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    z-index: 10;
}

.launcher-nav-logo {
    font-family: var(--font-code);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -1px;
    text-decoration: none;
}

.launcher-nav-links {
    display: flex;
    gap: 4px;
}

.launcher-nav-link {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    color: #555;
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
}
.launcher-nav-link:hover  { background: rgba(255,255,255,0.05); color: #999; }
.launcher-nav-link.active { color: #fff; }