* { box-sizing: border-box; }

/* --- Schriften (selbst gehostet, SIL OFL; siehe fonts/LIZENZ.txt) -------- */
@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/Inter-Regular.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600 700; font-style: normal; font-display: swap; src: url("fonts/Inter-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Inter Display"; font-weight: 600 700; font-style: normal; font-display: swap; src: url("fonts/InterDisplay-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/JetBrainsMono-Medium.woff2") format("woff2"); }

/* --- Farben (hell) ------------------------------------------------------- */
/* Koralle = hier passiert etwas / erledigt; Petrol (--accent) = klickbar, filtern, Fokus; Grau/Weiß = alles andere */
:root {
    color-scheme: light;
    --bg: #FFFFFF;
    --card: #F4F4F5;
    --text: #111111;
    --muted: #52525B;
    --faint: #71717A;
    --line: #E4E4E7;
    --input-bg: #FFFFFF;
    --input-border: #D4D4D8;
    --coral: #FF5A36;   /* Koralle: nur Schalter, Hauptbutton, Menü-Balken (siehe docs/brand/STYLEGUIDE.md) */
    --coral-hover: #E8461F;
    --on-coral: #1C1C1E;
    --accent: #247B8F;
    --accent-hover: #1B6275;
    --accent-fg: #247B8F;
    --on-accent: #FFFFFF;
    --accent-soft: rgba(36, 123, 143, .12);
    --accent-line: rgba(36, 123, 143, .35);
    --flash: rgba(249, 115, 22, .5);
    --flash-soft: rgba(249, 115, 22, .16);
    --danger: #e12d39;
    --danger-soft: #fde8e8;
    --warn: #B7791F;
    --ok: #16a34a;
    --mark: #fef08a;
    --shadow: 0 4px 20px rgba(0, 0, 0, .05);
}

/* --- Farben (dunkel): automatisch nach System oder per Schalter ---------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #1C1C1E;
        --card: #2A2A2D;
        --text: #F4F4F5;
        --muted: #A1A1AA;
        --faint: #71717A;
        --line: #3A3A3E;
        --input-bg: #1C1C1E;
        --input-border: #4A4A4F;
        --coral: #FF5A36;
        --coral-hover: #FF7A5C;
        --on-coral: #1C1C1E;
        --accent: #59ADC0;
        --accent-hover: #7FC2D1;
        --accent-fg: #59ADC0;
        --on-accent: #111111;
        --accent-soft: rgba(89, 173, 192, .15);
        --accent-line: rgba(89, 173, 192, .4);
        --flash: rgba(251, 146, 60, .42);
        --flash-soft: rgba(251, 146, 60, .13);
        --danger: #f87171;
        --danger-soft: #3b1f22;
        --warn: #E5A00D;
        --ok: #4ade80;
        --mark: #854d0e;
        --shadow: 0 4px 20px rgba(0, 0, 0, .4);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1C1C1E;
    --card: #2A2A2D;
    --text: #F4F4F5;
    --muted: #A1A1AA;
    --faint: #71717A;
    --line: #3A3A3E;
    --input-bg: #1C1C1E;
    --input-border: #4A4A4F;
    --coral: #FF5A36;
    --coral-hover: #FF7A5C;
    --on-coral: #1C1C1E;
    --accent: #59ADC0;
    --accent-hover: #7FC2D1;
    --accent-fg: #59ADC0;
    --on-accent: #111111;
    --accent-soft: rgba(89, 173, 192, .15);
    --accent-line: rgba(89, 173, 192, .4);
    --flash: rgba(251, 146, 60, .42);
    --flash-soft: rgba(251, 146, 60, .13);
    --danger: #f87171;
    --danger-soft: #3b1f22;
    --warn: #E5A00D;
    --ok: #4ade80;
    --mark: #854d0e;
    --shadow: 0 4px 20px rgba(0, 0, 0, .4);
}

body {
    margin: 0;
    font-family: "Inter", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--accent-fg); }
form { margin: 0; }
/* Das hidden-Attribut muss gewinnen, auch wenn eine Klasse display: flex o. ä. setzt */
[hidden] { display: none !important; }
h1 { margin-top: 0; }
h1, h2, .kpi .num { font-family: "Inter Display", "Inter", system-ui, sans-serif; font-weight: 600; letter-spacing: -.01em; }
code, kbd, .copy-row input { font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 500; }
mark { background: var(--mark); color: inherit; border-radius: 2px; }

