:root {
    --brand: #d72763;
    --brand-ink: #ffffff;
    --brand-soft: #fce8ef;
    --brand-gradient: linear-gradient(135deg, #d72763 0%, #f4bd00 100%);
    --bg: #f6f5f3;
    --surface: #ffffff;
    --ink: #1d1d1b;
    --muted: #6b6a66;
    --line: #e6e4e0;
    --yes: #1f8a4c;
    --yes-soft: #e1f3e8;
    --no: #c2412d;
    --no-soft: #fbe6e2;
    --sub: #b07800;
    --sub-soft: #fbf0d6;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --brand: #f0588a;
        --brand-ink: #2a0612;
        --brand-soft: #3a1622;
        --bg: #121211;
        --surface: #1c1c1a;
        --ink: #f2f2f2;
        --muted: #a3a29d;
        --line: #2f2e2b;
        --yes: #4cc98a;
        --yes-soft: #163527;
        --no: #f07a66;
        --no-soft: #3a1e19;
        --sub: #e6b445;
        --sub-soft: #3a2f14;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.plain { padding-bottom: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }

/* Kopf */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 12px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: var(--surface); color: var(--ink);
    border-bottom: 1px solid var(--line);
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--brand-gradient); }
.topbar .logo { display: block; line-height: 0; }
.topbar .logo img { height: 26px; width: auto; }
@media (max-width: 380px) { .topbar .logo img { height: 22px; } }
.topbar .spacer { flex: 1; }
.topbar a { color: inherit; font-size: .92rem; font-weight: 500; }

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

/* Untere Navigation */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: flex; justify-content: space-around;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: .72rem; color: var(--muted); padding: 4px 0; text-decoration: none;
}
.tabbar a.active { color: var(--brand); font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; }

/* Karten */
.card {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--line);
    padding: 16px; margin-bottom: 16px;
}
.card.hero { border: 2px solid transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--brand-gradient) border-box; }
.card h2 { margin-bottom: .4em; }
.eyebrow { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); margin-bottom: 4px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .92rem; margin-bottom: 12px; }

/* Zu-/Absage-Buttons */
.answer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.answer button {
    border: 2px solid var(--line); background: var(--surface); color: var(--ink);
    border-radius: 12px; padding: 14px 6px; font: inherit; font-weight: 600; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 72px;
    transition: transform .05s;
}
.answer button:active { transform: scale(.97); }
.answer button .ico { font-size: 1.4rem; line-height: 1; }
.answer button.yes.on { background: var(--yes-soft); border-color: var(--yes); color: var(--yes); }
.answer button.no.on  { background: var(--no-soft);  border-color: var(--no);  color: var(--no); }
.answer button.sub.on { background: var(--sub-soft); border-color: var(--sub); color: var(--sub); }
.answer-question { font-weight: 600; margin: 4px 0 10px; }

/* Code-Eingabe */
.code-form { display: flex; gap: 8px; }
.code-input {
    width: 100%; font-size: 2rem; letter-spacing: .5em; text-align: center; font-weight: 700;
    padding: 10px; border-radius: 12px; border: 2px solid var(--brand); background: var(--surface); color: var(--ink);
}
.code-big { font-size: 3.2rem; font-weight: 800; letter-spacing: .3em; text-align: center; color: var(--brand); margin: 8px 0; }

/* Status-Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--line); color: var(--ink); white-space: nowrap; }
.badge.present, .badge.yes { background: var(--yes-soft); color: var(--yes); }
.badge.no_early, .badge.no_late, .badge.noshow, .badge.no { background: var(--no-soft); color: var(--no); }
.badge.sub { background: var(--sub-soft); color: var(--sub); }
.badge.excused { background: var(--brand-soft); color: var(--brand); }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .sub { font-size: .88rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.list a.row { color: inherit; display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; }

.avatar {
    width: 40px; height: 40px; border-radius: 50%; flex: none;
    display: grid; place-items: center; font-weight: 700; font-size: .9rem;
    background: var(--brand-soft); color: var(--brand);
}

/* Formulare */
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: .82rem; color: var(--muted); font-weight: 400; margin-top: 4px; }
.field .error { font-size: .85rem; color: var(--no); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=time],
input[type=number], input[type=url], input[type=file], select, textarea {
    width: 100%; font: inherit; padding: 11px 12px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
textarea { min-height: 90px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
@media (max-width: 480px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 8px; }
.check input { width: 20px; height: 20px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 700; font-size: 1.05rem; margin-bottom: 10px; padding: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-weight: 600; padding: 11px 18px; border-radius: 10px; cursor: pointer;
    border: 1px solid transparent; background: var(--brand); color: var(--brand-ink); text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--surface); color: var(--no); border-color: var(--no); }
.btn.small { padding: 6px 12px; font-size: .88rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.inline { display: inline; }

/* Meldungen */
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; background: var(--yes-soft); color: var(--yes); }
.flash.error { background: var(--no-soft); color: var(--no); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.4rem; }
.stat span { font-size: .78rem; color: var(--muted); }

.contact-links { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: .9rem; }
.pill.wa { border-color: #25d366; color: #128c4a; }
@media (prefers-color-scheme: dark) { .pill.wa { color: #4fe08a; } }

.copy { display: flex; gap: 8px; }
.copy input { font-size: .85rem; }

/* Ortssuche */
.search-results { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.search-results:empty { display: none; }
.search-results li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .92rem; }
.search-results li:last-child { border-bottom: 0; }
.search-results li:hover { background: var(--brand-soft); }

/* Login */
.auth { max-width: 400px; margin: 8vh auto 0; padding: 16px; }
.auth.wide { max-width: 680px; margin-top: 4vh; }
.auth .brand { text-align: center; margin-bottom: 24px; }
.auth .brand .wordmark { width: 100%; max-width: 300px; height: auto; display: block; margin: 0 auto; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

details summary { cursor: pointer; font-weight: 600; color: var(--brand); padding: 4px 0; }
.empty { text-align: center; color: var(--muted); padding: 20px 0; }
.install-hint { display: none; }

.admin-fix { display: none !important; }
.show-fix .admin-fix { display: flex !important; }
