/* ============================================================
   SUTC-Designtokens -- Farbwelt "Sonnengelb", Kanten "Eckig".
   Uebernommen aus dem Redesign-Prototyp:
     prim #d9a300 · dark #8f6c02 · tint #fdf3d6
     bg #faf7ef · border #eee5cf · Text/Akzent #26202a

   Kontrast: weisse Schrift auf reinem Sonnengelb waere 2,3:1 und damit
   unlesbar. Deshalb zwei Rollen:
     --sun  (#d9a300) traegt DUNKLE Schrift (--ink, 6,9:1) -> Kopfzeilen der
            Kalender, aktive Reiter, Primaerknopf, Symbol-Kacheln.
     --sun-deep (#8f6c02) traegt WEISSE Schrift (4,9:1) und ist ausserdem die
            Textfarbe auf Weiss -> "heute", Platz-Unterzeile, Links, Rahmen.
   ============================================================ */
:root {
    --sun: #d9a300;          /* Sonnengelb -- Akzentkanten, aktive Marker */
    --sun-deep: #8f6c02;     /* Tiefgold -- Flaechen + Text (lesbar) */
    --sun-deeper: #6f5301;   /* noch dunkler -- Hover, "heute", Text auf Tint */
    --sun-tint: #fdf3d6;     /* helle Flaeche (Buchungen, Hover) */
    --sun-tint2: #f6e7bd;    /* kraeftigere helle Flaeche (Trennlinien) */
    --ink: #26202a;          /* Schrift auf Sonnengelb (6,9:1) */

    /* Alias-Ebene: die bestehenden ~500 Zeilen heissen historisch --green.
       Namen bleiben, damit der Umbau farbig statt strukturell ist. */
    --green: var(--sun-deep);
    --green-dark: var(--sun-deeper);
    --accent: #b4532c;       /* Warnrot, waermer abgestimmt */
    --ball: var(--sun);
    --ball-soft: var(--sun-tint);
    --tint: var(--sun-tint);
    --tint2: var(--sun-tint2);
    --clay: #b4532c;
    --bg: #faf7ef;
    --card: #ffffff;
    --border: #eee5cf;
    --text: #26202a;
    --muted: #837c80;

    /* Eckige Kanten (Design-Variante "Eckig") */
    --radius: 6px;
    --r-card: 6px;
    --r-btn: 6px;
    --r-input: 6px;
    --r-chip: 4px;
    --r-cell: 3px;
    --shadow: 0 4px 16px rgba(0,0,0,.08);
    /* Hoehe der mobilen Bottom-Nav (fixe Position). Inhalt bekommt so viel
       padding-bottom, plus der Sicherheitsabstand fuers iPhone-Home-Indicator. */
    --tabbar-h: calc(61px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
/* Die Seite selbst darf NIE horizontal verschoben werden -- horizontales
   Scrollen passiert nur innerhalb der Grid-Container (.grid-wrap). */
html, body { overflow-x: hidden; max-width: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar (hell, damit das Vereinslogo wirkt) */
/* Kopfzeile -- identisch in allen Bereichen (Vorlage: Startseite).
   flex: 0 0 auto ist Pflicht: als Flex-Kind wuerde die Leiste sonst
   schrumpfen (gemessen 43 statt 56px). Hoehe ergibt sich aus Polster +
   Inhalt, dazu der Sicherheitsabstand fuer die iOS-Statusleiste. */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex: 0 0 auto;
    background: #fff; color: var(--text);
    padding: 10px 18px;
    padding-top: calc(10px + env(safe-area-inset-top));
    border-bottom: 2px solid var(--sun);
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    position: relative;
}
/* Marken-Lockup: Tennisball-Kachel + Klubbezeichnung zweizeilig (aus dem
   Design). Der Text kommt aus club_name -- erstes Wort gross, Rest gesperrt
   darunter. Der Kreis bleibt rund: im Design ist er auch in der Variante
   "Eckig" hart auf 50% gesetzt. */
.brand { display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand-badge {
    width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%;
    background: var(--ink); color: var(--sun);
    display: flex; align-items: center; justify-content: center;
}
.brand-badge svg { width: 18px; height: 18px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 800; font-size: 16px; color: var(--green); letter-spacing: .4px; }
.brand-sub {
    font-size: 8.5px; letter-spacing: 2.2px; color: var(--muted);
    font-weight: 600; text-transform: uppercase; white-space: nowrap;
}
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: var(--green); font-size: .95rem; font-weight: 600; }
.topbar nav a:hover { color: var(--accent); text-decoration: none; }
.who { color: var(--muted); font-size: .9rem; font-weight: 500; }
.btn-ghost {
    border: 1px solid var(--green); border-radius: var(--r-btn);
    padding: 6px 16px; background: transparent; color: var(--green); cursor: pointer;
    font-size: .85rem; font-weight: 600;
}
.btn-ghost:hover { background: var(--green); color: #fff; text-decoration: none; }
.btn-ghost.danger { border-color: #b71c1c; color: #b71c1c; }
.btn-ghost.danger:hover { background: #b71c1c; color: #fff; }
.list td .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }

/* Konto-Knopf (nur mobil sichtbar). Loest den Hamburger ab: die Bereichs-
   Navigation sitzt jetzt unten in der Tabbar, hier drin bleiben nur die
   app-eigenen Punkte (Meine Buchungen, Einstellungen, Verwaltung, Abmelden). */
.nav-toggle {
    display: none; align-items: center; justify-content: center;
    width: 34px; height: 34px; padding: 0;
    background: var(--tint); color: var(--green-dark);
    border: 1px solid var(--border); border-radius: var(--r-btn);
    font-size: 14px; font-weight: 700; line-height: 1; cursor: pointer;
}
.nav-toggle svg { width: 18px; height: 18px; display: block; }
.nav-toggle.open { background: var(--sun); color: var(--ink); border-color: var(--sun); }

/* Kalender-Navigation (Tabs + prev/next + Datepicker) */
.calnav {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px; margin-bottom: 10px;
    /* Beim Scrollen oben angepinnt, damit Tag/Woche + Datum sichtbar bleiben. */
    position: sticky; top: 0; z-index: 30;
    background: var(--bg); padding: 6px 0;
}
.view-tabs { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: var(--r-btn); overflow: hidden; }
.view-tabs a { padding: 8px 16px; font-size: .9rem; font-weight: 600; color: var(--muted); }
.view-tabs a:hover { background: #f4f4f2; text-decoration: none; }
.view-tabs a.active { background: var(--sun); color: var(--ink); }
.calnav-mid { display: flex; align-items: center; gap: 10px; }
.calnav-label { font-size: 1.1rem; font-weight: 700; min-width: 0; text-align: center; }
.nav-arrow { padding: 6px 12px; font-size: 1rem; line-height: 1; }
.calnav-end { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.calnav-end .btn-ghost { flex: 0 0 auto; white-space: nowrap; }

/* Datum = anklickbares Label (öffnet nativen Datepicker). Das Datum wird so
   nur EINMAL angezeigt -- kein separates Datumsfeld mehr. */
.date-form { display: inline-flex; align-items: center; }
.datebtn {
    position: relative; cursor: pointer; font: inherit;
    font-size: 1.1rem; font-weight: 700; color: var(--text);
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 8px; border-radius: var(--r-btn); white-space: nowrap;
    transition: background .15s;
}
.datebtn:hover { background: var(--tint); }
.cal-ic { font-size: .68em; color: var(--muted); }
/* Datums-Label: Vollversion (mit Jahr) auf Desktop, Kurzversion (ohne Jahr) mobil */
.lbl-short { display: none; }
/* echtes, transparentes date-Input exakt über dem Label -> Tippen öffnet auf
   dem Handy zuverlässig den nativen Picker (kein showPicker nötig). */
.date-overlay {
    position: absolute; inset: 0; width: 100%; height: 100%;
    margin: 0; padding: 0; border: 0; cursor: pointer;
    opacity: 0; background: transparent; color: transparent;
    -webkit-appearance: none; appearance: none;
}
.date-overlay::-webkit-calendar-picker-indicator { opacity: 0; }

/* Wochen-Grid (alle Buchungen kompakt) */
table.weekgrid { table-layout: fixed; }
table.weekgrid th { padding: 6px 4px; }
.wd-head { display: flex; flex-direction: column; color: var(--ink); }
.wd-head:hover { text-decoration: none; }
.wd-name { font-size: .85rem; font-weight: 700; }
.wd-date { font-size: .72rem; opacity: .85; }
table.weekgrid th.is-today { background: var(--sun-deep); }
table.weekgrid th.is-today .wd-head { color: #fff; }
.wkcell { padding: 2px; vertical-align: top; }
.wkcell.past { opacity: .6; }
.wkcell-link { display: flex; flex-direction: column; gap: 2px; min-height: 30px; padding: 2px; }
.wkcell-link:hover { text-decoration: none; background: var(--tint); border-radius: var(--r-cell); }
.wchip {
    display: flex; flex-direction: column; line-height: 1.15;
    border-radius: var(--r-cell); padding: 3px 5px; font-size: .68rem;
    border-left: 3px solid var(--green);
}
.wchip.booking { background: var(--tint); border-left-color: var(--green); }
.wchip.training { background: #fdf0dd; border-left-color: #b26a12; }
.wchip.block { background: #f0f0f0; border-left-color: #9aa0a6; color: var(--muted); }
.wchip-court { font-weight: 700; color: var(--green); font-size: .66rem; }
.wchip.training .wchip-court { color: #b26a12; }
.wchip.block .wchip-court { color: #6c7178; }
.wchip-who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wchip-time { color: var(--muted); font-size: .62rem; }

/* Legende */
.legend { margin-top: 12px; }
.lg { font-size: .74rem; padding: 2px 8px; border-radius: var(--r-chip); margin-right: 6px; font-weight: 600; }
.lg-booking { background: var(--tint); color: var(--green); }
.lg-training { background: #fdf0dd; color: #b26a12; }
.lg-block { background: #f0f0f0; color: #6c7178; }

/* Flash */
.flash { padding: 10px 14px; border-radius: var(--r-card); margin-bottom: 16px; font-size: .95rem; }
.flash-success { background: #eaf6ea; color: #2e6b32; border: 1px solid #b7ddb9; }
.flash-error { background: #fdecea; color: #b71c1c; border: 1px solid #ef9a9a; }
.flash-info { background: #e3f2fd; color: #0d47a1; border: 1px solid #90caf9; }

/* Day navigation */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.daytitle { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.daytitle h1 { margin: 0; font-size: 1.3rem; }
.datepick input { padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--r-input); }

/* Buttons -- Pillen-Form wie leihen */
.btn, .btn-primary, .btn-cancel {
    display: inline-block; border: none; border-radius: var(--r-btn); cursor: pointer;
    padding: 9px 18px; font-size: .9rem; font-weight: 600;
    transition: transform .05s ease, background .15s ease, opacity .15s;
}
.btn:active, .btn-primary:active, .btn-cancel:active { transform: scale(.97); }
.btn { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn:hover { background: #f0f0f0; text-decoration: none; }
.btn-primary { background: var(--sun); color: var(--ink); }
.btn-primary:hover { background: var(--sun-deep); color: #fff; }
.btn-cancel { background: #fff; color: var(--clay); border: 1px solid var(--clay); padding: 5px 12px; font-size: .78rem; }
.btn-cancel:hover { background: var(--clay); color: #fff; }

/* Grid / Kalender */
/* Wochenansicht scrollt innerhalb dieses Containers (max-height wird per JS
   auf die Fensterhöhe gesetzt). So bleibt der Tabellenkopf via position:sticky
   oben stehen -- auch beim horizontalen Scrollen auf Mobile. */
.grid-wrap { overflow: auto; max-width: 100%; -webkit-overflow-scrolling: touch; border-radius: var(--r-card); }

/* Tagesansicht: Swipe-Karussell (gestern | heute | morgen).
   Ohne JS zeigt translateX(-100%) einfach das mittlere Panel. */
.swipe-wrap {
    overflow: hidden; max-width: 100%;
    touch-action: pan-y;                /* vertikal scrollt der Browser, horizontal wischen wir */
    overscroll-behavior-x: contain;
}
.swipe-strip { display: flex; transform: translateX(-100%); will-change: transform; }
/* Jedes Panel scrollt vertikal selbst (max-height per JS = Fensterhöhe). Der
   Tabellenkopf pinnt dann via sticky an den oberen Panel-Rand. window-basiertes
   sticky geht hier nicht, weil die .swipe-wrap (overflow) der Scroll-Kontext wäre. */
.swipe-panel {
    flex: 0 0 100%; min-width: 100%;
    max-height: var(--day-h, 70vh);
    overflow-x: hidden; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--r-card);
}

/* "Jetzt"-Markierung: die aktuelle Uhrzeit in der Zeitspalte rot betonen. */
tr.now-row td.timecol { color: var(--green); font-weight: 700; }
/* Auto-Sprung zur aktuellen Zeit soll die Zeile NICHT hinter dem angepinnten
   Tabellenkopf verstecken -> passender Abstand (Kopfhöhe). */
tr.now-row { scroll-margin-top: var(--stick-h, 56px); }

/* Tabellenkopf der Tagesansicht beim Scrollen im Panel oben anpinnen.
   Nur die Tagesansicht (table.grid ohne .weekgrid2). */
table.grid:not(.weekgrid2) thead th {
    position: sticky; top: 0; z-index: 20;
    box-shadow: 0 2px 4px rgba(0,0,0,.12);
}
/* table-layout: fixed -> Spalten gleich breit, unabhängig vom Inhalt
   (Platz 1 und Platz 2 also immer gleich groß, auch wenn ein Platz leer ist) */
/* WICHTIG: kein overflow:hidden auf der Tabelle selbst -- das würde die Tabelle
   zum sticky-Kontext machen und den angepinnten thead beim Scrollen mitnehmen.
   Die runden Ecken übernimmt der Scroll-Container (.grid-wrap / .swipe-panel). */
table.grid { width: 100%; table-layout: fixed; border-collapse: collapse; background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
table.grid th, table.grid td { border: 1px solid var(--border); text-align: center; }
table.grid th { background: var(--sun); color: var(--ink); padding: 5px 6px; font-size: .82rem; }
.timecol { background: #f4f4f2; font-weight: 600; color: var(--muted); width: 62px; font-size: .8rem; }
.cell { height: 33px; vertical-align: middle; position: relative; }
.cell.free { cursor: pointer; transition: background .12s; }
.cell.free:hover { background: var(--tint); }
.cell.free .plus { color: #cdbfa4; font-size: 1.3rem; font-weight: 700; }
.cell.free:hover .plus { color: var(--green); }
.cell.taken { padding: 4px; }
.cell.taken.booking { background: var(--tint); }
.cell.taken.training { background: #fdf0dd; }
.cell.taken.meisterschaft { background: #e7edf9; }
.cell.taken.block { background: #f2f2f2; color: var(--muted); }
/* Meisterschaft-Text abgesetzt (blau); Serien-Kennzeichen */
.cell.taken.meisterschaft .bk strong { color: #2f579b; }
.weekgrid2 .cell.taken.meisterschaft .wk-who { color: #2f579b; }
.weekgrid2 .cell.taken.training .wk-who { color: #b26a12; }
.series-badge { color: var(--green); font-weight: 700; }
.bk { display: flex; flex-direction: column; gap: 2px; align-items: center; font-size: .8rem; }
.bk strong { font-size: .85rem; }
.bktime { color: var(--muted); font-size: .72rem; }
.bknote { font-style: italic; color: var(--muted); font-size: .72rem; }

/* Cards / Forms */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; font-size: 1.05rem; }
.auth { max-width: 380px; margin: 24px auto; }
.auth h1 { margin-top: 0; }
form label { display: block; margin-bottom: 12px; font-size: .9rem; font-weight: 600; }
form input, form select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-input); font-size: .95rem; margin-top: 4px; font-weight: 400; }
form input:focus, form select:focus { outline: 2px solid var(--green); border-color: var(--green); }
form .row { display: flex; gap: 12px; }
form .row label { flex: 1; }
.inline { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.inline input, .inline select { margin-top: 0; }
/* Checkbox darf nicht die globale width:100%-Regel erben -> sonst ragt sie
   (v.a. mobil) aus dem Bildschirm. Fixe Größe, Text nimmt den Rest. */
.inline input[type="checkbox"] { width: auto; flex: 0 0 auto; }
.muted { color: var(--muted); font-size: .9rem; }

/* Passwort anzeigen/verbergen */
.pw-wrap { position: relative; display: block; margin-top: 4px; }
.pw-wrap input { margin-top: 0 !important; padding-right: 88px !important; }
.pw-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: transparent; border: none; color: var(--green-dark);
    cursor: pointer; font-size: .8rem; font-weight: 600; padding: 4px 8px;
}
.pw-toggle:hover { text-decoration: underline; }

/* Listen / Tabellen */
table.list { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.list th { text-align: left; font-size: .8rem; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--border); }
table.list td { padding: 8px; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
.tag { font-size: .72rem; padding: 2px 8px; border-radius: var(--r-chip); font-weight: 600; }
.tag.ok { background: #eaf6ea; color: #2e6b32; }
.tag.off { background: #fdecea; color: #b71c1c; }

/* Admin layout */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.card-wide { grid-column: 1 / -1; }             /* Mitglieder über volle Breite */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table.list { min-width: 520px; }  /* auf schmalen Screens horizontal scrollen statt quetschen */

/* App-Shell (Kalender/Woche): Seite auf Fensterhöhe fixieren, nur die
   Kalenderfläche scrollt. Topbar, Navigation, Legende + Footer bleiben stehen. */
body.app-shell { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body.app-shell .container {
    flex: 1; min-height: 0; width: 100%; margin: 0 auto;
    padding-top: 12px; padding-bottom: 0;
    display: flex; flex-direction: column; overflow: hidden;
}
body.app-shell .footer { flex: 0 0 auto; padding: 8px 0; }
/* Wochenansicht darf breiter werden -> breitere Platz-Spalten auf Desktop */
body.week-view .container { max-width: 1500px; }
/* Tagesansicht: das Swipe-Panel füllt den Rest und scrollt intern */
body.app-shell .calnav { flex: 0 0 auto; }
body.app-shell .swipe-wrap { flex: 1; min-height: 0; }
body.app-shell .swipe-strip { height: 100%; }
body.app-shell .swipe-panel { max-height: none; height: 100%; }
/* Wochenansicht: der Grid-Container scrollt, Legende bleibt darunter sichtbar */
body.app-shell .grid-wrap { flex: 1; min-height: 0; max-height: none !important; }
body.app-shell .legend { flex: 0 0 auto; margin: 8px 0 0; }

/* Info-Dialog (nur Anzeige) */
.info-dl { margin: 8px 0 0; }
.info-dl > div { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.info-dl dt { flex: 0 0 96px; color: var(--muted); font-size: .82rem; margin: 0; }
.info-dl dd { margin: 0; font-size: .92rem; overflow-wrap: anywhere; }

/* Install-Hinweis im Menü nur auf Mobile (im Sandwich-Panel) */
.install-area-nav { display: none; }

/* Modal */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); align-items: center; justify-content: center; z-index: 50; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: var(--r-card); padding: 24px; width: 90%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.modal-actions .btn-ghost { border-color: var(--border); color: var(--text); }

/* Serien-Verwaltungsseite */
.serie-head { margin: 4px 0 14px; }
.serie-head h1 { margin: 6px 0 2px; font-size: 1.25rem; }
.serie-list tr.past { opacity: .55; }
.serie-list th:first-child, .serie-list td:first-child { text-align: center; }
.serie-actions h2 { margin-top: 0; font-size: 1.05rem; }
.serie-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.serie-btns .btn-cancel { font-size: .9rem; padding: 9px 16px; }

/* Footer */
.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 24px 0; }

/* PWA-Installation */
.install-area { margin: 16px 0; }
.install-btn { width: 100%; padding: 12px; font-size: 1rem; border-radius: var(--r-btn); }
.install-hint {
    background: var(--ball-soft); border: 1px solid #e6cf8a; color: #6b520b;
    border-radius: var(--r-card); padding: 12px 14px; font-size: .9rem; line-height: 1.45;
}

/* Einfarbige Symbole in Ueberschriften und Zeilentiteln (Makro ic() aus
   _icons.html). Groesse haengt an der Schriftgroesse der Umgebung. */
.ic {
    width: 1.05em; height: 1.05em;
    vertical-align: -.15em; flex: 0 0 auto;
}
.setting-title .ic { margin-right: 2px; }

/* Marke auf den Anmeldeseiten: Ball + Schriftzug statt Logo-Grafik. */
.auth-logo { text-align: center; margin: 14px auto 20px; max-width: 380px; }
.brandmark { display: inline-flex; flex-direction: column; align-items: center; gap: 12px; }
.brandmark-badge {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--ink); color: var(--sun);
    display: flex; align-items: center; justify-content: center;
}
.brandmark-badge svg { width: 38px; height: 38px; display: block; }
.brandmark-text { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.brandmark-name {
    font-weight: 800; font-size: 30px; line-height: 1;
    color: var(--green); letter-spacing: .6px;
}
.brandmark-sub {
    font-size: 11px; letter-spacing: 4px; color: var(--muted);
    font-weight: 600; text-transform: uppercase;
}

/* ---------- Vergangene / nicht buchbare Slots ---------- */
.cell.free.past {
    cursor: default; color: var(--muted);
    background: repeating-linear-gradient(45deg, #f5f2ea, #f5f2ea 6px, #ebe6d9 6px, #ebe6d9 12px);
}
.cell.free.past:hover {
    background: repeating-linear-gradient(45deg, #f5f2ea, #f5f2ea 6px, #ebe6d9 6px, #ebe6d9 12px);
}
.cell.free.past .plus { display: none; }

/* ---------- Editierbare Buchungen ---------- */
.cell.taken.editable { cursor: pointer; transition: filter .12s; }
.cell.taken.editable:hover { filter: brightness(.96); }
.bkedit { font-size: .68rem; color: var(--green-dark); opacity: .85; margin-top: 2px; }

/* ---------- Wochen-Grid mit beiden Plätzen ---------- */
/* border-collapse: separate ist nötig, damit position:sticky auf den
   Zellen der Zeit-Spalte in Chrome funktioniert. Rahmen daher pro Zelle
   nur rechts+unten, damit keine doppelten Linien entstehen. */
table.weekgrid2 {
    table-layout: fixed; width: 100%;
    border-collapse: separate; border-spacing: 0;
    /* KEIN overflow:hidden (aus .grid geerbt) -- sonst wird die Tabelle selbst
       zum Scroll-Container und die sticky Zeit-Spalte klebt an der falschen Kante. */
    overflow: visible; border-radius: 0;
}
table.weekgrid2 th, table.weekgrid2 td {
    border: 0;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
table.weekgrid2 th.wk-day {
    padding: 4px 4px; background: var(--sun); color: var(--ink); border-left: 2px solid #fff;
}
table.weekgrid2 th.wk-day.is-today { background: var(--sun-deep); color: #fff; }
table.weekgrid2 th.wk-day.is-today .wd-head { color: #fff; }
table.weekgrid2 th.wk-court {
    background: var(--sun-deep); color: #fff; font-size: .66rem;
    font-weight: 700; padding: 2px 2px;
}
.weekgrid2 td.timecol { width: 46px; }
.weekgrid2 .wk-cell { padding: 1px; height: 28px; }
.weekgrid2 .wk-cell.day-start,
table.weekgrid2 th.wk-court.day-start { border-left: 2px solid #e0cfa8; }
.weekgrid2 .cell.free .plus { font-size: 1rem; color: #cdbfa4; }
.weekgrid2 .cell.free:hover .plus { color: var(--green); }
.wk-bk { display: flex; flex-direction: column; line-height: 1.15; padding: 3px 4px; }
.wk-who { font-size: .7rem; font-weight: 700; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.wk-time { font-size: .62rem; color: var(--muted); }
.weekgrid2 .wk-cell { vertical-align: top; }
.weekgrid2 .cell.taken.booking .wk-who { color: var(--green); }
/* Zeit-Spalte beim horizontalen Scrollen fixieren (bleibt links stehen).
   Opaker Hintergrund + Schatten, damit die Buchungszellen dahinter durchscrollen. */
table.weekgrid2 .timecol {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #f4f4f2;
    box-shadow: 2px 0 5px rgba(0, 0, 0, .08);
}
/* Beim Ueberfahren einer Slot-Zeile die zugehoerige Uhrzeit hervorheben ->
   man sieht sofort, welche Zeit gerade anvisiert wird. tr:hover feuert fuer
   die ganze Zeile, also auch beim Zeigen auf eine Buchungs-/Frei-Zelle. */
table.weekgrid2 tbody tr:hover td.timecol {
    background: var(--tint);
    color: var(--green);
    font-weight: 700;
}
/* Tabellenkopf der Wochenansicht beim vertikalen Scrollen anpinnen.
   Zwei Kopfzeilen: Tagesnamen (oben) + Platz-Spalten (darunter). */
table.weekgrid2 thead th.wk-day { position: sticky; top: 0; z-index: 4; }
table.weekgrid2 thead th.wk-court { position: sticky; top: var(--wk-h1, 34px); z-index: 4; }
/* Ecke oben-links (Zeit) muss über allem liegen: sowohl links als auch oben. */
table.weekgrid2 thead .timecol { position: sticky; left: 0; top: 0; z-index: 6; }
/* "Zeit"-Kopfecke rot wie die übrigen Kopfzeilen (nicht grau wie die
   Body-Zeitspalte) -- sonst wirkt die Ecke gebrochen. */
table.weekgrid2 thead th.timecol { background: var(--sun); color: var(--ink); }

@media (max-width: 720px) {
    .nav-toggle { display: flex; }
    /* Nav wird zum Dropdown-Panel (hell, passend zum Topbar) */
    #mainNav {
        display: none; position: absolute; top: 100%; right: 0; left: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        background: #fff; padding: 6px 0; z-index: 40;
        border-bottom: 3px solid var(--green);
        box-shadow: 0 10px 24px rgba(0,0,0,.14);
    }
    #mainNav.open { display: flex; }
    #mainNav a, #mainNav .who {
        padding: 13px 22px; font-size: 1.02rem; display: block;
        border-top: 1px solid var(--border);
    }
    #mainNav a:first-child { border-top: none; }
    #mainNav .who { display: block; color: var(--muted); font-weight: 600; }
    #mainNav .btn-ghost { margin: 10px 22px; text-align: center; }
    #mainNav .install-area-nav { display: block; margin: 8px 22px 4px; }
    #mainNav .install-area-nav .install-hint { font-size: .9rem; }

    /* Kalender-Nav in EINER Zeile: Tag/Woche + ← Datum → + Heute. nowrap ->
       nichts bricht je um; wird es eng, kürzt das Datums-Label mit "…". */
    .calnav { gap: 6px; flex-wrap: nowrap; }
    .view-tabs { flex: 0 0 auto; }
    .view-tabs a { text-align: center; padding: 6px 10px; font-size: .82rem; }
    .calnav-mid { order: 2; flex: 1 1 auto; min-width: 0; gap: 2px; justify-content: center; }
    .calnav-mid .nav-arrow { flex: 0 0 auto; padding: 5px 8px; }
    .calnav-label, .datebtn { font-size: .9rem; }
    .date-form { min-width: 0; }                       /* darf schrumpfen */
    .datebtn { padding: 4px 4px; min-width: 0; overflow: hidden; }
    .datebtn .lbl-short, .datebtn .lbl-full {
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
    }
    .cal-ic { flex: 0 0 auto; }
    .calnav-end { order: 3; flex: 0 0 auto; margin-left: auto; gap: 8px; }
    .calnav-end .btn-ghost { padding: 5px 12px; }

    /* Datum-Kurzform (ohne Jahr) -> passt neben Tag/Woche */
    .lbl-full { display: none; }
    .lbl-short { display: inline; }

    /* Seitenränder weg: im App-Modus das horizontale Container-Padding
       entfernen -> Grid füllt die volle Breite (randlos, Tag + Woche).
       calnav + Flash bekommen ihren Innenabstand separat zurück. */
    body.app-shell .container { padding-left: 0; padding-right: 0; }
    body.app-shell .calnav { padding-left: 12px; padding-right: 12px; }
    body.app-shell .flash { margin-left: 12px; margin-right: 12px; }
    body.app-shell .grid-wrap, body.app-shell .swipe-panel { border-radius: 0; }

    /* Tagesansicht: schmale Zeilen + kompakte Zeitspalte */
    .timecol { width: 52px; font-size: .72rem; padding: 3px 2px; }
    table.grid th { padding: 4px 4px; font-size: .78rem; }
    .daynav .btn { padding: 8px 10px; }

    /* Wochen-Grid mobil: 3,5 Tage (= 7 Platz-Spalten) passen auf den Schirm,
       der Rest wird horizontal gescrollt. Das Grid ist jetzt randlos (volle
       Viewport-Breite): sichtbar = Zeitspalte(38) + 7 Platz-Spalten = 100vw.
       Gesamt = 38 + 14 Spalten -> width = 2*100vw - 38px.
       table-layout:fixed teilt den Rest nach der 38px-Zeitspalte gleich auf. */
    table.weekgrid2 { width: calc(200vw - 38px); min-width: 0; }
    .weekgrid2 td.timecol, .weekgrid2 th.timecol { width: 38px; font-size: .64rem; }
    .weekgrid2 .wk-cell { height: 34px; }        /* minimal höher (Touch/Lesbarkeit) */
    table.weekgrid2 th.wk-day { font-size: .68rem; padding: 3px 1px; }
    table.weekgrid2 th.wk-court { font-size: .58rem; }
    .weekgrid2 .wd-date { font-size: .58rem; }
    .weekgrid2 .wk-bk { padding: 2px 2px; }
    .wk-who { font-size: .58rem; }
    .wk-time { font-size: .5rem; }

    /* Fussleiste mobil ueberall weg -- die Startseite hat auch keine,
       und unten sitzt ohnehin die Bereichs-Leiste. */
    .footer { display: none; }
}

/* Push-Erinnerung: Modus-Auswahl (Einstellungen) */
.reminder-fs {
    border: 1px solid var(--line, #ddd);
    border-radius: var(--r-card);
    padding: 8px 12px 12px;
    margin: 8px 0;
    /* Fieldsets haben per Default min-width:min-content und wachsen sonst
       breiter als die Karte (v.a. mit dem iOS-Zeitfeld). */
    min-width: 0;
    max-width: 100%;
}
.reminder-fs legend { padding: 0 6px; font-weight: 600; font-size: .9rem; }
.reminder-fs .radio-row {
    display: flex; align-items: center; gap: 8px;
    flex-direction: row; margin: 6px 0 2px; cursor: pointer;
}
.reminder-fs .radio-row input { width: auto; margin: 0; }
.reminder-opt { margin: 0 0 6px 26px; }
.reminder-opt.disabled { opacity: .4; pointer-events: none; }
/* Uhrzeit-Feld: natürliche Breite statt 100% -- iOS rendert time-Inputs
   sonst über den Karten-Rand hinaus. */
.reminder-opt input[type="time"] {
    width: auto;
    max-width: 100%;
    min-width: 0;
    margin-left: 8px;
}
.range-label span { display: block; margin-bottom: 4px; font-size: .85rem; }
.range-label input[type=range] { width: 100%; }
/* Slider und Radios in Vereinsfarbe statt System-Blau */
input[type=range], input[type=radio] { accent-color: var(--green); }

/* ---- Einstellungen: Benachrichtigungen (Switch-Design) ---- */
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.setting-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 12px 0; border-top: 1px solid var(--border);
}
.setting-row:first-of-type { border-top: 0; }
.setting-main { flex: 1; min-width: 0; }
.setting-title { font-weight: 600; }
.setting-desc { margin: 2px 0 0; font-size: .85rem; color: var(--muted); }
.setting-sub {
    margin: 2px 0 12px 10px; padding: 2px 0 2px 14px;
    border-left: 3px solid var(--tint2);
}
.setting-sub.hidden { display: none; }
.setting-sub .setting-sub { margin-bottom: 4px; }
/* Uhrzeit-Feld: natürliche Breite statt 100% -- iOS rendert time-Inputs
   sonst über den Karten-Rand hinaus. */
.setting-sub input[type="time"] {
    width: auto;
    max-width: 100%;
    min-width: 0;
    margin-left: 8px;
}

.choice-row {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 0; cursor: pointer;
}
.choice-row input[type=radio] { width: auto; margin: 3px 0 0; flex: none; }
.choice-row .setting-main { display: block; }
.choice-row .setting-title { display: block; }
.choice-row .setting-desc { display: block; }

/* iOS-artiger Schalter (echte Checkbox darunter) */
.switch { position: relative; flex: none; width: 48px; height: 28px; display: inline-block; }
.switch input {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; margin: 0; cursor: pointer; z-index: 1;
}
.switch .track {
    position: absolute; inset: 0; border-radius: var(--r-btn);
    background: #d5cbb4; transition: background .18s ease;
}
.switch .track::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 22px; height: 22px; border-radius: 3px;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35);
    transition: transform .18s ease;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:disabled + .track { opacity: .45; }
.switch input:focus-visible + .track { outline: 2px solid var(--green); outline-offset: 2px; }

/* Auto-Speichern-Hinweis */
.saved-note {
    flex: none; font-size: .85rem; font-weight: 600; color: #2e7d32;
    opacity: 0; transition: opacity .25s ease;
}
.saved-note.show { opacity: 1; }
.saved-note.error { color: var(--accent); }

/* Aufklappbare Hilfe (iOS-Hinweis) */
.setting-help { margin-top: 8px; font-size: .9rem; }
.setting-help summary { cursor: pointer; color: var(--muted); }
.setting-help p {
    margin: 8px 0 0; padding: 10px 12px; border-radius: var(--r-card);
    background: var(--ball-soft); font-size: .88rem;
}

/* Termin-Art 'Sonstiges' (Freitext): gruene Kacheln analog zu Training/Meisterschaft */
.cell.taken.sonstig { background: #e4f2e4; }
.cell.taken.sonstig .bk strong { color: #2f7d3a; }
.weekgrid2 .cell.taken.sonstig .wk-who { color: #2f7d3a; }
.wchip.sonstig { background: #e4f2e4; border-left-color: #3f9a4d; }
.wchip.sonstig .wchip-court { color: #2f7d3a; }

/* ============================================================
   Mobile Bereichs-Navigation unten (Design: 4 Tabs mit Symbolen)
   Wechselt zwischen den SUTC-Apps. Die app-eigenen Punkte bleiben
   hinter dem Konto-Knopf in der Kopfzeile.

   WICHTIG: die Leiste ist ein normales Flex-Kind von <body>, kein
   position:fixed. Dadurch schrumpft im App-Shell-Modus die Kalender-
   flaeche automatisch mit -- Zellenhoehen und die randlose mobile
   Grid-Metrik bleiben unveraendert.
   ============================================================ */
.tabbar { display: none; }

@media (max-width: 720px) {
    /* ---- Feste App-Huelle: Header oben, Tab-Leiste unten, Inhalt scrollt in
       der Mitte. Einheitlich in allen SUTC-Apps. ----
       Der body scrollt NICHT (overflow:hidden), nur <main> scrollt intern.
       Ohne Body-Scroll animiert iOS die Adressleiste nicht -> die fixe
       Tab-Leiste bleibt ruhig am unteren Rand. padding-bottom haelt den
       Inhalt ueber der Leiste frei (border-box zieht es von 100dvh ab).
       Die Kalender-Ansicht (body.app-shell) bringt height/overflow/flex
       schon selbst mit; hier gilt es fuer die uebrigen Seiten. */
    body {
        height: 100dvh; overflow: hidden;
        display: flex; flex-direction: column;
        padding-bottom: var(--tabbar-h);
    }
    .topbar { flex: 0 0 auto; }
    /* Nur die Nicht-Kalender-Seiten scrollen den Container intern. Die
       Kalender-Ansicht (body.app-shell .container) hat eigene, spezifischere
       Regeln (overflow:hidden fuer das interne Grid-Scrollen). */
    body:not(.app-shell) > main.container {
        flex: 1 1 auto; min-height: 0; width: 100%; min-width: 0;
        margin: 0 auto;
        overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
    }

    .tabbar {
        display: grid; grid-template-columns: repeat(4, 1fr);
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
        background: #fff;
        border-top: 1px solid var(--border);
        padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 10px rgba(0,0,0,.05);
    }
    .tabbar a {
        display: flex; flex-direction: column; align-items: center; gap: 3px;
        color: #8a858a; padding-top: 4px; margin-top: -2px;
        border-top: 2px solid transparent;
    }
    .tabbar a:hover { text-decoration: none; }
    .tabbar a.is-active { color: var(--green); border-top-color: var(--sun); }
    .tabbar svg { display: block; width: 21px; height: 21px; }
    .tabbar .tab-label { font-size: 10.5px; font-weight: 700; }

    /* Bereichs-Links doppeln sich sonst mit der Tabbar -> im Konto-Menue weg. */
    #mainNav .nav-cross, #mainNav .nav-home { display: none; }
}

/* ============================================================
   Installierter App-Modus (iOS Standalone)
   position:fixed bottom:0 verankert sich im Standalone am Layout- statt
   am sichtbaren Viewport -> die Leiste rutschte unter den Rand. Hier als
   Flex-Kind unten in die Spalte. Gilt auch fuer die Kalender-Ansicht
   (body.app-shell), daher beide Selektoren. 100vh ist im Standalone
   stabil (keine dynamische Chrome). */
@media (display-mode: standalone) and (max-width: 720px) {
  body, body.app-shell { height: 100vh; padding-bottom: 0; }
  .tabbar { position: static; flex: 0 0 auto; }
}
