:root {
  --bg: #ffffff;
  --side: #fcfaf8;
  --text: #202020;
  --muted: #808080;
  --line: #f0f0f0;
  --hover: #f5f3f0;
  --active: #ffefe5;
  --accent: #dc4c3e;
  --accent-ink: #ffffff;
  --sheet: #ffffff;
  --shadow: 0 8px 30px rgba(0, 0, 0, .14);
  --radius: 10px;
  --c: var(--accent);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e1e;
    --side: #262626;
    --text: #ececec;
    --muted: #9a9a9a;
    --line: #2f2f2f;
    --hover: #2c2c2c;
    --active: #3a2a26;
    --accent: #e46b5e;
    --sheet: #282828;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 8px; font-weight: 600; text-decoration: none;
  background: var(--hover); color: var(--text);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--accent); }
.btn.big { padding: 13px 28px; font-size: 17px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

/* ---------- Willkommen ---------- */
.welcome {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px 24px; gap: 4px;
}
.welcome img { border-radius: 22px; box-shadow: var(--shadow); }
.welcome h1 { font-size: 32px; margin: 18px 0 4px; }
.welcome p { color: var(--muted); max-width: 320px; margin: 0 0 24px; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100%; }
.sidebar {
  width: 280px; flex: none; background: var(--side); display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) 10px calc(env(safe-area-inset-bottom) + 12px);
  overflow-y: auto; border-right: 1px solid var(--line);
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.scrim { display: none; }
.only-mobile { display: none; }

@media (max-width: 799px) {
  .only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(84vw, 320px);
    transform: translateX(-102%); transition: transform .22s ease, visibility .22s; border: 0; visibility: hidden;
  }
  .app.drawer .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .3);
           opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.drawer .scrim { opacity: 1; pointer-events: auto; }
}

.side-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-title { font-size: 13px; font-weight: 700; color: var(--muted); padding: 8px 8px 4px; }
.lists { display: flex; flex-direction: column; gap: 1px; }
.list-link {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 7px; text-align: left; width: 100%;
}
.list-link:hover { background: var(--hover); }
.list-link.active { background: var(--active); }
.list-link .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; margin: 0 3px; }
.list-link .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-link .count { font-size: 12px; color: var(--muted); }
.list-link .shared { color: var(--muted); display: inline-flex; }
.side-btn { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 7px; width: 100%; text-align: left; color: var(--muted); }
.side-btn:hover { background: var(--hover); color: var(--text); }
.side-btn .plus { color: var(--accent); font-size: 20px; line-height: 1; width: 16px; text-align: center; }
.side-foot { margin-top: auto; padding-top: 16px; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff; background: var(--c, var(--muted)); text-transform: uppercase;
}
.avatar.sm { width: 24px; height: 24px; font-size: 11px; border: 2px solid var(--bg); }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; gap: 4px; flex: none;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 6px;
  background: var(--bg);
}
.list-title { font-size: 20px; margin: 0 6px 0 4px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.members { display: flex; }
.members .avatar + .avatar { margin-left: -7px; }
.members:empty { display: none; }
.sync { font-size: 12px; color: var(--muted); white-space: nowrap; padding: 0 4px; }

.content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px max(16px, calc((100% - 760px) / 2)) calc(env(safe-area-inset-bottom) + 80px);
}

/* ---------- Eingabe + Vorschläge ---------- */
.addbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 10px; padding: 8px 0 10px; border-bottom: 1px solid var(--line);
}
.add-plus {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: var(--c); font-size: 22px; line-height: 1; margin-left: 1px;
}
#add-input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 8px 0; font-size: 16px;
}
#add-input::placeholder { color: var(--muted); }
.add-submit { color: var(--accent-ink); background: var(--c); border-radius: 7px; padding: 6px 12px; font-weight: 600; font-size: 14px; }

