/* Notes – Gestaltung */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #efece5;
  --text: #1c2026;
  --muted: #6f7480;
  --line: #e6e2d9;
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 3px 12px rgba(40, 30, 10, .05);
  --shadow-lg: 0 12px 40px rgba(20, 15, 5, .18);
  --c: #3d6fd6;
  --danger: #d4483b;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141619;
    --surface: #1e2125;
    --surface-2: #262a2f;
    --text: #eceef1;
    --muted: #9aa1ab;
    --line: #2d3137;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    --danger: #ef6a5d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 22px; height: 22px; display: block; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- Layout */
#app { display: flex; min-height: 100dvh; }
#side {
  width: 320px; flex: none; border-right: 1px solid var(--line);
  height: 100dvh; position: sticky; top: 0; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
}
#main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  max-width: 760px; margin: 0 auto; width: 100%;
  padding: 0 20px;
}
@media (max-width: 899px) {
  #side { width: 100%; border-right: 0; position: static; height: auto; min-height: 100dvh; padding-left: 16px; padding-right: 16px; }
  #main { padding: 0 14px; }
  body.r-home #main { display: none; }
  body:not(.r-home) #side { display: none; }
  body.auth #main { display: flex; }
}
@media (min-width: 900px) {
  .list-head .back { display: none; }
}
body.auth #side { display: none; }

/* ---------- Seitenleiste */
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 22px; letter-spacing: -.02em; }
.logo {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--text); color: var(--bg);
}
.logo svg { width: 20px; height: 20px; }
.logo.big { width: 56px; height: 56px; border-radius: 18px; }
.logo.big svg { width: 34px; height: 34px; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--text);
  border: 2px solid var(--bg);
}
.avatar.me { background: var(--text); color: var(--bg); width: 34px; height: 34px; font-size: 15px; }
.avatar.big { width: 48px; height: 48px; font-size: 20px; }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -8px; }

