/* Farben aus dem Logo: Weiß, Bambusgrün, Fell-Braun */
:root {
  --bg: #faf7f0; --card: #ffffff; --text: #3b2818; --muted: #7a6a58; --border: #e6dccb;
  --primary: #4f7d0f; --primary-text: #ffffff; --accent: #8a5e34; --danger: #b42318;
  --p1: #e5484d; --p2: #d9902a; --p3: #6a9a14; --p4: #8a5e34; --p5: #9aa88c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #211809; --card: #2c2112; --text: #f3ead9; --muted: #b8a68a; --border: #4a3a26;
    --primary: #9cc54a; --primary-text: #211809; --accent: #d4a373; --danger: #f87171;
  }
}
:root[data-theme="dark"] {
  --bg: #211809; --card: #2c2112; --text: #f3ead9; --muted: #b8a68a; --border: #4a3a26;
  --primary: #9cc54a; --primary-text: #211809; --accent: #d4a373; --danger: #f87171;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button, select, input, textarea { font: inherit; color: inherit; }
button { padding: .45rem .9rem; border: 1px solid var(--border); background: var(--card); border-radius: 8px; cursor: pointer; min-height: 40px; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button.chip { border-radius: 999px; }
button.chip.active { background: var(--primary); color: var(--primary-text); border-color: transparent; }
button.nav-btn.active { border-color: var(--primary); color: var(--primary); font-weight: 600; }
input, select, textarea { padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 8px; background: var(--card); width: 100%; min-height: 40px; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
label.inline input { width: auto; min-height: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; padding: .6rem 16px; background: var(--card); border-bottom: 1px solid var(--border); }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
main { padding: 16px; max-width: 920px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 140px; }
.wrap { flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: .5rem; }
.muted { color: var(--muted); font-size: .9rem; }
.error { color: var(--danger); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card + .card { margin-top: 1rem; }
h2 { margin: 0 0 .25rem; font-size: 1.25rem; }
h3 { margin: 0; font-size: 1rem; }
.day-head { margin: 1.2rem 0 .4rem; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.day-head.today { color: var(--primary); }
.item { display: flex; gap: .75rem; align-items: flex-start; padding: .7rem .8rem; border-radius: 10px; border: 1px solid var(--border); border-left: 6px solid var(--p3); background: var(--card); margin-bottom: .45rem; cursor: pointer; }
.item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.item.p1 { border-left-color: var(--p1); background: color-mix(in srgb, var(--p1) 12%, var(--card)); }
.item.p2 { border-left-color: var(--p2); background: color-mix(in srgb, var(--p2) 10%, var(--card)); }
.item.p3 { border-left-color: var(--p3); }
.item.p4 { border-left-color: var(--p4); background: color-mix(in srgb, var(--p4) 8%, var(--card)); }
.item.p5 { border-left-color: var(--p5); background: color-mix(in srgb, var(--p5) 8%, var(--card)); }
.item.done { opacity: .55; }
.item.done .title { text-decoration: line-through; }
.item .time { min-width: 5.2em; font-variant-numeric: tabular-nums; color: var(--muted); }
.item .meta { font-size: .8rem; color: var(--muted); }
.item .body { flex: 1; min-width: 0; }
.badge { display: inline-block; font-size: .72rem; padding: 0 .4rem; border-radius: 6px; border: 1px solid var(--border); margin-left: .3rem; color: var(--muted); }
.wish { display: flex; gap: .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.wish.done span { text-decoration: line-through; opacity: .55; }
.wish span { flex: 1; overflow-wrap: anywhere; }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.checks { display: flex; gap: .6rem; flex-wrap: wrap; }
.checks label { flex-direction: row; align-items: center; color: var(--text); }
.checks input { width: auto; min-height: 0; }
.center { max-width: 380px; margin: 8vh auto; }
.copy { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; word-break: break-all; background: var(--bg); padding: .4rem; border-radius: 6px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; gap: .6rem; }
dialog { width: min(560px, 94vw); border: 1px solid var(--border); border-radius: 14px; background: var(--card); color: var(--text); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.4); }
.prio-select { font-weight: 600; }
.new-only[hidden] { display: none; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--primary); color: var(--primary-text); padding: .6rem 1rem; border-radius: 10px; z-index: 99; max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }
@media (max-width: 480px) { main { padding: 12px; } .topbar nav button { flex: 1 1 auto; } }

/* ---------- Wochenansicht (Zeitraster) ---------- */
.wgrid, .wbody { display: grid; grid-template-columns: 40px repeat(7, minmax(0, 1fr)); }
.wgrid { border: 1px solid var(--border); border-radius: 12px 12px 0 0; background: var(--card); overflow: hidden; }
.whead { padding: .35rem 0; text-align: center; font-size: .72rem; color: var(--muted); border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); }
.whead:first-child { border-left: 0; }
.whead b { display: block; font-size: .95rem; color: var(--text); font-weight: 600; }
.whead.today b { color: var(--primary-text); background: var(--primary); border-radius: 50%; width: 1.7rem; height: 1.7rem; line-height: 1.7rem; margin: 0 auto; }
.wallabel { font-size: .6rem; color: var(--muted); padding: .2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: center; text-align: center; }
.wallday { min-height: 30px; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); padding: 2px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wscroll { max-height: calc(100vh - 240px); min-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 12px 12px; background: var(--card); }
.wbody { position: relative; }
.whours, .wcol { height: calc(24 * 48px); position: relative; }
.whours { font-size: .6rem; color: var(--muted); }
.whour { height: 48px; text-align: right; padding-right: 4px; transform: translateY(-.55em); }
.wcol { border-left: 1px solid var(--border); min-width: 0; cursor: cell; background: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px 48px); }
.wcol.today { background-color: color-mix(in srgb, var(--primary) 6%, transparent); }
.wblock { position: absolute; box-sizing: border-box; border-radius: 5px; background: color-mix(in srgb, var(--pc) 24%, var(--card)); border-left: 3px solid var(--pc); padding: 2px 3px; font-size: .66rem; line-height: 1.2; overflow: hidden; cursor: pointer; }
.wblock:focus-visible, .mchip:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.wblock.done { opacity: .5; }
.wblock .wt { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wblock .wtime { color: var(--muted); font-size: .6rem; white-space: nowrap; }

/* ---------- Monatsansicht ---------- */
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.mhead { text-align: center; font-size: .75rem; color: var(--muted); padding: .4rem 0; font-weight: 600; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); }
.mhead:first-child, .mcell:nth-child(7n+1) { border-left: 0; }
.mcell { min-height: 96px; min-width: 0; padding: .2rem .15rem; border-top: 1px solid var(--border); border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.mcell.out { background: color-mix(in srgb, var(--bg) 55%, var(--card)); }
.mcell.out .mnum { color: var(--muted); opacity: .6; }
.mcell.sun .mnum { color: var(--danger); }
.mnum { align-self: center; width: 1.6rem; height: 1.6rem; line-height: 1.6rem; text-align: center; border-radius: 50%; font-size: .85rem; font-variant-numeric: tabular-nums; }
.mcell.today .mnum { background: var(--primary); color: var(--primary-text); }
.mchip { font-size: .66rem; line-height: 1.25; padding: 1px 3px; border-radius: 4px; background: color-mix(in srgb, var(--pc) 24%, var(--card)); border-left: 3px solid var(--pc); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.mchip.done { opacity: .5; text-decoration: line-through; }
.mmore { font-size: .64rem; color: var(--muted); padding-left: 3px; cursor: pointer; }
.mcell:hover { background: color-mix(in srgb, var(--primary) 5%, var(--card)); }

@media (max-width: 480px) {
  .mcell { min-height: 80px; }
  .mchip { font-size: .6rem; }
  .wallabel { font-size: .5rem; }
}

/* ---------- Faultier-Design ---------- */
.brand { display: flex; align-items: center; gap: .45rem; color: var(--primary); font-weight: 700; }
.brand-mark { width: 30px; height: 30px; border-radius: 50%; }
.login-logo { display: block; width: 240px; max-width: 80%; margin: 0 auto .25rem; }
.tagline { text-align: center; font-style: italic; color: var(--accent); margin: 0 0 .25rem; }
.topbar { border-bottom: 3px solid var(--primary); }
.card { box-shadow: 0 1px 2px rgba(59, 40, 24, .06); }
button.nav-btn.active { border-color: var(--primary); color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--card)); }
h2 { color: var(--text); }
.day-head.today { color: var(--primary); }
a { color: var(--primary); }

.toast.undo { display: flex; gap: .75rem; align-items: center; }
.toast .undo-btn { background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 8px; padding: .2rem .6rem; min-height: 0; }

.wx { display: inline-flex; vertical-align: middle; margin-left: .3rem; color: var(--accent); }
.wx:empty { display: none; }
.wx-ic { width: 14px; height: 14px; }
.whead .wx { margin-left: .2rem; }

.wish { flex-wrap: wrap; }
.wish > span:not(.meta) { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.wish .checklist { flex: 0 0 100%; }
.checklist li { margin: .15rem 0; }

.checklist label { display: flex; flex-direction: row; align-items: center; gap: .45rem; margin: 0; }
.checklist input[type=checkbox] { width: auto; min-height: 0; margin: 0; flex: none; }

/* Benutzerdefinierte Wiederholung */
.weekdays { display: flex; gap: .35rem; flex-wrap: wrap; }
.weekdays button { width: 2.4rem; height: 2.4rem; min-height: 0; padding: 0; border-radius: 50%; }
.weekdays button.on { background: var(--primary); color: var(--primary-text, #fff); border-color: var(--primary); }
#repeat-form label.inline input[type=date], #repeat-form label.inline input[type=number] { display: inline-block; margin-left: .3rem; }

/* Kategorie- und Kalender-Schalter */
.chip .dot, .badge .dot { display: inline-block; width: .6em; height: .6em; border-radius: 50%; margin-right: .35em; vertical-align: middle; }
button.chip.cal.off { opacity: .5; text-decoration: line-through; background: transparent; }
button.chip.cal.off .dot { background: transparent !important; border: 1px solid var(--muted); }
.chip-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 .2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Aufgaben ohne Termin */
.task { border-left: 4px solid var(--p3); padding-left: .6rem; }
.task.p1 { border-left-color: var(--p1); } .task.p2 { border-left-color: var(--p2); } .task.p4 { border-left-color: var(--p4); } .task.p5 { border-left-color: var(--p5); }
.task-add { display: flex; gap: .5rem; flex-wrap: wrap; align-items: stretch; }
.task-add input[type=text] { flex: 1 1 220px; min-width: 0; }
.task-add select { width: auto; flex: 0 0 auto; }
details.done-tasks summary { cursor: pointer; color: var(--muted); padding: .5rem 0; }
a.help-link { text-decoration: none; display: inline-flex; align-items: center; padding: .45rem .9rem; border: 1px solid var(--border); border-radius: 8px; min-height: 40px; color: var(--text); }

/* App installieren */
.ic { width: 1.15em; height: 1.15em; vertical-align: -.2em; display: inline-block; color: var(--primary); }
.install-steps { padding-left: 1.3rem; margin: .25rem 0; }
.install-steps li { margin: .45rem 0; line-height: 1.5; }
.install-benefits { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: .92rem; }
.install-ok { color: var(--primary); font-weight: 600; margin: 0; }
button.big { padding: .7rem 1.4rem; font-size: 1.05rem; }
.install-banner { display: flex; gap: .7rem; align-items: center; padding: .7rem .8rem; margin: 0 0 1rem; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--primary) 9%, var(--card)); }
.install-banner img { border-radius: 9px; flex: none; }
.install-banner > div { flex: 1; min-width: 0; line-height: 1.3; }
.install-banner .ghost { padding: .3rem .5rem; min-height: 0; }

/* Handy: Kopfzeile kompakt. Logo, Hilfe und Abmelden oben, Menü als eine wischbare Zeile darunter */
@media (max-width: 640px) {
  .topbar { padding: .5rem 12px .4rem; gap: .4rem .5rem; padding-top: max(.5rem, env(safe-area-inset-top)); }
  .topbar .brand { flex: 1; }
  .topbar a.help-link, .topbar #logout { padding: .3rem .7rem; min-height: 34px; font-size: .9rem; }
  .topbar nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -12px; padding: 0 12px 2px; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav button { flex: 0 0 auto; white-space: nowrap; min-height: 36px; padding: .35rem .8rem; }
  .install-banner { flex-wrap: wrap; }
  .install-banner > div { flex: 1 1 60%; }
}

/* hidden gilt immer, auch für Elemente mit eigener display-Regel (z. B. .stack) */
[hidden] { display: none !important; }
