:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #15222c;
  --muted: #68757f;
  --line: #e9e6df;
  --accent: #1a63d6;
  --accent-ink: #144a9f;
  --accent-tint: #e9f0fc;
  --accent-soft: #c9dbf8;
  --good: #1c8f5c;
  --good-tint: #e5f4ec;
  --warn: #a8690a;
  --warn-tint: #fbf0da;
  --bad: #c2412f;
  --bad-tint: #fbe9e5;
  --radius: 22px;
  --round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p, ul, ol, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

h1 { font: 600 30px/1.15 var(--round); letter-spacing: -0.01em; }
h2 { font: 600 22px/1.2 var(--round); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.lead { color: var(--muted); margin: -6px 0 18px; max-width: 60ch; }
.error { color: var(--bad); font-size: 14px; }

.eyebrow { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.eyebrow--accent { color: var(--accent-ink); }

.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Rahmen ---------- */

.shell { min-height: 100dvh; }

.main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom));
}

.shell--focus .main { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(246, 245, 241, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 64px; padding: 6px 10px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 11px; font-weight: 500;
}

.nav a.is-on { color: var(--ink); }
.nav a.nav-live { color: var(--accent); }
.brand { display: none; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }

.back { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 14px; margin: -4px 0 10px -6px; padding: 4px 6px; }

.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }

/* ---------- Karten ---------- */

.card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}

