:root {
  /* Sci-Fi (Default) */
  --bg: #0a0e12;
  --panel: #131922;
  --panel-2: #1a2230;
  --border: #2a3442;
  --accent: #ff8c1a;
  --accent-hover: #ffa040;
  --accent-2: #4ec5ff;
  --good: #5fd47b;
  --warn: #ff5560;
  --text: #d8e1ec;
  --muted: #6b7a8d;
  --code-bg: #07090c;

  /* RGB-Companion (für rgba()) */
  --accent-rgb: 255, 140, 26;
  --accent-2-rgb: 78, 197, 255;
  --bg-rgb: 10, 14, 18;
  --shadow-rgb: 0, 0, 0;

  /* Text auf Accent-Hintergrund */
  --text-on-accent: #0a0e12;

  /* LCD-Vorschau-Rahmen */
  --lcd-frame-bg: #07090c;
  --lcd-frame-border: #1a2230;
  --lcd-frame-glow: 255, 140, 26;

  /* Body-Glow-Tints (radial-gradients) */
  --body-glow-1: 255, 140, 26;
  --body-glow-2: 78, 197, 255;

  /* Syntax-Highlighting */
  --syn-kw:   #c586c0;
  --syn-type: #4ec9b0;
  --syn-str:  #ce9178;
  --syn-com:  #6a9955;
  --syn-num:  #b5cea8;
  --syn-fn:   #dcdcaa;
}

/* =================== THEMES =================== */

[data-theme="dark"] {
  --bg: #14161a;
  --panel: #1c1f24;
  --panel-2: #24282e;
  --border: #353a42;
  --accent: #8aa0b8;
  --accent-hover: #a8bbd0;
  --accent-2: #b8cbdb;
  --good: #6fd49b;
  --warn: #ff7080;
  --text: #e2e8ee;
  --muted: #7a8896;
  --code-bg: #0e1014;

  --accent-rgb: 138, 160, 184;
  --accent-2-rgb: 184, 203, 219;
  --bg-rgb: 20, 22, 26;
  --shadow-rgb: 0, 0, 0;

  --text-on-accent: #14161a;
  --lcd-frame-bg: #0a0c10;
  --lcd-frame-border: #24282e;
  --lcd-frame-glow: 138, 160, 184;
  --body-glow-1: 138, 160, 184;
  --body-glow-2: 184, 203, 219;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --border: #d0d8e2;
  --accent: #1e6fdb;
  --accent-hover: #2a82f0;
  --accent-2: #3aa8e8;
  --good: #2a9d4c;
  --warn: #d83040;
  --text: #1a2230;
  --muted: #6a7686;
  --code-bg: #f8fafc;

  --accent-rgb: 30, 111, 219;
  --accent-2-rgb: 58, 168, 232;
  --bg-rgb: 244, 246, 250;
  --shadow-rgb: 80, 100, 130;

  --text-on-accent: #ffffff;
  --lcd-frame-bg: #1a1f28;
  --lcd-frame-border: #c0c8d2;
  --lcd-frame-glow: 30, 111, 219;
  --body-glow-1: 30, 111, 219;
  --body-glow-2: 58, 168, 232;

  --syn-kw:   #0000c0;
  --syn-type: #267f99;
  --syn-str:  #a31515;
  --syn-com:  #008000;
  --syn-num:  #098658;
  --syn-fn:   #795e26;
}

[data-theme="cyberpunk"] {
  --bg: #0d0420;
  --panel: #1a0b3a;
  --panel-2: #2a1252;
  --border: #4a2890;
  --accent: #ff2bd1;
  --accent-hover: #ff5ed8;
  --accent-2: #00f5ff;
  --good: #00ff9c;
  --warn: #ff3060;
  --text: #f0e0ff;
  --muted: #9080c0;
  --code-bg: #060118;

  --accent-rgb: 255, 43, 209;
  --accent-2-rgb: 0, 245, 255;
  --bg-rgb: 13, 4, 32;
  --shadow-rgb: 0, 0, 0;

  --text-on-accent: #0d0420;
  --lcd-frame-bg: #060118;
  --lcd-frame-border: #2a1252;
  --lcd-frame-glow: 255, 43, 209;
  --body-glow-1: 255, 43, 209;
  --body-glow-2: 0, 245, 255;

  --syn-kw:   #ff2bd1;
  --syn-type: #00f5ff;
  --syn-str:  #ffd060;
  --syn-com:  #6a4a90;
  --syn-num:  #00ff9c;
  --syn-fn:   #ffff80;
}

