:root {
  --bg-main: #111;
  --bg-surface: #1a1a1a;
  --bg-hover: #262626;
  --bg-chain: #0a0a0a;
  --text-main: #eee;
  --text-muted: #888;
  --text-subtle: #999;
  --text-soft: #aaa;
  --border-main: #333;
  --border-soft: #2a2a2a;
  --line-accent: #0a5;
  --line-text: #041b12;
  --on-time: #5f5;
  --error: #f55;
  --link-hover: #5cf;
  --underline: #666;
  --header-bg:  #061030;
  --sbb-red:    #eb0000;
  --sbb-blue:   #2d327d;
  --sbb-orange: #E84E10;
  --sob-green:  #7BA55B;
  --sob-blue:   #1A527F;
  --board-bg:   #0a1a4a;
  --board-row:  #0d2060;
  --board-alt:  #0a1a4a;
  --board-head: #0d2060;
  --text-main:  #ffffff;
  --text-via:   #a0b8d8;
  --text-dim:   #6080a0;
  --night-gold: #d4af37;
  --border:     rgba(200,200,200,0.09);
  --header-bg:  #061030;
  --pifas-bg:   #ED702D;
  --pifas-searchbar: #d7d7d7;
  --pifas-timenav: #eef;
  --live-red:   #ff3b30;
  --plat-change:#fcbb00;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
	scrollbar-gutter: stable;
}
body {
  background: var(--bg-main);
  color: var(--text-main);
  margin: 0;
  padding: 8px 14px;
  font-family: "SBB Web", "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* HEADER */
#app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--header-bg);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: sticky;
    top: 0;
    z-index: 20;
    gap: 10px;
    flex-wrap: wrap;
}
#header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
#btn-home {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 5px 10px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
    transition: background 0.15s;
}
#btn-home:hover { background: rgba(255,255,255,0.22); }

#app-title,
#app-title a {
    color: white;
    font-size: 1.05em;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    text-decoration: none;
}
#header-center {
    flex: 1;
    text-align: center;
}
#live-clock {
    font-family: monospace;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--text-main);
}
#header-right {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.fav-btn {
    background: rgba(255,255,255,0.08);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.13);
    padding: 5px 13px;
    border-radius: 2px;
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.84em;
    letter-spacing: 0.02em;
    transition: background 0.15s;
    flex-shrink: 0;
}

h1 {
  font-size: clamp(1rem, 4vw, 1.3rem);
  margin: 0 0 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#search-box { position: relative; }

.time-picker-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.time-picker-row input[type="date"] {
  flex: 2;
}
.time-picker-row input[type="time"] {
  flex: 1;
}

input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  color: var(--text-main);
}
input:focus { outline: none; border-color: var(--line-accent); }

/* Icons in nativen Pickern für Dark Mode invertieren */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

#suggestions {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  position: absolute;
  left: 0; right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  z-index: 20;
  max-height: 55vh;
  overflow-y: auto;
}
#suggestions li {
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.95rem;
}
#suggestions li:last-child { border-bottom: none; }
#suggestions li:active, #suggestions li:hover { background: var(--bg-hover); }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
th { color: var(--text-muted); font-weight: normal; font-size: 0.75rem; }

.col-time { width: 55px; white-space: nowrap; }
.delay-badge {
    display: inline-block;
    font-size: 0.74em;
    color: var(--sbb-red);
    font-weight: 600;
    vertical-align: baseline;
}
.col-line {
	width: 70px;
	text-align: center;
	vertical-align: middle;
  text-overflow: ellipsis; }
.col-dest  { width: auto; white-space: normal; }
.col-platform {
	width: 90px;
	text-align: right;
	font-weight: 400;
	font-size: 1em;
	padding-right: 18px; }

.line-container {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #2d327d;
}

.mode-icon {
  width: 1.15rem;
  height: 1.15rem;
  color: var(--text-soft);
  flex-shrink: 0;
}

.line {
  font-weight: bold;
  color: white;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  display: inline-block;
  font-size: 0.85rem;
}
.tripnr { color: var(--text-subtle); font-size: 0.8rem; }
.delay { color: var(--error); font-weight: bold; }
.vbz-delay { color: var(--link-hover); font-weight: bold; }
.ontime { color: var(--on-time); }
.cancelled { color: var(--error); text-decoration: line-through; }

#status { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.6rem; text-align: left; }

tr.dep-row { cursor: pointer; min-height: 44px; }
tr.dep-row:active, tr.dep-row:hover { background: var(--bg-surface); }

tr.chain-row td { background: var(--bg-chain); padding: 0; }
.chain-wrap { padding: 0.5rem 0.4rem 0.8rem; }

.chain-header { color: var(--text-soft); font-size: 0.78rem; line-height: 1.4; margin-bottom: 0.4rem; }
.chain-header b { color: var(--text-main); }

.timeline { position: relative; padding-left: 0.9rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: 0.22rem; top: 0.5rem; bottom: 0.5rem;
  width: 2px; background: var(--border-soft);
}
.stop {
  position: relative;
  padding: 0.4rem 0 0.4rem 0.7rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 38px;
  align-items: flex-start;
}
.stop-dot {
  position: absolute;
  left: -0.68rem; top: 0.85rem;
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: var(--line-accent);
  box-shadow: 0 0 0 3px var(--bg-chain);
}
.stop.cancelled-stop .stop-dot { background: var(--error); }
.stop-name {
  font-size: 0.92rem;
  text-decoration: underline dotted var(--underline);
  text-underline-offset: 2px;
  cursor: pointer;
}
.stop-name.no-link { text-decoration: none; cursor: default; }
.stop-name:active, .stop-name:hover { color: var(--link-hover); }
.stop-times { color: var(--text-muted); font-size: 0.72rem; margin-top: 0.1rem; }
.stop-right { text-align: right; white-space: nowrap; font-size: 0.8rem; }
.stop-track { color: var(--text-muted); font-size: 0.7rem; margin-top: 0.1rem; }

.empty-hint, .error-hint {
  text-align: center; color: var(--text-muted); padding: 2rem 1rem; font-size: 0.9rem;
}
.error-hint { color: var(--error); }

@media (max-width: 360px) {
  th, td { font-size: 0.88rem; padding: 0.45rem 0.3rem; }
}
a {
  color: none;
  text-decoration: none;
}
.page-footer {
	text-decoration: none;
	padding: 8px 14px;
	margin-top: auto;
	border-top: 1px solid var(--border);
	background: var(--header-bg);
}

.page-footer a, a:hover, a:active {
	color: var(--sbb-red);
	text-decoration: none;
 }