:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: #0f172a;
  --panel-2: #111827;
  --line: rgba(148, 163, 184, 0.22);
  --line-strong: rgba(148, 163, 184, 0.42);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #60a5fa;
  --danger: #f87171;
  --success: #34d399;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body {
  background: radial-gradient(circle at top left, rgba(96,165,250,0.16), transparent 34%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select, .button-link, .button-label {
  font: inherit;
}

button, .button-link, .button-label {
  border: 1px solid var(--line-strong);
  background: rgba(30, 41, 59, 0.82);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:hover, .button-link:hover, .button-label:hover {
  border-color: rgba(96, 165, 250, 0.7);
  background: rgba(30, 64, 175, 0.34);
}

.button-label input { display: none; }

input, textarea, select {
  width: 100%;
  color: var(--text);
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  outline: none;
}

textarea { min-height: 90px; resize: vertical; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }

.studio-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.studio-topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 13, 22, 0.92);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
}

.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; font-weight: 800; }
h1 { font-size: 25px; margin: 2px 0 0; }
h2 { font-size: 15px; margin: 20px 0 10px; color: #f8fafc; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 8px 12px;
  background: rgba(15,23,42,0.8);
}

.studio-grid {
  display: grid;
  grid-template-columns: 310px minmax(620px, 1fr) 340px;
  gap: 16px;
  padding: 16px;
}

.studio-panel, .canvas-panel {
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.72);
  border-radius: 20px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.28);
}

.studio-panel { padding: 16px; align-self: start; position: sticky; top: 94px; max-height: calc(100vh - 110px); overflow: auto; }
.canvas-panel { padding: 16px; min-height: calc(100vh - 132px); }
.canvas-header { display: flex; justify-content: space-between; align-items: center; color: var(--muted); margin-bottom: 12px; }
.canvas-header strong { color: var(--text); }
.canvas-stage {
  min-height: 560px;
  overflow: auto;
  border: 1px solid rgba(148,163,184,0.18);
  border-radius: 18px;
  padding: 24px;
  background: repeating-linear-gradient(45deg, rgba(148,163,184,0.06) 0 12px, rgba(15,23,42,0.06) 12px 24px);
}

