/* Kürbis & Kobolde — gemeinsame Styles für Overlay (OBS) und Einrichtung. */

:root {
  color-scheme: dark;
  --color-primary: #ff8a1f;
  --color-secondary: #5fcf6a;
  --color-text: #ffffff;
  --color-text-dim: rgba(255, 255, 255, 0.65);
  --color-bg-panel: rgba(22, 24, 22, 0.88);
  --color-success: #2ecc71;
  --color-warn: #f5b942;
  --color-danger: #ff4d6d;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-ui: 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* overflow: hidden absichtlich NICHT hier, sondern nur auf .overlay-body —
   sonst lässt sich die Einrichtung (gleiche CSS-Datei) nicht scrollen. */
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  color: var(--color-text);
}

/* ================= Overlay (OBS Browser-Quelle) ================= */

body.overlay-body {
  background: transparent;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

.layer-canvas, .kobold-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.kobold-layer { overflow: hidden; }
.layer-bg { z-index: 1; }
.layer-kb-back { z-index: 2; }
.pk-wrap { z-index: 3; }
.layer-kb-front { z-index: 4; }
.layer-fx { z-index: 5; }
.pk-bubble { z-index: 6; }

/* ---- Kürbis ---- */
.pk-wrap { position: fixed; pointer-events: none; }
.pk-inner {
  width: 100%;
  height: 100%;
  transform-origin: 50% 92%;
  animation: pk-breathe 4.8s ease-in-out infinite;
}
.pk-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .35));
}
.pk-inner.mirror .pk-svg { transform: scaleX(-1); }
@keyframes pk-breathe {
  0%, 100% { transform: scale(1, 1); }
  50%      { transform: scale(1.012, .992); }
}
.pk-wrap.laugh .pk-inner { animation: pk-laugh .18s linear infinite; }
@keyframes pk-laugh {
  0%   { transform: rotate(0) translateY(0); }
  25%  { transform: rotate(1.6deg) translateY(-1.2%); }
  50%  { transform: rotate(0) translateY(0); }
  75%  { transform: rotate(-1.6deg) translateY(-1.2%); }
  100% { transform: rotate(0) translateY(0); }
}
.pk-crown-g {
  transform-box: fill-box;
  transform-origin: 30% 100%;
  animation: pk-sway 6.5s ease-in-out infinite alternate;
}
@keyframes pk-sway {
  from { transform: rotate(-1.8deg); }
  to   { transform: rotate(2.2deg); }
}
.pk-drip {
  transform-box: fill-box;
  transform-origin: 50% 0;
  animation: pk-drip 4.4s ease-in-out infinite;
}
@keyframes pk-drip {
  0%, 100% { transform: scaleY(1); }
  55%      { transform: scaleY(1.28); }
  70%      { transform: scaleY(.92); }
}
.pk-drop {
  animation: pk-fall 6.2s ease-in infinite;
  opacity: 0;
}
@keyframes pk-fall {
  0%, 52% { transform: translateY(0); opacity: 0; }
  56%     { transform: translateY(4px); opacity: .9; }
  80%     { transform: translateY(120px); opacity: .7; }
  81%, 100% { transform: translateY(120px); opacity: 0; }
}
.pk-glow { mix-blend-mode: screen; }

/* ---- Kobolde ---- */
.kb { position: absolute; left: 0; top: 0; will-change: transform; }
.kb-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.kb-eyes {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: kb-blink 4.2s infinite;
}
@keyframes kb-blink {
  0%, 93%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(.1); }
}

/* ---- Sprechblase ---- */
.pk-bubble {
  position: fixed;
  width: max-content;
  max-width: 420px;
  padding: .55em .85em;
  background: #fff6e6;
  color: #3a1606;
  border: .12em solid #3a1606;
  border-radius: 1em;
  font-family: 'Comic Sans MS', 'Segoe Print', 'Chalkboard SE', cursive;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: 0 .2em .5em rgba(0, 0, 0, .35);
  opacity: 0;
  transform: scale(.4);
  transition: opacity .25s ease, transform .35s cubic-bezier(.2, 1.4, .4, 1);
  pointer-events: none;
}
.pk-bubble.from-left { transform-origin: 0 100%; }
.pk-bubble.from-right { transform-origin: 100% 100%; }
.pk-bubble.show { opacity: 1; transform: scale(1); }
.pk-bubble::after {
  content: '';
  position: absolute;
  bottom: -.52em;
  width: .9em;
  height: .9em;
  background: #fff6e6;
  border: .12em solid #3a1606;
  border-top: none;
  border-left: none;
}
.pk-bubble.from-left::after { left: 1.2em; transform: rotate(45deg); }
.pk-bubble.from-right::after { right: 1.2em; transform: rotate(45deg); }

