body {
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: Arial, sans-serif; 
    height: 100vh;
    display: grid; 
    grid-template-columns: 250px minmax(1163px, 1fr) 250px; 
    grid-template-rows: 60px 1fr;
    grid-template-areas: 
        "history tools components" 
        "history canvas components";
    background-color: #2c3e50; 
    overflow: auto; 
}

.area { 
    background-color: #ffffff; 
    padding: 15px; 
    border: 2px solid #000; 
}

#area-1 { 
    grid-area: history; 
    border-right: 3px solid #000; 
    border-top: none; 
    border-bottom: none; 
    border-left: none; 
    overflow-y: auto; 
}

#area-2 { 
    grid-area: tools; 
    border-bottom: 3px solid #000; 
    border-top: none; 
    border-left: none; 
    border-right: none; 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    background-color: #ecf0f1; 
}

#area-3 { 
    grid-area: components; 
    border-left: 3px solid #000; 
    border-top: none; 
    border-bottom: none; 
    border-right: none; 
    overflow-y: auto; 
}

.canvas-scroll-wrapper {
    grid-area: canvas;
    width: 100%;
    height: 100%;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#area-4 { 
    grid-area: canvas; 
    position: relative; 
    border: 1px solid #7f8c8d; 
    background-color: white;
    background-image: radial-gradient(#bdc3c7 1px, transparent 1px); 
    background-size: 20px 20px; 
    width: 1348px;  /* NEU: 20% mehr Platz */
    height: 953px;  /* NEU: 20% mehr Platz */
    margin: 20px auto; 
    padding: 0; 
    box-shadow: 0 0 15px rgba(0,0,0,0.3); 
    overflow: hidden; 
    transform-origin: top center;
    transition: transform 0.15s ease-out;
    will-change: transform;
}

#deckblatt-view {
    /* ... andere Eigenschaften bleiben gleich ... */
    width: 1348px;  /* NEU */
    height: 953px;  /* NEU */
    /* ... */
}

#ihv-view {
    /* ... andere Eigenschaften bleiben gleich ... */
    width: 1348px;  /* NEU */
    height: 953px;  /* NEU */
    /* ... */
}

#area-4.show-grid {
    background-image: radial-gradient(#bdc3c7 1px, transparent 1px); 
    background-size: 20px 20px; 
}

#area-4.hide-grid {
    background-image: none !important;
}

.page-layer {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; 
}

.page-layer.active {
    display: block;
}

.page-layer > * {
    pointer-events: all; 
}

.wire-active {
    stroke: #e74c3c !important;
    stroke-width: 3 !important;
    transition: stroke 0.1s ease-in, stroke-width 0.1s ease-in;
}

#drawing-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; 
    z-index: 0;
}

h2 { 
    font-size: 1.2rem; 
    margin-top: 0; 
    margin-bottom: 15px; 
    color: #34495e; 
    border-bottom: 1px solid #ccc; 
    padding-bottom: 5px; 
}

.tool-btn { 
    padding: 8px 15px; 
    background: #fff; 
    border: 1px solid #bdc3c7; 
    border-radius: 4px; 
    cursor: pointer; 
    font-weight: bold; 
}

.tool-btn:hover { 
    background: #e0e0e0; 
}

.page-tab { 
    padding: 5px 10px; 
    background-color: #bdc3c7; 
    cursor: pointer; 
    border-radius: 4px; 
    font-size: 14px; 
}

.page-tab.active { 
    background-color: #3498db; 
    color: white; 
    font-weight: bold; 
}

.folder { 
    border: 1px solid #bdc3c7; 
    border-radius: 4px; 
    margin-bottom: 10px; 
    overflow: hidden; 
    background: #fff; 
}

.folder-header { 
    padding: 10px; 
    background: #ecf0f1; 
    cursor: pointer; 
    font-weight: bold; 
    display: flex; 
    justify-content: space-between; 
    user-select: none; 
    color: #2c3e50; 
}

.folder-header:hover { 
    background: #d0d3d4; 
}

.folder-content { 
    padding: 10px; 
    display: none; 
    background: #fdfdfd; 
}