/* --- Formularelemente ---------------------------------------------------- */
input[type=text], input[type=password], input[type=date], input[type=time], input[type=search], select, textarea {
    padding: 9px 11px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
    min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; }

button {
    padding: 9px 15px;
    border: 0;
    border-radius: 8px;
    background: var(--coral);
    color: var(--on-coral);
    font: inherit;
    cursor: pointer;
}
button:hover { background: var(--coral-hover); }
a.btn {
    display: inline-block;
    padding: 9px 15px;
    border-radius: 8px;
    background: var(--coral);
    color: var(--on-coral);
    text-decoration: none;
}
a.btn:hover { background: var(--coral-hover); }
button.secondary { background: var(--line); color: var(--text); }
button.secondary:hover { background: var(--input-border); }
button.danger-btn { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.danger-btn:hover { background: var(--danger-soft); }
button.link { background: none; color: var(--muted); padding: 0; }
button.link:hover { background: none; text-decoration: underline; }

.icon {
    background: none; color: var(--faint); padding: 4px 6px;
    text-decoration: none; font-size: 1rem;
}
.icon:hover { background: none; color: var(--accent-fg); }
.icon.danger:hover { color: var(--danger); }

/* --- Rahmen -------------------------------------------------------------- */
.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar .brand { display: inline-flex; text-decoration: none; }
/* Logo: je Design die passende Fassung (dunkel auf hellem, hell auf dunklem Grund); beide stehen im HTML, siehe brand_logo() */
.logo-wrap { display: inline-flex; line-height: 0; }
.logo { height: 26px; width: auto; }
.logo-on-dark { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .logo-on-light { display: none; }
    :root:not([data-theme="light"]) .logo-on-dark { display: inline; }
}
:root[data-theme="dark"] .logo-on-light { display: none; }
:root[data-theme="dark"] .logo-on-dark { display: inline; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.auth-logo .logo { height: auto; width: 220px; max-width: 100%; }
.topbar .search { flex: 1; max-width: 360px; }
.topbar .search input { width: 100%; padding: 7px 11px; }
.topbar nav { display: flex; gap: 16px; align-items: center; margin-left: auto; }
.topbar nav a { text-decoration: none; color: var(--text); }
.topbar nav a:hover { color: var(--accent-fg); }
.topbar .user { color: var(--muted); }

.flash {
    max-width: 960px; margin: 16px auto 0; padding: 10px 14px;
    background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 8px;
}

.card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    min-width: 0;
}

.app {
    display: grid; grid-template-columns: 220px 1fr; gap: 24px;
    max-width: 1000px; margin: 24px auto; padding: 0 16px;
}
.wide { max-width: 760px; margin: 24px auto; }
.muted { color: var(--muted); }
.empty { color: var(--muted); }

/* --- Login / Registrierung ---------------------------------------------- */
.auth { max-width: 380px; margin: 64px auto; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.error { color: var(--danger); }

/* --- Seitenleiste -------------------------------------------------------- */
.sidebar ul { list-style: none; padding: 0; margin: 0 0 12px; }
.sidebar li a {
    display: flex; gap: 6px; align-items: center;
    padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none;
}
.sidebar li a:hover { background: var(--card); }
.sidebar li a.active { background: var(--card); color: var(--text); box-shadow: inset 3px 0 0 var(--coral); font-weight: 600; }
.sidebar li.sep {
    margin: 16px 10px 6px; font-size: .75rem; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted);
}
.sidebar .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .shared { font-size: .8rem; }
.sidebar .count { font-size: .8rem; opacity: .7; }
.sidebar .manage { font-size: .9rem; text-decoration: none; padding: 0 10px; }

/* --- Aufgaben-Formular --------------------------------------------------- */
.todo-form { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.todo-form .title-input { width: 100%; font-size: 1.05rem; padding: 11px 13px; }
.todo-form .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.todo-form .buttons { display: flex; gap: 10px; align-items: center; margin-left: auto; }
/* Notizfeld beim Anlegen erst zeigen, wenn ein Titel getippt ist. Nicht schon bei Fokus: Das Titelfeld hat
   autofocus, sonst klappte das Feld bei jedem Seitenaufruf (z. B. Klick auf Sortierung/Filter) auf. */
.todo-form:not(.editing) textarea { display: none; }
.todo-form:not(.editing):has(.title-input:not(:placeholder-shown)) textarea,
.todo-form:not(.editing) textarea:not(:placeholder-shown) { display: block; }

/* Tag-Vorschläge */
.tags-wrap { position: relative; flex: 1 1 170px; display: flex; }
.tags-wrap .tags-input { width: 100%; }
.suggest {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 10;
    display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
    min-width: 100%; padding: 6px; background: var(--card);
    border: 1px solid var(--input-border); border-radius: 8px; box-shadow: var(--shadow);
}
.suggest button {
    padding: 3px 9px; border-radius: 999px; font-size: .85rem;
    background: var(--accent-soft); color: var(--accent-fg);
}
.suggest button.active, .suggest button:hover { background: var(--accent); color: var(--on-accent); }
.suggest .hint { margin-left: auto; font-size: .75rem; color: var(--muted); }

/* --- Filter & Tags ------------------------------------------------------- */
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 20px 0 8px; }
.filter { display: flex; gap: 6px; flex-wrap: wrap; }
.filter a { color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 6px; font-size: .95rem; }
.filter a:hover { color: var(--text); }
.filter a.active { background: var(--line); color: var(--text); }
.filter.sort a { font-size: .85rem; }

.tagbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag {
    display: inline-block; padding: 2px 8px; border-radius: 6px;
    background: var(--accent-soft); color: var(--accent-hover);   /* etwas kräftiger als Petrol: Kontrast ≥ 4,5:1 auf der getönten Fläche */
    font-size: .8rem; text-decoration: none;
}
.tag:hover, .tag.active { background: var(--accent); color: var(--on-accent); }

/* --- Aufgabenliste ------------------------------------------------------- */
.todos { list-style: none; padding: 0; margin: 0; }
.todos > li {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--line);
    background: var(--card);
}
.todos > li:target { background: var(--accent-soft); border-radius: 8px; }
/* Von anderen geänderte Zeile: zweimal kurz orange aufblinken, dann langsam ausglühen */
.todos > li.changed { border-radius: 8px; animation: change-glow 3.3s ease-out; }
@keyframes change-glow {
    0%   { background: transparent; }
    4%   { background: var(--flash); }
    9%   { background: var(--flash-soft); }
    14%  { background: var(--flash); }
    100% { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
    .todos > li.changed { animation: change-fade 2.7s ease-out; }
    @keyframes change-fade { 0% { background: var(--flash); } 100% { background: transparent; } }
}
.todos .body { flex: 1; min-width: 0; padding-top: 3px; }
.todos .title { word-break: break-word; }
.todos > li.done > .body > .title { text-decoration: line-through; color: var(--faint); }
.todos .empty { justify-content: center; }
.todos .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; font-size: .8rem; }
.todos .meta:empty { display: none; }

