/* Look & Feel: schlicht und flach, an Todoist angelehnt – weißer Grund, Listen mit feinen Trennlinien,
   keine Karten, keine Schatten, ein einziger Akzent (Schieferblau). */
/* Inter (variabel, Teilmenge Latin), lokal ausgeliefert; Lizenz: fonts/Inter-OFL.txt (SIL OFL 1.1) */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2-variations"), url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
}
:root {
  --bg: #fff; --sidebar: #f6f7f9; --surface: #fff; --hover: #f5f5f5; --field: #f4f4f4;
  --text: #202020; --muted: #808080; --line: #ebebeb;
  --accent: #5b6b8c; --accent-text: #fff;
  --warm: #b4540a;          /* Frist erreicht/überschritten: Hinweis, kein Alarm */
  --danger: #c0392b;        /* nur für „Löschen“ */
  --check: #808080;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; padding: 0 0 calc(64px + env(safe-area-inset-bottom));
}
main { max-width: 720px; margin: 0 auto; padding: 0 16px 24px; }
h2, h3, h4 { margin: 0; line-height: 1.25; }
small, .muted { color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* Kopfzeile mit Schnellerfassung */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; border-bottom: 1px solid var(--line); }
#quick { display: flex; gap: 8px; max-width: 720px; margin: 0 auto; }
#quick input { flex: 1; min-width: 0; }
#quick button { width: 40px; flex: none; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-size: 22px; line-height: 1; }

/* Tabs unten */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 9px 2px; border: 0; background: none; color: var(--muted); font-size: .72rem; }
.tabbar button { position: relative; }
.tabbar .badge { position: absolute; top: 4px; left: calc(50% + 4px); min-width: 1.3em; padding: 0 5px; font-size: .65rem; }
.tabbar svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--accent); font-weight: 600; }
.badge[hidden] { display: none; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-text); font-size: .72rem; text-align: center; }

/* Eingaben */
input[type=text], input[type=search], input[type=date], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--field);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons */
button.primary, a.btn, .menu button, button.ghost, button.danger {
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: transparent; text-decoration: none; color: var(--text); text-align: left; display: block;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; text-align: center; display: inline-block; white-space: nowrap; }
button.ghost { text-align: center; display: inline-block; }
button.danger { color: var(--danger); text-align: center; display: inline-block; margin-right: auto; }
button:disabled { opacity: .4; cursor: not-allowed; }
.menu { display: grid; gap: 8px; }

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 8px; }
.view-head h2 { font-size: 1.15rem; font-weight: 700; min-width: 0; }

/* Aufgabenlisten: Zeilen mit Trennlinie */
.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 12px; padding: 10px 8px; margin: 0 -8px; border-bottom: 1px solid var(--line); border-radius: 8px; }
.task:hover:not(:has(.subtasks .task:hover)) { background: var(--hover); }
.task-desc { flex-basis: 100%; margin: 6px 0 0 34px; color: var(--muted); font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-info { flex: none; border: 0; background: none; padding: 2px; border-radius: 6px; color: var(--muted); line-height: 0; }
.task-info:hover, .task-info[aria-expanded=true] { color: var(--accent); }
.task-info svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.task input[type=checkbox] {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; flex: none; margin: 2px 0 0; border-radius: 50%;
  border: 2px solid var(--check); background: transparent;
}
.task input[type=checkbox]:hover { background: color-mix(in srgb, var(--check) 18%, transparent); }
.task input[type=checkbox]:checked {
  background: var(--check) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 70% no-repeat;
}
.task-main { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 0; display: grid; gap: 2px; }
.task-title { overflow-wrap: anywhere; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: .8rem; color: var(--muted); }
.chip { padding: 0; background: none; border: 0; color: var(--muted); }
.chip.overdue { color: var(--warm); }
button.icon { border: 0; background: none; font-size: 1.3rem; line-height: 1; padding: 0 6px; color: var(--muted); }

/* Autocomplete im Editor */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; list-style: none; margin: 0; padding: 4px; max-height: 200px; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / .14); }
.ac-list li { padding: 6px 10px; border-radius: 6px; cursor: pointer; color: var(--text); font-size: .9rem; }
.ac-list li.active, .ac-list li:hover { background: var(--hover); }

