:root {
    --toolbar-bg: #ffffff;
    --border-color: #e2e8f0;
    --accent-blue: #2563eb;
    --danger-red: #ef4444;
    --success-green: #10b981;
}

.btn-active { background-color: #1e293b !important; color: white !important; border-color: #0f172a !important; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.btn-eval { background-color: #10b981 !important; color: white !important; border-color: #059669 !important; }

* { -webkit-tap-highlight-color: transparent; touch-action: none; -webkit-touch-callout: none; box-sizing: border-box; }

button, select, input, textarea { touch-action: auto !important; }

body { margin: 0; padding: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; font-family: 'Plus Jakarta Sans', sans-serif; background-color: #f8fafc; overflow: hidden; user-select: none; -webkit-user-select: none; }

/* --- TOOLBAR RIBBON STYLES --- */
#toolbar { 
    background-color: var(--toolbar-bg); 
    padding: 5px 15px 10px 15px; /* Unten etwas mehr Padding für die 2. Zeile */
    display: flex; 
    flex-direction: row;
    gap: 20px; 
    align-items: flex-start; /* Änderung: Align nach oben, falls andere Inhalte einzeilig bleiben */
    box-shadow: 0 2px 10px rgba(0,0,0,0.05); 
    border-bottom: 1px solid var(--border-color); 
    z-index: 1000; 
    min-height: 90px; /* Änderung: Flexibel wachsen lassen */
    height: auto;
    flex-shrink: 0; 
}

.toolbar-main-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.tab-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 2px;
}

.tab-buttons {
    display: flex;
    gap: 4px;
}

.tab-link {
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: #64748b;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: all 0.2s;
}

.tab-link.active {
    color: var(--accent-blue);
    background: #e0f2fe;
}

.control-panel { 
    display: none; 
    background: transparent; 
    padding: 0; 
    border-radius: 0; 
    flex-direction: row; 
    gap: 8px; 
    border: none; 
    align-items: center;
}

.control-panel.active {
    display: flex; 
}

.tool-group { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }

.logo-box { min-width: 140px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-container { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.dropdown { position: relative; display: inline-block; width: 100%; }
.dropbtn { width: 100%; background-color: #f1f5f9; color: #1e293b; padding: 4px 8px; font-size: 10px; border: 1px solid var(--border-color); border-radius: 6px; font-weight: 800; cursor: pointer; }

/* OVERFLOW: HIDDEN WURDE ENTFERNT, DAMIT DIE MENÜS RAUSSTEHEN DÜRFEN */
.dropdown-content { display: none; position: absolute; background-color: white; min-width: 140px; box-shadow: 0px 8px 16px rgba(0,0,0,0.1); z-index: 3000; border-radius: 8px; border: 1px solid var(--border-color); top: 105%; left: 0; }

/* Manuelle Ecken-Abrundung, da overflow: hidden fehlt */
.dropdown-content details:first-child summary { border-top-left-radius: 8px; border-top-right-radius: 8px; }
.dropdown-content button:last-child { border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }

.dropdown-content button { width: 100%; text-align: left; padding: 10px 12px; border: none; background: none; font-size: 11px; border-bottom: 1px solid #f1f5f9; border-radius: 0; color: #1e293b; }
.dropdown-content button:active { background-color: #e2e8f0; }
.show-dropdown { display: block !important; }

/* --- NEU: Untermenü Styles (Nach rechts aufklappend) --- */
details.menu-details { width: 100%; position: relative; }
details.menu-details summary { display: block; width: 100%; text-align: left; padding: 10px 12px; border: none; background: none; font-size: 11px; border-bottom: 1px solid #f1f5f9; color: #1e293b; cursor: pointer; font-weight: bold; list-style: none; }
details.menu-details summary::-webkit-details-marker { display: none; }
/* Pfeil zeigt jetzt nach rechts (▸) statt nach unten */
details.menu-details summary:after { content: '▸'; float: right; color: #64748b; font-size: 14px; line-height: 10px; }
details[open].menu-details summary:after { content: '▸'; color: var(--accent-blue); } 
details.menu-details summary:active { background-color: #e2e8f0; }

/* Die Box, die nach rechts aufklappt */
details.menu-details .details-content { 
    position: absolute; 
    top: -1px; /* Exakt auf Höhe des Menüpunkts */
    left: 100%; /* Menü komplett rechts neben das Hauptmenü schieben */
    min-width: 140px; 
    background-color: white; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    box-shadow: 0px 8px 16px rgba(0,0,0,0.1); 
    z-index: 3005;
    overflow: hidden; 
}
details.menu-details .details-content button { padding-left: 12px; border-bottom: 1px solid #f1f5f9; }
details.menu-details .details-content button:last-child { border-bottom: none; }

button, select { padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border-color); cursor: pointer; font-weight: bold; font-size: 10px; transition: background-color 0.2s, color 0.2s, transform 0.1s; background: white; }
button:active { transform: scale(0.95); }

.layer-dropdown { position: relative; min-width: 85px; font-size: 10px; z-index: 2000; }
.layer-head { background: white; border: 1px solid var(--border-color); padding: 5px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: bold; }
.layer-list { position: absolute; top: 105%; left: 0; right: 0; background: white; border: 1px solid var(--border-color); border-radius: 6px; display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.layer-list.show { display: block; }
.layer-item { padding: 10px 8px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.layer-item.active { background: #e0f2fe; }

#status-info { 
    color: #1e293b; 
    font-weight: 800; 
    min-width: 250px; 
    font-size: 13px; 
    background: #e2e8f0; 
    padding: 6px 14px; 
    border-radius: 6px; 
    border: 1px solid #cbd5e1; 
    text-align: center; 
    cursor: pointer; 
    
    /* NEUE EIGENSCHAFTEN FÜR ZWEIZEILIGEN PLATZ: */
    height: 48px; /* Reserviert exakt den Platz für zwei Zeilen */
    display: flex;
    align-items: center; /* Zentriert den Text vertikal */
    justify-content: center; /* Zentriert den Text horizontal */
}


#viewport { flex-grow: 1; position: relative; background-color: #ffffff; overflow: auto; }
#workspace { position: absolute; top: 0; left: 0; width: 1225px; height: 1550px; transform-origin: top left; transform: scale(1); }
#grid-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; background-image: linear-gradient(to right, #e2e8f0 1px, transparent 1px), linear-gradient(to bottom, #e2e8f0 1px, transparent 1px); background-size: 25px 25px; z-index: 0; }
#border-canvas { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 10; }
canvas.canvas-layer { position: absolute; top: 0; left: 0; display: block; z-index: 1; }

/* Media Overlays */
.media-overlay { pointer-events: auto; }

/* --- KONTEXTMENÜ --- */
.context-menu { position: absolute; background: white; border: 1px solid var(--border-color); box-shadow: 0 10px 25px rgba(0,0,0,0.2); border-radius: 8px; z-index: 10000; min-width: 170px; overflow: hidden; font-size: 11px; font-weight: 700; color: #1e293b; }
.context-menu-item { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.context-menu-item:hover { background: #f1f5f9; color: var(--accent-blue); }
.context-menu-divider { height: 1px; background: #e2e8f0; margin: 2px 0; }

/* --- KONTEXTMENÜ --- */
.context-menu { position: absolute; background: white; border: 1px solid var(--border-color); box-shadow: 0 10px 25px rgba(0,0,0,0.2); border-radius: 8px; z-index: 10000; min-width: 170px; overflow: hidden; font-size: 11px; font-weight: 700; color: #1e293b; }
.context-menu-item { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.context-menu-item:hover { background: #f1f5f9; color: var(--accent-blue); }
.context-menu-divider { height: 1px; background: #e2e8f0; margin: 2px 0; }

/* --- MODALS --- */
#custom-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 5000; display: none; justify-content: center; align-items: center; }
#custom-modal { background: white; padding: 20px; border-radius: 16px; width: 340px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); border: 1px solid var(--border-color); position: absolute; }
#custom-modal h3 { margin-top: 0; font-size: 16px; color: #1e293b; text-align: center; margin-bottom: 15px; cursor: move; padding-bottom: 10px; border-bottom: 1px solid #f1f5f9; }
.modal-group { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.modal-group label { font-size: 11px; font-weight: 800; color: #64748b; }
.modal-group input, .modal-group select { padding: 10px; border: 1px solid var(--border-color); border-radius: 8px; font-family: inherit; font-weight: bold; outline: none; font-size: 14px; width: 100%; }
.modal-actions { display: flex; gap: 10px; margin-top: 15px; }
.modal-actions button { flex: 1; padding: 12px; font-size: 12px; border-radius: 8px; border: none; cursor: pointer; }
.btn-confirm { background: #1e293b; color: white; }
.btn-cancel { background: #f1f5f9; color: #475569; }
.tab-btn-group { display: flex; background: #f1f5f9; padding: 3px; border-radius: 8px; margin-bottom: 15px; }
.tab-btn { flex: 1; border: none; background: none; font-size: 10px; padding: 8px; border-radius: 6px; font-weight: 800; }
.tab-btn.active { background: white; box-shadow: 0 2px 4px rgba(0,0,0,0.1); color: var(--accent-blue); }
.color-btn { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.color-btn.active { border-color: #333; transform: scale(1.2); }
.width-btn { background: white; border: 1px solid var(--border-color); padding: 4px 6px; font-size: 9px; }
.width-btn.active { background: #333; color: white; border-color: #333; }

/* --- TASCHENRECHNER --- */
#calculator { position: absolute; top: 130px; left: 20px; z-index: 4000; background: white; border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); width: 240px; display: none; }
#calc-header { background: #f1f5f9; padding: 10px; border-radius: 12px 12px 0 0; cursor: move; font-weight: 800; text-align: center; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; font-size: 12px; }
#calc-display { width: 100%; margin-bottom: 10px; text-align: right; font-size: 18px; padding: 8px; border: 1px solid var(--border-color); border-radius: 6px; font-family: monospace; font-weight: bold; background: #f8fafc; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.calc-btn { padding: 10px 5px; font-size: 14px; font-weight: 800; border-radius: 6px; background: #f1f5f9; }
.calc-btn:active { background: #e2e8f0; }
.calc-btn.op { background: #e2e8f0; color: var(--accent-blue); }
.calc-btn.eq { background: var(--accent-blue); color: white; }


/* --- VIEW CUBE (3D) --- */
#view-cube-wrapper {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    perspective: 400px;
    z-index: 1000;
    pointer-events: none; /* Klicks an den Würfel durchreichen */
}
#view-cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: translateZ(-30px);
}
.view-cube-face {
    position: absolute;
    width: 60px;
    height: 60px;
    background: #f1f5f9;
    border: 2px solid #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #334155;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    transition: background 0.2s, color 0.2s;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}
.view-cube-face:hover {
    background: #e0f2fe;
    color: #0284c7;
    border-color: #38bdf8;
}
/* Die 6 Seiten des Würfels in Position drehen */
.vc-front  { transform: rotateY(0deg) translateZ(30px); }
.vc-back   { transform: rotateY(180deg) translateZ(30px); }
.vc-right  { transform: rotateY(90deg) translateZ(30px); }
.vc-left   { transform: rotateY(-90deg) translateZ(30px); }
.vc-top    { transform: rotateX(90deg) translateZ(30px); }
.vc-bottom { transform: rotateX(-90deg) translateZ(30px); }