:root {
  --bg: #0b0b10; --card: #15151d; --card2: #1d1d28; --line: #272735;
  --text: #f3f3f7; --muted: #9696a8; --dim: #6b6b7d;
  --a1: #ff8a3d; --a2: #ff3d7f; --grad: linear-gradient(135deg, var(--a1), var(--a2));
  --green: #34d399; --blue: #60a5fa; --yellow: #fbbf24; --red: #f87171; --purple: #a78bfa;
  --r: 18px; --safe-b: env(safe-area-inset-bottom); --safe-t: env(safe-area-inset-top);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--card2);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; width: 100%; outline: none;
  -webkit-appearance: none; appearance: none; }
input:focus, select:focus, textarea:focus { border-color: var(--a1); }
input[type=time], input[type=date] { min-height: 44px; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
h1 { font-size: 26px; margin: 4px 0 2px; letter-spacing: -.02em; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 13px; }
.green { color: var(--green); } .red { color: var(--red); } .yellow { color: var(--yellow); }

/* Kopf & Navigation */
#top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 10px) 16px 10px; background: rgba(11,11,16,.86); backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px); }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.bolt { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.lvl-pill { background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--card2); border: 1px solid var(--line); }
.icon-btn svg, #nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#view { padding: 4px 14px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around;
  padding: 8px 6px calc(8px + var(--safe-b)); background: rgba(16,16,22,.92); backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
#nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--dim); padding: 4px 0; position: relative; }
#nav button.on { color: var(--text); }
#nav button.on svg { color: var(--a1); }
#nav .badge { position: absolute; top: 0; right: calc(50% - 20px); background: var(--a2); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; }

/* Karten */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; }
.card.tight { padding: 12px 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.link { color: var(--a1); font-weight: 600; font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stack > * + * { margin-top: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--card2); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 14px; font-weight: 600; min-height: 44px; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 6px 20px -8px rgba(255,61,127,.6); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .45; }
.btn:active, .tile:active, .chip:active, .item:active { transform: scale(.98); }

/* Hero */
.hero { display: flex; gap: 16px; align-items: center; }
.ring { position: relative; flex: none; }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .val b { font-size: 26px; display: block; line-height: 1; }
.ring .val span { font-size: 11px; color: var(--muted); }
.lvlbar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.lvlbar > i { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width .6s; }
.open-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.open-chips span { font-size: 12px; background: var(--card2); border-radius: 99px; padding: 3px 9px; color: var(--muted); }

/* Next-Up */
.next { background: linear-gradient(135deg, rgba(255,138,61,.16), rgba(255,61,127,.12)); border-color: rgba(255,120,80,.35); }
.next .big { font-size: 18px; font-weight: 700; }

/* Streaks */
.streaks { display: flex; gap: 8px; overflow-x: auto; margin: 12px -14px; padding: 0 14px; scrollbar-width: none; }
.streaks::-webkit-scrollbar { display: none; }
.streak { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; font-size: 13px; white-space: nowrap; }
.streak b { font-size: 16px; }
.streak.hot { border-color: rgba(255,138,61,.5); }

/* Kacheln */
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-align: left; display: block; width: 100%; }
.tile .lbl { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.tile .num { font-size: 22px; font-weight: 700; margin: 4px 0 8px; letter-spacing: -.02em; }
.tile .num small { font-size: 13px; color: var(--muted); font-weight: 500; }
.bar { height: 6px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--grad); }
.bar.green > i { background: var(--green); } .bar.blue > i { background: var(--blue); } .bar.purple > i { background: var(--purple); }
.bar.over > i { background: var(--red); }