.project-order { list-style: none; padding: 0; margin: 8px 0 0; max-width: 420px; }
.project-order li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.project-order .handle { cursor: grab; }
.handle {
    width: 14px; flex: none; padding-top: 4px;
    color: var(--faint); cursor: grab; user-select: none; touch-action: none;
}
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: var(--shadow); }

.due { color: var(--muted); }
.due.today { color: var(--warn); font-weight: 600; }
.due.overdue { color: var(--danger); font-weight: 600; }
.assignee {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 1px 8px 1px 1px; border-radius: 999px; background: var(--bg); color: var(--text); font-weight: 500;
}
.assignee .avatar { width: 1.6em; height: 1.6em; font-size: .65rem; }
.assignee.me { background: var(--accent); color: var(--on-accent); font-weight: 600; }
/* Zuweisungs-Spalte in geteilten Projekten */
.owner {
    display: flex; flex-direction: column; align-items: center; gap: 3px; flex: none;
    width: 68px; padding-top: 1px; font-size: .75rem; color: var(--muted); text-align: center;
}
.owner .avatar { width: 34px; height: 34px; font-size: .85rem; }
.owner .avatar.empty { background: none; border: 2px dashed var(--input-border); }
.owner-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 500; }
.owner.none .owner-name { color: var(--faint); font-weight: 400; }
.owner.me .avatar { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
.owner.me .owner-name { color: var(--accent-fg); font-weight: 700; }
.todos > li.done .owner { opacity: .5; }
@media (max-width: 600px) {
    .owner { width: 50px; }
}

/* Offene Aufgaben, die mir zugewiesen sind, fallen schon am Rand auf */
.todos li.mine { box-shadow: inset 3px 0 0 var(--accent); }

/* Aufgaben-Schalter (OwnDo): Umriss mit Knopf wie im Logo. AN = Knopf rechts in Koralle = die Aufgabe ist aktiv (offen);
   AUS = Knopf links, grau = erledigt. Koralle steht für „das, was aktiv ist“ (siehe docs/brand/STYLEGUIDE.md). Kein Haken. */
.check {
    position: relative; flex: none; width: 40px; height: 24px; padding: 0;
    border: 2px solid var(--text); border-radius: 999px;
    background: transparent; color: transparent; font-size: 0; cursor: pointer;
}
.check::before {   /* Knopf */
    content: ''; position: absolute; top: 50%; left: 3px; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%;
    background: var(--faint); transition: transform .15s ease, background-color .15s ease;
}
.check::after { content: ''; position: absolute; inset: -8px -4px; }   /* größere Trefferfläche für den Finger */
.check:hover { background: transparent; }
.check:hover::before { background: var(--muted); }
.check[aria-checked="false"] { border-color: var(--faint); }   /* erledigt: ganz grau, wie die durchgestrichene Zeile */
.check:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.check[aria-checked="true"]::before { transform: translateX(16px); background: var(--coral); }
.check.small { width: 30px; height: 18px; }
.check.small::before { left: 2px; width: 10px; height: 10px; margin-top: -5px; }
.check.small[aria-checked="true"]::before { transform: translateX(12px); }
@media (prefers-reduced-motion: reduce) { .check::before { transition: none; } }

/* Details: Notizen + Checkliste */
.details { margin-top: 4px; font-size: .9rem; }
.details summary {
    display: inline-flex; gap: 10px; cursor: pointer; list-style: none;
    color: var(--muted); font-size: .8rem; user-select: none;
}
.details summary::-webkit-details-marker { display: none; }
.details summary:hover { color: var(--accent-fg); }
.details summary .complete { color: var(--ok); }
.details .add-hint { opacity: 0; transition: opacity .15s; }
.todos > li:hover .add-hint, .details[open] .add-hint, .add-hint:focus { opacity: 1; }
.details[open] summary { margin-bottom: 8px; }
.notes {
    padding: 8px 12px; margin-bottom: 8px; border-left: 3px solid var(--accent-line);
    background: var(--bg); border-radius: 0 6px 6px 0; word-break: break-word;
}
/* Aufgeklappt: Notizen in Ruhe lesen – größere Schrift, angenehme Zeilenlänge */
.details[open] .notes.readable { font-size: .97rem; line-height: 1.6; max-width: 70ch; padding: 12px 16px; }
.details-foot {
    display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: .8rem;
}
.edit-btn {
    padding: 5px 12px; border-radius: 8px; background: var(--line); color: var(--text);
    text-decoration: none; font-size: .85rem;
}
.edit-btn:hover { background: var(--input-border); }
.subtasks { list-style: none; padding: 0; margin: 0 0 6px; }
.subtasks li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.subtasks li .title { flex: 1; }
.subtasks li.done .title { text-decoration: line-through; color: var(--faint); }
.subtasks .icon { font-size: .8rem; opacity: 0; }
.subtasks li:hover .icon { opacity: 1; }
.sub-add input { width: 100%; padding: 6px 10px; font-size: .9rem; }

footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 16px; color: var(--muted); font-size: .9rem;
}