/* ================= Einrichtung ================= */

body.dashboard-body {
  min-height: 100vh;
  background: radial-gradient(circle at top, #2b2a1c 0%, #0b0c0a 65%);
  padding: 24px;
}

.dashboard-shell { max-width: 1560px; margin: 0 auto; }
.dashboard-shell h1 { font-size: 26px; margin: 0 0 4px; }
.subtitle { color: var(--color-text-dim); margin: 0 0 20px; }

.statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  background: var(--color-bg-panel);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 18px;
  font-size: 13px;
}
.statusbar .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--color-danger);
  margin-right: 6px;
  vertical-align: -1px;
}
.statusbar .dot.ok { background: var(--color-success); }
.statusbar .dot.warn { background: var(--color-warn); }
.statusbar code { user-select: all; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
@media (min-width: 1200px) {
  .layout { grid-template-columns: minmax(460px, 1fr) minmax(0, 1.2fr); }
  .col-preview { position: sticky; top: 16px; }
}

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn { background: rgba(255, 255, 255, .06); color: var(--color-text-dim); }
.tab-btn.active { background: linear-gradient(90deg, var(--color-primary), var(--color-secondary)); color: #14101c; }

.card {
  background: var(--color-bg-panel);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 18px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; color: var(--color-primary); }
.card h3 { font-size: 14px; margin: 14px 0 8px; color: var(--color-secondary); }

.field-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 150px; }
.field label, .field .lbl { font-size: 12px; color: var(--color-text-dim); }
.field .lbl b { color: var(--color-text); font-weight: 600; }
.field input[type="text"],
.field textarea,
.field select {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--color-text);
  font-family: inherit;
  font-size: 14px;
}
.field textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
select option { background: #1a1c18; color: #fff; }
.field input[type="color"] {
  width: 100%; height: 36px;
  border: none; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; padding: 0;
}
.field input[type="range"] { width: 100%; accent-color: var(--color-primary); }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox label { font-size: 14px; color: var(--color-text); cursor: pointer; }
.field.checkbox input { width: 18px; height: 18px; accent-color: var(--color-primary); cursor: pointer; }

button {
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text);
  transition: transform .1s ease, opacity .2s ease, background .2s;
}
button:active { transform: scale(.97); }
button.secondary { background: rgba(255, 255, 255, .1); }
button.secondary:hover { background: rgba(255, 255, 255, .16); }
button.danger { background: rgba(255, 77, 109, .18); color: #ffb3c1; }
button.danger:hover { background: rgba(255, 77, 109, .3); }
button.small { padding: 6px 10px; font-size: 12px; }

.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 7px 8px; font-size: 13px; background: rgba(255, 255, 255, .07); color: var(--color-text-dim); }
.seg button.active { background: rgba(255, 138, 31, .3); color: #fff; }

.button-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.hint { font-size: 12px; color: var(--color-text-dim); margin: 6px 0 0; line-height: 1.5; }
.hint code, .card code { background: rgba(255, 255, 255, .08); padding: 1px 5px; border-radius: 4px; }
.save-status { font-size: 13px; margin-left: auto; }
.save-status.ok { color: var(--color-success); }
.save-status.err { color: var(--color-danger); }

/* Vorschau */
.preview-frame-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  background: repeating-conic-gradient(#1a1c19 0% 25%, #222520 0% 50%) 50% / 24px 24px;
  aspect-ratio: 16 / 9;
  position: relative;
}
.preview-frame-wrap.dark { background: #0d0d10; }
.preview-frame-wrap.light { background: #8a9aa8; }
.preview-frame-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 1920px; height: 1080px;
  border: none;
  transform-origin: 0 0;
  pointer-events: none;
  background: transparent;
}

.steps { margin: 0; padding-left: 20px; line-height: 1.8; font-size: 14px; }
.steps code { user-select: all; }
