:root {
  --bg: #0f1117;
  --bg-2: #151821;
  --panel: #1a1e29;
  --panel-2: #212635;
  --line: #2a3042;
  --line-2: #353c52;
  --text: #e6e9f2;
  --text-2: #9aa3b8;
  --text-3: #6b7489;
  --accent: #7c5cff;
  --accent-2: #9b82ff;
  --accent-soft: rgba(124, 92, 255, .18);
  --danger: #ff5470;
  --ok: #3ddc97;
  --stage: #0b0d12;
  --checker-a: #2b3040;
  --checker-b: #232736;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --radius: 10px;
  --font: "Segoe UI Variable", "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef0f5;
  --bg-2: #e6e9f0;
  --panel: #ffffff;
  --panel-2: #f3f4f8;
  --line: #dde1ea;
  --line-2: #c9cfdc;
  --text: #1b1f2b;
  --text-2: #586078;
  --text-3: #8890a5;
  --accent: #6a4cf5;
  --accent-2: #5536e8;
  --accent-soft: rgba(106, 76, 245, .14);
  --stage: #d9dde6;
  --checker-a: #ffffff;
  --checker-b: #e3e6ee;
  --shadow: 0 12px 40px rgba(20, 25, 45, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

#app { display: grid; grid-template-rows: auto auto 1fr auto; height: 100vh; }

/* ---------- Kopfzeile ---------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 10px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.brand:hover { background: var(--panel-2); }
.brand-icon { width: 22px; height: 22px; image-rendering: pixelated; border-radius: 5px; }
.brand-version {
  padding: 1px 7px; border-radius: 999px; font: 600 10.5px/1.6 var(--mono);
  color: var(--accent-2); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.brand-name { font-weight: 700; letter-spacing: .2px; background: linear-gradient(90deg, var(--accent-2), #ff7ac6); -webkit-background-clip: text; background-clip: text; color: transparent; }

#menubar { display: flex; gap: 2px; }
.menu { position: relative; }
.menu-btn { background: none; border: 0; padding: 6px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.menu-btn:hover, .menu.open .menu-btn { background: var(--panel-2); color: var(--text); }
.menu-list {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  min-width: 300px; width: max-content; max-width: calc(100vw - 24px); padding: 6px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow);
}
.menu.open .menu-list { display: block; animation: pop .12s ease-out; }
.menu-list button {
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none; cursor: pointer; text-align: left;
  white-space: nowrap; /* Menütexte nie umbrechen */
}
.menu-list button:hover { background: var(--accent-soft); }
.menu-list button.checked span::before { content: "✓ "; color: var(--accent-2); }
kbd { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.divider { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--text-2);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon-btn.small { width: 26px; height: 26px; border-radius: 6px; }
.icon-btn.small svg { width: 15px; height: 15px; }
.icon-btn.danger:hover { color: var(--danger); }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--panel-2); cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn svg { width: 16px; height: 16px; }

/* ---------- Optionsleiste ---------- */
#optionsbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  min-height: 40px; padding: 4px 14px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  color: var(--text-2);
}
.opt-group { display: flex; align-items: center; gap: 10px; }
.opt-group[hidden] { display: none; }
.opt-spacer { flex: 1; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.toggle:hover { background: var(--panel-2); color: var(--text); }
.toggle input { display: none; }
/* Schalter: aus = grau, an = komplett lila */
.toggle span { position: relative; padding-left: 34px; }
.toggle span::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 26px; height: 14px; margin-top: -7px;
  border-radius: 999px; background: var(--line-2); transition: background .15s;
}
.toggle span::after {
  content: ""; position: absolute; left: 2px; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  border-radius: 50%; background: var(--text-3); transition: transform .15s, background .15s;
}
.toggle input:checked + span { color: var(--text); }
.toggle input:checked + span::before { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(12px); background: var(--accent-2); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 110px; height: 4px; border-radius: 4px; background: var(--line-2); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); cursor: pointer; }