.lists { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.section-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 16px 10px 6px; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px;
  transition: background .15s;
}
.list-row:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.list-row.active { background: var(--surface); box-shadow: var(--shadow); }
.tile {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  font-size: 21px; background: color-mix(in srgb, var(--lc, var(--c)) 16%, var(--surface));
  color: var(--lc, var(--c));
}
.tile.big { width: 52px; height: 52px; font-size: 28px; border-radius: 15px; }
.list-row .name { flex: 1; min-width: 0; font-weight: 600; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.shared-ico svg { width: 16px; height: 16px; color: var(--muted); }
.list-row .count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; min-width: 1.5em; text-align: right; }
.new-list {
  display: flex; align-items: center; gap: 12px; padding: 12px 10px; margin-top: 8px;
  border-radius: 12px; color: var(--muted); font-weight: 600;
}
.new-list:hover { color: var(--text); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.new-list svg { width: 40px; height: 22px; }
.empty-side { padding: 12px 10px; color: var(--muted); }
.empty-side p { margin: 0 0 10px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
}
.chip:active { transform: scale(.97); }

/* ---------- Status */
.status-wrap:empty { display: none; }
.status-wrap { padding: 0 6px 8px; }
.status-wrap.inline { padding: 0 0 10px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.status svg { width: 16px; height: 16px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }

/* ---------- Listenkopf */
.list-head {
  display: flex; align-items: center; gap: 10px;
  padding: max(16px, env(safe-area-inset-top)) 0 14px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 80%, transparent);
}
.list-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.list-title h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.025em; font-weight: 760; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c); }
.big-emoji { font-size: 30px; line-height: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.danger { color: var(--danger); }
.people { padding: 4px; border-radius: 999px; }

/* ---------- Punkte */
.items { display: flex; flex-direction: column; gap: 6px; }
.item {
  display: flex; align-items: center; gap: 4px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); min-height: 54px; padding-left: 6px;
  animation: in .18s ease-out;
}
@keyframes in { from { opacity: 0; transform: translateY(4px); } }
.check {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none; position: relative;
  color: transparent;
}
.check::before {
  content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--lc, var(--c)) 70%, var(--muted)); transition: all .18s;
}
.check svg { width: 16px; height: 16px; position: relative; transition: color .15s, transform .2s; transform: scale(.6); }
@media (hover: hover) { .check:hover svg { color: color-mix(in srgb, var(--lc, var(--c)) 60%, transparent); transform: scale(1); } }
.item.done .check::before, .detail.done .check::before { background: var(--lc, var(--c)); border-color: var(--lc, var(--c)); }
.item.done .check svg, .detail.done .check svg { color: #fff; transform: scale(1); }
.item.lingering .check::before { animation: pop .3s ease-out; }
@keyframes pop { 50% { transform: scale(1.25); } }
.item-body { flex: 1; min-width: 0; padding: 10px 14px 10px 4px; display: flex; flex-direction: column; gap: 3px; }
.item .title { overflow-wrap: anywhere; font-size: 16.5px; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.item.done { box-shadow: none; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.item.lingering { transition: opacity .5s .4s; opacity: .55; }
.meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--muted); align-items: center; }
.meta svg { width: 14px; height: 14px; }
.meta > span { display: inline-flex; align-items: center; gap: 4px; }
.due.today { color: var(--c); font-weight: 650; }
.due.overdue { color: var(--danger); font-weight: 650; }
.meta-list { color: var(--lc); font-weight: 600; }

.done-toggle {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  margin: 18px 0 8px; padding: 6px 12px 6px 6px; border-radius: 10px; font-weight: 650; font-size: 15px; color: var(--muted);
}
.done-toggle:hover { background: var(--surface-2); }
.done-toggle svg { width: 18px; height: 18px; transition: transform .2s; }
.done-toggle.open svg { transform: rotate(90deg); }
.done-toggle .n { background: var(--surface-2); border-radius: 999px; padding: 0 8px; font-size: 13px; }

.group-label { font-size: 13px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 8px; }
.group-label:first-of-type { margin-top: 4px; }
.group-label.overdue { color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty.small { padding: 24px; }
.empty-emoji { font-size: 44px; display: block; margin-bottom: 8px; }
.empty p { margin: 0; }
.spacer { flex: 1; min-height: 110px; }

/* ---------- Eingabe unten */
.addbar {
  position: sticky; bottom: 0; z-index: 6;
  display: flex; align-items: center; gap: 4px;
  margin: 0 -6px; padding: 10px 6px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 26%);
}
.addbar input {
  flex: 1; min-width: 0; height: 52px; border-radius: var(--radius); border: 1.5px solid transparent;
  background: var(--surface); box-shadow: var(--shadow-lg); padding: 0 52px 0 48px; font-size: 16.5px; outline: none;
}
.addbar input:focus { border-color: color-mix(in srgb, var(--c) 55%, transparent); }
.addbar input::placeholder { color: var(--c); opacity: .85; font-weight: 550; }
.add-plus { position: absolute; left: 22px; color: var(--c); pointer-events: none; }
.add-btn {
  position: absolute; right: 14px; width: 38px; height: 38px; border-radius: 11px; background: var(--c); color: #fff;
  display: grid; place-items: center; opacity: 0; transform: scale(.8); transition: all .15s; pointer-events: none;
}
.addbar input:not(:placeholder-shown) ~ .add-btn { opacity: 1; transform: none; pointer-events: auto; }
.add-btn svg { width: 20px; height: 20px; }

/* ---------- Detail-Panel */
#panel { position: fixed; inset: 0; z-index: 30; }
.panel-backdrop { position: absolute; inset: 0; background: rgba(10, 10, 10, .28); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.panel-card {
  position: absolute; background: var(--bg); box-shadow: var(--shadow-lg); overflow-y: auto;
  padding: 0 18px max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
@media (min-width: 900px) {
  .panel-card { top: 0; right: 0; bottom: 0; width: 420px; animation: slideIn .22s ease-out; }
  @keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
}
@media (max-width: 899px) {
  .panel-card { left: 0; right: 0; bottom: 0; top: max(40px, env(safe-area-inset-top)); border-radius: 22px 22px 0 0; animation: slideUp .25s ease-out; }
  @keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
}
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 0 0; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.panel-list { flex: 1; text-align: center; font-weight: 650; color: var(--lc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-title { display: flex; align-items: flex-start; gap: 4px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 12px 6px 6px; }
.detail-title textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; font-size: 20px; font-weight: 650; padding: 9px 0; line-height: 1.3; }
.detail.done .detail-title textarea { text-decoration: line-through; color: var(--muted); }
.field { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.field-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field-label svg { width: 16px; height: 16px; }
.field textarea, .field input[type=date], .field select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px 12px; outline: none;
}
.field textarea { resize: none; min-height: 96px; line-height: 1.45; }
.field textarea:focus, .field input:focus, .field select:focus { border-color: var(--lc); }
.due-row { display: flex; gap: 8px; align-items: center; }
.due-row input { flex: 1; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick .chip { box-shadow: none; background: var(--bg); }

/* ---------- Buttons & Formulare */
.btn {
  height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 650; background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--c); color: #fff; }
.btn.danger { color: var(--danger); background: var(--surface); box-shadow: var(--shadow); }
.btn.danger-fill { background: var(--danger); color: #fff; }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; }
.btn.ghost { background: none; color: var(--muted); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; }
.btn:active { transform: scale(.98); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack input, .name-row input {
  height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); padding: 0 14px; outline: none; width: 100%;
}
.stack input:focus, .name-row input:focus { border-color: var(--c); }

/* ---------- Sheets */
#sheet { position: fixed; inset: 0; z-index: 40; display: grid; align-items: end; justify-items: center; }
@media (min-width: 600px) { #sheet { align-items: center; } }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 10, 10, .32); animation: fade .2s; }
.sheet-card {
  position: relative; width: min(480px, 100%); max-height: 90dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding: 22px 20px max(20px, env(safe-area-inset-bottom)); animation: slideUp2 .22s ease-out;
}
@media (min-width: 600px) { .sheet-card { border-radius: 22px; } }
@keyframes slideUp2 { from { transform: translateY(30px); opacity: 0; } }
.sheet-card h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -.01em; }
.sheet-text { font-size: 17px; margin: 4px 0 20px; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }
.name-row { display: flex; gap: 12px; align-items: center; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-btn { aspect-ratio: 1; border-radius: 10px; font-size: 22px; display: grid; place-items: center; }
.emoji-btn:hover { background: var(--surface-2); }
.emoji-btn.sel { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--text); }
.color-row { display: flex; gap: 10px; flex-wrap: wrap; padding: 4px 0; }
.swatch { width: 34px; height: 34px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.swatch.sel { outline: 3px solid var(--sw); outline-offset: 3px; }
.menu-head { display: flex; align-items: center; gap: 12px; font-size: 18px; margin-bottom: 8px; }
.menu { display: flex; flex-direction: column; margin-top: 8px; }
.menu button { text-align: left; padding: 14px 6px; font-size: 17px; border-top: 1px solid var(--line); }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.share-list { display: flex; flex-direction: column; }
.share-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); cursor: pointer; }
.share-row .avatar { width: 36px; height: 36px; font-size: 15px; }
.grow { flex: 1; font-weight: 600; }
.share-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 46px; height: 28px; border-radius: 999px; background: var(--surface-2); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.share-row input:checked + .switch { background: var(--c); }
.share-row input:checked + .switch::after { transform: translateX(18px); }

/* ---------- Einstellungen */
.settings { display: flex; flex-direction: column; gap: 14px; padding-bottom: 40px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.card p { margin: 0 0 12px; }
.me-row { display: flex; align-items: center; gap: 14px; }
.people-list { list-style: none; margin: 0 0 14px; padding: 0; }
.people-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.people-list li > span:nth-child(2) { flex: 1; font-weight: 600; }

/* ---------- Anmeldung */
.auth-box { max-width: 360px; width: 100%; margin: auto; padding: 40px 0; text-align: center; display: flex; flex-direction: column; align-items: center; }
.auth-box h1 { margin: 18px 0 6px; font-size: 28px; letter-spacing: -.02em; }
.auth-box form { width: 100%; margin-top: 18px; text-align: left; }
.auth-error { color: var(--danger); min-height: 1.4em; margin: 4px 0 0; font-size: 14px; }
.note { background: var(--surface-2); padding: 10px 14px; border-radius: 12px; }
body.auth #main { min-height: 100dvh; justify-content: center; }

.welcome { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.welcome .logo { opacity: .15; }

/* ---------- Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 10px 16px; font-size: 15px; font-weight: 550;
  display: flex; align-items: center; gap: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: var(--bg); font-weight: 750; text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
