:root {
  --ink: #1f2a26; --muted: #5f6b66; --line: #d9dfdc; --paper: #fff; --accent: #2e5e4e;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); }
body { display: flex; flex-direction: column; }
main { flex: 1; }

header {
  position: relative; z-index: 2; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
  background: var(--paper); border-bottom: 1px solid var(--line);
}
#q {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zooming in on focus */
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f4f6f5;
}
#hits {
  position: absolute; left: 12px; right: 12px; top: 100%; margin: 0; padding: 4px 0; list-style: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px #0002;
  max-height: 60vh; overflow: auto;
}
#hits button {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  padding: 8px 12px; border: 0; background: none; cursor: pointer;
}
#hits button:hover, #hits button:focus { background: #eef2f0; }
#hits small, .kind { display: block; color: var(--muted); }
#hits .none { padding: 8px 12px; color: var(--muted); }

#kinds { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; align-items: center; }
#kinds button {
  font: inherit; font-size: 14px; min-height: 40px; padding: 4px 14px; border-radius: 99px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
#kinds button[aria-pressed="false"] { background: var(--paper); color: var(--accent); }
#route { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; }
#route[hidden] { display: none; }
#route-text { flex: 1; font-weight: 600; color: var(--accent); }
#route-x { font: inherit; font-size: 22px; line-height: 1; min-width: 40px; min-height: 40px; border: 0; background: none; color: var(--muted); cursor: pointer; }
#more, #note { font-size: 13px; color: var(--muted); white-space: nowrap; }
#note { color: #b71c1c; }
.maplibregl-ctrl-bottom-right { margin-bottom: env(safe-area-inset-bottom); margin-right: env(safe-area-inset-right); }

#card {
  position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; max-height: 55vh; max-height: 55dvh; overflow: auto;
  padding: 14px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
  outline: none;
  background: var(--paper); border-radius: 14px 14px 0 0; box-shadow: 0 -6px 24px #0003;
}
#card h2 { margin: 0 32px 2px 0; font-size: 19px; }
#card dl { margin: 10px 0; }
#card dl div { display: flex; gap: 10px; padding: 3px 0; }
#card dt { flex: 0 0 82px; color: var(--muted); }
#card dd { margin: 0; overflow-wrap: anywhere; }
#card .route { display: flex; gap: 8px; margin: 10px 0 0; }
#card .route button {
  font: inherit; min-height: 40px; padding: 4px 14px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--paper); color: var(--accent);
}
#card .route button:first-child { background: var(--accent); color: #fff; }
#card .links { display: flex; gap: 16px; margin: 8px 0 0; }
#card a { color: var(--accent); }
#card .close {
  position: absolute; top: 4px; right: 6px; font-size: 24px; line-height: 1; min-width: 44px; min-height: 44px;
  border: 0; background: none; color: var(--muted); cursor: pointer;
}

@media (min-width: 720px) {
  header { position: absolute; top: 12px; left: 12px; width: 380px; border: 1px solid var(--line); border-radius: 12px; }
  #hits { left: 0; right: 0; }
  #card { left: auto; right: 12px; top: 12px; bottom: auto; width: 360px; max-height: calc(100% - 24px); border-radius: 12px; }
}
