/* ═══════════════════════════════════════════════════════
   Chem&Notes – Full-Screen-Layout
   Toolbar sitzt direkt unter der Bootstrap-Navbar (80px).
   cn-main füllt den Rest des Viewports.
═══════════════════════════════════════════════════════ */

:root {
    --cn-navbar-h: 80px;
    --cn-toolbar-h: 48px;
    --cn-handle-w: 8px;
}

/* Kein Body-Scroll auf dieser App-Seite */
html, body { overflow: hidden; }

/* Footer ausblenden – Seite ist eine Vollbild-App */
footer { display: none !important; }

/* ── Werkzeug-Toolbar ── */
#cn-toolbar {
    position: fixed;
    top: var(--cn-navbar-h);
    left: 0; right: 0;
    height: var(--cn-toolbar-h);
    background: linear-gradient(135deg, #1e3c72 0%, #2980b9 100%);
    border-bottom: 1px solid #154360;
    display: flex; align-items: center;
    padding: 0 12px; gap: 6px;
    z-index: 200;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    overflow-x: auto;
}
#cn-toolbar::-webkit-scrollbar { display: none; }

/* ── Haupt-Split-Bereich ── */
#cn-main {
    position: fixed;
    top: calc(var(--cn-navbar-h) + var(--cn-toolbar-h));
    left: 0; right: 0; bottom: 0;
    display: flex;
}

/* ── Reaktionsfeld-Panel ── */
#chem-wrap {
    flex: 0 0 auto;
    width: 50%;
    background: #fff;
    position: relative;
    min-width: 200px;
    overflow: hidden;
}

#chem-sketcher {
    display: block;
    position: absolute; inset: 0;
    cursor: crosshair;
    touch-action: none;
}

.cn-hint {
    position: absolute;
    bottom: 12px; left: 0; right: 0;
    text-align: center;
    font-size: 10px;
    color: rgba(41, 128, 185, .45);
    pointer-events: none;
    font-family: 'Poppins', sans-serif;
    letter-spacing: .02em;
}

/* ── Trennbalken ── */
#cn-handle {
    flex: 0 0 var(--cn-handle-w);
    width: var(--cn-handle-w);
    background: #f0f2f5;
    cursor: col-resize;
    position: relative;
    display: flex; align-items: center; justify-content: center;
    z-index: 10;
    user-select: none;
    border-left: 1px solid #dde2ea;
    border-right: 1px solid #dde2ea;
    transition: background .15s;
}
#cn-handle::after {
    content: '';
    width: 3px; height: 40px;
    border-radius: 2px;
    background: #b0b8c8;
    transition: background .15s, height .15s;
}
#cn-handle:hover { background: #e8ecf2; }
#cn-handle:hover::after { background: #3498db; height: 52px; }
#cn-handle.dragging::after { background: #1e3c72; height: 60px; }

/* ── Notiz-Panel ── */
#notes-wrap {
    flex: 1 1 0;
    min-width: 160px;
    position: relative; overflow: hidden;
    background-color: #fafcff;
    background-image:
        linear-gradient(to right,  rgba(52, 152, 219, .18) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(52, 152, 219, .18) 1px, transparent 1px),
        linear-gradient(to right,  rgba(52, 152, 219, .06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(52, 152, 219, .06) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
}

#draw-canvas {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    touch-action: none;
    cursor: crosshair;
}

/* ── Text-Ebene ── */
#text-layer {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
}
#text-layer.active {
    pointer-events: auto;
    cursor: text;
}

.cn-textbox {
    position: absolute;
    min-width: 60px;
    padding: 2px 5px;
    border: 1px dashed transparent;
    border-radius: 2px;
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Poppins', sans-serif;
    line-height: 1.4;
    cursor: text;
    box-sizing: border-box;
    transition: border-color .15s;
}
#text-layer.active .cn-textbox {
    border-color: rgba(52, 152, 219, 0.2);
}
.cn-textbox:focus {
    border-color: rgba(52, 152, 219, 0.75);
    background: rgba(255, 255, 255, 0.35);
}

/* ═══════════════════════════════════════════════════════
   Toolbar-Elemente
═══════════════════════════════════════════════════════ */

