:root {
    --bg-main: #1e1e1e;
    --bg-panel: #2d2d30;
    --bg-header: #3e3e42;
    --bg-hover: #4e4e52;
    --border: #555555;
    --accent: #007acc;
    --accent-hover: #005a9e;
    --text-main: #d4d4d4;
    --text-muted: #858585;
}

body {
    margin: 0; padding: 0;
    background-color: var(--bg-main); color: var(--text-main);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex; height: 100vh; overflow: hidden;
    user-select: none;
}

/* --- MENÜBAR OBEN --- */
.top-bar {
    position: absolute; top: 0; left: 0; right: 0; height: 30px;
    background: var(--bg-header); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 10px;
    font-size: 13px; z-index: 2000;
}

.top-bar-title {
    font-weight: bold; margin-right: 20px; color: var(--accent);
}

.menu-item {
    position: relative; padding: 0 10px; height: 100%;
    display: flex; align-items: center; cursor: pointer;
    color: var(--text-main); transition: background 0.1s;
}

.menu-item:hover, .menu-item:focus { background: var(--bg-hover); outline: none; }

.dropdown {
    display: none; position: absolute; top: 30px; left: 0;
    background: var(--bg-panel); border: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); min-width: 200px;
    border-radius: 0 0 4px 4px; padding: 5px 0; z-index: 2001;
}

.menu-item:focus .dropdown, .menu-item:hover .dropdown { display: block; }

.dropdown-item {
    padding: 8px 15px; cursor: pointer; color: var(--text-main);
    display: flex; align-items: center;
}

.dropdown-item:hover { background: var(--accent); color: white; }

.dropdown-divider {
    height: 1px; background: var(--border); margin: 5px 0;
}

.dropdown-item.active-menu-item {
    background: rgba(0, 122, 204, 0.2);
    font-weight: bold;
}
.dropdown-item.active-menu-item::before {
    content: "✓ ";
    color: var(--accent);
    margin-right: 6px;
}

/* --- SCHWEBENDE FENSTER --- */
.floating-window {
    position: absolute; background: var(--bg-panel);
    border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); display: flex; flex-direction: column;
    z-index: 100; max-height: 85vh;
}

.window-header {
    background: #36363a; padding: 6px 12px; font-size: 11px; font-weight: bold;
    color: var(--text-muted); cursor: move; border-bottom: 1px solid var(--border);
    text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0;
}

.panel-content { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.panel-header-sub {
    background: #252526; padding: 6px 12px; font-size: 10px; font-weight: bold;
    color: var(--text-muted); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
    text-transform: uppercase;
}

/* --- TOOLS GRID --- */
.tools-panel { padding: 8px; width: 90px; box-sizing: border-box; }
.tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }

.tool-btn {
    width: 100%; height: 36px; background: #333337; border: 1px solid var(--border);
    color: var(--text-main); border-radius: 4px; cursor: pointer; font-size: 16px;
    display: flex; justify-content: center; align-items: center; transition: 0.1s;
}

