:root {
  --gruen: #2d6a2e;
  --gruen-dunkel: #1f4d20;
  --gruen-hell: #e7f1e7;
  --gold: #c5a44e;
  --gold-hell: #f6efdc;
  --text: #17201a;
  --text-leise: #56635a;
  --flaeche: #ffffff;
  --grund: #f4f6f3;
  --linie: #dde3dc;
  --kante: #7d8a80; /* Kante bedienbarer Elemente, mindestens 3:1 gegen Flaeche und Grund */
  --rot: #b3261e;
  --rot-hell: #fbe9e7;
  --belegt: #e9ece8;
  --schatten: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gruen: #5fae61;
    --gruen-dunkel: #8fcf90;
    --gruen-hell: #1d2b1e;
    --gold: #d9bb6a;
    --gold-hell: #2d2717;
    --text: #e8ece7;
    --text-leise: #a5b0a7;
    --flaeche: #171c18;
    --grund: #0e120f;
    --linie: #2c352e;
    --kante: #6b786d;
    --rot: #f2a39c;
    --rot-hell: #3a1d1b;
    --belegt: #232a24;
    --schatten: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--grund);
}
a { color: var(--gruen); }
button, input, select, textarea { font: inherit; color: inherit; }
button { padding: 0; } /* Browser-Vorgabe 1px 6px liegt neben dem Vierer-Raster */
:focus-visible { outline: 3px solid var(--gruen); outline-offset: 2px; }
.pin-karte :focus-visible { outline-color: #fff; }

.kopf {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
}
.marke { display: flex; align-items: center; gap: 12px; font-weight: 700; text-decoration: none; color: var(--text); }
.marke-zeichen {
  width: 32px; height: 32px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e7f28a, #c6d93b 60%, #9fb32a);
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 60%);
}
.kopf nav { display: flex; gap: 4px; }
.kopf nav a {
  padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--text);
  min-height: 40px; display: inline-flex; align-items: center; border: 1px solid transparent;
}
.kopf nav a[aria-current="page"] { background: var(--gruen-hell); color: var(--gruen-dunkel); font-weight: 600; border-color: var(--gruen); }

main { max-width: 960px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 8px 0 4px; }
h2 { font-size: 1.15rem; margin: 24px 0 12px; }
.leise { color: var(--text-leise); }
.klein { font-size: .875rem; }

