* { box-sizing: border-box; }
body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #14151a; color: #e0e0e0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; user-select: none; }

/* Top Bar */
#top-bar { height: 44px; background: #1e1f29; border-bottom: 1px solid #333547; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; z-index: 200; box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.top-bar-left, .top-bar-right { display: flex; align-items: center; gap: 8px; }
.divider { width: 1px; height: 20px; background: #4a4d66; margin: 0 4px; }
.brand-logo { color: #00e5ff; font-weight: 900; font-size: 16px; letter-spacing: 1px; text-transform: uppercase; text-shadow: 0 0 8px rgba(0, 229, 255, 0.4); margin-right: 12px; }

/* Layout Main */
#main-content { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
#sidebar { width: 280px; background: #1e1f29; border-right: 1px solid #333547; display: flex; flex-direction: column; padding: 14px; gap: 14px; z-index: 100; overflow-y: auto; }
.sidebar-section { display: flex; flex-direction: column; gap: 6px; }
.sidebar-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: #8a8d9f; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
button { background: #2a2c3a; color: #ddd; border: 1px solid #44475a; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500; transition: all 0.1s ease; }
button:hover { background: #34374a; border-color: #00e5ff; color: #fff; }
button.active { background: #00e5ff; color: #111; border-color: #00e5ff; font-weight: 700; }
.size-btn { flex: 1; padding: 5px 0; font-size: 11px; }

.mode-btn { padding: 6px 10px; }
.mode-btn.active-wire { background: #50fa7b; color: #111; border-color: #50fa7b; }
.mode-btn.active-edit { background: #ffb86c; color: #111; border-color: #ffb86c; }
.mode-btn.active-pan  { background: #f1fa8c; color: #111; border-color: #f1fa8c; }
.mode-btn.active-img  { background: #bd93f9; color: #111; border-color: #bd93f9; }
.dark-input { background: #14151a; border: 1px solid #444; color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 11px; }

/* Colors & Library */
.color-picker-group { display: flex; flex-direction: column; gap: 6px; }
.color-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
input[type="color"] { width: 30px; height: 30px; padding: 0; border: none; border-radius: 4px; cursor: pointer; background: transparent; }
.color-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.color-btn { width: 100%; height: 24px; border-radius: 4px; border: 1px solid #444; cursor: pointer; padding: 0; }
.color-btn:hover { transform: scale(1.1); border-color: #fff; }
.library-list { background: #14151a; border: 1px solid #333547; border-radius: 6px; max-height: 120px; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.folder-item { font-size: 12px; font-weight: bold; color: #f1fa8c; padding: 4px 6px; background: #21222d; border-radius: 4px; }
.lib-template-item { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; background: #2a2c3a; border-radius: 4px; font-size: 11px; margin-left: 10px; }
.lib-template-item span { cursor: pointer; color: #00e5ff; }

/* Workspace */
#workspace-wrapper { flex: 1; position: relative; background: #111216; overflow: hidden; }
#workspace { position: absolute; transform-origin: 0 0; width: 4000px; height: 4000px; background-image: radial-gradient(#282a36 1.5px, transparent 1.5px); background-size: 24px 24px; }
body.mode-pan #workspace-wrapper { cursor: grab; }
body.mode-pan:active #workspace-wrapper { cursor: grabbing; }

svg#grid-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
svg#wire-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; pointer-events: none; }
.wire-path { fill: none; stroke-width: 3px; stroke-linecap: round; stroke-linejoin: round; cursor: pointer; pointer-events: stroke; transition: filter 0.2s; }
.active-wire-path { stroke-width: 5px; filter: drop-shadow(0 0 6px currentColor); }
.wire-label { font-size: 12px; font-weight: bold; fill: #fff; pointer-events: none; user-select: none; text-shadow: 0 0 3px #000, 0 0 5px #000; transition: all 0.2s; }
.active-wire-path + .wire-label { fill: currentColor; text-shadow: 0 0 5px currentColor, 0 0 10px currentColor; }

/* Cleane Container (Header entfernt) */
.component { position: absolute; border: 2px solid #4a4d66; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); cursor: move; z-index: 20; display: flex; flex-direction: column; transition: border-color 0.2s; }
.component.active-comp { border-color: #00e5ff; box-shadow: 0 0 15px rgba(0, 229, 255, 0.4); }
.component.circle { border-radius: 50%; }

.action-btn { height: 24px; padding: 0 10px; font-size: 11px; font-weight: bold; border-radius: 4px; background: #2f3142; border: 1px solid #555870; color: #ddd; cursor: pointer; }
.action-btn:hover { background: #00e5ff; color: #111; }
.pin-btn { width: 24px; height: 24px; padding: 0; font-size: 14px; line-height: 1; border-radius: 4px; background: #2f3142; border: 1px solid #555870; }
.pin-btn:hover { background: #00e5ff; color: #111; }
.pin-counter-label { font-size: 11px; color: #ffb86c; min-width: 38px; text-align: center; }

.comp-viewport { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.component.circle .comp-viewport { border-radius: 50%; }
.comp-text { position: absolute; inset: 0; padding: 8px; color: #fff; text-align: center; display: flex; align-items: center; justify-content: center; outline: none; word-break: break-word; overflow: hidden; z-index: 10; cursor: text; transition: all 0.2s; border: 2px solid transparent; }
.comp-text:focus { background: rgba(0, 229, 255, 0.15); box-shadow: inset 0 0 15px rgba(0, 229, 255, 0.3); border-color: rgba(0, 229, 255, 0.5); border-radius: 4px; }
.comp-image, .comp-svg { position: absolute; transform-origin: 0 0; pointer-events: none; user-select: none; z-index: 5; } 

body.mode-img .component { outline: 2px dashed #bd93f9; }
body.mode-img .comp-viewport { overflow: visible !important; opacity: 0.85; }
body.mode-img .comp-image { pointer-events: auto !important; cursor: move; }
.img-resize-handle { display: none; position: absolute; width: 12px; height: 12px; background: #bd93f9; border: 2px solid #fff; border-radius: 2px; bottom: -6px; right: -6px; cursor: nwse-resize; z-index: 50; }
body.mode-img .img-resize-handle { display: block; }

.pin { position: absolute; width: 13px; height: 13px; background: #ffb86c; border: 2px solid #14151a; border-radius: 50%; transform: translate(-50%, -50%); z-index: 30; }
body.mode-wire .pin { cursor: crosshair; }
body.mode-wire .pin:hover { background: #50fa7b; transform: translate(-50%, -50%) scale(1.4); }
body.mode-edit .pin { cursor: grab; background: #ff79c6; }
.pin.connecting { background: #50fa7b !important; box-shadow: 0 0 12px #50fa7b; }
.wire-handle { position: absolute; width: 12px; height: 12px; background: #ff5555; border: 2px solid #ffffff; border-radius: 50%; transform: translate(-50%, -50%); cursor: grab; z-index: 40; }

#status-bar { position: absolute; bottom: 12px; left: 16px; right: 16px; font-size: 12px; color: #8a8d9f; background: #1e1f29; padding: 8px 12px; border-radius: 4px; border: 1px solid #333547; z-index: 50; display: flex; justify-content: space-between; }
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 1000; justify-content: center; align-items: center; }
.modal-box { background: #1e1f29; padding: 24px; border-radius: 8px; width: 400px; max-width: 90%; border: 1px solid #4a4d66; }
.modal-overlay label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; background: #2a2c3a; padding: 8px; border-radius: 4px; }
.modal-overlay label:hover { background: #34374a; }

/* Drucker Modus */
body.print-mode #workspace { background-color: #ffffff !important; background-image: none !important; }
body.print-mode #grid-layer { display: none !important; }
body.print-mode .component { border-color: #000 !important; box-shadow: none !important; }
body.print-mode .comp-text { color: #000 !important; text-shadow: 0 0 2px #fff !important; }
body.print-mode .wire-label { fill: #000 !important; text-shadow: 0 0 4px #fff, 0 0 6px #fff !important; }
body.print-mode .wire-path { filter: none !important; }
body.print-mode .pin { border-color: #000 !important; }
body.print-mode .wire-handle { display: none !important; }