/* Checklisten */
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.item .t { flex: 1; min-width: 0; }
.item .t .meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.item.done .t > div:first-child { color: var(--dim); text-decoration: line-through; }
.chk { width: 28px; height: 28px; flex: none; border-radius: 9px; border: 2px solid var(--dim); display: grid; place-items: center; transition: all .15s; }
.chk.round { border-radius: 50%; }
.chk.on { background: var(--grad); border-color: transparent; }
.chk.on::after { content: ""; width: 10px; height: 6px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.xp { font-size: 11px; font-weight: 700; color: var(--a1); background: rgba(255,138,61,.12); border-radius: 99px; padding: 2px 7px; flex: none; }
.tag { font-size: 11px; border-radius: 99px; padding: 1px 7px; background: var(--card2); color: var(--muted); }
.tag.haushalt { color: var(--blue); } .tag.eltern { color: var(--purple); } .tag.uni { color: var(--yellow); } .tag.heute { color: var(--a1); }
.overdue { color: var(--red) !important; }
.slot-head { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
.slot-head:first-child { margin-top: 0; }

/* Chips & Segmente */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--card2); border: 1px solid var(--line); border-radius: 99px; padding: 7px 12px; font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; }
.chip small { color: var(--muted); } .chip.on small { color: #fff; opacity: .85; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1; padding: 8px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--card2); color: var(--text); }
.seg .cnt { font-size: 11px; color: var(--a1); margin-left: 3px; }

/* Tag-Navigation */
.daynav { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 2px; }
.daynav button { width: 40px; height: 40px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 18px; }
.daynav .d { font-weight: 700; font-size: 17px; text-align: center; }
.daynav .d small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }

/* Formulare */
.form-row { display: grid; gap: 8px; }
.form-row.c2 { grid-template-columns: 1fr 1fr; }
.form-row.c3 { grid-template-columns: 2fr 1fr 1fr; }
label.f { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field + .field, .form-row + .form-row, .form-row + .field, .field + .form-row { margin-top: 10px; }
.form-row > .field, .form-row > div > .field { margin-top: 0 !important; }
.wd { display: flex; gap: 5px; }
.wd button { flex: 1; height: 38px; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
.wd button.on { background: var(--grad); color: #fff; border-color: transparent; }
.switch { width: 50px; height: 30px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--green); border-color: transparent; }
.switch.on::after { transform: translateX(20px); }

/* Charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--dim); font-size: 10px; }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.stat b { font-size: 20px; display: block; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); }

/* Wake-Button */
.wake-btn { font-size: 20px; padding: 18px; border-radius: 16px; min-height: 64px; }

/* Timer */
.timer { font-size: 64px; font-weight: 800; text-align: center; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 6px 0; }

/* Belohnungen */
.reward { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.reward:first-of-type { border-top: 0; }
.reward .ic { font-size: 28px; width: 44px; height: 44px; display: grid; place-items: center; background: var(--card2); border-radius: 12px; flex: none; }
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ach { background: var(--card2); border-radius: 14px; padding: 10px 6px; text-align: center; border: 1px solid transparent; }
.ach .i { font-size: 28px; filter: grayscale(1); opacity: .35; }
.ach.done { border-color: rgba(255,138,61,.4); background: linear-gradient(160deg, rgba(255,138,61,.14), rgba(255,61,127,.08)); }
.ach.done .i { filter: none; opacity: 1; }
.ach .n { font-size: 12px; font-weight: 600; margin-top: 4px; line-height: 1.2; }
.ach .d { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.2; }
.ach .bar { margin-top: 6px; height: 4px; }

/* Sheet */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { background: var(--card); width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(20px + var(--safe-b)); border: 1px solid var(--line); border-bottom: 0; animation: up .25s cubic-bezier(.2,.9,.3,1); }
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 14px; font-size: 19px; }
.sheet .actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet .actions .btn { flex: 1; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* Toasts & XP */
#toasts { position: fixed; left: 0; right: 0; top: calc(var(--safe-t) + 60px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: drop .3s; max-width: 90vw; }
.toast.err { border-color: var(--red); color: var(--red); }
.toast.xp { background: var(--grad); border: 0; color: #fff; font-size: 17px; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 70; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }
.levelup { text-align: center; padding: 10px 0; }
.levelup .big { font-size: 64px; }

/* Login */
.login { min-height: 70vh; display: grid; place-items: center; }
.login .card { width: 100%; max-width: 360px; text-align: center; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.empty { color: var(--dim); font-size: 14px; padding: 6px 0; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--card2); border-radius: 10px; padding: 10px; word-break: break-all; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
ol.steps { padding-left: 20px; margin: 8px 0; } ol.steps li { margin: 6px 0; }
