:root {
  --bg-1: #0f1012;
  --bg-2: #1a1d22;
  --ink: #f1f3f5;
  --muted: #a9b0ba;
  --accent: #b40f2b;
  --accent-2: #d11f3f;
  --card: #171a1f;
  --error: #ff4d6d;
  --ok: #d11f3f;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  --surface: #22262d;
  --surface-alt: #20242b;
  --line: rgba(241, 243, 245, 0.16);
  --fill: rgba(241, 243, 245, 0.12);
  --fill-soft: rgba(241, 243, 245, 0.08);
  --scroll-thumb: rgba(241, 243, 245, 0.25);
  --scroll-thumb-hover: rgba(241, 243, 245, 0.4);
  --next-bg: #2a1117;
  --glow-1: rgba(209, 31, 63, 0.2);
  --glow-2: rgba(92, 101, 115, 0.2);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-1: #f2f3f6;
  --bg-2: #e4e7ec;
  --ink: #1b1d22;
  --muted: #58606b;
  --card: #ffffff;
  --error: #c22240;
  --shadow: 0 14px 40px rgba(15, 16, 18, 0.14);
  --surface: #f3f4f7;
  --surface-alt: #eaedf1;
  --line: rgba(15, 16, 18, 0.18);
  --fill: rgba(15, 16, 18, 0.08);
  --fill-soft: rgba(15, 16, 18, 0.06);
  --scroll-thumb: rgba(15, 16, 18, 0.3);
  --scroll-thumb-hover: rgba(15, 16, 18, 0.45);
  --next-bg: #fdeaee;
  --glow-1: rgba(209, 31, 63, 0.1);
  --glow-2: rgba(92, 101, 115, 0.1);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  /* Keep rem tied to the browser/system font size so Android text
     scaling reaches the whole app; stop iOS inflating text ad hoc. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@supports (font: -apple-system-body) {
  /* iOS ignores Dynamic Type on web content unless opted in. This sets
     the root size from the user's text-size setting; the font family is
     restored on body below. */
  html {
    font: -apple-system-body;
  }
}

[v-cloak] {
  display: none;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% 10%, var(--glow-1), transparent 33%),
    radial-gradient(circle at 10% 80%, var(--glow-2), transparent 40%),
    linear-gradient(130deg, var(--bg-1), var(--bg-2));
  display: grid;
  place-items: center;
  padding: 1rem;
}

#app {
  width: min(760px, 100%);
}

.app-header {
  margin-bottom: 1rem;
  text-align: center;
  animation: rise 0.5s ease;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.4rem, 5vw, 2.1rem);
  letter-spacing: 0.02em;
}

.app-header p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.panel {
  background: var(--card);
  border-radius: 20px;
  padding: 1rem;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease;
  max-width: 100vw;
  overflow: hidden;
}

h2 {
  margin-top: 0;
}

.choices {
  display: grid;
  gap: 0.7rem;
  margin: 1rem 0;
}

.choice-card {
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 0.9rem;
  text-align: left;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  font: inherit;
  color: inherit;
}

.choice-card input {
  accent-color: var(--accent);
}

.choice-card.selected {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(180, 15, 43, 0.22);
}

.choice-card.disabled {
  opacity: 0.55;
}

.role-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.btn {
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.6;
}

.btn.ghost {
  background: var(--fill);
  color: var(--ink);
}

.icon-btn {
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
}

.row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.wrap-row {
  flex-wrap: wrap;
}

.row.spread {
  justify-content: space-between;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.search-input-wrap {
  position: relative;
}

.field input {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 2.3rem 0.7rem 0.7rem;
  font: inherit;
  width: 100%;
  background: var(--surface);
  color: var(--ink);
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  border: 0;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
}

.time-debug-row {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.6rem;
  align-items: end;
  flex-wrap: wrap;
}

.compact-field {
  min-width: 9em;
}

.compact-field input {
  padding-right: 0.7rem;
}

.results {
  margin-top: 1rem;
  display: grid;
  gap: 0.6rem;
}

.platform-next-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(11em, 100%), 1fr));
}