.toolbar-list, .scene-list, .link-list, .inspector-stack { display: grid; gap: 10px; }
.scene-module { display: grid; justify-items: start; text-align: left; padding: 12px; }
.scene-module small { color: var(--muted); margin-top: 4px; }
.scene-module.active { border-color: rgba(96,165,250,0.75); background: rgba(30,64,175,0.36); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint, .muted { color: var(--muted); }
.danger { border-color: rgba(248,113,113,0.46); color: #fecaca; }
.message { min-height: 22px; margin-top: 12px; color: var(--muted); }
.message[data-type="success"] { color: var(--success); }
.message[data-type="error"] { color: var(--danger); }

.overlay-canvas {
  position: relative;
  overflow: hidden;
  transform-origin: top left;
  box-shadow: 0 30px 90px rgba(0,0,0,0.34);
}
.safe-area {
  position: absolute;
  border: 1px dashed rgba(255,255,255,0.18);
  pointer-events: none;
  z-index: 9999;
}
.overlay-module { display: flex; flex-direction: column; justify-content: center; }
.overlay-module-text { justify-content: center; }
.text-module-text { line-height: 1.05; white-space: pre-wrap; }
.module-label { font-size: 0.28em; line-height: 1; color: rgba(226,232,240,0.72); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 0.32em; }
.counter-value, .timer-value { line-height: 0.95; }
.image-module-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-placeholder { width: 100%; height: 100%; display: grid; place-items: center; text-align: center; gap: 8px; color: inherit; }
.image-placeholder span { font-size: 0.36em; color: rgba(226,232,240,0.72); }

.runtime-body { background: transparent; overflow: hidden; }
.runtime-body #app { width: 100vw; height: 100vh; display: grid; place-items: center; }
.runtime-stage { width: 100vw; height: 100vh; display: grid; place-items: center; background: transparent; }
.runtime-stage .overlay-canvas { box-shadow: none; }
.runtime-module-only { width: 100vw; height: 100vh; display: grid; place-items: center; background: transparent; }
.runtime-module-only .overlay-module { box-shadow: none; }
.runtime-error, .boot-error {
  max-width: 720px;
  margin: 10vh auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(15,23,42,0.86);
  color: var(--text);
}

@media (max-width: 1180px) {
  .studio-grid { grid-template-columns: 1fr; }
  .studio-panel { position: static; max-height: none; }
  .studio-topbar { position: static; align-items: flex-start; flex-direction: column; }
}

.module-action-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.compact-stack { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.scene-module.hidden { opacity: 0.54; }
.scene-module.hidden span::after { content: ' · ausgeblendet'; color: var(--muted); font-weight: 400; }
.nudge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nudge-grid span { min-height: 1px; }
.overlay-module.is-selected { outline: 2px solid rgba(96,165,250,0.95); outline-offset: 3px; }
.overlay-module.is-hidden { display: none; }
.inspector-stack button { min-width: 0; }

/* 0.1.2 Editor-Bedienung: Canvas-Interaktion, Panels, Grid und Inline-Editing. */
.canvas-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    linear-gradient(rgba(148,163,184,0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,0.12) 1px, transparent 1px);
}
.overlay-canvas > .overlay-module { z-index: 2; }
.overlay-module.is-editor-module {
  cursor: grab;
  user-select: none;
}
.overlay-module.is-editor-module:active { cursor: grabbing; }
.overlay-module.is-editor-module.is-locked {
  cursor: not-allowed;
  opacity: 0.72;
}
.overlay-module [contenteditable="true"] {
  min-height: 1em;
  outline: none;
  cursor: text;
  user-select: text;
  border-radius: 8px;
}
.overlay-module.is-selected [contenteditable="true"]:focus {
  box-shadow: 0 0 0 2px rgba(96,165,250,0.32);
  background: rgba(96,165,250,0.10);
}
.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #60a5fa;
  border: 2px solid #020617;
  z-index: 10001;
}
.resize-nw { left: -8px; top: -8px; cursor: nwse-resize; }
.resize-ne { right: -8px; top: -8px; cursor: nesw-resize; }
.resize-sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.resize-se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.module-editor-badge {
  position: absolute;
  left: 8px;
  top: -24px;
  z-index: 10002;
  color: #bfdbfe;
  background: rgba(15,23,42,0.92);
  border: 1px solid rgba(96,165,250,0.46);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.overlay-module-panel {
  display: flex;
}
.panel-module-content {
  width: 100%;
  min-height: 100%;
  display: grid;
  gap: 0.35em;
  align-content: start;
}
.panel-module-title {
  font-size: 1em;
  line-height: 1.05;
  font-weight: inherit;
}
.panel-module-subtitle {
  font-size: 0.58em;
  line-height: 1.25;
  color: rgba(226,232,240,0.70);
  font-weight: 500;
}
.template-list button {
  justify-content: flex-start;
}

/* 0.1.3 Container-/Template-Basis: Panels können Kindmodule aufnehmen. */
.mini-note {
  font-size: 12px;
  margin: 6px 0 10px;
}
.compact-toolbar {
  grid-template-columns: 1fr 1fr;
}
.parent-note {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(96,165,250,0.28);
  border-radius: 12px;
  color: #bfdbfe;
  background: rgba(30,64,175,0.18);
  font-size: 12px;
}
.parent-note button {
  padding: 7px 9px;
  font-size: 12px;
}
.scene-module span {
  font-family: inherit;
}
.overlay-module-panel {
  position: absolute;
}
.panel-children {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.panel-children > .overlay-module {
  pointer-events: auto;
}
.overlay-module.is-child-module {
  box-shadow: none;
}
.overlay-module.is-child-module.is-selected {
  outline-color: rgba(52,211,153,0.95);
}
.overlay-module-progress {
  gap: 0.28em;
}
.progress-line {
  display: flex;
  align-items: baseline;
  gap: 0.26em;
  line-height: 1;
}
.progress-line strong {
  font-size: 1.1em;
}
.progress-line span {
  color: rgba(226,232,240,0.74);
  font-size: 0.46em;
}
.progress-track {
  width: 100%;
  height: 0.34em;
  min-height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148,163,184,0.22);
  margin-top: 0.22em;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(52,211,153,0.95), rgba(96,165,250,0.95));
}
.overlay-module-notification {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.65em;
}
.notification-icon {
  width: 2.15em;
  height: 2.15em;
  border-radius: 0.65em;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(96,165,250,0.18);
  border: 1px solid rgba(96,165,250,0.32);
  color: #bfdbfe;
  font-weight: 900;
}
.notification-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.notification-body {
  min-width: 0;
}
.notification-title {
  line-height: 1.02;
  font-weight: 850;
}
.notification-message {
  line-height: 1.22;
  margin-top: 0.18em;
  color: rgba(226,232,240,0.78);
  font-size: 0.58em;
}
.eventfeed-list {
  list-style: none;
  padding: 0;
  margin: 0.35em 0 0;
  display: grid;
  gap: 0.32em;
  font-size: 0.72em;
  line-height: 1.2;
}
.eventfeed-list li {
  padding: 0.28em 0.45em;
  border-radius: 0.45em;
  background: rgba(15,23,42,0.38);
  color: rgba(226,232,240,0.82);
}
