/* CrowdWork: gemeinsame Grundlage aller Seiten (übernommen aus SlideDesk,
   frontend/static/app.css, und um CrowdWork-Eigenes gekürzt). TSE-Shell:
   Kopfzeile 56px mit Bildmarke, Werkzeugzeile, Knöpfe 42px/13px/600,
   Radius 4px, Bewegung 160ms. Farben nur über Rollen-Token aus tokens.css.
   White-Label: Event-Seiten überschreiben die Akzent-Rollen (backend/app/marke.py).
   Was Gefahr anzeigt, hängt an --fg-danger und bleibt rot.
   Live-Bausteine (Diagramme, Teilnahme, Leinwand, Steuerung, Konsole) in crowdwork.css. */

:root { --fg-danger: var(--tse-red); --border-danger: var(--tse-red); --bg-danger-wash: var(--tse-red-wash); }
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-thema="hell"]) { --fg-danger: var(--tse-red-bright); --border-danger: var(--tse-red-bright); --bg-danger-wash: var(--tse-red-deep); }
}
@media screen { :root[data-thema="dunkel"] { --fg-danger: var(--tse-red-bright); --border-danger: var(--tse-red-bright); --bg-danger-wash: var(--tse-red-deep); } }

html { scrollbar-gutter: stable; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg-2); color: var(--fg-1);
  font-family: var(--font-sans); font-size: var(--fs-small); line-height: var(--lh-normal);
  font-variant-numeric: tabular-nums;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: var(--lh-snug); }
/* Lange Wörter ohne Leerzeichen (Links, Zahlenketten) brechen notfalls, statt überzulaufen */
h1, h2, h3, h4, p, li, dd, blockquote, figcaption { overflow-wrap: break-word; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: var(--tracking-tight); }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
a { color: var(--fg-accent); }
.mono, .kennung { font-family: var(--font-mono); font-size: 12.5px; }
.kennung { white-space: nowrap; }
.leise { color: var(--fg-2); }
.klein { font-size: var(--fs-caption); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); border: 0; white-space: nowrap; }

