/* =====================================================================
   Equiplan – Stylesheet
   1. Schrift  2. Design-Tokens (hell/dunkel)  3. Basis  4. Layout
   5. Komponenten  6. Seiten  7. Bewegung  8. Equiplan-Module
   ===================================================================== */

/* 1. Schrift (lokal, SIL OFL – siehe fonts/OFL-IBMPlex.txt) */
@font-face {
  font-family: "Plex Sans";
  src: url("../fonts/IBMPlexSans-Var.woff2") format("woff2");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("../fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* 2. Design-Tokens */
:root {
  color-scheme: light;

  /* Farben – warmes Beige, Tinte, Akzent „Stallgrün“ */
  --c-bg: #f3f0e7;
  --c-surface: #faf8f2;
  --c-surface-2: #e9e5d8;
  --c-line: #d8d2c2;
  --c-line-strong: #bfb8a4;
  --c-text: #1d1c16;
  --c-text-muted: #67614f;
  --c-accent: #2f5233;
  --c-accent-hover: #234027;
  --c-accent-soft: #dde6d9;
  --c-on-accent: #ffffff;
  --c-ok: #2e7048;
  --c-ok-soft: #dcebdf;
  --c-warn: #8f5c00;
  --c-warn-soft: #f3e6c8;
  --c-danger: #a8261b;
  --c-danger-soft: #f6dcd8;
  --c-focus: #1f5fbf;
  --c-overlay: rgb(29 28 22 / 0.45);

  /* Typografie */
  --font-sans: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --fs-xs: 0.78rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.15rem;
  --fs-xl: 1.45rem;
  --fs-2xl: 1.9rem;
  --lh-tight: 1.2;
  --lh-body: 1.5;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* Abstände (4er-Raster) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;

  /* Form */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-1: 0 1px 2px rgb(29 27 23 / 0.06), 0 1px 1px rgb(29 27 23 / 0.04);
  --shadow-2: 0 6px 24px rgb(29 27 23 / 0.12), 0 2px 6px rgb(29 27 23 / 0.06);

  /* Maße */
  --touch: 44px;
  --rail-w: 220px;
  --bottom-nav-h: 64px;
  --content-max: 1080px;

  /* Bewegung */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 120ms;
  --dur-med: 220ms;
}

/* Dunkelmodus: Systemautomatik ODER manuelle Wahl (data-theme, siehe app.js) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --c-bg: #141713;
    --c-surface: #1c201b;
    --c-surface-2: #252a23;
    --c-line: #33382f;
    --c-line-strong: #4a5044;
    --c-text: #ecebe0;
    --c-text-muted: #a3a493;
    --c-accent: #8fbe8f;
    --c-accent-hover: #a7d1a5;
    --c-accent-soft: #22331f;
    --c-on-accent: #10160e;
    --c-ok: #6cc08d;
    --c-ok-soft: #1c3124;
    --c-warn: #e2ac4a;
    --c-warn-soft: #3a2d14;
    --c-danger: #f17d70;
    --c-danger-soft: #3d1c18;
    --c-focus: #7fb0ff;
    --c-overlay: rgb(0 0 0 / 0.6);
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 8px 28px rgb(0 0 0 / 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #141713;
  --c-surface: #1c201b;
  --c-surface-2: #252a23;
  --c-line: #33382f;
  --c-line-strong: #4a5044;
  --c-text: #ecebe0;
  --c-text-muted: #a3a493;
  --c-accent: #8fbe8f;
  --c-accent-hover: #a7d1a5;
  --c-accent-soft: #22331f;
  --c-on-accent: #10160e;
  --c-ok: #6cc08d;
  --c-ok-soft: #1c3124;
  --c-warn: #e2ac4a;
  --c-warn-soft: #3a2d14;
  --c-danger: #f17d70;
  --c-danger-soft: #3d1c18;
  --c-focus: #7fb0ff;
  --c-overlay: rgb(0 0 0 / 0.6);
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 8px 28px rgb(0 0 0 / 0.5);
}

/* 3. Basis */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: var(--lh-tight); font-weight: var(--fw-semibold); }
p { margin: 0; }
a { color: var(--c-accent); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--c-text-muted); }
.clamp-1 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack > * + * { margin-top: var(--sp-4); }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: -100px;
  z-index: 100;
  padding: var(--sp-2) var(--sp-3);
  background: var(--c-surface);
  border-radius: var(--radius-md);
}
.skip-link:focus { top: var(--sp-3); }

/* 4. Layout */
.main {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) calc(var(--bottom-nav-h) + var(--sp-6) + env(safe-area-inset-bottom));
}
.main:focus { outline: none; }
.is-bare .main { padding-bottom: var(--sp-7); }

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--c-text);
  text-decoration: none;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
}
.brand__mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: #2e2113;
  color: #d2a24a;
}
.brand__mark .icon { width: 18px; height: 18px; color: #d2a24a; }

/* Desktop: linke Leiste */
.rail { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--touch);
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--c-text-muted);
  text-decoration: none;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-item:hover { background: var(--c-surface-2); color: var(--c-text); }
.nav-item.is-active { color: var(--c-text); background: var(--c-surface-2); }
.nav-item.is-active .icon { color: var(--c-accent); }

/* Handy: Bottom-Navigation */
.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--c-surface);
  border-top: 1px solid var(--c-line);
}
.bottom-nav > *, .bottom-nav form { flex: 1; display: flex; }
.bottom-nav .nav-item {
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  border-radius: 0;
  font-size: var(--fs-xs);
  min-width: 0;
  padding: 0 2px;
}
.bottom-nav .nav-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bottom-nav .nav-item:hover { background: none; }
.bottom-nav .nav-item.is-active { background: none; }

@media (min-width: 900px) {
  .has-nav { padding-left: var(--rail-w); }
  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--rail-w);
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    padding: var(--sp-5) var(--sp-3);
    background: var(--c-surface);
    border-right: 1px solid var(--c-line);
  }
  .rail .brand { padding: 0 var(--sp-2); }
  .rail__nav { display: flex; flex-direction: column; gap: var(--sp-1); }
  .rail__foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-1); }
  .rail__user {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 0 var(--sp-3); min-height: var(--touch);
    color: var(--c-text-muted); font-size: var(--fs-sm);
  }
  .bottom-nav { display: none; }
  .main { padding: var(--sp-6) var(--sp-6) var(--sp-7); }
}

/* 5. Komponenten */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--touch);
  padding: 0 var(--sp-4);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  color: var(--c-text);
  font-weight: var(--fw-medium);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.btn:hover { background: var(--c-surface-2); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.btn--primary:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); }
.btn--block { width: 100%; }
.btn--icon { width: var(--touch); padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.is-busy { position: relative; color: transparent; pointer-events: none; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-color: var(--c-on-accent) var(--c-on-accent) transparent transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn:not(.btn--primary).is-busy::after { border-color: var(--c-text) var(--c-text) transparent transparent; }
.btn.is-done { background: var(--c-ok); border-color: var(--c-ok); color: var(--c-on-accent); }

/* Formulare */
.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.field + .field, .grid-2 + .field, .field + .grid-2 { margin-top: var(--sp-4); }
.field__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.field__hint { font-size: var(--fs-xs); color: var(--c-text-muted); }
.field__error {
  display: flex; align-items: flex-start; gap: var(--sp-1);
  font-size: var(--fs-sm); color: var(--c-danger);
}
.field__error .icon { width: 16px; height: 16px; margin-top: 2px; }
.input {
  width: 100%;
  min-height: var(--touch);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input:focus { outline: none; border-color: var(--c-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-focus) 25%, transparent); }
.input[disabled] { background: var(--c-surface-2); color: var(--c-text-muted); }
.has-error .input, .input[aria-invalid="true"] { border-color: var(--c-danger); }
.input-group { display: flex; gap: var(--sp-2); }
.input-group .input { flex: 1; }
.grid-2 { display: grid; gap: var(--sp-4); }
/* Im Raster regelt gap den Abstand, nicht der Feld-Abstand untereinander. */
.grid-2 > .field + .field, .shot-grid > .field + .field, .story-grid > .field + .field, .duration-grid > .field + .field,
.profile__grid > .field + .field { margin-top: 0; }
@media (min-width: 600px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Auswahl-Liste (Radio-Zeilen) */
.choice-list { display: flex; flex-direction: column; border: 1px solid var(--c-line); border-radius: var(--radius-md); overflow: hidden; }
.choice {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--touch); padding: var(--sp-2) var(--sp-3);
  background: var(--c-surface); cursor: pointer;
}
.choice + .choice { border-top: 1px solid var(--c-line); }
.choice:hover { background: var(--c-surface-2); }
.choice input { width: 20px; height: 20px; accent-color: var(--c-accent); margin: 0; }
.choice__main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.choice__meta { font-size: var(--fs-xs); color: var(--c-text-muted); }

/* Hinweise */
.notice {
  display: flex; gap: var(--sp-2); align-items: flex-start;
  padding: var(--sp-3); border-radius: var(--radius-md);
  font-size: var(--fs-sm); overflow-wrap: anywhere;
}
.notice--error { background: var(--c-danger-soft); color: var(--c-danger); }
.notice--ok { background: var(--c-ok-soft); color: var(--c-ok); }

.status { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.status .icon { width: 16px; height: 16px; }
.status--ok { background: var(--c-ok-soft); color: var(--c-ok); }
.status--warn { background: var(--c-warn-soft); color: var(--c-warn); }

/* Seitenkopf, Abschnitte, Listen */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.page-head__title { font-size: var(--fs-2xl); letter-spacing: -0.01em; }
.section + .section { margin-top: var(--sp-6); }
.section__title {
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-muted);
  margin-bottom: var(--sp-3);
}
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--c-line); }
.list__row {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 56px; padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--c-line);
}
.list__main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.facts { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--c-line); }
.facts > div { display: grid; grid-template-columns: 9rem 1fr; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-line); }
.facts dt { color: var(--c-text-muted); font-size: var(--fs-sm); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Leerer Zustand */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--sp-3); padding: var(--sp-7) var(--sp-4);
  border: 1px dashed var(--c-line-strong); border-radius: var(--radius-lg);
}
.empty__icon {
  display: grid; place-items: center; width: 56px; height: 56px;
  border-radius: 50%; background: var(--c-accent-soft); color: var(--c-accent);
}
.empty__icon .icon { width: 26px; height: 26px; }
.empty__title { font-size: var(--fs-lg); }
.empty__text { max-width: 38ch; color: var(--c-text-muted); }
.empty__hint { font-size: var(--fs-xs); color: var(--c-text-muted); }