.app-version { text-align: center; margin: 24px 0 16px; font-size: .8rem; font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 500; }
.app-version a { color: var(--faint); text-decoration: none; }
.app-version a:hover { color: var(--muted); text-decoration: underline; }
.changelog h2 { font-size: 1.15rem; margin: 24px 0 4px; }
.changelog h3 { font-size: .95rem; margin: 12px 0 4px; color: var(--muted); }
.changelog ul { margin: 0 0 8px; padding-left: 20px; }
.changelog li { margin: 2px 0; }

/* --- Suche --------------------------------------------------------------- */
.results .result { display: flex; flex-direction: column; gap: 4px; flex: 1; color: var(--text); text-decoration: none; padding: 2px 4px; border-radius: 6px; }
.results .result:hover { background: var(--bg); }
.results li.done .title { text-decoration: line-through; color: var(--faint); }
.snippet { font-size: .85rem; color: var(--muted); }

/* --- Projektverwaltung --------------------------------------------------- */
.add { display: flex; gap: 8px; flex-wrap: wrap; }
.add .grow { flex: 1 1 200px; }
.project { border-top: 1px solid var(--line); padding: 16px 0; }
.project header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.project h2 { margin: 0; font-size: 1.1rem; }
.project h2 a { color: var(--text); text-decoration: none; }
.project p { margin: 8px 0 0; font-size: .9rem; }
.my-role { font-size: .9rem; }
.member-list { list-style: none; padding: 0; margin: 10px 0 14px; }
.member-list li {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .9rem;
}
.member-list li:last-child { border-bottom: 0; }
.member-list li.disabled .name { opacity: .55; }
.member-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-left: auto; font-size: .85rem; }
.member-actions .link.danger { color: var(--danger); }
.role-badge {
    display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600;
    background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}