.cn-logo {
    font-size: 15px; font-weight: 700;
    color: #fff; letter-spacing: -.3px; flex-shrink: 0;
}
.cn-logo em { color: #85c1e9; font-style: normal; }

.cn-vr {
    width: 1px; height: 20px;
    background: rgba(255, 255, 255, .25);
    flex-shrink: 0; margin: 0 2px;
}

/* Werkzeug-Buttons */
.cn-tb {
    display: flex; align-items: center; gap: 4px;
    height: 28px; padding: 0 9px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 5px;
    color: rgba(255, 255, 255, .75);
    font-family: 'Poppins', sans-serif; font-size: 10px;
    cursor: pointer; flex-shrink: 0; white-space: nowrap;
    transition: color .12s, border-color .12s, background .12s;
}
.cn-tb:hover { color: #fff; border-color: rgba(255, 255, 255, .6); }
.cn-tb.on {
    background: rgba(255, 255, 255, .2);
    border-color: #85c1e9;
    color: #fff;
}

/* Farb-Vorschau im Button */
#farbe-preview {
    display: inline-block;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: #1a1a2e;
    border: 1.5px solid rgba(255,255,255,.5);
    flex-shrink: 0;
}

/* Farb-Dropdown Einträge */
.cn-color-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 11px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    font-family: 'Poppins', sans-serif;
}
.cn-color-item:hover { background: #ebf5ff; color: #1e3c72; }
.cn-color-item.on { background: #dbeafe; font-weight: 600; color: #1e3c72; }

.cn-color-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1.5px solid rgba(0,0,0,.15);
}

/* Trennlinie im Dropdown */
.cn-dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 4px 0;
}

/* Slider-Zeile im Dropdown */
.cn-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
}

/* Stärke-Slider (Toolbar-Variante, hell) */
.cn-slider {
    -webkit-appearance: none;
    width: 60px; height: 3px;
    background: rgba(255, 255, 255, .25);
    border-radius: 2px; outline: none; flex-shrink: 0;
}
.cn-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #85c1e9;
    cursor: pointer;
}

/* Slider im Dropdown (dunkler Hintergrund → andere Farben) */
.cn-slider-dark {
    background: #dde2ea;
}
.cn-slider-dark::-webkit-slider-thumb {
    background: #2563eb;
}
.cn-lbl-dark { color: #555; font-size: 11px; }

.cn-lbl {
    font-size: 9px;
    color: rgba(255, 255, 255, .65);
    flex-shrink: 0;
    font-family: 'Poppins', sans-serif;
}

.cn-spacer { flex: 1; min-width: 4px; }

/* PDF-Export-Button */
.cn-export-btn {
    display: flex; align-items: center; gap: 5px;
    height: 28px; padding: 0 12px;
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 5px;
    color: #fff;
    font-family: 'Poppins', sans-serif; font-size: 10px; font-weight: 600;
    cursor: pointer; flex-shrink: 0;
    transition: background .12s;
}
.cn-export-btn:hover { background: rgba(255, 255, 255, .25); }
.cn-export-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Symbole-Dropdown ── */
.cn-dropdown-wrap {
    position: relative;
    flex-shrink: 0;
}

.cn-dropdown-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #dde2ea;
    border-radius: 7px;
    box-shadow: 0 4px 16px rgba(30,60,114,.18);
    min-width: 130px;
    z-index: 1000;
    padding: 4px 0;
    font-family: 'Poppins', sans-serif;
}

.cn-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 12px;
    border: none;
    background: none;
    font-size: 11px;
    color: #333;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}
.cn-dropdown-item:hover { background: #ebf5ff; color: #1e3c72; }

.cn-dropdown-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Toast ── */
#cn-toast {
    position: fixed;
    bottom: 18px; left: 50%; transform: translateX(-50%);
    background: #1e3c72;
    border: 1px solid #2980b9;
    color: #fff;
    font-size: 12px; font-family: 'Poppins', sans-serif;
    padding: 8px 16px; border-radius: 6px;
    opacity: 0; transition: opacity .25s;
    pointer-events: none; z-index: 400; white-space: nowrap;
}
#cn-toast.show { opacity: 1; }

/* ═══════════════════════════════════════════════════════
   Molekül-Wizard
═══════════════════════════════════════════════════════ */

