:root {
  --bg: #f6f5f1; --card: #fff; --ink: #1d2422; --muted: #6b7471; --line: #e4e2dc;
  --accent: #1f6f5c; --accent-ink: #fff; --late: #b4442c; --today: #c77d12;
  --p1: #2d5fa8; --p2: #a2367a; --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151918; --card: #1f2523; --ink: #e8ece9; --muted: #98a29e; --line: #2e3633;
          --accent: #4fb397; --accent-ink: #0d1a16; --late: #e57a62; --today: #e3a640;
          --p1: #7fa8e8; --p2: #e083bf; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4; }
a { color: var(--accent); }
header { position: sticky; top: 0; z-index: 2; background: var(--card); border-bottom: 1px solid var(--line);
         padding: .6rem 1rem; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; align-items: center; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.1rem; }
nav { display: flex; flex-wrap: wrap; gap: .2rem; order: 3; flex-basis: 100%; }
.add { order: 2; margin-left: auto; width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--accent);
       color: var(--accent-ink); font-size: 1.4rem; font-weight: 600; text-decoration: none;
       display: flex; align-items: center; justify-content: center; }
.add:hover { filter: brightness(1.1); }
@media (min-width: 640px) { nav { order: 1; flex-basis: auto; } }
nav a { text-decoration: none; color: var(--muted); padding: .35rem .6rem; border-radius: 8px; white-space: nowrap; font-size: .95rem; }
nav a.on { background: var(--bg); color: var(--ink); font-weight: 600; }
main { max-width: 720px; margin: 0 auto; padding: 1rem 1rem 3rem; }
main.wide { max-width: 1100px; }
h1 { font-size: 1.4rem; margin: .4rem 0 1rem; }
h2 { font-size: 1rem; margin: 1.4rem 0 .5rem; display: flex; align-items: center; gap: .5rem; }
.group.overdue h2 { color: var(--late); }
.group.today h2 { color: var(--today); }
.count { font-size: .8rem; background: var(--line); color: var(--ink); border-radius: 99px; padding: 0 .5rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: var(--card);
        padding: .3rem .8rem; border-radius: 99px; font-size: .9rem; }
