/* ThermoTodo – ruhiges Notiz-App-Design: dunkle Seitenleiste, warme Flächen, roter Akzent */

:root {
  --font: "Avenir Next", "Avenir", "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --side-w: 250px;
  --list-w: 400px;

  color-scheme: light;
  --accent: #dd4c4f;
  --accent-soft: rgba(221, 76, 79, .12);
  --bg: #f6f5f2;
  --panel: #ffffff;
  --side: #2b2c2f;
  --side-ink: #d6d6d8;
  --side-muted: #8f9095;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(255, 255, 255, .11);
  --ink: #2e2f33;
  --ink-2: #56575c;
  --muted: #8d8e93;
  --line: #e6e4de;
  --line-2: #eeede8;
  --hover: rgba(0, 0, 0, .035);
  --selected: #ebe9e3;
  --input: #ffffff;
  --input-line: #dad8d1;
  --shadow: 0 10px 34px rgba(0, 0, 0, .13), 0 2px 6px rgba(0, 0, 0, .05);
  --overdue: #d2403c;
  --ok: #4c9a5a;
  --warn: #b97f12;
  --orange: #e07b28;
  --toast: #2b2c2f;

  --col-red: #d9534f; --col-orange: #e5822f; --col-yellow: #d4a72c; --col-green: #4f9d5d; --col-teal: #2f9c96;
  --col-blue: #3d7fd1; --col-indigo: #5b62c9; --col-purple: #9157c2; --col-pink: #d1568f; --col-gray: #7f868f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --accent: #e8625f;
    --accent-soft: rgba(232, 98, 95, .17);
    --bg: #1f1f21;
    --panel: #262628;
    --side: #18181a;
    --side-ink: #d2d2d5;
    --side-muted: #85868b;
    --ink: #e4e4e6;
    --ink-2: #b8b8bc;
    --muted: #87878d;
    --line: #333336;
    --line-2: #2c2c2f;
    --hover: rgba(255, 255, 255, .045);
    --selected: #2f2f32;
    --input: #2b2b2e;
    --input-line: #3c3c40;
    --shadow: 0 10px 34px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
    --overdue: #ef6b66;
    --ok: #66b674;
    --warn: #dcaa45;
    --orange: #f0994f;
    --toast: #3a3a3e;
    --col-red: #e8716d; --col-orange: #f0994f; --col-yellow: #e6c04f; --col-green: #6bbd7a; --col-teal: #4dbab3;
    --col-blue: #609ae6; --col-indigo: #7f85e0; --col-purple: #ac7bd8; --col-pink: #e379aa; --col-gray: #9aa1aa;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #e8625f;
  --accent-soft: rgba(232, 98, 95, .17);
  --bg: #1f1f21;
  --panel: #262628;
  --side: #18181a;
  --side-ink: #d2d2d5;
  --side-muted: #85868b;
  --ink: #e4e4e6;
  --ink-2: #b8b8bc;
  --muted: #87878d;
  --line: #333336;
  --line-2: #2c2c2f;
  --hover: rgba(255, 255, 255, .045);
  --selected: #2f2f32;
  --input: #2b2b2e;
  --input-line: #3c3c40;
  --shadow: 0 10px 34px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
  --overdue: #ef6b66;
  --ok: #66b674;
  --warn: #dcaa45;
  --orange: #f0994f;
  --toast: #3a3a3e;
  --col-red: #e8716d; --col-orange: #f0994f; --col-yellow: #e6c04f; --col-green: #6bbd7a; --col-teal: #4dbab3;
  --col-blue: #609ae6; --col-indigo: #7f85e0; --col-purple: #ac7bd8; --col-pink: #e379aa; --col-gray: #9aa1aa;
}

.c-red { --c: var(--col-red); } .c-orange { --c: var(--col-orange); } .c-yellow { --c: var(--col-yellow); }
.c-green { --c: var(--col-green); } .c-teal { --c: var(--col-teal); } .c-blue { --c: var(--col-blue); }
.c-indigo { --c: var(--col-indigo); } .c-purple { --c: var(--col-purple); } .c-pink { --c: var(--col-pink); }
.c-gray { --c: var(--col-gray); }