.suggest {
  position: absolute; left: -8px; right: -8px; top: 100%; margin-top: -4px;
  background: var(--sheet); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px; max-height: min(60vh, 380px); overflow-y: auto;
}
.suggest-label { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 10px 4px; }
.sugg {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px; border-radius: 7px;
}
.sugg:hover, .sugg.sel { background: var(--hover); }
.sugg .ico { width: 20px; text-align: center; color: var(--c); font-size: 18px; line-height: 1; flex: none; }
.sugg .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg b { font-weight: 700; }
.sugg .hint { font-size: 12px; color: var(--muted); flex: none; }
.sugg.on-list { color: var(--muted); }
.sugg.on-list .ico { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 6px 8px; }
.chip {
  padding: 6px 12px; border-radius: 999px; background: var(--hover); font-size: 14px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover, .chip.sel { background: var(--active); }

.banner {
  margin: 10px 0 0; padding: 9px 12px; border-radius: 8px; background: var(--hover); font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.banner .btn { margin-left: auto; padding: 5px 10px; }

/* ---------- Artikel ---------- */
.items { padding-top: 2px; }
.item {
  display: flex; align-items: flex-start; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line);
  background: var(--bg); position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: pointer;
}
.item .body { flex: 1; min-width: 0; padding-top: 1px; }
.item .name { word-wrap: break-word; }
.item .note { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: pre-wrap; word-wrap: break-word; }
.item .who { margin-top: 1px; }
.check {
  width: 22px; height: 22px; border-radius: 50%; flex: none; margin-top: 0;
  border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 8%, transparent);
  display: grid; place-items: center; position: relative;
}
.check svg { opacity: 0; color: var(--c); transition: opacity .12s; }
@media (hover: hover) { .check:hover svg { opacity: 1; } }
.item.checking .check, .item.done .check { background: var(--c); }
.item.checking .check svg, .item.done .check svg { opacity: 1; color: #fff; }
.item.checking .name { text-decoration: line-through; color: var(--muted); }
.item.checking { animation: out .35s ease .15s forwards; }
@keyframes out { to { opacity: 0; transform: translateX(10px); } }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.item.done .check { --c: var(--muted); }
.item.flash { animation: flash 1.1s ease; }
@keyframes flash { 0%, 60% { background: var(--active); } 100% { background: var(--bg); } }
.item.dragging { z-index: 10; box-shadow: var(--shadow); border-radius: 8px; transition: none; cursor: grabbing; }
.items.sorting .item:not(.dragging) { transition: transform .15s ease; }

.done-head {
  display: flex; align-items: center; gap: 8px; margin-top: 22px; padding: 6px 0;
  color: var(--muted); font-weight: 600; font-size: 14px;
}
.done-head .toggle { display: flex; align-items: center; gap: 6px; flex: 1; text-align: left; padding: 4px 0; }
.done-head .toggle svg { transition: transform .15s; }
.done-head.open .toggle svg { transform: rotate(90deg); }
.done-head .btn { padding: 4px 10px; font-size: 13px; font-weight: 500; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px 24px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- Bottom-Sheet / Dialog ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); animation: fade .15s; }
.sheet {
  position: relative; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: var(--sheet); border-radius: 14px 14px 0 0; box-shadow: var(--shadow);
  padding: 4px 18px calc(env(safe-area-inset-bottom) + 18px); animation: up .2s ease;
}
@media (min-width: 600px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 14px; padding-bottom: 18px; }
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 0 6px; position: sticky; top: 0; background: var(--sheet); }
.sheet-head h2 { flex: 1; font-size: 17px; margin: 0; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; padding-top: 6px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field textarea {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 16px; outline: 0;
}
.field input:focus, .field textarea:focus { border-color: var(--muted); }
.field textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row .grow { flex: 1; }
.meta { font-size: 13px; color: var(--muted); }
.colors { display: flex; flex-wrap: wrap; gap: 8px; }
.color {
  width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 3px solid transparent;
  box-shadow: inset 0 0 0 2px var(--sheet);
}
.color.sel { border-color: var(--c); }
.menu { display: flex; flex-direction: column; }
.menu button {
  display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-radius: 8px; text-align: left; font-size: 15px;
}
.menu button:hover { background: var(--hover); }
.menu .danger { color: var(--accent); }
.menu .ico { width: 22px; text-align: center; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.member .grow { min-width: 0; }
.member .sub { font-size: 12px; color: var(--muted); }
.link-box {
  font-size: 14px; padding: 10px 12px; border-radius: 8px; background: var(--hover); word-break: break-all;
  user-select: all; -webkit-user-select: all;
}
.hist { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.hist .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .sub { font-size: 12px; color: var(--muted); }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  z-index: 60; background: #202020; color: #fff; border-radius: 8px; padding: 10px 10px 10px 16px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
  animation: up .2s ease; font-size: 14px;
}
.toast span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast button { color: #ff9a8f; font-weight: 700; padding: 4px 8px; }
@media (prefers-color-scheme: dark) { .toast { background: #3a3a3a; } }
