@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600;700&display=swap');
        
        :root {
            --gold: #d4af37;
            --gold-bright: #fcd34d;
            --amber: #f59e0b;
            --blue: #3b82f6;
            --cyan: #06b6d4;
            --red: #ef4444;
            --font-heading: 'Cinzel', serif;
            --font-mono: 'JetBrains Mono', monospace;
            --font-body: 'Inter', sans-serif;
        }

        body {
            font-family: var(--font-body);
            background-color: #0a0d14;
            color: #e2e8f0;
            height: 100vh;
            overflow: hidden;
            margin: 0;
            user-select: none;
        }
        
        #main-container { display: flex; height: 100vh; width: 100vw; overflow: hidden; }
        
        /* Left Editor Panel */
        #editor-panel {
            width: 460px;
            flex-shrink: 0;
            overflow-y: auto;
            padding: 1rem;
            border-right: 1px solid #1e293b;
            background: #0f1422;
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            z-index: 20;
            user-select: text;
        }

        #visual-panel {
            flex-grow: 1;
            display: flex;
            flex-direction: column;
            background: #07090f;
            position: relative;
            overflow: hidden;
        }
        
        /* Map Canvas */
        #map-container {
            flex-grow: 1;
            overflow: hidden;
            cursor: grab;
            position: relative; 
            background-image: radial-gradient(#1e293b 1px, transparent 1px);
            background-size: 24px 24px;
        }
        #map-container:active { cursor: grabbing; }
        #map-content { transform-origin: 0 0; transition: transform 0.08s ease-out; }
        
        /* Room Nodes */
        .map-room rect {
            fill: #162035;
            stroke: #2e3e5c;
            stroke-width: 1.2;
            transition: all 0.12s ease;
            cursor: pointer;
            rx: 4;
        }
        .map-room:hover rect {
            fill: #223254;
            stroke: var(--gold-bright);
            stroke-width: 1.5;
            filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.4));
        }
        .map-room.current rect {
            fill: #78350f;
            stroke: var(--gold-bright);
            stroke-width: 2.2;
            filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.6));
        }
        .map-room.quest-target rect {
            stroke: #eab308;
            stroke-width: 2;
            stroke-dasharray: 3,2;
        }
        .map-room text {
            font-size: 8px;
            fill: #cbd5e1;
            text-anchor: middle;
            pointer-events: none;
            font-family: var(--font-mono);
            font-weight: 700;
            user-select: none;
        }
        .map-room.current text {
            fill: #fff;
        }
        
        /* Links & Connectors */
        .map-link {
            stroke: #334767;
            stroke-width: 1.4;
            pointer-events: none;
            marker-end: url(#arrowhead);
        }
        .map-link.cross-zone {
            stroke: #3b82f6;
            stroke-width: 2;
            stroke-dasharray: 4,4;
            marker-end: url(#arrowhead-blue);
        }
        .map-link.object-link {
            stroke: var(--amber);
            stroke-width: 1.5;
            stroke-dasharray: 4,3;
            marker-end: url(#arrowhead-orange);
            opacity: 0.85;
        }

        /* Zone Groups */
        .zone-group rect.zone-bg {
            fill: rgba(19, 28, 48, 0.35);
            stroke: #253754;
            stroke-width: 1;
            stroke-dasharray: 5,4;
            rx: 8;
            transition: all 0.15s ease;
        }
        .zone-group text.zone-label {
            fill: #64748b;
            font-size: 11px;
            font-weight: 700;
            pointer-events: none;
            font-family: var(--font-mono);
            letter-spacing: 0.05em;
        }
        .zone-group:hover rect.zone-bg {
            stroke: var(--gold);
            fill: rgba(212, 175, 55, 0.08);
            cursor: move;
        }
        
        /* UI Elements & Controls */
        .form-label {
            display: block;
            font-size: 0.68rem;
            color: #94a3b8;
            margin-bottom: 0.2rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }
        .form-input, .form-textarea, .form-select {
            width: 100%;
            background: #090d16;
            border: 1px solid #1e2c45;
            color: #f8fafc;
            padding: 0.4rem 0.5rem;
            border-radius: 0.35rem;
            font-size: 0.82rem;
            font-family: var(--font-mono);
            transition: border-color 0.15s;
        }
        .form-input:focus, .form-select:focus, .form-textarea:focus {
            outline: none;
            border-color: var(--gold);
            box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.3);
        }
        
        .btn {
            padding: 0.35rem 0.65rem;
            border-radius: 0.35rem;
            font-weight: 600;
            font-size: 0.75rem;
            cursor: pointer;
            transition: all 0.15s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            user-select: none;
        }
        .btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
        .btn:active { transform: translateY(0); }
        .btn-primary { background: linear-gradient(135deg, #d4af37, #f59e0b); color: #0a0e17; font-weight: 700; border: none; }
        .btn-danger { background: #b91c1c; color: #fff; border: 1px solid #ef4444; }
        .btn-neutral { background: #151f33; color: #e2e8f0; border: 1px solid #273854; }
        .btn-neutral:hover { background: #1e2c48; border-color: var(--gold); }
        .btn-success { background: #059669; color: #fff; border: 1px solid #10b981; }

        /* Collapsible Sections */
        details { border: 1px solid #1c2a42; border-radius: 6px; overflow: hidden; background: #090e18; }
        details summary {
            padding: 0.5rem 0.75rem;
            background: #111a2d;
            cursor: pointer;
            font-size: 0.75rem;
            font-weight: 700;
            user-select: none;
            color: #cbd5e1;
        }
        details summary:hover { background: #18253f; color: #f8fafc; }
        details[open] summary { border-bottom: 1px solid #1c2a42; }
        .details-content { padding: 0.65rem; }

        /* Checkbox Grid */
        .flag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
        .flag-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; color: #cbd5e1; cursor: pointer; }
        .flag-item input { accent-color: var(--gold); }

        /* Object & Interaction Cards */
        .object-card {
            background: #101828;
            border: 1px solid #1c2a42;
            border-radius: 6px;
            padding: 8px;
            margin-bottom: 8px;
            position: relative;
            transition: border-color 0.15s;
        }
        .object-card:hover { border-color: #3b5078; }
        .object-card.hidden-obj { border-color: var(--amber); background: #1a150a; }
        .interaction-row {
            display: flex;
            gap: 4px;
            margin-top: 4px;
            background: #070a12;
            padding: 4px 6px;
            border-radius: 4px;
            border: 1px solid #1c293f;
            align-items: center;
        }

        /* Context Menu */
        #context-menu {
            position: absolute;
            display: none;
            background: #0f1628;
            border: 1px solid #273b5e;
            border-radius: 6px;
            z-index: 100;
            min-width: 190px;
            box-shadow: 0 12px 28px rgba(0,0,0,0.8), 0 0 12px rgba(212, 175, 55, 0.15);
        }
        .ctx-item {
            padding: 8px 12px;
            cursor: pointer;
            font-size: 0.78rem;
            color: #cbd5e1;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .ctx-item:hover { background: #1d3358; color: white; }
        .ctx-divider { height: 1px; background: #1f2c44; margin: 4px 0; }

        /* Zone List Overlay */
        #zone-list { 
            position: absolute;
            top: 14px;
            left: 14px; 
            background: rgba(12, 18, 32, 0.95); 
            border: 1px solid #243552; 
            padding: 10px; 
            border-radius: 8px; 
            max-height: 58vh;
            width: 300px; 
            display: flex;
            flex-direction: column;
            box-shadow: 0 16px 36px rgba(0, 0, 0, 0.75);
            backdrop-filter: blur(8px);
            z-index: 50;
        }
        #loaded-files-container {
            overflow-y: auto; 
            flex-grow: 1; 
            margin-top: 6px;
            margin-bottom: 8px;
            padding-right: 4px;
        }
        
        .zone-entry { 
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.75rem; 
            padding: 6px 8px;
            background: rgba(255,255,255,0.03); 
            border: 1px solid transparent;
            border-radius: 5px;
            margin-bottom: 4px;
            transition: all 0.15s;
        }
        .zone-entry:hover { 
            background: rgba(255,255,255,0.08); 
            border-color: rgba(212, 175, 55, 0.3);
        }
        .zone-name { 
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap; 
            flex: 1; 
            margin-right: 8px; 
            color: #e2e8f0; 
            cursor: pointer;
            font-weight: 600;
        }
        .zone-name:hover { color: var(--gold-bright); text-decoration: underline; }
        
        .zone-actions { display: flex; align-items: center; gap: 4px; }
        .zone-count { font-size: 0.68rem; color: #64748b; font-family: var(--font-mono); min-width: 24px; text-align: right; }
        
        .zone-btn { 
            display: flex;
            align-items: center;
            justify-content: center;
            width: 22px;
            height: 22px;
            border-radius: 4px;
            color: #94a3b8;
            background: #141c2c;
            border: 1px solid #273750;
            transition: all 0.12s;
            cursor: pointer;
            font-size: 0.7rem;
        }
        .zone-btn:hover { background: #233552; color: white; }
        .zone-btn.save:hover { background: #065f46; color: #34d399; border-color: #10b981; }
        .zone-btn.close:hover { background: #7f1d1d; color: #fca5a5; border-color: #ef4444; }
        
        /* Modal & Asset Palette */
        #modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.82);
            z-index: 200;
            justify-content: center;
            align-items: center;
            backdrop-filter: blur(4px);
        }
        .modal-box {
            background: #0f1628;
            padding: 1.5rem;
            border-radius: 8px;
            border: 1px solid #d4af37;
            width: 480px;
            max-width: 92%;
            box-shadow: 0 20px 40px rgba(0,0,0,0.8), 0 0 24px rgba(212, 175, 55, 0.2);
        }

        #asset-palette-modal {
            width: 780px;
            max-width: 95%;
            max-height: 88vh;
            display: flex;
            flex-direction: column;
        }
        .asset-card {
            background: #111a2d;
            border: 1px solid #1c2a44;
            border-radius: 6px;
            padding: 8px 10px;
            cursor: pointer;
            transition: all 0.15s;
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .asset-card:hover {
            border-color: var(--gold);
            background: #17243c;
            transform: translateY(-1px);
        }

        /* Toast Notification */
        #toast-notification {
            position: absolute;
            bottom: 4rem;
            left: 50%;
            transform: translateX(-50%);
            background-color: #152238;
            color: #f8fafc;
            border: 1px solid var(--gold);
            padding: 8px 18px;
            border-radius: 6px;
            font-size: 0.78rem;
            font-weight: 700;
            box-shadow: 0 10px 25px rgba(0,0,0,0.7), 0 0 12px rgba(212, 175, 55, 0.3);
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.2s ease-in-out;
            z-index: 150;
        }

        /* Z-Toggles */
        .z-toggle-btn {
            width: 26px;
            height: 26px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.72rem;
            font-weight: 700;
            font-family: var(--font-mono);
            border-radius: 4px;
            cursor: pointer;
            border: 1px solid #283a58;
            background: #141c2c;
            color: #94a3b8;
            transition: all 0.12s;
        }
        .z-toggle-btn:hover { color: white; border-color: var(--gold); }
        .z-toggle-btn.active {
            background: var(--gold);
            color: #0a0e17;
            border-color: var(--gold-bright);
            box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
        }
        .z-toggle-btn.z-over { border-top: 2px solid #3b82f6; }
        .z-toggle-btn.z-under { border-bottom: 2px solid #8b5cf6; }

        /* Header Brand */
        .brand-title {
            font-family: var(--font-heading);
            color: var(--gold-bright);
            letter-spacing: 0.05em;
        }
