/* ME – App-Stil. Mobil zuerst, Hell/Dunkel über Tokens. */

:root {
    --akzent: #0f766e;
    --akzent-hell: #ccfbf1;
    --akzent-text: #ffffff;
    --grund: #f5f6f4;
    --flaeche: #ffffff;
    --flaeche-2: #eef0ed;
    --text: #1c2321;
    --text-leise: #5f6b67;
    --linie: #dde2df;
    --fehler: #b42318;
    --fehler-grund: #fde8e6;
    --ok: #12703a;
    --warn: #a15c07;
    --schatten: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .06);
    --radius: 14px;
    --kopf-hoehe: 56px;
    --nav-hoehe: 64px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="hell"]) {
        --akzent: #2dd4bf;
        --akzent-hell: #134e48;
        --akzent-text: #04211e;
        --grund: #0f1413;
        --flaeche: #171e1c;
        --flaeche-2: #1f2826;
        --text: #e6ece9;
        --text-leise: #94a39e;
        --linie: #2a3532;
        --fehler: #f97066;
        --fehler-grund: #3b1513;
        --ok: #4ade80;
        --warn: #fbbf24;
        --schatten: 0 1px 2px rgb(0 0 0 / .4), 0 4px 16px rgb(0 0 0 / .3);
        color-scheme: dark;
    }
}

:root[data-theme="dunkel"] {
    --akzent: #2dd4bf;
    --akzent-hell: #134e48;
    --akzent-text: #04211e;
    --grund: #0f1413;
    --flaeche: #171e1c;
    --flaeche-2: #1f2826;
    --text: #e6ece9;
    --text-leise: #94a39e;
    --linie: #2a3532;
    --fehler: #f97066;
    --fehler-grund: #3b1513;
    --ok: #4ade80;
    --warn: #fbbf24;
    --schatten: 0 1px 2px rgb(0 0 0 / .4), 0 4px 16px rgb(0 0 0 / .3);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--grund);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100dvh;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--akzent); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }

.laden { padding: 40px 16px; text-align: center; color: var(--text-leise); }

/* ---------- Kopf, Navigation, Inhalt ---------- */

.kopf {
    position: sticky; top: 0; z-index: 10;
    height: calc(var(--kopf-hoehe) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 72px 0 16px;
    display: flex; align-items: center; gap: 12px;
    background: var(--flaeche);
    border-bottom: 1px solid var(--linie);
}
.kopf .marke { font-weight: 800; letter-spacing: .04em; color: var(--akzent); text-decoration: none; }
.kopf .titel { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.symbolknopf {
    width: 40px; height: 40px; border-radius: 10px;
    display: inline-grid; place-items: center;
    border: 0; background: transparent; cursor: pointer; color: var(--text-leise);
    text-decoration: none;
}
.symbolknopf:hover { background: var(--flaeche-2); color: var(--text); }
.symbolknopf svg { width: 22px; height: 22px; }

.nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--nav-hoehe) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--flaeche);
    border-top: 1px solid var(--linie);
}
.nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--text-leise); text-decoration: none; font-size: .72rem; font-weight: 500;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--akzent); }

.inhalt {
    max-width: 760px; margin: 0 auto;
    padding: 20px 16px calc(var(--nav-hoehe) + env(safe-area-inset-bottom) + 24px);
}

@media (min-width: 900px) {
    .nav {
        top: calc(var(--kopf-hoehe) + env(safe-area-inset-top)); right: auto; bottom: 0;
        width: 200px; height: auto; padding: 16px 12px;
        grid-template-columns: 1fr; grid-auto-rows: 48px; align-content: start; gap: 4px;
        border-top: 0; border-right: 1px solid var(--linie);
    }
    .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; border-radius: 10px; font-size: .95rem; }
    .nav a:hover { background: var(--flaeche-2); }
    .nav a[aria-current="page"] { background: var(--akzent-hell); }
    .inhalt { padding: 28px 24px 40px; margin-left: 200px; margin-right: 0; max-width: 820px; }
    @media (min-width: 1240px) { .inhalt { margin-left: auto; margin-right: auto; } }
}

/* ---------- Feedback-Stift ---------- */

.stift {
    position: fixed; z-index: 20;
    top: calc(env(safe-area-inset-top) + 8px); right: 12px;
    width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center;
    border: 0; cursor: pointer;
    background: var(--akzent); color: var(--akzent-text);
    box-shadow: var(--schatten);
}
.stift svg { width: 20px; height: 20px; }

/* ---------- Bausteine ---------- */

.karte {
    background: var(--flaeche);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.karte.hervor { border-color: var(--akzent); }

.leise { color: var(--text-leise); }
.ohne-rand { margin: 0; }
.klein-auswahl { width: auto; padding: 4px 8px; margin-left: 6px; }
.klein { font-size: .875rem; }

.feld { display: grid; gap: 6px; margin-bottom: 14px; }
.feld label { font-weight: 600; font-size: .9rem; }
input[type="text"], input[type="password"], select, textarea {
    width: 100%; padding: 11px 12px;
    background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--akzent); outline-offset: 2px;
}
.haken { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.haken input { width: 20px; height: 20px; accent-color: var(--akzent); }

.knopf {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px;
    border-radius: 10px; border: 1px solid var(--linie);
    background: var(--flaeche-2); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text);
}
.knopf.haupt { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.knopf.breit { width: 100%; }
.knopf:disabled { opacity: .6; cursor: default; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 10px; }

.meldung { padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }
.meldung.fehler { background: var(--fehler-grund); color: var(--fehler); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
    min-height: 36px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--linie); background: var(--flaeche); cursor: pointer; font-size: .9rem;
}
.chip[aria-pressed="true"] { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }

.marker {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: .75rem; font-weight: 600; background: var(--flaeche-2); color: var(--text-leise);
}
.marker.hoch { color: var(--fehler); }
.marker.offen { color: var(--warn); }
.marker.erledigt { color: var(--ok); }

.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { padding: 14px 0; border-top: 1px solid var(--linie); }
.liste > li:first-child { border-top: 0; padding-top: 0; }
.zeile { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.zeile .rest { flex: 1; }
.umbruch { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; }

/* ---------- Anmeldung ---------- */

.anmeldung {
    min-height: 100dvh; display: grid; place-items: center;
    padding: 24px 16px;
}
.anmeldung .karte { width: 100%; max-width: 380px; padding: 24px; }
.anmeldung .marke-gross {
    width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 16px;
    display: grid; place-items: center;
    background: var(--akzent); color: var(--akzent-text); font-weight: 800; font-size: 1.4rem; letter-spacing: .04em;
}
.anmeldung h1 { text-align: center; font-size: 1.25rem; }
.anmeldung .unter { text-align: center; margin-bottom: 20px; }
.pin-eingabe { text-align: center; font-size: 1.6rem; letter-spacing: .4em; }

/* ---------- Dialog & Hinweis ---------- */

dialog {
    width: min(520px, calc(100% - 32px));
    border: 1px solid var(--linie); border-radius: var(--radius);
    background: var(--flaeche); color: var(--text);
    padding: 20px; box-shadow: var(--schatten);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog .kontext { margin: -6px 0 14px; }

.hinweis {
    position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
    bottom: calc(var(--nav-hoehe) + env(safe-area-inset-bottom) + 16px);
    padding: 10px 16px; border-radius: 10px;
    background: var(--text); color: var(--grund); box-shadow: var(--schatten);
    max-width: calc(100% - 32px);
}

/* ---------- Woche ---------- */

.inhalt.breit { max-width: 1200px; }
@media (min-width: 900px) {
    .inhalt.breit { max-width: none; margin-left: 200px; margin-right: 0; }
    .nur-mobil { display: none; }
}

.kopfzeile { margin-bottom: 4px; }
.knopf.gefahr { color: var(--fehler); }
.zwei-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="time"], input[type="number"] {
    width: 100%; padding: 11px 12px;
    background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px;
}

.woche {
    display: grid; grid-template-columns: 48px repeat(7, minmax(0, 1fr)); gap: 4px;
    margin: 12px 0 20px;
}
.woche-zeit .tag-flaeche { border: 0; background: none; }
.tag-kopf {
    height: 32px; display: flex; align-items: center; justify-content: center; gap: 6px;
    font-size: .9rem;
}
.tag-flaeche {
    position: relative;
    border: 1px solid var(--linie); border-radius: 10px;
    background-color: var(--flaeche);
    background-image: linear-gradient(to bottom, var(--linie) 1px, transparent 1px);
}
.stunde {
    position: absolute; right: 6px; transform: translateY(-50%);
    font-size: .7rem; color: var(--text-leise); font-variant-numeric: tabular-nums;
}
.stunde:first-child { transform: none; }

.block {
    position: absolute; left: 3px; right: 3px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 0;
    padding: 3px 6px; overflow: hidden; cursor: pointer; text-align: left;
    border: 0; border-left: 4px solid var(--farbe); border-radius: 6px;
    background: color-mix(in srgb, var(--farbe) 20%, var(--flaeche));
    color: var(--text); font-size: .75rem; line-height: 1.25;
}
.block:hover { background: color-mix(in srgb, var(--farbe) 32%, var(--flaeche)); }
.block.inaktiv { opacity: .45; border-left-style: dashed; }
.block-zeit { color: var(--text-leise); font-variant-numeric: tabular-nums; white-space: nowrap; }
.block-titel { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.block.kurz { flex-direction: row; align-items: center; gap: 6px; }
.block.kurz .block-titel { white-space: nowrap; }

@media (max-width: 899px) {
    .woche { grid-template-columns: 48px 1fr; }
    .woche .tag:not(.gewaehlt) { display: none; }
    .block { font-size: .85rem; }
}

.liste-kompakt { list-style: none; margin: 0; padding: 0; }
.liste-kompakt li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--linie); }
.liste-kompakt li:first-child { border-top: 0; }
.farbpunkt { width: 12px; height: 12px; border-radius: 50%; background: var(--farbe); flex: none; }

.kat-liste { display: grid; gap: 8px; margin-bottom: 14px; }
.kat-zeile { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; }
.kat-zeile input[type="color"] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--linie); border-radius: 10px; background: var(--flaeche); }
.kat-zeile select, .kat-zeile .knopf { grid-column: span 1; }
dialog.breit { width: min(760px, calc(100% - 32px)); }
.kat-zeile .knopf { min-height: 40px; padding: 0 12px; font-size: .9rem; }
@media (min-width: 640px) {
    .kat-zeile { grid-template-columns: 44px minmax(160px, 1fr) 120px auto auto; }
}
.chips.nur-mobil .chip { padding: 0 11px; }