[data-theme="matrix"] {
  --bg: #020a02;
  --panel: #061a06;
  --panel-2: #0a2b0a;
  --border: #144014;
  --accent: #00ff44;
  --accent-hover: #40ff70;
  --accent-2: #50ff7a;
  --good: #00ff44;
  --warn: #ffff40;
  --text: #aaffaa;
  --muted: #4a8a4a;
  --code-bg: #010401;

  --accent-rgb: 0, 255, 68;
  --accent-2-rgb: 80, 255, 122;
  --bg-rgb: 2, 10, 2;
  --shadow-rgb: 0, 0, 0;

  --text-on-accent: #020a02;
  --lcd-frame-bg: #010401;
  --lcd-frame-border: #0a2b0a;
  --lcd-frame-glow: 0, 255, 68;
  --body-glow-1: 0, 255, 68;
  --body-glow-2: 80, 255, 122;

  --syn-kw:   #00ff80;
  --syn-type: #80ffaa;
  --syn-str:  #ddffdd;
  --syn-com:  #4a8a4a;
  --syn-num:  #aaffaa;
  --syn-fn:   #00ff44;
}

[data-theme="hero"] {
  /* Star-Citizen-/Destiny-Sci-Fi: eisblau auf dunkelmarineblau,
     feine Linien, leichter Glassmorph-Touch */
  --bg: #0a1420;
  --panel: #14202e;
  --panel-2: #1e2c3e;
  --border: #3a5070;
  --accent: #7fb8ff;
  --accent-hover: #a0cfff;
  --accent-2: #c8d8f0;
  --good: #5fd4a0;
  --warn: #ff7080;
  --text: #e8f0fa;
  --muted: #7e8fa6;
  --code-bg: #060e18;

  --accent-rgb: 127, 184, 255;
  --accent-2-rgb: 200, 216, 240;
  --bg-rgb: 10, 20, 32;
  --shadow-rgb: 0, 0, 0;

  --text-on-accent: #0a1420;
  --lcd-frame-bg: #060e18;
  --lcd-frame-border: #1e2c3e;
  --lcd-frame-glow: 127, 184, 255;
  --body-glow-1: 127, 184, 255;
  --body-glow-2: 200, 216, 240;

  --syn-kw:   #b090ff;
  --syn-type: #7fb8ff;
  --syn-str:  #ffc080;
  --syn-com:  #6080a0;
  --syn-num:  #80ddc0;
  --syn-fn:   #e0e8f5;
}

[data-theme="hologram"] {
  /* HUD-Holo-Display: kühles Türkis, leicht leuchtend, fast schwebend */
  --bg: #051818;
  --panel: #0a2a2e;
  --panel-2: #103a3e;
  --border: #1e6068;
  --accent: #5fffe0;
  --accent-hover: #80fff0;
  --accent-2: #80fff0;
  --good: #5fffa0;
  --warn: #ffa050;
  --text: #b8e8e0;
  --muted: #4a8a82;
  --code-bg: #021010;

  --accent-rgb: 95, 255, 224;
  --accent-2-rgb: 128, 255, 240;
  --bg-rgb: 5, 24, 24;
  --shadow-rgb: 0, 40, 50;

  --text-on-accent: #051818;
  --lcd-frame-bg: #021010;
  --lcd-frame-border: #103a3e;
  --lcd-frame-glow: 95, 255, 224;
  --body-glow-1: 95, 255, 224;
  --body-glow-2: 128, 255, 240;

  --syn-kw:   #80fff0;
  --syn-type: #c0fff5;
  --syn-str:  #ffd090;
  --syn-com:  #4a8a82;
  --syn-num:  #a0ffe0;
  --syn-fn:   #e0fff5;
}

