/* NYC Trains. Flat opaque cards, glass only on the top bar. */
:root {
  color-scheme: light dark;

  /* Neutral steps, cool blue-grey hue. light-dark(light, dark) */
  --n0: light-dark(#f7f9fc, #0a1017);
  --bg: light-dark(#eef1f6, #0e141b);
  --card: light-dark(#ffffff, #18212c);
  --inset: light-dark(#e4e9f0, #212c39);
  --line: light-dark(#cfd7e2, #2f3c4c);
  --muted: light-dark(#566579, #9aa9bb);
  --secondary: light-dark(#40505f, #b8c4d2);
  --text: light-dark(#131c28, #eaeff5);
  --text-strong: light-dark(#0a111a, #f6f9fc);

  --accent: light-dark(#0b5fd1, #7ab8ff);
  --on-accent: light-dark(#ffffff, #06203f);
  --warn-bg: light-dark(#fdf0d2, #3a2d10);
  --warn-text: light-dark(#5c3d00, #f5d48a);
  --err-bg: light-dark(#fde4e1, #3d1f1d);
  --err-text: light-dark(#7a1a10, #ffc9c2);

  --bar: light-dark(#f4f6fa, #131a23);
  --bar-alpha: 82%;
  --shadow: 0 4px 12px rgb(10 20 35 / .14);

  --radius: 14px;
  --side: 16px;
  --bar-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@supports not (backdrop-filter: blur(1px)) { :root { --bar-alpha: 96%; } }
:root[data-solid] { --bar-alpha: 100%; }

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-h) + env(safe-area-inset-top) + 16px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.4 var(--font);   /* 17px */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Top bar (glass) */
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: color-mix(in srgb, var(--bar) var(--bar-alpha), transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: 0 2px 8px rgb(10 20 35 / .10);
}
:root[data-solid] .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; }
.bar-inner {
  max-width: 1100px; margin: 0 auto; min-height: var(--bar-h);
  padding: 6px var(--side);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.title { margin: 0; font-size: 1.625rem; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.bar-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  min-height: 44px; min-width: 44px; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; background: var(--inset); cursor: pointer;
  font-size: .9375rem; font-weight: 650;
}
.btn-icon { padding: 0; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn:active { filter: brightness(.94); }

/* Main */
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px var(--side) 32px; }
.cards { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); }
@media (min-width: 900px) { .cards { gap: 16px; } main { padding-top: 24px; } }

.callout {
  margin: 0 0 12px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--err-bg); color: var(--err-text); font-size: .9375rem; font-weight: 500;
}
.empty { text-align: center; padding: 32px 16px; display: grid; justify-items: center; gap: 16px; }
.empty p { margin: 0; color: var(--secondary); }
.loading { margin: 0; color: var(--muted); font-size: .9375rem; }

/* Card: flat and opaque */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin: -4px -8px 0 0; }
.card h2 { margin: 4px 0 0; font-size: 1.25rem; line-height: 1.25; font-weight: 650; overflow-wrap: anywhere; }
.remove { background: transparent; color: var(--secondary); flex: none; margin-top: -6px; }
.remove:hover { background: var(--inset); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 4px 0 0; font-size: .8125rem; color: var(--muted); }
.source { font-weight: 650; color: var(--secondary); padding: 0 8px; border-radius: 999px; background: var(--inset); line-height: 1.6; }
.sub { margin: 4px 0 0; font-size: .8125rem; color: var(--muted); }
.banner, .note-line {
  margin: 12px 0 0; padding: 8px 12px; border-radius: 10px; font-size: .9375rem; font-weight: 500;
}
.banner { background: var(--warn-bg); color: var(--warn-text); }
.note-line { background: var(--inset); color: var(--secondary); }
.unavailable { margin: 12px 0 0; color: var(--secondary); font-size: .9375rem; }

.dir { margin: 24px 0 4px; font-size: .8125rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.dir:first-of-type { margin-top: 16px; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 0; min-height: 48px; }
.row + .row { border-top: 1px solid var(--inset); }
.dest { min-width: 0; font-size: 1.0625rem; font-weight: 500; line-height: 1.25; overflow-wrap: break-word; hyphens: manual; }
.dest .branch { display: block; font-size: .8125rem; font-weight: 400; color: var(--muted); margin-top: 2px; }
.bullet.rail { width: 6px; height: 32px; border-radius: 3px; justify-self: center; }
.times { display: flex; align-items: baseline; gap: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--secondary); font-size: .9375rem; }
.times .first { font-size: 1.375rem; font-weight: 700; color: var(--text-strong); line-height: 1.2; }

/* Route bullets */
.bullet {
  background: var(--bg-c, var(--inset)); color: var(--fg-c, var(--text));
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  font-weight: 700; line-height: 1; letter-spacing: -.02em;
}
.bullet.circle { width: 28px; height: 28px; border-radius: 50%; font-size: .9375rem; }
.bullet.diamond { width: 32px; height: 32px; font-size: .8125rem; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.bullet.pill { min-height: 24px; padding: 0 10px; border-radius: 999px; font-size: .8125rem; }
.row .bullet.pill { min-width: 28px; }
.row .bullet.pill, .row .bullet.circle, .row .bullet.diamond { justify-self: center; }

/* Dialogs */
.sheet {
  border: 0; padding: 0; background: var(--card); color: var(--text);
  width: 100%; max-width: none; max-height: 88dvh;
  margin: auto 0 0; border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 16px rgb(10 20 35 / .18);
  padding-bottom: env(safe-area-inset-bottom);
  overflow: auto;
  opacity: 1; transform: none;
  transition: opacity .2s cubic-bezier(.2,.8,.2,1), transform .2s cubic-bezier(.2,.8,.2,1), overlay .2s allow-discrete, display .2s allow-discrete;
}
.sheet:not([open]) { opacity: 0; transform: translateY(24px); }
@starting-style { .sheet[open] { opacity: 0; transform: translateY(24px); } }
.sheet::backdrop { background: rgb(8 14 22 / .5); }
@media (min-width: 640px) {
  .sheet { width: min(480px, calc(100% - 32px)); margin: auto; border-radius: var(--radius); box-shadow: 0 8px 24px rgb(10 20 35 / .22); padding-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet:not([open]) { transform: none; transition: opacity .2s linear, overlay .2s allow-discrete, display .2s allow-discrete; }
  @starting-style { .sheet[open] { transform: none; } }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 16px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; font-weight: 650; }
.search { position: relative; margin: 8px 16px 8px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 48px; padding: 0 12px 0 44px; font-size: 17px;
  background: var(--inset); border: 0; border-radius: 12px; color: var(--text);
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.note { margin: 0 16px 8px; font-size: .9375rem; color: var(--secondary); }
.results { list-style: none; margin: 0; padding: 0 8px 16px; }
.pick {
  width: 100%; min-height: 56px; padding: 8px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  background: transparent; border: 0; border-radius: 10px; text-align: left; cursor: pointer;
}
.pick:hover:not(:disabled) { background: var(--inset); }
.pick:disabled { cursor: default; color: var(--muted); }
.pick-name { font-size: 1.0625rem; font-weight: 500; }
.pick-sys { font-size: .8125rem; color: var(--muted); font-weight: 500; }
.pick-bullets { display: flex; flex-wrap: wrap; gap: 4px; grid-column: 1; }
.pick-state { grid-row: 1 / span 2; grid-column: 2; font-size: .9375rem; font-weight: 650; color: var(--muted); }
.pick-bullets .bullet.circle { width: 24px; height: 24px; font-size: .8125rem; }
.pick-bullets .bullet.diamond { width: 28px; height: 28px; font-size: .75rem; }
.pick-bullets .bullet.pill { min-height: 24px; }
.none { padding: 16px 8px; color: var(--secondary); font-size: .9375rem; }

/* Settings */
.setting { border: 0; margin: 0; padding: 12px 16px 16px; }
.setting legend, .setting label.lbl { font-weight: 650; padding: 0; margin-bottom: 8px; }
.row-setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--inset); }
.row-setting label { font-weight: 650; display: block; }
.row-setting .note { margin: 0; }
.seg { display: flex; gap: 4px; background: var(--inset); border-radius: 999px; padding: 4px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 999px; font-size: .9375rem; font-weight: 500; color: var(--secondary); }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); font-weight: 650; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 3px; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; cursor: pointer;
  width: 52px; height: 44px; margin: 0; background: transparent; border: 0;
}
.switch::before { content: ""; position: absolute; left: 0; top: 8px; width: 52px; height: 28px; border-radius: 999px; background: var(--line); }
.switch::after { content: ""; position: absolute; left: 4px; top: 12px; width: 20px; height: 20px; border-radius: 50%; background: var(--card); }
.switch:checked::before { background: var(--accent); }
.switch:checked::after { left: 28px; background: var(--on-accent); }

.footer { max-width: 1100px; width: 100%; margin: 0 auto; padding: 16px var(--side) calc(32px + env(safe-area-inset-bottom)); }
.footer p { margin: 0; font-size: .8125rem; line-height: 1.5; color: var(--muted); max-width: 70ch; }

@media (min-width: 900px) {
  :root { --side: 24px; }
  .title { font-size: clamp(1.625rem, 1.4rem + .6vw, 2rem); }
}