/* ------------------------------------------------------------- Grundlagen */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--accent); }
button { font: inherit; }
code { font-family: var(--mono); font-size: .86em; background: var(--hover); padding: 1px 5px; border-radius: 5px; }
kbd { font-family: var(--font); font-size: 11px; font-weight: 600; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--ink-2); }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.muted { color: var(--muted); font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="time"],
input:not([type]), select, textarea {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--input);
  border: 1px solid var(--input-line);
  border-radius: 9px;
  padding: 8px 11px;
  min-height: 40px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .9; }
select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type="date"], input[type="time"] { min-width: 0; }
input[type="date"]::-webkit-calendar-picker-indicator, input[type="time"]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
:root[data-theme="dark"] input::-webkit-calendar-picker-indicator { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input::-webkit-calendar-picker-indicator { filter: invert(1); } }

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--input-line); background: var(--input); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn .icon { width: 16px; height: 16px; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--overdue); }
.btn.block { width: 100%; height: 48px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
@media (hover: hover) {
  .btn:hover { border-color: var(--muted); }
  .btn.primary:hover { filter: brightness(1.06); border-color: var(--accent); }
  .btn.ghost:hover, .btn.danger-ghost:hover { background: var(--hover); }
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 38px; height: 38px; padding: 0 7px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; flex: none;
}
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn.sm { min-width: 30px; height: 30px; padding: 0 4px; }
.icon-btn.sm .icon { width: 16px; height: 16px; }
.icon-btn.danger { color: var(--overdue); }
@media (hover: hover) { .icon-btn:hover { background: var(--hover); color: var(--ink); } .icon-btn.danger:hover { color: var(--overdue); } }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ----------------------------------------------------------------- Layout */
.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(320px, var(--list-w)) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.shell.wide { grid-template-columns: var(--side-w) minmax(0, 1fr); }
.backdrop { display: none; }

.sidebar { background: var(--side); color: var(--side-ink); overflow-y: auto; overscroll-behavior: contain; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); border-right: 1px solid var(--line); }
.shell.wide .main { border-right: 0; }
.list-body { order: 2; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* -------------------------------------------------------------- Seitenleiste */
.sidebar-inner {
  display: flex; flex-direction: column; min-height: 100%;
  padding: calc(14px + env(safe-area-inset-top)) 10px calc(14px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .01em; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand-logo .icon { width: 18px; height: 18px; }
.brand-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-close { display: none; color: var(--side-muted); }

.side-item {
  display: flex; align-items: center; gap: 11px;
  min-height: 38px; padding: 7px 10px; border-radius: 8px;
  color: var(--side-ink); text-decoration: none; font-size: 14.5px; font-weight: 500;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.side-item .icon { width: 18px; height: 18px; color: var(--side-muted); }
.side-item.active { background: var(--side-active); color: #fff; }
.side-item.active .icon { color: var(--accent); }
@media (hover: hover) { .side-item:hover { background: var(--side-hover); } .side-item.active:hover { background: var(--side-active); } }
.side-item .dot { margin: 0 4px; }
.side-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item > span:not(.count):not(.side-name) { flex: 1; }
.hint-key { margin-left: auto; color: var(--side-muted); border-color: rgba(255, 255, 255, .16); background: transparent; }

.side-heading {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 4px 6px 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--side-muted);
}
.sidebar .icon-btn { color: var(--side-muted); }
@media (hover: hover) { .sidebar .icon-btn:hover { background: var(--side-hover); color: #fff; } }
.side-lists { display: flex; flex-direction: column; gap: 1px; }

.count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--side-muted); font-variant-numeric: tabular-nums; }
.count.overdue { color: #fff; background: var(--accent); border-radius: 999px; padding: 0 7px; line-height: 19px; }
.count:empty { display: none; }

.new-list { display: flex; flex-direction: column; gap: 10px; background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 10px; margin: 6px 0; }
.new-list input { background: rgba(0, 0, 0, .25); border-color: rgba(255, 255, 255, .12); color: #fff; width: 100%; }
.row-end { display: flex; justify-content: flex-end; gap: 6px; }
.sidebar .btn.ghost { color: var(--side-ink); }

.side-bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .07); display: flex; flex-direction: column; gap: 1px; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--muted)); display: inline-block; flex: none; }

/* --------------------------------------------------------- Kopf der Liste */
.main-head {
  order: 0;
  display: flex; align-items: center; gap: 6px;
  min-height: 60px; padding: 12px 12px 8px 18px;
}
.menu-btn { display: none; margin-left: -6px; }
.main-title { flex: 1; min-width: 0; margin: 0; display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.main-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-title .dot { width: 12px; height: 12px; }
.main-title .icon { width: 20px; height: 20px; color: var(--muted); }
.head-count { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; padding: 0 4px; }

.menu { position: relative; }
.menu > summary { cursor: pointer; }
.menu[open] > summary { background: var(--hover); color: var(--ink); }
.menu-panel {
  position: absolute; right: 0; top: 44px; z-index: 25;
  width: min(300px, calc(100vw - 24px));
  max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 14px;
}
.menu-link {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 8px; border-radius: 8px;
  border: 0; background: transparent; color: var(--ink); text-decoration: none; cursor: pointer; font-size: 14px; font-weight: 500; text-align: left;
}
.menu-link .icon { width: 17px; height: 17px; color: var(--muted); }
.menu-link.danger, .menu-link.danger .icon { color: var(--overdue); }
@media (hover: hover) { .menu-link:hover { background: var(--hover); } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select { width: 100%; }

.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch { position: relative; cursor: pointer; display: block; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch i { display: block; width: 24px; height: 24px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); transition: box-shadow .12s; }
.swatch input:checked + i { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--c); }
.sidebar .swatch input:checked + i { box-shadow: 0 0 0 2px var(--side), 0 0 0 4px var(--c); }
.swatch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ------------------------------------------------------------ Schnelleingabe */
.quick-add { order: 1; display: flex; flex-direction: column; gap: 7px; padding: 2px 14px 12px; background: var(--bg); }
.quick-field {
  order: 1;
  display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 5px 0 12px;
  background: var(--input); border: 1px solid var(--input-line); border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  transition: border-color .15s, box-shadow .15s;
}
.quick-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-icon { color: var(--accent); display: flex; }
.quick-icon .icon { width: 20px; height: 20px; }
.quick-field input {
  flex: 1; min-width: 0; height: 100%; min-height: 0;
  border: 0; background: transparent; padding: 0; box-shadow: none !important; font-size: 16px;
}
.quick-send {
  width: 36px; height: 36px; border-radius: 9px; border: 0; flex: none;
  background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer;
  opacity: 0; transform: scale(.85); transition: opacity .15s, transform .15s; pointer-events: none;
}
.quick-send .icon { width: 19px; height: 19px; stroke-width: 2.4; }
.quick-field input:not(:placeholder-shown) ~ .quick-send { opacity: 1; transform: none; pointer-events: auto; }

.parse-preview { order: 2; display: none; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 0; }
.parse-preview.has { display: flex; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; line-height: 1.3;
  padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); text-decoration: none;
}
.chip .icon { width: 13px; height: 13px; }
.chip-title { background: transparent; color: var(--ink-2); font-weight: 500; padding-left: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-list { background: var(--hover); color: var(--ink-2); }
.chip-priority { background: color-mix(in srgb, var(--orange) 15%, transparent); color: var(--orange); }

/* ---------------------------------------------------------- Aufgabenliste */
.task-list { min-height: 100%; padding-bottom: 24px; }
.task-row {
  position: relative;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 16px 11px 16px;
  border-bottom: 1px solid var(--line-2);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  transition: background .12s;
}
@media (hover: hover) { .task-row:hover { background: var(--hover); } }
.task-row.active { background: var(--selected); }
.task-row.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.task-link { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; color: inherit; text-decoration: none; padding-top: 1px; }
.task-title { font-size: 15.5px; font-weight: 500; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; font-size: 12.5px; color: var(--muted); }
.task-meta:empty { display: none; }
.task-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.task-meta .icon { width: 13px; height: 13px; }
.meta-due.today { color: var(--accent); font-weight: 600; }
.meta-due.overdue { color: var(--overdue); font-weight: 700; }
.meta-due.soon { color: var(--ink-2); }
.meta-subs.all { color: var(--ok); }
.meta-tag { color: var(--accent); font-weight: 500; }
.meta-list .dot { width: 8px; height: 8px; }
.printed { opacity: .7; }
.prio { color: var(--overdue); font-weight: 800; font-size: 13px; letter-spacing: -.5px; padding-top: 2px; }
.p2 .prio { color: var(--orange); }
.p3 .prio { color: var(--muted); }

.check {
  flex: none; display: grid; place-items: center;
  width: 22px; height: 22px; margin-top: 1px; padding: 0;
  border-radius: 50%; border: 1.8px solid var(--c, var(--muted));
  background: transparent; color: transparent; cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
.check .icon { width: 14px; height: 14px; stroke-width: 2.7; }
.check:active { transform: scale(.88); }
@media (hover: hover) { .check:hover { color: var(--c, var(--muted)); background: color-mix(in srgb, var(--c, var(--muted)) 12%, transparent); } }
.p1 > .check { border-width: 2.2px; }
.done > .check, .done > .batch-main > .check, .sub.done > .check { background: var(--c, var(--ok)); border-color: var(--c, var(--ok)); color: #fff; }
.done .task-title { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); color: var(--muted); }
/* Sofortiges Feedback, bevor der Server antwortet */
.optimistic:not(.done) > .check, .optimistic:not(.done) > .batch-main > .check { background: var(--c, var(--ok)); border-color: var(--c, var(--ok)); color: #fff; }
.optimistic.done > .check, .optimistic.done > .batch-main > .check { background: transparent; color: transparent; }

.drag-ghost { opacity: .35; background: var(--accent-soft) !important; }
.drag-chosen { background: var(--selected); }

.group-head { margin: 0; padding: 18px 16px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-2); }
.list-note { margin: 0; padding: 10px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line-2); }
.snippet { margin: 0; padding: 0 16px 10px 50px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line-2); margin-top: -1px; }
.trash-row { align-items: center; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
.load-more { display: flex; width: max-content; margin: 18px auto; }

.empty { text-align: center; padding: 56px 28px; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; background: var(--hover); display: grid; place-items: center; }
.empty-icon .icon { width: 26px; height: 26px; }
.empty-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--ink-2); }
.empty-text { margin: 0 auto; max-width: 310px; font-size: 14px; line-height: 1.6; }

.search-form {
  flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0;
  height: 42px; padding: 0 12px; border-radius: 11px;
  background: var(--input); border: 1px solid var(--input-line); color: var(--muted);
}
.search-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-form input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; min-height: 0; box-shadow: none !important; -webkit-appearance: none; }