.platform-next-card {
  background: var(--surface-alt);
  border-color: var(--line);
}

.subhead {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  color: var(--muted);
}

.platform-subtitle {
  margin: 0.25rem 0 0;
}

.toggle-row {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
}

.result-card h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.result-card p {
  margin: 0.18rem 0;
}

.passed-train-card {
  opacity: 0.55;
  filter: grayscale(0.35);
}

.queue-badge {
  display: inline-block;
  background: #b40f2b;
  color: #fff;
  padding: 0.125em 0.625em;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.calling-list {
  margin: 0.2rem 0 0.1rem 1rem;
  padding: 0;
}

.calling-list li {
  margin: 0.14rem 0;
}

.swipe-card {
  border-left: 5px solid var(--accent-2);
  transition: transform 0.22s ease, opacity 0.22s ease, box-shadow 0.22s ease;
  touch-action: pan-y;
}

.next-train-card {
  background: var(--next-bg);
  border-color: #d11f3f;
  box-shadow: 0 10px 24px rgba(209, 31, 63, 0.3);
}

.swipe-card.is-dismissing {
  transform: translateX(-48px);
  opacity: 0;
  box-shadow: none;
  pointer-events: none;
}

.card-actions-end {
  display: flex;
  justify-content: flex-end;
}

.muted-card {
  opacity: 0.75;
}

.meta {
  color: var(--muted);
  margin: 0.7rem 0 0;
}

.error {
  color: var(--error);
  margin: 0.7rem 0 0;
}

.app-footer {
  margin-top: 0.8rem;
  text-align: center;
}

.online {
  color: var(--ok);
}

.offline {
  color: var(--error);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 40em instead of 640px so enlarged text also collapses to one column */
@media (max-width: 40em) {
  .role-grid {
    grid-template-columns: 1fr;
  }
}

.button-group {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.info-content {
  max-height: 70vh;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.info-content::-webkit-scrollbar {
  width: 8px;
}

.info-content::-webkit-scrollbar-track {
  background: var(--fill-soft);
  border-radius: 4px;
}

.info-content::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 4px;
}

.info-content::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

.info-section {
  margin-bottom: 1.2rem;
}

.info-section h3 {
  margin: 0 0 0.6rem 0;
  color: var(--accent-2);
  font-size: 1.1rem;
}

.info-table {
  max-width: 100%;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.3rem;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);
}

.info-cell {
  padding: 0.4rem 0.6rem;
  background: var(--fill-soft);
  vertical-align: top;
}

.info-cell:first-child {
  border-radius: 6px 0 0 6px;
  padding-right: 1rem;
}

.info-cell:last-child {
  border-radius: 0 6px 6px 0;
}

.info-cell:only-child {
  border-radius: 6px;
}

.pdf-links {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.pdf-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1rem;
  background: rgba(209, 31, 63, 0.15);
  border: 2px solid rgba(209, 31, 63, 0.4);
  border-radius: 8px;
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.pdf-link:hover {
  background: rgba(209, 31, 63, 0.25);
  border-color: var(--accent-2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(209, 31, 63, 0.2);
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

.subway-train-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.subway-train-header p {
  margin: 0.18rem 0;
}

.calling-points-panel {
  margin-top: 0.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.4rem;
}

.calling-label {
  margin: 0 0 0.2rem;
}

#auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 90% 10%, var(--glow-1), transparent 33%),
    radial-gradient(circle at 10% 80%, var(--glow-2), transparent 40%),
    linear-gradient(130deg, var(--bg-1), var(--bg-2));
  z-index: 9999;
  padding: 1rem;
}

#auth-screen.hidden {
  display: none;
}

.auth-card {
  background: var(--card);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.auth-card h1 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
}

.auth-card .btn {
  margin-top: 1rem;
}

.auth-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