[data-theme="industrial"] {
  /* Space-Engineers-Werkstatt: gedämpftes Rost-Orange, Stahlgrau,
     schwere Kanten, Warntreifen-Vibe */
  --bg: #1a1a1c;
  --panel: #232325;
  --panel-2: #2c2c2e;
  --border: #4a4a4c;
  --accent: #e07020;
  --accent-hover: #ff8830;
  --accent-2: #b8a880;
  --good: #80a060;
  --warn: #c84040;
  --text: #d0d0cc;
  --muted: #80807c;
  --code-bg: #131315;

  --accent-rgb: 224, 112, 32;
  --accent-2-rgb: 184, 168, 128;
  --bg-rgb: 26, 26, 28;
  --shadow-rgb: 0, 0, 0;

  --text-on-accent: #1a1a1c;
  --lcd-frame-bg: #131315;
  --lcd-frame-border: #2c2c2e;
  --lcd-frame-glow: 224, 112, 32;
  --body-glow-1: 224, 112, 32;
  --body-glow-2: 184, 168, 128;

  --syn-kw:   #d090c0;
  --syn-type: #80b0a0;
  --syn-str:  #d8a070;
  --syn-com:  #6a8a55;
  --syn-num:  #b8c890;
  --syn-fn:   #d0c890;
}

/* "Auto" folgt dem OS-Theme: hellt auf bei prefers-color-scheme:light,
   dunkelt sonst. Realisiert via inheriting der light/dark-Variablen.
   Wir spiegeln die Variablen-Sets im @media-Block. */
@media (prefers-color-scheme: light) {
  [data-theme="auto"] {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --panel-2: #eef2f7;
    --border: #d0d8e2;
    --accent: #1e6fdb;
    --accent-hover: #2a82f0;
    --accent-2: #3aa8e8;
    --good: #2a9d4c;
    --warn: #d83040;
    --text: #1a2230;
    --muted: #6a7686;
    --code-bg: #f8fafc;

    --accent-rgb: 30, 111, 219;
    --accent-2-rgb: 58, 168, 232;
    --bg-rgb: 244, 246, 250;
    --shadow-rgb: 80, 100, 130;

    --text-on-accent: #ffffff;
    --lcd-frame-bg: #1a1f28;
    --lcd-frame-border: #c0c8d2;
    --lcd-frame-glow: 30, 111, 219;
    --body-glow-1: 30, 111, 219;
    --body-glow-2: 58, 168, 232;

    --syn-kw:   #0000c0;
    --syn-type: #267f99;
    --syn-str:  #a31515;
    --syn-com:  #008000;
    --syn-num:  #098658;
    --syn-fn:   #795e26;
  }
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #14161a;
    --panel: #1c1f24;
    --panel-2: #24282e;
    --border: #353a42;
    --accent: #8aa0b8;
    --accent-hover: #a8bbd0;
    --accent-2: #b8cbdb;
    --good: #6fd49b;
    --warn: #ff7080;
    --text: #e2e8ee;
    --muted: #7a8896;
    --code-bg: #0e1014;

    --accent-rgb: 138, 160, 184;
    --accent-2-rgb: 184, 203, 219;
    --bg-rgb: 20, 22, 26;
    --shadow-rgb: 0, 0, 0;

    --text-on-accent: #14161a;
    --lcd-frame-bg: #0a0c10;
    --lcd-frame-border: #24282e;
    --lcd-frame-glow: 138, 160, 184;
    --body-glow-1: 138, 160, 184;
    --body-glow-2: 184, 203, 219;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 20% 0%, rgba(var(--body-glow-1), 0.06), transparent 40%),
    radial-gradient(circle at 80% 100%, rgba(var(--body-glow-2), 0.05), transparent 40%);
}

