:root {
    --bg-color: #dbe0e5;
    --menu-bg: #ffffff;
    --border-color: #ced4da;
    --highlight: #0d6efd;
    --highlight-hover: #0b5ed7;
    --node-bg: #f8f9fa;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, sans-serif; }
body { background-color: var(--bg-color); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

header { background-color: var(--menu-bg); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 20px; height: 60px; }
.logo { font-size: 20px; font-weight: bold; color: var(--highlight); margin-right: 30px; }

#editor-workspace { display: flex; flex-grow: 1; overflow: hidden; }

#toolbar-panel { width: 240px; background-color: var(--node-bg); border-right: 2px solid var(--border-color); overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 0; z-index: 10; }
.accordion { font-weight: bold; color: #495057; margin-top: 15px; margin-bottom: 5px; font-size: 13px; text-transform: uppercase; border-bottom: 2px solid var(--border-color); padding-bottom: 5px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; user-select: none; }
.accordion:first-child { margin-top: 0; }
.accordion span { font-size: 10px; transition: transform 0.3s ease; }
.accordion.active span { transform: rotate(180deg); }
.panel { display: none; flex-direction: column; gap: 8px; margin-bottom: 10px; }

#fup-panel { flex: 1; position: relative; } 
#drawflow { width: 100%; height: 100%; background: var(--bg-color); }

#code-panel { width: 350px; background-color: #1e1e1e; color: #d4d4d4; display: flex; flex-direction: column; border-left: 2px solid #2d2d2d; z-index: 10; }
.code-header { display: flex; justify-content: space-between; align-items: center; padding: 10px; background-color: #252526; border-bottom: 1px solid #333; font-weight: bold; font-size: 14px; }
#btn-copy-code { background-color: #3a3d41; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; }
#btn-copy-code:hover { background-color: #4a4d51; }
#arduino-code-output { padding: 20px; font-family: 'Consolas', monospace; font-size: 13px; overflow-y: auto; flex-grow: 1; white-space: pre-wrap; color: #9cdcfe; }

.menu-btn { background-color: #e9ecef; border: 1px solid var(--border-color); padding: 8px 12px; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 13px; text-align: left; width: 100%; transition: background-color 0.2s;}
.menu-btn:hover { background-color: #dde2e6; }
.menu-btn.highlight { background-color: #198754; color: white; border: none; }
.menu-btn.highlight:hover { background-color: #157347; }
.menu-btn.highlight-var { background-color: #6610f2; color: white; border: none; }
.menu-btn.highlight-var:hover { background-color: #520dc2; }

.drawflow .drawflow-node { background: var(--node-bg); border: 2px solid #495057; border-radius: 4px; width: 150px; padding: 0; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.fup-title { background-color: #495057; color: white; font-weight: bold; text-align: center; padding: 4px 0; font-size: 14px; }
.fup-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 12px; font-weight: bold; color: #333; text-align: center;}
.fup-input-field, .fup-select-field { width: 100%; padding: 4px; border: 1px solid #ced4da; border-radius: 3px; text-align: center; font-weight: bold; margin-top: 4px; font-size: 12px;}
.drawflow .drawflow-node .input, .drawflow .drawflow-node .output { width: 14px; height: 14px; background: #ffffff; border: 2px solid #495057; border-radius: 50%; }
.drawflow .drawflow-node .input:hover, .drawflow .drawflow-node .output:hover { background: var(--highlight); }
.drawflow .connection .main-path { stroke: #495057; stroke-width: 3px; }

/* Modal - Breiter für Hardware-Spalte */
#var-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; z-index: 1000; }
#var-modal-overlay.hidden { display: none; }
#var-modal { background: #fff; width: 850px; max-width: 95%; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.3); display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--border-color); background: #f8f9fa; border-radius: 8px 8px 0 0; }
.modal-header h2 { font-size: 18px; color: #333; margin: 0; }
.close-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: #888; }
.close-btn:hover { color: #dc3545; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
#var-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
#var-table th, #var-table td { border: 1px solid var(--border-color); padding: 8px; text-align: left; font-size: 13px; }
#var-table th { background: #e9ecef; font-weight: bold; color: #495057; }
.var-input { width: 100%; padding: 6px; border: 1px solid #ced4da; border-radius: 4px; font-family: monospace;}
.btn-delete-var { background: #dc3545; color: white; border: none; padding: 6px 10px; border-radius: 4px; cursor: pointer; font-weight: bold; }
.btn-delete-var:hover { background: #c82333; }

/* --- Spezielle Linie für Analoge Signale --- */
.drawflow .connection .main-path.analog-line { stroke: #28a745; stroke-width: 4px; }

/* --- Simulation Mode Styling --- */
.sim-val-display {
    position: absolute;
    top: -12px;
    right: -10px;
    background: #6c757d;
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 100;
    pointer-events: none; /* <--- NEU: Das Badge lässt Klicks "durchfallen" */
}

/* Während der Simulation normales Bearbeiten sperren */
body.sim-active .fup-input-field:not([df-simval]),
body.sim-active .fup-select-field {
    pointer-events: none;
    opacity: 0.6;
}

/* Die Sim-Felder (Schalter/Zahlen) in den Eingängen */
.sim-ui { 
    display: none; 
    margin-top: 8px; 
    padding-top: 8px; 
    border-top: 1px dashed #adb5bd; 
    font-size: 11px; 
    color: #dc3545;
}
body.sim-active .sim-ui { display: block; }

body.sim-active .sim-ui input[type="checkbox"] { transform: scale(1.3); cursor: pointer; }
body.sim-active .sim-ui .fup-input-field { pointer-events: auto; opacity: 1; border-color: #dc3545; }