/* Skeleton */
.skeleton {
  display: block; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--c-surface-2) 25%, var(--c-line) 50%, var(--c-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
.skeleton--line { height: 1em; margin: var(--sp-2) 0; }

/* Toasts */
.toasts {
  position: fixed; z-index: 60;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom-nav-h) + var(--sp-3) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--sp-2);
  width: min(92vw, 420px); pointer-events: none;
}
@media (min-width: 900px) { .toasts { bottom: var(--sp-5); left: calc(50% + var(--rail-w) / 2); } }
.is-bare .toasts { bottom: var(--sp-5); left: 50%; }
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-md);
  background: var(--c-text); color: var(--c-bg); box-shadow: var(--shadow-2);
  pointer-events: auto; animation: toast-in var(--dur-med) var(--ease);
}
.toast--error { background: var(--c-danger); color: #fff; }
.toast__text { flex: 1; font-size: var(--fs-sm); }
.toast .btn { min-height: 36px; background: transparent; color: inherit; border-color: currentColor; }

/* Netz-Hinweis */
.net-banner {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--c-warn-soft); color: var(--c-warn);
  font-size: var(--fs-sm); text-align: center;
}

/* Update-Hinweis (neue Version bereit) – fest oben, unter dem Netz-Banner */
.update-banner {
  position: sticky; top: 0; z-index: 49;
  display: flex; align-items: center; justify-content: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: var(--c-accent); color: var(--c-on-accent, #fff);
  font-size: var(--fs-sm);
}
.update-banner .btn--primary { background: var(--c-surface); color: var(--c-accent); border-color: transparent; }

/* Kopier-Fallback-Dialog */
.dialog {
  border: 0; padding: 0; border-radius: var(--radius-lg);
  width: min(94vw, 640px); background: var(--c-surface); color: var(--c-text);
  box-shadow: var(--shadow-2);
}
.dialog::backdrop { background: var(--c-overlay); }
.dialog__body { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.dialog textarea { width: 100%; min-height: 40vh; font-family: var(--font-mono); font-size: var(--fs-sm); }

/* Zentrierte Einzelseiten (Fehler) */
.center-panel {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--sp-3); max-width: 440px; margin: 12vh auto 0;
}
.center-panel__icon { color: var(--c-accent); }
.center-panel__icon .icon { width: 40px; height: 40px; }

/* 6. Seiten */

/* Login */
.auth { max-width: 380px; margin: 10vh auto 0; }
.auth__brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-semibold); margin-bottom: var(--sp-6); }
.auth__title { font-size: var(--fs-2xl); margin-bottom: var(--sp-5); }
.auth .btn--block { margin-top: var(--sp-5); }

/* Setup */
.setup { max-width: 680px; margin: 0 auto; }
.setup__head { margin-bottom: var(--sp-5); }
.setup__title { font-size: var(--fs-2xl); margin-bottom: var(--sp-2); }
.steps { list-style: none; margin: 0 0 var(--sp-5); padding: 0; display: flex; gap: var(--sp-2); }
.steps__item {
  flex: 1; display: flex; align-items: center; gap: var(--sp-2);
  padding-top: var(--sp-2); border-top: 3px solid var(--c-line);
  color: var(--c-text-muted); font-size: var(--fs-sm); min-width: 0;
}
.steps__num {
  display: inline-grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-surface-2); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
}
.steps__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps__item.is-current { border-color: var(--c-accent); color: var(--c-text); }
.steps__item.is-current .steps__num { background: var(--c-accent); color: var(--c-on-accent); }
.steps__item.is-done { border-color: var(--c-ok); color: var(--c-text); }
.steps__item.is-done .steps__num { background: var(--c-ok); color: var(--c-on-accent); }

.setup-step {
  margin: 0; padding: var(--sp-5) 0;
  border: 0; border-top: 1px solid var(--c-line);
  min-width: 0;
  transition: opacity var(--dur-med);
}
.setup-step[disabled] { opacity: 0.55; }
.setup-step__title { padding: 0; font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin-bottom: var(--sp-4); }
.setup-step__locked { font-size: var(--fs-sm); margin-bottom: var(--sp-3); }
.setup-step:not([disabled]) .setup-step__locked { display: none; }
.setup-step .notice { margin-top: var(--sp-4); }
.setup-step__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-top: var(--sp-5); }
.setup-step__result { font-size: var(--fs-sm); color: var(--c-ok); display: flex; align-items: center; gap: var(--sp-1); }
.setup-step__result .icon { width: 18px; height: 18px; }

/* Phase 2: Projekte, Elemente, Admin */

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.btn--small { min-height: 36px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn--small .icon { width: 18px; height: 18px; }
.btn--icon-only { padding: 0; width: 36px; }
@media (pointer: coarse) { .btn--small { min-height: var(--touch); } .btn--icon-only { width: var(--touch); } }
.btn--danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn--danger:hover { filter: brightness(1.08); background: var(--c-danger); }
.btn--danger-quiet { color: var(--c-danger); border-color: transparent; background: transparent; }
.btn--danger-quiet:hover { background: var(--c-danger-soft); }
label.btn { position: relative; }

.input--area { resize: vertical; min-height: 4.5rem; line-height: var(--lh-body); }
select.input { appearance: auto; }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--touch); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--c-accent); margin: 0; }
.notice--warn { background: var(--c-warn-soft); color: var(--c-warn); align-items: center; flex-wrap: wrap; }
.notice--warn > span { flex: 1; min-width: 12rem; }
.notice .icon { margin-top: 1px; }

.badge {
  display: inline-flex; align-items: center; padding: 0 var(--sp-2); height: 20px;
  border-radius: 999px; font-size: var(--fs-xs); font-weight: var(--fw-medium);
  background: var(--c-surface-2); color: var(--c-text-muted);
}
.badge--warn { background: var(--c-warn-soft); color: var(--c-warn); }
.badge--ok { background: var(--c-ok-soft); color: var(--c-ok); }

/* Kopf mit Rücksprung */
.page-head--stacked { flex-direction: column; align-items: stretch; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.page-head__row { display: flex; align-items: baseline; gap: var(--sp-3); min-width: 0; }
.page-head__row .page-head__title { min-width: 0; }
.back-link {
  display: inline-flex; align-items: center; gap: var(--sp-1); align-self: flex-start;
  min-height: 36px; margin-left: calc(-1 * var(--sp-1)); padding-right: var(--sp-2);
  color: var(--c-text-muted); text-decoration: none; font-size: var(--fs-sm);
}
.back-link:hover { color: var(--c-text); }
.back-link .icon { width: 18px; height: 18px; }

/* Tabs */
.tabs {
  display: flex; gap: var(--sp-1); margin: 0 calc(-1 * var(--sp-4)) var(--sp-5); padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--c-line); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  display: inline-flex; align-items: center; flex: none; min-height: var(--touch); padding: 0 var(--sp-3);
  color: var(--c-text-muted); text-decoration: none; font-weight: var(--fw-medium);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs__item:hover { color: var(--c-text); }
.tabs__item.is-active { color: var(--c-text); border-bottom-color: var(--c-accent); }
@media (min-width: 900px) { .tabs { margin-left: 0; margin-right: 0; padding: 0; } }

/* Linkliste */
.list--links .list__row--link {
  color: inherit; text-decoration: none; padding: var(--sp-3) var(--sp-2); margin: 0 calc(-1 * var(--sp-2));
  border-radius: var(--radius-md); border-bottom: 0; transition: background var(--dur-fast);
}
.list--links > li { border-bottom: 1px solid var(--c-line); }
.list--links .list__row--link:hover { background: var(--c-surface-2); }
.list__meta { font-size: var(--fs-sm); color: var(--c-text-muted); white-space: nowrap; }
.list__chev { color: var(--c-text-muted); }
@media (max-width: 599px) { .list__meta { display: none; } }

/* Werkzeugleiste über Listen */
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.toolbar__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
@media (max-width: 599px) {
  .toolbar__actions { width: 100%; }
  .toolbar__actions .btn--primary { order: -1; flex: 1 1 100%; }
  .toolbar__actions .btn:not(.btn--primary) { flex: 1; }
}

/* Kacheln (Desktop: Raster mit Bild, Handy: Liste) */
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); grid-template-columns: minmax(0, 1fr); }
.tiles > li { min-width: 0; }
.tile {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2);
  border-radius: var(--radius-md); color: inherit; text-decoration: none;
  transition: background var(--dur-fast);
}
.tile:hover { background: var(--c-surface-2); }
.tile__media {
  flex: none; display: grid; place-items: center; width: 64px; height: 64px; overflow: hidden;
  border-radius: var(--radius-sm); background: var(--c-surface-2); color: var(--c-text-muted);
}
.tile__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile__placeholder { width: 26px; height: 26px; }
.tile__body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tile__title { font-weight: var(--fw-medium); }
.tile__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); min-width: 0; }
.tile__meta .mono, .shot__tags .tag, .ref__label, .scene__meta { overflow-wrap: anywhere; min-width: 0; }
.tile__meta .mono { max-width: 100%; }
@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-4); }
  .tile { flex-direction: column; align-items: stretch; padding: 0; gap: var(--sp-2); }
  .tile:hover { background: none; }
  .tile__media { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: var(--radius-md); transition: box-shadow var(--dur-fast); }
  .tile:hover .tile__media { box-shadow: 0 0 0 2px var(--c-accent); }
  .tile__body { padding: 0 var(--sp-1); }
}

/* Aktionsleiste der Detailseite */
.action-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.action-bar .save-status { margin-left: auto; }
@media (max-width: 599px) {
  .action-bar .btn--primary { flex: 1 1 100%; }
  .action-bar .btn:not(.btn--primary) { flex: 1; padding: 0 var(--sp-2); }
  .action-bar .save-status { flex: 1 1 100%; margin-left: 0; }
}

/* Speicherstatus */
.save-status { display: inline-flex; align-items: center; gap: var(--sp-1); min-height: 24px; font-size: var(--fs-sm); color: var(--c-text-muted); }
.save-status .icon { width: 16px; height: 16px; }
.save-status[data-state="saving"] .icon { animation: spin 0.8s linear infinite; }
.save-status[data-state="saved"] { color: var(--c-ok); }
.save-status[data-state="error"] { color: var(--c-danger); }
.editor__bar { display: flex; justify-content: flex-end; min-height: 24px; margin-bottom: var(--sp-2); }

/* Editor-Layout Element */
.element-layout { display: grid; gap: var(--sp-5); }
.element-layout__media { display: flex; flex-direction: column; gap: var(--sp-3); }
.usage-note { display: flex; gap: var(--sp-2); align-items: flex-start; font-size: var(--fs-sm); }
.usage-note .icon { width: 18px; height: 18px; margin-top: 2px; }
.editor > .notice { margin-bottom: var(--sp-4); }
@media (min-width: 900px) {
  .element-layout { grid-template-columns: minmax(260px, 340px) 1fr; align-items: start; }
  .element-layout__media { position: sticky; top: var(--sp-5); }
}