/* ------------------------------------------------------------------ Detail */
.detail { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.detail:not(.open) { align-items: center; justify-content: center; }
.detail-empty { text-align: center; color: var(--muted); padding: 40px; font-size: 14.5px; line-height: 1.6; }
.detail-empty .keys { font-size: 12.5px; margin-top: 18px; }
.detail-head {
  display: flex; align-items: center; gap: 4px;
  min-height: 56px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
}
.back { display: none; color: var(--accent); padding-left: 2px; }
.back .icon { width: 24px; height: 24px; }
.back-label { font-size: 16px; font-weight: 600; max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--hover); padding: 4px 9px; border-radius: 999px; margin-right: 4px; }
.pill .icon { width: 14px; height: 14px; }

.detail-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.detail-body { max-width: 760px; margin: 0 auto; padding: 0 48px 90px; }
.detail.is-deleted .detail-body > *:not(.banner) { opacity: .7; }

.detail-title { display: flex; align-items: flex-start; gap: 14px; padding: 6px 0 20px; }
.check.lg { width: 28px; height: 28px; margin-top: 5px; }
.check.lg .icon { width: 17px; height: 17px; }
.title-input {
  flex: 1; min-width: 0; min-height: 0 !important;
  border: 0 !important; box-shadow: none !important; background: transparent !important; padding: 0 !important; border-radius: 0 !important;
  font-size: 27px !important; font-weight: 700; line-height: 1.3; letter-spacing: -.015em;
  resize: none; overflow: hidden; color: var(--ink);
  field-sizing: content;
}
.detail-title.done .title-input { text-decoration: line-through; color: var(--muted); }