/* ---- Kopfzeile ---- */
.kopf {
  position: sticky; top: 0; z-index: 60;
  background: var(--bg-1); border-bottom: 1px solid var(--border-2);
}
.kopf-innen {
  display: flex; align-items: center; gap: 14px;
  min-height: var(--shell-h); padding: 0 16px; max-width: 1280px; margin: 0 auto;
}
.marke { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.marke img { height: 20px; width: auto; display: block; }
.marke img.logo-event { flex: none; height: 32px; max-width: 180px; object-fit: contain; object-position: left center; }
.logo-dunkel { display: none !important; }
:root[data-thema="dunkel"] .logo-hell { display: none !important; }
:root[data-thema="dunkel"] .logo-dunkel { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-thema="hell"]) .logo-hell { display: none !important; }
  :root:not([data-thema="hell"]) .logo-dunkel { display: block !important; }
}
/* Logo ohne Dunkel-Variante: im Dunkelmodus auf heller Platte, damit es lesbar bleibt. */
:root[data-thema="dunkel"] img.auf-platte { background: #fff; padding: 3px 6px; border-radius: var(--radius-2); box-sizing: content-box; }
@media (prefers-color-scheme: dark) {
  :root:not([data-thema="hell"]) img.auf-platte { background: #fff; padding: 3px 6px; border-radius: var(--radius-2); box-sizing: content-box; }
}
.trenn { width: 1px; height: 18px; background: var(--border-2); flex: none; }
.chip {
  width: 30px; height: 30px; flex: none; border-radius: var(--radius-2); background: var(--bg-accent-wash);
  display: inline-flex; align-items: center; justify-content: center;
}
.chip svg { width: 17px; height: 17px; fill: none; stroke: var(--fg-accent); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.titel-block { min-width: 0; display: flex; flex-direction: column; }
.titel { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.untertitel { font-size: 12px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aktionen { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---- Werkzeugzeile ---- */
.werkzeug {
  position: sticky; top: var(--shell-h); z-index: 50;
  background: var(--bg-1); border-bottom: 1px solid var(--border-2);
}
.werkzeug-innen {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: var(--shell-wz-h); padding: 6px 16px; max-width: 1280px; margin: 0 auto;
}
.reiter { display: flex; gap: 4px; }
.reiter button {
  min-height: 42px; padding: 0 14px; border: 0; background: transparent; color: var(--fg-2);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: var(--radius-2);
  transition: background var(--duration-base) var(--ease-standard), color var(--duration-base) var(--ease-standard);
}
.reiter button:hover { background: var(--bg-3); color: var(--fg-1); }
.reiter button[aria-selected="true"] { color: var(--fg-1); box-shadow: inset 0 -2px 0 var(--border-accent); border-radius: var(--radius-2) var(--radius-2) 0 0; }
.luecke { flex: 1; }

/* ---- Inhalt ---- */
main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 64px; }
main.schmal { max-width: 760px; }
.stapel { display: flex; flex-direction: column; gap: 16px; }
.zeile { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.karte {
  background: var(--bg-1); border: 1px solid var(--border-2); border-radius: var(--radius-2);
  box-shadow: var(--shadow-1); padding: 20px;
}
.karte-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--fg-2); font-size: 13px; margin-bottom: 4px; }
.hinweis { padding: 12px 14px; border-left: 3px solid var(--border-accent); background: var(--bg-accent-wash); border-radius: 0 var(--radius-2) var(--radius-2) 0; color: var(--fg-1); }
.leer { padding: 32px 16px; text-align: center; color: var(--fg-2); }

/* ---- Knöpfe ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 14px; cursor: pointer; text-decoration: none;
  background: var(--bg-1); border: 1px solid var(--border-1); border-radius: var(--radius-2);
  color: var(--fg-1); font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background var(--duration-base) var(--ease-standard), border-color var(--duration-base) var(--ease-standard), color var(--duration-base) var(--ease-standard);
}
.btn:hover { border-color: var(--border-strong); }
.btn:focus-visible, .reiter button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--border-strong); outline-offset: 2px;
}
.btn.primaer { background: var(--bg-accent); border-color: var(--bg-accent); color: var(--fg-on-accent); }
.btn.primaer:hover { background: var(--bg-accent-hover); border-color: var(--bg-accent-hover); }
.btn.leise { border-color: transparent; color: var(--fg-2); background: transparent; }
.btn.leise:hover { color: var(--fg-1); background: var(--bg-3); }
.btn.gefahr { color: var(--fg-danger); }
.btn.gefahr:hover { border-color: var(--border-danger); }
.btn.gefahr.voll { background: var(--fg-danger); border-color: var(--fg-danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn.klein-btn { min-height: 34px; padding: 0 10px; font-size: 12.5px; }

/* ---- Formular ---- */
label.feld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input:not([type]), select, textarea {
  min-height: 42px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--fg-1);
  background: var(--bg-1); border: 1px solid var(--border-1); border-radius: var(--radius-2);
}
textarea { padding: 10px 12px; min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--border-strong); box-shadow: var(--shadow-focus); }
.raster-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.haken { display: inline-flex; align-items: center; gap: 10px; min-height: 42px; cursor: pointer; font-size: 14px; }
.haken input { width: 18px; height: 18px; accent-color: var(--bg-accent); margin: 0; }

/* ---- Zustände ---- */
.status {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: var(--radius-1);
  border: 1px solid var(--border-2); color: var(--fg-2); background: var(--bg-2);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.pruefung { color: var(--fg-warning); border-color: var(--fg-warning); background: var(--bg-warning-wash); }
.status.sichtbar, .status.offen, .status.live { color: var(--fg-success); }
.status.beantwortet { color: var(--fg-info); }
.status.abgelehnt { color: var(--fg-danger); border-color: var(--border-danger); background: var(--bg-danger-wash); }
.status.archiviert, .status.geschlossen { color: var(--fg-3); }
.status.archiviert::before, .status.geschlossen::before { background: transparent; border: 1px solid currentColor; }

/* ---- Tabellen ---- */
.tabelle-rahmen { overflow-x: auto; border: 1px solid var(--border-2); border-radius: var(--radius-2); background: var(--bg-1); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
th { font-size: 11px; font-weight: 700; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--fg-2); background: var(--bg-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* ---- Dialog ---- */
dialog {
  border: 1px solid var(--border-2); border-radius: var(--radius-2); padding: 24px; max-width: min(520px, calc(100vw - 32px));
  background: var(--bg-1); color: var(--fg-1); box-shadow: var(--shadow-3);
  opacity: 0; transform: translateY(-6px) scale(.98);
  transition: opacity var(--duration-base) var(--ease-standard), transform var(--duration-base) var(--ease-standard), overlay var(--duration-base) allow-discrete, display var(--duration-base) allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: translateY(-6px) scale(.98); } }
dialog::backdrop { background: var(--tse-scrim); }
dialog h2 { margin-bottom: 10px; }
dialog .knopfzeile { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

/* ---- Toast (dunkel, unten links) ---- */
.toasts { position: fixed; left: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 10px 14px;
  background: var(--bg-inverse); color: var(--fg-on-dark); border-radius: var(--radius-2); box-shadow: var(--shadow-3);
  font-size: 13px; opacity: 0; transform: translateY(6px);
  transition: opacity var(--duration-base) var(--ease-standard), transform var(--duration-base) var(--ease-standard);
}
.toast.da { opacity: 1; transform: none; }
.toast button { background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 6px 0; }

/* ---- Darstellung ---- */
.darstellung { position: relative; }
.darstellung select { min-height: 42px; font-size: 13px; }

/* ---- Fußzeile (Hinweis auf TSE, je Event schaltbar) ---- */
.fuss {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px 32px; color: var(--fg-2); font-size: 12px;
}
.fuss img { height: 14px; width: auto; display: block; }

/* ---- Pflege (Konsole) ---- */
.bilder { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.bild-feld { display: flex; flex-direction: column; gap: 8px; }
.bild-vorschau {
  height: 96px; display: flex; align-items: center; justify-content: center; padding: 10px;
  border: 1px dashed var(--border-1); border-radius: var(--radius-2); background: var(--bg-2); color: var(--fg-2); cursor: pointer;
}
.bild-vorschau.dunkel-grund { background: #1f1f1f; color: #c9c9c9; }
.bild-vorschau img { max-width: 100%; max-height: 100%; object-fit: contain; }
.bild-vorschau.ziel { border-color: var(--border-accent); border-style: solid; }
.farbe { display: flex; align-items: center; gap: 8px; }
.farbe input[type=color] { width: 48px; height: 42px; padding: 2px; border: 1px solid var(--border-1); border-radius: var(--radius-2); background: var(--bg-1); cursor: pointer; }
.farbe input[type=text] { width: 110px; font-family: var(--font-mono); }
.muster { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px; border: 1px solid var(--border-2); border-radius: var(--radius-2); }
.abschnitt-titel { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.mehrfach { max-height: 180px; overflow-y: auto; border: 1px solid var(--border-1); border-radius: var(--radius-2); padding: 4px 10px; display: flex; flex-direction: column; }
.mehrfach .haken { min-height: 34px; font-size: 13px; }
.raster-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .raster-3 { grid-template-columns: 1fr 1fr; } .raster-3 > :first-child { grid-column: 1 / -1; } }
@media (max-width: 520px) { .marke:has(.logo-event) .titel-block, .marke:has(.logo-event) .trenn { display: none; } }
dialog.breit { max-width: min(720px, calc(100vw - 32px)); width: 100%; }
.zaehler { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; align-items: center; justify-content: center; background: var(--fg-danger); color: #fff; font-size: 11px; font-weight: 700; }
:root { --bg-warning-wash: #FBF0DD; --bg-success-wash: #E6F2EA; }
@media screen and (prefers-color-scheme: dark) { :root:not([data-thema="hell"]) { --bg-warning-wash: #3A2E1A; --bg-success-wash: #1C3326; } }
@media screen { :root[data-thema="dunkel"] { --bg-warning-wash: #3A2E1A; --bg-success-wash: #1C3326; } }

/* ---- Öffentliche Seiten (Teilnehmer): 16px Grundschrift, sonst zoomt iOS in Eingabefelder ---- */
body.oeffentlich { font-size: var(--fs-body); }
body.oeffentlich input[type=text], body.oeffentlich input[type=email], body.oeffentlich input:not([type]), body.oeffentlich select, body.oeffentlich textarea { font-size: 16px; }
body.oeffentlich .klein { font-size: 13px; }
body.oeffentlich .btn { min-height: 44px; font-size: 14px; }
body.oeffentlich .btn.klein-btn { min-height: 40px; }
body.oeffentlich .haken { min-height: 44px; font-size: 16px; }
.sprung { position: absolute; left: 16px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--bg-strong); color: var(--fg-on-strong); border-radius: var(--radius-2); font-weight: 600; text-decoration: none; }
.sprung:focus { top: 8px; }

/* ---- Fehler am Ort des Geschehens, nicht nur als Toast ---- */
.feldfehler { display: block; font-weight: 400; margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--border-danger); background: var(--bg-danger-wash); color: var(--fg-1); border-radius: 0 var(--radius-2) var(--radius-2) 0; font-size: 13px; }
body.oeffentlich .feldfehler { font-size: 15px; }
.btn[aria-busy="true"] { cursor: progress; }

/* ---- Login ---- */
.login { max-width: 400px; margin: 10vh auto 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
