/* ===== Design-Tokens: Dunkel (Standard) & Hell ===== */
:root, [data-theme="dark"] {
  --bg: #131314;
  --flaeche: #1e1f20;
  --flaeche-2: #282a2c;
  --flaeche-3: #333537;
  --rand: #3c4043;
  --text: #e3e3e3;
  --text-2: #c4c7c5;
  --text-leise: #8e918f;
  --akzent: #a8c7fa;
  --akzent-stark: #4f8cff;
  --verlauf: linear-gradient(90deg, #4f8cff, #9b72f2 55%, #e86aa6);
  --nutzer-blase: #282a2c;
  --code-bg: #0f1011;
  --gefahr: #f28b82;
  --erfolg: #81c995;
  --warnung: #fdd663;
  --schatten: 0 8px 28px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #ffffff;
  --flaeche: #f0f4f9;
  --flaeche-2: #e9eef6;
  --flaeche-3: #dde3ea;
  --rand: #c7cdd4;
  --text: #1f1f1f;
  --text-2: #444746;
  --text-leise: #6b6f72;
  --akzent: #0b57d0;
  --akzent-stark: #0b57d0;
  --nutzer-blase: #e9eef6;
  --code-bg: #f4f6f9;
  --gefahr: #b3261e;
  --erfolg: #146c2e;
  --warnung: #8a5a00;
  --schatten: 0 8px 24px rgba(30, 40, 60, .14);
  color-scheme: light;
}
:root {
  --radius: 16px;
  --radius-klein: 10px;
  --schrift: "Google Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sidebar-breite: 288px;
  --inhalt-breite: 780px;
  --safe-oben: env(safe-area-inset-top, 0px);
  --safe-unten: env(safe-area-inset-bottom, 0px);
  --safe-links: env(safe-area-inset-left, 0px);
  --safe-rechts: env(safe-area-inset-right, 0px);
}

/* ===== Grundlagen ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--schrift);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--akzent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; border-radius: 8px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ===== Bausteine ===== */
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-2); transition: background .15s;
}
.icon-btn:hover { background: var(--flaeche-2); }
.icon-btn.klein { width: 32px; height: 32px; }
.icon-btn.klein svg { width: 18px; height: 18px; }
.text-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--akzent);
  padding: 6px 8px; border-radius: 8px; font-size: 14px;
}
.text-btn:hover { background: var(--flaeche-2); }
.text-btn svg { width: 16px; height: 16px; }
.primaer {
  border: 0; border-radius: 999px; padding: 11px 22px; background: var(--akzent-stark); color: #fff;
  font-weight: 600; transition: filter .15s;
}
.primaer:hover:not(:disabled) { filter: brightness(1.1); }
.sekundaer {
  border: 1px solid var(--rand); border-radius: 999px; padding: 8px 16px; background: transparent; color: var(--text);
}
.sekundaer:hover { background: var(--flaeche-2); }
.gefahr-btn { color: var(--gefahr); }
input[type="text"], input[type="password"], input[type="number"], input:not([type]), select, textarea {
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius-klein);
  padding: 10px 12px; font-size: 16px; /* 16px verhindert Auto-Zoom in iOS */
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--akzent); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  background: var(--flaeche-2); color: var(--text-2); font-size: 12px; white-space: nowrap;
}
.verlauf-text { background: var(--verlauf); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ===== Schalter ===== */
.schalter { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.schalter input { opacity: 0; width: 0; height: 0; position: absolute; }
.schalter span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--flaeche-3); transition: background .2s;
}
.schalter span::after {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%;
  background: var(--text-2); transition: transform .2s, background .2s;
}
.schalter input:checked + span { background: var(--akzent-stark); }
.schalter input:checked + span::after { transform: translateX(16px); background: #fff; }
.schalter input:disabled + span { opacity: .4; }

/* ===== Toasts ===== */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(110px + var(--safe-unten));
  display: grid; gap: 8px; z-index: 100; width: min(92vw, 440px);
}
.toast {
  background: var(--flaeche-3); color: var(--text); padding: 12px 16px; border-radius: 12px;
  box-shadow: var(--schatten); font-size: 14px; animation: rein .2s ease-out;
}
.toast.fehler { border-left: 4px solid var(--gefahr); }
.toast.erfolg { border-left: 4px solid var(--erfolg); }
@keyframes rein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