.meta { display: flex; flex-direction: column; margin: 0 0 28px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.meta-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.meta-row:last-child { border-bottom: 0; }
.meta-label { display: flex; align-items: center; gap: 9px; min-height: 40px; font-size: 14px; font-weight: 600; color: var(--muted); }
.meta-label .icon { width: 17px; height: 17px; }
.meta-value { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.meta-value > input[type="text"], .meta-value > select { width: 100%; max-width: 380px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline input[type="date"] { width: 168px; }
.inline input[type="time"] { width: 140px; }
input.overdue { color: var(--overdue); font-weight: 600; }
.quick-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip-btn {
  border: 1px solid var(--input-line); background: transparent; color: var(--ink-2);
  font-size: 12.5px; font-weight: 600; padding: 4px 11px; border-radius: 999px; cursor: pointer;
}
@media (hover: hover) { .chip-btn:hover { border-color: var(--accent); color: var(--accent); } }
.due-hint { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.due-hint.today { color: var(--accent); }
.due-hint.overdue { color: var(--overdue); }
.field-error { margin: 0; font-size: 13px; color: var(--overdue); }

.segmented { display: inline-flex; align-self: flex-start; gap: 2px; padding: 3px; border-radius: 10px; background: var(--hover); }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; gap: 5px; min-width: 44px; justify-content: center; padding: 6px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); cursor: pointer; transition: background .12s; }
.seg span .icon { width: 15px; height: 15px; }
.seg input:checked + span { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg.p1 input:checked + span { color: var(--overdue); }
.seg.p2 input:checked + span { color: var(--orange); }
:root[data-theme="dark"] .seg input:checked + span { background: #3a3a3e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg input:checked + span { background: #3a3a3e; } }

.section { margin: 0 0 28px; }
.section-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.section-head .btn { margin-left: auto; text-transform: none; letter-spacing: 0; }
.progress { height: 4px; margin: 0 0 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ok); border-radius: 2px; transition: width .25s; }

.subtasks { list-style: none; margin: 0; padding: 0; }
.sub { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line-2); }
.check.sm { width: 20px; height: 20px; margin: 0; border-color: var(--muted); --c: var(--ok); }
.check.sm .icon { width: 12px; height: 12px; }
.sub-title, .sub-add input {
  flex: 1; min-width: 0; min-height: 0 !important;
  border: 0 !important; box-shadow: none !important; background: transparent !important; border-radius: 0 !important;
  padding: 9px 0 !important; font-size: 15.5px !important;
}
.sub.done .sub-title { text-decoration: line-through; color: var(--muted); }
.grip { display: flex; color: var(--muted); opacity: .45; cursor: grab; padding: 4px 2px; touch-action: none; }
.grip .icon { width: 16px; height: 16px; }
.sub-add { display: flex; align-items: center; gap: 10px; }
.sub-plus { width: 20px; display: grid; place-items: center; color: var(--muted); }
.sub-plus .icon { width: 16px; height: 16px; }

.notes-input { width: 100%; min-height: 180px; resize: vertical; padding: 12px 14px; font-size: 16px; line-height: 1.6; field-sizing: content; }
.note-empty {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 14px 16px; text-align: left;
  border: 1px dashed var(--input-line); border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer;
}
@media (hover: hover) { .note-empty:hover { border-color: var(--accent); color: var(--accent); } }
.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

.markdown { font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { line-height: 1.3; margin: 1.1em 0 .4em; }
.markdown h1 { font-size: 1.45em; } .markdown h2 { font-size: 1.25em; } .markdown h3 { font-size: 1.1em; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote, .markdown pre, .markdown table { margin: 0 0 .8em; }
.markdown ul, .markdown ol { padding-left: 1.4em; }
.markdown a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; }
.markdown blockquote { margin-left: 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.markdown pre { background: var(--hover); padding: 12px 14px; border-radius: 9px; overflow-x: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown mark { background: color-mix(in srgb, var(--col-yellow) 35%, transparent); color: inherit; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 5px 9px; }
.markdown .task-list-item { list-style: none; margin-left: -1.3em; }
.markdown .task-list-item-checkbox { margin-right: 7px; accent-color: var(--accent); }
.markdown hr { margin: 1.2em 0; }

.files { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.files li { display: flex; align-items: center; gap: 4px; }
.file-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--ink); text-decoration: none;
}
@media (hover: hover) { .file-link:hover { border-color: var(--accent); } }
.file-icon { display: flex; color: var(--accent); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-size { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.file-dl { display: flex; color: var(--muted); }
.upload { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.upload-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border: 1px dashed var(--input-line); border-radius: 11px;
  font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.upload-btn .icon { width: 17px; height: 17px; }
.upload-btn .muted { font-size: 12.5px; }
.upload-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) { .upload-btn:hover { border-color: var(--accent); color: var(--accent); } }
.indicator { display: none; font-size: 13px; color: var(--muted); }
.htmx-request .indicator, .htmx-request.indicator { display: inline; }

.detail-foot { display: flex; flex-wrap: wrap; gap: 4px 16px; padding-top: 14px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted); }

.banner { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; padding: 10px 14px; border-radius: 11px; background: var(--accent-soft); color: var(--ink); font-size: 14px; }
.banner .icon { width: 17px; height: 17px; }
.banner .btn { margin-left: auto; }
.banner.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); }
.banner.ok .icon { color: var(--ok); }
.banner.error { background: color-mix(in srgb, var(--overdue) 13%, transparent); color: var(--overdue); }

/* -------------------------------------------------------------- Einstellungen */
.settings { max-width: 780px; margin: 0 auto; padding: 4px 20px 70px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: 18px 20px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.card p { margin: 0 0 12px; font-size: 14.5px; }
.card p:last-child { margin-bottom: 0; }
.card .btn { margin: 0 6px 6px 0; }
.status { font-weight: 600; line-height: 1.6; }
.status .icon { width: 17px; height: 17px; vertical-align: -3px; margin-right: 4px; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.endpoints { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; }
.endpoint { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 10px; padding: 10px 12px; font-size: 13.5px; background: var(--bg); border-radius: 10px; }
.endpoint > code:nth-child(2) { overflow-wrap: anywhere; background: none; padding: 0; }
.endpoint span { grid-column: 2; color: var(--muted); }
code.method { background: var(--accent-soft); color: var(--accent); font-weight: 700; align-self: start; }
.help-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.help-table th { text-align: left; vertical-align: top; padding: 9px 14px 9px 0; white-space: nowrap; color: var(--ink-2); font-weight: 700; }
.help-table td { padding: 7px 0; line-height: 2; }
.help-table tr + tr { border-top: 1px solid var(--line-2); }
.help-table code { white-space: nowrap; }
details.more { margin: 0 0 12px; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.copy-field { width: 100%; font-family: var(--mono) !important; font-size: 13px !important; }
.import { display: flex; flex-direction: column; gap: 12px; max-width: 440px; margin-top: 8px; }
.import input[type="file"] { font-size: 14px; color: var(--ink-2); }
.theme-switch .seg span { padding: 8px 14px; }

/* ---------------------------------------------------------- Login / Fehler */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-card {
  width: 100%; max-width: 370px; display: flex; flex-direction: column; gap: 14px; text-align: center;
  padding: 34px 26px 26px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
}
.login-logo { width: 60px; height: 60px; margin: 0 auto; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.login-logo .icon { width: 32px; height: 32px; }
.login-card h1 { margin: 0 0 4px; font-size: 23px; }
.login-card input { width: 100%; height: 50px; text-align: center; font-size: 17px; }
.login-card .banner { justify-content: center; margin: 0; }

/* -------------------------------------------------------------------- Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 11px 12px 11px 16px; border-radius: 13px;
  background: var(--toast); color: #fff; box-shadow: var(--shadow); font-size: 14px;
  opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%, 16px);
}
.toast.show { animation: toast 4.8s ease forwards; }
.toast.error { background: var(--overdue); }
.toast-btn { border: 0; background: transparent; color: #ff9b98; font-weight: 700; cursor: pointer; padding: 4px 6px; white-space: nowrap; }
@keyframes toast {
  0% { opacity: 0; visibility: visible; pointer-events: auto; transform: translate(-50%, 16px); }
  5%, 88% { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0); }
  100% { opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%, 8px); }
}

/* -------------------------------------------------------- Zettel (QR-Seite) */
.zettel { max-width: 640px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) 0 calc(40px + env(safe-area-inset-bottom)); }
.zettel-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px 16px; }
.zettel-head h1 { margin: 0; font-size: 23px; letter-spacing: -.01em; }
.zettel-head p { margin: 2px 0 0; font-size: 14px; }
.zettel-list { background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.batch-row { flex-direction: column; align-items: stretch; gap: 6px; padding: 15px 16px; }
.batch-main { display: flex; align-items: flex-start; gap: 14px; }
.batch-row .task-title { font-size: 17px; }
.batch-subs { list-style: none; margin: 0; padding: 0 0 0 42px; display: flex; flex-direction: column; }
.batch-subs .sub { gap: 12px; padding: 6px 0; border: 0; font-size: 15.5px; }
.batch-subs .check { width: 24px; height: 24px; margin: 0; --c: var(--ok); border-color: var(--muted); }
.batch-subs .sub.done span { text-decoration: line-through; color: var(--muted); }
.zettel-done { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 26px 0 0; color: var(--ok); font-size: 18px; font-weight: 700; }
.zettel-done .icon { width: 22px; height: 22px; }
.zettel-app { display: flex; width: max-content; margin: 22px auto 0; }

/* ======================================================= Tablet (Schublade) */
@media (max-width: 1100px) {
  .shell { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  .shell.wide { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0;
    width: min(300px, 84vw);
    transform: translateX(-102%); transition: transform .26s cubic-bezier(.2, .8, .2, 1), box-shadow .26s;
    box-shadow: none;
  }
  .shell.drawer-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .shell.drawer-open .backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .38); animation: fade .2s; }
  .menu-btn { display: inline-flex; }
  .main-head { padding-left: 12px; }
  .drawer-close { display: inline-flex; }
  .detail-body { padding: 0 32px 90px; }
}
@keyframes fade { from { opacity: 0; } }

/* ============================================================ Smartphone */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .shell, .shell.wide { grid-template-columns: minmax(0, 1fr); }
  .main { border-right: 0; }
  .main-head { min-height: 54px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px 8px; }
  .main-title { font-size: 20px; }

  .task-row { padding: 13px 14px 13px 14px; gap: 13px; }
  .task-title { font-size: 16.5px; }
  .task-meta { font-size: 13px; }
  .check { width: 24px; height: 24px; }
  .check .icon { width: 15px; height: 15px; }

  .quick-add {
    order: 3; padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  }
  .parse-preview { order: 0; }
  .quick-field { height: 48px; border-radius: 14px; }

  .detail:not(.open) { display: none; }
  .detail.open { position: fixed; inset: 0; z-index: 40; animation: slide-in .24s cubic-bezier(.2, .8, .2, 1); }
  .detail-head { min-height: 52px; padding: calc(4px + env(safe-area-inset-top)) 8px 4px 4px; }
  .back { display: inline-flex; }
  .desktop-only { display: none; }
  .detail-body { padding: 0 18px calc(70px + env(safe-area-inset-bottom)); }
  .detail-title { padding-top: 4px; gap: 12px; }
  .title-input { font-size: 23px !important; }
  .check.lg { width: 28px; height: 28px; margin-top: 2px; }
  .meta-row { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 12px 0; }
  .meta-label { min-height: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
  .meta-label .icon { width: 15px; height: 15px; }
  .meta-value > input[type="text"], .meta-value > select { max-width: none; }
  .inline input[type="date"] { flex: 1 1 150px; width: auto; }
  .inline input[type="time"] { flex: 1 1 120px; width: auto; }
  .segmented { align-self: stretch; }
  .seg { flex: 1; }
  .seg span { width: 100%; padding: 9px 6px; }
  .sub-title, .sub-add input { padding: 11px 0 !important; font-size: 16px !important; }
  .grip { opacity: .6; padding: 8px 4px; }

  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .hint-key, .detail-empty .keys { display: none; }
  .settings { padding: 4px 12px 60px; }
  .card { padding: 16px; border-radius: 14px; }
  .help-table th { padding-right: 10px; }
  .help-table code { white-space: normal; }
  .menu-panel { position: fixed; top: calc(54px + env(safe-area-inset-top)); right: 10px;
    max-height: calc(100dvh - 70px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
@keyframes slide-in { from { transform: translateX(28%); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .toast.show { animation: none; opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0); }
}

/* ------------------------------------------------------ Benachrichtigungen */
.menu-head { display: flex; align-items: center; gap: 7px; margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.menu-head .icon { width: 15px; height: 15px; }
.ntfy { display: flex; flex-direction: column; gap: 10px; }
.ntfy.off .ntfy-topic, .ntfy.off .ntfy-url { opacity: .5; }
.ntfy-topic input { font-family: var(--mono); font-size: 13px !important; }
.ntfy-url { margin: -4px 0 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 11.5px; }
.ntfy-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ntfy-actions .btn { margin: 0; }
.ntfy-msg { margin: 0; font-size: 13px; font-weight: 600; }
.ntfy-msg.ok { color: var(--ok); }
.ntfy-msg.error { color: var(--overdue); }
.ntfy-lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin: 0 0 12px; }
.ntfy-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--bg); }
.ntfy-name { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.steps { margin: 0 0 12px; padding-left: 1.3em; font-size: 14.5px; line-height: 1.7; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { position: relative; width: 40px; height: 24px; flex: none; border-radius: 999px; background: var(--input-line); transition: background .18s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s; }
.switch input:checked + .switch-ui { background: var(--ok); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- Web Push */
.card-sub { margin: 18px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.push-device { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--bg); display: flex; flex-direction: column; gap: 12px; }
.push-head { display: flex; gap: 12px; align-items: flex-start; }
.push-head p { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); }
.push-icon { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.push-icon .icon { width: 19px; height: 19px; }
.push-status.ok { color: var(--ok); font-weight: 600; }
.push-status.warn { color: var(--warn); font-weight: 600; }
.push-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.push-buttons .btn { margin: 0; }
.push-buttons:has(> :not([hidden])) { display: flex; }
.push-device details.more { margin: 0; }
.push-devices-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.push-devices-head .btn { margin: 8px 0 0; }
.devices { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.devices li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; }
.device-icon { display: flex; color: var(--muted); }
.device-info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.device-info .muted { font-size: 12.5px; }
.push-devices { margin: 4px 0 14px; }
.device-error { color: var(--overdue); font-size: 12.5px; font-weight: 600; }