.chip.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: .75rem .85rem; display: flex; gap: .75rem; align-items: center; }
.group.overdue .card { border-left: 4px solid var(--late); }
.group.today .card { border-left: 4px solid var(--today); }
.card.paused { opacity: .55; }
.card .main { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
details.fold { margin-top: 1.6rem; }
details.fold summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: .4rem 0; list-style: none;
                       display: flex; align-items: center; gap: .5rem; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::before { content: '▸'; transition: transform .15s; }
details.fold[open] summary::before { transform: rotate(90deg); }
details.fold .cards { margin-top: .5rem; }
.card.done .title { text-decoration: line-through; color: var(--muted); }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.danger-zone form { margin: 0; }
.title { font-weight: 600; }
.desc { color: var(--muted); font-size: .92rem; margin-top: .1rem; white-space: pre-line; }
.meta { display: flex; flex-wrap: wrap; gap: .25rem .7rem; font-size: .82rem; color: var(--muted); margin-top: .3rem; }
.who { font-weight: 600; }
.who.p1 { color: var(--p1); } .who.p2 { color: var(--p2); }
.late { color: var(--late); font-weight: 600; }
.ok { color: var(--accent); font-weight: 600; }
.tag { font-size: .75rem; font-weight: 500; border: 1px solid var(--line); border-radius: 6px; padding: 0 .35rem; color: var(--muted); }
.actions { display: flex; gap: .35rem; }
.actions form { margin: 0; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
               border-radius: 10px; min-width: 2.6rem; height: 2.6rem; padding: 0 .8rem; cursor: pointer;
               text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:hover, .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger:hover { border-color: var(--late); color: var(--late); }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }
.error { color: var(--late); font-weight: 600; }
.hint { color: var(--muted); font-size: .85rem; }
.form { display: grid; gap: 1rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
.form small { font-weight: 400; }
input, textarea, select { font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px;
                          background: var(--card); color: var(--ink); width: 100%; }
fieldset { border: 0; padding: 0; margin: 0; }
fieldset.person { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; gap: .8rem; }
legend { font-weight: 600; font-size: .95rem; margin-bottom: .3rem; }
fieldset.person legend { font-size: 1.05rem; padding: 0 .3rem; }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg label { display: block; font-weight: 500; }
.seg input { position: absolute; opacity: 0; width: 0; }
.seg span { display: inline-block; padding: .5rem 1rem; border: 1px solid var(--line); border-radius: 99px; background: var(--card); cursor: pointer; }
.seg input:checked + span { background: var(--ink); color: var(--card); border-color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
pre { white-space: pre-wrap; font: inherit; margin: .4rem 0 0; }
/* Housekeeping-Raster */
.weeknav .btn { height: 2.2rem; font-size: .9rem; }
.hk-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.hk { border-collapse: collapse; width: 100%; font-size: .85rem; }
.hk th, .hk td { padding: .35rem; text-align: center; border-bottom: 1px solid var(--line); }
.hk tbody tr:last-child th, .hk tbody tr:last-child td { border-bottom: 0; }
.hk th.area { position: sticky; left: 0; z-index: 1; background: var(--card); text-align: left;
              min-width: 7.5rem; padding-left: .75rem; font-weight: 600; border-right: 1px solid var(--line); }
.hk thead th { font-weight: 500; color: var(--muted); white-space: nowrap; }
.hk .kw { font-weight: 700; color: var(--ink); }
.hk .sat { font-size: .75rem; }
.hk .now { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.hk .past { opacity: .55; }
.hk form { margin: 0; }
.hk button.cell { width: 100%; min-width: 5.2rem; height: 2.4rem; padding: 0 .3rem; font-size: .85rem;
                  color: var(--muted); border-style: dashed; }
.hk button.cell.set { border-style: solid; font-weight: 600; color: #fff; }
.hk button.cell.set.p1 { background: var(--p1); border-color: var(--p1); }
.hk button.cell.set.p2 { background: var(--p2); border-color: var(--p2); }
@media (prefers-color-scheme: dark) { .hk button.cell.set { color: #10141a; } }
.settings-links { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.crumb { margin: 0 0 .2rem; font-size: .9rem; }
.tg p { margin: .2rem 0; }
.tglink { word-break: break-all; font-size: .9rem; }
button.small { height: 2rem; font-size: .85rem; margin-left: .5rem; }
code { font-size: .9em; }
.hk th.area a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.addarea { margin-top: 1rem; }
.addarea input { flex: 1; min-width: 12rem; width: auto; }
button:disabled { opacity: .4; cursor: default; }
body.loading main { opacity: .6; transition: opacity .15s .1s; pointer-events: none; }
main.login { max-width: 360px; padding-top: 3rem; text-align: center; }
main.login .form { text-align: left; margin-top: 1rem; }
.login-icon { width: 88px; height: 88px; border-radius: 20px; }

/* Kurzlink-Seite aus WhatsApp-Erinnerungen */
main.quick form { margin: .6rem 0; }
main.quick button.big { width: 100%; padding: .9rem; font-size: 1.05rem; }
.quick-result { font-size: 1.1rem; margin: 1rem 0 .5rem; }
.quick-open { margin-top: 2rem; }
.error-text { color: var(--late); font-weight: 600; }
.cmb ol { margin: .3rem 0 .5rem 1.2rem; padding: 0; font-size: .9rem; }
.cmb li { margin: .15rem 0; }

/* Private Tasks */
label.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; cursor: pointer; }
label.check input { width: 1.25rem; height: 1.25rem; margin: 0; flex: none; accent-color: var(--accent); }
label.check small { display: block; font-weight: 400; }

/* Kalender */
.cal-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.cal-head h1 { margin: 0; min-width: 9.5rem; text-align: center; }
.cal-head .btn { padding: .3rem .8rem; font-size: 1.1rem; text-decoration: none; }
.cal-head .small-btn { font-size: .85rem; margin-left: auto; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-top: .8rem; }
.cal-wd { font-size: .75rem; color: var(--muted); text-align: center; padding: .2rem 0; font-weight: 600; }
.cal-day { background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-height: 3.4rem;
           padding: .2rem .25rem; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 2px;
           text-decoration: none; color: inherit; overflow: hidden; }
.cal-day.out { opacity: .45; }
.cal-day.today { border: 2px solid var(--today); }
.cal-num { flex-basis: 100%; font-size: .8rem; font-weight: 600; color: var(--muted); }
.cal-day.today .cal-num { color: var(--today); }
/* Handy: farbige Punkte; ab Tablet: Titel */
.cal-item { width: .55rem; height: .55rem; border-radius: 50%; background: var(--muted); font-size: 0; overflow: hidden; }
.cal-item.p1 { background: var(--p1); } .cal-item.p2 { background: var(--p2); }
.cal-item.planned { opacity: .4; }
.cal-item.done { opacity: .35; }
.cal-item.late { outline: 2px solid var(--late); outline-offset: 1px; }
@media (min-width: 700px) {
  .cal-day { min-height: 6rem; }
  .cal-item { width: 100%; height: auto; border-radius: 4px; font-size: .72rem; line-height: 1.25; color: #fff;
              padding: 1px 4px; white-space: nowrap; text-overflow: ellipsis; }
  .cal-item.done { text-decoration: line-through; }
  .cal-item.late { outline: none; box-shadow: inset 3px 0 0 var(--late); }
}
@media (min-width: 700px) and (prefers-color-scheme: dark) { .cal-item { color: #10141a; } }
.cal-legend { margin: .5rem 0 0; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; vertical-align: middle; margin-right: .25rem; }
.dot.p1 { background: var(--p1); } .dot.p2 { background: var(--p2); }
.agenda h2.is-today { color: var(--today); }
.agenda h2 { scroll-margin-top: 7rem; }
.card.planned { opacity: .6; border-style: dashed; }

/* Kategorien */
.cat { color: var(--ink); }
.cat-row { display: grid; grid-template-columns: 9.5rem 1fr auto; gap: .4rem; align-items: center; margin-bottom: .45rem; }
.cat-row.new { grid-template-columns: 9.5rem 1fr; margin-top: .8rem; }
.cat-row .del { font-size: .8rem; gap: .3rem; color: var(--muted); }
.cat-row .del input { width: 1rem; height: 1rem; }

/* Farbschemata (pro Person). "auto" = Standard oben, folgt dem Hell/Dunkel-Modus des Handys */
:root { --on-p: #fff; color-scheme: light dark; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] { --on-p: #10141a; } }
:root[data-theme="light"] {
  --bg: #f8f9fa; --card: #fff; --ink: #202124; --muted: #5f6368; --line: #dadce0;
  --accent: #1a73e8; --accent-ink: #fff; --late: #d93025; --today: #e37400;
  --p1: #1967d2; --p2: #a142f4; --on-p: #fff; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #202124; --card: #2d2e31; --ink: #e8eaed; --muted: #9aa0a6; --line: #3c4043;
  --accent: #8ab4f8; --accent-ink: #202124; --late: #f28b82; --today: #fdd663;
  --p1: #8ab4f8; --p2: #f28bd1; --on-p: #202124; color-scheme: dark;
}
:root[data-theme="colorful"] {
  --bg: #fff8f1; --card: #fff; --ink: #1f1b16; --muted: #6d5f52; --line: #f3dccb;
  --accent: #e52592; --accent-ink: #fff; --late: #d93025; --today: #f9ab00;
  --p1: #1a73e8; --p2: #e8710a; --on-p: #fff; color-scheme: light;
}
:root[data-theme="colorful"] header { background: linear-gradient(90deg, #fde7f3, #fff1e0 50%, #e8f0fe); }
:root[data-theme="ocean"] {
  --bg: #eef7f8; --card: #fff; --ink: #102a2f; --muted: #557178; --line: #cfe5e8;
  --accent: #00838f; --accent-ink: #fff; --late: #c62828; --today: #ef6c00;
  --p1: #1565c0; --p2: #6a1b9a; --on-p: #fff; color-scheme: light;
}
.hk button.cell.set, .cal-item { color: var(--on-p) !important; }
input, select, textarea { background: var(--card); color: var(--ink); }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
.theme-opt { display: block !important; cursor: pointer; }
.theme-opt input { position: absolute; opacity: 0; width: 0; }
.theme-card { display: grid; gap: .25rem; padding: .6rem; border-radius: 12px; border: 2px solid var(--line); min-height: 6.2rem; }
.theme-opt input:checked + .theme-card { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-opt input:focus-visible + .theme-card { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-bar { display: flex; gap: .3rem; padding: .35rem; border-radius: 8px; }
.theme-bar i { width: 1rem; height: 1rem; border-radius: 50%; display: block; }
.theme-card b { font-size: .95rem; }
.theme-card small { font-size: .75rem; line-height: 1.25; font-weight: 400; }

/* Aufgabenliste: Sortierung */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.sortby { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.sortby .hint { margin-right: .1rem; }
.chip.small { padding: .2rem .6rem; font-size: .82rem; }
.card.is-overdue { border-left: 4px solid var(--late); }
.card.is-today { border-left: 4px solid var(--today); }
.group.person-group.p1 h2 { color: var(--p1); } .group.person-group.p2 h2 { color: var(--p2); }

/* Kalender v2: Monat / Woche / Tag, Einträge sind Buttons */
.cal-item { border: 0; padding: 0; margin: 0; cursor: pointer; font: inherit; display: block; text-align: left; }
.cal-num { text-decoration: none; }
.cal-head .today-btn { margin-left: auto; font-size: .85rem; }
.views { gap: .3rem; }
.only-desktop { display: none; }
@media (min-width: 700px) { .only-mobile { display: none; } .only-desktop { display: inline; } }
@media (max-width: 699px) { .cal-month .cal-day { cursor: pointer; } }

/* volle Einträge (Woche, Tag) */
.cal-item.full, .cal-item.big { width: 100%; height: auto; border-radius: 6px; font-size: .85rem; line-height: 1.3;
  padding: .3rem .45rem; white-space: normal; overflow: visible; }
.cal-item.full .t, .cal-item.big .t { display: block; }
.cal-item.full.done, .cal-item.big.done { text-decoration: line-through; }
.cal-item.full.late, .cal-item.big.late { outline: none; box-shadow: inset 4px 0 0 var(--late); padding-left: .6rem; }
.cal-item.big { font-size: 1rem; padding: .8rem .9rem; border-radius: var(--radius); margin-bottom: .5rem; }
.cal-item.big.late { padding-left: 1.1rem; }

.cal-week { display: grid; gap: 4px; margin-top: .8rem; }
.wk-day { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .4rem;
          display: grid; grid-template-columns: 3.2rem 1fr; gap: .5rem; align-items: start; }
.wk-day.today { border: 2px solid var(--today); }
.wk-head { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--muted); }
.wk-wd { font-size: .75rem; font-weight: 600; }
.wk-num { font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.wk-day.today .wk-num { color: var(--today); }
.wk-items { display: grid; gap: 3px; }
.wk-empty { color: var(--muted); font-size: .85rem; padding: .3rem 0; }
@media (min-width: 900px) {
  .cal-week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .wk-day { grid-template-columns: 1fr; min-height: 14rem; }
  .wk-head { flex-direction: row; gap: .35rem; justify-content: center; }
}
.cal-dayview { margin-top: 1rem; max-width: 640px; }

/* Detailfenster */
dialog.pop { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink);
             width: min(26rem, calc(100vw - 2rem)); padding: 1.1rem 1.2rem 1.2rem; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
dialog.pop::backdrop { background: rgba(0, 0, 0, .35); }
.pop-close { position: absolute; top: .5rem; right: .5rem; margin: 0; }
.pop-close button { border: 0; background: transparent; font-size: 1.1rem; color: var(--muted); padding: .3rem .5rem; }
.pop-title { margin: 0 2rem .4rem 0; font-size: 1.15rem; display: block; }
.pop-meta { font-size: .9rem; color: var(--muted); }
.pop-desc { white-space: pre-line; margin: .6rem 0 0; }
.pop-desc:empty { display: none; }
.pop-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.pop-actions form { margin: 0; }
.pop-actions .btn { text-decoration: none; }
.cal-item.big .m { display: block; font-size: .82rem; opacity: .85; margin-top: .15rem; }
.cal-item.big.done .m { text-decoration: none; }
@media (min-width: 900px) { .wk-day { align-content: start; } .wk-empty { text-align: center; } }

/* kurze Meldung nach einer Aktion */
.flash { background: var(--card); border: 1px solid var(--accent); border-left: 4px solid var(--accent);
         border-radius: 10px; padding: .55rem .8rem; margin: 0 0 .8rem; font-weight: 500;
         animation: flash-out .4s ease 6s forwards; }
.flash.warn { border-color: var(--late); }
@keyframes flash-out { to { opacity: 0; height: 0; padding: 0; margin: 0; border-width: 0; overflow: hidden; } }

/* Monat auf dem Handy: nur Punkte */
@media (max-width: 699px) {
  .cal-month .cal-day { gap: 3px; align-content: flex-start; }
  .cal-month .cal-item { flex: none; width: .62rem; height: .62rem; min-width: 0; min-height: 0; padding: 0;
    border-radius: 50%; font-size: 0; line-height: 0; display: inline-block; }
  .cal-month .cal-item .t { display: none; }
  .cal-month .cal-item.late { outline: 2px solid var(--late); outline-offset: 1px; box-shadow: none; }
}
/* Monat auf großem Bildschirm: Balken mit Titel */
@media (min-width: 700px) {
  .cal-month .cal-item { width: 100%; }
  .cal-month .cal-item .t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Wunschliste */
.wishes { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .35rem; }
.wish { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 10px; }
.wish .txt { flex: 1; min-width: 0; white-space: pre-line; }
.wish .by { display: block; font-size: .78rem; color: var(--muted); }
.wish.done .txt > span:first-child { text-decoration: line-through; color: var(--muted); }
.wish form { margin: 0; }
.wish button { padding: .15rem .45rem; font-size: .85rem; }
.wish-add { display: flex; gap: .4rem; }
.wish-add input { flex: 1; }