.tool-btn:hover:not(:disabled) { background: #4e4e52; }
.tool-btn.active { background: rgba(0, 122, 204, 0.4); border-color: var(--accent); }
.tool-btn:disabled { opacity: 0.2; cursor: not-allowed; }
.tool-separator { width: 100%; height: 1px; background: var(--border); margin: 5px 0; }

/* --- COLOR PICKER --- */
.custom-color-picker { display: flex; flex-direction: column; }
#colorBox { border: 1px solid var(--border); cursor: crosshair; border-radius: 2px; }
#colorHue { border: 1px solid var(--border); cursor: pointer; border-radius: 2px; }
.color-preview-box { width: 30px; height: 30px; border: 2px solid var(--border); border-radius: 4px; background: #27ae60; }
.color-history { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.history-swatch { width: 100%; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 2px; cursor: pointer; }
.history-swatch:hover { border-color: white; }

/* --- BRUSH & LAYERS --- */
.brush-setting { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.brush-setting label { display: flex; justify-content: space-between; color: var(--text-muted); }
.brush-setting input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.brush-shape-buttons { display: flex; gap: 5px; }
.shape-btn { flex: 1; background: #333337; border: 1px solid var(--border); padding: 4px; border-radius: 4px; cursor: pointer; }
.shape-btn.active { background: var(--accent); border-color: var(--accent); }

.layer-item {
    display: flex; align-items: center; background: #333337; border: 1px solid var(--border);
    padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; gap: 8px;
}
.layer-item.active { background: rgba(0, 122, 204, 0.4); border-color: var(--accent); }
.layer-vis-btn, .layer-del-btn { background: none; border: none; cursor: pointer; padding: 2px; }
.mini-btn { padding: 2px 6px; font-size: 10px; background: #333337; border: 1px solid var(--border); border-radius: 3px; cursor: pointer; color: white;}

/* --- THE NEW SWAPPABLE PREVIEW SLOTS --- */
.view-slot-main, .view-slot-floating {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transition: all 0.2s ease-in-out;
}

/* Dynamisches Sizing der 3D Box basierend auf dem aktuellen Slot */
#main-slot #view3d {
    width: 400px !important;
    height: 400px !important;
    border: 1px solid var(--border);
    background: #252526;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#floating-slot #view3d {
    width: 200px !important;
    height: 200px !important;
    border: none !important;
    box-shadow: none !important;
}

/* Dynamisches Sizing des 2D Scroll-Containers basierend auf dem aktuellen Slot */
#main-slot .canvas-scroll-wrapper {
    width: 400px;
    height: 400px;
    overflow: auto;
    border: 1px solid var(--border);
    background: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

#floating-slot .canvas-scroll-wrapper {
    width: 200px !important;
    height: 200px !important;
    border: none !important;
    box-shadow: none !important;
    overflow: hidden !important; /* Versteckt Scrollbalken in der Live Vorschau */
}

#floating-slot .canvas-stack {
    width: 200px !important;
    height: 200px !important;
}

/* --- MAIN WORKSPACE --- */
.workspace {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: #1a1a1a; display: flex; justify-content: center; align-items: center; z-index: 10;
}
.canvas-stack { position: relative; width: 400px; height: 400px; background: #808080; background-image: linear-gradient(45deg, #999 25%, transparent 25%), linear-gradient(-45deg, #999 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #999 75%), linear-gradient(-45deg, transparent 75%, #999 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0px; flex-shrink: 0;}
.canvas-stack canvas, .canvas-stack .grid-overlay, .canvas-stack .interaction-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.canvas-stack .grid-overlay { background-size: 6.25px 6.25px; background-image: linear-gradient(to right, rgba(255,255,255,0.08) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,0.08) 1px, transparent 1px); pointer-events: none; }
.selection-border { position: absolute; border: 1px dashed #ffffff; box-shadow: 0 0 0 1px #000000; pointer-events: none; z-index: 5; box-sizing: border-box; }
.canvas-stack .interaction-layer { cursor: crosshair; z-index: 10; }

/* =========================================
   MODAL STYLES (Neu-Projekt Fenster)
   ========================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75); /* Dunkelt den Hintergrund ab */
    z-index: 9999; /* Legt sich über alles andere (inkl. Menüs) */
    display: none; /* Standardmäßig unsichtbar */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px); /* Moderner Blur-Effekt für den Hintergrund */
}

.modal {
    background: var(--bg-panel, #1e1e1e);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border, #444);
    width: 90%;
    max-width: 350px;
    color: var(--text-main, #e0e0e0);
    box-shadow: 0 15px 35px rgba(0,0,0,0.8);
    text-align: left;
}

.modal h3 {
    margin-top: 0;
    color: white;
    margin-bottom: 5px;
    font-size: 18px;
}

.modal-input {
    width: 100%;
    padding: 12px;
    background: #111;
    color: white;
    border: 1px solid var(--border, #444);
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 16px;
    cursor: pointer;
    box-sizing: border-box; /* Verhindert, dass Padding die Breite sprengt */
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent, #007acc);
}

.modal-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    background: #333;
    color: white;
    transition: background 0.2s;
}

.modal-btn:hover {
    background: #444;
}

.modal-btn.primary {
    background: var(--accent, #007acc);
}

.modal-btn.primary:hover {
    background: #0098ff; /* Etwas heller beim Hovern */
}

/* Fallback falls im HTML aus Versehen .tool-btn im Modal genutzt wurde */
.modal .tool-btn {
    flex: 1;
    padding: 12px;
    font-size: 15px;
}