:root {
  --page: #f3f5f8;
  --card: #ffffff;
  --card-2: #f7f8fa;
  --ink: #11161d;
  --soft: #3b4350;
  --dim: #636c79;
  --edge: rgba(17, 22, 29, 0.1);
  --track: rgba(17, 22, 29, 0.16);
  --idle: #d5dae1;
  --hatch: rgba(17, 22, 29, 0.12);
  --shadow: 0 12px 32px rgba(17, 22, 29, 0.14);

  --operational: #06c652;
  --degraded: #fbbf24;
  --partial: #fb8f24;
  --major: #ff2b3c;
  --info: #2878e1;

  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d1117;
    --card: #161b22;
    --card-2: #1b2129;
    --ink: #f5f7fa;
    --soft: #c9d1d9;
    --dim: #8b949e;
    --edge: rgba(240, 246, 252, 0.1);
    --track: rgba(240, 246, 252, 0.18);
    --idle: #353c46;
    --hatch: rgba(240, 246, 252, 0.1);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --page: #0d1117;
  --card: #161b22;
  --card-2: #1b2129;
  --ink: #f5f7fa;
  --soft: #c9d1d9;
  --dim: #8b949e;
  --edge: rgba(240, 246, 252, 0.1);
  --track: rgba(240, 246, 252, 0.18);
  --idle: #353c46;
  --hatch: rgba(240, 246, 252, 0.1);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 6px; }

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

[data-state="operational"] { --state: var(--operational); }
[data-state="degraded"] { --state: var(--degraded); }
[data-state="partial"] { --state: var(--partial); }
[data-state="major"] { --state: var(--major); }
[data-state="idle"] { --state: var(--idle); }
[data-state="nodata"] { --state: var(--idle); }
[data-state="pending"] { --state: var(--info); }

/* Header, with the system map drawing itself behind it */

.masthead {
  position: relative;
  overflow: hidden;
  padding: 20px 0 28px;
}

.status-lines {
  position: absolute;
  opacity: 0.2;
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
}

.status-lines .transit-station { fill: var(--page); }
.status-lines .transit-station.is-transfer { stroke: var(--ink); }
.status-lines .transit-station.is-alert { animation: station-pulse 1.4s ease-in-out infinite; }

@keyframes station-pulse {
  50% { stroke-width: 10; }
}

.masthead .wrap { position: relative; z-index: 1; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand img { border-radius: 8px; }

.switch {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  border: 1px solid var(--edge);
  backdrop-filter: blur(8px);
}

.switch a, .switch span {
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--dim);
  text-decoration: none;
}

.switch a:hover { color: var(--ink); }
.switch a[aria-current="page"] { background: var(--ink); color: var(--page); }
.switch .is-off { opacity: 0.45; cursor: default; }

.banner {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--state) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--state) 40%, transparent);
  box-shadow: var(--shadow);
}

.roundel {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--state);
  box-shadow: inset 0 0 0 9px var(--state), inset 0 0 0 14px var(--card);
}

.banner:not([data-state="operational"]):not([data-state="nodata"]) .roundel::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--state);
  animation: ring 1.8s ease-out infinite;
}

@keyframes ring {
  from { transform: scale(0.8); opacity: 0.9; }
  to { transform: scale(1.35); opacity: 0; }
}

.banner h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 3.2vw, 28px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-wrap: balance;
}

.banner-lead { margin: 8px 0 0; font-size: 15px; }
.banner-items { margin: 6px 0 0; padding-left: 18px; font-size: 15px; line-height: 1.45; }
.banner-items li + li { margin-top: 2px; }
.updated { margin: 4px 0 0; color: var(--dim); font-size: 14px; }

.unreachable {
  margin: 12px 0 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--major) 14%, var(--card));
  border: 1px solid color-mix(in srgb, var(--major) 45%, transparent);
  font-weight: 600;
  font-size: 14px;
}

/* Panels and groups */

.board { padding-bottom: 64px; }