.role-badge.role-owner { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.role-badge.role-manager { background: var(--accent-soft); color: var(--accent-fg); border-color: var(--accent-line); }

/* Namenskürzel: Farbton pro Benutzer (--hue), Helligkeit fest – lesbar in hell und dunkel */
.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 1.7em; height: 1.7em; border-radius: 50%;
    background: hsl(var(--hue) 55% 42%); color: #fff;
    font-size: .72rem; font-weight: 700; letter-spacing: .02em; line-height: 1;
}
.member-list .avatar { font-size: .8rem; }
.project-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.project-head h1 { margin-bottom: 0; }
.head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.export-links { font-size: .8rem; color: var(--muted); }
.export-links a { color: var(--muted); }
.export-links a:hover { color: var(--accent-fg); }
.team { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); text-decoration: none; }
.team:hover { color: var(--accent-fg); }
.team .avatars { display: inline-flex; gap: 3px; }
.roles-help { margin: 12px 0 4px; font-size: .9rem; }
.roles-help summary { cursor: pointer; color: var(--accent-fg); }
.roles-help td:not(:first-child), .roles-help th { text-align: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline { display: flex; gap: 6px; }
.inline input { width: 160px; }

/* --- Titel klickbar (öffnet Bearbeiten) ---------------------------------- */
.todos .body > a.title, .dash-list a.title { color: var(--text); text-decoration: none; cursor: pointer; }
.todos .body > a.title:hover, .dash-list a.title:hover { color: var(--accent-fg); }
.dash-list a.title { cursor: pointer; }

/* --- Priorität ----------------------------------------------------------- */
.prio { font-weight: 600; }
.prio { color: var(--muted); }
.prio .flag { color: var(--faint); }
.prio-3 .flag, .prio-2 .flag { color: var(--warn); }

/* --- Drag & Drop auf Projekte -------------------------------------------- */
.dragging .sidebar a[data-project]:not(.active) { outline: 1px dashed var(--input-border); outline-offset: -1px; }
.sidebar a.drop-target {
    outline: 2px solid var(--accent) !important; background: var(--accent-soft); transform: scale(1.03);
    transition: transform .1s;
}
.over-project .todos .sortable-ghost { opacity: .15; }
.sortable-fallback { opacity: .9 !important; box-shadow: var(--shadow); border-radius: 8px; }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
    padding: 10px 18px; border-radius: 999px; background: var(--text); color: var(--card);
    box-shadow: var(--shadow); font-size: .9rem; transition: opacity .4s; max-width: calc(100% - 32px);
}
.toast.hide { opacity: 0; }
/* --- Dashboard ----------------------------------------------------------- */
.dashboard { min-width: 0; }
.dash-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-head h1 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
    display: flex; flex-direction: column; gap: 2px; padding: 14px 16px;
    background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
    color: var(--text); text-decoration: none; border-top: 3px solid var(--line);
}
a.kpi:hover { border-top-color: var(--accent); }
.kpi b { font-size: 1.8rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .85rem; color: var(--muted); }
.kpi.bad { border-top-color: var(--danger); } .kpi.bad b { color: var(--danger); }
.kpi.warn { border-top-color: var(--warn); } .kpi.warn b { color: var(--warn); }
.kpi.good { border-top-color: var(--ok); } .kpi.good b { color: var(--ok); }

