:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #1c2024;
    --muted: #6b7280;
    --accent: #0d6b5e;
    --accent-soft: #e6f2f0;
    --warn: #9a5b00;
    --warn-soft: #fdf3e2;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 60rem; margin: 0 auto; padding: 0 1.25rem; }

/* ---------- Kopfbereich ---------- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }

.topbar__inner {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding-block: 1.35rem;
}

.topbar h1 { margin: 0; font-size: 1.4rem; letter-spacing: -.01em; }
.topbar__sub { margin: .15rem 0 0; color: var(--muted); font-size: .875rem; }

.stats { display: flex; gap: 1.75rem; margin: 0; }
.stats dt { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.stats dd { margin: 0; font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stats__open { color: var(--accent); }
.stats__done { color: var(--muted); }

/* ---------- Abruf-Button & Meldungen ---------- */

.topbar__right { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center; }

.fetch { display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; }

.btn {
    padding: .5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .875rem;
    font-weight: 550;
    cursor: pointer;
}

.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: #0a564b; border-color: #0a564b; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }

.fetch__stand { margin: 0; color: var(--muted); font-size: .725rem; }
.fetch__failed { color: #b42318; font-weight: 600; }

.flash {
    margin: 1.25rem 0 0;
    padding: .8rem 1rem;
    border: 1px solid;
    border-radius: var(--radius);
    font-size: .9rem;
}

.flash--success { background: #eaf7f2; border-color: #b6e0cf; color: #0a544a; }
.flash--info { background: #eef1f4; border-color: var(--border); color: var(--text); }
.flash--warn { background: var(--warn-soft); border-color: #e8cfa0; color: var(--warn); }
.flash--error { background: #fdecec; border-color: #f5c2c2; color: #9a2626; }
.flash code { background: rgba(0, 0, 0, .07); }

/* ---------- Fokus-Kasten ---------- */

.focus {
    margin-top: 1.5rem;
    padding: 1.1rem 1.25rem;
    background: var(--accent-soft);
    border: 1px solid #cfe4e0;
    border-radius: var(--radius);
}

.focus h2 { margin: 0 0 .5rem; font-size: .95rem; color: #0a544a; }
.focus__date { font-weight: 400; color: #4a7b74; }
.focus p { margin: 0 0 .6rem; font-size: .925rem; }
.focus p:last-child { margin-bottom: 0; }

/* ---------- Filter & Suche ---------- */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    margin: 1.5rem 0 1rem;
}

.tabs { display: flex; gap: .25rem; padding: .25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }

.tab {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .4rem .9rem;
    border-radius: 999px;
    color: var(--muted);
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
}

.tab:hover { color: var(--text); background: #f0f1f3; }
.tab--active { background: var(--accent); color: #fff; }
.tab--active:hover { background: #0a564b; color: #fff; }
.tab__count { font-variant-numeric: tabular-nums; font-size: .8rem; opacity: .75; }

.search { display: flex; align-items: center; gap: .4rem; }

.search input[type="search"] {
    min-width: 15rem;
    padding: .45rem .7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: .875rem;
}

.search input:focus-visible, .task__check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.search button {
    padding: .45rem .85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: .875rem;
    cursor: pointer;
}

.search button:hover { background: #f0f1f3; }
.search__reset { color: var(--muted); font-size: .8rem; }

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

.tasks { list-style: none; margin: 0 0 2rem; padding: 0; display: flex; flex-direction: column; gap: .75rem; }

.task {
    display: flex;
    gap: .9rem;
    padding: 1.1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.task--done { border-left-color: #cbd2d8; background: #fbfbfc; }
.task--done .task__body h3, .task--done .task__desc { color: var(--muted); }
.task--done .task__body h3 { text-decoration: line-through; text-decoration-color: #c3cad1; }

.task__check { flex: 0 0 auto; padding-top: .15rem; }
.task__check input[type="checkbox"] { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); cursor: pointer; }

.task__body { flex: 1 1 auto; min-width: 0; }

.task__head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; justify-content: space-between; }
.task__head h3 { margin: 0; font-size: 1.05rem; line-height: 1.35; }

.task__pos {
    display: inline-block;
    min-width: 1.4rem;
    margin-right: .25rem;
    color: var(--muted);
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.badge { padding: .15rem .5rem; border-radius: 999px; font-size: .725rem; font-weight: 600; white-space: nowrap; }
.badge--done { background: #eef1f3; color: var(--muted); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }

.task__url { display: inline-block; margin: .15rem 0 .5rem; color: var(--accent); font-size: .8rem; word-break: break-all; }

.task__desc p { margin: 0 0 .6rem; font-size: .925rem; }
.task__desc p:last-child { margin-bottom: 0; }

.task__sources { margin-top: .7rem; font-size: .825rem; }
.task__sources summary { color: var(--muted); cursor: pointer; }
.task__sources ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.task__sources li { margin-bottom: .2rem; word-break: break-all; }

.task__meta { margin: .8rem 0 0; color: var(--muted); font-size: .775rem; }

.empty {
    padding: 2.5rem 1.25rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

/* ---------- Fuss & Einrichtung ---------- */

.foot { padding-bottom: 2.5rem; color: var(--muted); font-size: .775rem; }
.foot p { margin: 0; }

.setup { max-width: 44rem; padding-block: 3rem; }
.setup h1 { font-size: 1.4rem; }
.setup h2 { font-size: 1rem; margin-top: 2rem; }
.setup__error { padding: .85rem 1rem; background: #fdecec; border: 1px solid #f5c2c2; border-radius: 8px; white-space: pre-wrap; }
.setup li { margin-bottom: .75rem; }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
code { padding: .1rem .3rem; background: #eef0f2; border-radius: 4px; }
pre { margin: .4rem 0 0; padding: .6rem .8rem; background: #1c2024; color: #e8eaed; border-radius: 8px; overflow-x: auto; }
pre code { background: none; padding: 0; }

a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 42rem) {
    .topbar__right { width: 100%; justify-content: space-between; gap: 1rem; }
    .fetch { align-items: flex-end; text-align: right; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .tabs { justify-content: space-between; }
    .search input[type="search"] { min-width: 0; flex: 1; }
    .task { padding: .9rem 1rem; }
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #14161a;
        --surface: #1c1f24;
        --border: #2c3138;
        --text: #e6e8ea;
        --muted: #99a1ab;
        --accent: #4ec9b4;
        --accent-soft: #16302c;
        --warn: #e0a458;
        --warn-soft: #322612;
    }
    :root:not([data-theme="light"]) .tab:hover { background: #262a30; }
    :root:not([data-theme="light"]) .tab--active { color: #10201d; }
    :root:not([data-theme="light"]) .tab--active:hover { background: #6fd9c7; color: #10201d; }
    :root:not([data-theme="light"]) .task--done { background: #191c20; border-left-color: #333941; }
    :root:not([data-theme="light"]) .badge--done { background: #262a30; }
    :root:not([data-theme="light"]) .focus { border-color: #22453f; }
    :root:not([data-theme="light"]) .focus h2 { color: #7fdbca; }
    :root:not([data-theme="light"]) .focus__date { color: #8fb3ad; }
    :root:not([data-theme="light"]) .search button:hover { background: #262a30; }
    :root:not([data-theme="light"]) code { background: #262a30; }
    :root:not([data-theme="light"]) .btn--primary { color: #10201d; }
    :root:not([data-theme="light"]) .btn--primary:hover:not(:disabled) { background: #6fd9c7; border-color: #6fd9c7; }
    :root:not([data-theme="light"]) .flash--success { background: #16302c; border-color: #22453f; color: #7fdbca; }
    :root:not([data-theme="light"]) .flash--info { background: #1f2328; border-color: var(--border); }
    :root:not([data-theme="light"]) .flash--error { background: #2e1a1a; border-color: #5a2b2b; color: #f0a7a7; }
    :root:not([data-theme="light"]) .fetch__failed { color: #f0a7a7; }
    :root:not([data-theme="light"]) .flash code { background: rgba(255, 255, 255, .1); }
    :root:not([data-theme="light"]) .setup__error { background: #2e1a1a; border-color: #5a2b2b; }
}