.karte {
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--schatten);
}
.stapel > * + * { margin-top: 12px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 4px; scrollbar-width: thin; }
.chip {
  flex: 0 0 auto; min-height: 44px; padding: 8px 16px; border-radius: 12px;
  border: 1px solid var(--kante); background: var(--flaeche); cursor: pointer; text-align: center;
}
.chip small { display: block; color: var(--text-leise); font-size: .75rem; }
.chip[aria-pressed="true"] { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.chip[aria-pressed="true"] small { color: rgb(255 255 255 / 85%); }
.chip:disabled { opacity: .45; cursor: not-allowed; }

.zeiten { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.zeit {
  min-height: 48px; padding: 4px 8px; border-radius: 12px; border: 1px solid var(--kante); background: var(--flaeche); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.zeit small { color: var(--text-leise); font-size: .72rem; }
.zeit.haupt { box-shadow: inset 0 -4px 0 var(--gold); }
.zeit[aria-pressed="true"] { background: var(--gruen); color: #fff; border-color: var(--gruen); }
.zeit[aria-pressed="true"] small { color: rgb(255 255 255 / 85%); }

.plaetze { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.platzwahl {
  text-align: left; padding: 16px; border-radius: var(--radius); border: 1px solid var(--kante);
  background: var(--flaeche); cursor: pointer; min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.platzwahl:hover { border-color: var(--gruen); }
.platzwahl strong { display: block; }
.abzeichen { font-size: .72rem; padding: 4px 8px; border-radius: 999px; background: var(--gruen-hell); color: var(--gruen-dunkel); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.abzeichen.tennis { background: var(--gold-hell); color: #7a5f12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .abzeichen.tennis { color: var(--gold); } }
.preis { font-weight: 700; white-space: nowrap; }

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 16px; border-radius: 12px; border: 1px solid transparent;
  background: var(--gruen); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none;
}
.knopf:hover { background: var(--gruen-dunkel); }
.knopf.zweit { background: var(--flaeche); color: var(--text); border-color: var(--kante); }
.knopf.zweit:hover { border-color: var(--gruen); }
.knopf.gefahr { background: var(--flaeche); color: var(--rot); border-color: var(--kante); }
.knopf.voll { width: 100%; }
.knopf:disabled { opacity: .5; cursor: not-allowed; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .knopf:not(.zweit):not(.gefahr) { color: #0e120f; }
  :root:not([data-theme="light"]) .chip[aria-pressed="true"], :root:not([data-theme="light"]) .zeit[aria-pressed="true"] { color: #0e120f; }
  :root:not([data-theme="light"]) .chip[aria-pressed="true"] small, :root:not([data-theme="light"]) .zeit[aria-pressed="true"] small { color: #1d2b1e; }
}

label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type="text"], input[type="tel"], input[type="email"], input[type="password"], input[type="month"], select, textarea {
  width: 100%; min-height: 48px; padding: 12px; border-radius: 12px; border: 1px solid var(--kante); background: var(--flaeche);
}
.code-eingabe { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.feld + .feld { margin-top: 12px; }
.haken { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; }
.haken input { width: 24px; height: 24px; margin: 0; flex: 0 0 auto; }

dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); border: none; border-radius: 18px; padding: 0;
  background: var(--flaeche); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
dialog::backdrop { background: rgb(10 15 11 / 55%); }
.dialog-kopf { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 0; }
.dialog-kopf h2 { margin: 0; }
.dialog-inhalt { padding: 16px; }
.schliessen { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--grund); cursor: pointer; font-size: 1.2rem; }

.zusammenfassung { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; }
.zusammenfassung dt { color: var(--text-leise); }
.zusammenfassung dd { margin: 0; font-weight: 600; text-align: right; }

.meldung { padding: 12px 16px; border-radius: 12px; background: var(--gruen-hell); color: var(--gruen-dunkel); }
.meldung.fehler { background: var(--rot-hell); color: var(--rot); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--flaeche); padding: 12px 16px; border-radius: 12px; max-width: calc(100vw - 32px);
}

.pin-karte { text-align: center; background: linear-gradient(160deg, var(--gruen), var(--gruen-dunkel)); color: #fff; border: none; }
.pin-karte .leise { color: rgb(255 255 255 / 85%); }
.pin { font-size: clamp(2.4rem, 12vw, 3.6rem); font-weight: 800; letter-spacing: .18em; font-variant-numeric: tabular-nums; margin: 8px 0; }
.pin-karte .knopf { background: #fff; color: var(--gruen-dunkel); }
.pin-karte .knopf.zweit { background: transparent; color: #fff; border-color: rgb(255 255 255 / 50%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pin-karte { background: linear-gradient(160deg, #2d6a2e, #1f4d20); }
  :root:not([data-theme="light"]) .pin-karte .knopf:not(.zweit) { color: #1f4d20; }
}

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--linie); }
.liste li:last-child { border-bottom: none; }

/* Chat */
.chat-knopf {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; min-height: 56px; padding: 0 24px; border-radius: 999px;
  border: none; background: var(--gold); color: #1c1608; font-weight: 700; box-shadow: var(--schatten); cursor: pointer;
}
.chat-verlauf { height: min(52vh, 420px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px; }
.blase { max-width: 85%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; }
.blase.gast { align-self: flex-end; background: var(--gruen); color: #fff; border-bottom-right-radius: 4px; }
.blase.assistent { align-self: flex-start; background: var(--grund); border-bottom-left-radius: 4px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .blase.gast { color: #0e120f; } }
.chat-eingabe { display: flex; gap: 8px; margin-top: 12px; }
.chat-eingabe input { flex: 1; }

/* Belegungsplan */
.plan { overflow-x: auto; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--flaeche); }
.plan table { border-collapse: separate; border-spacing: 4px; font-size: .75rem; }
.plan th { position: sticky; left: 0; background: var(--flaeche); text-align: left; padding: 4px 8px; white-space: nowrap; font-weight: 600; }
.plan td { width: 24px; height: 24px; padding: 0; border-radius: 4px; background: var(--gruen-hell); }
.plan td.belegt { background: var(--belegt); }
.plan td.meins { background: var(--gold); }
.plan td.vorbei { background: transparent; }
.plan thead th { font-weight: 400; color: var(--text-leise); }

/* Verwaltung */
.raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabelle th, .tabelle td { text-align: left; padding: 8px; border-bottom: 1px solid var(--linie); vertical-align: top; }
.lichter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.licht { min-height: 56px; border-radius: 12px; border: 1px solid var(--kante); background: var(--flaeche); cursor: pointer; font-weight: 600; }
.licht[aria-pressed="true"] { background: #f7e27a; color: #2a2405; border-color: #e0c43c; }
.protokoll { font: .8rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 340px; overflow: auto; }
.protokoll div { padding: 4px 0; border-bottom: 1px dashed var(--linie); }
.art { display: inline-block; min-width: 64px; font-weight: 700; }

.fuss { text-align: center; color: var(--text-leise); font-size: .8rem; padding: 32px 16px 96px; }
.versteckt { display: none !important; }
.vorfuehrung { background: #8a6508; color: #fff; text-align: center; font-size: .875rem; font-weight: 600; padding: 4px 16px; }
@media (max-width: 520px) {
  .kopf nav a { padding: 8px; font-size: .9rem; }
  .marke span { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .zeit, .chip, .platzwahl, .knopf { transition: background-color .15s, border-color .15s, color .15s; }
}
