/* Schrift Patrick Hand (SIL Open Font License), lokal eingebunden */
@font-face { font-family: "Patrick Hand"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/patrick-hand-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Patrick Hand"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/patrick-hand-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Layout: Kopfleiste wie eine Stiftablage, darunter die freie Wand (2400×1600) mit Zetteln. */
:root {
  --wall: #f3f4f1;          /* Whiteboard, leicht grünstichig */
  --wall-dot: #d9ddd6;
  --bar: #ffffff;
  --line: #dfe2dc;
  --ink: #23262b;
  --ink-soft: #5d636b;
  --accent: #4a78c9;        /* sanftes Blau */
  --accent-ink: #ffffff;
  --danger: #c4553f;
  --note-ink: #2b2a26;
  --note-high: #ffc9a9;     /* Aprikose */
  --note-mid: #fff0a6;      /* Butter */
  --note-low: #cdebd3;      /* Salbei-Mint */
  --overdue: #d4734f;       /* Terrakotta */
  --shadow: 0 1px 1px rgb(30 35 30 / .12), 0 6px 14px -6px rgb(30 35 30 / .35);
  --shadow-lift: 0 2px 2px rgb(30 35 30 / .12), 0 18px 30px -10px rgb(30 35 30 / .45);
  --font-ui: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-hand: "Patrick Hand", "Marker Felt", "Segoe Print", "Bradley Hand", ui-rounded, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --wall: #1b1f24; --wall-dot: #2c323a; --bar: #22272e; --line: #333a43;
    --ink: #e8eaed; --ink-soft: #a2a9b3; --accent: #8aa9e6; --accent-ink: #10172e; --danger: #f08f78;
    --note-high: #e9b597; --note-mid: #e8d891; --note-low: #b5d8bd; --overdue: #c9694a;
    --shadow: 0 1px 1px rgb(0 0 0 / .4), 0 8px 18px -8px rgb(0 0 0 / .7);
    --shadow-lift: 0 2px 2px rgb(0 0 0 / .4), 0 20px 34px -10px rgb(0 0 0 / .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--wall); color: var(--ink);
  font: 15px/1.4 var(--font-ui);
  display: flex; flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Kopfleiste ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bar); border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
.brand {
  margin: 0; font: 600 20px/1 var(--font-hand); letter-spacing: .01em;
  display: flex; align-items: center; gap: 8px;
}
.brand-pin {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  box-shadow: inset -2px -2px 0 rgb(0 0 0 / .2);
}
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; flex: 1; min-width: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; cursor: pointer; color: var(--ink-soft);
}
.chip b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.chip[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-high { background: var(--note-high); } .sw-mid { background: var(--note-mid); } .sw-low { background: var(--note-low); }
.select select {
  padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bar);
}
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.actions { display: flex; gap: 8px; margin-left: auto; }
.nur-klein { display: none; }
#filterToggle { display: none; }
#filterToggle.aktiv::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px;
  border-radius: 50%; background: var(--accent); vertical-align: 1px; }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 7px 14px; cursor: pointer;
  font-weight: 600; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.confirm { background: var(--danger); color: #fff; }

/* ---------- Wand ---------- */
.board-wrap { flex: 1; overflow: auto; position: relative; overscroll-behavior: contain; }
.board {
  position: relative; width: 2400px; height: 1600px;
  background-image: radial-gradient(var(--wall-dot) 1.2px, transparent 1.3px);
  background-size: 24px 24px;
}
.empty {
  position: absolute; left: 60px; top: 60px; max-width: 360px;
  color: var(--ink-soft); font-size: 15px;
}
.empty-title { font: 22px/1.2 var(--font-hand); color: var(--ink); margin: 0 0 6px; }

/* ---------- Zettel ---------- */
.note {
  position: absolute; width: 200px; min-height: 160px;
  padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 8px;
  color: var(--note-ink); background: var(--note-mid);
  box-shadow: var(--shadow); border-radius: 2px 2px 14px 2px / 2px 2px 8px 2px;
  transform: rotate(var(--tilt, 0deg));
  cursor: grab; touch-action: none; user-select: none;
  transition: box-shadow .15s, transform .15s, opacity .2s, left .5s ease, top .5s ease;
}
.note.p-high { background: var(--note-high); }
.note.p-low { background: var(--note-low); }
.note::before { /* Klebestreifen oben, in der Farbe der Person */
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 9px;
  background: var(--tape, rgb(0 0 0 / .06));
}
.pin { /* Pinnadel in der Farbe der Person, bei "Beide" zweifarbig */
  position: absolute; top: -7px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%;
  background: var(--pin, var(--accent));
  box-shadow: inset -2px -3px 0 rgb(0 0 0 / .22), 0 2px 3px rgb(0 0 0 / .3);
}
.tag.who { background: var(--who, rgb(0 0 0 / .08)); color: #fff; }
.note.for-both .tag.who { background: rgb(0 0 0 / .08); color: inherit; }
.note:hover { box-shadow: var(--shadow-lift); }
.board:not(.bereit) .note { transition: none; }
.note.dragging { cursor: grabbing; box-shadow: var(--shadow-lift); transform: rotate(0deg) scale(1.03); transition: none; z-index: 99999 !important; }
.note-text {
  font: 20px/1.25 var(--font-hand); white-space: pre-wrap; overflow-wrap: anywhere; flex: 1;
}
.note-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; flex-wrap: wrap; }
.tag {
  padding: 2px 7px; border-radius: 999px; background: rgb(0 0 0 / .08); font-weight: 600;
}
.tag.overdue { background: var(--overdue); color: #fff; }
.tag.today { background: rgb(0 0 0 / .78); color: #fff; }
.check {
  margin-left: auto; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid rgb(0 0 0 / .45); background: rgb(255 255 255 / .35);
  display: grid; place-items: center; cursor: pointer; padding: 0; flex: none;
}
.check svg { width: 16px; height: 16px; opacity: 0; transition: opacity .15s; }
.check:hover svg { opacity: .35; }
.note.done { opacity: .55; }
.note.done .note-text { text-decoration: line-through; text-decoration-thickness: 2px; }
.note.done .check { background: rgb(0 0 0 / .78); border-color: transparent; color: #fff; }
.note.done .check svg { opacity: 1; }
.note.hidden-by-filter { display: none; }

/* ---------- Dialog ---------- */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--bar); color: var(--ink); box-shadow: 0 30px 60px -20px rgb(0 0 0 / .5);
}
dialog::backdrop { background: rgb(20 24 28 / .45); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
dialog h2, .login h2 { margin: 0; font: 22px/1.2 var(--font-hand); display: flex; align-items: center; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 0; }
.field em { font-style: normal; font-weight: 400; }
.field textarea, .field input, .field select {
  width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--wall);
}
.field textarea { font: 18px/1.35 var(--font-hand); resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* Themen */
.note-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.note-tag {
  font: 600 11px/1.5 var(--font-ui); letter-spacing: .02em; padding: 0 7px; border-radius: 999px;
  background: rgb(255 255 255 / .55); border: 1px solid rgb(0 0 0 / .12); color: rgb(0 0 0 / .65);
}
.tag-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.linkish { align-self: flex-start; border: 0; background: none; padding: 2px 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.icon-btn { padding: 4px 10px; font-weight: 500; }
.tag-edit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tag-edit-list input[type="text"] { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--wall); }
.tag-count { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
#tagDialog .step-add input { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--wall); }
.hint { margin: -4px 0 0; font-size: 13px; color: var(--ink-soft); }
.tag-pick label { cursor: pointer; }
.tag-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tag-pick span {
  display: inline-block; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 14px;
}
.tag-pick input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tag-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.due-pick { display: flex; gap: 6px; align-items: center; min-width: 0; }
.due-pick input { flex: 1; min-width: 0; }
.due-pick .btn { padding: 6px 10px; font-size: 13px; font-weight: 500; flex: none; }
.prio-pick { display: flex; gap: 8px; }
.prio-pick label { flex: 1; }
.prio-pick input { position: absolute; opacity: 0; }
.pp {
  display: block; text-align: center; padding: 10px 0; border-radius: 4px; cursor: pointer;
  color: var(--note-ink); font-weight: 600; border: 3px solid transparent; box-shadow: var(--shadow);
}
.pp-high { background: var(--note-high); } .pp-mid { background: var(--note-mid); } .pp-low { background: var(--note-low); }
.prio-pick input:checked + .pp { border-color: var(--ink); }
.prio-pick input:focus-visible + .pp { outline: 2px solid var(--accent); outline-offset: 2px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.form-error { margin: 0; color: var(--danger); font-size: 14px; }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--wall); z-index: 50; padding: 16px; }
.login-card {
  width: min(340px, 100%); background: var(--bar); padding: 24px; border-radius: 16px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}

/* ---------- Statusmeldung ---------- */
.status {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--wall); padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 60;
}

/* ---------- Kleine Schritte ---------- */
.note-steps { list-style: none; margin: -2px 0 0; padding: 0; display: grid; gap: 3px; font-size: 13.5px; line-height: 1.3; }
.note-step { display: flex; align-items: flex-start; gap: 6px; }
.note-step.done span { text-decoration: line-through; opacity: .6; }
.step-box {
  flex: none; width: 16px; height: 16px; margin-top: 1px; padding: 0; cursor: pointer;
  border: 2px solid rgb(0 0 0 / .45); border-radius: 4px; background: rgb(255 255 255 / .4);
}
.note-step.done .step-box { background: rgb(0 0 0 / .72); border-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3L12.5 5' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.tag.prog { background: linear-gradient(90deg, rgb(0 0 0 / .22) var(--p, 0%), rgb(0 0 0 / .08) var(--p, 0%)); font-variant-numeric: tabular-nums; }
.board.stacked .note-steps { display: none; }
.step-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.edit-step { display: flex; align-items: center; gap: 8px; }
.edit-step input[type="text"] { flex: 1; min-width: 0; }
.edit-step input[type="checkbox"] { width: 18px; height: 18px; padding: 0; flex: none; accent-color: var(--accent); }
.step-add .btn { padding: 7px 14px; }
.step-del { border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink-soft); padding: 2px 6px; }
.step-add { display: flex; gap: 8px; margin-top: 6px; }
.step-add input { flex: 1; min-width: 0; }

/* ---------- Belohnung ---------- */
.konfetti { position: fixed; width: 8px; height: 12px; z-index: 100000; pointer-events: none; border-radius: 2px; }
.note.jubel { animation: jubel .6s ease; }
@keyframes jubel {
  0% { transform: rotate(var(--tilt, 0deg)) scale(1); }
  30% { transform: rotate(calc(var(--tilt, 0deg) - 4deg)) scale(1.06); }
  60% { transform: rotate(calc(var(--tilt, 0deg) + 3deg)) scale(1.02); }
  100% { transform: rotate(var(--tilt, 0deg)) scale(1); }
}

/* ---------- Karten (0.6.1): senkrecht Gruppen, waagrecht wischen ---------- */
.board.swipe {
  width: auto !important; height: auto !important; min-height: 100%; background-image: none;
  display: block; padding: 10px 0 calc(28px + env(safe-area-inset-bottom));
}
.swipe-row { margin-bottom: 14px; }
.row-head {
  display: flex; align-items: baseline; gap: 8px; margin: 0; padding: 4px 16px 6px;
  font: 600 13px/1.3 var(--font-ui); color: var(--ink-soft); letter-spacing: .03em; text-transform: uppercase;
}
.row-count { font-variant-numeric: tabular-nums; padding: 0 7px; border-radius: 999px; background: var(--line); color: var(--ink); }
.row-track {
  display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden; padding: 10px 16px 14px;
  scroll-snap-type: x mandatory; scroll-padding-inline: 16px; overscroll-behavior-x: contain; scrollbar-width: none;
}
.row-track::-webkit-scrollbar { display: none; }
.board.swipe .note {
  position: relative; left: auto !important; top: auto !important; z-index: auto !important;
  flex: 0 0 66vw; max-width: 320px; min-height: 96px; padding: 14px 14px 10px; gap: 8px;
  scroll-snap-align: start; touch-action: pan-x pan-y; cursor: pointer;
  transform: rotate(calc(var(--tilt, 0deg) / 3));
}
.board.swipe .note-text { font-size: 20px; flex: none; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.board.swipe .note-steps { font-size: 14px; }
.board.swipe .note-foot { margin-top: auto; }
.board.swipe .check { width: 34px; height: 34px; }
.board.swipe .empty { position: static; padding: 0 16px; }

/* ---------- Stapel ---------- */
.board.stacked { background-image: none; }
.board.stacked .note {
  min-height: 130px; cursor: pointer; touch-action: auto;
  transform: rotate(calc(var(--tilt, 0deg) / 3));
  box-shadow: 0 -1px 0 rgb(0 0 0 / .06), 0 4px 10px rgb(0 0 0 / .14);
}
.board.stacked .note:hover, .board.stacked .note:focus-visible {
  z-index: 9999 !important; transform: translateY(-4px); box-shadow: var(--shadow-lift);
}
.board.stacked .note-text { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; flex: none; }
.board.stacked .note-foot { margin-top: auto; }
.board.stacked .pin { top: 6px; left: auto; right: 10px; margin: 0; width: 14px; height: 14px; }
.pile-label {
  position: absolute; height: 26px; font: 600 13px/26px var(--font-ui); color: var(--ink-soft);
  letter-spacing: .03em; text-transform: uppercase; border-bottom: 1px solid var(--line);
}

/* ---------- Handy: Liste nach Priorität ---------- */
@media (max-width: 720px) {
  .board-wrap { overflow-x: hidden; }
  .topbar > * { min-width: 0; }
  .topbar { gap: 8px; }
  .filters { order: 3; flex-basis: 100%; display: none; }
  .topbar.filters-open .filters { display: flex; }
  #filterToggle { display: inline-block; }
  /* 0.6.2: in der HA-App steht der Titel schon oben -> eigene Leiste nur eine schmale Zeile */
  .topbar { padding: 5px 12px; gap: 6px; }
  .brand { display: none; }
  .actions { margin-left: 0; flex: 1; justify-content: space-between; }
  .actions .btn { padding: 4px 12px; font-size: 14px; border-radius: 8px; }
  .nur-gross { display: none; }
  .nur-klein { display: inline; }
  .topbar.filters-open .filters { padding-bottom: 4px; }
  .board.stacked .note { min-height: 0; }
  .actions { margin-left: auto; }
  #clearDone { display: none; }
  .board:not(.stacked):not(.swipe) {
    width: auto; height: auto; min-height: 100%; background-image: none;
    display: flex; flex-direction: column; gap: 12px;
    padding: 16px max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .empty { position: static; }
  .board:not(.stacked):not(.swipe) .note {
    position: relative; width: auto; min-height: 0; transform: none; cursor: default; touch-action: auto;
    left: auto !important; top: auto !important;
  }
  .board.stacked .note:hover { transform: none; }
  .note-text { font-size: 19px; }
  .row { grid-template-columns: 1fr; }
}

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

/* ---------- Konto, Anmeldung (Web-App) ---------- */
.hint.klein { font-size: 12px; margin: 0; }
.login-card .hint { margin: 0; }
.login-card .field input { font-size: 16px; }
#kontoDialog { width: min(560px, calc(100vw - 32px)); }
#kontoDialog .field { gap: 8px; }
.knopf-reihe { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.klein { padding: 4px 10px; font-size: 13px; font-weight: 500; }
.konto-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.konto-liste li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.konto-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.konto-text small { color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }
.link-box { display: grid; gap: 8px; padding: 10px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.link-box input { width: 100%; font: 13px ui-monospace, Menlo, monospace; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bar); color: var(--ink); }
#kontoDialog .toggle { align-items: flex-start; }
@media (max-width: 720px) { #kontoBtn { padding: 4px 9px; } }
#importBereich input[type=password] { font-size: 16px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bar); color: var(--ink); }
#importBereich input[type=file] { font-size: 14px; }