.panel {
  margin-top: 28px;
  border: 1px solid var(--edge);
  border-radius: 18px;
  background: var(--card);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 18px 20px 4px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sub { margin: 2px 0 0; color: var(--dim); font-size: 14px; }

.group + .group { border-top: 1px solid var(--edge); }

.group-head {
  display: grid;
  grid-template-columns: 30px 1fr auto 18px;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.group-head:hover { background: var(--card-2); }

.bullet {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--state);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
}

[data-state="degraded"] > .group-head .bullet,
[data-state="idle"] > .group-head .bullet,
[data-state="nodata"] > .group-head .bullet { color: #11161d; }

.group-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; }

.group-sum { color: var(--dim); font-size: 14px; text-align: right; }

.chev {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--dim);
  border-bottom: 2px solid var(--dim);
  transform: rotate(45deg) translateY(-3px);
  transition: transform 0.2s ease;
}

.group.is-open .chev { transform: rotate(-135deg) translate(-2px, -2px); }

.group-strip { padding: 0 20px 18px 64px; }
.group.is-open .group-strip { display: none; }

.rows {
  position: relative;
  display: none;
  padding: 0 20px 8px 64px;
}

.group.is-open .rows,
.group.has-bad .rows { display: block; }
.group:not(.is-open) .row:not(.is-bad) { display: none; }
.group:not(.is-open) .row + .row { border-top: 0; }
.group:not(.is-open) .rows::before { top: -8px; }

.rows::before {
  content: "";
  position: absolute;
  left: 33px;
  top: -18px;
  bottom: 30px;
  width: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--state) 55%, var(--track));
}

.row { position: relative; padding: 16px 0 20px; }
.row + .row { border-top: 1px solid var(--edge); }

.stop {
  position: absolute;
  left: -29px;
  transform: translateX(-50%);
  top: 21px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--card);
  border: 3px solid color-mix(in srgb, var(--ink) 45%, transparent);
}

.row.is-bad .stop {
  top: 18px;
  width: 20px;
  height: 20px;
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 3px var(--state);
}

.row-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 12px;
}

.row-name {
  padding: 0;
  border: 0;
  background: none;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
}

button.row-name { cursor: pointer; }
button.row-name:hover { text-decoration: underline; text-underline-offset: 3px; }

.tag {
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--edge);
  color: var(--dim);
  font-size: 12px;
}

.row-meta { margin-left: auto; color: var(--dim); font-size: 14px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 8px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--state) 14%, transparent);
  font-size: 14px;
  font-weight: 500;
  cursor: default;
}

.chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--state);
}

.chip[data-state="idle"], .chip[data-state="nodata"] { background: none; color: var(--dim); padding-left: 0; }
.chip[data-card] { cursor: pointer; }

/* Day pills */

.pills {
  position: relative;
  display: flex;
  gap: 3px;
  height: 32px;
  padding-bottom: 0;
  margin-bottom: 4px;
}

.pill {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  border-radius: 4px;
  background: var(--state);
  overflow: hidden;
  cursor: pointer;
}

.pill[data-state="idle"] { background: var(--idle); }

.pill[data-state="nodata"] {
  background: var(--hatch);
}

.pill.has-segments { background: var(--operational); }
.pill i { position: absolute; left: 0; right: 0; min-height: 4px; background: var(--state); }
.pill i.later { min-height: 0; background: var(--idle); }

.pill:hover { filter: brightness(1.12); }

.axis {
  display: flex;
  justify-content: space-between;
  padding: 2px 20px 14px 64px;
  color: var(--dim);
  font-size: 13px;
}

.axis .phone { display: none; }

/* Sources */

.source { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; }
.source .row-name { grid-column: 1; }
.source-when { color: var(--dim); font-size: 14px; text-align: right; }
.source-err { grid-column: 1 / -1; color: var(--dim); font-size: 14px; }
.source.is-bad .source-err { color: var(--ink); }
.sources .row { padding: 14px 0; }
.sources .stop { top: 19px; }
.sources .row.is-bad .stop { top: 16px; }

/* One agency's week */

