/* Hundeschule-Tracker — mobile first, keine Abhängigkeiten, kein Build. */

:root {
    --bg: #f2f2f7;
    --surface: #fff;
    --surface-2: #f7f7fa;
    --text: #111214;
    --muted: #6b6f76;
    --line: #e2e3e8;
    --accent: #2f6f4f;
    --accent-soft: #e6f1ea;
    --skip: #a8720f;
    --cancel: #5b6169;
    --danger: #a52626;
    --warn-bg: #fff6e0;
    --warn-line: #e8c26a;
    --warn-text: #6b4c05;
    --radius: 14px;
    --tap: 44px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d0e10;
        --surface: #17191c;
        --surface-2: #1f2226;
        --text: #f0f1f3;
        --muted: #9aa0a8;
        --line: #2b2e33;
        --accent: #5fb98a;
        --accent-soft: #1c2f25;
        --skip: #d8a33f;
        --cancel: #8b929b;
        --danger: #e07373;
        --warn-bg: #2e2510;
        --warn-line: #6b5518;
        --warn-text: #e8c26a;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

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

.app {
    max-width: 32rem;
    margin: 0 auto;
    padding: calc(8px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

/* ---------- Kopf ---------- */

.topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 2px 14px;
}

.topbar h1 {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.topbar .date,
.topbar .back {
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

.section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    font-weight: 600;
    margin: 22px 2px 8px;
}

.empty {
    color: var(--muted);
    font-size: 14.5px;
    text-align: center;
    padding: 26px 12px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

/* ---------- Karten ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}

.card.pending {
    border-color: var(--accent);
    border-width: 1.5px;
}

.entry-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
}

.entry-course { font-weight: 650; font-size: 17px; }
.entry-when { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- Buttons ---------- */

.btn-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* Zukünftige Termine kennen nur die beiden Planungs-Optionen. */
.btn-row-2 { grid-template-columns: repeat(2, 1fr); }

.btn {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 11px;
    padding: 12px 4px;
    min-height: 52px;
    font: 600 14px/1.2 inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    text-align: center;
}

.btn .ico { font-size: 17px; line-height: 1; }
.btn-ok { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-skip { color: var(--skip); }
.btn-cancel { color: var(--cancel); }
.btn:active { transform: scale(0.985); }

.btn-wide {
    width: 100%;
    flex-direction: row;
    min-height: var(--tap);
    gap: 8px;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-quiet { background: transparent; }
.btn-danger { color: var(--danger); background: transparent; }

.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

/* ---------- Hinweisbanner ---------- */

.banner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--warn-bg);
    border: 1px solid var(--warn-line);
    color: var(--warn-text);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 12px;
    font-size: 14px;
    text-decoration: none;
}

.banner strong { display: block; font-size: 15px; margin-bottom: 2px; }
.banner .go { margin-left: auto; align-self: center; font-weight: 650; white-space: nowrap; }

.flash {
    border-radius: var(--radius);
    padding: 11px 14px;
    margin: 0 0 12px;
    font-size: 14.5px;
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.flash-error { border-color: var(--danger); background: transparent; color: var(--danger); }

/* ---------- Kurskachel ---------- */

.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.tile-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 10px;
}

.tile-name { font-weight: 650; font-size: 17px; }

.tile-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 99px;
    background: var(--accent-soft);
    color: var(--accent);
    white-space: nowrap;
}

.tile-body { padding: 0 14px 4px; }

.big { font-size: 15px; margin: 0 0 10px; }
.big b { font-size: 19px; }
.big .sub { color: var(--muted); }

.pips {
    display: flex;
    gap: 5px;
    margin: 0 0 12px;
}

.pip {
    height: 8px;
    border-radius: 99px;
    background: var(--line);
    flex: 1 1 0;
    max-width: 30px;
}

.pip-attended { background: var(--accent); }
.pip-skipped { background: var(--skip); }
.pip-free { background: var(--skip); opacity: 0.4; }

.meta {
    font-size: 13.5px;
    margin: 0 0 4px;
    display: flex;
    gap: 8px;
}

.meta .k { min-width: 9em; color: var(--muted); }
.meta .v { color: var(--text); }

.tile-foot {
    border-top: 1px solid var(--line);
    margin-top: 10px;
    padding: 11px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    font-size: 14px;
}

.tile-foot .closure { color: var(--skip); }
.tile-foot .chev { font-size: 17px; }

/* Die ganze Kachel ist der Link — dorthin zielt der Daumen ohnehin. */
.tile-link {
    display: block;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

.tile-link:active {
    border-color: var(--accent);
    transform: scale(0.995);
}

.tile-link:active .tile-foot { background: var(--accent-soft); }
.tile-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (hover: hover) {
    .tile-link:hover { border-color: var(--accent); }
    .tile-link:hover .chev { color: var(--accent); }
}

/* ---------- Listen ---------- */

.group-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 20px 2px 8px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.list {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    min-height: var(--tap);
    color: inherit;
    text-decoration: none;
}

.row:last-child { border-bottom: 0; }
.row .n { width: 1.8em; font-size: 13px; color: var(--muted); text-align: right; flex: 0 0 auto; }
.row .d { flex: 1; font-size: 15px; }
.row .d small { display: block; color: var(--muted); font-size: 12.5px; }
.row .s { font-size: 13px; font-weight: 600; white-space: nowrap; }
.row.future { opacity: 0.7; }

.row.closure {
    background: var(--surface-2);
    color: var(--muted);
    font-style: italic;
    justify-content: center;
    font-size: 13.5px;
    min-height: 0;
    padding: 9px 14px;
}

/* Trennzeile: ab hier reicht die laufende Karte bzw. der Block nicht mehr. */
.row.limit {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-top: 1px solid var(--warn-line);
    border-bottom: 1px solid var(--warn-line);
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    min-height: 0;
    padding: 9px 14px;
}

/* Termine jenseits der Grenze sind nur Vorschau. */
.row.beyond { opacity: 0.45; }

.s-attended { color: var(--accent); }
.s-skipped { color: var(--skip); }
.s-cancelled { color: var(--cancel); }
.s-free { color: var(--skip); font-weight: 400; }

.s-open {
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 5px 9px;
}

/* Aufklappbare Zeile: Tippen zeigt die Status-Buttons, ganz ohne JavaScript. */
.list details { border-bottom: 1px solid var(--line); }
.list details:last-child { border-bottom: 0; }
.list details > summary { cursor: pointer; list-style: none; }
.list details > summary::-webkit-details-marker { display: none; }
.list details .row { border-bottom: 0; }
.list details[open] > summary .row { background: var(--surface-2); }
.list details .panel { padding: 4px 14px 14px; background: var(--surface-2); }
.list details .panel .btn { min-height: 48px; }

.panel-note {
    font-size: 12.5px;
    color: var(--muted);
    margin: 10px 0 0;
    text-align: center;
}

.panel-note button {
    appearance: none;
    background: none;
    border: 0;
    color: var(--danger);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
    padding: 6px;
}

details.inline-form {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

details.inline-form > summary {
    padding: 13px 14px;
    min-height: var(--tap);
    display: flex;
    align-items: center;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    list-style: none;
}

details.inline-form > summary::-webkit-details-marker { display: none; }
details.inline-form .panel { padding: 4px 14px 14px; border-top: 1px solid var(--line); }
details.inline-form .panel .row-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

.chev { color: var(--muted); }

/* ---------- Einstellungen ---------- */

.settings {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 14px;
}

.setting {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    min-height: var(--tap);
    color: inherit;
    text-decoration: none;
    width: 100%;
    background: none;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.setting:last-child { border-bottom: 0; }
form.setting { margin: 0; }
.setting .btn { flex: 0 0 auto; min-height: 38px; padding: 8px 12px; font-size: 13.5px; }
.setting .lbl { flex: 1; }
.setting .lbl small { display: block; color: var(--muted); font-size: 12.5px; }
.setting .val { color: var(--muted); font-size: 14px; }
.setting.add .lbl { color: var(--accent); font-weight: 600; }
.setting.danger .lbl { color: var(--danger); }

/* ---------- Formulare ---------- */

form .field { margin-bottom: 14px; }

form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 5px;
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="date"],
form input[type="time"],
form select,
form textarea {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 12px;
    min-height: var(--tap);
    appearance: none;
    -webkit-appearance: none;
}

form input:focus,
form select:focus,
form textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

form .help { font-size: 12.5px; color: var(--muted); margin: 5px 0 0; }
form .checkboxes { display: flex; flex-direction: column; gap: 8px; }

form .checkboxes label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 400;
    color: var(--text);
    margin: 0;
    min-height: var(--tap);
}

form input[type="checkbox"],
form input[type="radio"] {
    width: 22px;
    height: 22px;
    accent-color: var(--accent);
    flex: 0 0 auto;
}

form .errors {
    color: var(--danger);
    font-size: 13px;
    margin: 5px 0 0;
    padding: 0;
    list-style: none;
}

fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin: 0 0 14px;
}

legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }

/* ---------- Tabbar ---------- */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    backdrop-filter: saturate(180%) blur(12px);
}

.tab {
    flex: 1;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    padding: 2px 0;
}

.tab .ico { display: block; font-size: 20px; line-height: 1.2; margin-bottom: 2px; }
.tab.on { color: var(--accent); }

/* ---------- Login ---------- */

.login {
    max-width: 22rem;
    margin: 12vh auto 0;
    padding: 0 20px;
}

.login h1 { font-size: 24px; margin: 0 0 4px; }
.login p.lead { color: var(--muted); margin: 0 0 24px; font-size: 14.5px; }
