@font-face {
  font-family: "Atkinson Next";
  src: url("/fonts/atkinson-next.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #edf0f5;          /* kuehles Heft-Blaugrau */
  --grid: rgba(22, 33, 58, .045);
  --surface: #ffffff;
  --ink: #16213a;         /* Tinten-Navy */
  --muted: #5d6880;
  --rule: #d3d9e4;
  --now: #e5383b;         /* einziges Rot: die Jetzt-Linie */
  --done: #22a06b;
  --schule: #3b6fe0;
  --job: #d98c1f;
  --haus: #23978a;
  --pflege: #8a6bd8;
  --hatch: rgba(22, 33, 58, .07);
  --radius-l: 18px;
  --radius-s: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1626; --grid: rgba(255, 255, 255, .035); --surface: #18213a; --ink: #e9edf6;
    --muted: #9aa5bd; --rule: #29344f; --now: #ff5a5d; --done: #3cc488;
    --schule: #7aa0ff; --job: #f2b04d; --haus: #4fc7b8; --pflege: #b7a0ff; --hatch: rgba(255, 255, 255, .06);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  font: 17px/1.45 "Atkinson Next", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  padding: calc(env(safe-area-inset-top) + 8px) 0 calc(76px + env(safe-area-inset-bottom));
}
main { max-width: 640px; margin: 0 auto; padding: 8px 16px 24px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--schule); outline-offset: 2px; }

/* ---------- Kopf ---------- */
.dayhead, .wsum-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 0 14px; }
.date { margin: 8px 0 14px; font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -0.015em; }
.dayhead .date, .wsum-top .date { margin: 0; }
.dayprog { margin: 0; color: var(--muted); font-size: 15px; white-space: nowrap; }

/* ---------- Jetzt-Karte ---------- */
.now {
  --tone: var(--schule);
  position: relative; overflow: hidden;
  background: var(--surface); border-radius: var(--radius-l);
  padding: 18px 18px 16px 22px; margin-bottom: 22px;
  box-shadow: 0 1px 0 var(--rule), 0 10px 28px -18px rgba(22, 33, 58, .45);
}
.now::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--tone); }
.now[data-tone="job"] { --tone: var(--job); }
.now[data-tone="haus"] { --tone: var(--haus); }
.now[data-tone="pflege"] { --tone: var(--pflege); }
.now.calm::before { background: repeating-linear-gradient(135deg, var(--tone) 0 6px, transparent 6px 10px); }
.now-title { margin: 0; font-size: 28px; line-height: 1.12; font-weight: 700; letter-spacing: -0.02em; }
.now-note { margin: 4px 0 0; color: var(--muted); }
.now-big { margin: 14px 0 8px; display: flex; align-items: baseline; flex-wrap: wrap; }
.now-big .num { font-size: 56px; line-height: .9; font-weight: 800; letter-spacing: -0.03em; color: var(--now); }
.now-big .unit { font-size: 16px; color: var(--muted); margin-left: 8px; }
.now .bar { height: 8px; border-radius: 99px; background: var(--hatch); overflow: hidden; }
.now .bar .fill { height: 100%; background: var(--now); border-radius: 99px; transition: width .6s ease; }
.now-range { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.now-next { margin: 12px 0 0; font-size: 15px; }
.now-done {
  margin-top: 14px; width: 100%; min-height: 48px; border-radius: var(--radius-s);
  border: 2px solid var(--done); background: transparent; color: var(--done); font-weight: 700; cursor: pointer;
}
.now-done.on { background: var(--done); color: #fff; }

/* ---------- Zeitleiste ---------- */
.tl { position: relative; margin: 0 0 8px; }
.blk { position: relative; display: grid; grid-template-columns: 54px 1fr; }
.blk .t { font-size: 14px; color: var(--muted); padding-top: 6px; }
.blk .body {
  position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  margin: 2px 0; padding: 8px 10px 8px 14px; border-radius: var(--radius-s); min-height: 0; overflow: hidden;
}
.blk.task .body { background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule); }
.blk.task .body::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--schule); }
.blk[data-tone="job"] .body::before { background: var(--job); }
.blk[data-tone="haus"] .body::before { background: var(--haus); }
.blk[data-tone="pflege"] .body::before { background: var(--pflege); }
.blk.pause .body { background: repeating-linear-gradient(135deg, var(--hatch) 0 6px, transparent 6px 12px); padding-top: 5px; }
.blk.pause .title { font-size: 14px; color: var(--muted); font-weight: 400; }
.blk.pause .t { padding-top: 4px; }
.txt { display: flex; flex-direction: column; min-width: 0; }
.title { font-weight: 700; line-height: 1.25; }
.note { font-size: 14px; color: var(--muted); }
.blk.done .title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.blk.notdue .body { opacity: .55; }
.blk.current.task .body { box-shadow: inset 0 0 0 2px var(--ink); }

.chk {
  flex: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--muted); background: transparent; display: grid; place-items: center;
}
.chk::after { content: ""; width: 12px; height: 7px; border: solid transparent; border-width: 0 0 3px 3px; transform: translateY(-2px) rotate(-45deg); }
.chk.on { background: var(--done); border-color: var(--done); }
.chk.on::after { border-color: #fff; }
.chk:disabled { cursor: default; }

.nowline { position: absolute; left: 44px; right: 0; height: 0; border-top: 2px solid var(--now); z-index: 2; pointer-events: none; }
.nowline::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--now); }
.nowtime {
  position: absolute; left: -46px; top: -10px; background: var(--now); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 1; padding: 4px 7px; border-radius: 99px;
}

/* ---------- Woche ---------- */
.wsum { background: var(--surface); border-radius: var(--radius-l); padding: 14px 16px 12px; margin-bottom: 18px; box-shadow: 0 1px 0 var(--rule); }
.wsum .wsum-top { margin: 0 0 12px; }
.wbars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.wbar { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wbar .track { width: 100%; max-width: 30px; height: 56px; border-radius: 8px; background: var(--hatch); display: flex; align-items: flex-end; overflow: hidden; }
.wbar .fill { width: 100%; background: var(--done); border-radius: 8px 8px 0 0; }
.wbar .lbl { font-size: 13px; color: var(--muted); }
.wbar.today .lbl { color: var(--ink); font-weight: 700; }
.wbar.today .track { box-shadow: inset 0 0 0 2px var(--ink); }
.wbar.future .track { background: transparent; box-shadow: inset 0 0 0 1px var(--rule); }

.blockhead { font-size: 17px; margin: 18px 0 8px; }
.gridwrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 340px; background: var(--surface); border-radius: var(--radius-s); box-shadow: inset 0 0 0 1px var(--rule); }
.grid th { font-size: 13px; font-weight: 700; color: var(--muted); padding: 8px 2px; border-bottom: 1px solid var(--rule); }
.grid th.today { color: var(--ink); }
.grid td { padding: 6px 4px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid td.task { position: relative; padding-left: 14px; }
.grid td.task .time { display: block; font-size: 12px; color: var(--muted); }
.grid tr.pause td.task .time { display: inline; margin-left: 6px; }
.grid td.task::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--schule); }
.grid td.task[data-tone="job"]::before { background: var(--job); }
.grid td.task[data-tone="haus"]::before { background: var(--haus); }
.grid td.task[data-tone="pflege"]::before { background: var(--pflege); }
.grid td.task .title { font-size: 15px; }
.grid tr.pause td { padding-top: 3px; padding-bottom: 3px; background: repeating-linear-gradient(135deg, var(--hatch) 0 6px, transparent 6px 12px); }
.grid tr.pause td.task::before { display: none; }
.grid tr.pause .title { font-weight: 400; font-size: 13px; color: var(--muted); }
.grid tr.current td.task .title { text-decoration: underline 2px var(--now); text-underline-offset: 4px; }
.grid td.cell { text-align: center; width: 38px; padding: 6px 2px; }
.grid td.cell.today, .grid th.today { background: color-mix(in srgb, var(--schule) 9%, transparent); }
.dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted); background: transparent; cursor: pointer; padding: 0; }
.dot.on { background: var(--done); border-color: var(--done); }
.dot:disabled { cursor: default; }
.dash { color: var(--muted); }

/* ---------- Verlauf ---------- */
.weeks { display: flex; flex-direction: column; gap: 10px; }
.weekbtn {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: baseline; text-align: left;
  background: var(--surface); border: 0; border-radius: var(--radius-s); padding: 14px 16px; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--rule);
}
.weekbtn .wk { display: flex; align-items: baseline; gap: 10px; }
.weekbtn .kw { font-size: 20px; font-weight: 700; }
.weekbtn .range, .weekbtn .frac { color: var(--muted); font-size: 14px; }
.weekbtn .bar { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--hatch); overflow: hidden; }
.weekbtn .bar .fill { height: 100%; background: var(--done); border-radius: 99px; }
.back { background: none; border: 0; color: var(--schule); font-weight: 700; padding: 8px 0; cursor: pointer; }

/* ---------- Einstellungen ---------- */
.settings { margin-top: 28px; background: var(--surface); border-radius: var(--radius-l); padding: 16px; box-shadow: 0 1px 0 var(--rule); }
.settings h2 { margin: 0 0 6px; font-size: 18px; }
.switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.sw-txt { display: flex; flex-direction: column; }
.sw-label { font-weight: 700; }
.sw-help { font-size: 14px; color: var(--muted); }
.switch input { position: absolute; opacity: 0; width: 52px; height: 32px; right: 0; margin: 0; cursor: pointer; }
.sw-track { flex: none; width: 52px; height: 32px; border-radius: 99px; background: var(--rule); position: relative; transition: background .2s; }
.sw-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch input:checked + .sw-track { background: var(--done); }
.switch input:checked + .sw-track::after { transform: translateX(20px); }
.switch input:focus-visible + .sw-track { outline: 3px solid var(--schule); outline-offset: 2px; }
.action {
  margin-top: 14px; width: 100%; min-height: 48px; border: 0; border-radius: var(--radius-s);
  background: var(--ink); color: var(--bg); font-weight: 700; cursor: pointer;
}

/* ---------- Sonstiges ---------- */
.hint { color: var(--muted); font-size: 15px; }
.hint.big { font-size: 18px; margin-top: 30vh; text-align: center; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 5;
  max-width: 608px; margin: 0 auto; background: var(--ink); color: var(--bg);
  padding: 12px 16px; border-radius: var(--radius-s); text-align: center;
}

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  box-shadow: 0 -1px 0 var(--rule);
}
#tabs button { border: 0; background: none; color: var(--muted); font-weight: 700; padding: 10px 0; border-radius: 99px; cursor: pointer; }
#tabs button.on { background: var(--ink); color: var(--bg); }

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