.week { margin: 6px 0 4px; }
.week-day { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; margin-bottom: 4px; }
.week-day span { color: var(--dim); font-size: 13px; }
.week-day svg { width: 100%; height: 16px; border-radius: 3px; background: repeating-linear-gradient(135deg, var(--hatch) 0 3px, transparent 3px 6px); }
.week-hours { display: grid; grid-template-columns: 64px repeat(4, 1fr); gap: 0 10px; color: var(--dim); font-size: 12px; margin-bottom: 4px; }
.week-note { color: var(--dim); font-size: 14px; margin: 4px 0; }
.week rect.s-operational { fill: var(--operational); }
.week rect.s-degraded { fill: var(--degraded); }
.week rect.s-partial { fill: var(--partial); }
.week rect.s-major { fill: var(--major); }
.week rect.s-idle { fill: var(--idle); }

/* Accuracy */

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--edge);
}

.seg button {
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.seg button[aria-pressed="true"] { background: var(--ink); color: var(--page); }

.table-wrap { overflow-x: auto; padding: 8px 20px 4px; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 11px 8px; text-align: right; border-bottom: 1px solid var(--edge); white-space: nowrap; }
th:first-child { text-align: left; white-space: normal; }
thead th { color: var(--dim); font-size: 13px; font-weight: 600; }
thead tr:first-child th { border-bottom: 0; padding-bottom: 4px; }
thead th[colspan] { text-align: center; box-shadow: inset 0 -1px 0 var(--edge); }
tbody th { font-weight: 500; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
td.is-best { color: var(--operational); font-weight: 600; }
td.is-none { color: var(--dim); }

.graded { margin: 0; padding: 4px 20px 16px; color: var(--dim); font-size: 13px; }

.empty { padding: 4px 20px 20px; color: var(--dim); margin: 0; }

/* Hover card */

.pop {
  position: fixed;
  z-index: 50;
  width: min(320px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow);
  font-size: 14px;
  pointer-events: none;
}

.pop.is-pinned { pointer-events: auto; }

.pop-date { margin: 0 0 8px; color: var(--dim); font-size: 13px; }
.pop-item + .pop-item { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--edge); }
.pop-label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; }
.pop-label::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--state); flex: none; }
.pop-part { margin: 2px 0 0 18px; color: var(--dim); }
.pop-text { margin: 6px 0 0 18px; }
.pop-when { margin: 4px 0 0 18px; color: var(--dim); font-size: 13px; }
.pop .tag { display: inline-block; margin: 6px 0 0 18px; }

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .masthead { padding-top: 16px; }
  .top { margin-bottom: 20px; }
  .brand span { display: none; }
  .switch a, .switch span { padding: 6px 12px; }
  .banner { padding: 18px; gap: 14px; }
  .roundel { width: 36px; height: 36px; box-shadow: inset 0 0 0 7px var(--state), inset 0 0 0 11px var(--card); }
  .group-head { padding: 16px; gap: 2px 12px; grid-template-columns: 30px 1fr 18px; }
  .group-head .bullet { grid-row: 1 / span 2; }
  .group-sum { grid-column: 2; grid-row: 2; text-align: left; }
  .chev { grid-column: 3; grid-row: 1 / span 2; }
  .source { grid-template-columns: 1fr; }
  .source-when { text-align: left; }
  .group-strip { padding: 0 16px 16px 58px; }
  .rows { padding: 0 16px 6px 58px; }
  .rows::before { left: 29px; }
  .stop { left: -27px; }
  .axis { padding: 2px 16px 12px 58px; }
  .axis .wide { display: none; }
  .axis .phone { display: inline; }
  .pills .pill:nth-child(-n+60) { display: none; }
  .row-meta { margin-left: 0; }
  .panel-head { padding: 16px 16px 4px; }
  .table-wrap { padding: 8px 12px 4px; }
  th, td { padding: 10px 6px; font-size: 14px; }
  .graded, .empty { padding-left: 16px; padding-right: 16px; }
  .week-day { grid-template-columns: 48px 1fr; }
  .week-hours { grid-template-columns: 48px repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .status-lines .transit-station.is-alert { animation: none; stroke-width: 7; }
  .banner .roundel::after { animation: none !important; opacity: 0.5; transform: scale(1.15); }
  .chev { transition: none; }
}