/* Bildfeld */
.drop { display: flex; flex-direction: column; gap: var(--sp-2); border-radius: var(--radius-lg); outline-offset: 4px; }
.drop__preview {
  position: relative; display: grid; place-items: center; overflow: hidden;
  aspect-ratio: 4 / 3; border-radius: var(--radius-md);
  border: 1.5px dashed var(--c-line-strong); background: var(--c-surface);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.drop.has-image .drop__preview { border-style: solid; border-color: var(--c-line); background: var(--c-surface-2); }
.drop__preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.drop.is-over .drop__preview { border-color: var(--c-accent); background: var(--c-accent-soft); }
.drop.is-uploading .drop__preview { opacity: 0.6; }
.drop__empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); padding: var(--sp-4); text-align: center; color: var(--c-text-muted); font-size: var(--fs-sm); }
.drop__empty .icon { width: 28px; height: 28px; }
.drop__hint { font-size: var(--fs-xs); }
@media (pointer: coarse) { .drop__hint { display: none; } }
.drop__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.drop__paste-target { width: 100%; min-height: var(--touch); border: 1.5px dashed var(--c-accent); border-radius: var(--radius-md); background: var(--c-accent-soft); padding: var(--sp-2); font-size: var(--fs-sm); }
.drop__status { font-size: var(--fs-sm); color: var(--c-text-muted); min-height: 1.2em; }
.drop__status.is-error { color: var(--c-danger); }
.drop--sm .drop__preview { aspect-ratio: 1 / 1; }

/* Abschnitte mit Kopfzeile */
.section__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.section__head .section__title { margin-bottom: 0; }
.section__intro { margin-bottom: var(--sp-4); font-size: var(--fs-sm); max-width: 60ch; }
.variants { margin-top: var(--sp-7); }

/* Varianten */
.variant-list, .profile-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--c-line); }
.variant { display: grid; gap: var(--sp-4); padding: var(--sp-4) 0; border-bottom: 1px solid var(--c-line); }
.variant__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-3); }
@media (min-width: 700px) { .variant { grid-template-columns: 180px 1fr; align-items: start; } }

/* Modellprofile */
.profile { padding: var(--sp-4) 0; border-bottom: 1px solid var(--c-line); }
.profile__grid { display: grid; gap: var(--sp-4); align-items: end; }
.profile__grid + .field { margin-top: var(--sp-4); }
@media (min-width: 700px) { .profile__grid { grid-template-columns: 2fr 1fr 1fr auto; } }

/* Gefahrenbereich */
.danger-zone { margin-top: var(--sp-7); padding-top: var(--sp-5); border-top: 1px solid var(--c-line); }
.danger-zone p { margin-bottom: var(--sp-3); max-width: 60ch; }

/* Dialoge */
.dialog__title { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.dialog__text { color: var(--c-text-muted); overflow-wrap: anywhere; }
.dialog__actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.dialog__list { margin: 0; padding-left: 1.2em; max-height: 50vh; overflow: auto; color: var(--c-danger); overflow-wrap: anywhere; }
.dialog__list li + li { margin-top: var(--sp-1); }
.dialog__copy { min-height: 40vh; font-family: var(--font-mono); font-size: var(--fs-sm); }
.dialog { max-height: 90dvh; }
.dialog__body { max-height: 90dvh; overflow: auto; }

/* Import-Vorschau */
.import-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; border-top: 1px solid var(--c-line); }
.import-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-line); }
.import-row__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 14rem; overflow-wrap: anywhere; }
.import-row__meta { font-size: var(--fs-xs); color: var(--c-text-muted); }
.import-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.seg { display: inline-flex; border: 1px solid var(--c-line-strong); border-radius: var(--radius-md); overflow: hidden; padding: 0; margin: 0; }
.seg__opt { position: relative; display: inline-flex; }
.seg__opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg__opt span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.seg__opt + .seg__opt span { border-left: 1px solid var(--c-line-strong); }
.seg__opt input:checked + span { background: var(--c-accent); color: var(--c-on-accent); }
.seg__opt input:focus-visible + span { outline: 2px solid var(--c-focus); outline-offset: -2px; }
@media (pointer: coarse) { .seg__opt span { min-height: var(--touch); } }

/* Phase 3: Folgen, Stepper, Story, Prompt, JSON-Import */

.episode-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--c-line); }
.episode-list > li { border-bottom: 1px solid var(--c-line); }
.episode-row {
  display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2) var(--sp-3); align-items: center;
  padding: var(--sp-3) var(--sp-2); margin: 0 calc(-1 * var(--sp-2)); border-radius: var(--radius-md);
  color: inherit; text-decoration: none; transition: background var(--dur-fast);
}
.episode-row:hover { background: var(--c-surface-2); }
.episode-row__code { font-size: var(--fs-lg); color: var(--c-accent); align-self: start; padding-top: 2px; }
.episode-row__main { display: flex; flex-direction: column; min-width: 0; }
.episode-row__state { grid-column: 2; display: flex; flex-direction: column; gap: var(--sp-1); }
.episode-row__step { font-size: var(--fs-xs); color: var(--c-text-muted); }
@media (min-width: 700px) {
  .episode-row { grid-template-columns: auto 1fr 240px; }
  .episode-row__state { grid-column: auto; }
}

/* Statusbalken (Breiten über Klassen, CSP erlaubt keine Inline-Styles) */
.statusbar { display: flex; align-items: center; gap: var(--sp-2); }
.statusbar__track { flex: 1; display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--c-surface-2); }
.statusbar__seg { height: 100%; }
.statusbar__seg--offen { background: var(--c-line-strong); }
.statusbar__seg--kulisse_ok { background: var(--c-warn); }
.statusbar__seg--bild_ok { background: var(--c-focus); }
.statusbar__seg--video_ok { background: var(--c-ok); }
.statusbar__label { font-size: var(--fs-xs); color: var(--c-text-muted); white-space: nowrap; }
.statusbar--empty .statusbar__label { font-style: italic; }
.w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; } .w-25 { width: 25%; }
.w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; } .w-50 { width: 50%; }
.w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; } .w-75 { width: 75%; }
.w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }

/* Stepper */
.stepper { margin: 0 calc(-1 * var(--sp-4)) var(--sp-5); padding: 0 var(--sp-4); overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--c-line); }
.stepper::-webkit-scrollbar { display: none; }
.stepper__list { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--sp-1); }
.stepper__item { flex: none; }
.stepper__link {
  display: flex; align-items: center; gap: var(--sp-2); min-height: 56px; padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-1);
  color: var(--c-text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.stepper__link:hover { color: var(--c-text); }
.stepper__num {
  display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--c-surface-2); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
}
.stepper__num .icon { width: 14px; height: 14px; }
.stepper__text { display: flex; flex-direction: column; line-height: 1.25; }
.stepper__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; }
.stepper__progress { font-size: var(--fs-xs); white-space: nowrap; color: var(--c-text-muted); }
.stepper__item.is-done .stepper__num { background: var(--c-ok-soft); color: var(--c-ok); }
.stepper__item.is-current .stepper__link { color: var(--c-text); border-bottom-color: var(--c-accent); }
.stepper__item.is-current .stepper__num { background: var(--c-accent); color: var(--c-on-accent); }
@media (max-width: 899px) {
  .stepper__item:not(.is-current) .stepper__progress { display: none; }
}
@media (min-width: 900px) {
  .stepper { margin-left: 0; margin-right: 0; padding: 0; overflow: visible; }
  /* Alle 7 Schritte passen nebeneinander; Texte dürfen umbrechen. */
  .stepper__list { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .stepper__link { align-items: flex-start; padding-right: var(--sp-2); }
  .stepper__label, .stepper__progress { white-space: normal; overflow-wrap: anywhere; }
}

.step { min-height: 40vh; }
.step-nav { display: flex; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-7); padding-top: var(--sp-4); border-top: 1px solid var(--c-line); }
.step-nav .btn { max-width: 48%; }
.step-nav .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Schritt 1 */
.story-grid { display: grid; grid-template-columns: 7rem 1fr; gap: var(--sp-4); }
.story-grid + .field { margin-top: var(--sp-4); }
.story-count { margin-top: var(--sp-1); }
.story-form .section, .story-form + .section { margin-top: var(--sp-6); }
.scene__loc { display: inline-flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; min-width: 0; }
.duration-grid { display: grid; gap: var(--sp-4); }
@media (min-width: 700px) { .duration-grid { grid-template-columns: 1fr 1fr 2fr; } }
.estimate { margin-top: var(--sp-4); font-size: var(--fs-md); }
.estimate strong { color: var(--c-accent); }
[data-shot-warning] { margin-top: var(--sp-3); }
.participants { display: grid; gap: var(--sp-5); }
@media (min-width: 700px) { .participants { grid-template-columns: 1fr 1fr; } }
.participants__group { border: 0; padding: 0; margin: 0; min-width: 0; }
.participants__legend { font-weight: var(--fw-semibold); margin-bottom: var(--sp-2); padding: 0; }
.check--row { display: flex; width: 100%; padding: var(--sp-1) 0; border-bottom: 1px solid var(--c-line); }
.check--row > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.check--strong { margin: var(--sp-4) 0 0; padding: var(--sp-3); border: 1px solid var(--c-warn); border-radius: var(--radius-md); background: var(--c-warn-soft); }

/* Schritt 2 */
.prompt-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.prompt-meta { font-size: var(--fs-xs); margin-top: var(--sp-1); }
.btn--large { min-height: 52px; padding: 0 var(--sp-5); font-size: var(--fs-lg); }
@media (max-width: 599px) { .prompt-head .btn--large { width: 100%; } }
.prompt-preview {
  margin: 0; padding: var(--sp-4); max-height: 65vh; overflow: auto;
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.prompt-foot { font-size: var(--fs-xs); margin-top: var(--sp-2); }
.notice--list { margin-bottom: var(--sp-4); }
.notice--list ul { margin: var(--sp-1) 0; padding-left: 1.1em; }
.notice + .prompt-preview, .notice + .notice { margin-top: var(--sp-3); }

/* Schritt 3 */
.input--code { font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.5; min-height: 14rem; }
.import > .muted { margin-bottom: var(--sp-4); max-width: 70ch; }
.import__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.import__result { margin-top: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.import__result:empty { display: none; }
.check-box { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-md); }
.check-box ul { margin: var(--sp-2) 0 0; padding-left: 1.1em; max-height: 40vh; overflow: auto; overflow-wrap: anywhere; }
.check-box li + li { margin-top: 2px; }
.check-box__title { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); }
.check-box--error { background: var(--c-danger-soft); color: var(--c-danger); }
.check-box--warn { background: var(--c-warn-soft); color: var(--c-warn); }
.check-ok { display: flex; align-items: center; gap: var(--sp-2); color: var(--c-ok); font-weight: var(--fw-medium); }
.diff__chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.chip { display: inline-flex; align-items: center; gap: var(--sp-1); padding: var(--sp-1) var(--sp-3); border-radius: 999px; font-size: var(--fs-sm); background: var(--c-surface-2); }
.chip--new { background: var(--c-ok-soft); color: var(--c-ok); }
.chip--changed { background: var(--c-warn-soft); color: var(--c-warn); }
.chip--removed { background: var(--c-danger-soft); color: var(--c-danger); }
.diff__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--c-line); max-height: 45vh; overflow: auto; }
.diff__row { display: grid; grid-template-columns: 6rem 1fr; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--c-line); font-size: var(--fs-sm); }
.diff__row::before { content: none; }
.diff__row--new .mono { color: var(--c-ok); }
.diff__row--changed .mono { color: var(--c-warn); }
.diff__row--removed .mono { color: var(--c-danger); }
.diff__same { font-size: var(--fs-sm); margin-top: var(--sp-2); overflow-wrap: anywhere; }

