:root {
  color-scheme: dark;
  --bg: #14171c;
  --ink: #f5f6f7;
  --muted: #aab2bd;
  --line: #333a44;
  --calm: #157a4b;
  --hurry: #f2b632;
  --rush: #d92d2d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { background: var(--bg); }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom));
  color: var(--ink);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
html[data-status="calm"] { background: var(--calm); --muted: #e3f5ec; --line: #ffffff55; }
html[data-status="hurry"] { background: var(--hurry); --ink: #14171c; --muted: #3d3214; --line: #14171c44; color-scheme: light; }
html[data-status="rush"] { background: var(--rush); --muted: #ffe5e5; --line: #ffffff55; }
p { margin: 0; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#route { font-weight: 600; min-width: 0; }
#open-settings { flex: none; display: grid; place-items: center; width: 44px; padding: 0; border-color: transparent; }
button, input, select { font: inherit; }
button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 20px; padding: 24px 0; }
#verdict { font-size: 24px; font-weight: 700; }
#time { font-size: clamp(84px, 30vw, 150px); line-height: 1.05; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
#train { font-size: 20px; font-weight: 600; }
#advice { color: var(--muted); font-size: 19px; }
#retry { margin-top: 16px; }
#missed { color: var(--muted); }
#missed:empty, #later:empty { display: none; }
#later { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
#later li { display: flex; gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
#later .at { font-weight: 700; font-size: 20px; }
#later .to { flex: 1; min-width: 0; }
#later .tag { color: var(--muted); font-size: 15px; }
footer { color: var(--muted); font-size: 13px; display: grid; gap: 6px; }
#start-picker { display: grid; gap: 4px; font-size: 15px; }
footer select { background: transparent; color: inherit; border: 1px solid var(--line); border-radius: 10px; min-height: 44px; padding: 0 8px; }
footer select option { color: #14171c; }

dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow-y: auto;
  background: #000;
  color: #fff;
  font-size: 17px;
}
dialog[open] { animation: sheet-up 0.28s cubic-bezier(0.32, 0.72, 0, 1); }
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }

.nav {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  background: rgb(22 22 24 / 0.86);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 0.5px solid #38383a;
}
.nav h2 { grid-column: 2; margin: 0; font-size: 17px; font-weight: 600; }
#close-settings {
  grid-column: 3;
  justify-self: end;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: #0a84ff;
  font-size: 17px;
  font-weight: 600;
}

.sheet {
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 16px max(32px, env(safe-area-inset-bottom));
}
.sheet h3 {
  margin: 24px 16px 6px;
  color: #8e8e93;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.group { overflow: hidden; border-radius: 10px; background: #1c1c1e; }
.group > * + *, #results li + li { border-top: 0.5px solid #38383a; }
.cell {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 0 16px;
  border-radius: 0;
  font-size: 17px;
}
#saved-row { justify-content: space-between; }
#saved-address { color: #8e8e93; text-align: right; }
.search svg { flex: none; color: #8e8e93; }
.search input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  color: inherit;
  font-size: 17px;
}
.search input::placeholder { color: #8e8e93; }
#results { list-style: none; margin: 0; padding: 0; }
#results:empty { display: none; }
#results button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font-size: 17px;
  font-weight: 400;
  text-align: left;
}
#results button:active, #use-location:active { background: #2c2c2e; }
#results small { display: block; margin-top: 2px; color: #8e8e93; font-size: 14px; }
#use-location {
  border: 0;
  border-top: 0.5px solid #38383a;
  background: none;
  color: #0a84ff;
  font-weight: 400;
  text-align: left;
}
.picker > span { flex: none; }
.picker select {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  border: 0;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  color: #8e8e93;
  font-size: 17px;
  text-align: right;
  text-align-last: right;
}
.picker svg { flex: none; color: #8e8e93; }
.note { margin: 8px 16px 0; color: #8e8e93; font-size: 13px; line-height: 1.35; }
.note:empty { display: none; }
