:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #15181d;
  --muted: #5d6673;
  --line: #dde1e7;
  --accent: #0b5fa5;
  --accent-ink: #ffffff;
  --badge: #eef3f8;
  --warn: #8a4b00;
  --warn-bg: #fdf1e2;
  --radius: 12px;
  /* echte Hoehe der Kopfzeile, von app.js gesetzt - der Titel kann umbrechen */
  --top-h: 61px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --card: #1d2127;
    --ink: #eef1f5;
    --muted: #9aa4b2;
    --line: #2d333c;
    --accent: #6cb6ff;
    --accent-ink: #0d1117;
    --badge: #252b33;
    --warn: #ffcf96;
    --warn-bg: #3a2a12;
  }
}

* { box-sizing: border-box; }
/* Jede eigene display-Regel schlaegt sonst das hidden-Attribut - genau so stand
   erst das Menue dauerhaft offen und danach der Nachlade-Knopf. Einmal global
   statt pro Element. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
main { padding: 0 16px 96px; max-width: 42rem; margin: 0 auto; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: .98rem; line-height: 1.3; margin: 0; font-weight: 650; flex: 1; min-width: 0; }

.icon-button {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  background: none; border: 1px solid var(--line); border-radius: 10px;
  color: inherit; cursor: pointer;
}
.icon-button svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round;
  transition: transform .25s ease;
}
.icon-button[aria-expanded="true"] svg { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) {
  .icon-button svg { transition: none; }
}

nav {
  position: sticky; top: var(--top-h); z-index: 19;
  display: flex; flex-direction: column;
  background: var(--card); border-bottom: 1px solid var(--line);
}

nav a { padding: 14px 16px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); }
nav a[aria-current="page"] { font-weight: 650; color: var(--accent); }
nav #export-ics, nav #subscribe-ics, nav #whatsapp {
  color: var(--accent); display: flex; align-items: center; gap: 8px;
}
nav #whatsapp { color: #1f9d55; }
@media (prefers-color-scheme: dark) {
  nav #whatsapp { color: #4ddb8a; }
}
.menu-label {
  margin: 0; padding: 12px 16px 4px; border-top: 1px solid var(--line);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}

form#filters { margin: 16px 0 8px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { padding: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: inherit; font-size: .92rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip[disabled] { opacity: .45; cursor: default; }
.chip[disabled]:hover { background: var(--card); }
.chip .count { opacity: .7; font-variant-numeric: tabular-nums; }

/* Monatsansicht statt Von/Bis-Feldern */
.calendar {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px 6px;
  margin-bottom: 12px;
}
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head strong { flex: 1; text-align: center; font-size: .98rem; }
.cal-nav {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  background: none; border: 1px solid var(--line); border-radius: 10px;
  color: inherit; cursor: pointer;
}
.cal-nav[disabled] { opacity: .35; cursor: default; }
.cal-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-weekdays {
  margin-bottom: 4px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); text-align: center;
}
.cal-day {
  font: inherit; font-variant-numeric: tabular-nums;
  aspect-ratio: 1 / 1; min-height: 38px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 9px;
  background: none; color: var(--muted); cursor: default; padding: 0;
}
.cal-day.blank { visibility: hidden; }
/* Tage mit Terminen sind die einzigen, die etwas tun. */
.cal-day.has-events {
  background: var(--accent); color: var(--accent-ink);
  font-weight: 650; cursor: pointer;
}
.cal-day.has-events:hover { filter: brightness(1.08); }
.cal-day.today { border-color: var(--ink); }
.cal-day.outside { opacity: .3; }

.wide-button {
  display: block; width: 100%; padding: 12px; margin: 8px 0;
  font: inherit; background: var(--card); color: var(--accent);
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}

.status { color: var(--muted); font-size: .92rem; margin: 10px 0; }

.day { margin-top: 18px; }

.day { scroll-margin-top: calc(var(--top-h) + 9px); }
.day > h2 {
  position: sticky; top: var(--top-h);
  margin: 0 -16px 8px; padding: 6px 16px;
  font-size: .88rem; font-weight: 650; color: var(--muted);
  background: var(--bg);
}
/* Auf dem Handy steht die Zeit ueber dem Titel: eine Zeitspalte daneben frisst
   ein Drittel der 375px und zwingt fast jeden Hallennamen in den Umbruch. */
.event {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "when add" "body body";
  gap: 2px 10px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 8px;
}
.event .when {
  grid-area: when;
  font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap;
}
.event .body { grid-area: body; min-width: 0; }
.event .title { font-weight: 600; }
.event .where { font-size: .9rem; color: var(--muted); }
.event .where a { color: inherit; }
.event.off .title { text-decoration: line-through; }
.badge {
  display: inline-block; margin-top: 6px; padding: 3px 8px;
  font-size: .82rem; border-radius: 8px; background: var(--badge); color: var(--muted);
}
.badge.off { background: var(--warn-bg); color: var(--warn); }
.event .add {
  grid-area: add;
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--accent);
}
.event .add svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.inline-icon { width: 18px; height: 18px; vertical-align: -4px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.hint { font-size: .86rem; color: var(--muted); }

/* Anmeldeformular */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 14px 0;
}
.checks { display: flex; flex-direction: column; }
label.row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
label.row.stacked { flex-direction: column; align-items: stretch; gap: 5px; }
label.row.stacked > span { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; }
input[type="email"] {
  font: inherit; padding: 11px 12px; width: 100%;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink);
}
#signup button {
  font: inherit; width: 100%; padding: 12px; margin-top: 12px;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
#signup button[disabled] { opacity: .5; cursor: default; }
#signup-status { margin-top: 10px; }
#signup-status.bad { color: var(--warn); }
#sentinel { height: 1px; }

/* Overlay unten rechts: erscheint erst, wenn es etwas zu scrollen gibt. */
.to-top {
  position: fixed; z-index: 30;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 48px; height: 48px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--card); color: var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  cursor: pointer;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.to-top.show { opacity: 1; transform: none; }
.to-top svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) {
  .to-top { transition: none; }
}

h2 { font-size: 1.1rem; }
a { color: var(--accent); }

@media (min-width: 560px) {
  nav { flex-direction: row; flex-wrap: wrap; align-items: center; }
  nav a { border-top: 0; }
  .menu-label { border-top: 0; padding: 12px 16px; width: 100%; }
  .event {
    grid-template-columns: 7.5rem 1fr auto;
    grid-template-areas: "when body add";
    align-items: start;
  }
  .event .when { padding-top: 2px; }
}