/* Phase 4: Szenen & Shots, Bilder */

.text-warn { color: var(--c-warn); }
.badge--info { background: color-mix(in srgb, var(--c-focus) 16%, transparent); color: var(--c-focus); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.step-intro { margin-bottom: var(--sp-5); max-width: 70ch; }

.board__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.board__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.seg--view { display: none; }
@media (min-width: 900px) { .seg--view { display: inline-flex; } }
.seg__btn { min-height: 36px; padding: 0 var(--sp-3); border: 0; background: var(--c-surface); font-size: var(--fs-sm); cursor: pointer; }
.seg__btn + .seg__btn { border-left: 1px solid var(--c-line-strong); }
.seg__btn.is-active { background: var(--c-accent); color: var(--c-on-accent); }

/* Szene */
.scene { margin-bottom: var(--sp-6); }
.scene__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding-bottom: var(--sp-2); border-bottom: 2px solid var(--c-text); }
.scene__headtext { min-width: 0; }
.scene__title { font-size: var(--fs-lg); display: flex; align-items: center; gap: var(--sp-2); overflow-wrap: anywhere; }
.scene__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); font-size: var(--fs-sm); margin-top: 2px; }
.scene__meta .icon { width: 16px; height: 16px; }
.scene__meta .text-warn { display: inline-flex; align-items: center; gap: var(--sp-1); }
.scene__editor { padding: var(--sp-4) 0; border-bottom: 1px solid var(--c-line); }
.scene__add { margin-top: var(--sp-3); }

/* Shot-Liste */
.shot-list { list-style: none; margin: 0; padding: 0; min-height: 12px; }
.shot { border-bottom: 1px solid var(--c-line); background: var(--c-bg); }
.shot.is-dragging { opacity: 0.45; }
.shot.is-open { background: var(--c-surface); }
.shot__row { display: flex; align-items: stretch; gap: var(--sp-1); }
.shot__grip { display: none; align-items: center; padding: 0 var(--sp-1); color: var(--c-text-muted); cursor: grab; }
@media (pointer: fine) { .shot__grip { display: flex; } }
.shot__toggle {
  flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-1); border: 0; background: none; text-align: left; cursor: pointer; color: inherit;
}
.shot__toggle:hover .shot__uid { text-decoration: underline; }
.shot__nr {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--c-surface-2); font-weight: var(--fw-semibold); font-size: var(--fs-sm);
}
.shot__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.shot__line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); font-size: var(--fs-sm); }
.shot__uid { font-weight: var(--fw-medium); color: var(--c-text); }
.shot__dur { font-variant-numeric: tabular-nums; }
.shot__cam { max-width: 14rem; }
.shot__text { font-size: var(--fs-md); }
.shot__tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 0 var(--sp-2); height: 22px; border-radius: var(--radius-sm); background: var(--c-surface-2); font-size: var(--fs-xs); }
.tag .icon { width: 14px; height: 14px; }
.tag--warn { background: var(--c-warn-soft); color: var(--c-warn); }
.shot__move { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: var(--sp-1) 0; }
@media (pointer: coarse) { .shot__move { flex-direction: row; align-items: center; } }
.shot__editor { padding: var(--sp-2) var(--sp-3) var(--sp-5) calc(28px + var(--sp-4)); }
@media (max-width: 599px) { .shot__editor { padding-left: var(--sp-1); padding-right: var(--sp-1); } }
.shot-grid { display: grid; gap: var(--sp-3) var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); }
.shot-grid + .field { margin-top: var(--sp-4); }
.shot__part { margin-top: var(--sp-5); }
.shot__part-title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); margin-bottom: var(--sp-2); }
.shot__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-5); padding-top: var(--sp-3); border-top: 1px dashed var(--c-line); }
.shot-chars, .dialog-lines { list-style: none; margin: 0 0 var(--sp-2); padding: 0; }
.shot-char, .dialog-line { padding: var(--sp-2) 0; border-bottom: 1px solid var(--c-line); }
.shot-char__form, .dialog-line__form { display: grid; gap: var(--sp-2) var(--sp-3); align-items: end; grid-template-columns: 1fr auto; }
.shot-char__form .field + .field, .dialog-line__form .field + .field { margin-top: 0; }
.shot-char__name { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .shot-char__form { grid-template-columns: 9rem 13rem 1fr 1.4fr auto; }
  .shot-char__name { grid-column: auto; align-self: center; overflow-wrap: anywhere; }
  .dialog-line__form { grid-template-columns: 11rem 10rem 1fr auto; align-items: start; }
}
.inline-add { display: flex; gap: var(--sp-2); max-width: 32rem; }
.inline-add .input { flex: 1; }
.prop-checks { display: flex; flex-wrap: wrap; gap: 0 var(--sp-4); }

/* Verwaiste Shots */
.orphans { margin-top: var(--sp-7); padding: var(--sp-4); border: 1px dashed var(--c-warn); border-radius: var(--radius-md); }
.orphans .scene__title { color: var(--c-warn); margin-bottom: var(--sp-2); }
.orphan-list { list-style: none; margin: var(--sp-3) 0 0; padding: 0; }
.orphan { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-2) 0; border-top: 1px solid var(--c-line); font-size: var(--fs-sm); }
.orphan__text { flex: 1 1 12rem; min-width: 0; }

/* Raster (Desktop) */
.raster-scene { margin-bottom: var(--sp-6); }
.raster-scene .scene__title { margin-bottom: var(--sp-3); }
.raster { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-4); }
.raster__tile { display: flex; flex-direction: column; gap: var(--sp-1); }
.raster__media { display: grid; place-items: center; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius-sm); background: var(--c-surface-2); color: var(--c-text-muted); }
.raster__media img { width: 100%; height: 100%; object-fit: cover; }
.raster__meta { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); }
.raster__text { font-size: var(--fs-sm); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Schritt 5 */
.img-scene { margin-bottom: var(--sp-7); }
.img-scene__head { padding-bottom: var(--sp-2); border-bottom: 2px solid var(--c-text); margin-bottom: var(--sp-4); }
.img-set { display: grid; gap: var(--sp-4); padding-bottom: var(--sp-5); margin-bottom: var(--sp-2); border-bottom: 1px solid var(--c-line); }
.img-set__info { display: flex; flex-direction: column; gap: var(--sp-3); }
@media (min-width: 900px) { .img-set { grid-template-columns: 320px 1fr; } }
.drop--md .drop__preview { aspect-ratio: 16 / 9; }
.prompt-details summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; font-size: var(--fs-sm); color: var(--c-text-muted); }
.prompt-preview--small { max-height: 40vh; font-size: var(--fs-xs); }
.img-shot { padding: var(--sp-5) 0; border-bottom: 1px solid var(--c-line); }
.img-shot__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.img-shot__text { margin: var(--sp-1) 0 var(--sp-4); }
.img-shot__cols { display: grid; gap: var(--sp-5); }
@media (min-width: 900px) { .img-shot__cols { grid-template-columns: 1fr 1fr; } }
.img-shot__prompt { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.ref-list { list-style: none; margin: 0; padding: 0; }
.ref { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-1) 0; }
.ref__nr { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--c-surface-2); font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.ref__thumb { flex: none; width: 48px; height: 36px; display: grid; place-items: center; overflow: hidden; border-radius: var(--radius-sm); background: var(--c-surface-2); color: var(--c-warn); }
.ref__thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref__label { flex: 1; min-width: 0; font-size: var(--fs-sm); overflow-wrap: anywhere; display: flex; flex-direction: column; }
.ref__missing { font-size: var(--fs-xs); color: var(--c-warn); }
.takes { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-3); }
.take { display: flex; flex-direction: column; gap: var(--sp-1); border-radius: var(--radius-md); }
.take img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-sm); background: var(--c-surface-2); border: 2px solid transparent; }
.take.is-selected img { border-color: var(--c-ok); }
.take__bar { display: flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; }
.take__chosen { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--c-ok); font-weight: var(--fw-semibold); margin-right: auto; }
.take__chosen .icon { width: 16px; height: 16px; }
.take__bar .btn:first-child:not(.btn--icon-only) { margin-right: auto; }
.is-end { max-width: 220px; margin-bottom: var(--sp-2); }
.drop__preview--slim { aspect-ratio: auto; min-height: 88px; }
.endframe { margin-top: var(--sp-4); }
.endframe summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; font-weight: var(--fw-medium); font-size: var(--fs-sm); }
.dialog--wide { width: min(96vw, 960px); }
.frame-canvas { width: 100%; height: auto; max-height: 55vh; object-fit: contain; background: #000; border-radius: var(--radius-sm); }
.range { width: 100%; accent-color: var(--c-accent); min-height: var(--touch); }

/* Phase 5: Video, Export, Vorlagen, Druck */

.video-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.video-bar + .notice { margin-bottom: var(--sp-4); }
.video-shot { display: grid; gap: var(--sp-4); padding: var(--sp-4) 0; border-bottom: 1px solid var(--c-line); }
@media (min-width: 700px) { .video-shot { grid-template-columns: 220px 1fr; } }
.video-shot__thumb img, .video-shot__nothumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-sm); background: var(--c-surface-2); display: block; }
.video-shot__nothumb { display: grid; place-items: center; align-content: center; gap: var(--sp-1); color: var(--c-text-muted); font-size: var(--fs-sm); }
.video-shot__body { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.video-shot.is-done .video-shot__thumb img { outline: 3px solid var(--c-ok); outline-offset: -3px; }
.btn--toggle .icon { opacity: 0.35; }
.btn--toggle.is-on { background: var(--c-ok-soft); border-color: var(--c-ok); color: var(--c-ok); }
.btn--toggle.is-on .icon { opacity: 1; }

.export { display: flex; flex-direction: column; gap: var(--sp-5); }
.export__block { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-4); padding-bottom: var(--sp-5); border-bottom: 1px solid var(--c-line); }
.export__block > div { flex: 1 1 22rem; }
.export__title { font-size: var(--fs-lg); margin-bottom: var(--sp-1); }
@media (max-width: 599px) { .export__block .btn--large { width: 100%; } }

