/* Systemschriften – keine externen Fonts. Große Bedienelemente für die Nutzung am Wasser. */
:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --text: #14232b;
  --muted: #53656e;
  --border: #c9d5da;
  --primary: #0b5d7a;
  --primary-text: #ffffff;
  --secondary: #e3eef2;
  --danger: #b3261e;
  --ok-bg: #e3f4e6; --ok-text: #1d5b2a;
  --warn-bg: #fff4d6; --warn-text: #6a4b00;
  --error-bg: #fde7e5; --error-text: #8c1d17;
  --info-bg: #e5f0fb; --info-text: #17456f;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1619;
    --surface: #172328;
    --text: #e6eef1;
    --muted: #9fb2ba;
    --border: #2f4149;
    --primary: #4cb0d4;
    --primary-text: #06212b;
    --secondary: #22363e;
    --danger: #ff8a80;
    --ok-bg: #173a22; --ok-text: #b7e6c2;
    --warn-bg: #3a300f; --warn-text: #f5dc92;
    --error-bg: #401a18; --error-text: #ffb4ab;
    --info-bg: #15304a; --info-text: #b6d6f7;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
main.narrow { max-width: 440px; padding-top: 32px; }
main.wide { max-width: 1100px; }

h1, h2, h3 { line-height: 1.2; }
h2 { font-size: 1.3rem; margin: 28px 0 12px; }
h3 { font-size: 1.1rem; margin: 24px 0 10px; }
a { color: var(--primary); }

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.03em; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 6px 0; }
.center { text-align: center; }
.loading { padding: 32px; text-align: center; color: var(--muted); }

/* --- Kopfzeile & Navigation --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--primary); color: var(--primary-text);
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar .who { font-size: 0.85rem; opacity: 0.9; white-space: nowrap; }
.topbar .btn { background: transparent; color: inherit; border-color: currentColor; }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 16px 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--primary); font-weight: 600; }

.brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 20px; }
.brand h1 { margin: 0; font-size: 2rem; }
.brand img { border-radius: 14px; }

/* --- Karten, Formulare --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field.inline { display: flex; align-items: center; gap: 10px; }
.field.inline label { margin: 0; }

input, select, textarea {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
}
textarea { min-height: auto; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
input[type="checkbox"] { width: 28px; height: 28px; min-height: 0; accent-color: var(--primary); vertical-align: middle; }
input.short { width: 7.5em; }
.field.inline select { width: auto; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check.big { display: flex; font-weight: 600; margin: 4px 0 18px; min-height: 44px; }

.stepper { display: flex; gap: 8px; }
.stepper input { text-align: center; font-size: 1.3rem; font-weight: 600; }
.btn-step { min-width: 60px; font-size: 1.6rem; padding: 0; }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row .field { margin-bottom: 0; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  font: inherit; font-weight: 600; text-decoration: none; text-align: center;
  color: var(--text); background: var(--secondary);
  border: 2px solid transparent; border-radius: 10px;
  cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-secondary { background: var(--secondary); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-link { background: transparent; color: var(--primary); }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }
.btn-big { display: flex; width: 100%; min-height: 56px; font-size: 1.1rem; margin: 12px 0; }
.btn-huge { display: flex; width: 100%; min-height: 72px; font-size: 1.35rem; margin: 12px 0; }
form .btn-link, form .btn-danger { display: flex; width: 100%; margin-top: 8px; }

.actions { margin: 8px 0 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.toolbar select { width: auto; min-height: 44px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- Meldungen --- */
.msg { padding: 12px 14px; border-radius: 10px; margin: 12px 0; }
.msg .btn { margin-left: 6px; }
.msg-error { background: var(--error-bg); color: var(--error-text); }
.msg-warn { background: var(--warn-bg); color: var(--warn-text); }
.msg-ok { background: var(--ok-bg); color: var(--ok-text); }
.msg-info { background: var(--info-bg); color: var(--info-text); }

.badge { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 6px; font-size: 0.85rem; }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-error { background: var(--error-bg); color: var(--error-text); }

/* --- Übersicht --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 12px 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.summary .tile { background: var(--secondary); border: 0; }
.tile strong { display: block; font-size: 2rem; line-height: 1.1; }
.tile span { color: var(--muted); font-size: 0.9rem; }
.species-list { margin: 8px 0 0; color: var(--muted); }

.entries { list-style: none; padding: 0; margin: 0; }
.entry {
  display: block; padding: 14px 16px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--primary);
  border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.entry.trip { border-left-color: var(--muted); }
.entry-head { display: flex; justify-content: space-between; gap: 12px; }
.entry-head span { color: var(--muted); text-align: right; }

/* --- Tabellen (Admin) --- */
.table-wrap { overflow-x: auto; margin: 8px 0 16px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 0.95rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--secondary); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; }
td.empty { color: var(--muted); text-align: center; }
input[type="search"] { max-width: 320px; }

.list-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-row input:not([type="checkbox"]) { flex: 1 1 220px; width: auto; }
.list-row .msg, .list-row > div:last-child:empty { flex-basis: 100%; }