#mol-wizard {
    position: fixed; z-index: 500;
    background: #fff; border: 1px solid #dde2ea;
    border-radius: 8px; box-shadow: 0 4px 24px rgba(30,60,114,0.18);
    width: 270px; font-family: 'Poppins', sans-serif; font-size: 12px;
}
.mw-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #1e3c72 0%, #2980b9 100%);
    border-radius: 8px 8px 0 0; color: #fff;
}
.mw-title { font-size: 11px; font-weight: 600; }
.mw-close {
    background: none; border: none; color: #fff;
    cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px;
}
.mw-close:hover { opacity: .75; }
.mw-body { padding: 12px; }
.mw-footer {
    display: flex; justify-content: space-between; gap: 6px;
    padding: 8px 12px; border-top: 1px solid #eee;
}
.mw-back, .mw-next {
    height: 26px; padding: 0 10px; border-radius: 5px; border: none;
    font-family: 'Poppins', sans-serif; font-size: 10px; cursor: pointer;
}
.mw-back { background: #f0f2f5; color: #555; }
.mw-back:hover { background: #e2e6ea; }
.mw-next { background: #2980b9; color: #fff; font-weight: 600; }
.mw-next:hover { background: #1e6fa8; }

/* Typauswahl */
.mw-type-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.mw-type-btn {
    padding: 10px 6px; border: 1px solid #dde2ea; border-radius: 6px;
    background: #f8faff; cursor: pointer; font-size: 10px; text-align: center;
    font-family: 'Poppins', sans-serif; transition: border-color .12s, background .12s;
}
.mw-type-btn:hover { border-color: #2980b9; background: #ebf5ff; }
.mw-type-icon { font-size: 16px; display: block; margin-bottom: 4px; }

/* Formularelemente im Wizard */
.mw-label {
    display: block; font-size: 10px; color: #555;
    margin-bottom: 4px; font-family: 'Poppins', sans-serif;
}
.mw-input, .mw-select {
    width: 100%; height: 28px; padding: 0 8px; box-sizing: border-box;
    border: 1px solid #cdd5e0; border-radius: 5px;
    font-family: 'Poppins', sans-serif; font-size: 11px; color: #222;
    outline: none; background: #fff;
}
.mw-input:focus, .mw-select:focus { border-color: #2980b9; }
.mw-group { margin-bottom: 10px; }
.mw-group:last-child { margin-bottom: 0; }
.mw-hint { font-size: 9px; color: #888; margin-top: 3px; font-family: 'Poppins', sans-serif; }
.mw-error {
    color: #e74c3c; font-size: 9px; margin-top: 4px;
    display: none; font-family: 'Poppins', sans-serif;
}
.mw-error.show { display: block; }
.mw-sc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ═══════════════════════════════════════════════════════
   Responsive – Mobil: vertikal stapeln
═══════════════════════════════════════════════════════ */
@media (max-width: 680px) {
    :root {
        --cn-navbar-h: 70px;
        --cn-toolbar-h: 44px;
    }

    #cn-main { flex-direction: column; }

    #chem-wrap {
        flex: 0 0 calc(50% - var(--cn-handle-w) / 2);
        width: 100% !important;
    }

    #cn-handle {
        flex: 0 0 var(--cn-handle-w);
        width: 100%;
        cursor: row-resize;
    }
    #cn-handle::after { width: 40px; height: 3px; }

    .cn-lbl { display: none; }
    .cn-slider { width: 44px; }
}

/* ── Kontextmenü für + und → ───────────────────────────── */
#chem-context-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #c8d6e0;
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    z-index: 9000;
    min-width: 200px;
}
.ccm-label { display: block; font-size: 11px; font-weight: 600; color: #5a6475; margin-bottom: 6px; }
.ccm-row   { display: flex; gap: 6px; align-items: center; }
.ccm-input { flex: 1; border: 1px solid #c8d6e0; border-radius: 5px; padding: 4px 8px; font-size: 13px; }
.ccm-btn   { padding: 4px 10px; border: none; border-radius: 5px; background: #3498db; color: #fff;
             font-size: 12px; font-weight: 600; cursor: pointer; }
.ccm-btn:hover { background: #2980b9; }
.ccm-clear { background: #e0e0e0; color: #333; }
.ccm-clear:hover { background: #c8c8c8; }
