:root {
  --bg: #0f161d;
  --panel: #121a23;
  --accent: #42d6c7;
  --accent-soft: rgba(66,214,199,0.18);
  --text: #e5f7ff;
  --muted: #94a8bd;
  --danger: #ff8677;
  --radius: 6px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
#topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: #0b1015;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.btn {
  background: rgba(66,214,199,0.12);
  border: 1px solid rgba(66,214,199,0.18);
  border-radius: 4px;
  color: var(--text);
  padding: 4px 10px;
  cursor: pointer;
  font-weight: 500;
}
.btn.primary {
  background: var(--accent);
  color: #001b12;
  border-color: rgba(0,0,0,0);
}
#statusBar {
  min-width: 220px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
#layout {
  display: grid;
  /* nur noch 2 Spalten: links (Tiles) + Mitte (Map) */
  grid-template-columns: 480px 1fr;
  height: calc(100vh - 42px);
}
#left {
  background: var(--panel);
  padding: 10px;
  overflow-y: auto;
}
#main {
  position: relative;
  background: #05090e;
}
#left h2 {
  margin-top: 0;
  font-size: 14px;
}

/* Map-Liste ------------------------------------------------- */
#mapList {
  list-style: none;
  margin: 0 0 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#mapList li {
  background: #0a1017;
  border: 1px solid rgba(255,255,255,0.015);
  border-radius: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 6px;
  cursor: pointer;
}
#mapList li.active {
  outline: 2px solid var(--accent);
}
#mapList canvas {
  width: 46px;
  height: 46px;
  background: #394451;
  border-radius: 3px;
}

/* Tilepalette ----------------------------------------------- */
#tilePalette {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  max-height: 640px;
  overflow-y: auto;
}
.tile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  margin: 0;
  background: #0c1218;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.02);
  cursor: pointer;
}
.tile-btn img {
  display: block;
  image-rendering: pixelated;
  max-width: 64px;
  max-height: 64px;
}
.tile-btn span {
  display: none;
}
.tile-btn.active {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}
.tile-btn:hover {
  border-color: var(--accent-soft);
}

/* Canvas & Layerbar ---------------------------------------- */
#layerbar {
  background: #0d131a;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  padding: 4px 12px 6px;
  display: flex;
  flex-direction: column;   /* Zeilen untereinander */
  gap: 4px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#canvasWrap {
  position: relative;
  width: 100%;
  height: calc(100% - 36px);
  overflow: auto;
}
#canvasWrap canvas {
  position: absolute;
  top: 0;
  left: 0;
  image-rendering: pixelated;
}

/* Sonstiges ------------------------------------------------ */
.sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.04);
}
#selectedTileBox img {
  width: 64px;
  height: 64px;
  background: #000;
  image-rendering: pixelated;
  margin-bottom: 4px;
}
.debug {
  background: #0a1015;
  border: 1px solid rgba(255,255,255,0.02);
  border-radius: 4px;
  padding: 6px;
  font-size: 11px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
}
.hint {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}


/* === TEIL 8: Minimap & Selection-Overlay ======================= */

#minimapPanel {
  position: absolute;
  top: 54px; /* unter der Toolbar */
  right: 10px;
  width: 220px;
  background: var(--panel);
  border-radius: 6px;
  padding: 6px;
  box-shadow: 0 0 12px rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.06);
  z-index: 20;
}

#minimapPanel .panel-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
  margin-bottom: 4px;
}

#globalMinimap {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border-radius: 3px;
  background: #020308;
}

/* Selection-Overlay auf dem Canvas */
#selectionOverlay {
  pointer-events: none; /* wird vom Selection-Tool bei Bedarf aktiviert */
}

.selection-rect {
  outline: 1px dashed rgba(255,255,255,0.7);
}

.canvas-selection-active #selectionOverlay {
  pointer-events: auto;
}

/* Hover/Active-Feedback für Buttons, Tiles & Maps */

.btn,
#mapList li,
.tile-btn {
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, background 0.08s ease-out;
}

.btn:hover,
#mapList li:hover,
.tile-btn:hover {
  box-shadow: 0 0 0 1px rgba(0,255,255,0.4);
  transform: translateY(-1px);
}

.btn:active,
#mapList li:active,
.tile-btn:active {
  transform: translateY(0);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5), 0 0 6px rgba(0,0,0,0.9);
}

/* Map-Liste optisch anklickbar machen */
#mapList li {
  cursor: pointer;
}

/* Kleinere Scrollbar im Map-List & Tile-Palette-Panel */
#mapList,
#tilePalette {
  scrollbar-width: thin;
}


/* === TEIL 11: Theme-Switcher (A/B/C) ======================= */

body.theme-a {
  /* Standard – nutzt die :root Werte, optional kleine Anpassungen */
}

body.theme-b {
  --bg: #050811;
  --panel: #070c16;
  --accent: #4fd2ff;
  --accent-soft: rgba(79,210,255,0.22);
  --text: #e8f8ff;
  --muted: #8ca0c0;
}