.species-row {
  display: grid; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border);
  grid-template-columns: minmax(140px, 1.5fr) repeat(4, minmax(80px, 1fr)) 90px 110px;
}
.species-row input.short { width: 100%; }
.species-head { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.span-all { grid-column: 1 / -1; }
.span-all:empty { display: none; }
@media (max-width: 760px) {
  .species-row { grid-template-columns: 1fr 1fr; }
  .species-row input:first-child { grid-column: 1 / -1; }
  .species-head { display: none; }
}

/* --- Zettel zum Aushändigen --- */
.slips { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.slip { border: 2px dashed var(--border); border-radius: 8px; padding: 14px; background: var(--surface); break-inside: avoid; }
.slip-title { font-weight: 700; margin-bottom: 8px; }
.slip dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0 0 8px; }
.slip dt { color: var(--muted); }
.slip dd { margin: 0; }
.slip dd.big { font-size: 1.25rem; font-weight: 700; }
.slip ol { margin: 6px 0; padding-left: 20px; font-size: 0.9rem; }
.slip-note { font-size: 0.8rem; color: var(--muted); margin: 6px 0 0; }

/* --- Druck (Zettel, Auswertung als PDF) --- */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --border: #999; --secondary: #eee; }
  body { font-size: 11pt; background: #fff; }
  .no-print, .topbar, .tabs { display: none !important; }
  main, main.wide { max-width: none; padding: 0; }
  .tile { border: 1px solid #999; }
  .table-wrap { overflow: visible; }
  body.print-slips main > div > :not(:nth-child(2)) { display: none !important; }
  body.print-slips .slips { grid-template-columns: 1fr 1fr; gap: 0; }
  body.print-slips .slip { border-radius: 0; margin: 0; }
}

/* --- Mitglieder-Navigation unten --- */
main.with-nav { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  position: relative; flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 60px; font-weight: 600; text-decoration: none; color: var(--muted);
  border-top: 3px solid transparent;
}
.bottom-nav a.active { color: var(--primary); border-top-color: var(--primary); }
.bottom-nav .dot { width: 10px; height: 10px; margin-left: 6px; border-radius: 50%; background: var(--danger); }

.topbar .back { color: inherit; text-decoration: none; font-size: 1.5rem; padding: 0 8px 0 0; }
.topbar:has(.back) { justify-content: flex-start; }
.subtabs { position: sticky; top: 52px; z-index: 9; }

/* --- Mitteilungen --- */
.announcement h2, .announcement h3 { margin: 4px 0 8px; }
.announcement.unread { border-left: 6px solid var(--primary); }
.announcement .meta, .event .meta { color: var(--muted); font-size: 0.9rem; display: flex; gap: 8px; align-items: center; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.badge-new { background: var(--primary); color: var(--primary-text); margin-top: 0; }
.announcement-banner { display: block; text-decoration: none; }
.entry .badge + .badge { margin-left: 6px; }

/* --- Gruppen --- */
.event h2 { margin: 4px 0 8px; }
.event .row-actions { margin-top: 12px; }
.invite-code { font-size: 1.8rem; font-weight: 700; text-align: center; margin: 12px 0; letter-spacing: 0.08em; }
.member-list { list-style: none; padding: 0; margin: 0; }
.member-list li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.member-list li > span:first-child { flex: 1 1 auto; }

.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bubble {
  max-width: 85%; padding: 8px 12px; border-radius: 14px 14px 14px 4px;
  background: var(--surface); border: 1px solid var(--border); align-self: flex-start;
}
.bubble.mine { align-self: flex-end; background: var(--secondary); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.bubble .author { font-size: 0.85rem; font-weight: 700; color: var(--primary); }
.bubble .time { font-size: 0.75rem; color: var(--muted); text-align: right; margin-top: 2px; }
.chat-form {
  position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end;
  background: var(--bg); padding: 8px 0;
}
.chat-form textarea { flex: 1; min-height: 52px; }
.subtabs { padding: 4px 8px 0; gap: 0; }
.subtabs a { padding: 10px 9px; font-size: 0.95rem; }

/* --- QR-Code auf den Zetteln --- */
.slip-body { display: flex; gap: 12px; align-items: flex-start; }
.slip-body > div { flex: 1; min-width: 0; }
.slip-qr { margin: 0; flex: 0 0 auto; text-align: center; }
.slip-qr .qr { display: block; width: 34mm; height: 34mm; }
.slip-qr figcaption { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.event.unread { border-left: 6px solid var(--primary); }
.event h3 { margin: 4px 0 8px; }
.announcement-banner > div + div { margin-top: 6px; }
td.num, th.num { white-space: nowrap; }

/* --- Bilder im Chat --- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn-photo { min-width: 52px; min-height: 52px; padding: 0; font-size: 1.4rem; }
.bubble.has-image { padding: 6px; }
.bubble.has-image .author, .bubble.has-image .pre, .bubble.has-image .time { padding: 0 6px; }
.chat-img { display: block; width: 100%; max-width: 280px; height: auto; border-radius: 10px; cursor: zoom-in; background: var(--secondary); margin-bottom: 4px; }
.chat-preview:empty { display: none; }
.chat-preview { display: flex; gap: 12px; align-items: center; padding: 8px; margin-bottom: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.chat-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.chat-preview .hint { margin: 2px 0; }
.link-btn { background: none; border: 0; padding: 0 0 0 8px; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; }
.lightbox { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgb(0 0 0 / 0.9); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; width: 48px; height: 48px; border: 0; border-radius: 50%; font-size: 1.4rem; background: rgb(255 255 255 / 0.2); color: #fff; cursor: pointer; }

/* --- Abgabe-Liste --- */
.filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
tr.status-offen td { background: var(--warn-bg); }
tr.status-offen .status-badge { font-weight: 700; color: var(--warn-text); }
tr.status-nicht-aktiviert td, tr.status-gesperrt td { color: var(--muted); }
a.who { color: inherit; text-decoration: underline dotted; }

/* --- Erneute Bestätigung & Zwei-Faktor-Einrichtung --- */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgb(0 0 0 / 0.55); }
.modal-card { width: 100%; max-width: 420px; margin: 0; }
.totp-qr { margin: 12px auto; width: 220px; }
.totp-qr .qr { display: block; width: 220px; height: 220px; }
.totp-secret { font-size: 1.1rem; letter-spacing: 0.08em; word-break: break-all; }
