:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --bg: #f1f5f9;
    --panel: #ffffff;
    --text: #0f172a;
    --text-muted: #334155;
    --border: #475569;
    --accent: #b45309;
    --danger: #b91c1c;
    --success: #15803d;
    --drawer-width: 380px;
    --canvas-size: 5000px;
}

body, html {
    margin: 0; padding: 0; height: 100%;
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
}

:focus { outline: 3px solid var(--accent); outline-offset: 2px; }

header {
    background: #0f172a;
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
}

header h1 { font-size: 1rem; margin: 0; }

/* Splash Lightbox */
.splash-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.9);
    display: flex; justify-content: center; align-items: center;
    z-index: 5000; padding: 20px;
}
.splash-card {
    background: white;
    max-width: 600px;
    width: 100%;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
}
.splash-card h2 { color: var(--primary); margin-top: 0; }
.splash-card p { line-height: 1.6; color: var(--text-muted); text-align: left; font-size: 0.95rem; }
.splash-card ul { text-align: left; color: var(--text-muted); margin-bottom: 2rem; font-size: 0.9rem; }

/* Sidebar - Default to Open */
.drawer-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3);
    opacity: 0; visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1040;
}
.drawer-overlay.active { opacity: 1; visibility: visible; }

.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--drawer-width);
    max-width: 85vw;
    height: 100%;
    background: var(--panel);
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    display: flex;
    flex-direction: column;
}
.sidebar.active { transform: translateX(0); }

.sidebar-header { padding: 1rem; background: var(--primary); color: white; display: flex; justify-content: space-between; align-items: center; }
.sidebar-content { padding: 1.2rem; overflow-y: auto; flex-grow: 1; }
.sidebar h3 { font-size: 0.85rem; color: var(--primary); margin: 1rem 0 0.5rem 0; border-bottom: 2px solid #e2e8f0; padding-bottom: 5px; text-transform: uppercase; }
.sidebar p, .sidebar li { font-size: 0.85rem; line-height: 1.5; margin-bottom: 0.6rem; color: var(--text-muted); }

.kbd-key { background: #f1f5f9; border-radius: 3px; padding: 2px 5px; font-size: 0.7rem; font-weight: bold; border: 1px solid var(--border); color: var(--text); }

/* Toolbar */
.toolbar { padding: 0.5rem 1rem; background: #ffffff; border-bottom: 2px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; z-index: 900; }
.prominent-select { padding: 0.5rem; border: 2px solid var(--primary); border-radius: 8px; font-weight: 600; font-size: 0.85rem; background-color: #f8fafc; cursor: pointer; min-width: 240px; }

/* Canvas */
.layout { display: flex; height: calc(100vh - 56px); flex-direction: column; }
.viewport { flex-grow: 1; overflow: auto; background-color: #cbd5e1; position: relative; }
#canvas { width: var(--canvas-size); height: var(--canvas-size); background-color: white; position: relative; }
.svg-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

/* Nodes */
.node { position: absolute; width: 220px; background: white; border: 2px solid var(--primary); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 10; cursor: grab; }
.node-header { padding: 6px 30px 6px 10px; background: #f1f5f9; border-bottom: 2px solid #e2e8f0; border-radius: 6px 6px 0 0; font-weight: bold; font-size: 0.85rem; text-align: center; color: var(--primary); pointer-events: none; }
.node-body { padding: 8px; font-size: 0.8rem; pointer-events: none; }
.node-img { width: 100%; border-radius: 4px; margin-top: 5px; display: block; border: 1px solid #cbd5e1; }
.del-btn { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: white; border: 1px solid #7f1d1d; cursor: pointer; font-size: 10px; font-weight: bold; display: flex; align-items: center; justify-content: center; z-index: 20; }

/* Buttons */
.btn { padding: 0.5rem 1rem; border: none; border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 5px; }
.btn-primary { background: var(--primary); color: white; }
.btn-link { background: var(--success); color: white; }
.btn-outline { background: transparent; border: 2px solid white; color: white; }
.btn-ghost { background: transparent; color: white; border: 1px solid white; }
.status-badge { padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 800; display: none; background: #dcfce7; color: #14532d; border: 2px solid var(--success); }
.line-del { fill: var(--danger); cursor: pointer; pointer-events: all; stroke: white; stroke-width: 1; }

/* Modal Editor */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.85); display: none; justify-content: center; align-items: center; z-index: 2000; padding: 10px; }
.modal { background: white; width: 480px; max-width: 95%; border-radius: 12px; padding: 1.5rem; }
.form-group { margin-bottom: 0.8rem; }
.form-group label { display: block; margin-bottom: 0.2rem; font-weight: bold; font-size: 0.85rem; }
.form-group input, .form-group textarea { width: 100%; padding: 0.6rem; border: 1.5px solid var(--border); border-radius: 6px; box-sizing: border-box; }

@media (max-width: 600px) {
    .toolbar { flex-direction: column; align-items: flex-start; }
    .prominent-select { min-width: 100%; }
}