:root {
  --bg: #0f1720;
  --bg2: #16212e;
  --card: #1c2a3a;
  --card2: #223346;
  --line: #2c3f55;
  --text: #eaf1f8;
  --muted: #9fb2c6;
  --brand: #e2001a;       /* DB red */
  --green: #21c47a;
  --amber: #f5a623;
  --blue: #3aa0ff;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg2));
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(15, 23, 32, 0.85);
  backdrop-filter: blur(8px); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; }
.logo { font-size: 1.5rem; }
.brandname { letter-spacing: 0.3px; }
.langswitch button {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 8px; cursor: pointer; font-weight: 600; margin-left: 6px;
}
.langswitch button.active { color: #fff; background: var(--brand); border-color: var(--brand); }

main { max-width: 760px; margin: 0 auto; padding: 22px 16px 60px; }

.hero h1 { font-size: 1.55rem; margin: 14px 0 8px; }
.intro { color: var(--muted); margin: 0 0 18px; }
.intro strong, .hint strong { color: var(--text); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}

.fields { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.field > span { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.field input {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 12px; border-radius: 10px; font-size: 1rem; width: 100%;
}
.field input:focus { outline: none; border-color: var(--blue); }
.swap {
  align-self: end; margin-bottom: 4px; background: var(--card2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; width: 42px; height: 44px;
  font-size: 1.1rem; cursor: pointer;
}

.suggest {
  list-style: none; margin: 4px 0 0; padding: 4px; position: absolute; top: 100%; left: 0; right: 0;
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px; z-index: 10;
  max-height: 260px; overflow: auto; box-shadow: var(--shadow);
}
.suggest li { padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.suggest li:hover, .suggest li.active { background: var(--brand); }
.suggest li small { display: block; color: var(--muted); }
.suggest li:hover small, .suggest li.active small { color: #ffd9dd; }

.row2 { display: flex; gap: 10px; align-items: end; margin-top: 14px; flex-wrap: wrap; }
.field.when { flex: 1; min-width: 180px; }
.btn-primary {
  background: var(--brand); color: #fff; border: none; border-radius: 10px;
  padding: 12px 18px; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary[disabled] { opacity: 0.6; cursor: progress; }
.btn-primary.block { display: block; text-align: center; text-decoration: none; margin-top: 14px; }
.btn-ghost {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600;
}
.error { color: #ff8b96; margin: 12px 0 0; font-weight: 600; }

.status { border-left: 5px solid var(--blue); }
.status.ok { border-left-color: var(--green); background: linear-gradient(180deg, rgba(33,196,122,0.12), var(--card)); }
.status.warn { border-left-color: var(--amber); }
.status h2 { margin: 0 0 6px; font-size: 1.2rem; }
.status p { margin: 0; color: var(--muted); }
.status p strong { color: var(--text); }

.section h2 { margin: 0 0 4px; font-size: 1.15rem; }
.section.fern h2 { color: #ffd1d6; }
.hint { color: var(--muted); margin: 0 0 12px; font-size: 0.92rem; }

.connlist { display: flex; flex-direction: column; gap: 10px; }
.conn {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.conn.fern { border-color: #5a3340; background: linear-gradient(180deg, rgba(226,0,26,0.08), var(--bg2)); }
.conn-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.time { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.time .arrow { color: var(--muted); margin: 0 6px; font-weight: 400; }
.lines { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.pill {
  font-size: 0.78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--card2); border: 1px solid var(--line); white-space: nowrap;
}
.pill.fern { background: var(--brand); border-color: var(--brand); color: #fff; }
.pill.nah { background: #2a4a63; border-color: #336082; color: #d6ecff; }
.conn-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 0.86rem; }
.badge { font-size: 0.76rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.ontime { background: rgba(33,196,122,0.18); color: var(--green); }
.badge.delay { background: rgba(245,166,35,0.2); color: var(--amber); }
.badge.cancelled { background: rgba(226,0,26,0.22); color: #ff8b96; }
.badge.refund { background: rgba(33,196,122,0.18); color: var(--green); }

/* a regional train + its indented IC/ICE replacement suggestions */
.conn-group { display: flex; flex-direction: column; }
.conn.eligible { border-color: var(--green); border-left: 4px solid var(--green); }
.alts {
  margin: -2px 0 0 22px; padding: 12px 14px 12px 16px;
  border-left: 2px dashed var(--green);
  background: rgba(33, 196, 122, 0.06);
  border-radius: 0 12px 12px 0;
  display: flex; flex-direction: column; gap: 8px;
}
.alt-title { font-weight: 700; color: var(--green); font-size: 0.92rem; }
.alt {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg2); border: 1px solid #2c4a3c; border-radius: 10px; padding: 8px 12px;
}
.time.small { font-size: 1rem; }
.alt-none { color: var(--muted); font-size: 0.88rem; margin: 0; }

.btn-pick {
  align-self: flex-start; background: var(--green); color: #06231a; border: none;
  border-radius: 8px; padding: 7px 12px; font-weight: 700; cursor: pointer; font-size: 0.85rem;
}
.btn-pick:hover { filter: brightness(1.06); }

/* claim assistant modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow: auto;
}
/* the class sets display:flex, which would otherwise beat the UA [hidden] rule,
   so the hidden attribute must be honoured explicitly (open & close + load) */
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  width: 100%; max-width: 640px; padding: 20px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 1.25rem; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.8rem; cursor: pointer; line-height: 1; }
.modal h3 { font-size: 1rem; margin: 18px 0 8px; color: #ffd1d6; }
.privacy { color: var(--green); font-size: 0.86rem; margin: 6px 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.grid2 label.wide { grid-column: 1 / -1; }
.grid2 input {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 10px; border-radius: 8px; font-size: 0.95rem;
}
.grid2 input:focus { outline: none; border-color: var(--blue); }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.saved-hint { color: var(--green); font-size: 0.85rem; }
.trip-summary { display: flex; flex-direction: column; gap: 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.trip-summary .row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; }
.trip-summary .row span:first-child { color: var(--muted); }
.trip-summary .row span:last-child { font-weight: 600; text-align: right; }
.sheet {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem; resize: vertical;
}
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

.rules ul, .checklist ol { margin: 8px 0 0; padding-left: 20px; }
.rules li, .checklist li { margin-bottom: 8px; color: var(--muted); }
.rules li strong, .checklist li strong { color: var(--text); }
.rules h2, .checklist h2 { margin: 0; font-size: 1.1rem; }

footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 0 16px 30px; max-width: 760px; margin: 0 auto; }

@media (max-width: 560px) {
  .fields { grid-template-columns: 1fr; }
  .swap { justify-self: center; transform: rotate(90deg); }
  .row2 { flex-direction: column; align-items: stretch; }
  .btn-primary, .btn-ghost { width: 100%; }
}
