/* Black & white, X-style: system type, near-black / near-white text.
   Dark is the default; light only when the rider switches it on. */
:root {
  --bg: #000000;
  --panel: #000000;
  --text: #e7e9ea;
  --muted: #71767b;
  --line: #2f3336;
  --soft: #16181c;
  --ink: #eff3f4;      /* primary buttons, selected states */
  --on-ink: #0f1419;
  --ok: #00ba7c;
  --warn: #ffad1f;
  --bad: #f4212e;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.6), 0 0 0 1px #2f3336;
  --radius: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --panel: #ffffff;
  --text: #0f1419;
  --muted: #536471;
  --line: #eff3f4;
  --soft: #f7f9f9;
  --ink: #0f1419;
  --on-ink: #ffffff;
  --ok: #00875a;
  --warn: #b26b00;
  --bad: #f4212e;
  --shadow: 0 2px 14px rgba(15, 20, 25, 0.12), 0 0 0 1px rgba(15, 20, 25, 0.04);
  color-scheme: light;
}

/* dark map to match (the standard map tiles are light) */
:root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.92); }
:root:not([data-theme="light"]) .leaflet-container { background: #111; }
.leaflet-control-attribution { font-size: 10px; }

/* header logo follows the theme */
.brand .logo-light { display: none; }
:root[data-theme="light"] .brand .logo-light { display: block; }
:root[data-theme="light"] .brand .logo-dark { display: none; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* loading screen */
.splash {
  position: fixed; inset: 0; z-index: 1000; background: #000; color: #fff;
  display: grid; place-items: center; padding: 24px;
  transition: opacity .6s ease, visibility .6s;
}
.splash.done { opacity: 0; visibility: hidden; pointer-events: none; }
.splash.done .splash-inner { transform: scale(1.04); }
.splash-inner {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  width: min(420px, 100%); transition: transform .6s ease;
}
.splash-mark { width: 132px; height: 132px; margin-bottom: 18px; }
.splash-headline {
  width: min(320px, 82vw); height: auto; margin-bottom: 18px;
  opacity: 0; transform: translateY(10px); animation: splash-in .7s cubic-bezier(.2, .7, .2, 1) .85s forwards;
}
.splash-line {
  margin: 0; font-size: .82rem; letter-spacing: .08em; color: #b9b9b9; line-height: 1.9;
  opacity: 0; transform: translateY(8px); animation: splash-in .6s ease forwards;
}
.splash-line.l1 { animation-delay: 1.25s; }
.splash-line.l2 { animation-delay: 1.5s; }
.splash-bar {
  margin-top: 30px; width: 120px; height: 2px; background: rgba(255, 255, 255, .14); border-radius: 2px; overflow: hidden;
  opacity: 0; animation: splash-in .5s ease .3s forwards;
}
.splash-bar span {
  display: block; height: 100%; width: 0; background: #fff; border-radius: 2px;
  transition: width .5s cubic-bezier(.3, .6, .3, 1);
}
@keyframes splash-in { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .splash-headline, .splash-line, .splash-bar { animation: none; opacity: 1; transform: none; }
  .splash.done .splash-inner { transform: none; }
}

#map { position: fixed; inset: 0; z-index: 0; }
.leaflet-container { background: var(--soft); }

/* top bar: a floating rounded pill, same shape as the search bar */
.top {
  position: fixed; z-index: 12; left: 12px; right: 12px; max-width: 560px; margin: 0 auto;
  top: calc(env(safe-area-inset-top) + 10px); height: 52px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 7px 0 18px; border-radius: 999px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow);
}
.brand { margin: 0; display: flex; align-items: center; }
.brand img { height: 22px; width: auto; display: block; }
.mode { display: flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.mode button {
  border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 700; transition: background .2s, color .2s;
}
.mode button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }

/* search */
.search {
  position: fixed; z-index: 11; left: 12px; right: 12px;
  top: calc(env(safe-area-inset-top) + 72px);
  display: flex; gap: 8px; max-width: 560px; margin: 0 auto;
}
.search input {
  flex: 1; min-width: 0; height: 48px; padding: 0 20px; border-radius: 999px; border: 0;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow); font-size: 16px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: 2px solid var(--ink); outline-offset: 0; }
.search > button {
  border: 0; border-radius: 999px; height: 48px; padding: 0 20px;
  background: var(--ink); color: var(--on-ink); font-weight: 700; box-shadow: var(--shadow);
}
/* Coppin State shuttle button + panel (Coppin blue & gold) */
.search > .csu-btn {
  background: #0b3d91; color: #ffc72c; padding: 0 14px; letter-spacing: 0.04em; font-weight: 800;
}
.csu-frame-wrap { display: flex; flex-direction: column; }
.csu-frame {
  width: 100%; height: 52vh; border: 1px solid var(--line); border-radius: 16px; background: #fff;
}
.csu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.csu-tag { background: #0b3d91; color: #ffc72c; border-radius: 999px; padding: 3px 10px; font-weight: 800; font-size: 0.75rem; }
.code-input {
  width: 100%; height: 48px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--soft); color: var(--text); font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase;
}
.results {
  position: absolute; top: 56px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); max-height: 50vh; overflow: auto;
}
.results li button { width: 100%; text-align: left; border: 0; background: none; padding: 12px; border-radius: 14px; display: flex; gap: 8px; }
.results li button:hover, .results li button:focus-visible { background: var(--soft); }
.results small { color: var(--muted); }