.card--warn { background: var(--warn-tint); color: #5c3a05; }
.card--warn .eyebrow { color: var(--warn); }
.card--good { background: var(--good-tint); }
.card--good .eyebrow, .card--good .row-title { color: var(--good); }

.card h2 { margin-bottom: 2px; }

.journey { background: var(--accent-tint); color: var(--accent-ink); }
.journey .unit { font-size: 14px; }

.big { display: flex; align-items: baseline; gap: 8px; }
.num { font: 600 44px/1 var(--round); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.num-md { font: 600 24px/1.2 var(--round); font-variant-numeric: tabular-nums; }
.num-sm { font: 500 15px/1.2 var(--round); font-variant-numeric: tabular-nums; }

.stage { display: block; width: 100%; height: auto; margin: 6px 0 2px; overflow: visible; }
.stage path { fill: none; stroke-width: 6; stroke-linecap: round; }
.stage-base { stroke: var(--accent-soft); }
.stage-prog { stroke: var(--accent); }
.stage-end { fill: var(--accent); }
.stage-end--open { fill: var(--accent-tint); stroke: var(--accent-soft); stroke-width: 3; }
.stage-boat { fill: #fff; stroke: var(--accent); stroke-width: 4; }

.ends { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }

.overall { height: 6px; border-radius: 3px; background: var(--accent-soft); margin: 16px 0 6px; overflow: hidden; }
.overall i { display: block; height: 100%; min-width: 6px; border-radius: 3px; background: var(--accent); }

.week-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.week-name { flex: 1; font-weight: 500; white-space: nowrap; }
.week-chain { font-size: 13px; color: var(--muted); }

.dots { display: inline-flex; align-items: center; gap: 7px; }
.dot3 { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #cfd4d8; }
.dot3.is-on { background: var(--accent); border-color: var(--accent); }
.dot3-more { font-size: 12px; color: var(--muted); }

.blocks { margin: 12px 0 16px; display: grid; gap: 6px; }
.blocks li { position: relative; padding-left: 16px; font-size: 15px; }
.blocks li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-soft); }

.quiet-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; margin-top: 12px; }
.link { background: none; border: 0; padding: 6px 2px; color: var(--muted); font-size: 14px; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.link:hover { color: var(--ink); }

.row-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-link .ic { color: #b9c0c5; }
.row-title { font-weight: 600; }

.list li + li { border-top: 1px solid var(--line); }
.list .row-link { padding: 12px 0; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 8px; text-align: center; }
.tiles--plain { padding: 0 4px; }

.empty { text-align: center; padding: 36px 22px; display: grid; gap: 10px; justify-items: center; }
.note { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); white-space: pre-wrap; }

/* ---------- Knöpfe ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px;
  border: 0; border-radius: 15px;
  background: #ecebe6; color: var(--ink);
  font-weight: 600; font-size: 15px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary .ic { fill: currentColor; stroke-width: 0; width: 18px; height: 18px; }
.btn--wide { width: 100%; min-height: 54px; font-size: 16px; border-radius: 17px; }
.btn--small { min-height: 36px; padding: 6px 14px; font-size: 14px; border-radius: 12px; }
.btn--danger { background: var(--bad-tint); color: var(--bad); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.avatars { display: flex; gap: 6px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: #e6e4dd; color: var(--muted);
  font: 600 15px var(--round); cursor: pointer;
  transition: transform 0.12s ease;
}
.avatar:active { transform: scale(0.94); }
.avatar.is-on { background: var(--accent); color: #fff; }

/* ---------- Reise ---------- */

.timeline { margin: 6px 0 12px; }
.tl-country { font-size: 12px; color: var(--muted); padding: 14px 0 4px 26px; }
.tl { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 7px 0; color: #9aa4ab; }
.tl::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tl-dot { position: relative; z-index: 1; flex: none; width: 14px; height: 14px; margin-top: 4px; border-radius: 50%; background: var(--surface); border: 2px solid #d5d9dc; }
.tl-body { flex: 1; min-width: 0; }
.tl-name { font-weight: 500; }
.tl-side { font-size: 13px; white-space: nowrap; padding-top: 2px; font-variant-numeric: tabular-nums; }
.tl.is-reached { color: var(--ink); }
.tl.is-reached::before { background: var(--accent); }
.tl.is-reached .tl-dot { background: var(--accent); border-color: var(--accent); }
.tl.is-next { color: var(--ink); }
.tl.is-next .tl-dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-tint); }
.tl.is-next .tl-side { color: var(--accent-ink); font-weight: 600; }

/* ---------- Plan ---------- */

.plan-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.plan-row + .plan-row { border-top: 1px solid var(--line); }
.plan-row > div { flex: 1; min-width: 0; }
.plan-mark { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #d5d9dc; display: grid; place-items: center; }
.plan-mark .ic { width: 14px; height: 14px; stroke-width: 3; }
.plan-row.is-done { color: var(--muted); }
.plan-row.is-done .plan-mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.plan-row.is-next .plan-mark { border-color: var(--accent); }

.extras { display: grid; gap: 10px; margin-top: 8px; }

/* ---------- Formulare ---------- */

.form { display: grid; gap: 16px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.field { display: grid; gap: 6px; margin-top: 10px; }
.form .field { margin-top: 0; }
.field > span, .field > legend { font-size: 14px; color: var(--muted); }
.field > legend { margin-bottom: 6px; }

input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: #fbfaf8; font-size: 16px;
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); background: #fff; }
textarea { resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: block; padding: 9px 14px; border-radius: 13px; background: #f1efea; font-size: 14px; cursor: pointer; }
.choice input:checked + span { background: var(--ink); color: #fff; }
.choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.switch { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; cursor: pointer; }
.switch input { flex: none; width: 22px; height: 22px; margin-top: 1px; accent-color: var(--accent); }

.zone-row { display: grid; grid-template-columns: 1fr 76px auto 76px auto; align-items: center; gap: 8px; margin: 8px 0; font-size: 15px; }
.zone-row input { min-height: 40px !important; padding: 6px 10px !important; text-align: center; }

details { margin-top: 12px; }
summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 6px 0; }
.log { margin: 8px 0 0; padding: 12px; border-radius: 12px; background: #f1efea; font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; max-height: 240px; overflow: auto; }
.live-row { display: flex; gap: 18px; margin-top: 14px; font-size: 14px; color: var(--muted); }
.live-row b { font: 600 18px var(--round); color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Diagramme ---------- */

.chart { display: block; width: 100%; height: auto; margin-top: 8px; }
.bar { fill: var(--accent-soft); }
.bar--now { fill: var(--accent); }
.line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.area { fill: var(--accent-tint); }
.band { fill: var(--good-tint); }
.chart-val { font: 600 11px var(--round); fill: var(--ink); }
.chart-lab { font: 11px var(--sans); fill: var(--muted); }

/* ---------- Training ---------- */

.main--train { max-width: 620px; padding-left: 0; padding-right: 0; padding-bottom: 0 !important; }

.train {
  position: relative;
  min-height: calc(100dvh - 18px - env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 18px;
  padding: 0 22px calc(120px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.train-prog { height: 4px; border-radius: 2px; background: #e6e4dd; overflow: hidden; }
.train-prog i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 2px; transition: width 0.3s linear; }

.train-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #e6e4dd; color: var(--muted); white-space: nowrap; }
.pill--on { background: var(--good-tint); color: var(--good); }

.train-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 260px; }
.hero-num { font: 600 clamp(96px, 30vw, 168px)/0.95 var(--round); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.hero-sub { color: var(--muted); margin-top: 6px; }

.zonebar { position: relative; width: min(100%, 360px); height: 10px; border-radius: 5px; background: #e6e4dd; margin-top: 18px; }
.zonebar-band { position: absolute; top: 0; bottom: 0; border-radius: 5px; background: var(--good); opacity: 0.85; }
.zonebar-mark { position: absolute; top: -6px; width: 5px; height: 22px; margin-left: -2.5px; border-radius: 3px; background: var(--ink); left: 0; transition: left 0.4s ease; }

.cue { margin-top: 22px; min-height: 62px; padding: 10px 20px; border-radius: 18px; transition: background 0.3s ease, color 0.3s ease; }
.cue-text { font: 600 22px/1.25 var(--round); }
.cue-sub { font-size: 14px; opacity: 0.85; }
.cue--ok { background: var(--good-tint); color: var(--good); }
.cue--low { background: var(--accent-tint); color: var(--accent-ink); }
.cue--high { background: var(--warn-tint); color: var(--warn); }
.cue--neutral { color: var(--muted); }

.ghost { background: var(--good-tint); color: var(--good); border-radius: 18px; padding: 12px 16px 14px; }
.ghost .eyebrow { color: inherit; opacity: 0.85; }
.ghost--behind { background: var(--warn-tint); color: var(--warn); }
.ghost-delta { font: 600 22px var(--round); font-variant-numeric: tabular-nums; }
.ghost-first { font-weight: 500; }
.lanes { position: relative; height: 34px; margin-top: 8px; }
.lanes::before, .lanes::after { content: ""; position: absolute; left: 0; right: 0; border-top: 1.5px dashed currentColor; opacity: 0.3; }
.lanes::before { top: 8px; }
.lanes::after { top: 26px; }
.boat { position: absolute; width: 34px; height: 12px; margin-left: -17px; border-radius: 6px 9px 9px 6px; left: 50%; transition: left 0.6s ease; }
.boat--me { top: 2px; background: currentColor; }
.boat--ghost { top: 20px; border: 2px solid currentColor; opacity: 0.7; }

.train-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; z-index: 2; }
.foot-num { font: 600 34px/1.1 var(--round); font-variant-numeric: tabular-nums; }
.controls { display: flex; gap: 10px; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; transition: transform 0.12s ease; }
.round:active { transform: scale(0.93); }
.round#t-toggle { background: var(--ink); color: #fff; }
.train-next { position: relative; z-index: 2; font-size: 14px; color: var(--muted); }

.water { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 110px; z-index: 1; pointer-events: none; }
.water-back { fill: var(--accent-soft); opacity: 0.55; }
.water-front { fill: var(--accent-tint); }

/* ---------- Abschluss ---------- */

.done { display: grid; gap: 14px; padding-top: 24px; }
.done-num { font: 600 56px/1 var(--round); letter-spacing: -0.03em; }
.arrival { background: var(--ink); color: #fff; animation: pop 0.6s 0.2s both cubic-bezier(0.2, 1.3, 0.4, 1); }
.arrival .eyebrow { color: #9fc3ff; }
.arrival .muted { color: #b8c2c9; }

@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 500;
  animation: pop 0.3s both;
}

/* ---------- iPad und Mac ---------- */

@media (min-width: 900px) {
  .shell:not(.shell--focus) { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
  .nav {
    position: sticky; top: 0; height: 100dvh;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 28px 14px; border-top: 0; border-right: 1px solid var(--line);
    background: transparent; backdrop-filter: none;
  }
  .brand { display: block; font: 600 20px var(--round); padding: 0 12px 20px; }
  .nav a { flex-direction: row; gap: 12px; font-size: 15px; padding: 11px 12px; }
  .nav a.is-on { background: var(--surface); }
  .main { max-width: 980px; padding: 40px 40px 60px; }
  .shell--focus .main { max-width: 640px; }
  .shell--focus .main--train { max-width: 760px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .card--span { grid-column: 1 / -1; }
  .card--next { grid-row: span 2; }
  h1 { font-size: 36px; }
  .toast { bottom: 32px; }
  .train { min-height: calc(100dvh - 40px); }
  .tiles--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

/* ---------- Figuren ---------- */

.fig { display: block; width: 100%; height: auto; border-radius: 18px; }
.fig-glow { stroke: #fff; opacity: 0; transition: opacity 0.18s ease; }
.fig-glow.is-on { opacity: 0.85; }
.extra { display: flex; gap: 14px; align-items: center; }
.extra .fig { flex: none; width: 116px; border-radius: 14px; }
.tech { display: grid; gap: 10px; }
.tech-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tech-phase { min-width: 104px; font-weight: 600; }
.chip { font-size: 14px; padding: 4px 13px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip.is-on { background: var(--accent-tint); border-color: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.chip.is-off { border-style: dashed; color: #a3acb3; }
.train-main--fig .fig { width: min(100%, 440px); margin-bottom: 14px; }
.train-main--fig .hero-num { font-size: clamp(64px, 18vw, 104px); }
