:root {
  color-scheme: light;
  --ink: #19212d;
  --muted: #79818d;
  --surface: #fff;
  --canvas: #f4f5f7;
  --line: #e7e9ed;
  --purple: #5237cc;
  --purple-soft: #f0edff;
  --green: #258257;
  --red: #b64b52;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(100%, 540px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 22px max(18px, env(safe-area-inset-bottom));
}

.topbar, .brand, .panel-heading, .dialog-heading, .live-status, .departure-row, .app-footer {
  display: flex;
  align-items: center;
}

.topbar { justify-content: space-between; }

.brand {
  gap: 11px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -.2px;
  text-decoration: none;
}

.brand-icon, .line-badge {
  display: grid;
  place-items: center;
  flex: none;
  background: var(--purple);
  color: white;
  font-weight: 800;
}

.brand-icon {
  width: 39px;
  height: 39px;
  border-radius: 13px;
  font-size: 16px;
}

.brand-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 1.25px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #4e5662;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.intro { margin: 33px 0 19px; }
.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.25px;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 5px;
  font-size: clamp(27px, 7vw, 34px);
  letter-spacing: -1.3px;
}

.intro-copy { margin: 0; color: var(--muted); font-size: 15px; }
.intro-copy strong { color: var(--ink); }

.direction-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.direction-tab {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}

.direction-tab:active { transform: scale(.985); }
.direction-tab.is-active { border: 2px solid var(--purple); background: var(--purple-soft); padding: 13px; }
.tab-caption { display: block; margin-bottom: 8px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.tab-destination { display: block; font-size: clamp(14px, 3.7vw, 16px); font-weight: 750; letter-spacing: -.3px; }
.tab-destination span { color: var(--purple); }
.tab-stop { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }

.departures-panel {
  margin-top: 17px;
  padding: 20px 17px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 8px 26px rgb(29 35 48 / 4%);
}

.panel-heading { justify-content: space-between; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.panel-heading h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.6px; }
.line-badge { width: 43px; height: 43px; border-radius: 14px; font-size: 17px; }

.live-status {
  gap: 8px;
  min-height: 35px;
  margin-top: 15px;
  padding: 0 10px;
  border-radius: 10px;
  background: #f5f6f8;
  color: var(--muted);
  font-size: 11px;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #a2a8b1; }
.live-status > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.live-status.is-live { background: #eef8f2; color: #327553; }
.live-status.is-live .status-dot { background: #31a36a; box-shadow: 0 0 0 3px rgb(49 163 106 / 12%); }
.live-status.is-error { background: #fff3f3; color: var(--red); }
.live-status.is-error .status-dot { background: var(--red); }

.departure-list { margin-top: 4px; }
.load-more-button {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--purple);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}
.load-more-button:active { background: var(--purple-soft); }
.departure-row {
  justify-content: space-between;
  gap: 12px;
  min-height: 69px;
  border-bottom: 1px solid var(--line);
}

.departure-row:last-child { border-bottom: 0; }
.departure-time { min-width: 54px; font-size: 20px; font-weight: 750; letter-spacing: -.5px; }
.departure-detail { flex: 1; min-width: 0; }
.departure-destination { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.departure-source { display: inline-block; margin-top: 5px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .65px; }
.gps-estimate { display: block; margin-top: 4px; color: var(--green); font-size: 10px; font-weight: 700; }
.gps-estimate.is-late { color: var(--red); }
.gps-estimate.is-early { color: var(--green); }
.countdown { flex: none; color: var(--purple); font-size: 13px; font-weight: 750; white-space: nowrap; }
.countdown.is-now { color: var(--green); }

.empty-state { padding: 33px 7px 18px; text-align: center; }
.empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin: 0 auto 13px;
  border-radius: 16px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 24px;
}

.empty-state h3 { margin-bottom: 7px; font-size: 16px; }
.empty-state p { max-width: 310px; margin: 0 auto 18px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.primary-button {
  min-height: 45px;
  padding: 0 17px;
  border: 0;
  border-radius: 13px;
  background: var(--purple);
  color: white;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.primary-button:disabled { opacity: .65; cursor: wait; }
.update-note { min-height: 12px; margin: 5px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.app-footer { justify-content: center; gap: 7px; margin: 18px 0; color: var(--muted); font-size: 10px; }
.footer-separator { color: #b6bbc3; }
.app-footer button { padding: 0; border: 0; background: transparent; color: var(--purple); font-size: inherit; cursor: pointer; }

dialog {
  width: min(calc(100% - 28px), 480px);
  max-height: min(88vh, 760px);
  padding: 23px;
  overflow-y: auto;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 80px rgb(18 23 34 / 28%);
}

dialog::backdrop { background: rgb(20 24 33 / 48%); backdrop-filter: blur(3px); }
.dialog-heading { justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dialog-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.6px; }
.close-button { flex: none; font-size: 25px; line-height: 1; }
.help-copy, .info-dialog p { color: #5e6672; font-size: 13px; line-height: 1.6; }
.help-copy a, .info-dialog a { color: var(--purple); font-weight: 650; }
.field-label { display: block; margin: 17px 0 7px; font-size: 12px; font-weight: 750; }
input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid #dfe2e8;
  border-radius: 12px;
  background: white;
  color: var(--ink);
  font-size: 14px;
}

input:focus { outline: 2px solid rgb(82 55 204 / 22%); border-color: var(--purple); }
.privacy-note, .pole-help { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-error { min-height: 17px; margin: 12px 0 0; color: var(--red); font-size: 12px; }
.save-button { width: 100%; margin-top: 4px; }
.info-dialog p:last-of-type { margin-bottom: 15px; }

@media (max-width: 380px) {
  .app-shell { padding-right: 15px; padding-left: 15px; }
  .direction-tab { padding: 12px; }
  .direction-tab.is-active { padding: 11px; }
  .departures-panel { padding-right: 14px; padding-left: 14px; }
}