header {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-bottom: 2px solid var(--accent);
  padding: 18px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 20px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 600;
}

header h1 .accent { color: var(--accent); }

header .tag {
  font-family: 'Consolas', monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 18px;
}

.theme-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 11px;
}

.theme-picker-label {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
}

.theme-picker select {
  width: auto;
  padding: 4px 24px 4px 8px;
  font-size: 11px;
  font-family: 'Consolas', monospace;
  letter-spacing: 0.5px;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1900px;
  margin: 0 auto;
}

@media (max-width: 1400px) {
  .layout { grid-template-columns: 220px 1fr; }
  .layout > .panel.code-panel { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .layout > .panel.code-panel { grid-column: auto; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.panel-header {
  background: var(--panel-2);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.panel-body {
  padding: 16px;
}

.section {
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(var(--shadow-rgb), 0.15);
}

.section-title {
  background: var(--panel-2);
  padding: 8px 12px;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.section-content {
  padding: 12px;
}

label {
  display: block;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  font-family: 'Consolas', monospace;
  font-size: 13px;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.15s;
}

.group-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 4px;
  padding: 4px 8px;
  background: rgba(var(--shadow-rgb), 0.12);
  border-left: 2px solid var(--accent-2);
  font-size: 11px;
  font-family: 'Consolas', monospace;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  border-radius: 2px;
}
.group-toggle input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.group-toggle:has(input:checked) {
  color: var(--accent-2);
  background: rgba(var(--accent-2-rgb), 0.10);
}

.share-token-area {
  font-size: 11px;
  line-height: 1.35;
  word-break: break-all;
  resize: vertical;
  min-height: 64px;
  max-height: 280px;
}

/* ============ Themed Modal Dialogs (v1.4.1) ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--shadow-rgb), 0.65);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: modal-fade 0.12s ease-out;
}
.modal-overlay.show { display: flex; }

@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 4px;
  padding: 18px 20px 16px;
  min-width: 320px;
  max-width: 560px;
  box-shadow: 0 12px 40px rgba(var(--shadow-rgb), 0.55);
  font-family: 'Segoe UI', system-ui, sans-serif;
  animation: modal-pop 0.14s ease-out;
}

@keyframes modal-pop {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.modal-title {
  font-family: 'Consolas', monospace;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.modal-body { margin-bottom: 14px; }

.modal-message {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
}

.modal-input {
  margin-top: 10px;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-actions button {
  min-width: 96px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ff8c1a' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.row { display: grid; gap: 8px; margin-bottom: 8px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent-hover);
  color: var(--text-on-accent);
}

button.danger:hover {
  border-color: var(--warn);
  color: var(--warn);
}

button.small {
  padding: 4px 8px;
  font-size: 10px;
}

.btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.condition-block, .action-block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-2);
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 2px;
}

.action-block { border-left-color: var(--good); }
.else-block { border-left-color: var(--warn); }

.cond-header, .act-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.logic-op {
  display: flex;
  justify-content: center;
  margin: -4px 0;
}

.logic-op select {
  width: auto;
  font-size: 10px;
  padding: 3px 24px 3px 8px;
  text-transform: uppercase;
  background-color: var(--accent);
  color: var(--text-on-accent);
  font-weight: 700;
  border-color: var(--accent);
}

.code-output {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 14px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  min-height: 400px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.code-output .kw   { color: var(--syn-kw); }
.code-output .type { color: var(--syn-type); }
.code-output .str  { color: var(--syn-str); }
.code-output .com  { color: var(--syn-com); font-style: italic; }
.code-output .num  { color: var(--syn-num); }
.code-output .fn   { color: var(--syn-fn); }

.empty-hint {
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
  padding: 8px 0;
}

.toggle-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  cursor: pointer;
  font-size: 11px;
}

.toggle-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--good);
  color: var(--text-on-accent);
  padding: 12px 20px;
  border-radius: 3px;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.templates-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.template-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-size: 11px;
  font-family: 'Consolas', monospace;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.template-chip:hover { border-color: var(--accent-2); color: var(--accent-2); }

.template-chip .x {
  color: var(--warn);
  font-weight: bold;
  cursor: pointer;
  padding: 0 2px;
}

.help-text {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 4px;
  font-family: 'Consolas', monospace;
  line-height: 1.4;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

footer {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-family: 'Consolas', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

footer .accent { color: var(--accent); }

.ascii-corner {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0;
}

.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.tab {
  padding: 8px 14px;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--muted);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ============================================================
   TOOLTIPS (Phase 1 — Grundgerüst, Inhalte folgen ab Phase 2)
   ============================================================ */

.tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  cursor: help;
  font-family: 'Consolas', monospace;
  user-select: none;
  vertical-align: middle;
}

.tooltip-trigger:hover {
  background: var(--accent-2);
  color: var(--bg);
}

.tooltip {
  position: fixed;
  background: var(--panel-2);
  border: 1px solid var(--accent-2);
  color: var(--text);
  font-family: 'Consolas', monospace;
  font-size: 11px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 3px;
  max-width: 280px;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(var(--shadow-rgb), 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}

.tooltip.show {
  opacity: 1;
}

/* ============================================================
   PALETTE (Phase 3 — Drag & Drop)
   ============================================================ */

.palette-panel {
  position: sticky;
  top: 70px;       /* unterhalb des Sticky-Headers */
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

.palette-search {
  margin-bottom: 10px;
}

.palette-category {
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(var(--shadow-rgb), 0.15);
}

.palette-cat-header {
  background: var(--panel-2);
  padding: 6px 10px;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-2);
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.palette-cat-header:hover { color: var(--accent); }

.palette-cat-header .toggle-arrow {
  font-size: 9px;
  color: var(--muted);
  transition: transform 0.15s;
}

.palette-category.collapsed .toggle-arrow { transform: rotate(-90deg); }
.palette-category.collapsed .palette-cat-body { display: none; }

.palette-cat-body {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.palette-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-2);
  border-radius: 2px;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  color: var(--text);
  cursor: grab;
  user-select: none;
  transition: all 0.12s;
}

.palette-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateX(2px);
}

.palette-card:active { cursor: grabbing; }

.palette-card.dragging {
  opacity: 0.4;
}

.palette-card .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--accent-2);
}

.palette-card:hover .icon { color: var(--accent); }

.palette-card .name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Drop-Zones (auf den Section-Content-Containern) */

.drop-target {
  transition: background 0.1s, border-color 0.1s;
  position: relative;
}

.drop-target.dragover {
  background: rgba(var(--accent-rgb), 0.08);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.drop-target.dragover::after {
  content: "↓ Hier ablegen";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--accent);
  font-family: 'Consolas', monospace;
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 700;
  background: rgba(10, 14, 18, 0.5);
  z-index: 1;
}

/* ============================================================
   LCD-COMPOSER (Phase 4a)
   ============================================================ */

.lcd-widget-block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  padding: 10px;
  margin-bottom: 10px;
}