.tpl { border-top: 1px solid var(--c-line); }
.tpl:last-of-type { border-bottom: 1px solid var(--c-line); }
.tpl__summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); min-height: 52px; cursor: pointer; }
.tpl__name { font-weight: var(--fw-medium); }
.tpl__body { padding: var(--sp-2) 0 var(--sp-5); }
.tpl__body .notice { margin-top: var(--sp-3); }
.placeholders { margin: 0; display: grid; gap: 2px var(--sp-4); grid-template-columns: 1fr; font-size: var(--fs-sm); }
.placeholders > div { display: grid; grid-template-columns: minmax(12rem, auto) 1fr; gap: var(--sp-3); padding: 2px 0; }
.placeholders dd { margin: 0; color: var(--c-text-muted); }
@media (max-width: 599px) { .placeholders > div { grid-template-columns: 1fr; gap: 0; } }

/* Druckansicht */
.print-page .main { max-width: 1200px; }
.print-bar { display: flex; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.print-head { margin-bottom: var(--sp-5); }
.print-head h1 { font-size: var(--fs-2xl); }
.print-logline { margin-top: var(--sp-2); max-width: 70ch; }
.print-scene { margin-bottom: var(--sp-6); }
.print-scene h2 { font-size: var(--fs-lg); padding-bottom: var(--sp-1); border-bottom: 2px solid var(--c-text); margin-bottom: var(--sp-3); }
.print-scene__meta { font-weight: var(--fw-regular); color: var(--c-text-muted); font-size: var(--fs-sm); margin-left: var(--sp-2); }
.print-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); }
.print-tile { font-size: var(--fs-sm); break-inside: avoid; page-break-inside: avoid; }
.print-tile__img { aspect-ratio: 16 / 9; display: grid; place-items: center; background: var(--c-surface-2); border: 1px solid var(--c-line); overflow: hidden; margin-bottom: var(--sp-2); color: var(--c-text-muted); }
.print-tile__img img { width: 100%; height: 100%; object-fit: cover; }
.print-tile__head { margin-bottom: 2px; }
.print-tile__cam { color: var(--c-text-muted); font-size: var(--fs-xs); margin-bottom: var(--sp-1); }
.print-tile__text { margin-bottom: var(--sp-1); }
.print-tile__line { margin-top: 2px; }
.print-tile__sound { margin-top: var(--sp-1); font-style: italic; color: var(--c-text-muted); font-size: var(--fs-xs); }

@media print {
  @page { size: A4 landscape; margin: 12mm; }
  :root { color-scheme: light; --c-bg: #fff; --c-surface: #fff; --c-surface-2: #f1f1f1; --c-text: #111; --c-text-muted: #555; --c-line: #ccc; }
  body { background: #fff; color: #111; font-size: 10pt; }
  .no-print, .print-bar { display: none !important; }
  .print-grid { grid-template-columns: repeat(3, 1fr); gap: 6mm; }
  .print-scene { break-before: auto; }
  .print-scene h2 { break-after: avoid; }
  .print-tile__img { border-color: #bbb; }
}

/* 7. Bewegung */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .btn.is-busy::after { animation: none; border-color: currentColor; }
}

@media print {
  .rail, .bottom-nav, .toasts, .net-banner, .update-banner, .skip-link { display: none !important; }
  .has-nav { padding-left: 0; }
  .main { padding: 0; max-width: none; }
}

/* Projektliste: Zeile mit Einstellungs-Zahnrad neben dem Link */
.list__item--actions { display: flex; align-items: center; gap: var(--sp-2); }
.list__item--actions > .list__row--link { flex: 1; min-width: 0; margin-right: 0; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--c-text-muted); }
.btn--ghost:hover { background: var(--c-surface-2); color: var(--c-text); }
.dialog__actions--split { justify-content: space-between; flex-wrap: wrap; }
.dialog__actions--split > span { display: flex; gap: var(--sp-2); }
.dialog__link { display: inline-block; margin-top: var(--sp-2); font-size: var(--fs-sm); }

/* ===================== Mediathek ===================== */
.hint-box {
  margin: 0 0 var(--sp-4); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--c-line);
  border-radius: var(--radius-md); background: var(--c-surface); font-size: var(--fs-sm);
}
.hint-box > summary { cursor: pointer; display: flex; align-items: center; gap: var(--sp-2); min-height: 36px; font-weight: var(--fw-medium); }
.hint-box > p { margin: var(--sp-2) 0; }
.copy-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); overflow-wrap: anywhere; }
.copy-line > span { min-width: 0; padding: var(--sp-1) var(--sp-2); background: var(--c-surface-2); border-radius: var(--radius-sm); }

.upload-queue { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.upload-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-1) var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--c-line); border-radius: var(--radius-md); background: var(--c-surface);
}
.upload-row__bar { grid-column: 1 / -1; width: 100%; height: 6px; accent-color: var(--c-accent); }
.upload-row__state { font-size: var(--fs-sm); }
.upload-row__name { grid-column: 1; }
.upload-row > .btn { grid-column: 2; grid-row: 1; }
.upload-row__state { grid-column: 1 / -1; }
.upload-row.is-error { border-color: var(--c-danger); }
.upload-row.is-error .upload-row__state { color: var(--c-danger); }
.upload-row.is-done .upload-row__state { color: var(--c-ok); }

.dropzone-page { border-radius: var(--radius-lg); outline: 2px dashed transparent; outline-offset: 6px; transition: outline-color var(--dur-fast); min-height: 120px; }
.dropzone-page.is-drag { outline-color: var(--c-accent); background: var(--c-accent-soft); }

