:root {
  --bg: #f4f2ee; --card: #ffffff; --text: #1f2421; --muted: #6b726d; --line: #e3e0da;
  --accent: #2f6f4f; --accent-soft: #e2efe7; --danger: #b3412f; --done: #9aa19c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161917; --card: #202422; --text: #e8ebe9; --muted: #98a09b; --line: #313733;
    --accent: #5fb88a; --accent-soft: #24362c; --danger: #e07a68; --done: #6c736e;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

header {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
header h1 { font-size: 19px; margin: 0; flex: 1; }
header .who { color: var(--muted); font-size: 14px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 6px 10px; font-size: 14px;
}

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 60px; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
.tab {
  white-space: nowrap; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 6px 14px; font-size: 15px;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab .count { opacity: .75; font-size: 13px; margin-left: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.list-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.list-head h2 { margin: 0; font-size: 20px; flex: 1; overflow-wrap: anywhere; }
.list-head .meta { color: var(--muted); font-size: 13px; }

form.add { margin-bottom: 8px; }
form.add .add-row { display: flex; gap: 8px; }
form.add input {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg);
}
.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: #fff; font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }

ul.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.check {
  flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--accent);
  background: transparent; display: grid; place-items: center; padding: 0; margin-top: 1px;
}
.item.mine .check { background: var(--accent); }
.item.mine .check::after { content: ""; width: 7px; height: 13px; border: solid #fff; border-width: 0 3px 3px 0; transform: translateY(-2px) rotate(45deg); }
.item .body { flex: 1; min-width: 0; }
.item .text { overflow-wrap: anywhere; }
.item.done .text { text-decoration: line-through; color: var(--done); }
.item .by { color: var(--muted); font-size: 12.5px; }
.item .del { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 0 4px; line-height: 1; }
.item .del:hover { color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; align-items: center; }
.chip { font-size: 12.5px; border: 1px dashed var(--line); color: var(--muted); border-radius: 6px; padding: 0 6px; }
.chip.on { border-style: solid; border-color: transparent; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.progress { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.item.done .progress { color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

dialog {
  border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text);
  width: min(460px, calc(100vw - 32px)); padding: 18px;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin: 0 0 12px; }
dialog .row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
dialog input[type=text], dialog input[type=password] {
  flex: 1; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.users { list-style: none; padding: 0; margin: 0 0 12px; }
.users li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.users li span { flex: 1; overflow-wrap: anywhere; }
.users .tag { flex: none; font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; }
.users button { font-size: 13px; padding: 5px 9px; }
.notice {
  background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px;
  font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 4px 0 0; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-wrap .card { width: min(380px, 100%); }
.login-wrap h1 { margin: 0 0 4px; font-size: 22px; }
.login-wrap p { margin: 0 0 16px; color: var(--muted); }
.login-wrap label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.login-wrap input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.login-wrap .btn { width: 100%; margin-top: 16px; }

.for-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.for-label { font-size: 13px; color: var(--muted); }
.pill {
  font-size: 13px; border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 3px 11px;
}
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.check.na { border-style: dashed; border-color: var(--line); cursor: default; }
.only { font-size: 12px; color: var(--muted); font-style: italic; }
.for-edit { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 0 4px; text-decoration: underline dotted; }
.for-edit:hover { color: var(--accent); }
.for-text { margin: 0 0 6px; font-weight: 600; overflow-wrap: anywhere; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.list-head .icon-btn { white-space: nowrap; }

/* Abschnitte (Skizze: „Packliste ⌄“, zugeklappt „andere ‹“) */
.group.sec { margin-top: 14px; }
.section { display: flex; align-items: center; gap: 6px; padding: 4px 0 6px; border-bottom: 1px solid var(--line); }
.sec-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  border: 0; background: none; padding: 4px 2px; text-align: left; color: var(--text);
}
.sec-name { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.chev { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.group.shut .chev { transform: rotate(90deg); }
.group.shut .section { border-bottom-color: transparent; }
.sec-count { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.icon-btn.sm { padding: 2px 9px; font-size: 14px; }
.sec-empty { color: var(--muted); font-size: 13px; padding: 10px 2px; }
.sec-pick { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.sec-select {
  flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 14px;
}

/* Ziehen & Ablegen */
.handle {
  flex: none; width: 18px; margin: 2px -4px 0 -2px; color: var(--muted); font-size: 18px; line-height: 1;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; text-align: center;
}
.handle.off { cursor: default; }
.ghost {
  position: fixed; z-index: 50; pointer-events: none; background: var(--card); list-style: none;
  border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); opacity: .95;
}
.drag-src { opacity: .35; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.group { border-radius: 10px; transition: background .1s, outline-color .1s; outline: 2px dashed transparent; outline-offset: 2px; }
body.dragging .group { outline-color: var(--line); }
body.dragging .group.drop-over { outline-color: var(--accent); background: var(--accent-soft); }
.group.empty-zone { display: none; }
body.dragging .group.empty-zone { display: block; }
.drop-hint { color: var(--muted); font-size: 13px; text-align: center; padding: 12px; }