.lcd-widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.lcd-widget-block.expanded .lcd-widget-header {
  margin-bottom: 8px;
  color: var(--accent);
}
.lcd-widget-block.collapsed {
  padding: 6px 10px;
}
.lcd-collapse-arrow {
  display: inline-block;
  width: 12px;
  color: var(--muted);
}

/* Layer-Liste (Phase B.1) */
.lcd-layer-list {
  margin: 8px auto 14px;
  max-width: 380px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(var(--shadow-rgb), 0.2);
  padding: 4px;
}
.lcd-layer-title {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-2);
  padding: 2px 4px 6px;
}
.lcd-layer-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}
.lcd-layer-row.is-hidden { opacity: 0.45; }
.lcd-layer-eye {
  background: transparent;
  border: 1px solid transparent;
  width: 24px;
  padding: 2px 0;
  font-size: 11px;
  cursor: pointer;
  color: var(--text);
}
.lcd-layer-eye:hover { color: var(--accent); border-color: var(--border); }
.lcd-layer-name {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  padding: 2px 6px;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  color: var(--text);
}
.lcd-layer-name:hover { color: var(--accent); border-color: var(--border); }

.lcd-widget-preview {
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--code-bg);
  margin-bottom: 8px;
  overflow: hidden;
  line-height: 0;
  /* kompakter — Editor-Vorschau soll nur ein kleiner Thumbnail sein */
  max-width: 180px;
  max-height: 120px;
  display: inline-block;
}

