*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f1a;
  --fg:        #ffffff;
  --in:        #4ecdc4;
  --out:       #a29bfe;
  --express:   #ff6b6b;
  --soon:      #ffd93d;
  --late:      #ff9f43;
  --dim:       #555555;
  --stale:     #e74c3c;
}

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 16px) 20px env(safe-area-inset-bottom, 16px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 12px;
}

#title {
  font-size: 1.5rem;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#badge {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--dim);
  letter-spacing: 0.05em;
}

#num-toggle {
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--dim);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 7px;
  transition: all 0.15s;
  line-height: 1.4;
}
#num-toggle.active {
  color: var(--fg);
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.07);
}

#train-list {
  flex: 1;
}

.train-row {
  display: flex;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  gap: 8px;
}

.rt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255,255,255,0.12);
}
.rt-dot.live { background: #26de81; }

.express-marker {
  color: var(--express);
  font-weight: 700;
  font-size: 1rem;
  width: 14px;
  flex-shrink: 0;
}

.train-time {
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-size: 1.1rem;
  min-width: 62px;
}

.train-time.live { color: var(--fg); }
.train-time.express { color: var(--express); }

.delta {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  min-width: 32px;
  text-align: center;
}
.delta.early { background: rgba(255, 211, 61, 0.2); color: var(--soon); }
.delta.late  { background: rgba(255, 159, 67, 0.2); color: var(--late); }

.train-num {
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.65rem;
  color: var(--dim);
  min-width: 34px;
  display: none;
}
body.show-numbers .train-num { display: inline; }

.dir-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.dir-label.in  { color: var(--in); }
.dir-label.out { color: var(--out); }

.countdown {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--dim);
}
.countdown.soon { color: var(--soon); }

.no-trains {
  color: var(--dim);
  font-size: 0.95rem;
  padding: 24px 0;
  text-align: center;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 4px;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin-top: 8px;
}

#footer-status {
  font-size: 0.72rem;
  color: var(--dim);
}
#footer-status.stale { color: var(--stale); }

#refresh-btn {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s;
}
#refresh-btn:active { color: var(--fg); }
