:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --danger: #d93a3a;
  --danger-bg: #fdecec;
  --today-bg: #e8f0ff;
  --done: #9aa1ad;
  --focus: #1f9d55;
  --focus-bg: #dcf5e6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --card: #1b2029;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #2a303b;
    --accent: #5b8cff;
    --danger: #ff6b6b;
    --danger-bg: #3a1f22;
    --today-bg: #1f2b45;
    --done: #6b7280;
    --focus: #3ecf7a;
    --focus-bg: #173a27;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 80px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
header h1 { font-size: 22px; margin: 0; }
header .date { color: var(--muted); font-size: 14px; }
a { color: var(--accent); }
button, input, textarea, select {
  font: inherit;
  color: inherit;
}
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
textarea { resize: vertical; min-height: 60px; }
button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
button.ghost { background: transparent; color: var(--muted); padding: 6px 8px; }
button.secondary { background: var(--line); color: var(--text); }
button.danger { background: var(--danger); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }

.add { display: flex; gap: 8px; }
.add input { flex: 1; }
.add-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.add-extra label, dialog label { font-size: 13px; color: var(--muted); display: block; }
.add-extra[hidden] { display: none; }

header { align-items: flex-start; }
.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; }
.notify { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.notify[hidden] { display: none; }
button.link { background: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: 12px; border-radius: 0; }
button.link[hidden] { display: none; }

h2 { font-size: 15px; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
ul.tasks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
ul.tasks li {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px 10px 4px;
}
ul.tasks li.overdue { border-color: var(--danger); background: var(--danger-bg); }
ul.tasks li.today { background: var(--today-bg); }
ul.tasks li.focus { background: var(--focus-bg); border-color: var(--focus); box-shadow: inset 4px 0 0 var(--focus); }
.edit { font-size: 18px; flex: none; }
.handle { cursor: grab; color: var(--muted); padding: 4px 6px; touch-action: none; user-select: none; font-size: 18px; }
.check { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.body { flex: 1; min-width: 0; cursor: pointer; }
.title { overflow-wrap: anywhere; }
.meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.meta .late { color: var(--danger); font-weight: 600; }
.done-list li .title { text-decoration: line-through; color: var(--done); }
.sortable-ghost { opacity: .4; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

details summary { cursor: pointer; color: var(--muted); margin: 20px 0 8px; font-weight: 600; font-size: 15px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); width: min(480px, calc(100vw - 32px)); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { display: flex; flex-direction: column; gap: 10px; }
dialog .row { display: flex; gap: 8px; justify-content: space-between; margin-top: 6px; }

body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
body.login form { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; }
body.login h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.error { color: var(--danger); margin: 0; text-align: center; }

.wa h3 { margin: 0; font-size: 18px; }
.wa p { margin: 0; }
.wa .hint { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.wa-status { font-weight: 600; }
#waQrBox { text-align: center; }
#waQrBox[hidden] { display: none; }
#waQr { background: #fff; padding: 8px; border-radius: 10px; max-width: 100%; height: auto; }

main.wide { max-width: 1280px; }
.people { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; margin-bottom: 4px; scrollbar-width: thin; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: 15px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip .count { font-size: 12px; opacity: .75; }
.chip .count.late { color: var(--danger); opacity: 1; font-weight: 700; }
.chip.active .count.late { color: #fff; }
.chip.add { color: var(--muted); border-style: dashed; }
.people-edit { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.people-edit .person-row { display: flex; gap: 6px; align-items: center; }
.people-edit .person-row input { flex: 1; }
.people-edit .saved { font-size: 12px; color: var(--focus); width: 72px; white-space: nowrap; }
.people-edit .spacer { width: 34px; flex: none; }
.add select { width: auto; max-width: 40%; }
.add select[hidden] { display: none; }
.board { display: grid; gap: 4px 20px; }
main.wide .board { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.col h2 { display: flex; justify-content: space-between; }
.col ul.tasks { min-height: 44px; }
.who { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }

@media (min-width: 900px) {
  body { padding-left: 220px; }
  .people {
    position: fixed; top: 0; left: 0; bottom: 0; width: 220px;
    flex-direction: column; gap: 4px; overflow-x: hidden; overflow-y: auto;
    padding: 20px 12px; margin: 0;
    background: var(--card); border-right: 1px solid var(--line);
  }
  .people::before { content: "Osoby"; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 12px 6px; }
  .chip { justify-content: space-between; border-radius: 10px; border-color: transparent; background: transparent; padding: 9px 12px; }
  .chip:hover { background: var(--bg); }
  .chip.active, .chip.active:hover { background: var(--accent); }
  .chip.add { border-color: transparent; justify-content: flex-start; margin-top: 6px; }
}