/* chips */
.chips {
  position: fixed; z-index: 9; left: 12px; right: 12px; top: calc(env(safe-area-inset-top) + 130px);
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; max-width: 560px; margin: 0 auto;
}
.chip {
  flex: none; border: 0; background: var(--panel); color: var(--text); border-radius: 999px;
  padding: 6px 12px; font-size: 0.8rem; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap;
}
.chip.warn::before { content: "●"; color: var(--warn); margin-right: 5px; font-size: 0.7em; vertical-align: 1px; }
.offline {
  position: fixed; z-index: 13; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 66px);
  background: var(--ink); color: var(--on-ink); border-radius: 999px; font-size: 0.8rem; font-weight: 600; padding: 5px 14px;
  white-space: nowrap;
}

/* bottom sheet */
.sheet {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto; height: 52vh;
  background: var(--panel); border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column; transition: height 0.25s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.small { height: 22vh; }
.sheet.big { height: 86vh; }
.handle { border: 0; background: none; padding: 10px 0 6px; flex: none; }
.handle::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
#view { overflow-y: auto; padding: 0 16px 16px; flex: 1; overscroll-behavior: contain; }

h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; margin: 4px 0 2px; }
h3 { font-size: 1.05rem; font-weight: 800; margin: 18px 0 6px; color: var(--text); }
.sub { color: var(--muted); font-size: 0.85rem; margin: 0 0 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.back { border: 0; background: none; color: var(--muted); padding: 4px 0; font-size: 0.9rem; }

.btn { border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-weight: 700; background: var(--panel); color: var(--text); }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.dark { background: var(--panel); color: var(--text); border-color: var(--text); }
.btn.danger { border-color: var(--bad); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.card {
  border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 8px 0; background: var(--panel); color: var(--text);
  width: 100%; text-align: left; display: block;
}
button.card:hover, button.card:focus-visible { background: var(--soft); }

.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 26px; padding: 0 8px;
  border-radius: 7px; font-weight: 800; font-size: 0.8rem; flex: none;
}
.window { font-size: 1.15rem; font-weight: 800; }
.wait { color: var(--muted); font-size: 0.85rem; }
.live { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--ok); font-weight: 600; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
.sched { font-size: 0.75rem; color: var(--warn); font-weight: 600; }
@keyframes pulse { 50% { opacity: 0.3; } }
.factors { margin: 6px 0 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--muted); }
.factors li::before { content: "• "; }
.conf-high { color: var(--ok); }
.conf-medium { color: var(--warn); }
.conf-low { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.empty { text-align: center; color: var(--muted); padding: 20px 8px; }

.legs { list-style: none; padding: 0; margin: 8px 0; }
.legs li { padding: 8px 0 8px 18px; border-left: 3px solid var(--line); margin-left: 8px; position: relative; }
.legs li::before { content: ""; position: absolute; left: -8px; top: 12px; width: 13px; height: 13px; border-radius: 50%; background: var(--panel); border: 3px solid var(--muted); }

/* chat */
.chat { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.msg { padding: 8px 10px; border-radius: 12px; background: var(--soft); max-width: 88%; }
.msg { border-radius: 18px; }
.msg.rider { background: var(--ink); color: var(--on-ink); align-self: flex-end; }
.msg.rider header, .msg.rider .flag { color: color-mix(in srgb, var(--on-ink) 70%, transparent); }
.msg.mine { outline: 2px solid var(--muted); outline-offset: 1px; }
.msg header { font-size: 0.72rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.msg p { margin: 2px 0 0; word-wrap: break-word; }
.msg .flag { border: 0; background: none; color: var(--muted); font-size: 0.72rem; padding: 0; margin-left: auto; }
.tag { font-size: 0.7rem; padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; }
.composer { display: flex; gap: 6px; position: sticky; bottom: 0; background: var(--panel); padding: 8px 0; }
.composer input { flex: 1; min-width: 0; padding: 11px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--soft); color: var(--text); font-size: 16px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tags button { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 5px 12px; font-size: 0.8rem; font-weight: 600; }
.tags button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.error { color: var(--bad); font-size: 0.85rem; margin: 4px 0; }
.note { font-size: 0.75rem; color: var(--muted); margin: 6px 0; }

.prompt { border: 0; border-radius: 18px; padding: 20px; max-width: 340px; width: calc(100% - 32px); box-shadow: var(--shadow); background: var(--panel); color: var(--text); }
.prompt::backdrop { background: rgba(10, 12, 30, 0.45); }
.prompt p { font-size: 1.05rem; font-weight: 600; margin: 0 0 14px; }
.prompt-actions { display: flex; gap: 8px; justify-content: flex-end; }

.credits { font-size: 0.75rem; color: var(--muted); border-top: 1px solid var(--line); margin-top: 18px; padding-top: 10px; }
.credits a { color: inherit; }

.you { width: 16px; height: 16px; border-radius: 50%; background: #2f7cf6; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47, 124, 246, 0.25); }
