/* Layout: Kopfzeile mit drei Ansichten, darunter Monatskalender, darunter Terminliste; in der Verwaltung links ein Formular. */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #17302e;
  --muted: #5d7270;
  --line: #d9e1df;
  --accent: #d9622b;
  --accent-ink: #ffffff;
  --intern: #2c5f9e;
  --intern-bg: #e6eef8;
  --pub-bg: #fbe9df;
  --today: #fff7c2;
  --ferien-bg: #e4f2e8;
  --ferien-ink: #2c6b45;
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101b1a; --surface: #182827; --ink: #e6efed; --muted: #93aaa7; --line: #2c4240;
    --accent: #f08a57; --accent-ink: #1a0f08; --intern: #8db8f0; --intern-bg: #1d3350;
    --pub-bg: #4a2c1d; --today: #4a4519; --ferien-bg: #1f3a2c; --ferien-ink: #8fd0a8; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101b1a; --surface: #182827; --ink: #e6efed; --muted: #93aaa7; --line: #2c4240;
  --accent: #f08a57; --accent-ink: #1a0f08; --intern: #8db8f0; --intern-bg: #1d3350;
  --pub-bg: #4a2c1d; --today: #4a4519; --ferien-bg: #1f3a2c; --ferien-ink: #8fd0a8; color-scheme: dark;
}
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  padding-block: 20px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
h1, h2 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
nav { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
nav a { padding: 7px 14px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 500; }
nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
nav a:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.layout { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
.layout.with-form { grid-template-columns: 300px minmax(0, 1fr); }
@media (max-width: 800px) { .layout.with-form { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=time], textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; box-sizing: border-box; }
textarea { min-height: 90px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
button { font: inherit; font-weight: 500; border-radius: 8px; padding: 8px 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: #b3261e; }
:root[data-theme="dark"] button.danger { color: #ff9a92; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.cal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cal-head .btns { align-items: center; }
.grid-scroll { overflow-x: auto; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(84px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); min-width: 600px; }
.dow, .cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.dow { padding: 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cell { min-height: 88px; padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cell.other { opacity: .45; }
.cell.ferien { background: var(--ferien-bg); }
.cell.today { background: var(--today); }
.cell .fer { font-size: 11px; line-height: 1.2; color: var(--ferien-ink); font-weight: 600; overflow-wrap: anywhere; }
.cell .n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
a.chip { display: block; text-decoration: none; box-sizing: border-box; font-size: 12px; line-height: 1.3; padding: 2px 6px; border-radius: 5px; background: var(--pub-bg); text-align: left; border: 0; font-weight: 500; overflow-wrap: anywhere; width: 100%; color: var(--ink); }
.chip.intern { background: var(--intern-bg); color: var(--intern); }
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.ev { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 12px; display: grid; gap: 4px; }
.ev.intern { border-left-color: var(--intern); }
.ev .when { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ev .t { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.ev .prog { white-space: pre-wrap; overflow-wrap: anywhere; }
.ev .who { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--intern-bg); color: var(--intern); margin-left: 6px; text-transform: uppercase; letter-spacing: .05em; }
.empty { color: var(--muted); padding: 16px 0; }
.note { background: var(--intern-bg); color: var(--ink); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.chip.intern, a.chip.intern { background: var(--intern-bg); color: var(--intern); }
.auth { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.auth form { flex-direction: row; display: inline; }
.auth a { color: var(--muted); }
.flash { overflow-wrap: anywhere; background: var(--pub-bg); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.flash.err { background: #fbe3e1; color: #7a1710; }
:root[data-theme="dark"] .flash.err { background: #4a1f1b; color: #ffb4ad; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td form { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
td input[type=password] { width: 12em; }
.narrow { max-width: 460px; margin: 0 auto; }
@media print { nav, .btns, .auth, .panel form { display: none; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .flash.err { background: #4a1f1b; color: #ffb4ad; } }
a.btn { display: inline-block; font-weight: 500; border-radius: 8px; padding: 8px 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; }
.btns form { display: inline; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ferienlist { display: flex; flex-direction: column; gap: 4px; background: var(--ferien-bg); color: var(--ferien-ink); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.src { margin-top: 12px; }
.src a { color: inherit; }

fieldset { border: 1px solid #ccc; border-radius: 6px; margin: 0 0 .8rem; padding: .4rem .8rem; }
fieldset legend { padding: 0 .3rem; font-size: .9em; }

/* Gruppenauswahl als große Tippflächen (Touch) */
.groupbtns { display: flex; flex-wrap: wrap; gap: 10px; }
.groupbtns .btn { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 18px; font-size: 15px; }
.groupbtns .btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
ul.plain { list-style: none; margin: 0 0 12px; padding: 0; }
ul.plain li { padding: 4px 0; }
.radios { display: flex; flex-wrap: wrap; gap: 6px 14px; }

/* Anwesenheit: Status als Tipp-Buttons (Radio) */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; flex-direction: row; font-size: 14px; font-weight: 500; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.seg .s-anwesend input:checked + span { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.seg .s-entschuldigt input:checked + span { background: #b26a00; border-color: #b26a00; color: #fff; }
.seg .s-unentschuldigt input:checked + span { background: #b3261e; border-color: #b3261e; color: #fff; }
tr.archiv td { opacity: .75; }
.subnav { margin-bottom: 14px; }

/* Kompakte Verwaltungstabellen: eine Zeile = ein Formular (inputs per form-Attribut) */
.tablewrap { overflow-x: auto; }
table.compact th, table.compact td { padding: 6px 8px; vertical-align: middle; white-space: nowrap; }
table.compact .inline { display: flex; flex-wrap: wrap; gap: 4px 14px; }
table.compact input[type=text], table.compact input[type=password] { width: 12em; padding: 5px 8px; }
table.compact button { padding: 5px 10px; }
table.compact .btns { flex-wrap: nowrap; }
table.compact label.check { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Schnell-Anlegen in einer Zeile über der Tabelle */
form.addrow { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
form.addrow input[type=text], form.addrow input[type=search] { width: 16em; max-width: 100%; }
form.addrow .inline { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.sortbtns { display: inline-flex; gap: 6px; }
.sortbtns .btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Anwesenheits-Übersicht im Archiv: dicht, erste Spalte beim Scrollen sichtbar */
h3.sub { margin: 14px 0 6px; font-size: 14px; }
h3.sub .hint { font-weight: 400; font-size: 12px; margin-left: 8px; }
table.compact.terms td:nth-child(2) { white-space: normal; }
table.compact.terms th, table.compact.terms td { padding: 4px 8px; }
table.matrix { font-size: 13px; }
table.matrix th, table.matrix td { padding: 3px 6px; text-align: center; min-width: 2em; }
table.matrix td:first-child, table.matrix th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); max-width: 11em; overflow: hidden; text-overflow: ellipsis; }
table.matrix th:nth-last-child(-n+3), table.matrix td:nth-last-child(-n+3) { border-left: 1px solid var(--line); }
table.matrix td.m-anwesend { color: #2e7d32; font-weight: 600; }
table.matrix td.m-entschuldigt { color: #b26a00; font-weight: 600; }
table.matrix td.m-unentschuldigt { color: #b3261e; font-weight: 600; }
table.matrix td.m-offen { opacity: .45; }
form.addrow label { flex-direction: row; align-items: center; gap: 6px; }
form.addrow input[type=date] { width: auto; }

/* Anwesenheit erfassen: zusammenhängende Segment-Buttons, dichte Zeilen */
.seg { gap: 0; flex-wrap: nowrap; }
.seg span { min-height: 38px; padding: 4px 12px; border-radius: 0; margin-left: -1px; font-size: 14px; }
.seg label:first-child span { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg label:last-child span { border-radius: 0 8px 8px 0; }
.seg input:checked + span { position: relative; z-index: 1; }
.seg .short { display: none; font-weight: 600; }
table.attend td { padding: 3px 8px; }
table.attend td:first-child { white-space: normal; min-width: 7em; }
@media (max-width: 520px) { .seg .full { display: none; } .seg .short { display: inline; } .seg span { padding: 4px 11px; } }

/* Betreuer-Anwesenheit optisch abgesetzt */
.attbox { margin-top: 14px; padding: 8px 12px 4px; border: 1px dashed var(--line); border-left: 4px solid var(--accent); border-radius: 8px; background: var(--bg); }
.attbox h3.sub { margin-top: 2px; }
table.matrix tr.sep th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding-top: 8px; border-top: 2px solid var(--line); background: var(--bg); }

/* Mitglieder und Betreuer: dezent unterschiedliche Tönung */
.attbox.members { border-left-color: #3b7dd8; background: color-mix(in srgb, #3b7dd8 6%, var(--bg)); }
.attbox.leaders { border-left-color: #c9822b; background: color-mix(in srgb, #c9822b 7%, var(--bg)); }
.attbox.members h3.sub { color: #2f66b0; }
.attbox.leaders h3.sub { color: #a8661a; }
:root[data-theme="dark"] .attbox.members h3.sub { color: #8db8f0; }
:root[data-theme="dark"] .attbox.leaders h3.sub { color: #e8b073; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .attbox.members h3.sub { color: #8db8f0; } :root:not([data-theme="light"]) .attbox.leaders h3.sub { color: #e8b073; } }

/* Mitglieder- und Betreuer-Tabelle: gleiche Namensspalte, damit die Status-Buttons exakt untereinander stehen */
table.attend td:first-child { width: 11em; min-width: 11em; max-width: 11em; overflow-wrap: anywhere; }
@media (max-width: 520px) { table.attend td:first-child { width: 7.5em; min-width: 7.5em; max-width: 7.5em; } }

/* Anwesenheit: jeder Termin ein eigenes Feld, Klick auf die Zeile klappt die Erfassung darunter auf */
.termlist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.term { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.term.archiv { background: var(--bg); }
.term.open { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.termhead { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; min-height: 44px; padding: 8px 12px; color: inherit; text-decoration: none; }
.termhead:hover { background: var(--bg); }
.termhead .d { font-size: 13px; opacity: .75; min-width: 11em; }
.termhead .ti { font-weight: 600; flex: 1 1 10em; }
.termhead .n { font-size: 13px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; }
.term.open .termhead { border-bottom: 1px solid var(--line); }
.attpanel { padding: 4px 12px 12px; }

/* Termin-Feld bleibt eigenständig, die Erfassung klappt als separates Feld darunter auf */
.termwrap { display: flex; flex-direction: column; gap: 6px; }
.term.open .termhead { border-bottom: 0; }
.attpanel { padding: 6px 12px 12px; border: 1px solid var(--accent); border-radius: 10px; background: var(--surface); margin-left: 10px; }
@media (max-width: 520px) { .attpanel { margin-left: 4px; padding: 6px 8px 10px; } }

/* ---- Optik-Feinschliff Anwesenheit ---- */
.termlist { gap: 10px; }
.term { transition: border-color .15s, box-shadow .15s; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.term:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.termhead { gap: 2px 12px; padding: 10px 14px; border-radius: 10px; }
.termhead:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.termhead .chev { width: 8px; height: 8px; flex: 0 0 auto; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); opacity: .55; transition: transform .15s; margin-right: 2px; }
.term.open .termhead .chev { transform: rotate(45deg); opacity: .9; }
.termhead .d { min-width: 10em; font-variant-numeric: tabular-nums; }
.termhead .ti { font-size: 15px; }
.termhead .n { font-variant-numeric: tabular-nums; margin-left: auto; background: var(--bg); }
.termhead .n.done { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.term.open { box-shadow: 0 2px 8px rgba(0,0,0,.08), 0 0 0 1px var(--accent); }
.attpanel { margin-left: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.attbox { padding: 6px 12px 8px; border-style: solid; border-width: 1px 1px 1px 4px; border-color: var(--line); }
.attbox.members { border-left-color: #3b7dd8; }
.attbox.leaders { border-left-color: #c9822b; }
.attbox h3.sub { margin: 4px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.attbox .hint { margin: 6px 0 2px; font-size: 12px; }
.attbox table.attend tr + tr td { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.seg span { transition: background .12s, border-color .12s; }
.seg label:hover span { border-color: var(--accent); }
.attpanel .btns { margin-top: 12px; }
.attpanel .btns button.primary { padding: 10px 22px; font-size: 15px; }
@media (max-width: 520px) {
  .termhead { padding: 10px; }
  .termhead .d { min-width: 0; flex: 1 1 auto; }
  .termhead .ti { flex-basis: 100%; order: 3; }
  .attpanel .btns button.primary { width: 100%; }
}

/* Mitglied/Betreuer mindestens 5 erfasste Termine in Folge nicht anwesend */
table.compact tr.warn td { background: color-mix(in srgb, #d93025 11%, var(--surface)); }
table.compact tr.warn td:first-child { box-shadow: inset 4px 0 0 #d93025; }
.badge.warn { background: #d93025; color: #fff; border-color: #d93025; }

/* Archiv-Übersicht: seitlich verschiebbar, Terminspalten behalten ihre Breite */
.matrixnav { display: flex; align-items: center; gap: 6px; margin: 2px 0 4px; }
.matrixnav button { padding: 2px 12px; font-size: 16px; line-height: 1.2; }
.matrixnav .hint { font-size: 12px; margin-left: 6px; }
.matrixscroll { overflow-x: scroll; scrollbar-width: thin; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.matrixscroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.matrixscroll::-webkit-scrollbar { height: 10px; }
.matrixscroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
table.matrix { width: max-content; min-width: 100%; }
table.matrix th, table.matrix td { min-width: 3.4em; }
table.matrix td:first-child, table.matrix th:first-child { min-width: 9em; z-index: 1; }

/* ---- Anwesenheit erfassen: kompakte Zeilen, alle Personen untereinander (keine Begrenzung der Anzahl) ---- */
.attpanel { padding: 4px 10px 10px; }
.attbox { margin-top: 8px; padding: 4px 10px 6px; }
.attbox h3.sub { margin: 2px 0 4px; }
.attbox .hint { margin: 4px 0 0; }
.attbox .tablewrap { overflow: visible; }
table.attend { display: block; font-size: 13px; }
table.attend tbody { display: block; } /* alle Personen untereinander, eine Spalte */
table.attend tr { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
table.attend tr + tr td { border-top: 0; }
table.attend td { padding: 2px 0; border: 0; white-space: normal; }
table.attend td:first-child { width: auto; min-width: 0; max-width: none; flex: 1 1 6em; overflow-wrap: anywhere; line-height: 1.2; }
table.attend td:last-child { flex: 0 0 auto; }
.seg span { min-height: 32px; padding: 2px 10px; font-size: 13px; }
@media (pointer: coarse) { .seg span { min-height: 38px; } }
@media (max-width: 520px) {
  .seg span { padding: 2px 9px; }
}

/* Anmeldung/Abmeldung kompakt oben rechts im Kopf */
.account { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px 8px; font-size: 13px; }
.account form { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
.account .who { color: var(--ink); font-weight: 600; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.account button { padding: 4px 10px; font-size: 13px; }
.account .loginbar input { width: 9em; padding: 4px 8px; font-size: 13px; }
.hbreak { flex-basis: 100%; height: 0; }
@media (max-width: 520px) { .account .loginbar input { width: 7.5em; } .account { margin-left: 0; justify-content: flex-start; } }

/* Infopunkte (Rechte erklären) */
.info { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px; border: 1px solid var(--muted); border-radius: 50%; font: italic 700 11px/1 Georgia, serif; text-transform: none; letter-spacing: 0; color: var(--muted); cursor: help; vertical-align: middle; user-select: none; }
.info:hover, .info:focus-visible { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.rt { display: inline-flex; align-items: center; }
.infotip { position: fixed; z-index: 100; max-width: min(22em, calc(100vw - 16px)); padding: 8px 10px; background: var(--ink); color: var(--bg); border-radius: 8px; font-size: 12.5px; line-height: 1.4; white-space: pre-line; box-shadow: 0 4px 14px rgba(0,0,0,.25); pointer-events: none; }
.infotip[hidden] { display: none; }

/* =====================================================================
   Design-Auffrischung: moderner, kompakter, mobil zuerst
   (überschreibt frühere Regeln; Farben bleiben über die Variablen oben steuerbar)
   ===================================================================== */
:root {
  --radius: 12px; --radius-s: 8px;
  --shadow: 0 1px 2px rgba(16, 27, 26, .06), 0 2px 8px rgba(16, 27, 26, .04);
  --ctl: 34px;               /* Höhe von Bedienelementen am Desktop */
  --nav-h: 56px;             /* Höhe der Tab-Leiste am Handy */
}
html { -webkit-text-size-adjust: 100%; }
body { font-size: 14px; line-height: 1.45; padding-block: 14px; -webkit-font-smoothing: antialiased; }
.wrap { gap: 12px; }
h1 { font-size: 20px; letter-spacing: -.01em; }
h2 { font-size: 16px; letter-spacing: -.005em; margin-bottom: 8px; }
.panel { padding: 14px; border-radius: var(--radius); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--line) 80%, transparent); }
.panel > h2:first-child { margin-top: 0; }

/* Kopf: Titel links, Konto rechts, darunter die Navigation als Segment-Leiste */
header { gap: 8px 12px; }
header h1 + .hint { display: none; }
nav { gap: 2px; padding: 3px; border-radius: 999px; box-shadow: var(--shadow); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a { padding: 6px 16px; border-radius: 999px; font-size: 14px; white-space: nowrap; transition: background .15s, color .15s; }
nav a:hover:not([aria-current]) { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--ink); }

/* Unterbuttons (Kalender/Verwaltung) als Pillen */
.groupbtns { gap: 6px; }
.groupbtns .btn, .subnav .btn { min-height: 32px; padding: 4px 14px; font-size: 13px; border-radius: 999px; }
.subnav { margin-bottom: 0; }

/* Bedienelemente */
button, a.btn { border-radius: var(--radius-s); padding: 6px 12px; min-height: var(--ctl); box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; font-size: 13.5px; line-height: 1.2; transition: background .12s, border-color .12s, box-shadow .12s; }
button:hover, a.btn:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
button.primary:hover { filter: brightness(.95); }
button:active, a.btn:active { transform: translateY(1px); }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=time], textarea { border-radius: var(--radius-s); padding: 6px 10px; min-height: var(--ctl); box-sizing: border-box; font-size: 14px; transition: border-color .12s, box-shadow .12s; }
input:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
form { gap: 10px; }
label { font-size: 12.5px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 6px 10px 8px; margin: 0; }
fieldset legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.btns { gap: 6px; }

/* Meldungen, Hinweise */
.flash, .note { border-radius: var(--radius-s); padding: 8px 12px; box-shadow: var(--shadow); }
.badge { font-size: 10.5px; padding: 1px 7px; }

/* Tabellen: dichter, ruhiger */
table { font-size: 13.5px; }
th, td { padding: 6px 8px; }
th { font-size: 11px; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
table.compact th, table.compact td { padding: 5px 8px; }
table.compact tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }

/* Kalender */
.cal-head { margin-bottom: 8px; }
.cal-head .btns .btn, .cal-head .btns button { min-height: 32px; }
.grid { border-radius: var(--radius-s); overflow: hidden; border-color: var(--line); }
.cell { min-height: 78px; padding: 3px; }
.cell .n { font-weight: 600; }
.cell.today .n { background: var(--accent); color: var(--accent-ink); border-radius: 999px; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.cell.today { background: color-mix(in srgb, var(--today) 55%, var(--surface)); }
a.chip { border-radius: 4px; padding: 1px 5px; font-size: 11.5px; }
.list { gap: 8px; margin-top: 10px; }
.ev { border-radius: var(--radius-s); padding: 8px 12px; gap: 2px; box-shadow: var(--shadow); }
.ev .t { font-size: 15px; }

/* Anwesenheit: Karten */
.termlist { gap: 8px; }
.term { border-radius: var(--radius); box-shadow: var(--shadow); }
.termhead { min-height: 40px; padding: 8px 12px; }
.attpanel { border-radius: var(--radius); }
.attbox { border-radius: var(--radius-s); }

/* Tooltips der Infopunkte */
.infotip { border-radius: var(--radius-s); }

/* ---- Handy (bis 640 px): Tab-Leiste unten, Karten statt Tabellen, kompakter Kalender ---- */
@media (max-width: 640px) {
  :root { --ctl: 40px; }
  body { padding-block: 10px calc(var(--nav-h) + 18px + env(safe-area-inset-bottom, 0px)); font-size: 15px; }
  .wrap { gap: 10px; }
  .panel { padding: 12px; border-radius: 10px; }
  header { flex-wrap: nowrap; align-items: center; }
  header > div:first-child { min-width: 0; }
  .hbreak { display: none; }
  .account { margin-left: auto; font-size: 12.5px; flex-wrap: nowrap; }
  .account .who { max-width: 8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .account .loginbar { flex-wrap: wrap; justify-content: flex-end; }
  .account .loginbar input { width: 7em; min-height: 34px; }
  .account button { min-height: 34px; }

  /* Haupt-Navigation fest am unteren Rand */
  nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; border-radius: 0; border: 0; border-top: 1px solid var(--line); padding: 6px max(8px, env(safe-area-inset-left, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)); justify-content: space-around; gap: 4px; box-shadow: 0 -2px 10px rgba(0, 0, 0, .08); min-height: var(--nav-h); box-sizing: border-box; overflow: visible; }
  nav a { flex: 1 1 0; text-align: center; padding: 10px 6px; font-size: 14px; }

  /* Unterbuttons: umbrechen, große Tippflächen */
  .groupbtns .btn, .subnav .btn { min-height: 38px; padding: 6px 16px; }

  /* Kalender: Monatsübersicht mit Punkten, Details in der Liste darunter */
  .cal-head { flex-direction: column; align-items: stretch; }
  .cal-head .btns { justify-content: space-between; }
  .cal-head #pdfYearBtn, .cal-head #pdfBtn { flex: 1 1 45%; font-size: 12.5px; }
  .grid-scroll { overflow: visible; }
  .grid { min-width: 0; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .dow { padding: 4px 0; text-align: center; font-size: 10.5px; letter-spacing: 0; }
  .cell { min-height: 48px; padding: 2px; align-items: center; gap: 2px; }
  .cell .fer { display: none; }
  .cell .n { font-size: 12px; }
  a.chip { font-size: 0; line-height: 0; width: 100%; height: 5px; padding: 0; border-radius: 3px; background: var(--accent); }
  a.chip.intern { background: var(--intern); }
  .ev { padding: 8px 10px; }

  /* Verwaltungstabellen als Karten */
  .tablewrap:not(.matrixscroll) { overflow-x: visible; }
  table.cards, table.cards tbody { display: block; }
  table.cards tr:first-child { display: none; }
  table.cards tr { display: grid; gap: 6px; padding: 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
  table.cards td { display: block; padding: 0; border: 0; white-space: normal; }
  table.cards td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
  table.cards input[type=text], table.cards input[type=password] { width: 100%; }
  table.cards .btns { justify-content: flex-start; }
  table.cards tr.warn { border-left: 4px solid #d93025; }
  table.cards tr.warn td { background: transparent; box-shadow: none; }
  table.plain tr:first-child th { display: table-cell; }
  form.addrow { flex-direction: column; align-items: stretch; }
  form.addrow input[type=text], form.addrow input[type=search], form.addrow input[type=date] { width: 100%; max-width: none; }
  form.addrow label { flex-direction: column; align-items: stretch; }

  /* Anwesenheit */
  .termhead { padding: 10px; min-height: 44px; }
  .attpanel { margin-left: 0; padding: 4px 8px 10px; }
  .attbox { padding: 4px 8px 6px; }
  .seg span { min-height: 38px; }
  table.attend td:first-child { flex-basis: 5em; }
  table.matrix { font-size: 12px; }
  .infotip { font-size: 13px; }
}
/* Sehr schmal */
@media (max-width: 380px) {
  .seg span { padding: 2px 7px; }
  .account .who { max-width: 5.5em; }
}
/* Touch-Geräte: großzügigere Tippflächen */
@media (pointer: coarse) {
  .seg span { min-height: 40px; }
  .info { width: 20px; height: 20px; }
}
@media print { .wrap > header, nav { display: none; } }

/* Korrekturen nach Sichtprüfung */
h1, h2 { font-weight: 650; }
.narrow { width: 100%; box-sizing: border-box; }
/* „Offen“ ist neutral, nicht als Auswahl in Akzentfarbe */
.seg label:first-child input:checked + span { background: var(--line); border-color: var(--line); color: var(--ink); }
@media (max-width: 640px) {
  form.addrow:has(input[type=date]) { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  form.addrow:has(input[type=date]) > a.btn, form.addrow:has(input[type=date]) > button { grid-column: 1 / -1; }
}
.narrow { margin-inline: 0; }

/* Termin-Formular: Felder einer Zeile bündig, auch wenn eine Beschriftung umbricht */
.row2 { align-items: end; }
.row2 > label { justify-content: flex-end; min-width: 0; }
.row2 input[type=date], .row2 input[type=time], .row2 input[type=text] { height: var(--ctl); min-height: var(--ctl); }

/* Termin-Farben (8 feste Farben über --tc) */
a.chip.tc { background: color-mix(in srgb, var(--tc) 22%, var(--surface)); color: var(--ink); box-shadow: inset 3px 0 0 var(--tc); }
.ev.tc { border-left-color: var(--tc); }
.colorpick { margin: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sw { position: relative; flex-direction: row; }
.sw input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.sw .dot { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--tc); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); transition: transform .12s, box-shadow .12s; }
.sw:hover .dot { transform: scale(1.1); }
.sw input:checked + .dot { box-shadow: 0 0 0 2px var(--ink); }
.sw input:focus-visible + .dot, .sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw-none span { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); background: var(--surface); }
.sw-none input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
@media (max-width: 640px) { a.chip.tc { background: var(--tc); box-shadow: none; } .sw .dot { width: 34px; height: 34px; } .swatches { gap: 10px; } }

/* Anwesenheit: kein oranges Hervorheben mehr; der gewählte Termin hebt sich nur über die Intensität des Hintergrunds ab */
.groupbtns[aria-label="Gruppe wählen"] .btn.on { background: color-mix(in srgb, var(--ink) 12%, var(--surface)); color: var(--ink); border-color: color-mix(in srgb, var(--ink) 28%, var(--line)); font-weight: 600; }
.term { background: var(--surface); }
.term.open { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 26%, var(--line)); box-shadow: var(--shadow); }
.term.open .termhead:hover { background: transparent; }
.term.archiv.open { background: color-mix(in srgb, var(--accent) 13%, var(--bg)); }
.attpanel { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 22%, var(--line)); box-shadow: none; }
.termhead .n { background: var(--surface); }
.term.open .termhead .n:not(.done) { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }

/* Gruppenfarbe: Punkt vor dem Namen, getönte Badges */
.badge.tc { background: color-mix(in srgb, var(--tc) 22%, var(--surface)); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tc) 45%, transparent); }

/* Gruppenfarbe als Hintergrund des Gruppennamens (statt Punkt) */
.gname { display: inline-block; padding: 1px 9px; border-radius: 999px; background: color-mix(in srgb, var(--tc) 24%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tc) 45%, transparent); color: var(--ink); line-height: 1.5; }
.groupbtns .btn.gbtn { background: color-mix(in srgb, var(--tc) 20%, var(--surface)); border-color: color-mix(in srgb, var(--tc) 45%, var(--line)); color: var(--ink); }
.groupbtns[aria-label="Gruppe wählen"] .btn.gbtn.on { background: color-mix(in srgb, var(--tc) 48%, var(--surface)); border-color: var(--tc); font-weight: 600; }

/* Mitgliederliste: jede Zeile bleibt einzeilig (Gruppenwahl nebeneinander); am Handy wieder als Karte */
table.oneline .inline { flex-wrap: nowrap; gap: 0 10px; }
table.oneline label.check { gap: 5px; white-space: nowrap; }
table.oneline td { white-space: nowrap; }
table.oneline .gname { padding: 1px 8px; }
table.oneline input[type=text] { width: 11em; }
@media (max-width: 640px) { table.oneline .inline { flex-wrap: wrap; gap: 4px 12px; } table.oneline td { white-space: normal; } table.oneline input[type=text] { width: 100%; } }

/* Logo-Vorschau in den Einstellungen */
.logoprev { padding: 10px; border: 1px dashed var(--line); border-radius: var(--radius-s); background: repeating-conic-gradient(var(--bg) 0% 25%, var(--surface) 0% 50%) 50% / 14px 14px; text-align: center; }
.logoprev img { max-width: 100%; max-height: 90px; width: auto; height: auto; object-fit: contain; }
input[type=file] { font: inherit; font-size: 13px; max-width: 100%; }

/* Rollenwahl: genau eine Rolle, Optionen nebeneinander */
fieldset.rolepick .inline { display: flex; flex-wrap: wrap; gap: 4px 16px; }

/* Rollenwahl: alle Rollen untereinander */
table.compact td[data-l="Rolle"] .inline, fieldset.rolepick .inline { flex-direction: column; flex-wrap: nowrap; align-items: flex-start; gap: 3px; }
fieldset.rolepick .inline .rt { width: 100%; }

.rolefilter { margin-bottom: 10px; }

/* Rolle Leitung/Administrator: Hinweis „sieht und verwaltet alle Gruppen“ */
.autohint { display: inline-block; margin-top: 4px; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.autohint[hidden] { display: none; }

/* Benutzerliste: Hinweis bricht um (macht die Tabelle nicht breiter), Speichern/Löschen bleiben immer erreichbar */
table.cards .autohint { display: block; white-space: normal; max-width: 17em; line-height: 1.3; padding: 3px 9px; border-radius: 10px; }
table.cards td[data-l="Gruppen"] { white-space: normal; }
@media (min-width: 641px) {
  table.cards td:last-child { position: sticky; right: 0; background: var(--surface); box-shadow: -10px 0 8px -8px rgba(0, 0, 0, .14); }
  table.cards tr.warn td:last-child { background: color-mix(in srgb, #d93025 11%, var(--surface)); }
}
table.cards .autohint[hidden] { display: none; }

/* Benutzerliste: alle Gruppen in einer Zeile (Hinweis bricht darunter um); Felder etwas schmaler, damit alles ohne Scrollen passt */
table.users td[data-l="Gruppen"] { white-space: nowrap; }
table.users td[data-l="Gruppen"] .inline { flex-wrap: nowrap; }
table.users input[type=text] { width: 9.5em; }
table.users input[type=password] { width: 8.5em; }
@media (max-width: 640px) { table.users td[data-l="Gruppen"] { white-space: normal; } table.users td[data-l="Gruppen"] .inline { flex-wrap: wrap; } table.users input[type=text], table.users input[type=password] { width: 100%; } }
table.users td[data-l="Gruppen"] .inline { gap: 0 6px; }
table.users td[data-l="Gruppen"] label.check { gap: 4px; }
table.users td[data-l="Gruppen"] .gname { padding: 1px 7px; }
table.users input[type=text] { width: 8.5em; }
table.users input[type=password] { width: 7em; }
table.users th, table.users td { padding-left: 6px; padding-right: 6px; }
@media (max-width: 640px) { table.users input[type=text], table.users input[type=password] { width: 100%; } }

/* Hinweis bei Leitung/Administrator: einzeilig, so breit wie nötig */
table.users .autohint { max-width: none; white-space: nowrap; width: max-content; }
table.users .autohint { font-size: 11px; padding: 2px 8px; }
table.users input[type=text] { width: 8em; }
table.users input[type=password] { width: 6.2em; }
@media (max-width: 640px) { table.users input[type=text], table.users input[type=password] { width: 100%; } table.users .autohint { white-space: normal; width: auto; } }

/* Passwort-Dialog (Benutzerverwaltung) */
dialog.pwdlg { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; width: min(92vw, 380px); background: var(--surface); color: var(--ink); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
dialog.pwdlg::backdrop { background: rgba(10, 20, 20, .45); }
dialog.pwdlg h2 { margin: 0 0 2px; }
table.users td:last-child .btns { flex-wrap: nowrap; }

/* Mitglieder: bis zu 4 Merkmale (Abzeichen, Lehrgänge …) */
.merk { display: flex; flex-wrap: nowrap; gap: .25rem; margin-top: .25rem; }
.merk input { flex: 1 1 0; min-width: 0; width: 0; font-size: .8rem; padding-block: .15rem; }
.merk-badge { background: color-mix(in srgb, var(--accent, #d9622b) 14%, #fff); color: inherit; margin-left: .25rem; }
@media (max-width: 600px) { .merk { flex-wrap: wrap; } .merk input { flex: 1 1 40%; } }
/* Merkmal-Felder kleiner */
.merk { gap: .2rem; margin-top: .2rem; }
.merk input { flex: 0 0 6.2rem; width: 6.2rem; height: 1.45rem; min-height: 0; font-size: .72rem; padding: 0 .4rem; border-radius: .4rem; }
@media (max-width: 600px) { .merk input { flex: 1 1 40%; width: auto; } }
/* Merkmal-Pillen: gut lesbar (dunkle Schrift auf hellem Grund) */
.badge.merk-badge { background: #fbe3d6; color: #5a2410; border: 1px solid #efb99d; font-weight: 600; text-transform: none; letter-spacing: 0; font-size: .75rem; }
