:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --text: #13202b;
  --muted: #5d6b78;
  --line: #dde4ea;
  --brand: #0f3d5e;
  --accent: #ff7a3d;
  --accent-ink: #ffffff;
  --good: #1f8a53;
  --warn: #b25a00;
  --warn-bg: #fff3e4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 61, 94, .06), 0 4px 16px rgba(15, 61, 94, .06);
  --tabbar-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d151c;
    --surface: #16212b;
    --text: #e7eef4;
    --muted: #93a3b1;
    --line: #26333f;
    --brand: #8cc7f0;
    --warn: #ffb15c;
    --warn-bg: #2e2112;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}
.login-logo { margin-bottom: 8px; }
.login-card form { text-align: left; margin-top: 16px; display: grid; gap: 12px; }
.error { color: #d1373a; min-height: 1.5em; margin: 0; font-size: .9rem; }

/* ---------- App-Gerüst ---------- */
.app { min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand);
  color: #fff;
}
@media (prefers-color-scheme: dark) { .topbar { background: #0f2433; } }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.chip {
  font-size: .78rem; padding: 2px 8px; border-radius: 99px;
  background: rgba(255, 255, 255, .16);
  font-variant-numeric: tabular-nums;
}
.topbar .icon-btn { color: #fff; }

.tab { max-width: 680px; margin: 0 auto; padding: 16px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tab-btn {
  flex: 1; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: .78rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer;
}
.tab-btn span { font-size: 1.3rem; line-height: 1; }
.tab-btn.active { color: var(--brand); font-weight: 600; }

/* ---------- Bausteine ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.form { display: grid; gap: 14px; }
.row { display: grid; gap: 10px; }
.row.two { grid-template-columns: 1fr 1fr; }
.route-row { grid-template-columns: 1fr auto 1fr; align-items: end; }

.field { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.field input, .field select, .field textarea, .chat-input textarea {
  font: inherit; font-size: 16px; /* verhindert iOS-Zoom */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
}
.field input:focus, .field select:focus, .field textarea:focus, .chat-input textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 0;
  border-color: transparent;
}

.btn {
  font: inherit; font-weight: 600;
  border: 0; border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .55; cursor: progress; }
.btn.big { padding: 14px; font-size: 1.05rem; }
.icon-btn {
  border: 0; background: none; color: var(--muted);
  font-size: 1.25rem; line-height: 1;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
}
.swap { margin-bottom: 2px; }

.segmented {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg); border-radius: 10px; padding: 4px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: 8px; border-radius: 8px;
  cursor: pointer; color: var(--muted); font-weight: 500;
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.more summary { cursor: pointer; color: var(--brand); font-weight: 500; }
.more[open] { display: grid; gap: 12px; }
.more[open] summary { margin-bottom: 4px; }

/* ---------- Ergebnisse ---------- */
.out { margin-top: 16px; display: grid; gap: 12px; }
.status {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  font-size: .85rem; color: var(--muted);
}
.status .step {
  background: var(--surface); border: 1px solid var(--line);
  padding: 2px 10px; border-radius: 99px;
}
.status .step.err { color: #d1373a; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.summary:empty { display: none; }
.summary { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.md p { margin: 0 0 .6em; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .3em 0 .6em; padding-left: 1.2em; }
.md code { background: var(--bg); padding: 0 4px; border-radius: 4px; }
.md h3, .md h4 { margin: .6em 0 .3em; font-size: 1rem; }

.cards { display: grid; gap: 10px; }
.flight {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: grid; gap: 6px;
  border-left: 4px solid transparent;
}
.flight.best { border-left-color: var(--good); }
.flight.hidden-city { border-left-color: var(--warn); }
.flight-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.price { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.badge { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.badge.good { background: #e4f5ec; color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
@media (prefers-color-scheme: dark) { .badge.good { background: #12301f; } }
.leg { font-weight: 600; }
.leg .time { font-variant-numeric: tabular-nums; }
.leg .date { font-weight: 400; color: var(--muted); }
.note { margin: 0; font-size: .88rem; background: var(--warn-bg); color: var(--warn); padding: 6px 10px; border-radius: 8px; }
.book { justify-self: start; background: var(--brand); color: #fff; margin-top: 4px; }
@media (prefers-color-scheme: dark) { .book { color: #0d151c; } }
.cost { font-size: .8rem; text-align: center; margin: 0; }

/* ---------- Chat ---------- */
#tab-chat { display: flex; flex-direction: column; min-height: calc(100dvh - 56px - var(--tabbar-h)); padding-bottom: 0; }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.bubble {
  max-width: 92%; padding: 10px 14px; border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.bubble.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
@media (prefers-color-scheme: dark) { .bubble.user { color: #0d151c; } }
.bubble.assistant { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble .cards { margin-top: 10px; }
.bubble .flight { box-shadow: none; border: 1px solid var(--line); border-left-width: 4px; }
.bubble .status { margin-bottom: 6px; }
.examples { display: grid; gap: 6px; margin-top: 8px; }
.example {
  font: inherit; font-size: .9rem; text-align: left; cursor: pointer;
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px;
}
.chat-input {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: flex; gap: 6px; align-items: flex-end;
  background: var(--bg); padding: 8px 0 12px;
}
.chat-input textarea { resize: none; max-height: 140px; }
.send { width: 46px; height: 46px; padding: 0; flex: none; }

.tips ol { padding-left: 1.2em; display: grid; gap: 10px; }