body.theme-c {
  --bg: radial-gradient(circle at top, #1a2330 0%, #050811 55%, #020308 100%);
  --panel: rgba(5, 12, 24, 0.72);
  --accent: #ffb84f;
  --accent-soft: rgba(255,184,79,0.16);
  --text: #fff7e3;
  --muted: #b7aa90;
}

/* Theme-Select im Topbar */
.theme-label {
  font-size: 11px;
  opacity: 0.8;
  margin-right: 4px;
}

.theme-select {
  background: rgba(2,10,20,0.9);
  color: var(--text);
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.12);
  padding: 2px 6px;
  font-size: 11px;
  margin-right: 10px;
}


/* Layer Meta UI (Lock/Opacity/Names) */
.layer-row-visibility {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.layerRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
}
.layerRow .layerPrimary {
  flex: 1 1 auto;
}
.layerRow .layerName {
  cursor: pointer;
  user-select: none;
}
.layerRow .layerMini {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.layerRow .layerOpacity {
  width: 84px;
}
.layerRow.is-locked {
  opacity: 0.65;
  outline: 1px solid rgba(255,255,255,0.06);
}
.layerRow.is-locked .layerName {
  text-decoration: line-through;
}


/* Layer Order Buttons */
.layerOrderBtns {
  display: flex;
  gap: 4px;
}
.btn-mini {
  font-size: 10px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: inherit;
  cursor: pointer;
}
.btn-mini:hover {
  background: rgba(255,255,255,0.12);
}


/* Layer Dynamic Header */
.layerRowHeader {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
}
.layerHeaderTitle {
  font-weight: 600;
  margin-right: 8px;
  color: var(--text, inherit);
}


/* Layer Actions Row */
.layer-row-layeractions {
  padding: 2px 4px;
  background: rgba(255,255,255,0.03);
  border-radius: 4px;
}
.layerActionsWrap {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
}
.btn-layer-action {
  min-width: 72px;
}


/* Layer-Row Layout Refresh (Teil 40) */
.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 5px;
  background: radial-gradient(circle at 0 0, rgba(66,214,199,0.1), transparent 55%);
  border: 1px solid rgba(255,255,255,0.03);
}
.layer-row-main {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  background: linear-gradient(135deg, rgba(21,34,49,0.95), rgba(9,17,26,0.95));
  border: 1px solid rgba(66,214,199,0.35);
  box-shadow: 0 0 14px rgba(0,0,0,0.65);
}
.layer-row-layerinfo {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.layer-row-layerinfo strong {
  font-size: 12px;
  color: var(--accent);
}
.layer-row-layeractions {
  background: rgba(2,6,12,0.9);
  border: 1px solid rgba(66,214,199,0.25);
}
.layer-row-edit {
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 4px;
}
.layer-row-edit label {
  margin-right: 4px;
}
.layerActionsWrap .btn-layer-action {
  flex: 1 1 auto;
}
.layerRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 4px;
  margin-top: 2px;
  border-radius: 4px;
  background: rgba(3,8,14,0.95);
  border: 1px solid rgba(255,255,255,0.03);
}
.layerRow .layerPrimary {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.layerRow .layerMini {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--muted);
}
.layerRow .layerOpacity {
  flex: 0 0 60px;
}
.layerOrderBtns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.layerOrderBtns .btn-mini {
  padding: 0 4px;
  font-size: 10px;
}


/* Teil 41 – Layer Lock & Solo Visualisation */
.layerRow-locked {
  opacity: 0.55;
  filter: grayscale(0.25);
  background-image: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(0,0,0,0));
  border-color: rgba(255, 180, 120, 0.45);
}
.layerRow-locked .layerName::before {
  content: "\1F512  "; /* 🔒 */
  font-size: 11px;
  opacity: 0.9;
}
.layerRow-hidden {
  opacity: 0.55;
}
.layerRow[data-visible="false"] .layerName {
  text-decoration: line-through;
  opacity: 0.75;
}
.layerRow .layerShow {
  cursor: pointer;
}
.layerRow .layerShow:hover {
  box-shadow: 0 0 6px rgba(66,214,199,0.8);
}
.layerRow .layerShow::after {
  /* Nur visueller Hinweis im Titel (Tooltip übernimmt Text) */
}


/* TEIL 43 – Map-Info Panel neben Minimap */
#mapInfoPanel {
  position: absolute;
  right: 12px;
  top: 58px;
  width: 260px;
  background: linear-gradient(145deg, rgba(10,18,26,0.96), rgba(16,26,38,0.96));
  border-radius: 10px;
  padding: 8px 10px 10px;
  box-shadow: 0 0 18px rgba(0,0,0,0.7);
  border: 1px solid rgba(66,214,199,0.4);
  font-size: 11px;
}
#mapInfoPanel .panel-header {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
#mapInfoContent {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mapinfo-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.mapinfo-row .label {
  opacity: 0.7;
}
.mapinfo-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#mapInfoName {
  max-width: 140px;
}


/* TEIL 47 – Dev-HUD Panel unter Map-Info */
#devHudPanel {
  position: absolute;
  right: 12px;
  top: 190px;
  width: 260px;
  background: linear-gradient(145deg, rgba(8,14,22,0.96), rgba(14,24,36,0.96));
  border-radius: 10px;
  padding: 6px 10px 8px;
  box-shadow: 0 0 14px rgba(0,0,0,0.7);
  border: 1px solid rgba(120,180,255,0.3);
  font-size: 11px;
}
#devHudPanel .panel-header {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-soft, #8fd5ff);
  margin-bottom: 4px;
}
#devHudContent {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
