/* Platinen-Layouter – gemeinsame Gestaltung.
   Tokens (hell/dunkel), gemeinsame Klassen, Layout der Container.
   Modul-eigenes CSS hängen die Module selbst per PL.css() an. */

:root {
  color-scheme: light dark;
  --bg: #eef1f0;
  --flaeche: #ffffff;
  --flaeche2: #f3f5f4;
  --text: #1c2422;
  --gedimmt: #63706c;
  --linie: #d3dad7;
  --akzent: #1d7f4c;
  --akzent-text: #ffffff;
  --gefahr: #c0392b;
  --ok: #2e8b57;
  --kupfer: #c8792f;
  --radius: 6px;
  --schatten: 0 6px 24px rgba(20, 35, 30, .16);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917;
    --flaeche: #1d2421;
    --flaeche2: #262f2b;
    --text: #e6ece9;
    --gedimmt: #93a09b;
    --linie: #36423d;
    --akzent: #3fae72;
    --akzent-text: #08140e;
    --gefahr: #e5604f;
    --ok: #4cbb80;
    --kupfer: #e3a660;
    --schatten: 0 8px 28px rgba(0, 0, 0, .55);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

h1, h2, h3, h4, p { margin: 0; }

a { color: var(--akzent); }

:focus-visible {
  outline: 2px solid var(--akzent);
  outline-offset: 1px;
}

/* ------------------------------------------------------------------
   Layout der Container
   ------------------------------------------------------------------ */
#pl-kopf {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 46px;
  padding: 6px 12px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
  position: relative;
  z-index: 10;
}

#pl-haupt {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#pl-schritt1 {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 20px 16px 32px;
}

#pl-schritt2 {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 280px;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

#pl-palette,
#pl-eigenschaften {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--flaeche);
  padding: 10px;
}

#pl-palette { border-right: 1px solid var(--linie); }
#pl-eigenschaften { border-left: 1px solid var(--linie); }

#pl-buehne {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

#pl-svg {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

@media (max-width: 900px) {
  #pl-schritt2 { grid-template-columns: 200px minmax(0, 1fr) 220px; }
}

@media (max-width: 640px) {
  #pl-schritt2 {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 30%) minmax(0, 1fr) minmax(0, 30%);
  }
  #pl-palette { border-right: 0; border-bottom: 1px solid var(--linie); }
  #pl-eigenschaften { border-left: 0; border-top: 1px solid var(--linie); }
}

/* ------------------------------------------------------------------
   Dialog (modal, zentriert) und Toast (unten mittig)
   Der Inhalt (Fenster, Kopf, Fuß) wird von core.js gestaltet.
   ------------------------------------------------------------------ */
#pl-dialog {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .45);
}

#pl-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 90vw;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   Gemeinsame Klassen
   ------------------------------------------------------------------ */
.pl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--flaeche2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color .12s, border-color .12s;
}

.pl-btn:hover { border-color: var(--gedimmt); }
.pl-btn:active { transform: translateY(1px); }

.pl-btn.primaer {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--akzent-text);
  font-weight: 600;
}

.pl-btn.primaer:hover { filter: brightness(1.08); border-color: var(--akzent); }

.pl-btn.gefahr {
  background: transparent;
  border-color: var(--gefahr);
  color: var(--gefahr);
}

.pl-btn.gefahr:hover { background: var(--gefahr); color: #fff; }

.pl-btn.klein {
  min-height: 26px;
  padding: 2px 8px;
  font-size: 12.5px;
}

.pl-btn.aktiv {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--akzent-text);
}

.pl-btn[disabled],
.pl-btn.primaer[disabled],
.pl-btn.gefahr[disabled] {
  opacity: .45;
  cursor: not-allowed;
  filter: none;
  transform: none;
  pointer-events: none;
}

.pl-feld {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--gedimmt);
}