.inbox-hint {
    display: block; margin-bottom: 16px; padding: 10px 14px; border-radius: 8px;
    background: var(--accent-soft); border: 1px solid var(--accent-line); text-decoration: none;
}
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dash-section { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 18px; }
.dash-section h2 { font-size: 1rem; margin: 0 0 10px; }
.dash-section.bad h2 { color: var(--danger); }
.dash-section p { margin: 0; font-size: .9rem; }
.dash-list { list-style: none; padding: 0; margin: 0; }
.dash-list li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line); }
.dash-list li:last-child { border-bottom: 0; }
.dash-list .check { margin-top: 1px; }
.dash-list li.done a.title { text-decoration: line-through; color: var(--faint); }
.dash-section.good h2 { color: var(--ok); }
/* Klick auf eine Kachel: angesprungenen Abschnitt kurz hervorheben (sonst passiert scheinbar nichts, wenn er schon sichtbar ist) */
.dash-col > [id] { scroll-margin-top: 16px; }
.dash-col > [id]:target > .dash-section { animation: target-flash 1.6s ease-out; }
@keyframes target-flash {
    0%, 40% { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
    100% { box-shadow: var(--shadow); }
}
.dash-list .body { flex: 1; min-width: 0; }
.dash-list .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: .78rem; margin-top: 3px; }
.proj-chip { padding: 0 7px; border-radius: 999px; background: color-mix(in srgb, var(--pc) 16%, transparent); border-left: 3px solid var(--pc); }

.progress-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.progress-list a { display: flex; justify-content: space-between; gap: 8px; color: var(--text); text-decoration: none; font-size: .9rem; }
.progress-list a:hover .name { color: var(--accent-fg); }
.progress-list .muted { font-size: .8rem; white-space: nowrap; }
.overdue-text { color: var(--danger); }
.bar { height: 6px; margin-top: 5px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--pc); border-radius: 999px; }

