:root {
  --bg: #F3F2EE;
  --surface: #FFFFFF;
  --ink: #1B1D1C;
  --muted: #5E625F;
  --line: #DEDCD5;
  --line-strong: #C9C6BD;
  --dash: #A9A69C;
  --soft: #E8E6E0;
  --accent: #1D5FD1;
  --accent-ink: #164AA6;
  --accent-soft: #E4ECFB;
  --accent-mid: #9DB8EC;
  --missed: #B4410E;
  --missed-soft: #FBE9DF;
  --on-accent: #FFFFFF;
  --inv-bg: #1B1D1C;
  --inv-fg: #FFFFFF;
  --hero-bg: #1B1D1C;
  --hero-fg: #FFFFFF;
  --hero-sub: #B9BCB8;
  --hero-muted: #CFD1CD;
  --hero-track: #3A3E3C;
  --hero-fill: #7FA8F0;
  --banner-fg: #7A2E0A;
  --hint-fg: #1B3F80;
  --pending: #8A4A12;
  color-scheme: light dark;
  --radius: 18px;
  --font: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Space Grotesk', Inter, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141615;
    --surface: #1E2120;
    --ink: #ECEBE6;
    --muted: #A3A7A4;
    --line: #333735;
    --line-strong: #4A4E4C;
    --dash: #6E726F;
    --soft: #2A2E2C;
    --accent: #7AA4F2;
    --accent-ink: #A2C0F6;
    --accent-soft: #1E2A42;
    --accent-mid: #3F5E99;
    --missed: #F0895B;
    --missed-soft: #3A2218;
    --on-accent: #0D1A33;
    --inv-bg: #ECEBE6;
    --inv-fg: #141615;
    --hero-bg: #262A28;
    --hero-track: #3F4442;
    --banner-fg: #F6C3A8;
    --hint-fg: #BCD0F7;
    --pending: #E8B07A;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
h1, h2 { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Kopf & Navigation ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 20px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand__mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
}
.brand__name { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
.mepill {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 6px 0 12px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500;
}
.mepill:hover { color: var(--ink); }

.content {
  flex: 1;
  padding: 4px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tabs {
  position: sticky; bottom: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tabs[hidden] { display: none; }
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 52px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ---------- Bausteine ---------- */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 500; }
.center { text-align: center; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.card--dark { background: var(--hero-bg); color: var(--hero-fg); border: none; }
.card h2 { font-size: 15px; font-weight: 600; }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-top: 4px; }
.section-head h1, .page-title { font-family: var(--display); font-weight: 600; font-size: 22px; }
.page-title { font-size: 28px; }

.avatar {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0;
}
.avatar--sm { width: 32px; height: 32px; font-size: 14px; }
.avatar--md { width: 40px; height: 40px; font-size: 16px; }
.avatar--xl { width: 72px; height: 72px; font-size: 30px; font-family: var(--display); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 16px; border-radius: 14px; border: none;
  font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-ink); color: var(--on-accent); }
.btn--dark { background: var(--inv-bg); color: var(--inv-fg); }
.btn--dark:hover { color: var(--inv-fg); opacity: 0.88; }
.btn--ghost { background: var(--surface); border: 1px solid var(--line-strong); font-weight: 500; font-size: 14px; }
.btn--lg { min-height: 52px; }
.btn--xl { min-height: 56px; font-size: 17px; border-radius: 16px; }
.btn--grow { flex: 1; }
.btn--block { display: flex; width: 100%; }
.btn--sm { min-height: 44px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn--icon { width: 44px; padding: 0; }
.btn:disabled { opacity: 0.5; cursor: default; }

.linkbtn {
  min-height: 44px; padding: 0 8px; border: none; background: transparent;
  color: var(--muted); font-size: 13px; text-decoration: underline;
}

.bar { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; display: flex; }
.bar > div { height: 100%; background: var(--accent); border-radius: 4px; }
.bar--dark { background: var(--hero-track); }
.bar--dark > div { background: var(--hero-fill); }
.bar--thick { height: 10px; border-radius: 5px; }
.bar--thin { height: 6px; }
.bar .bar__planned { background: var(--accent-mid); border-radius: 0; }

.banner, .hint {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: 16px; font-size: 14px; line-height: 1.45;
}
.banner { background: var(--missed-soft); color: var(--banner-fg); }
.hint { background: var(--accent-soft); color: var(--hint-fg); }
.banner svg, .hint svg { flex-shrink: 0; margin-top: 1px; }

/* ---------- Fortschrittskarte ---------- */
.progress { padding: 18px 20px; }
.progress__top { display: flex; align-items: baseline; justify-content: space-between; }
.progress__day { font-family: var(--display); font-weight: 600; font-size: 28px; }
.progress__day span { color: var(--hero-sub); font-weight: 500; font-size: 18px; }
.progress__end, .progress__sub { font-size: 13px; color: var(--hero-muted); }
.finish h1 { font-family: var(--display); font-size: 26px; }
.finish p { margin: 0; color: var(--hero-muted); }

/* ---------- Slots (Heute) ---------- */
.slot {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.slot--assigned { border: 2px solid var(--accent); }
.slot--free { background: transparent; border: 2px dashed var(--dash); }
.slot--missed { border: 2px solid var(--missed); }
.slot__row { display: flex; align-items: center; gap: 14px; }
.slot__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.slot__text strong { font-size: 16px; font-weight: 600; }
.slot__text .muted { font-size: 13px; }
.slot__meta { font-size: 13px; color: var(--muted); font-weight: 500; }
.slot__actions { display: flex; gap: 10px; align-items: center; }
.slot__foot { display: flex; justify-content: flex-end; margin: -8px -8px -8px 0; }
.slot__note { margin: 0; font-size: 14px; font-style: italic; color: var(--muted); }

.bubble {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: -0.02em;
}
.bubble--done { background: var(--accent); color: var(--on-accent); }
.bubble--time { background: var(--accent-soft); color: var(--accent); }
.bubble--free { background: var(--soft); color: var(--ink); }
.bubble--missed { background: var(--missed-soft); color: var(--missed); }

/* ---------- Willkommen ---------- */
.welcome { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: 32px 0 8px; }
.welcome h1 { font-family: var(--display); font-weight: 600; font-size: 34px; line-height: 1.1; }
.lead { margin: 0; font-size: 16px; line-height: 1.5; color: var(--muted); }

/* ---------- Plan ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 40px; padding: 0 16px; border-radius: 20px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 14px; font-weight: 500; color: var(--ink); text-decoration: none;
}
.chip[aria-current="true"] { background: var(--inv-bg); color: var(--inv-fg); border-color: var(--inv-bg); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.legend .l-done { background: var(--accent); }
.legend .l-assigned { border: 2px solid var(--accent); background: var(--surface); }
.legend .l-free { border: 2px dashed var(--dash); }
.legend .l-missed { background: var(--missed); }
.pastbtn {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 48px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 14px;
}
.day { padding: 14px; gap: 10px; }
.day--today { border: 2px solid var(--ink); }
.day h2 { font-size: 15px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile {
  min-height: 56px; border-radius: 12px; padding: 6px 8px;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 2px;
  text-align: left; border: none; background: transparent; min-width: 0;
}
.tile span { font-size: 12px; color: var(--muted); }
.tile strong { font-size: 14px; font-weight: 600; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile--done { background: var(--accent); color: var(--on-accent); }
.tile--done span { color: var(--on-accent); opacity: 0.9; }
.tile--assigned { border: 2px solid var(--accent); background: var(--surface); }
.tile--free { border: 2px dashed var(--dash); }
.tile--free strong { color: var(--accent); }
.tile--missed { background: var(--missed-soft); border: 2px solid var(--missed); }
.tile--missed strong { color: var(--missed); }
.empty { padding: 24px 8px; }

/* ---------- Fortschritt ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.stat strong { font-family: var(--display); font-weight: 600; font-size: 28px; }
.stat--accent strong { color: var(--accent); }
.stat--missed strong { color: var(--missed); }
.stat span { font-size: 13px; color: var(--muted); }
.person { display: flex; align-items: center; gap: 12px; }
.person__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.person__line { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.person__line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.later { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 16px; display: flex; gap: 12px; align-items: center; color: var(--muted); }
.later strong { color: var(--ink); font-size: 14px; display: block; }
.rowlink {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; padding: 0 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 500;
}
.rowlink:hover { color: var(--ink); }

/* ---------- Personen & Einstellungen ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; align-self: flex-start; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 500; }
.back:hover { color: var(--ink); }
.pcard { gap: 12px; padding: 14px; }
.pcard__head { display: flex; align-items: center; gap: 12px; }
.pcard__name { font-size: 16px; font-weight: 600; }
.pcard__tag { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.pcard__ok { font-size: 13px; color: var(--accent); font-weight: 500; }
.pcard__pending { font-size: 13px; color: var(--pending); font-weight: 500; }
.linkbox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--muted);
  background: var(--bg); border-radius: 10px; padding: 10px 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row { display: flex; gap: 8px; align-items: center; }
.menu { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.menu button { min-height: 44px; text-align: left; border: none; background: transparent; padding: 0 4px; font-size: 15px; }
.menu .danger { color: var(--missed); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label, .label { font-size: 14px; font-weight: 500; color: var(--muted); }
.input {
  flex: 1; min-width: 0; min-height: 52px; padding: 0 14px; border-radius: 14px;
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 16px;
}
.times { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.times label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.times .input { padding: 0 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--inv-bg); color: var(--inv-fg); padding: 12px 18px; border-radius: 14px;
  font-size: 15px; font-weight: 500; max-width: calc(100% - 40px); box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  z-index: 10;
}
.toast[hidden] { display: none; }