.lcd-widget-preview svg {
  display: block;
  width: 100%;
  height: auto;
}

.lcd-widget-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.lcd-widget-fields > div { min-width: 0; }

.lcd-widget-group-title {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-2);
  margin: 6px 0 4px;
  padding-bottom: 3px;
  border-bottom: 1px dashed var(--border);
}

/* Theme-Auswahlleiste (Phase 4c) */
.lcd-theme-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 6px 8px;
  background: rgba(var(--shadow-rgb), 0.2);
  border: 1px solid var(--border);
  border-radius: 2px;
  flex-wrap: wrap;
}

.lcd-theme-label {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

/* Live-Full-Preview (Phase 4c.1) */
.lcd-full-preview-wrap {
  margin-bottom: 14px;
}

.lcd-full-preview-label {
  font-family: 'Consolas', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.lcd-full-preview {
  background: var(--lcd-frame-bg);
  border: 3px solid var(--lcd-frame-border);
  border-radius: 6px;
  margin: 0 auto;
  box-shadow: 0 0 12px rgba(var(--lcd-frame-glow), 0.15), inset 0 0 8px rgba(var(--shadow-rgb), 0.6);
  overflow: hidden;
  position: relative;  /* für absolut positionierte Cells */
}

.lcd-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    linear-gradient(to right,  rgba(var(--accent-rgb), 0.10) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(var(--accent-rgb), 0.10) 1px, transparent 1px);
}

/* Multi-LCD: kräftigere Trennlinien zwischen physischen LCDs */
.lcd-sep {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  background: rgba(var(--accent-rgb), 0.6);
  box-shadow: 0 0 4px rgba(var(--accent-rgb), 0.5);
}

.lcd-name-tag {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  font-family: 'Consolas', monospace;
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: rgba(var(--shadow-rgb), 0.5);
  padding: 1px 4px;
  border-radius: 2px;
  text-transform: uppercase;
}

.lcd-full-cell {
  position: absolute;
  overflow: hidden;
  line-height: 0;
}

.lcd-cell-manual {
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
  cursor: move;
  z-index: 2;
  user-select: none;
}
.lcd-cell-manual:hover {
  outline: 2px solid var(--accent);
}
/* SVG-Inhalt fängt mousedown nicht ab — Drag soll von der Cell selbst gestartet werden */
.lcd-cell-manual > svg {
  pointer-events: none;
}

.lcd-cell-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: var(--accent);
  cursor: nwse-resize;
  z-index: 3;
  border-top-left-radius: 4px;
}
.lcd-cell-resize::before {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 6px 6px;
  border-color: transparent transparent var(--text-on-accent) transparent;
}

/* Live-Maße-Badge während Drag/Resize */
.lcd-drag-badge {
  position: fixed;
  background: var(--accent);
  color: var(--text-on-accent);
  padding: 4px 8px;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  font-weight: 700;
  border-radius: 3px;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(var(--shadow-rgb), 0.4);
  white-space: nowrap;
}

.lcd-full-cell svg {
  display: block;
  width: 100%;
  height: 100%;
  preserveAspectRatio: none;
}

.lcd-full-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: 'Consolas', monospace;
  font-size: 11px;
  font-style: italic;
}

.lcd-overflow-mark {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(255, 85, 96, 0.85);
  color: #fff;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 3px 4px;
  pointer-events: none;
}

button.small:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
button.small:disabled:hover {
  border-color: var(--border);
  color: var(--text);
}