.folder.open .folder-content { 
    display: block; 
}

.folder.open .folder-header::after { 
    content: "▼"; 
    color: #7f8c8d; 
}

.folder:not(.open) .folder-header::after { 
    content: "◀"; 
    color: #7f8c8d; 
}

.component-item { 
    position: relative; 
    padding: 10px; 
    margin-bottom: 10px; 
    background: #fff; 
    border: 1px solid #bdc3c7; 
    text-align: center; 
    cursor: grab; 
    border-radius: 4px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
}

.component-item:active { 
    cursor: grabbing; 
}

.edit-comp-btn { 
    position: absolute; 
    top: 5px; 
    right: 5px; 
    background: #ecf0f1; 
    border: 1px solid #bdc3c7; 
    border-radius: 3px; 
    cursor: pointer; 
    font-size: 12px; 
    padding: 2px 5px; 
    z-index: 10; 
}

.edit-comp-btn:hover { 
    background: #3498db; 
    color: white; 
}

.history-item { 
    font-size: 0.9em; 
    padding: 5px 0; 
    color: #7f8c8d; 
    border-bottom: 1px dashed #ecf0f1; 
}

.symbol { 
    pointer-events: all; 
    user-select: none; 
}

.port { 
    pointer-events: all; 
    cursor: crosshair; 
}

.port:hover { 
    fill: #ff4d4d; 
    r: 6; 
}

.dropped-component { 
    position: absolute; 
    cursor: move; 
    background: transparent; 
    border: none; 
    user-select: none; 
    z-index: 10; 
    display: inline-block;
    overflow: visible !important;
}

/* --- KABEL EBENEN (Multipage-Fix) --- */
.wiring-layer-svg { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
    z-index: 100; 
}

.wiring-layer-svg path { 
    pointer-events: stroke; /* 'stroke' ist bei SVGs besser als 'auto', so muss man genau die Linie treffen */
    cursor: pointer; 
    transition: stroke 0.2s, stroke-width 0.2s; 
}

.wiring-layer-svg .wire-handle { 
    pointer-events: all !important; 
}

.wire-handle { 
    fill: #3498db; 
    stroke: white; 
    stroke-width: 1.5; 
    r: 5; 
    transition: r 0.2s ease-in-out; 
}

.wire-handle:hover { 
    fill: #e74c3c; 
    r: 7; 
}

.v-handle { cursor: ew-resize; } 
.h-handle { cursor: ns-resize; } 

.coil-rect { fill: white; }

.modal { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(44, 62, 80, 0.8); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 100000; 
}

.modal.hidden { display: none !important; }

.modal-content { 
    background: #fff; 
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); 
    width: 420px; 
}

.editor-toolbar { 
    display: flex; 
    gap: 5px; 
    margin-bottom: 15px; 
    flex-wrap: wrap; 
}

.editor-btn { 
    padding: 5px 10px; 
    border: 1px solid #bdc3c7; 
    background: #ecf0f1; 
    cursor: pointer; 
    border-radius: 3px; 
}

.editor-btn.active { 
    background: #3498db; 
    color: white; 
    border-color: #2980b9; 
}

.editor-canvas-container { 
    display: flex; 
    justify-content: center; 
    background: #fdfdfd; 
    background-image: radial-gradient(#bdc3c7 1px, transparent 1px); 
    background-size: 10px 10px; 
    border: 1px solid #bdc3c7; 
    margin-bottom: 15px; 
    height: 300px; 
}

.editor-footer { 
    display: flex; 
    justify-content: space-between; 
}

#editor-canvas { 
    width: 300px; 
    height: 300px; 
    overflow: visible; 
}

#context-menu { 
    position: absolute; 
    background: #fff; 
    border: 1px solid #bdc3c7; 
    box-shadow: 2px 2px 10px rgba(0,0,0,0.2); 
    border-radius: 4px; 
    padding: 5px 0; 
    z-index: 100000; 
    min-width: 150px; 
}

.menu-item { 
    padding: 8px 15px; 
    cursor: pointer; 
    font-size: 13px; 
    color: #2c3e50; 
}