.pl-feld input,
.pl-feld select,
.pl-feld textarea {
  width: 100%;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--text);
  font-size: 14px;
}

.pl-feld input[type="checkbox"],
.pl-feld input[type="radio"] {
  width: auto;
  min-height: 0;
  padding: 0;
  accent-color: var(--akzent);
}

.pl-feld input[type="color"] {
  padding: 2px;
  height: 32px;
}

.pl-feld input[type="range"] {
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--akzent);
}

.pl-feld input:focus,
.pl-feld select:focus,
.pl-feld textarea:focus {
  outline: none;
  border-color: var(--akzent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--akzent) 30%, transparent);
}

.pl-feld input[disabled],
.pl-feld select[disabled],
.pl-feld textarea[disabled] {
  opacity: .55;
  cursor: not-allowed;
}

.pl-reihe {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pl-reihe > .pl-feld { flex: 1 1 0; }

.pl-karte {
  display: block;
  padding: 12px;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--text);
  text-align: left;
}

button.pl-karte,
a.pl-karte,
.pl-karte[role="button"],
.pl-karte[tabindex] {
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}

button.pl-karte:hover,
a.pl-karte:hover,
.pl-karte[role="button"]:hover,
.pl-karte[tabindex]:hover {
  border-color: var(--gedimmt);
}

.pl-karte.aktiv {
  border-color: var(--akzent);
  box-shadow: 0 0 0 2px var(--akzent);
}

.pl-titel {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gedimmt);
}

.pl-hinweis {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--gedimmt);
}

.pl-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pl-liste > li,
.pl-liste > div,
.pl-liste > button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.pl-liste > li:hover,
.pl-liste > div:hover,
.pl-liste > button:hover {
  background: var(--flaeche2);
}

.pl-liste > .aktiv {
  background: var(--flaeche2);
  border-color: var(--akzent);
}

.pl-trenner {
  height: 0;
  margin: 12px 0;
  border: 0;
  border-top: 1px solid var(--linie);
}

/* senkrechter Trenner in einer Zeile (z. B. Werkzeugleiste) */
.pl-reihe > .pl-trenner,
#pl-kopf > .pl-trenner {
  align-self: stretch;
  width: 0;
  height: auto;
  min-height: 20px;
  margin: 2px 4px;
  border-top: 0;
  border-left: 1px solid var(--linie);
}

.pl-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border: 1px solid var(--linie);
  border-radius: 999px;
  background: var(--flaeche2);
  color: var(--gedimmt);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

/* ------------------------------------------------------------------
   Hinweiskasten, falls der Start scheitert (index.html)
   ------------------------------------------------------------------ */
.pl-startfehler {
  position: fixed;
  left: 50%;
  top: 60px;
  transform: translateX(-50%);
  z-index: 2000;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 90px);
  overflow: auto;
  padding: 14px 16px;
  border: 1px solid var(--gefahr);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--text);
  box-shadow: var(--schatten);
}

.pl-startfehler strong { display: block; color: var(--gefahr); }
.pl-startfehler ul { margin: 8px 0; padding-left: 20px; }
.pl-startfehler li { overflow-wrap: anywhere; }
.pl-startfehler .pl-btn { margin-top: 10px; }

/* Schmale, unauffällige Rollbalken in den Seitenleisten */
#pl-palette, #pl-eigenschaften, #pl-schritt1 {
  scrollbar-width: thin;
  scrollbar-color: var(--linie) transparent;
}

/* ------------------------------------------------------------------
   Druck: nur das Element mit der Klasse .pl-ex-druck ist sichtbar
   ------------------------------------------------------------------ */
.pl-ex-druck { display: none; }

@media print {
  html, body {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: #fff;
    color: #000;
  }
  body > *:not(.pl-ex-druck) { display: none !important; }
  body > .pl-ex-druck { display: block !important; }
  #pl-dialog, #pl-toast, .pl-startfehler { display: none !important; }
}
