:root {
  color-scheme: light dark;
  --bg: #edf2f3;
  --panel: #ffffff;
  --panel-soft: #f5f8f8;
  --ink: #17242b;
  --muted: #566872;
  --line: #cbd6da;
  --header: #102832;
  --accent: #13847a;
  --accent-soft: #d9f1ee;
  --orange: #c94f2f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
a {
  font: inherit;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 8px;
  z-index: 10;
  transform: translateY(-160%);
  padding: 8px 12px;
  background: #fff;
  color: #111;
}

.skip-link:focus {
  transform: none;
}

.topbar {
  height: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(14px, 2.6vw, 28px);
  position: relative;
  z-index: 3000;
  background: var(--header);
  color: #fff;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: var(--orange);
  font-weight: 900;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 4px;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.account,
.content-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button,
.content-home-button,
.location-button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}

.icon-button {
  width: 40px;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-button svg,
.location-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.content-home-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  text-decoration: none;
  font-weight: 900;
}

.header-menu {
  position: relative;
}

.header-menu summary {
  min-height: 36px;
  width: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  list-style: none;
}

.header-menu summary::-webkit-details-marker {
  display: none;
}

.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.hamburger-icon {
  position: relative;
}

.hamburger-icon::before,
.hamburger-icon::after {
  position: absolute;
  left: 0;
  content: "";
}

.hamburger-icon::before {
  top: -6px;
}

.hamburger-icon::after {
  top: 6px;
}

.header-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 3100;
  width: min(260px, calc(100vw - 24px));
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.25);
}

.header-menu-panel a,
.header-menu-action {
  min-height: 38px;
  display: grid;
  align-items: center;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  text-align: left;
  text-decoration: none;
}

.header-menu-panel a:hover,
.header-menu-action:hover {
  background: var(--panel-soft);
}

.menu-account-status {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

main {
  width: min(980px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.location-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.direction-section header p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 2rem);
}

.status,
.feed-status,
.disclaimer {
  margin: 5px 0 0;
  color: var(--muted);
}

.location-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 0 12px;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 800;
}

.direction-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.direction-summary a {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
}

.direction-summary span {
  color: var(--muted);
  font-weight: 900;
}

.direction-summary strong {
  font-size: 1.35rem;
}

.feed-status {
  min-height: 22px;
  margin-bottom: 12px;
}

.direction-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.direction-section,
.uncertain-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.direction-section > header {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.direction-section header p {
  margin: 0;
}

.direction-section h2 {
  margin: 2px 0 0;
  font-size: 1rem;
}

.compass {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #075e57;
  font-weight: 900;
}

.train-list {
  display: grid;
}

.train-card {
  min-width: 0;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.train-card:last-child {
  border-bottom: 0;
}

.train-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.train-card h3 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.distance {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 900;
}

.train-card p {
  margin: 5px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  line-height: 1.35;
}

.train-meta {
  color: var(--ink) !important;
  font-weight: 750;
}

.empty {
  margin: 0;
  padding: 18px 14px;
  color: var(--muted);
  text-align: center;
}

.uncertain-section {
  margin-top: 14px;
}

.uncertain-section summary {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
}

.uncertain-section summary strong {
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--panel-soft);
  text-align: center;
}

.disclaimer {
  padding: 14px 2px 0;
  font-size: 0.78rem;
  line-height: 1.45;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid #46bdb2;
  outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07161c;
    --panel: #0d2028;
    --panel-soft: #102a33;
    --ink: #eef6f7;
    --muted: #a8bac1;
    --line: #29434d;
    --accent: #58c8bd;
    --accent-soft: #123c3d;
  }

  .compass {
    color: #8ce1d9;
  }
}

:root[data-theme="dark"] {
  --bg: #07161c;
  --panel: #0d2028;
  --panel-soft: #102a33;
  --ink: #eef6f7;
  --muted: #a8bac1;
  --line: #29434d;
  --accent: #58c8bd;
  --accent-soft: #123c3d;
}

:root[data-theme="light"] {
  --bg: #edf2f3;
  --panel: #ffffff;
  --panel-soft: #f5f8f8;
  --ink: #17242b;
  --muted: #566872;
  --line: #cbd6da;
  --accent: #13847a;
  --accent-soft: #d9f1ee;
}

@media (max-width: 640px) {
  .topbar {
    padding-inline: 12px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand h1 {
    font-size: 1.2rem;
  }

  .content-home-button {
    padding-inline: 9px;
  }

  .location-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .location-button {
    justify-content: center;
    width: 100%;
  }

  .direction-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