/* Erledigt-Ansicht */
/* Umschalter Liste/Kalender, Sortierung und Gruppierung */
.seg { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 4px 12px; font-size: .82rem; color: var(--muted); }
.seg button.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
.viewopts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0 -4px 6px; }
.viewopts select { width: auto; max-width: 100%; padding: 3px 4px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: .8rem; cursor: pointer; }
.viewopts select:hover { background: var(--hover); color: var(--text); }
.pick-h { margin: 12px 0 2px; color: var(--muted); font-size: .75rem; font-weight: 600; }
.chip.why { color: var(--accent); }

/* Monatskalender */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.cal-head strong { flex: 1; font-size: .95rem; }
.cal-head button { border: 1px solid var(--line); background: none; border-radius: 8px; padding: 3px 12px; color: var(--text); }
.cal-head button:hover { background: var(--hover); }
.cal-wd { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding-bottom: 4px; text-align: center; font-size: .72rem; color: var(--muted); }
.cal-week { position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 64px; border-top: 1px solid var(--line); }
.cal-week:last-of-type { border-bottom: 1px solid var(--line); }
.cal-bg { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-cell { border-left: 1px solid var(--line); cursor: pointer; }
.cal-cell:last-child { border-right: 1px solid var(--line); }
.cal-cell:hover { background: var(--hover); }
.cal-cell.other { background: #fafafa; }
.cal-cell.sel { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.cal-num { position: relative; z-index: 1; justify-self: end; margin: 2px 4px 0; min-width: 22px; padding: 1px 4px; border: 0; border-radius: 99px; background: none; font-size: .75rem; color: var(--muted); text-align: center; }
.cal-num.today { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.cal-bar { position: relative; z-index: 1; display: block; margin: 1px 3px; padding: 1px 6px; border: 0; border-radius: 4px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-size: .72rem; text-align: left; }
.cal-bar.cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar.cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-bar span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-due span { display: block; white-space: normal; overflow-wrap: break-word; hyphens: auto; line-height: 1.25; }   /* Fristen brechen um statt abzuschneiden */
.cal-dues { position: relative; z-index: 1; display: grid; align-content: start; gap: 1px; padding: 1px 3px 3px; cursor: pointer; }
.cal-due { padding: 1px 4px; border: 0; border-radius: 4px; background: none; color: var(--text); font-size: .72rem; text-align: left; }
.cal-due:hover { background: var(--hover); }
.cal-due.overdue { color: var(--warm); }
@media (max-width: 899px) {   /* schmal: Punkte und dünne Balken statt Titel; Details stehen unter dem Kalender */
  .cal-dues { display: flex; flex-wrap: wrap; padding: 0 3px 4px; }
  .cal-due { width: 7px; height: 7px; margin: 1px; padding: 0; border-radius: 50%; background: var(--accent); font-size: 0; }
  .cal-due.overdue { background: var(--warm); }
  .cal-bar { height: 6px; padding: 0; font-size: 0; }
}

.day-group { margin-top: 22px; }
.day-group h4 { color: var(--muted); font-size: .8rem; font-weight: 600; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.time { color: var(--muted); font-size: .8rem; flex: none; padding-top: 3px; }

/* 1-2-3-Abschnitte */
.slot { margin: 22px 0 0; }
.slot > header { display: flex; align-items: baseline; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.slot > header h3 { font-size: 1rem; font-weight: 700; }
.slot-num { color: var(--muted); font-weight: 700; order: -1; }
.slot > header .cap { margin-left: auto; }
.cap { font-size: .8rem; color: var(--muted); }
.empty-slot { border-bottom: 1px solid var(--line); }
.empty-slot button { width: 100%; padding: 10px 0; border: 0; background: none; color: var(--muted); text-align: left; }
.empty-slot button:hover { color: var(--accent); }

/* Dialoge */
dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 0; border-radius: 12px; padding: 0; color: var(--text); background: var(--bg); box-shadow: 0 8px 32px rgb(0 0 0 / .25); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
@media (max-width: 600px) { dialog { margin: auto auto calc(8px + env(safe-area-inset-bottom)); } }
.dlg-body { padding: 18px; display: grid; gap: 12px; }
.dlg-body h3 { font-size: 1.15rem; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; padding: 8px 0 0; background: var(--bg); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 { margin: 0; }
.editor label { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
.editor label > input, .editor label > select, .editor label > textarea { color: var(--text); }
.rec-box { display: grid; grid-template-columns: auto 70px 1fr auto 70px 1fr; gap: 8px; align-items: center; font-size: .9rem; color: var(--muted); }
.rec-box[hidden] { display: none; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); }
#toast[hidden] { display: none; }
#toast button { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 0; }

/* Login / Setup */
body.auth { display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(360px, 100%); padding: 8px; }
.auth-card h1 { margin: 0 0 16px; font-size: 1.4rem; }
.auth-card form { display: grid; gap: 14px; }
.auth-card label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.auth-card label.check { display: flex; gap: 8px; align-items: center; }
.error { color: var(--warm); margin: 0; }
.secret { font: 600 1.1rem/1.4 ui-monospace, monospace; letter-spacing: .08em; word-break: break-all; }
.codes { columns: 2; padding-left: 18px; }

#add-open { display: none; }
.tabbar button[data-view=done], .tabbar button[data-view=waiting] { display: none; }   /* mobil über „Mehr“ erreichbar */
/* Seitenleiste (nur Desktop; mobil blenden die Auswahlfelder und die Tab-Leiste die Funktion ab) */
#side { display: none; }
@media (min-width: 900px) {
  body {
    display: grid; grid-template-columns: 272px minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "top main" "nav main" "side main";
    height: 100dvh; overflow: hidden; padding: 0;
  }
  .topbar, .tabbar, #side { background: var(--sidebar); border: 0; }
  .topbar { grid-area: top; position: static; padding: 20px 12px 4px; }
  #quick { display: none; }
  #add-open { display: flex; }
  .side-add { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 12px; border: 0; border-radius: 8px; background: none; color: var(--accent); font-size: .9rem; font-weight: 600; text-align: left; }
  .side-add:hover { background: var(--hover); }
  .side-add svg { width: 20px; height: 20px; flex: none; }
  .side-add circle { fill: var(--accent); }
  .side-add path { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
  .side-add kbd { margin-left: auto; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; font: inherit; font-size: .72rem; font-weight: 500; color: var(--muted); background: var(--bg); }
  .tabbar { grid-area: nav; position: static; flex-direction: column; padding: 4px 12px; }
  .tabbar button { flex-direction: row; gap: 8px; justify-content: flex-start; text-align: left; padding: 7px 12px; border-radius: 8px; font-size: .9rem; color: var(--text); }
  .tabbar button:hover { background: var(--hover); }
  .tabbar button.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
  .tabbar button[data-view=more] { display: none; }
  .tabbar button[data-view=done], .tabbar button[data-view=waiting] { display: flex; }
  .tabbar .badge { position: static; margin-left: auto; padding: 0 6px; font-size: .72rem; }
  #side { grid-area: side; display: flex; flex-direction: column; gap: 16px; padding: 16px 12px 16px; overflow-y: auto; border-top: 0; }
  #side section { display: grid; gap: 2px; }
  #side h4 { padding: 0 12px 4px; color: var(--muted); font-size: .72rem; font-weight: 600; }
  .side-item { display: block; width: 100%; padding: 6px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); text-align: left; text-decoration: none; font-size: .85rem; }
  .side-item:hover { background: var(--hover); }
  .side-item.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
  .side-item.reset { color: var(--muted); }
  .side-foot { margin-top: auto; display: grid; gap: 2px; color: var(--muted); }
  .side-foot .side-item { color: var(--muted); }
  main { grid-area: main; overflow-y: auto; padding: 36px max(48px, calc((100% - 760px) / 2)) 64px; max-width: none; margin: 0; }
  .view-head { margin-top: 0; }
  .view-head h2 { font-size: 1.5rem; }
  .filters { display: none; }
  #toast { bottom: 24px; }
}

/* Unteraufgaben: Ordner mit Fortschritt, eingerückte Einträge */
.fold { flex: none; border: 0; background: none; padding: 3px 0; margin: 0 -6px 0 -6px; border-radius: 6px; color: var(--muted); line-height: 0; cursor: pointer; }
.fold:hover { color: var(--text); }
.fold svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.fold[aria-expanded=true] svg { transform: rotate(90deg); }
.prog { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--muted); }
.prog-bar { width: 90px; max-width: 40%; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.prog-fill { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.prog.all .prog-fill { background: var(--check); }
.subtasks { flex-basis: 100%; margin: 6px 0 0 34px; border-left: 2px solid var(--line); padding-left: 10px; }
.subtasks[hidden] { display: none; }
.subtasks .task { margin: 0; padding: 7px 4px; font-size: .95rem; }
.subtasks .task:last-of-type { border-bottom: 0; }
.sub-add button { border: 0; background: none; padding: 6px 4px; color: var(--muted); font-size: .85rem; cursor: pointer; }
.sub-add button:hover { color: var(--accent); }
.chip.who { color: var(--accent); }
.task.later > .task-main, .task.later > .task-info { opacity: .55; }
.chip.later { font-style: italic; }
.sub-edit { display: grid; gap: 6px; }
.sub-h { font-size: .88rem; color: var(--muted); }
.sub-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sub-list button { border: 0; background: none; padding: 4px 0; text-align: left; width: 100%; cursor: pointer; }
.sub-list button.done { text-decoration: line-through; color: var(--muted); }

/* Drag & Drop in „Heute“ (Desktop) */
@media (min-width: 900px) and (hover: hover) { .slot .task { cursor: grab; } .slot .task:active { cursor: grabbing; } .slot .subtasks { cursor: default; } }
.slot .tasks { min-height: 44px; }
.drag-ghost { opacity: .35; background: var(--hover); }
.drag-chosen { background: var(--hover); }

/* Slot-Dock beim Ziehen aus Listen (Desktop) */
#dock { display: none; }
@media (min-width: 900px) and (hover: hover) {
  #dock:not([hidden]) { position: fixed; left: 272px; right: 0; bottom: 16px; z-index: 20; display: flex; justify-content: center; gap: 12px; padding: 0 24px; pointer-events: none; }
  .dock-zone { position: relative; flex: 1; max-width: 260px; min-height: 76px; background: var(--bg); border: 1.5px dashed var(--line); border-radius: 12px; box-shadow: 0 6px 24px rgb(0 0 0 / .12); pointer-events: auto; }
  .dock-info { padding: 10px 12px; pointer-events: none; }
  .dock-head { display: flex; align-items: baseline; gap: 6px; font-size: .85rem; }
  .dock-head .cap { margin-left: auto; color: var(--muted); font-size: .8rem; }
  .dock-items { margin-top: 4px; font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dock-drop { position: absolute; inset: 0; list-style: none; margin: 0; padding: 0; }
  .dock-drop > * { height: 0; margin: 0; padding: 0; border: 0; overflow: hidden; }
  .dock-zone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
  .dock-zone.full { opacity: .6; }
  .dock-zone.full.over { border-color: var(--warm); background: var(--bg); }
}

.chip.plan { color: var(--accent); font-weight: 600; }

/* Drag & Drop, Phase 3 */
.side-item.drop-over { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); outline: 1.5px dashed var(--accent); }
.cal-cell.drop-over { background: color-mix(in srgb, var(--accent) 14%, var(--bg)); }
.cal-due[draggable=true] { cursor: grab; }

/* Kalender nutzt am Desktop die volle Breite (Liste darunter bleibt lesbar schmal) */
@media (min-width: 900px) {
  main.wide { padding-left: max(32px, calc((100% - 1500px) / 2)); padding-right: max(32px, calc((100% - 1500px) / 2)); }
  .cal .day-group { max-width: 760px; margin-left: auto; margin-right: auto; }
}

/* Verwalten */
.mlist { list-style: none; margin: 0; padding: 0; }
.mrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.mrow .mname { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.mrow.archived .mname { color: var(--muted); font-style: italic; }
.mrow .mcount { font-size: .85rem; }
.mrow button.ghost { padding: 6px 10px; font-size: .85rem; }
.mrow input { flex: 1 1 180px; min-width: 0; }
