:root {
  color-scheme: light;
  font-family: "Arial Narrow", "Helvetica Neue", sans-serif;
  background: #f3f4ef;
  color: #1b2524;
  --ink: #1b2524;
  --muted: #64716e;
  --line: #d7ddd7;
  --surface: #ffffff;
  --accent: #007a5e;
  --accent-dark: #005c47;
}

* {
  box-sizing: border-box;
}

body {
  width: 360px;
  min-height: 420px;
  max-height: 600px;
  margin: 0;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 18px 15px;
  background: var(--ink);
  color: #fff;
}

.eyebrow {
  margin: 0 0 3px;
  color: #a6d9c9;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 15px;
}

main {
  padding: 14px 16px 18px;
}

/* City switcher: a button in the top bar opens a menu under it. */
.city-button {
  display: grid;
  justify-items: end;
  gap: 1px;
  min-width: 52px;
  padding: 5px 9px;
  border: 1px solid #4b5a57;
  border-radius: 4px;
  background: transparent;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.city-button:hover,
.city-button[aria-expanded="true"] {
  border-color: #a6d9c9;
}

.city-button-label {
  color: #a6d9c9;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.city-button-name {
  font-size: 14px;
  font-weight: 700;
}

.city-menu {
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.city-menu[hidden] {
  display: none;
}

.city-menu-title {
  font-size: 14px;
}

.city-menu-note {
  margin: 3px 0 10px;
  color: var(--muted);
  font-size: 11px;
}

.city-options {
  display: grid;
  gap: 6px;
}

.city-option {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.city-option:hover {
  border-color: var(--accent);
}

.city-option[aria-current="true"] {
  border-color: var(--accent);
  background: #e8f2ed;
  color: var(--accent-dark);
}

.city-option[aria-current="true"]::after {
  content: " · current";
  color: var(--muted);
  font-weight: 400;
}

.city-confirm {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #e5c46a;
  border-radius: 3px;
  background: #fff8e6;
}

.city-confirm[hidden] {
  display: none;
}

.city-confirm p {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.4;
}

.city-confirm-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.city-confirm-actions .primary-button {
  width: auto;
  margin: 0;
  padding: 0 12px;
}

.transit-tabs {
  display: grid;
  grid-template-columns: repeat(var(--tab-count, 3), 1fr);
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #e5e9e2;
}

.transit-tab {
  min-height: 40px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.transit-tab[aria-selected="true"] {
  position: relative;
  top: 1px;
  border-color: var(--line);
  background: #f3f4ef;
  color: var(--accent-dark);
}

.transit-tab:focus-visible {
  outline-offset: -3px;
}

.transit-panel[hidden] {
  display: none;
}

/* Notices from the app itself (src/notices.js); styled apart from the agencies' alerts. */
.app-notices {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.app-notices[hidden] {
  display: none;
}

.app-notice {
  padding: 10px 12px;
  border-radius: 3px;
  background: #b3261e;
  color: #fff;
}

.app-notice-label {
  margin: 0 0 4px;
  color: #ffd9d4;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.app-notice-title {
  margin: 0;
  font-size: 13px;
}

.app-notice-message {
  margin: 4px 0 0;
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-line;
}

/* System-wide alerts at the top of a tab (PATH). */
.system-alerts {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 9px 10px;
  border: 1px solid #e5c46a;
  border-left: 3px solid #b7791f;
  border-radius: 3px;
  background: #fff8e6;
}

.system-alerts[hidden] {
  display: none;
}

.system-alerts[data-state="error"] {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.system-alerts-heading {
  margin: 0;
  color: #754b08;
  font-size: 12px;
}

.system-alerts-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.system-alerts-toggle .card-chevron {
  margin: 4px 4px 0;
  border-color: #8a6a2a;
}

.system-alerts.collapsed .card-chevron {
  margin-top: -3px;
}

.system-alerts-list {
  display: grid;
  gap: 6px;
}

.system-alerts.collapsed .system-alerts-list {
  display: none;
}

.system-alerts .service-alert + .service-alert {
  margin-top: 0;
}

.system-alerts .service-alert-label {
  display: inline;
}

.system-alerts .service-alert-header {
  display: block;
  margin: 2px 0 0 14px;
  color: #8a6a2a;
  font-weight: 400;
}

.selector {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.selector-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  cursor: pointer;
  list-style: none;
}

.selector-toggle::-webkit-details-marker {
  display: none;
}

.selector-title,
.selector-caption {
  display: block;
}

.selector-title {
  font-size: 15px;
  font-weight: 700;
}

.selector-caption {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.toggle-mark {
  display: grid;
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent-dark);
}

.toggle-mark::before {
  content: "+";
  font-size: 18px;
  line-height: 1;
}

.selector[open] .toggle-mark::before {
  content: "-";
}

.selector-body {
  display: grid;
  gap: 7px;
  padding-top: 8px;
}

label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.picker input,
#mode-input {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #bac4bd;
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

#mode-input:focus,
.picker input:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.picker {
  position: relative;
}

.picker-options {
  position: absolute;
  z-index: 2;
  top: calc(100% + 3px);
  right: 0;
  left: 0;
  max-height: 190px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  box-shadow: 0 5px 14px rgb(27 37 36 / 14%);
  list-style: none;
}

.picker-options[hidden] {
  display: none;
}

.picker-option {
  padding: 8px;
  border-radius: 2px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
}

.picker-option:hover,
.picker-option[aria-selected="true"] {
  background: #e8f2ed;
  color: var(--accent-dark);
}

.picker-empty {
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

button {
  font: inherit;
  cursor: pointer;
}

.primary-button {
  min-height: 35px;
  margin-top: 3px;
  border: 0;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.status,
.empty-state {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.status {
  min-height: 16px;
}

.selector + .status {
  margin-top: 6px;
}

.arrival-error,
.status[data-error="true"] {
  color: #a32929;
  font-weight: 700;
}

.tracked {
  padding-top: 13px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.text-button {
  padding: 3px 0 3px 8px;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.text-button:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.favorites {
  display: grid;
  gap: 8px;
}

.favorite {
  display: flex;
  flex-direction: column;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--route-color, var(--accent));
  border-radius: 3px;
  background: var(--surface);
}

.favorite.has-alert {
  border-color: #e5c46a;
  border-left-color: #b7791f;
  background: #fff8e6;
}

.favorite-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.route-badge {
  display: grid;
  flex: 0 0 auto;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  place-items: center;
  border-radius: 50%;
  background: var(--route-color, var(--accent));
  color: var(--route-text, #fff);
  font-size: 11px;
  font-weight: 700;
}

.station-name {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.card-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.card-title {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding-top: 3px;
}

.card-chevron {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin: 8px 4px 0;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-135deg);
}

.collapsed .card-chevron {
  margin-top: 5px;
  transform: rotate(45deg);
}

/* A collapsed card shows only its header, which then carries the next arrivals. */
.favorite.collapsed > :not(.favorite-header, .card-actions) {
  display: none;
}

.arrival-summary {
  display: none;
}

.collapsed .arrival-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.summary-time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
}

.summary-time[data-direction="N"] .arrival-direction {
  background: #126b8a;
}

.summary-time[data-direction="S"] .arrival-direction {
  background: #b25428;
}

.more-button {
  flex: 0 0 auto;
  width: 26px;
  height: 24px;
  margin: 0 -4px 0 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.more-button:hover,
.more-button[aria-expanded="true"] {
  background: #e8ece7;
  color: var(--ink);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0 32px;
}

.card-actions[hidden] {
  display: none;
}

.card-action {
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.card-action:hover:not(:disabled) {
  border-color: #bac4bd;
  background: #f3f4ef;
}

.card-action:disabled {
  cursor: default;
  opacity: 0.4;
}

.card-action.remove-button {
  margin-left: auto;
  color: #a32929;
}

.service-alerts,
.service-alert-error {
  margin: 8px 0 0 32px;
}

.service-alert {
  color: #68480e;
  font-size: 11px;
  line-height: 1.4;
}

.service-alert + .service-alert {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #ead9a8;
}

.service-alert summary {
  cursor: pointer;
}

.service-alert-label {
  display: inline-block;
  margin-right: 5px;
  color: #754b08;
  font-weight: 700;
}

.service-alert-header {
  font-weight: 600;
}

.service-alert-description {
  margin: 5px 0 0;
  color: #604c27;
  white-space: pre-line;
}

/* Alerts about other lines that mention this one: quiet, and always after the arrivals. */
.related-alerts {
  order: 1;
  margin: 8px 0 0 32px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.related-alerts .service-alert,
.related-alerts .service-alert-label,
.related-alerts .service-alert-description {
  color: var(--muted);
}

.related-alerts .service-alert + .service-alert {
  border-top-color: var(--line);
}

.service-alert-error {
  color: #8a4b16;
  font-size: 11px;
  line-height: 1.4;
}

.arrival-status {
  margin: 8px 0 0 32px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.arrival-groups {
  display: grid;
  gap: 8px;
  margin: 8px 0 0 32px;
}

.arrival-group {
  min-width: 0;
}

.arrival-destination {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: 11px;
  font-weight: 700;
}

.direction-marker,
.arrival-direction {
  display: inline-grid;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: #68736f;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
}

.arrival-group[data-direction="N"] .direction-marker,
.arrival-time[data-direction="N"] .arrival-direction {
  background: #126b8a;
}

.arrival-group[data-direction="S"] .direction-marker,
.arrival-time[data-direction="S"] .arrival-direction {
  background: #b25428;
}

.arrival-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 5px 0 0;
  padding: 0;
  list-style: none;
}

.arrival-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 25px;
  padding: 3px 7px 3px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.arrival-time.no-marker {
  padding-left: 7px;
}

.arrival-time[data-direction="N"] {
  border-color: #9bbfcd;
  background: #eaf3f6;
  color: #0d536a;
}

.arrival-time[data-direction="S"] {
  border-color: #d9ad94;
  background: #fbf0e9;
  color: #873f1d;
}

.empty-state {
  padding: 7px 0 3px;
}

.empty-state[hidden] {
  display: none;
}
.popup-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.attribution {
  display: inline-flex;
  gap: 8px;
}

.attribution[hidden] {
  display: none;
}

.popup-footer a {
  color: var(--muted);
  text-decoration: none;
}

.popup-footer a:hover,
.popup-footer a:focus-visible {
  color: var(--accent-dark);
  text-decoration: underline;
}