.media-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.media-grid > li { min-width: 0; }
.media-card {
  display: flex; flex-direction: column; width: 100%; padding: 0; text-align: left; font: inherit; color: inherit;
  background: none; border: 0; border-radius: var(--radius-md); cursor: pointer;
}
.media-card:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.media-card__media {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius-md); background: var(--c-surface-2); color: var(--c-text-muted);
}
.media-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card:hover .media-card__media { filter: brightness(0.96); }
.media-card__icon { width: 32px; height: 32px; }
.media-card__dur {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: var(--radius-sm);
  background: rgb(0 0 0 / 0.7); color: #fff; font-size: var(--fs-xs);
}
.media-card__body { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-2) 2px 0; min-width: 0; }
.media-card__title { font-weight: var(--fw-medium); }
.media-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); font-size: var(--fs-xs); }
.media-card.is-missing .media-card__media { opacity: 0.5; }
.media-player { display: block; width: 100%; max-height: 50vh; border-radius: var(--radius-md); background: #000; margin-bottom: var(--sp-3); }
.media-player--audio { background: none; }
img.media-player { object-fit: contain; }
.facts--compact > div { grid-template-columns: 6.5rem 1fr; padding: var(--sp-2) 0; font-size: var(--fs-sm); }
.facts--compact dd { margin: 0; overflow-wrap: anywhere; }
.input--color { padding: 4px; height: 44px; width: 6rem; }

/* ===================== Schnitt-Editor ===================== */
.is-editor .main { max-width: none; padding: var(--sp-2) var(--sp-3) calc(var(--bottom-nav-h) + var(--sp-3) + env(safe-area-inset-bottom)); }
.nle {
  display: grid; gap: var(--sp-2);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "bar" "viewer" "timeline" "side";
}
.nle__bar { grid-area: bar; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); min-width: 0; }
.nle__title { font-size: var(--fs-lg); margin: 0; min-width: 0; flex: 1 1 10rem; }
.nle__status { margin: 0; font-size: var(--fs-sm); }
.nle__status.is-error { color: var(--c-danger); }
.nle__bar-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.nle__viewer { grid-area: viewer; display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.nle__stage-wrap {
  display: flex; align-items: center; justify-content: center; min-width: 0;
  height: min(42vh, 56vw); background: #111; border-radius: var(--radius-md); overflow: hidden;
}
.nle__sizer { position: relative; overflow: hidden; flex: none; box-shadow: 0 0 0 1px rgb(255 255 255 / 0.08); }
.nle__stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
.nle-el { position: absolute; display: block; transform-origin: 50% 50%; }
.nle-el--media { object-fit: cover; }
.nle-el--text { white-space: pre-wrap; line-height: 1.2; overflow-wrap: anywhere; }
.nle-el--text.has-bg { background: var(--nle-text-bg); padding: 0.15em 0.4em; border-radius: 0.15em; box-decoration-break: clone; }
.nle__transport { display: flex; align-items: center; gap: var(--sp-2); }
.nle__time { font-size: var(--fs-md); }
.nle__dur { font-size: var(--fs-sm); }

.nle__side { grid-area: side; min-width: 0; border: 1px solid var(--c-line); border-radius: var(--radius-md); background: var(--c-surface); display: flex; flex-direction: column; }
.nle__tabs { display: flex; border-bottom: 1px solid var(--c-line); }
.nle__tab {
  flex: 1; min-height: 40px; border: 0; background: none; font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  color: var(--c-text-muted); cursor: pointer; border-bottom: 2px solid transparent;
}
.nle__tab.is-active { color: var(--c-text); border-bottom-color: var(--c-accent); }
.nle__panel { padding: var(--sp-3); overflow: auto; min-height: 0; }

.nle__timeline { grid-area: timeline; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.nle__tl-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); }
.nle__tl-add, .nle__tl-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); }
.nle__snap { min-height: 32px; font-size: var(--fs-sm); margin: 0 var(--sp-2); }
.nle__tl {
  position: relative; overflow: auto; min-height: 180px; height: 34vh;
  border: 1px solid var(--c-line); border-radius: var(--radius-md); background: var(--c-surface);
  overscroll-behavior: contain;
}
.nle-tl { position: relative; display: grid; align-content: start; min-height: 100%; }
.nle-tl__corner, .nle-tl__ruler { position: sticky; top: 0; z-index: 4; height: 28px; background: var(--c-surface-2); border-bottom: 1px solid var(--c-line); }
.nle-tl__corner { left: 0; z-index: 6; display: flex; align-items: center; padding: 0 var(--sp-2); font-size: var(--fs-xs); border-right: 1px solid var(--c-line); }
.nle-tl__ruler { cursor: col-resize; touch-action: none; }
.nle-tick { position: absolute; bottom: 0; height: 6px; border-left: 1px solid var(--c-line-strong); font-size: 10px; line-height: 1; color: var(--c-text-muted); padding-left: 3px; white-space: nowrap; }
.nle-tick.is-major { height: 100%; padding-top: 4px; }
.nle-tl__empty { grid-column: 1 / -1; padding: var(--sp-4); font-size: var(--fs-sm); }
.nle-head {
  position: sticky; left: 0; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 0 4px 0 2px;
  background: var(--c-surface); border-right: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line); min-width: 0;
}
.nle-head.is-selected { background: var(--c-accent-soft); }
.nle-head__name {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; height: 100%; padding: 0 4px; border: 0; background: none;
  font: inherit; font-size: var(--fs-sm); color: inherit; text-align: left; cursor: pointer;
}
.nle-head__name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nle-head__name .icon { flex: none; width: 15px; height: 15px; color: var(--c-text-muted); }
.nle-head__btns { display: flex; flex: none; }
.nle-head__btn {
  display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--c-text-muted); cursor: pointer;
}
.nle-head__btn .icon { width: 15px; height: 15px; }
.nle-head__btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.nle-head__btn.is-on { color: var(--c-accent); }
.nle-lane { position: relative; border-bottom: 1px solid var(--c-line); touch-action: pan-x pan-y; }
.nle-lane.is-dim { background: repeating-linear-gradient(135deg, transparent 0 8px, var(--c-surface-2) 8px 9px); }
.nle-lane.is-drop { background: var(--c-accent-soft); }
.nle-clip {
  position: absolute; top: 4px; bottom: 4px; min-width: 4px; overflow: hidden; display: flex; align-items: center;
  border-radius: 5px; border: 1px solid rgb(0 0 0 / 0.25); cursor: grab; touch-action: none; user-select: none;
  background-size: auto 100%; background-repeat: repeat-x; color: #fff; font-size: var(--fs-xs);
}
.nle-clip--video, .nle-clip--bild { background-color: #3f5f8f; }
.nle-clip--text { background-color: #8a5a1f; }
.nle-clip--audio { background-color: #2f6e55; background-image: repeating-linear-gradient(90deg, rgb(255 255 255 / 0.18) 0 2px, transparent 2px 5px); }
.nle-clip.is-missing { background-color: #7a2b22; background-image: none; }
.nle-clip.is-selected { outline: 2px solid var(--c-focus); outline-offset: 1px; z-index: 2; }
.nle-clip.is-dragging { cursor: grabbing; opacity: 0.85; z-index: 3; }
.nle-clip.is-locked { cursor: default; opacity: 0.75; }
.nle-clip__label {
  flex: 1; min-width: 0; padding: 0 8px; text-shadow: 0 1px 2px rgb(0 0 0 / 0.8); pointer-events: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}
.nle-clip__h { flex: none; width: 8px; height: 100%; cursor: ew-resize; background: rgb(255 255 255 / 0.12); }
.nle-clip__h:hover { background: rgb(255 255 255 / 0.4); }
.nle-clip.is-locked .nle-clip__h { cursor: default; }
.nle-playhead { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid var(--c-accent); z-index: 5; pointer-events: none; }
.nle-playhead > span { position: sticky; top: 0; display: block; width: 12px; height: 12px; margin-left: -7px; background: var(--c-accent); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.nle-tip { position: fixed; z-index: 100; padding: 2px 6px; border-radius: var(--radius-sm); background: var(--c-text); color: var(--c-bg); font-size: var(--fs-xs); pointer-events: none; }

.nle-media__head { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.nle-media__head .input { flex: 1; min-width: 0; }
.input--small { min-height: 34px; padding: 4px 8px; font-size: var(--fs-sm); }
.nle-media { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nle-media__item { display: flex; align-items: center; gap: var(--sp-2); padding: 4px; border-radius: var(--radius-sm); cursor: grab; }
.nle-media__item:hover { background: var(--c-surface-2); }
.nle-media__item.is-missing { opacity: 0.55; cursor: default; }
.nle-media__thumb {
  flex: none; display: grid; place-items: center; width: 56px; height: 32px; border-radius: 3px;
  background: var(--c-surface-2) center / cover no-repeat; color: var(--c-text-muted);
}
.nle-media__thumb .icon { width: 16px; height: 16px; }
.nle-media__body { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: var(--fs-sm); }
.nle-media__body .mono { font-size: var(--fs-xs); }
.nle-media__empty, .nle-hint { font-size: var(--fs-sm); margin: var(--sp-2) 0; }

.ins-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); min-width: 0; }
.ins { display: grid; gap: var(--sp-2); }
.ins .field { margin: 0; }
.ins__group { border: 0; border-top: 1px solid var(--c-line); margin: 0; padding: var(--sp-2) 0 0; display: grid; gap: var(--sp-2); min-width: 0; }
.ins__group > legend { padding: 0 var(--sp-1) 0 0; font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-muted); }
.field--inline { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); align-items: center; gap: var(--sp-2); }
.ins-num { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.ins-num .input { width: 100%; max-width: 8rem; }
.ins-range { width: 100%; accent-color: var(--c-accent); }
.ins .input--color { height: 34px; width: 4rem; }
.ins__checks { display: flex; flex-wrap: wrap; gap: 0 var(--sp-4); }
.ins__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--c-line); }
.ins__sub { font-size: var(--fs-sm); margin: var(--sp-4) 0 var(--sp-2); }
.nle-keys { margin: 0; padding-left: 1.1em; font-size: var(--fs-sm); display: grid; gap: 4px; }
kbd { font-family: var(--font-mono); font-size: 0.85em; padding: 1px 5px; border: 1px solid var(--c-line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--c-surface); }

@media (min-width: 1000px) {
  .nle {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "bar bar" "viewer side" "timeline timeline";
  }
  .nle__stage-wrap { height: 44vh; }
  .nle__side { height: calc(44vh + 48px); }
  .nle__tl { height: calc(100vh - 44vh - 210px); min-height: 200px; }
}
@media (min-width: 1000px) and (max-height: 760px) {
  .nle__stage-wrap { height: 36vh; }
  .nle__side { height: calc(36vh + 48px); }
  .nle__tl { height: calc(100vh - 36vh - 200px); }
}
.nle-clip--video .nle-clip__label, .nle-clip--bild .nle-clip__label { flex: 0 1 auto; margin-left: 2px; padding: 1px 6px; border-radius: 3px; background: rgb(0 0 0 / 0.55); }
@media (max-width: 599px) {
  .nle-head__btn { width: 22px; }
  .nle-head__name .icon { display: none; }
  .nle__tl-add .btn span, .nle__bar-actions .btn span { font-size: var(--fs-sm); }
}
.export-choice { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.export-opt { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); border: 1px solid var(--c-line); border-radius: var(--radius-md); cursor: pointer; }
.export-opt:has(input:checked) { border-color: var(--c-accent); background: var(--c-accent-soft); }
.export-opt:has(input:disabled) { opacity: 0.55; cursor: default; }
.export-opt input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--c-accent); flex: none; }
.export-opt > span { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); }
.render-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: var(--sp-4); background: var(--c-overlay); }
.render-box { width: min(640px, 100%); max-height: 100%; overflow: auto; padding: var(--sp-5); border-radius: var(--radius-lg); background: var(--c-surface); box-shadow: 0 20px 60px rgb(0 0 0 / 0.35); }
.render-box canvas { display: block; width: 100%; height: auto; margin: var(--sp-3) 0; border-radius: var(--radius-md); background: #000; }
.render-box progress { width: 100%; accent-color: var(--c-accent); }
.render-hint { font-size: var(--fs-sm); }

/* ===================== Kompositionen ===================== */
.sync-notice { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-4); }
.media-card--comp { text-decoration: none; }
.media-card--comp .media-card__media { background: repeating-linear-gradient(135deg, var(--c-surface-2) 0 10px, var(--c-surface) 10px 20px); }
.list__lead { flex: none; width: 20px; height: 20px; color: var(--c-text-muted); }
.comp-section { margin-top: var(--sp-6); }
.comp-path { margin: 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.comp { display: grid; gap: var(--sp-3); }
.comp__frame-wrap { width: 100%; max-height: 70vh; background: #000; border-radius: var(--radius-md); overflow: hidden; display: flex; justify-content: center; }
.comp__frame { display: block; width: 100%; height: 100%; border: 0; }
.comp__transport { flex-wrap: wrap; }
.comp__seek { flex: 1 1 12rem; min-width: 0; accent-color: var(--c-accent); }
.comp__state { margin: 0; font-size: var(--fs-sm); }
.comp__state.is-warn { color: var(--c-warn); }
.comp__actions { justify-content: flex-start; }
.comp__hint { font-size: var(--fs-sm); overflow-wrap: anywhere; }

/* 8. Equiplan-Module */

/* Kopfleiste */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 58px;
  padding: 0 var(--sp-3);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
}
.topbar__stall { display: flex; align-items: center; min-width: 0; flex: 1; justify-content: center; }
.topbar__user { margin-left: auto; position: relative; }
.stall-switch {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  max-width: 46vw;
  min-height: var(--touch);
  padding: 0 var(--sp-3);
  border: 0; border-radius: var(--radius-md);
  background: none; color: var(--c-text);
  font-weight: var(--fw-medium); cursor: pointer;
}
.stall-switch:hover { background: var(--c-surface-2); }
.stall-switch--static { cursor: default; }
.stall-switch--static:hover { background: none; }
.stall-switch .icon { width: 16px; height: 16px; flex: none; }

.avatar-btn {
  border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%;
  min-width: var(--touch); min-height: var(--touch);
  display: inline-grid; place-items: center;
}
.avatar {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  background: var(--c-accent-soft); color: var(--c-accent);
  font-weight: var(--fw-semibold);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-lg); }
.avatar--xl { width: 96px; height: 96px; font-size: var(--fs-2xl); }

/* Aufklapp-Menüs */
.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  min-width: 220px;
  padding: var(--sp-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  display: none;
  z-index: 40;
}
.menu.is-open { display: block; }
.menu--right { left: auto; right: 0; transform: none; }
.menu__head { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--c-line); margin-bottom: var(--sp-1); }
.menu__item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  min-height: var(--touch);
  padding: 0 var(--sp-3);
  border: 0; border-radius: var(--radius-md);
  background: none; color: var(--c-text);
  text-decoration: none; text-align: left;
  cursor: pointer;
}
.menu__item:hover { background: var(--c-surface-2); }
.menu__item.is-active { background: var(--c-accent-soft); }
.menu__item--danger { color: var(--c-danger); }
.menu form { margin: 0; }

/* Desktop: Rail läuft bis ganz nach oben; die Logo-Zelle oben schließt
   bündig an die Kopfleiste an (gleiche Höhe, gleiche Trennlinie). */
@media (min-width: 900px) {
  .has-nav { padding-left: var(--rail-w); }
  .rail { top: 0; padding-top: 0; }
  .rail > .brand {
    min-height: 58px;
    margin: 0 calc(-1 * var(--sp-3)) var(--sp-3);
    padding: 0 var(--sp-3);
    border-bottom: 1px solid var(--c-line);
  }
}

/* Seitenkopf */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.page-head h1 { font-size: var(--fs-xl); }