/* --- Projektfarben (Kalender) ------------------------------------------- */
.pc-0 { --pc: #3b82f6; } .pc-1 { --pc: #10b981; } .pc-2 { --pc: #f59e0b; } .pc-3 { --pc: #8b5cf6; }
.pc-4 { --pc: #ec4899; } .pc-5 { --pc: #14b8a6; } .pc-6 { --pc: #ef4444; } .pc-7 { --pc: #64748b; }

/* --- Kalender ------------------------------------------------------------ */
.calendar { max-width: 1100px; margin: 24px auto; }
.cal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cal-head h1 { margin: 0; font-size: 1.4rem; min-width: 190px; text-align: center; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav .icon { font-size: 1.6rem; line-height: 1; }
.today-btn {
    margin-left: 8px; padding: 4px 12px; border: 1px solid var(--input-border);
    border-radius: 6px; color: var(--text); text-decoration: none; font-size: .9rem;
}
.today-btn:hover { background: var(--line); }

.cal-grid {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    border-top: 1px solid var(--line); border-left: 1px solid var(--line);
}
.cal-wd {
    padding: 6px; font-size: .8rem; font-weight: 600; color: var(--muted); text-align: center;
    border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.cal-day {
    min-height: 104px; padding: 4px; display: flex; flex-direction: column; gap: 2px;
    border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0;
}
.cal-day.weekend { background: color-mix(in srgb, var(--bg) 50%, transparent); }
.cal-day.other { opacity: .45; }
.cal-day .num { font-size: .8rem; color: var(--muted); align-self: flex-end; padding: 1px 6px; }
.cal-day.today .num { background: var(--accent); color: var(--on-accent); border-radius: 999px; font-weight: 700; }

.cal-item {
    display: block; padding: 2px 6px; border-radius: 4px; font-size: .78rem;
    color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    background: color-mix(in srgb, var(--pc) 16%, transparent);
    border-left: 3px solid var(--pc);
}
.cal-item:hover { background: color-mix(in srgb, var(--pc) 30%, transparent); }
.cal-item .time { font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-item.done .t { text-decoration: line-through; color: var(--faint); }
.cal-item.virtual { opacity: .55; border-left-style: dashed; }
.cal-item.overdue { box-shadow: inset 0 0 0 1px var(--danger); }
.cal-item .proj { color: var(--muted); font-size: .9em; margin-left: auto; }
.legend { font-size: .8rem; margin-top: 10px; }

/* Terminübersicht */
.agenda-day { margin-bottom: 18px; }
.agenda-day h2 { font-size: .95rem; margin: 0 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.agenda-day.is-today h2 { color: var(--accent-fg); }
.overdue-block h2 { color: var(--danger); }
.agenda-row { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.agenda-row .date { width: 44px; flex: none; font-size: .85rem; color: var(--danger); font-variant-numeric: tabular-nums; }
.agenda-row .cal-item { flex: 1; display: flex; gap: 6px; align-items: baseline; font-size: .9rem; padding: 6px 10px; white-space: normal; }

/* --- Einstellungen ------------------------------------------------------- */
.settings section { border-top: 1px solid var(--line); padding: 18px 0; }
.settings section:first-of-type { border-top: 0; padding-top: 0; }
.settings h2 { font-size: 1.1rem; margin: 0 0 8px; }
.settings h3 { font-size: .95rem; margin: 16px 0 8px; }
.settings p { margin: 0 0 10px; }
.settings .stack { display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.settings .actions { align-items: center; margin-bottom: 8px; }
.settings code { font-size: .82rem; word-break: break-all; }
.settings fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0; }
.settings legend { color: var(--muted); font-size: .85rem; padding: 0 4px; }
.settings label { display: flex; align-items: center; gap: 6px; font-size: .92rem; }
.api-new { margin-top: 12px; }
.api-new summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.api-projects { display: flex; flex-direction: column; gap: 2px; padding-left: 22px; }
.secret {
    margin: 0 0 12px; padding: 12px 14px; border-radius: 8px;
    background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.secret strong { display: block; margin-bottom: 8px; font-size: .9rem; }
.secret p { margin: 8px 0 0; font-size: .9rem; }
.secret details { margin-top: 8px; font-size: .9rem; }
.secret ul { margin: 6px 0 0; padding-left: 20px; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { flex: 1; font-size: .8rem; }
.invites { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: 8px; }
.invites th { text-align: left; color: var(--muted); font-weight: 600; }
.invites th, .invites td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.invites tr.muted td { color: var(--muted); }

/* --- Reiter (Einstellungen, Administration) ------------------------------ */
.tabs {
    display: flex; gap: 4px; margin: 0 0 20px; border-bottom: 1px solid var(--line);
    overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
    padding: 8px 12px; color: var(--muted); text-decoration: none; white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a[href="/admin"]:not(.active), .tabs a[href="/einstellungen"]:not(.active):last-child { margin-left: auto; }
.settings section:first-of-type { padding-top: 0; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* --- Administration ------------------------------------------------------ */
.user-list { list-style: none; padding: 0; margin: 16px 0 0; }
.user-list li {
    display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap;
    padding: 12px 0; border-top: 1px solid var(--line);
}
.user-list li.disabled .who strong { text-decoration: line-through; color: var(--muted); }
.user-list .who { flex: 1 1 260px; min-width: 0; }
.user-list .buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.small { font-size: .82rem; }
button.small { padding: 5px 10px; }
.badge {
    display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 999px;
    font-size: .75rem; background: var(--line); color: var(--text); vertical-align: 1px;
}
.badge.admin { background: var(--accent-soft); color: var(--accent-fg); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.button-link { font-size: .82rem; padding: 5px 10px; border-radius: 8px; text-decoration: none; align-self: center; }
.button-link.danger { color: var(--danger); }
.delete-plan { max-width: none !important; }
.delete-plan .decision { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.delete-plan ul { margin: 0; padding-left: 20px; font-size: .92rem; }

/* --- Handy --------------------------------------------------------------- */
@media (max-width: 700px) {
    .dash-grid { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .cal-day { min-height: 64px; padding: 2px; }
    .cal-item { font-size: .65rem; padding: 1px 3px; border-left-width: 2px; }
    .cal-item .time, .cal-item .rep { display: none; }
    .cal-head h1 { min-width: 0; font-size: 1.15rem; }
    .invites th:nth-child(2), .invites td:nth-child(2) { display: none; }

    /* Rahmen */
    /* minmax(0, …): sonst wächst die Spalte mit der langen Projekt-Chip-Zeile mit, statt sie scrollen zu lassen */
    .app { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 0; }
    .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 10px 16px; }
    .topbar .search { order: 3; flex-basis: 100%; max-width: none; }
    .topbar nav { gap: 14px; }
    .topbar .uname { display: none; }                 /* nur ⚙ – Einstellungen bleiben erreichbar */
    .card { padding: 16px; }
    .user-list .buttons { justify-content: flex-start; }

    /* Seitenleiste → eine wischbare Zeile mit Projekt-Chips, bleibt beim Scrollen oben
       (Projekt wechseln und Aufgaben auf ein Projekt ziehen geht so von überall) */
    .sidebar {
        position: sticky; top: 0; z-index: 5;
        margin: 0 -16px; padding: 8px 16px;
        background: var(--bg); border-bottom: 1px solid var(--line);
    }
    .sidebar ul {
        display: flex; gap: 6px; margin: 0;
        overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
    }
    .sidebar ul::-webkit-scrollbar { display: none; }
    .sidebar li.sep, .sidebar .manage { display: none; }
    .sidebar li a {
        white-space: nowrap; padding: 6px 12px;
        border: 1px solid var(--line); border-radius: 999px; background: var(--card);
    }
    .sidebar .name { max-width: 150px; }
    .dragging .sidebar a[data-project]:not(.active) { outline-offset: 1px; }
    .todos > li, section[id], .dash-col > [id] { scroll-margin-top: 70px; }   /* Sprungziele (#todo-7) nicht unter der Leiste verstecken */

    /* Filter und Sortierung: je eine wischbare Zeile statt Umbruch */
    .toolbar { flex-direction: column; gap: 6px; margin-top: 16px; }
    .filter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .filter::-webkit-scrollbar { display: none; }
    .filter a { white-space: nowrap; }

    /* Fingergerechte Tippflächen */
    .todos .icon { padding: 10px; margin: -6px -2px; }
    .handle { width: 24px; margin-left: -6px; text-align: center; font-size: 1.1rem; }
    .todo-form .buttons { margin-left: 0; }
    .subtasks .icon, .add-hint { opacity: 1; }

    /* Neue Aufgabe: erst nur das Titelfeld (Enter speichert), Datum/Priorität/Tags … erscheinen beim Tippen */
    .todo-form:not(.editing):not(:has(.title-input:not(:placeholder-shown))) .row { display: none; }
    main.card > h1 { font-size: 1.5rem; }

    /* iOS zoomt in Eingabefelder unter 16 px hinein (und nicht wieder heraus) */
    input, select, textarea { font-size: 16px !important; }
}

/* --- Symbole (Lucide, inline) -------------------------------------------- */
.ic { width: 1.1em; height: 1.1em; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar .ic, .dash-section h2 .ic, .tabs .ic, .settings h2 .ic { color: var(--muted); }
.sidebar li a.active .ic { color: var(--text); }
.todos .ic, .dash-list .ic, .due .ic, .handle .ic { width: 1em; height: 1em; }
.icon .ic { width: 1.05em; height: 1.05em; vertical-align: -.2em; }
.icon:hover .ic, a:hover > .ic { color: var(--text); }
h1 .ic { width: .85em; height: .85em; vertical-align: -.05em; color: var(--muted); }
.prio .flag .ic { width: .95em; height: .95em; vertical-align: -.15em; }
#theme-toggle .ic { display: none; }
#theme-toggle:not([data-mode]) .t-auto, #theme-toggle[data-mode="auto"] .t-auto,
#theme-toggle[data-mode="dark"] .t-dark, #theme-toggle[data-mode="light"] .t-light { display: inline; }
.topbar .user .ic { vertical-align: -.2em; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
