:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2125;
    --muted: #5e6670;
    --line: #e2e5e9;
    --accent: #1a5fb4;
    --accent-text: #ffffff;
    --ok: #26804a;
    --ok-bg: #e5f4ea;
    --warn: #9a5b00;
    --warn-bg: #fff2d9;
    --error: #c01c28;
    --error-bg: #fde7e9;
    --radius: 12px;
    --tap: 44px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #15181b;
        --surface: #1f2327;
        --text: #e8eaed;
        --muted: #9aa3ad;
        --line: #31363c;
        --accent: #78aeed;
        --accent-text: #0d1b2a;
        --ok: #6fcf8f;
        --ok-bg: #1b3325;
        --warn: #f0b85a;
        --warn-bg: #3a2c12;
        --error: #ff7b84;
        --error-bg: #3d1c20;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

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

/* ---------- Kopfleiste ---------- */

.bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 52px;
    padding: env(safe-area-inset-top, 0px) 8px 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.bar-title {
    flex: 1;
    margin: 0 8px;
    font-size: 1.1rem;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-back, .bar-action {
    min-width: var(--tap);
    min-height: var(--tap);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--accent);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.bar-action:disabled { opacity: .4; }

.notice {
    margin: 0;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-size: .9rem;
}
.notice-info { background: var(--warn-bg); color: var(--text); }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-error { background: var(--error-bg); color: var(--error); }

main {
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 16px 32px;
}

/* ---------- Liste ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    margin-bottom: 12px;
}

.search {
    flex: 1 1 200px;
    min-height: var(--tap);
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--tap);
    color: var(--muted);
    font-size: .95rem;
}
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

.cards { display: grid; gap: 10px; }

.card {
    display: block;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: inherit;
    text-decoration: none;
}
.card:active { transform: scale(.995); }
.card-urgent { border-color: var(--error); box-shadow: inset 4px 0 0 var(--error); }

.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.card-name { font-size: 1.05rem; }
.card-date { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.card-sub { color: var(--muted); font-size: .9rem; margin: 2px 0 10px; }
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.meter {
    height: 6px;
    border-radius: 3px;
    background: var(--line);
    overflow: hidden;
}
.meter span { display: block; height: 100%; background: var(--ok); border-radius: 3px; transition: width .2s; }
.meter-lg { height: 8px; margin: 10px 0 6px; }

.badge {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
    font-size: .8rem;
}
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }

.text-urgent, .text-error { color: var(--error); }

.empty { color: var(--muted); text-align: center; padding: 32px 0; }

.foot { margin-top: 24px; color: var(--muted); font-size: .85rem; text-align: center; }

/* ---------- Detail ---------- */

.summary {
    padding: 14px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}
.summary-line { font-size: .95rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.chip {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 100%;
    min-height: var(--tap);
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.chip-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.chip-value { font-size: .9rem; overflow-wrap: anywhere; }

.phase {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}
.phase summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--tap);
    padding: 0 14px;
    font-size: .95rem;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
}
.phase summary::-webkit-details-marker { display: none; }
.phase summary::after { content: "›"; margin-left: 10px; color: var(--muted); transition: transform .15s; }
.phase[open] summary::after { transform: rotate(90deg); }
.phase[open] summary { border-bottom: 1px solid var(--line); }
.phase-count { margin-left: auto; color: var(--muted); font-weight: 500; }
.phase-done summary { color: var(--ok); }

.steps { list-style: none; margin: 0; padding: 0; }

.step {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}
.step:last-child { border-bottom: 0; }
.step-failed { background: var(--error-bg); }
.step-na { opacity: .55; }

.check {
    flex: none;
    width: 26px;
    height: 26px;
    margin: 0;
    accent-color: var(--ok);
}

.step-body { flex: 1; min-width: 0; }
.step-title { display: block; font-weight: 550; cursor: pointer; }
.step-done .step-title { color: var(--muted); }
.wi { margin-left: 6px; font-size: .75rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.step-meta { font-size: .8rem; color: var(--muted); }
.src { font-weight: 600; }
.src-script { color: var(--accent); }
.src-verify { color: var(--warn); }
.step-detail, .step-note { font-size: .85rem; margin-top: 4px; overflow-wrap: anywhere; }
.step-note { padding: 6px 8px; border-radius: 8px; background: var(--bg); white-space: pre-wrap; }

.note-edit textarea {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
.note-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ---------- Bedienelemente ---------- */

.btn {
    min-height: var(--tap);
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

.link {
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
}
.link.small { font-size: .85rem; }
.link.center { display: block; margin: 8px auto; }

.login { text-align: center; padding: 48px 0; }
.login p { color: var(--muted); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