/* ---------- Arbeitsbereich ---------- */
#workspace { display: grid; grid-template-columns: 52px 1fr 330px; min-height: 0; }

/* Kompakte Werkzeugleiste: passt auch auf Laptops ohne Scrollbalken; bei sehr kleinen Fenstern scrollt sie per Mausrad (ohne sichtbaren Balken) */
#toolbar {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
  background: var(--bg-2); border-right: 1px solid var(--line); overflow-y: auto; min-height: 0;
  scrollbar-width: none;
}
#toolbar::-webkit-scrollbar { display: none; }
.tool {
  flex: none; width: 34px; height: 27px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--text-2);
  transition: background .12s, color .12s, transform .08s;
}
.tool:hover { background: var(--panel-2); color: var(--text); }
.tool:active { transform: scale(.94); }
.tool.active { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(124, 92, 255, .45); }
.tool svg { width: 17px; height: 17px; }
.tool-sep { width: 22px; height: 1px; background: var(--line); margin: 1px 0; flex: none; }

.color-pair { position: relative; width: 46px; height: 46px; margin-top: auto; flex: none; }
.color-chip {
  position: absolute; width: 28px; height: 28px; border-radius: 7px; cursor: pointer; padding: 0;
  border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line-2);
  background-image: linear-gradient(var(--c, #000), var(--c, #000)), conic-gradient(#ccc 25%, #fff 0 50%, #ccc 0 75%, #fff 0);
  background-size: 100% 100%, 10px 10px;
}
.color-chip.primary { left: 0; top: 0; z-index: 2; }
.color-chip.secondary { right: 0; bottom: 0; }
.swap { position: absolute; right: -1px; top: -3px; width: 16px; height: 16px; padding: 0; border: 0; background: none; color: var(--text-3); cursor: pointer; }
.swap svg { width: 13px; height: 13px; }
.swap:hover { color: var(--text); }

#stage { position: relative; overflow: hidden; background: var(--stage); }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Scrollleisten der Zeichenfläche */
.sbar { position: absolute; z-index: 2; border-radius: 999px; background: rgba(127, 127, 140, .10); }
.sbar[hidden] { display: none; }
.sbar-h { left: 6px; right: 20px; bottom: 4px; height: 10px; }
.sbar-v { top: 6px; bottom: 20px; right: 4px; width: 10px; }
.sbar-thumb { position: absolute; border-radius: 999px; background: var(--line-2); cursor: pointer; transition: background .12s; }
.sbar-h .sbar-thumb { top: 1px; bottom: 1px; }
.sbar-v .sbar-thumb { left: 1px; right: 1px; }
.sbar-thumb:hover, .sbar-thumb.dragging { background: var(--accent); }
/* GB-Studio-Paletten: Anzeige oben links auf der Zeichenfläche und Dialog */
#gb-hud {
  position: absolute; left: 14px; top: 14px; display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 6px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow); z-index: 3;
}
#gb-hud[hidden] { display: none; }
/* Paletten-Übersicht unter der Anzeige */
#gb-legend {
  position: absolute; left: 14px; top: 58px; display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); z-index: 3;
}
#gb-legend[hidden] { display: none; }
.gb-lrow { display: flex; align-items: center; gap: 3px; }
.gb-ltag { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; color: #fff; font: 700 10px var(--mono); margin-right: 3px; flex: none; }
.gb-ltag.ok { background: rgba(61, 220, 132, .25); color: #3ddc84; }
.gb-ltag.warn { background: rgba(255, 50, 80, .25); color: #ff6b81; }
.gb-lsw { width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--line-2); padding: 0; cursor: pointer; flex: none; }
.gb-lsw:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.gb-lsw.empty { cursor: default; background: repeating-linear-gradient(45deg, transparent 0 3px, var(--line) 3px 4px); }
.gb-lsw.empty:hover { outline: none; }
.gb-lmore { font: 600 10px var(--mono); color: var(--text-3); margin-left: 2px; }
/* Paletten über 7: rot */
.gb-lrow.gb-over { outline: 1px solid #ff3250; outline-offset: 2px; border-radius: 6px; background: rgba(255, 50, 80, .12); }
.gb-row.gb-over .hint { color: #ff6b81; }
.gb-pair { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.gb-pair .gb-sw { width: 14px; height: 14px; border-radius: 3px; }
#gb-hud.warn { border-color: #ff3250; }
#gb-hud-open { display: flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text); font: 600 12px inherit; cursor: pointer; padding: 4px 6px; }
.gb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
#gb-hud.warn .gb-dot { background: #ff3250; }
.gb-sum { margin: 0; font-weight: 700; color: var(--text); }
.gb-sum.ok { color: #3ddc84; }
.gb-sum.warn { color: #ff6b81; }
.gb-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.gb-row { display: flex; align-items: center; gap: 10px; }
.gb-num { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; font: 700 12px var(--mono); flex: none; }
.gb-sws { display: flex; gap: 3px; }
.gb-sw { width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--line-2); }
.gb-sw.empty { background: repeating-linear-gradient(45deg, transparent 0 4px, var(--line) 4px 5px); }
#modal-body .gb-warn { color: #ff6b81; }
.gb-mode { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel-2); }
.gb-mode-btn { flex: 1; border: 0; background: none; color: var(--text-2); font: 600 13px inherit; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.gb-mode-btn:hover { color: var(--text); }
.gb-mode-btn.active { background: var(--accent); color: #fff; }
.exp-mode { margin-bottom: 2px; }
.gb-line { display: flex; align-items: center; gap: 8px; color: var(--text); }
.gb-line .hint { color: var(--text-3); font-size: 12px; }
.gb-ui { display: inline-flex; gap: 3px; vertical-align: middle; }
.gb-ui .gb-sw { width: 14px; height: 14px; border-radius: 3px; }
.gb-mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none; }
.gb-mark.ok { background: rgba(61, 220, 132, .18); color: #3ddc84; }
.gb-mark.warn { background: rgba(255, 50, 80, .18); color: #ff6b81; }
.gb-label { min-width: 52px; }
.gb-foreigns { flex-wrap: wrap; gap: 8px; }
.gb-foreign { display: inline-flex; align-items: center; gap: 4px; }
.gb-sprite { margin-top: 2px; }

#zoom-hud {
  position: absolute; right: 26px; bottom: 26px; display: flex; align-items: center; gap: 2px; padding: 4px;
  background: color-mix(in srgb, var(--panel) 85%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
#zoom-label { min-width: 54px; text-align: center; color: var(--text-2); }

/* ---------- Seitenleiste ---------- */
#sidebar { display: flex; flex-direction: column; gap: 8px; padding: 8px; background: var(--bg-2); border-left: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 26px; }
.panel-head h3 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-2); font-weight: 700; }
.panel-actions { display: flex; gap: 1px; }
.row { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.row label { min-width: 58px; font-size: 12px; }
.row input[type="range"] { flex: 1 1 auto; width: auto; min-width: 0; }
.row .mono { min-width: 36px; text-align: right; }
.row span.mono { flex: none; min-width: 40px; white-space: nowrap; }
.hint { margin: 0; font-size: 11px; color: var(--text-3); }

.preview-box {
  display: grid; place-items: center; height: 120px; border-radius: 8px; overflow: hidden;
  background: conic-gradient(var(--checker-a) 25%, var(--checker-b) 0 50%, var(--checker-a) 0 75%, var(--checker-b) 0) 0 0 / 16px 16px;
}
#preview { image-rendering: pixelated; max-width: 100%; max-height: 100%; }
/* Vorschau-Zoom: Mausrad zoomt, Ziehen verschiebt, Doppelklick = ganzes Bild */
#preview.zoomed { cursor: grab; }
.preview-box.dragging #preview.zoomed { cursor: grabbing; }
.pv-zoom { border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent-2); font: 700 11px var(--mono); padding: 2px 7px; border-radius: 999px; cursor: pointer; margin-right: 4px; }
.pv-zoom[hidden] { display: none; }
.pv-zoom:hover { background: var(--accent); color: #fff; }

.color-editor { display: flex; gap: 10px; align-items: center; }
#color-input { width: 46px; height: 46px; padding: 0; border: 0; border-radius: 10px; background: none; cursor: pointer; flex: none; }
#color-input::-webkit-color-swatch-wrapper { padding: 0; }
#color-input::-webkit-color-swatch { border: 1px solid var(--line-2); border-radius: 10px; }
.color-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.color-fields .row label { min-width: 62px; }
#hex-input { width: 100%; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel-2); user-select: text; }
#hex-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.recent { display: flex; gap: 4px; min-height: 18px; }
.recent button { width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--line-2); cursor: pointer; padding: 0; }

select {
  width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer;
}
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(22px, 1fr)); gap: 4px; }
.swatch {
  aspect-ratio: 1; border-radius: 5px; border: 0; padding: 0; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 0 0 1px rgba(0, 0, 0, .25);
  transition: transform .08s;
}
.swatch:hover { transform: scale(1.15); z-index: 1; }
.swatch.is-primary { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.swatch.is-secondary { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text-3); }

/* Seitenleiste: nur die Ebenen-Liste scrollt, nicht die ganze Leiste */
#panel-preview, #panel-palette { flex: none; }
#panel-layers { flex: 1 1 0; min-height: 150px; }
.layers { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-height: 40px; overflow-y: auto; }
.layer {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent;
}
.layer:hover { background: var(--panel-2); }
.layer.active { background: var(--accent-soft); border-color: var(--accent); }
.layer canvas { width: 30px !important; height: 30px !important; object-fit: contain; border-radius: 4px; image-rendering: pixelated; background: conic-gradient(var(--checker-a) 25%, var(--checker-b) 0 50%, var(--checker-a) 0 75%, var(--checker-b) 0) 0 0 / 8px 8px; flex: none; }
.layer .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer .name input { width: 100%; padding: 2px 4px; border-radius: 4px; border: 1px solid var(--accent); background: var(--panel-2); user-select: text; }
.layer .vis { width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; color: var(--text-2); border-radius: 5px; padding: 0; }
.layer .vis:hover { color: var(--text); background: var(--line); }
.layer.hidden-layer .name, .layer.hidden-layer canvas { opacity: .4; }
.layer .vis svg { width: 15px; height: 15px; }

/* ---------- Zeitleiste ---------- */
#timeline { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 96px 26px; background: var(--bg-2); border-top: 1px solid var(--line); }
.timeline-controls { display: flex; align-items: center; gap: 2px; padding: 0 10px; border-right: 1px solid var(--line); }
.frames { display: flex; align-items: center; gap: 8px; padding: 0 12px; overflow-x: auto; overflow-y: hidden; }
.frame {
  position: relative; flex: none; width: 72px; height: 72px; border-radius: 9px; cursor: pointer;
  border: 2px solid var(--line); overflow: hidden;
  background: conic-gradient(var(--checker-a) 25%, var(--checker-b) 0 50%, var(--checker-a) 0 75%, var(--checker-b) 0) 0 0 / 10px 10px;
  transition: border-color .12s;
}
.frame:hover { border-color: var(--line-2); }
.frame.active { border-color: var(--accent); box-shadow: 0 6px 18px rgba(124, 92, 255, .35); }
.frame { display: grid; place-items: center; }
.frame canvas { max-width: 100%; max-height: 100%; image-rendering: pixelated; display: block; }
.frame canvas.smooth, .layer canvas.smooth, #preview.smooth { image-rendering: auto; }
.frame .num { position: absolute; left: 4px; top: 3px; font: 600 10px var(--mono); padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, .6); color: #fff; }
.frame.drag-over { border-color: var(--ok); }
.frame-add {
  flex: none; width: 72px; height: 72px; border-radius: 9px; border: 2px dashed var(--line-2); background: none; cursor: pointer; color: var(--text-3);
  display: grid; place-items: center;
}
.frame-add:hover { border-color: var(--accent); color: var(--accent-2); }

#statusbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; padding: 0 14px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 12px; }
#status-msg { margin-left: auto; }

/* ---------- Dialog & Toast ---------- */
#modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(5, 6, 10, .55); backdrop-filter: blur(3px); animation: fade .15s; }
#modal-backdrop[hidden] { display: none; }
#modal { width: min(460px, calc(100vw - 32px)); max-height: 85vh; overflow: auto; padding: 22px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); animation: pop .15s ease-out; }
#modal h2 { margin: 0 0 14px; font-size: 18px; }
#modal-body { display: flex; flex-direction: column; gap: 12px; color: var(--text-2); }
#modal-body .field { display: flex; flex-direction: column; gap: 5px; }
#modal-body .field[hidden] { display: none; }
#modal-body .field-row { display: flex; gap: 12px; }
#modal-body .field-row > * { flex: 1; }
#modal-body input[type="number"], #modal-body input[type="text"], #modal-body select, #modal-body textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); user-select: text;
}
#modal-body input:focus, #modal-body textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
#modal-body textarea { resize: vertical; min-height: 64px; font: 600 14px var(--mono); color: var(--text); text-transform: uppercase; }
#modal-body .chips { display: flex; flex-wrap: wrap; gap: 6px; }
#modal-body .chip { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; font-size: 12px; }
#modal-body .chip:hover { border-color: var(--accent); color: var(--text); }
#modal-body table { border-collapse: collapse; width: 100%; font-size: 12px; }
#modal-body td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
#modal-body td:first-child { font-family: var(--mono); color: var(--text); white-space: nowrap; }
#modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }

#toast {
  position: fixed; left: 50%; bottom: 140px; transform: translate(-50%, 20px); z-index: 200;
  padding: 10px 16px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

#modal a { color: var(--accent-2); text-decoration: none; }
#modal a:hover { text-decoration: underline; }
#modal-body p { margin: 0; }
.panel-head h3 .count:not(:empty) { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); letter-spacing: 0; }
.palette-empty { grid-column: 1 / -1; padding: 10px 2px; }
.color-preview { width: 100%; height: 40px; border-radius: 8px; border: 1px solid var(--line-2); }
/* Farbe überall ersetzen */
.rc-row { display: flex; align-items: flex-start; gap: 12px; }
.rc-side { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rc-arrow { font-size: 22px; color: var(--text-3); padding-top: 34px; }
.rc-sw { height: 44px; border-radius: 10px; border: 1px solid var(--line-2); }
.rc-hexrow { display: flex; gap: 6px; align-items: center; }
#modal-body .rc-hexrow input[type="text"] { flex: 1; min-width: 0; font-size: 13px; padding: 6px 8px; }
#modal-body .rc-hexrow input.bad { outline: 2px solid #ff3250; border-color: transparent; }
.rc-pick { position: relative; overflow: hidden; flex: none; }
.rc-pick input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.rc-colors { display: flex; flex-wrap: wrap; gap: 5px; max-height: 120px; overflow: auto; padding: 2px; }
.rc-c { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line-2); cursor: pointer; padding: 0; }
.rc-c:hover { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.rc-c.active { outline: 2px solid var(--accent); outline-offset: 2px; }
#modal-body input[type="color"] { width: 100%; height: 40px; padding: 0; border: 1px solid var(--line-2); border-radius: 8px; background: none; cursor: pointer; }

/* Nur in der Windows-App */
body:not(.is-desktop) .desktop-only { display: none; }

/* Update-Hinweis unten rechts */
#update-banner {
  /* unten rechts über der Zeitleiste – verdeckt weder Zeichenfläche noch Ebenen */
  position: fixed; right: 16px; bottom: 34px; z-index: 150; width: min(470px, calc(100vw - 32px)); max-height: 90px;
  display: flex; flex-wrap: nowrap; gap: 12px; align-items: center; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 14px;
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft); animation: pop .2s ease-out;
}
#update-banner[hidden] { display: none; }
.ub-icon { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: #fff; }
.ub-icon svg { width: 18px; height: 18px; }
.ub-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ub-body b { font-size: 14px; }
.ub-body span { color: var(--text-2); font-size: 12px; }
.ub-progress { height: 6px; margin-top: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.ub-progress div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.ub-body { flex: 1; }
.ub-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }
.ub-actions:empty { display: none; }
.ub-actions .btn { height: 30px; padding: 0 12px; font-size: 12px; justify-content: center; }

/* Palettenauswahl mit Knöpfen */
.pal-row { display: flex; gap: 4px; align-items: center; }
.pal-row select { flex: 1; min-width: 0; }
optgroup { font-style: normal; color: var(--text-3); }
optgroup option { color: var(--text); }
.gb-uirow { flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: 13px; color: var(--text-2); }
.gb-uihex { display: inline-flex; align-items: center; gap: 4px; }
.gb-uihex .gb-sw { width: 14px; height: 14px; border-radius: 3px; }
.gb-uihex input { width: 66px; padding: 3px 5px; font: 12px ui-monospace, Consolas, monospace; background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; }
.gb-uihex input:focus { outline: none; border-color: var(--accent); }
.gb-uirow .btn { padding: 3px 10px; font-size: 12px; }
.gb-map { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; color: var(--text-3); }
.gb-map.diff { color: #ff6b81; }
#modal-body .gb-uihex input[type="text"] { width: 78px; padding: 3px 6px; font: 12px ui-monospace, Consolas, monospace; }

/* GB-Studio-Prüfung – Dialog (seit 1.5.10) */
#modal.wide { width: min(560px, calc(100vw - 32px)); }
.gbx { display: flex; flex-direction: column; gap: 14px; }
.gbx-status { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel-2); }
.gbx-status.ok { border-color: rgba(61, 220, 132, .45); background: linear-gradient(135deg, rgba(61, 220, 132, .16), rgba(61, 220, 132, .04)); }
.gbx-status.warn { border-color: rgba(255, 50, 80, .5); background: linear-gradient(135deg, rgba(255, 50, 80, .18), rgba(255, 50, 80, .04)); }
.gbx-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 800 20px var(--font); background: var(--line-2); color: var(--text); flex: none; }
.gbx-status.ok .gbx-icon { background: #3ddc84; color: #0b2417; box-shadow: 0 0 0 5px rgba(61, 220, 132, .18); }
.gbx-status.warn .gbx-icon { background: #ff3250; color: #fff; box-shadow: 0 0 0 5px rgba(255, 50, 80, .18); }
.gbx-head { font-size: 16px; font-weight: 700; color: var(--text); }
.gbx-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.gbx-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gbx-stat { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); }
.gbx-stat-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.gbx-stat-value { font: 700 22px var(--font); color: var(--text); margin: 2px 0 6px; }
.gbx-stat-value span { font-size: 14px; font-weight: 600; color: var(--text-3); }
.gbx-stat.warn .gbx-stat-value { color: #ff6b81; }
.gbx-stat-note { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.gbx-bar { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; }
.gbx-bar i { display: block; height: 100%; border-radius: 4px; background: #3ddc84; }
.gbx-stat.warn .gbx-bar i { background: #ff3250; }
.gbx-section { display: flex; flex-direction: column; gap: 8px; }
.gbx-title { display: flex; align-items: baseline; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.gbx-title.warn { color: #ff6b81; }
.gbx-title .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
.gbx-pals { display: flex; flex-direction: column; gap: 4px; }
.gbx-pal { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 9px; border: 1px solid transparent; }
.gbx-pal:hover { background: var(--panel-2); }
.gbx-pal.bad { border-color: rgba(255, 50, 80, .5); background: rgba(255, 50, 80, .08); }
.gbx-pal.close { border-color: rgba(61, 220, 132, .4); }
.gbx-use { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gbx-use .gbx-bar { flex: 1; height: 5px; }
.gbx-use .gbx-bar i { background: var(--accent); }
.gbx-pal.bad .gbx-use .gbx-bar i { background: #ff3250; }
.gbx-n { font-size: 12px; color: var(--text-3); white-space: nowrap; min-width: 74px; text-align: right; }
.gbx-pal.bad .gbx-n { color: #ff6b81; }
.gbx-map { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 0 2px 34px; font-size: 12px; color: #ff6b81; }
.gbx-map.ok { color: #3ddc84; }
.gbx-map .gb-map { gap: 3px; margin: 0; padding: 2px 6px; border-radius: 6px; background: var(--bg-2); }
.gbx-map .gb-map b { font-weight: 400; color: var(--text-3); }
.gbx-map .gb-map.diff { outline: 1px solid #ff3250; }
.gbx-map .gb-sw { width: 14px; height: 14px; border-radius: 3px; }
.gbx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gbx-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); font: 12px ui-monospace, Consolas, monospace; color: var(--text-2); }
.gbx-chip .gb-sw { width: 18px; height: 18px; border-radius: 4px; }
.gbx-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.gbx-note p { margin: 0; line-height: 1.45; }
.gbx-note > span { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font: 800 11px var(--font); flex: none; margin-top: 1px; }
.gbx-note.issue { background: rgba(255, 50, 80, .1); color: #ffb3bf; }
.gbx-note.issue > span { background: #ff3250; color: #fff; }
.gbx-note.tip { background: rgba(61, 220, 132, .1); color: #b6f0cf; }
.gbx-note.tip > span { background: #3ddc84; color: #0b2417; }
.gbx-ui { padding-top: 12px; border-top: 1px solid var(--line); }
.gbx-uifields { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.gbx-uifields .gb-uihex { gap: 0; position: relative; }
.gbx-uifields .gb-uihex .gb-sw { position: absolute; left: 7px; width: 14px; height: 14px; border-radius: 4px; pointer-events: none; }
#modal-body .gbx-uifields .gb-uihex input[type="text"] { width: 104px; padding: 6px 8px 6px 28px; font: 12px ui-monospace, Consolas, monospace; }
.gbx-uifields .gb-uireset { padding: 5px 10px; font-size: 14px; }
.gbx-info summary { cursor: pointer; font-size: 12px; color: var(--text-3); list-style: none; }
.gbx-info summary::before { content: 'ⓘ '; }
.gbx-info summary:hover { color: var(--text-2); }
.gbx-info p { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: var(--text-3); }
:root[data-theme="light"] .gbx-note.issue { color: #a3122c; }
:root[data-theme="light"] .gbx-note.tip { color: #11633a; }
.gbx-note .gbx-apply { margin-left: auto; flex: none; padding: 5px 12px; font-size: 12px; align-self: center; }
.gbx-note.tip .gbx-apply { border-color: rgba(61, 220, 132, .6); }
.gbx-note.tip .gbx-apply:hover { background: rgba(61, 220, 132, .18); }
.gbx-note.issue .gbx-apply { border-color: rgba(255, 50, 80, .6); }
.gbx-note.issue .gbx-apply:hover { background: rgba(255, 50, 80, .18); }
.gbx-arrow { font-weight: 400; color: var(--text-3); margin: 0 -2px; }
