/* Routenchecker – zuerst fürs Handy gebaut, ab 900 px zweispaltig. */
:root {
  --ink:#17212b; --muted:#5d6b78; --line:#d9e0e6; --bg:#f4f6f8; --card:#fff;
  --accent:#0b6e4f; --sel:#0b5ed7; --mine:#e60000; --mark:#ffd60a;
  --tap:46px; /* Mindesthöhe für alles, was man antippt */
}
* { box-sizing:border-box; }
/* ausgeblendete Felder wirklich ausblenden (sonst gewinnt display:block der Labels) */
[hidden] { display:none !important; }
html { -webkit-text-size-adjust:100%; scroll-behavior:smooth; }
body { margin:0; font:16px/1.45 system-ui,-apple-system,"Segoe UI",sans-serif; color:var(--ink); background:var(--bg); }

/* ---------- Kopfzeile ---------- */
header {
  position:sticky; top:0; z-index:20; display:flex; align-items:center; gap:10px;
  padding:10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  padding-top:max(10px, env(safe-area-inset-top));
  background:var(--ink); color:#fff;
}
header h1 { margin:0; font-size:18px; }
header nav { display:flex; gap:6px; margin-left:auto; }
header nav a { color:#fff; text-decoration:none; font-size:14px; padding:7px 12px; border:1px solid #ffffff55; border-radius:999px; }
header .version { margin:0; font-size:11px; color:#8fa0ae; }

/* ---------- Grundgerüst ---------- */
main { display:grid; grid-template-columns:1fr; gap:12px; padding:12px; padding-bottom:max(24px, env(safe-area-inset-bottom)); align-items:start; }
.panel, .results { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:14px; min-width:0; scroll-margin-top:64px; }
@media (min-width:900px) {
  main { grid-template-columns:minmax(340px,420px) 1fr; gap:16px; padding:16px; }
  header nav { display:none; }
  header .version { margin-left:auto; font-size:12px; }
  .panel, .results { padding:16px; }
}

/* ---------- Schritte und Formularfelder ---------- */
.step { padding-bottom:14px; margin-bottom:14px; border-bottom:1px solid var(--line); }
.step h2 { font-size:16px; margin:0 0 8px; display:flex; gap:8px; align-items:center; }
.step h2 span { background:var(--ink); color:#fff; width:24px; height:24px; border-radius:50%; display:grid; place-items:center; font-size:13px; flex:none; }
select, input[type=text], input:not([type]), input[type=number], button {
  font:inherit; font-size:16px; /* unter 16 px zoomt das iPhone beim Antippen */
  min-height:var(--tap); padding:10px 12px; border:1px solid var(--line); border-radius:10px; background:#fff; color:var(--ink); width:100%;
}
label { display:block; font-size:14px; color:var(--muted); margin-top:10px; }
label > select, label > input { margin-top:4px; }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:end; }
.row > * { flex:1 1 140px; min-width:0; }
.row > button { flex:0 0 auto; width:auto; }
.row > #fromText { flex:1 1 0; }
button { cursor:pointer; margin-top:10px; background:#eef2f5; touch-action:manipulation; }
button:disabled { cursor:not-allowed; opacity:.5; }
button.primary { background:var(--accent); color:#fff; border-color:var(--accent); font-weight:600; font-size:17px; min-height:52px; }
.hint { color:var(--muted); font-size:14px; margin:6px 0 0; }
.small { font-size:12px; margin-top:14px; }
.error { color:#a4161a; background:#fdecec; padding:10px 12px; border-radius:10px; }

/* Verkehrsmittel als drei große Schaltflächen */
.modes { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; margin-bottom:6px; }
.modes label { margin:0; min-height:var(--tap); display:flex; align-items:center; justify-content:center; gap:6px; border:1px solid var(--line); border-radius:10px; color:var(--ink); font-size:16px; cursor:pointer; }
.modes input { width:auto; min-height:0; accent-color:var(--ink); }
.modes label:has(input:checked) { background:var(--ink); color:#fff; border-color:var(--ink); font-weight:600; }

/* ---------- Verbindungen / Routen ---------- */
#connections h3, #connectionsBack h3 { font-size:15px; margin:16px 0 0; }
.conn { display:flex; gap:10px; padding:12px; border:1px solid var(--line); border-radius:10px; margin-top:8px; cursor:pointer; color:var(--ink); font-size:15px; }
.conn input { width:20px; height:20px; min-height:0; margin:2px 0 0; flex:none; accent-color:var(--sel); }
.conn:has(input:checked) { border-color:var(--sel); background:#eef4ff; }
.conn > span { flex:1; min-width:0; }
.conn small { color:var(--muted); display:block; overflow-wrap:anywhere; }
.conn small.warn { color:#b54708; } .conn small.ok { color:var(--accent); }
.pager { margin-top:8px; background:#fff; color:var(--sel); border-style:dashed; }
.legs { display:none; list-style:none; margin:10px 0 2px; padding:0 0 0 12px; border-left:3px solid var(--sel); font-size:14px; }
.conn:has(input:checked) .legs { display:block; }
.legs li { margin-bottom:8px; }
.legs .t { font-variant-numeric:tabular-nums; font-weight:600; }
.legs em { font-style:normal; color:var(--muted); }
.legs .ride { color:var(--muted); padding:2px 0 2px 10px; }
.legs .ride strong { color:var(--ink); }
.legs .cap { color:var(--muted); padding:0 0 2px 10px; font-size:13px; }
.legs .cap.full { color:#b42318; font-weight:600; }
.legs .change { color:var(--muted); background:#f1f4f7; border-radius:6px; padding:4px 8px; margin-left:-6px; }
.legs .change.tight { color:#b54708; background:#fff4e5; }

/* ---------- Fortschritt ---------- */
progress { width:100%; height:16px; margin-top:12px; accent-color:var(--accent); }
details summary { min-height:36px; display:flex; align-items:center; cursor:pointer; color:var(--muted); font-size:14px; }
#log { font-size:13px; color:var(--muted); max-height:180px; overflow:auto; padding-left:22px; margin:0; }

/* ---------- Ergebnis: Reiter, Schalter, Karte, Legende ---------- */
.tabs { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin-bottom:10px; }
.tabs button { margin:0; background:#fff; }
.tabs button.on { background:var(--ink); color:#fff; border-color:var(--ink); font-weight:600; }
.switch { display:flex; gap:10px; align-items:center; min-height:var(--tap); margin:0 0 8px; color:var(--ink); font-size:14px; cursor:pointer; }
.switch input { width:22px; height:22px; min-height:0; flex:none; accent-color:var(--ink); }
#map { height:clamp(300px, 56vh, 640px); border-radius:10px; border:1px solid var(--line); }
@media (min-width:900px) { #map { height:clamp(420px, 60vh, 720px); } }
.pin { width:18px; height:18px; border-radius:50%; border:3px solid #fff; box-shadow:0 0 0 1px #0006; cursor:pointer; }
.pin.active { width:28px; height:28px; border-width:4px; box-shadow:0 0 0 2px var(--ink), 0 0 0 10px #ffd60a88; }
.legend { display:flex; gap:10px; align-items:center; justify-content:space-between; flex-wrap:wrap; font-size:14px; line-height:1.9; padding:8px 10px; margin-top:8px; background:#f7fafc; border:1px solid var(--line); border-radius:10px; }
.legend > span { flex:1 1 200px; min-width:0; }
.legend button { width:auto; margin:0; min-height:40px; padding:6px 12px; font-size:14px; }
.legend .sw { display:inline-block; width:22px; height:6px; border-radius:3px; vertical-align:middle; margin:0 4px 0 10px; }
.legend .sw:first-child { margin-left:0; }
.legend .sw.dot { width:12px; height:12px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 1px #0006; }
.legend .sw.dash { background:repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 9px) !important; }
.dot { display:inline-block; width:13px; height:13px; border-radius:50%; margin-right:6px; vertical-align:-1px; border:1px solid #0003; flex:none; }

/* ---------- Begegnungen ---------- */
#summary { margin-top:10px; }
#encounters { list-style:none; padding:0; margin:10px 0 0; }
#encounters li { display:grid; grid-template-columns:1fr; gap:2px; padding:12px; border:1px solid var(--line); border-radius:10px; margin-bottom:8px; cursor:pointer; }
#encounters li:hover { background:#f7fafc; }
#encounters li.active { border-color:var(--ink); background:#fffbe6; box-shadow:inset 4px 0 0 var(--mark); }
#encounters time { font-variant-numeric:tabular-nums; font-weight:700; white-space:nowrap; }
#encounters small { color:var(--muted); display:block; margin-top:2px; }
@media (min-width:560px) { #encounters li { grid-template-columns:auto 1fr; gap:4px 12px; } }
/* Rot ist der eigenen Route vorbehalten, deshalb sind Marken und Status neutral gehalten */
.tag { display:inline-block; font-size:12px; padding:2px 8px; border-radius:999px; color:#fff; margin-right:6px; }
.same_train, .same_road { background:#17212b; } .station { background:#475467; } .crossing { background:#5d6b78; }

/* ---------- Spiele am selben Tag ---------- */
#gamesBox h3 { font-size:16px; margin:20px 0 0; }
.tablewrap { margin-top:8px; }
table { width:100%; border-collapse:collapse; font-size:14px; }
th { text-align:left; color:var(--muted); font-weight:600; border-bottom:1px solid var(--line); padding:6px 8px; }
td { padding:8px; border-bottom:1px solid var(--line); vertical-align:top; }
td:first-child { white-space:nowrap; font-variant-numeric:tabular-nums; }
.chip { display:inline-block; font-size:12px; padding:2px 8px; border-radius:999px; color:#fff; background:#8793a0; margin-right:4px; white-space:nowrap; }
.st-meet .chip { background:#17212b; } .st-time .chip { background:#b54708; } .st-own .chip { background:var(--mine); }
.st-far td, .st-unknown td { color:var(--muted); }
#games tr.clickable { cursor:pointer; }
#games tr.clickable:hover td { background:#f7fafc; }
#games tr.picked td { background:#fffbe6; color:var(--ink); }
#games tr.picked td:first-child { box-shadow:inset 4px 0 0 var(--mark); }
.rts { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; align-items:center; }
.rt { width:auto; margin:0; min-height:38px; padding:6px 12px; font-size:13px; border-radius:999px; background:#fff; color:var(--ink); white-space:nowrap; }
.rt.alt { border-style:dashed; color:var(--muted); }
.rt.on { background:var(--ink); color:#fff; border-color:var(--ink); border-style:solid; }
.dirlabel { font-size:12px; color:var(--muted); min-width:34px; }
.manual #encounters, .manual #summary, .manual #games .st { display:none; }

/* Auf dem Handy wird aus jeder Tabellenzeile eine Karte */
@media (max-width:699px) {
  #games, #games tr, #games td { display:block; }
  table thead { display:none; }
  #games tr { border:1px solid var(--line); border-radius:10px; padding:10px 12px; margin-bottom:8px; }
  #games td { border:0; padding:0; }
  #games td:nth-child(1), #games td:nth-child(2) { display:inline; color:var(--muted); font-size:13px; }
  #games td:nth-child(1)::after { content:" Uhr · "; }
  #games td:nth-child(3) { margin:2px 0 6px; font-size:15px; }
  #games tr.picked { background:#fffbe6; border-color:var(--ink); box-shadow:inset 4px 0 0 var(--mark); }
  #games tr.picked td { background:none; box-shadow:none; }
  #games tr.clickable:hover td { background:none; }
  .rt { min-height:42px; padding:8px 14px; font-size:14px; }
}

/* Genaue Verbindung einer angeklickten Route in der Spieleliste */
.rdetail:not(:empty) { margin-top:10px; padding-top:8px; border-top:1px dashed var(--line); }
.rdetail .rhead { font-size:14px; margin-top:6px; }
.rdetail .legs { display:block; margin:6px 0 10px; }
.rdetail .hint { margin:2px 0 8px; }
.rt { white-space:normal; text-align:left; }

/* Eingeklappte Verbindungen bei Spielen, die ganz woanders liegen */
.rtfold { margin-top:6px; }
.rtfold summary { min-height:40px; color:var(--sel); font-size:14px; }


#usage.over { color:#b54708; font-weight:600; }
.conn small.traffic { color:var(--ink); }

/* ---------- Anmeldung und Adminbereich ---------- */
header .account { display:flex; align-items:center; gap:8px; margin-left:auto; font-size:13px; color:#c9d3db; min-width:0; }
header .account span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:14ch; }
header .account a, header .account button { display:inline-flex; align-items:center; color:#fff; background:none; text-decoration:none; white-space:nowrap; font-size:14px; padding:0 14px; margin:0; min-height:40px; width:auto; border:1px solid #ffffff55; border-radius:999px; touch-action:manipulation; }
header .account a { background:#ffffff1f; font-weight:600; }
/* Handy: Kopfzeile in zwei Reihen. Oben Titel und Konto, darunter die Sprungmarken über die volle Breite. */
@media (max-width:899px) {
  header { flex-wrap:wrap; row-gap:8px; }
  header h1 { font-size:17px; }
  header .version { display:none; }
  header .account { order:1; }
  header nav { order:2; flex:1 0 100%; margin-left:0; }
  header nav a { flex:1; text-align:center; padding:9px 12px; }
  .panel, .results { scroll-margin-top:112px; }
}
@media (max-width:420px) { header .account span { display:none; } }
@media (min-width:900px) { header nav + .account { margin-left:10px; } }
main.narrow { display:block; max-width:420px; margin:24px auto; padding:0 12px; }
main.narrow.wide { max-width:760px; }
main.narrow .panel { margin-bottom:16px; }
.addrow { display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; }
.addrow > div { flex:1 1 160px; }
.addrow button { width:auto; margin-top:0; padding:0 22px; }
.credentials { margin-top:14px; padding:12px; border:2px solid var(--accent); border-radius:10px; background:#f3f8fc; }
.credentials pre { margin:8px 0; padding:10px; background:#fff; border:1px solid #d5dde3; border-radius:8px; font-size:15px; white-space:pre-wrap; word-break:break-all; user-select:all; }
.users .user { display:flex; gap:10px; align-items:center; justify-content:space-between; flex-wrap:wrap; padding:12px 0; border-top:1px solid #e3e8ec; }
.users .user:first-child { border-top:0; }
.users .user.locked { background:#fff5f5; }
.users small { display:block; color:#66757f; margin-top:3px; }
.users .acts { display:flex; gap:6px; flex-wrap:wrap; }
.users .acts button { width:auto; margin:0; padding:8px 12px; font-size:14px; min-height:40px; }
.users .tag { font-size:12px; padding:2px 8px; border-radius:999px; background:#e8edf1; margin-left:6px; }
.users .tag.bad { background:#c62828; color:#fff; }
button.danger { color:#b71c1c; border-color:#e5b5b5; background:#fff; }
main.narrow.login { margin-top:max(24px, 18vh); }

/* Auswahlfeld mit umbrochenem Text: die echte Liste liegt unsichtbar darüber */
.wrapselect { position:relative; display:flex; align-items:center; min-height:var(--tap); padding:10px 34px 10px 12px; border:1px solid var(--line); border-radius:10px; background:#fff; }
.wrapselect::after { content:""; position:absolute; right:14px; top:50%; width:7px; height:7px; border-right:2px solid var(--ink); border-bottom:2px solid var(--ink); transform:translateY(-70%) rotate(45deg); pointer-events:none; }
.wrapselect span { overflow-wrap:anywhere; }
.wrapselect select { position:absolute; inset:0; width:100%; height:100%; min-height:0; opacity:0; cursor:pointer; }
.wrapselect:focus-within { outline:2px solid var(--accent); outline-offset:1px; }
.wrapselect.disabled { opacity:.55; }
.wrapselect.disabled select { cursor:not-allowed; }
.users .who { flex:1 1 280px; min-width:0; }
.users table.usage { margin-top:8px; border-collapse:collapse; font-size:13px; width:100%; max-width:420px; }
.users table.usage th, .users table.usage td { text-align:right; padding:3px 0 3px 12px; border-top:1px solid #edf0f3; font-weight:400; }
.users table.usage th { color:#66757f; border-top:0; }
.users table.usage th:first-child, .users table.usage td:first-child { text-align:left; padding-left:0; }
.users .tag { color:var(--ink); }
.users table.usage td:first-child { white-space:normal; }
.users table.usage td { border-bottom:0; font-variant-numeric:tabular-nums; }
