:root {
  color-scheme: light dark;
  --bg: #f5f4ef;
  --card: #fffefb;
  --ink: #1d1c1a;
  --muted: #736f66;
  --line: #e3e0d6;
  --accent: #2e6b55;
  --accent-ink: #ffffff;
  --warn: #c98a1b;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --card: #1e1d1b;
    --ink: #eeece6;
    --muted: #9c988e;
    --line: #302e2a;
    --accent: #74c7a5;
    --accent-ink: #0f241b;
    --warn: #e0a83a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* Kopf */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.top h1 { margin: 0; font-size: 2rem; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.date { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.status { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.status[data-state="online"] { background: var(--accent); }
.status[data-state="offline"] { background: var(--warn); }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%; color: var(--muted);
}
.icon-btn:hover { background: var(--line); color: var(--ink); }

.note {
  margin: 0 0 16px; padding: 10px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 16%, transparent); font-size: 0.9rem;
}

/* Umschalter Heute/Morgen (nur schmal) */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px; background: var(--line); border-radius: 12px; }
.tabs button { min-height: 40px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.count { margin-left: 4px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Listen */
.list h2 { display: none; margin: 0 0 10px; font-size: 1.05rem; font-weight: 700; }
@media (max-width: 759.98px) {
  .app[data-tab="today"] .list[data-list="tomorrow"],
  .app[data-tab="tomorrow"] .list[data-list="today"] { display: none; }
}

.add {
  display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.add:focus-within { border-color: var(--accent); }
.add input { flex: 1; min-width: 0; height: 44px; border: 0; background: none; outline: none; }
.add input::placeholder { color: var(--muted); }
.add button {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
}

.list ul { list-style: none; margin: 10px 0 0; padding: 0; }
.item {
  display: grid; grid-template-columns: 44px 1fr 40px 40px; align-items: center;
  min-height: 54px; padding: 4px 2px 4px 4px; margin-bottom: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.check { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; }
.check svg {
  width: 26px; height: 26px; padding: 4px; border-radius: 50%;
  border: 2px solid var(--muted); stroke: transparent; stroke-width: 3;
}
.check:hover svg { border-color: var(--accent); }
.item.done .check svg { background: var(--accent); border-color: var(--accent); stroke: var(--accent-ink); }
.text { padding: 8px 6px; border-radius: 6px; overflow-wrap: anywhere; cursor: text; }
.text[contenteditable]:not([contenteditable="false"]) { background: var(--bg); outline: 2px solid var(--accent); }
.item.done .text { color: var(--muted); text-decoration: line-through; }
.act { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--muted); }
.act svg { width: 20px; height: 20px; }
.act:hover { background: var(--bg); color: var(--ink); }
.list[data-list="tomorrow"] .move svg { transform: scaleX(-1); }
@media (hover: hover) {
  .act { opacity: 0.35; }
  .item:hover .act, .item:focus-within .act { opacity: 1; }
}

.empty { margin: 28px 0; text-align: center; color: var(--muted); }
.clear-done { display: block; margin: 10px auto 0; padding: 10px 14px; border: 0; background: none; color: var(--muted); text-decoration: underline; }
.clear-done:hover { color: var(--ink); }

/* Breit: beide Listen nebeneinander */
@media (min-width: 760px) {
  .tabs { display: none; }
  .columns { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
  .list h2 { display: block; }
}

/* Start / Dialog */
.welcome { max-width: 420px; margin: 0 auto; padding: 12vh 20px 40px; text-align: center; }
.welcome h1 { margin: 16px 0 6px; font-size: 1.8rem; letter-spacing: -0.02em; }
.welcome > p { margin: 0 0 28px; color: var(--muted); }
.primary { min-height: 46px; padding: 0 22px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.join { margin-top: 28px; text-align: left; }
.join label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 0.9rem; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.row button { flex: none; height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-weight: 600; }
.error { margin: 8px 0 0; color: #c0392b; font-size: 0.9rem; }

dialog {
  width: min(440px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--bg); color: var(--ink);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
dialog p { margin: 0 0 14px; color: var(--muted); font-size: 0.92rem; }
.dialog-end { margin-top: 24px; text-align: right; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
}
.toast button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: inherit; font-weight: 700; text-decoration: underline; }
