:root {
  --bg: #f3f4f6;
  --fg: #16181d;
  --muted: #646a75;
  --card: #ffffff;
  --accent: #b42318;
  --accent-fg: #ffffff;
  --border: #dcdfe4;
  --chip: #eef0f3;
  --header-h: 60px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --fg: #e9ebef;
    --muted: #9aa1ac;
    --card: #1b1e24;
    --accent: #f0645a;
    --accent-fg: #16181d;
    --border: #2d313a;
    --chip: #262a32;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted { color: var(--muted); }

/* ---------- header ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header-h);
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 1.25rem; }
h2 { margin: 0 0 4px; font-size: 1rem; }

/* ---------- controls ---------- */

input, select, button { font: inherit; color: inherit; }

input, select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}

button.primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

button.link {
  border: none;
  background: none;
  padding: 8px 0;
  color: var(--accent);
  text-decoration: underline;
}

button:disabled, select:disabled { opacity: .55; cursor: not-allowed; }

.badge {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: .8rem;
  text-align: center;
}

/* ---------- filter panel ---------- */

.filters {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.location {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}
.location p { margin: 0; font-size: .9rem; }

.loc-form { display: flex; gap: 8px; }
.loc-form button { flex: none; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 0; min-width: 0; }
.field > span, .field legend { font-size: .85rem; font-weight: 600; color: var(--muted); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

fieldset.types { border: none; padding: 0; }
#types { display: flex; flex-wrap: wrap; gap: 8px; }
#types label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  user-select: none;
}
#types input { width: auto; min-height: 0; margin: 0; accent-color: var(--accent); }

/* ---------- results ---------- */

main { padding: 0 16px 32px; min-width: 0; }

.summary { margin: 16px 0 8px; color: var(--muted); }

.day { margin: 0 0 20px; }
.day h3 {
  position: sticky;
  top: var(--header-h);
  z-index: 1;
  margin: 0;
  padding: 8px 0;
  background: var(--bg);
  font-size: .95rem;
}

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.card a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
}
.card a:hover, .card a:focus-visible { border-color: var(--accent); }

.card .name { font-weight: 600; overflow-wrap: anywhere; }
.card .where { color: var(--muted); font-size: .92rem; }
.card .side {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}
.card .dist { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.card .type {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: .78rem;
}

.empty { padding: 32px 0; text-align: center; color: var(--muted); }

.more { display: block; width: 100%; margin-top: 8px; }

/* ---------- mobile: collapsible filters ---------- */

@media (max-width: 799px) {
  h1 { font-size: 1.1rem; }
  .filters-toggle { flex: none; }
  .filters { display: none; border-bottom: 1px solid var(--border); }
  .filters.open { display: flex; }
}

/* ---------- desktop: sidebar ---------- */

@media (min-width: 800px) {
  .filters-toggle { display: none; }

  .layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 8px;
    max-width: 1280px;
    margin: 0 auto;
  }

  .filters {
    position: sticky;
    top: var(--header-h);
    align-self: start;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }

  main { padding-top: 0; }

  .cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}
