:root {
  --bg: #05070a;
  --panel: #0d1117;
  --panel-2: #161b22;
  --border: #21262d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #0084ff; /* primary blue */
  --accent-2: #00d2ff; /* cyan */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(15px);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 26px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 800; }
.brand small { color: var(--muted); }
.actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.2s;
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #0073e6; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Main layout */
main { display: flex; flex: 1; min-height: 0; }

#sidebar {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px;
}
.panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}
.panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 10px;
}

/* Key/Value-Listen */
.kvlist .kv, .bi-props .kv {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px dashed #2c313b;
}
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; word-break: break-word; }
.muted { color: var(--muted); }

/* Controls */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
select, input[type="range"] {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
}
.control-row select { width: auto; flex: 1; }
input[type="range"] { padding: 0; accent-color: var(--accent); margin: 6px 0; }
.layer-step { gap: 6px; }
.layer-step input[type="range"] { flex: 1; margin: 0; }
.layer-step .btn.small { padding: 4px 9px; line-height: 1; }
.checkbox { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; line-height: 1.3; }
.checkbox input { margin-top: 2px; }

/* Block-Info */
.bi-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.bi-props { margin-top: 8px; }
.be { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* Materialliste */
.matlist { max-height: 280px; overflow-y: auto; }
.mat {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px dashed #2c313b;
}
.mat span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Stage */
#stage { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #0f1115; }
#gl, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }
#stage.dragover { outline: 3px dashed var(--accent); outline-offset: -8px; }

.overlay-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
  color: var(--muted);
}
/* Wichtig: ohne diese Regel überschreibt das obige display:flex das hidden-Attribut,
   d. h. #empty / #loading liessen sich nie ausblenden. */
.overlay-msg[hidden] { display: none; }
.empty-card { text-align: center; }
.empty-card .big { font-size: 48px; }
.empty-card p { margin: 4px 0; }

.hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #cdd3df;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

/* Spinner */
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: 80vw;
  background: #2a2f3a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

/* Schmale Screens: Sidebar unter die Bühne */
@media (max-width: 760px) {
  main { flex-direction: column-reverse; }
  #sidebar { width: 100%; max-height: 45vh; border-right: none; border-top: 1px solid var(--border); }
  .hint { display: none; }
}

/* Touch: Browser-Gesten (Seiten-Scroll/-Zoom) über der Bühne unterdrücken */
#stage { touch-action: none; }

/* On-Screen-Bewegung – nur auf Touch-Geräten (Handy/iPad) einblenden */
.touch-controls { display: none; }
@media (pointer: coarse) {
  .touch-controls { display: flex; }
}
#touch-move {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  padding: 0 16px;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none; /* nur die Buttons fangen Eingaben */
  z-index: 6;
}
.tc-pad,
.tc-updown { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tc-row { display: flex; gap: 8px; }
.tc-btn {
  pointer-events: auto;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(30, 33, 40, 0.7);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.tc-btn:active { background: var(--accent); color: #fff; border-color: transparent; }

/* Hinweis bei zu kleinem / hochkant Bildschirm (Handy). iPads sind bewusst ausgenommen. */
#small-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(16, 18, 22, 0.97);
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ss-card {
  max-width: 340px;
  text-align: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 22px;
}
.ss-card .big { font-size: 44px; margin-bottom: 6px; }
.ss-card p { margin: 8px 0; }
@media (max-width: 600px), (max-height: 430px) {
  body:not(.dismiss-smallscreen) #small-screen { display: flex; }
}