/* Panels & Karten */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-1);
}
.panel h2 { font-size: var(--fs-lg); margin-bottom: var(--sp-3); }
.panel__sub { font-size: var(--fs-md); margin: var(--sp-4) 0 var(--sp-2); }
.card-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  margin-bottom: var(--sp-5);
}
.card {
  display: flex; flex-direction: column; gap: var(--sp-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-1);
  text-decoration: none; color: var(--c-text);
}
.card--link:hover { border-color: var(--c-line-strong); background: var(--c-surface-2); }
.card--alert { border-color: var(--c-warn); background: var(--c-warn-soft); }
.card__icon { color: var(--c-accent); }
.card__icon .icon { width: 22px; height: 22px; }
.card__title { font-weight: var(--fw-semibold); }
.card__meta { font-size: var(--fs-sm); color: var(--c-text-muted); }
.card__text { font-size: var(--fs-sm); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--sp-2);
  border-radius: 999px;
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  background: var(--c-surface-2); color: var(--c-text-muted);
}
.badge--ok { background: var(--c-ok-soft); color: var(--c-ok); }
.badge--warn { background: var(--c-warn-soft); color: var(--c-warn); }
.badge--danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge--muted { background: var(--c-surface-2); color: var(--c-text-muted); }

/* Hinweise */
.notice {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-4);
  background: var(--c-surface-2);
}
.notice .icon { margin-top: 2px; flex: none; }
.notice--ok { background: var(--c-ok-soft); color: var(--c-ok); }
.notice--warn { background: var(--c-warn-soft); color: var(--c-warn); }
.notice--error { background: var(--c-danger-soft); color: var(--c-danger); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--sp-2) var(--sp-3); text-align: left; border-bottom: 1px solid var(--c-line); vertical-align: middle; }
.table th { color: var(--c-text-muted); font-weight: var(--fw-medium); white-space: nowrap; }
.table__actions { text-align: right; white-space: nowrap; }
.table__actions .btn { margin-left: var(--sp-1); }
.person { display: flex; align-items: center; gap: var(--sp-2); }

/* Tabs */
.tabs { display: flex; gap: var(--sp-1); flex-wrap: wrap; margin-bottom: var(--sp-4); border-bottom: 1px solid var(--c-line); }
.tabs__item {
  padding: var(--sp-2) var(--sp-3);
  color: var(--c-text-muted); text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs__item:hover { color: var(--c-text); }
.tabs__item.is-active { color: var(--c-text); border-bottom-color: var(--c-accent); font-weight: var(--fw-medium); }

/* Mitgliederkarten */
.member-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.member-card {
  display: flex; gap: var(--sp-3);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
}
.member-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--fs-sm); }
.member-card__body .icon { width: 14px; height: 14px; vertical-align: -2px; }

/* Verschiedenes */
.metric-row { display: flex; gap: var(--sp-5); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.metric { display: flex; flex-direction: column; }
.metric__value { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); }
.metric__label { font-size: var(--fs-sm); color: var(--c-text-muted); }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.inline-form .input { width: auto; flex: 1; min-width: 160px; }
.stack--narrow { max-width: 480px; }
.copy-line { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.code-list { columns: 2; list-style: none; padding: 0; font-size: var(--fs-sm); }
.code-list li { padding: var(--sp-1) 0; break-inside: avoid; }
.area-list { list-style: none; padding: 0; margin: 0 0 var(--sp-3); }
.area-list li { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; border-bottom: 1px solid var(--c-line); }
.mini-list { list-style: none; padding: 0; margin: 0; font-size: var(--fs-sm); color: var(--c-text-muted); }
.mini-list li { padding: 2px 0; }
.steps-list { padding-left: var(--sp-5); }
.steps-list li { margin-bottom: var(--sp-2); }
.profil-grid { display: grid; gap: var(--sp-5); }
@media (min-width: 760px) { .profil-grid { grid-template-columns: 220px 1fr; } }
.avatar-row { display: flex; flex-direction: column; gap: var(--sp-3); align-items: flex-start; }
.legal { max-width: 720px; margin: var(--sp-6) auto; padding: 0 var(--sp-4); }
.legal h1 { margin: var(--sp-4) 0; }
.legal__text { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--radius-lg); padding: var(--sp-5); }
.auth__links { text-align: center; margin-top: var(--sp-3); }
.auth__note { font-size: var(--fs-sm); text-align: center; margin-top: var(--sp-4); }
.auth__footer { margin-top: var(--sp-5); text-align: center; font-size: var(--fs-sm); }
.auth--wide { max-width: 560px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Pferdeverwaltung (Phase 3) --- */
.btn--secondary { background: var(--c-surface-2); border: 1px solid var(--c-line-strong); color: var(--c-text); }
.btn--secondary:hover { border-color: var(--c-accent); }

details.panel > summary {
  cursor: pointer;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: var(--fw-medium);
}
details.panel > summary::before {
  content: "";
  width: 0.55em; height: 0.55em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
details.panel[open] > summary::before { transform: rotate(45deg); }
details.panel > summary ~ * { margin-top: var(--sp-3); }

.def-list { display: grid; gap: 0; }
.def-list__row {
  display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr;
  gap: var(--sp-3); padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--c-line);
}
.def-list__row dt { color: var(--c-text-muted); }
.def-list__row dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 599px) { .def-list__row { grid-template-columns: 1fr; gap: 0; } }

.check-row { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); }

.feed-item {
  border: 1px solid var(--c-line);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.feed-item legend { font-weight: var(--fw-medium); padding: 0 var(--sp-2); }

.sep { border: 0; border-top: 1px solid var(--c-line); margin: var(--sp-4) 0; }


/* ---------- Aufgaben & Pflichtdienste ---------- */
.day-head {
  font-size: var(--fs-lg);
  margin: var(--sp-5) 0 var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--c-line);
}
.day-head:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.task {
  border: 1px solid var(--c-line);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  background: var(--c-surface);
}
.task--overdue { border-color: var(--c-danger); }
.task__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.task__head strong { margin-right: auto; }
.task__meta { color: var(--c-text-muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.task__main { margin-top: var(--sp-2); }
.task__claims { margin-top: var(--sp-2); font-size: var(--fs-sm); }
.task__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.task__proof { margin-top: var(--sp-2); }
.task__proof > summary {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  cursor: pointer; color: var(--c-text-muted); font-size: var(--fs-sm);
  list-style: none;
}
.task__proof > summary::marker { content: none; }
.task__proof[open] > summary { color: var(--c-text); }

.duty-bar {
  height: 8px;
  background: var(--c-surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.duty-bar__fill {
  display: block; height: 100%;
  background: var(--c-ok);
  border-radius: 999px;
  transition: width 0.2s;
}
tr.is-me td { background: var(--c-surface-2); }


/* ---------- Kalender ---------- */
.kal-nav { align-items: center; margin: var(--sp-3) 0; }

.kal-list { list-style: none; margin: 0 0 var(--sp-3); padding: 0; }
.kal-entry { display: flex; gap: var(--sp-2); padding: var(--sp-1) 0; align-items: baseline; }
.kal-entry__dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; margin-top: 2px; }
.kal-entry--aufgabe .kal-entry__dot, .kal-dot--aufgabe { background: var(--c-accent); }
.kal-entry--gesundheit .kal-entry__dot, .kal-dot--gesundheit { background: var(--c-danger); }
.kal-entry--training .kal-entry__dot, .kal-dot--training { background: var(--c-focus); }
.kal-entry--training_log .kal-entry__dot, .kal-dot--training_log { background: var(--c-text-muted); }
.kal-entry--ruhephase .kal-entry__dot, .kal-dot--ruhephase { background: var(--c-warn); }
.kal-entry--veranstaltung .kal-entry__dot, .kal-dot--veranstaltung { background: var(--c-ok); }
.kal-entry--ressource .kal-entry__dot, .kal-dot--ressource { background: var(--c-accent-hover); }
.kal-entry__body .badge { margin-left: var(--sp-1); }

.kal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--sp-2); }
.kal-day {
  border: 1px solid var(--c-line);
  border-radius: var(--radius-md);
  padding: var(--sp-2);
  min-width: 0;
  background: var(--c-surface);
}
.kal-day h3 { font-size: var(--fs-sm); margin: 0 0 var(--sp-2); }
.kal-day.is-today { border-color: var(--c-accent); }
.kal-day .kal-entry { font-size: var(--fs-sm); }
@media (max-width: 899px) {
  .kal-week { grid-template-columns: 1fr; }
}

.kal-month__head {
  display: grid; grid-template-columns: repeat(7, 1fr);
  color: var(--c-text-muted); font-size: var(--fs-sm);
  text-align: center; margin-bottom: var(--sp-1);
}
.kal-month__grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; background: var(--c-line);
  border: 1px solid var(--c-line); border-radius: var(--radius-md);
  overflow: hidden;
}
.kal-cell {
  background: var(--c-surface);
  min-height: 64px;
  padding: var(--sp-1) var(--sp-2);
  display: flex; flex-direction: column; gap: var(--sp-1);
  color: var(--c-text);
  text-decoration: none;
}
.kal-cell:hover { background: var(--c-surface-2); }
.kal-cell.is-today { outline: 2px solid var(--c-accent); outline-offset: -2px; }
.kal-cell.is-fremdmonat { opacity: 0.45; }
.kal-cell__nr { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.kal-cell__dots { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.kal-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.kal-cell__count { font-size: var(--fs-xs); color: var(--c-text-muted); margin-left: auto; }
.kal-legend { margin-top: var(--sp-2); font-size: var(--fs-sm); }
.kal-legend .kal-dot { margin-right: 2px; }
@media (max-width: 599px) {
  .kal-cell { min-height: 44px; padding: 2px var(--sp-1); }
}


/* ---------- Gemeinschaft: Glocke, Pinnwand, Chats ---------- */
.bell-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; color: var(--c-text); text-decoration: none; }
.bell-badge {
  position: absolute; top: -2px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px;
  background: var(--c-danger); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center;
  pointer-events: none;
}

.feed-item.is-pinned { border-color: var(--c-accent); }
.feed-item.is-unread { border-left: 3px solid var(--c-accent); }
.feed-item--antwort { margin-left: var(--sp-5); }
.feed-item h3 { margin: 0 0 var(--sp-1); font-size: var(--fs-md); }

.post-bild {
  max-width: 220px; max-height: 160px;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-line);
  object-fit: cover;
}

.chat-verlauf { display: flex; flex-direction: column; gap: var(--sp-2); }
.chat-msg {
  max-width: 85%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  background: var(--c-surface-2);
  align-self: flex-start;
}
.chat-msg--eigen {
  align-self: flex-end;
  background: var(--c-accent-soft);
}
.chat-msg__meta { margin: 0; font-size: var(--fs-xs); color: var(--c-text-muted); }
.chat-msg__text { margin: var(--sp-1) 0 0; overflow-wrap: anywhere; }
.chat-msg .post-bild { margin-top: var(--sp-1); }
.chat-msg details.task__proof { margin-top: var(--sp-1); }

