:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #687385;
  --line: #e2e6ec;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e0f2f1;
  --yes: #15803d;
  --yes-soft: #dcfce7;
  --no: #b91c1c;
  --no-soft: #fee2e2;
  --maybe: #a16207;
  --maybe-soft: #fef3c7;
  --game: #c2410c;
  --game-soft: #ffedd5;
  --other: #6d28d9;
  --other-soft: #ede9fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 2px 8px rgb(0 0 0 / .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --card: #182028;
    --text: #e6eaef;
    --muted: #94a0b0;
    --line: #2a3542;
    --brand: #2dd4bf;
    --brand-ink: #062b27;
    --brand-soft: #123532;
    --yes: #4ade80;
    --yes-soft: #143322;
    --no: #f87171;
    --no-soft: #3a1717;
    --maybe: #facc15;
    --maybe-soft: #3a3110;
    --game: #fb923c;
    --game-soft: #3b2110;
    --other: #a78bfa;
    --other-soft: #271d43;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 20px 0 8px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; }

/* Kopfzeile */
header { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 10px; max-width: 860px; margin: 0 auto; padding: 8px 16px; }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
#team-switch { flex: 1; min-width: 0; max-width: 320px; }
#nav { display: flex; max-width: 860px; margin: 0 auto; overflow-x: auto; }
#nav a { flex: 1; text-align: center; padding: 10px 8px; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
#nav a.active { color: var(--brand); border-color: var(--brand); }

main { max-width: 860px; margin: 0 auto; padding: 16px 16px 80px; }

/* Bausteine */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
button.ghost, .btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: transparent; color: var(--no); border-color: var(--line); }
button.small, .btn.small { padding: 4px 10px; font-size: .85rem; }
button.link { background: none; border: 0; color: var(--brand); padding: 0; font-weight: 500; }

input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
.badge.training { background: var(--brand-soft); color: var(--brand); }
.badge.game { background: var(--game-soft); color: var(--game); }
.badge.other { background: var(--other-soft); color: var(--other); }
.badge.cat { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.pin { background: var(--maybe-soft); color: var(--maybe); }

/* Terminliste */
.event-card { display: grid; grid-template-columns: 56px 1fr; gap: 12px; color: var(--text); border-left: 4px solid var(--brand); }
.event-card.game { border-left-color: var(--game); }
.event-card.other { border-left-color: var(--other); }
.datebox { text-align: center; line-height: 1.1; }
.datebox .wd { font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.datebox .d { font-size: 1.5rem; font-weight: 700; }
.datebox .m { font-size: .75rem; color: var(--muted); }
.meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }

/* Zu-/Absage */
.rsvp { display: flex; gap: 6px; flex-wrap: wrap; }
.rsvp button { background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
.rsvp button.yes.on { background: var(--yes-soft); color: var(--yes); border-color: var(--yes); }
.rsvp button.maybe.on { background: var(--maybe-soft); color: var(--maybe); border-color: var(--maybe); }
.rsvp button.no.on { background: var(--no-soft); color: var(--no); border-color: var(--no); }
.counts { display: flex; gap: 10px; font-size: .85rem; font-weight: 600; }
.c-yes { color: var(--yes); } .c-no { color: var(--no); } .c-maybe { color: var(--maybe); }
.bar-yes { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; display: flex; }
.bar-yes span { display: block; height: 100%; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0 12px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a.active { color: var(--text); border-color: var(--brand); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--line); }
.dot.yes { background: var(--yes); } .dot.no { background: var(--no); } .dot.maybe { background: var(--maybe); }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: #fff; }

/* Trainingsplan */
.plan-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: start; }
.plan-time { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.plan-edit { display: grid; grid-template-columns: 1fr 80px auto; gap: 6px; align-items: center; }
details summary { cursor: pointer; color: var(--muted); font-size: .85rem; }

/* Chat */
.chat { display: flex; flex-direction: column; height: min(65vh, 600px); }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 2px 8px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 80%; padding: 6px 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.msg.system { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: .85rem; text-align: center; max-width: 95%; }
.msg .who { font-size: .75rem; font-weight: 700; color: var(--brand); }
.msg .when { font-size: .7rem; color: var(--muted); margin-left: 6px; }
.chat-form { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }

/* Mitfahrten */
.seats { display: flex; gap: 4px; }
.seat { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--brand); }
.seat.taken { background: var(--brand); }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.auth { max-width: 380px; margin: 8vh auto 0; }
.fab { position: fixed; right: 20px; bottom: 20px; border-radius: 99px; padding: 12px 18px; box-shadow: 0 4px 14px rgb(0 0 0 / .2); }
.code { font: 700 1.4rem ui-monospace, Consolas, monospace; letter-spacing: .15em; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(100px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; transition: transform .2s; z-index: 50; max-width: calc(100% - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }
