:root {
  --primary: #1a5276;
  --primary-dark: #0f2a3d;
  --accent: #e67e22;
  --bg: #f2f4f6;
  --card: #ffffff;
  --text: #1c2833;
  --muted: #6b7a85;
  --border: #dfe4e8;
  --ok: #1e8449;
  --today: #fdf2e9;
  --tab: #ffffff;
  --radius: 14px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #0f2a3d;
    --bg: #0e1418;
    --card: #19232a;
    --text: #e8edf0;
    --muted: #8fa0ab;
    --border: #2a363e;
    --today: #2b2218;
    --tab: #141c21;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  padding-bottom: calc(72px + var(--sab));
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* Kopf */
.top {
  background: linear-gradient(135deg, var(--primary), #21618c);
  color: #fff;
  padding: calc(14px + var(--sat)) 18px 14px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title { font-size: 1.35rem; font-weight: 700; letter-spacing: .2px; }
.sub { font-size: .86rem; opacity: .9; margin-top: 2px; }
.stats { font-size: .8rem; opacity: .85; margin-top: 10px; }
.ring { position: relative; width: 56px; height: 56px; flex: none; }
.ring svg { width: 56px; height: 56px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.2; }
.ring-bg { stroke: rgba(255,255,255,.25); }
.ring-fg { stroke: #fff; stroke-linecap: round; stroke-dasharray: 97.4; stroke-dashoffset: 97.4; transition: stroke-dashoffset .4s ease; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: .78rem; font-weight: 700; }

/* Wochen-Navigation */
.weeknav {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.navbtn { width: 44px; height: 40px; font-size: 1.6rem; line-height: 1; border-radius: 10px; color: var(--primary); }
@media (prefers-color-scheme: dark) { .navbtn { color: #7fb3d5; } }
.navbtn:active { background: var(--border); }
.weeklabel { flex: 1; text-align: center; padding: 4px 6px; border-radius: 10px; }
.weeklabel strong { display: block; font-size: 1rem; }
.weeklabel small { display: block; color: var(--muted); font-size: .78rem; }
.weeklabel .note { display: block; font-size: .76rem; margin-top: 2px; color: var(--accent); font-weight: 600; }

/* Tage */
main { padding: 10px 12px 8px; display: flex; flex-direction: column; gap: 10px; }
.day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.day.past { opacity: .82; }
.day-head { display: flex; align-items: baseline; gap: 8px; padding: 10px 14px 4px; }
.day-head .dow { font-weight: 700; }
.day-head .date { color: var(--muted); font-size: .86rem; }
.day-head .badge { margin-left: auto; font-size: .7rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 10px; }
.item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  min-height: 56px;
}
.item:first-of-type { border-top: 0; }
.item:active { background: var(--bg); }
.item .box {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border); display: grid; place-items: center;
  font-size: .9rem; color: #fff; transition: background .15s, border-color .15s;
}
.item.done .box { background: var(--ok); border-color: var(--ok); }
.item.rest .box { visibility: hidden; }
.item .icon { flex: none; font-size: 1.25rem; width: 28px; text-align: center; }
.item .txt { flex: 1; min-width: 0; }
.item .t { font-weight: 600; font-size: .96rem; }
.item .d { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.item.done .t { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.item .tag { flex: none; width: 4px; align-self: stretch; border-radius: 2px; }
.banner {
  background: var(--today); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 10px 14px; font-size: .88rem;
}

/* Tab-Leiste */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-around;
  background: var(--tab);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + var(--sab));
}
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; color: var(--muted); padding: 4px 12px; min-width: 64px; }
.tabbar button span { font-size: 1.3rem; line-height: 1.1; }
.tabbar button:active { color: var(--accent); }

/* Dialog */
dialog {
  border: 0; padding: 0; margin: auto;
  width: min(100vw, 560px); max-width: 100vw; max-height: 100dvh;
  background: var(--card); color: var(--text);
  border-radius: 18px 18px 0 0;
}
@media (min-width: 600px) { dialog { border-radius: 18px; } }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog[open] { position: fixed; bottom: 0; top: auto; max-height: 88dvh; display: flex; flex-direction: column; }
@media (min-width: 600px) { dialog[open] { top: 0; bottom: 0; } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 8px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { margin: 0; font-size: 1.1rem; }
.close { width: 36px; height: 36px; border-radius: 50%; background: var(--bg); font-size: .95rem; }
.dlg-body { padding: 14px 18px calc(18px + var(--sab)); overflow: auto; font-size: .92rem; }
.dlg-body p { margin: 8px 0; }
.dlg-body h3 { margin: 16px 0 6px; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.dlg-body ul { padding-left: 18px; margin: 6px 0; }
.dlg-body li { margin: 4px 0; }
.phase {
  display: grid; grid-template-columns: 6px 1fr auto; gap: 0 12px;
  border: 1px solid var(--border); border-radius: 12px; margin: 8px 0; overflow: hidden;
  width: 100%; text-align: left;
}
.phase .bar { grid-row: 1 / span 3; }
.phase .name { font-weight: 700; padding-top: 10px; }
.phase .pct { padding: 10px 12px 0 0; font-weight: 700; color: var(--muted); }
.phase .range { color: var(--muted); font-size: .82rem; grid-column: 2 / span 2; }
.phase .focus { font-size: .84rem; grid-column: 2 / span 2; padding: 4px 12px 10px 0; }
.phase .focus b { color: var(--ok); }
.phase.current { border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px 14px; margin: 6px 0;
  border-radius: 12px; background: var(--primary); color: #fff; font-weight: 600;
  text-decoration: none;
}
.btn.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: #c0392b; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; word-break: break-all; background: var(--bg); padding: 8px 10px; border-radius: 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--sab)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .88rem;
  z-index: 20; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