/* --- Stallleben-Hub & Umfragebalken (Phase 7) --- */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-3); }
.hub-card {
  display: block; background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); text-decoration: none; color: var(--c-text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.hub-card:hover { border-color: var(--c-accent); transform: translateY(-1px); }
.hub-card__title { margin: 0 0 var(--sp-1); font-size: var(--fs-lg); }
.hub-card__text { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); color: var(--c-text-muted); }
.hub-card__count { margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-muted); }
.hub-card__count.is-active { color: var(--c-accent); }

.duty-row { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-1) 0; }
.duty-row__name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.duty-row__count { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--c-text-muted); }
.duty-row .duty-bar { flex: 0 0 40%; }
.liste-plain { margin: var(--sp-2) 0; padding-left: var(--sp-4); }
.liste-plain li { margin: var(--sp-1) 0; overflow-wrap: anywhere; }

/* Statistik-Kacheln (Phase 8) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-2); margin: var(--sp-2) 0; }
.stat { background: var(--c-surface-2, rgba(0,0,0,.04)); border: 1px solid var(--c-border, rgba(0,0,0,.1)); border-radius: var(--radius, 8px); padding: var(--sp-2) var(--sp-3); }
.stat__wert { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat__label { font-size: .85rem; color: var(--c-text-muted); margin-top: 2px; }
.duty-bar--mini { height: 6px; }

/* Layout-Feinschliff: Logo in der Rail, Topbar entlastet, Stall-Titel bricht um */
@media (min-width: 900px) {
  .topbar .brand { display: none; }
}

/* Stall-Titel: Schrift skaliert mit der Breite, Text darf mittig umbrechen */
.stall-switch { font-size: clamp(var(--fs-sm), 3.4vw, var(--fs-md)); }
.stall-switch .clamp-1 { flex: 0 1 auto; min-width: 0; }

@media (max-width: 899px) {
  .stall-switch { max-width: 52vw; min-height: 0; padding: var(--sp-1) var(--sp-2); }
  .stall-switch .clamp-1 {
    white-space: normal;
    text-align: center;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .topbar { gap: var(--sp-2); }
}

/* Sehr schmal: nur das Logo-Zeichen, ohne Schriftzug — mehr Platz für den Stallnamen */
@media (max-width: 560px) {
  .topbar .brand__name { display: none; }
  .topbar { padding: 0 var(--sp-2); }
}

/* Stall-Logo & Titelbild (Konzept §9) */
.brand__mark--img { background: transparent; overflow: hidden; }
.brand__mark--img img { width: 100%; height: 100%; object-fit: cover; }
.stall-hero { margin: 0 0 var(--sp-5); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--c-line); }
.stall-hero img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.stall-logo-preview { max-width: 128px; max-height: 128px; border-radius: var(--radius-md); border: 1px solid var(--c-line); }
.stall-hero-preview { display: block; max-width: 100%; max-height: 140px; border-radius: var(--radius-md); border: 1px solid var(--c-line); }
.panel__sub { font-size: var(--fs-md); margin: 0; }
.check-list { display: grid; gap: var(--sp-1); max-height: 180px; overflow: auto; padding: var(--sp-1) 0; }

/* Statistik-Diagramme (inline-SVG, keine externen Bibliotheken) */
.chart { display: block; width: 100%; height: auto; }
.chart__a { fill: #7ba05b; }
.chart__b { fill: #d2a24a; }
.chart__grid { stroke: var(--c-line); stroke-width: 1; }
.chart__text { font-size: 10px; fill: var(--c-text-muted, #8a8578); }
.chart-legend { display: flex; gap: var(--sp-4); margin: var(--sp-2) 0 0; font-size: var(--fs-sm); }
.chart-legend__item { display: inline-flex; align-items: center; gap: var(--sp-1); }
.chart-legend__swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-legend__swatch--a { background: #7ba05b; }
.chart-legend__swatch--b { background: #d2a24a; }

/* Pferde-Fotogalerie (Konzept §10) */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-4); }
.galerie__item { margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.galerie__bild { display: block; aspect-ratio: 1 / 1; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--c-line); }
.galerie__bild img { width: 100%; height: 100%; object-fit: cover; display: block; }
.galerie__meta { font-size: var(--fs-sm); display: flex; flex-direction: column; gap: 2px; }
.galerie__aktionen { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- Trainingseinheiten: Ritt (GPS) & Bodenarbeit (1.9.0) ---------- */
:root {
  --gang-schritt: #2f7d4f;
  --gang-trab: #c27a00;
  --gang-galopp: #b8322a;
  --gang-stand: #8a8578;
  --gang-luecke: #b9b3a3;
  --route-bg: #ece8dc;
  --route-grid: #ddd7c7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gang-schritt: #6cc08d;
    --gang-trab: #f0b54a;
    --gang-galopp: #f27d70;
    --gang-stand: #a3a493;
    --gang-luecke: #5b5f52;
    --route-bg: #1f241e;
    --route-grid: #2c3229;
  }
}
:root[data-theme="dark"] {
  --gang-schritt: #6cc08d;
  --gang-trab: #f0b54a;
  --gang-galopp: #f27d70;
  --gang-stand: #a3a493;
  --gang-luecke: #5b5f52;
  --route-bg: #1f241e;
  --route-grid: #2c3229;
}

.einheit-start { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-3); }
.einheit-start__karte { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); border: 1px solid var(--c-line); border-radius: var(--radius-lg); background: var(--c-surface); }
.einheit-start__karte h3 { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-1); font-size: var(--fs-md); }

.einheit-rec { display: flex; flex-direction: column; gap: var(--sp-3); }
.einheit-rec__titel { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin: 0; }
.einheit-rec__zeit { font-size: clamp(2.6rem, 12vw, 4rem); line-height: 1; margin: 0; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.einheit-rec__werte { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--sp-3); margin: 0; }
.einheit-rec__werte div { padding: var(--sp-3); border-radius: var(--radius-md); background: var(--c-surface-2); }
.einheit-rec__werte dt { font-size: var(--fs-sm); color: var(--c-text-muted); }
.einheit-rec__werte dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.einheit-rec__hinweis { margin: 0; }
.einheit-rec__knoepfe .btn { flex: 1 1 140px; }
.btn--lg { min-height: 56px; font-size: 1.05rem; }

.gang-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--c-surface); border: 1px solid var(--c-line); }
.gang-badge.gang--schritt, .gang-badge.gang--trab, .gang-badge.gang--galopp, .gang-badge.gang--stand { color: #fff; border-color: transparent; }
.gang-badge.gang--schritt { background: var(--gang-schritt); }
.gang-badge.gang--trab { background: var(--gang-trab); }
.gang-badge.gang--galopp { background: var(--gang-galopp); }
.gang-badge.gang--stand { background: var(--gang-stand); }

.einheit-liste { list-style: none; margin: 0; padding: 0; }
.einheit-liste li + li { border-top: 1px solid var(--c-line); }
.einheit-liste__item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; min-height: var(--touch); color: inherit; text-decoration: none; }
.einheit-liste__item:hover .einheit-liste__text strong { text-decoration: underline; }
.einheit-liste__icon { flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--c-accent-soft); color: var(--c-accent); }
.einheit-liste__icon--boden { background: var(--c-warn-soft); color: var(--c-warn); }
.einheit-liste__text { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.einheit-liste__werte { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.einheit-nachtragen { margin-top: var(--sp-4); }
.einheit-nachtragen > summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; font-weight: 600; }

.uebungen { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.uebungen__zeile { display: grid; grid-template-columns: 1fr 88px; gap: var(--sp-2); }

.gang-balken { display: flex; height: 18px; border-radius: 999px; overflow: hidden; background: var(--c-surface-2); margin-bottom: var(--sp-3); }
.gang-balken__teil { display: block; height: 100%; width: 0; }
.gang-balken__teil.gang--schritt, .gang-punkt.gang--schritt { background: var(--gang-schritt); }
.gang-balken__teil.gang--trab, .gang-punkt.gang--trab { background: var(--gang-trab); }
.gang-balken__teil.gang--galopp, .gang-punkt.gang--galopp { background: var(--gang-galopp); }
.gang-balken__teil.gang--stand, .gang-punkt.gang--stand { background: var(--gang-stand); }
.gang-balken__teil.gang--luecke, .gang-punkt.gang--luecke { background: var(--gang-luecke); }
.gang-punkt { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: var(--sp-2); vertical-align: -1px; }
.gang-tabelle td { font-variant-numeric: tabular-nums; }
.gang-tabelle td:first-child { white-space: nowrap; }

.route-legende { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-3); font-size: var(--fs-sm); }
.route-map { display: block; width: 100%; height: auto; }
.route-map__bg { fill: var(--route-bg); }
.route-map__grid { stroke: var(--route-grid); stroke-width: 1; }
.route-map__line { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.route-map__line.gang--schritt, .tempo-chart__line.gang--schritt { stroke: var(--gang-schritt); }
.route-map__line.gang--trab, .tempo-chart__line.gang--trab { stroke: var(--gang-trab); }
.route-map__line.gang--galopp, .tempo-chart__line.gang--galopp { stroke: var(--gang-galopp); }
.route-map__line.gang--stand, .tempo-chart__line.gang--stand { stroke: var(--gang-stand); }
.route-map__line.gang--luecke { stroke: var(--gang-luecke); stroke-dasharray: 4 6; }
.route-map__start, .route-map__start-punkt { fill: var(--c-accent); background: var(--c-accent); stroke: var(--c-surface); stroke-width: 3; }
.route-map__end, .route-map__end-punkt { fill: var(--c-text); background: var(--c-text); stroke: var(--c-surface); stroke-width: 3; }
.route-map__scale { stroke: var(--c-text); stroke-width: 3; }
.route-map__text { font-size: 12px; fill: var(--c-text); font-weight: 600; }
.tempo-chart__line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.tempo-chart__schwelle { stroke: var(--c-line-strong); stroke-width: 1; stroke-dasharray: 5 5; }

.plain-list { margin: 0 0 var(--sp-3); padding-left: 1.2em; }
.plain-list li + li { margin-top: var(--sp-1); }
.panel--danger { border-color: var(--c-danger-soft); }

/* ---------- Rechtstexte (Markdown, 1.9.0) ---------- */
.legal__text > :first-child { margin-top: 0; }
.legal__text > :last-child { margin-bottom: 0; }
.legal__text h2 { font-size: 1.25rem; margin: var(--sp-5) 0 var(--sp-2); }
.legal__text h3 { font-size: 1.08rem; margin: var(--sp-4) 0 var(--sp-2); }
.legal__text h4 { font-size: 1rem; margin: var(--sp-3) 0 var(--sp-1); }
.legal__text p { margin: 0 0 var(--sp-3); line-height: 1.6; overflow-wrap: anywhere; }
.legal__text ul, .legal__text ol { margin: 0 0 var(--sp-3); padding-left: 1.3em; line-height: 1.6; }
.legal__text code { font-family: var(--font-mono, monospace); font-size: 0.92em; background: var(--c-surface-2); padding: 0 4px; border-radius: 4px; }
