:root {
  color-scheme: light;
  --ink: var(--tg-theme-text-color, #242126);
  --muted: var(--tg-theme-hint-color, #6f6973);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --page: var(--tg-theme-bg-color, #f4f1ec);
  --accent: var(--tg-theme-button-color, #6750a4);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --accent-soft: #eee8fb;
  --line: #e6e0e8;
  --warm: #f6b84a;
  --success: #34745b;
  --danger: #a74444;
  font-family: Inter, ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }

.hero {
  position: relative;
  overflow: hidden;
  padding: max(22px, env(safe-area-inset-top)) 22px 64px;
  color: #fff;
  background:
    radial-gradient(circle at 86% 18%, rgba(246, 184, 74, .72) 0 8%, transparent 8.5%),
    radial-gradient(circle at 93% 67%, rgba(255,255,255,.12) 0 17%, transparent 17.5%),
    linear-gradient(145deg, #58408f, #7860b3 68%, #8b6ec5);
}

.hero::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  right: -70px;
  bottom: -95px;
  border: 22px solid rgba(255,255,255,.09);
  border-radius: 50%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 34px;
  font-weight: 750;
  letter-spacing: .01em;
}

.brand-mark { color: var(--warm); font-size: 24px; }

.hero h1 {
  max-width: 520px;
  margin: 0;
  font-size: clamp(2.1rem, 9vw, 3.4rem);
  line-height: .98;
  letter-spacing: -.045em;
}

.hero p {
  max-width: 520px;
  margin: 19px 0 0;
  color: rgba(255,255,255,.83);
  font-size: 1rem;
  line-height: 1.48;
}

main {
  position: relative;
  width: min(100%, 680px);
  margin: -34px auto 0;
  padding: 0 14px max(42px, env(safe-area-inset-bottom));
}

.panel {
  margin-bottom: 14px;
  padding: 22px 18px;
  border: 1px solid rgba(45,31,62,.06);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 10px 32px rgba(48,37,61,.08);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.section-heading h2, .results-heading h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: .85rem; }

.step {
  display: grid;
  flex: 0 0 30px;
  height: 30px;
  place-items: center;
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 750;
  font-size: .85rem;
}

.combobox-wrap { position: relative; }
.address-row { position: relative; }

.pin {
  position: absolute;
  top: 50%;
  left: 14px;
  translate: 0 -50%;
  color: var(--accent);
  font-size: 1.35rem;
}

#address {
  width: 100%;
  min-height: 52px;
  padding: 12px 44px;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  color: var(--ink);
  background: #fbfafc;
  transition: border-color .15s, box-shadow .15s;
}

#address:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(103,80,164,.13); }

.mini-spinner {
  position: absolute;
  top: 17px;
  right: 16px;
  width: 18px;
  height: 18px;
  border: 2px solid #ddd5ea;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}

@keyframes spin { to { rotate: 360deg; } }

.suggestions {
  position: absolute;
  z-index: 10;
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  margin: 6px 0 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 14px 32px rgba(35,25,47,.17);
}

.suggestions button {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  text-align: left;
  background: transparent;
}

.suggestions button:hover, .suggestions button:focus { outline: none; background: var(--accent-soft); }
.suggestions strong, .suggestions small { display: block; }
.suggestions small { margin-top: 2px; color: var(--muted); }

.text-button {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 6px 2px;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 680;
}

.selected-location {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 11px;
  color: var(--success);
  background: #eaf5ef;
  font-size: .88rem;
}

fieldset { margin: 0 0 20px; padding: 0; border: 0; }
legend, .field-label { display: flex; width: 100%; margin-bottom: 9px; font-size: .88rem; font-weight: 730; }
.hint { margin-left: auto; color: var(--muted); font-size: .78rem; font-weight: 500; }

.choice-grid { display: grid; gap: 7px; }
.choice-grid.four { grid-template-columns: repeat(2, 1fr); }
.choice-grid.three { grid-template-columns: repeat(3, 1fr); }
.choice-grid input { position: absolute; opacity: 0; pointer-events: none; }
.choice-grid span {
  display: grid;
  min-height: 40px;
  padding: 6px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: #fbfafc;
  font-size: .84rem;
  font-weight: 650;
  text-align: center;
  transition: .15s;
}
.choice-grid input:checked + span { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.choice-grid input:focus-visible + span { outline: 3px solid rgba(103,80,164,.2); }

.filter-row { margin-bottom: 20px; }
.number-field { display: flex; align-items: center; gap: 9px; }
.number-field input {
  width: 78px;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  text-align: center;
  background: #fbfafc;
}
.number-field input:focus { border-color: var(--accent); }
.number-field span { color: var(--muted); }

.toggles { border-top: 1px solid var(--line); }
.toggle-row { display: flex; align-items: center; gap: 16px; padding: 15px 0 0; }
.toggle-row + .toggle-row { margin-top: 14px; border-top: 1px solid var(--line); }
.toggle-row > span { flex: 1; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: .87rem; }
.toggle-row small { margin-top: 3px; color: var(--muted); font-size: .75rem; line-height: 1.25; }
.toggle-row input { position: absolute; opacity: 0; }
.toggle-row i {
  position: relative;
  flex: 0 0 44px;
  height: 26px;
  border-radius: 20px;
  background: #d9d4dc;
  transition: .2s;
}
.toggle-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: .2s;
}
.toggle-row input:checked + i { background: var(--accent); }
.toggle-row input:checked + i::after { translate: 18px 0; }
.toggle-row input:focus-visible + i { outline: 3px solid rgba(103,80,164,.2); }

.primary-button {
  display: flex;
  width: 100%;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  border: 0;
  border-radius: 17px;
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(73,50,127,.24);
  font-size: 1rem;
  font-weight: 760;
}
.primary-button:hover { filter: brightness(1.06); }
.primary-button:disabled { cursor: wait; opacity: .72; }

.results-section { margin-top: 34px; }
.results-heading { display: flex; align-items: flex-end; justify-content: space-between; margin: 0 4px 15px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.count { padding: 5px 9px; border-radius: 20px; color: var(--accent); background: var(--accent-soft); font-size: .8rem; font-weight: 750; }

.status {
  padding: 24px 18px;
  border: 1px dashed #d7d0d9;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}
.status.error { border-color: #e5b9b9; color: var(--danger); background: #fff5f5; }
.status.loading { border-style: solid; }
.results { display: grid; gap: 12px; }

.event-card {
  padding: 18px;
  border: 1px solid rgba(45,31,62,.07);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(48,37,61,.07);
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.category-pill { padding: 5px 9px; border-radius: 9px; color: var(--accent); background: var(--accent-soft); font-size: .73rem; font-weight: 760; }
.distance { color: var(--muted); font-size: .78rem; font-weight: 650; }
.event-card h3 { margin: 13px 0 7px; font-size: 1.16rem; line-height: 1.2; letter-spacing: -.02em; }
.schedule { margin: 0; color: var(--ink); font-size: .88rem; font-weight: 660; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.fact { padding: 6px 9px; border-radius: 9px; color: #524b55; background: #f3f0f4; font-size: .76rem; }
.fact.caution { color: #895f15; background: #fff2d6; }
.description-block { margin-top: 14px; }
.description-block summary { width: max-content; color: var(--accent); cursor: pointer; font-size: .82rem; font-weight: 720; }
.description-block summary::marker { color: var(--accent); }
.description { margin: 9px 0 0; color: var(--muted); font-size: .87rem; line-height: 1.48; white-space: pre-line; }
.uncertainty { margin-top: 13px; padding: 10px 11px; border-radius: 11px; color: #755419; background: #fff5dd; font-size: .76rem; line-height: 1.42; }
.uncertainty ul { margin: 5px 0 0; padding-left: 17px; }
.sources { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.sources a { color: var(--accent); font-size: .8rem; font-weight: 720; text-decoration: none; }
.sources a:hover { text-decoration: underline; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
[hidden] { display: none !important; }

@media (min-width: 620px) {
  .hero { padding-left: max(22px, calc((100vw - 650px) / 2)); padding-right: max(22px, calc((100vw - 650px) / 2)); }
  main { padding-inline: 0; }
  .panel { padding: 25px 24px; }
  .choice-grid.four { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