.menu-item:hover { 
    background: #ecf0f1; 
}

.comp-label { 
    position: absolute; 
    font-size: 12px; 
    font-weight: bold; 
    font-family: Arial, sans-serif; 
    color: #2c3e50; 
    pointer-events: none; 
    white-space: nowrap; 
}

.pos-left { 
    right: 100%; 
    margin-right: 5px; 
    top: 50%; 
    transform: translateY(-50%); 
}

.pos-bottom-left { 
    right: 100%; 
    margin-right: 5px; 
    bottom: 0; 
}

.parent-selected { 
    outline: 2px dashed #e74c3c; 
    outline-offset: 4px; 
}

.assign-mode { 
    cursor: crosshair !important; 
}

.terminal-label { 
    position: absolute; 
    font-size: 11px; 
    font-family: Arial, sans-serif; 
    color: #34495e; 
    pointer-events: none; 
}

.pos-term-top { top: 8px; right: 10px; }
.pos-term-bottom { bottom: 8px; right: 10px; }


/* --- NEUES VOLLBILD-EDITOR LAYOUT --- */
#fullscreen-editor {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh; 
    background: rgba(44, 62, 80, 0.95); 
    z-index: 100000; 
    display: grid !important; 
    grid-template-columns: 340px 1fr 340px; 
}

#fullscreen-editor.hidden {
    display: none !important;
}

#editor-sidebar-left, #editor-sidebar-right {
    background: #34495e; 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    gap: 12px;
    border-right: 2px solid #2c3e50; 
    overflow-y: auto; 
    color: white;
}

#editor-sidebar-right { 
    border-right: none; 
    border-left: 2px solid #2c3e50; 
}

#editor-main-area { 
    display: flex; 
    flex-direction: column; 
    position: relative; 
    overflow: hidden; 
}

#fullscreen-editor .form-group { display: flex; flex-direction: column; gap: 4px; }
#fullscreen-editor label { font-size: 12px; color: #bdc3c7; font-weight: bold; }
#fullscreen-editor input, #fullscreen-editor select {
    background: #2c3e50; border: 1px solid #7f8c8d; color: white; padding: 8px; border-radius: 4px; font-size: 14px;
}
#fullscreen-editor input:focus, #fullscreen-editor select:focus { border-color: #3498db; outline: none; }
#fullscreen-editor .btn { border: none; padding: 10px; border-radius: 4px; cursor: pointer; font-weight: bold; color: white; text-align: center; }
#fullscreen-editor .btn-success { background: #27ae60; }
#fullscreen-editor .btn-success:hover { background: #219653; }
#fullscreen-editor .btn-close { background: #e74c3c; }
#fullscreen-editor .btn-close:hover { background: #c0392b; }
#fullscreen-editor .panel-title { margin: 0 0 10px 0; border-bottom: 2px solid #2980b9; padding-bottom: 5px; font-size: 1.2em; text-transform: uppercase; }
/* --------------------------------- */


.contact-only, .power-only, .assign-only, .motor-only, .terminal-only, .lamp-only, .arrow-only, .taster-only { 
    display: none; 
}

.ihv-header-row { 
    display: flex; 
    align-items: center; 
    margin-bottom: 20px; 
    border-bottom: 2px solid #bdc3c7; 
    padding-bottom: 10px; 
}

.ihv-row { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    margin-bottom: 10px; 
    padding: 10px; 
    background: #ecf0f1; 
    border-radius: 4px; 
    border: 1px solid #bdc3c7; 
}

.ihv-page-name { 
    font-weight: bold; 
    width: 90px; 
    color: #2c3e50; 
    font-size: 1.1em; 
}

.ihv-input { 
    padding: 8px; 
    border: 1px solid #bdc3c7; 
    border-radius: 4px; 
    font-family: Arial, sans-serif; 
}

.ihv-input:focus { 
    outline: 2px solid #3498db; 
    border-color: transparent; 
}

.ihv-large { flex-grow: 1; }
.ihv-small { width: 120px; text-align: center; }