:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --ink: #161d3b;
  --ink-soft: #596079;
  --line: #e0dcd2;
  --line-strong: #c9c2b1;

  --navy: #1f3373;
  --navy-deep: #18245c;
  --sky: #4f7cc4;
  --sky-soft: #e7edf8;
  --header: #e9eff9;
  --header-line: #cfdaee;

  --a-public: #b4583a;
  --a-group: #4f7cc4;
  --a-closed: #8b93a7;

  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

a { color: var(--navy); }

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

:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

.site-header {
  background: var(--header);
  border-bottom: 1px solid var(--header-line);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 16px 14px;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand .logo { width: 42px; height: 42px; display: block; flex: none; }
.org-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; color: var(--navy); }

.kicker {
  margin: 16px 0 0;
  font-size: 12.5px; font-weight: 600;
  letter-spacing: .02em;
  color: var(--sky);
}

h1 {
  margin: 4px 0 4px;
  font-size: clamp(26px, 6.6vw, 40px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -.015em;
  color: var(--navy-deep);
}

.lede {
  margin: 0 0 14px;
  max-width: 62ch;
  font-size: 14.5px;
  color: var(--ink-soft);
}

.home-link {
  display: inline-flex; align-items: center;
  min-height: 40px; padding: 8px 16px; margin-bottom: 6px;
  border-radius: 6px;
  background: var(--navy); color: #fff;
  font-size: 14px; font-weight: 700;
  text-decoration: none;
}
.home-link:hover { background: var(--navy-deep); }

.controls {
  display: flex; gap: 8px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px;
}
.controls::-webkit-scrollbar { display: none; }

.city-filter { flex: none; position: relative; }

.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px;
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--header-line);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--sky); }
.chip[aria-checked="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.chip .n {
  font-size: 12px; font-weight: 700;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.chip[aria-checked="true"] .n { color: #b9c8ea; }
.chip.toggle[aria-pressed="true"] {
  background: var(--a-public);
  border-color: var(--a-public);
  color: #fff;
}
.chip.toggle::before {
  content: "";
  width: 14px; height: 14px; border-radius: 4px;
  border: 1.5px solid currentColor;
  box-sizing: border-box;
}
.chip.toggle[aria-pressed="true"]::before {
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='8' viewBox='0 0 10 8'%3E%3Cpath d='M1 4l3 3 5-6' stroke='%23b4583a' stroke-width='1.8' fill='none'/%3E%3C/svg%3E") no-repeat center;
  border-color: #fff;
}

.city-filter select {
  appearance: none;
  min-height: 40px;
  padding: 7px 36px 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--header-line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231f3373' stroke-width='1.8' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}

.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 16px 0;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr);
}

.map-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #ebe8e1;
  height: min(118vw, 70vh);
  height: min(118vw, 70svh);
  min-height: 320px;
  scroll-margin-top: 10px;
}
.map-wrap::after {
  content: "";
  position: absolute; inset: 6px;
  border: 1px solid rgba(31, 51, 115, .28);
  border-radius: 4px;
  pointer-events: none;
  z-index: 800;
}

#map { position: absolute; inset: 0; }

.legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 700;
  display: flex; gap: 10px;
  padding: 5px 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--line);
  font-size: 12px; font-weight: 600;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.dot.a-public { background: var(--a-public); }
.dot.a-group { background: var(--a-group); }
.dot.a-closed { background: var(--a-closed); }

.list-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  overflow: hidden;
  display: flex; flex-direction: column;
}

.list-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.list-head h2 { margin: 0; font-size: 17px; font-weight: 800; color: var(--navy-deep); }
.count { font-size: 13px; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }

.event-list { overflow-y: auto; }

.day-group h3 {
  position: sticky; top: 0; z-index: 1;
  margin: 0;
  padding: 8px 16px;
  font-size: 12px; font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--navy);
  background: #f4f6fb;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}

.event-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  font: inherit; color: inherit;
  cursor: pointer;
  transition: background .12s;
}
.event-item:hover { background: #fafaf7; }
.event-item.is-active { background: var(--sky-soft); box-shadow: inset 3px 0 0 var(--navy); }

.event-item .time {
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--navy-deep);
  padding-top: 1px;
}
.event-item .time small { display: block; font-size: 12px; font-weight: 500; color: var(--ink-soft); }
.event-item .title { display: block; font-weight: 600; font-size: 15px; line-height: 1.3; }
.event-item .where { display: block; margin-top: 3px; font-size: 13px; color: var(--ink-soft); }
.event-item .tag {
  display: inline-block; margin-top: 5px;
  padding: 1px 7px; border-radius: 4px;
  font-size: 11.5px; font-weight: 700;
  color: #fff; background: var(--a-closed);
}
.tag.a-public { background: var(--a-public); }
.tag.a-group { background: var(--a-group); }
.event-item.no-pin { position: relative; padding-right: 36px; }
.event-item.no-pin::after {
  content: ""; position: absolute; right: 16px; top: 18px;
  width: 8px; height: 8px;
  border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg); transition: transform .15s;
}
.event-item.no-pin.is-open::after { transform: rotate(-135deg); top: 22px; }
.event-details {
  padding: 4px 16px 14px 84px;
  border-bottom: 1px solid var(--line);
  background: var(--sky-soft);
  font-size: 13.5px;
}
.event-details ul { list-style: none; margin: 0 0 8px; padding: 0; }
.event-details li, .event-details .org {
  display: grid; grid-template-columns: 20px 1fr; gap: 8px;
  padding: 2px 0; margin: 0;
}
.event-details svg { margin-top: 2px; color: var(--navy); }
.event-details p { margin: 0 0 8px; color: var(--ink-soft); }
.event-details .org { color: var(--ink-soft); }
.event-details .audience b, .pop .audience b { color: var(--navy-deep); }
.online-group h3 { background: #f6efe9; color: #6e3322; }

.empty, .error { padding: 28px 16px; color: var(--ink-soft); text-align: center; }

.pin {
  width: 28px; height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(22, 29, 59, .45);
  display: grid; place-items: center;
}
.pin span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #fff;
}
.pin.a-public { background: var(--a-public); }
.pin.a-group { background: var(--a-group); }
.pin.a-closed { background: var(--a-closed); }
.leaflet-marker-icon.is-active .pin { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--navy); }

.cluster {
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--navy);
  box-shadow: 0 1px 4px rgba(22, 29, 59, .35);
}
.cluster div {
  width: calc(100% - 8px); height: calc(100% - 8px);
  border-radius: 50%;
  border: 1px solid rgba(31, 51, 115, .4);
  display: grid; place-items: center;
  color: var(--navy);
  font-weight: 800; font-size: 15px;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
  box-shadow: 0 6px 22px rgba(22, 29, 59, .2);
}
.leaflet-popup-content {
  margin: 0;
  width: min(300px, 78vw) !important;
  font-family: "Golos Text", system-ui, sans-serif;
  line-height: 1.45;
}
.leaflet-container a.leaflet-popup-close-button {
  width: 32px; height: 32px; font-size: 22px; line-height: 30px;
  top: 6px; right: 4px; color: var(--ink-soft);
}

.pop { border-top: 4px solid var(--c, var(--navy)); padding: 14px 16px; }
.pop.a-public { --c: var(--a-public); }
.pop.a-group { --c: var(--a-group); }
.pop.a-closed { --c: var(--a-closed); }
.pop .access-tag {
  display: inline-block; margin-left: 8px;
  padding: 1px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 700;
  color: #fff; background: var(--c);
  vertical-align: 1px;
}
.pop .badge {
  display: inline-block;
  font-size: 11.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--c);
}
.pop h3 { margin: 4px 26px 10px 0; font-size: 16.5px; line-height: 1.25; font-weight: 800; color: var(--navy-deep); }
.pop ul { list-style: none; margin: 0 0 10px; padding: 0; }
.pop li {
  display: grid; grid-template-columns: 20px 1fr; gap: 8px;
  padding: 3px 0;
  font-size: 13.5px; color: var(--ink);
}
.pop li svg { margin-top: 2px; color: var(--navy); }
.pop .nowrap { white-space: nowrap; }
.pop li small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.pop p { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-soft); }
.pop p.org { display: grid; grid-template-columns: 20px 1fr; gap: 8px; font-size: 12.5px; margin-bottom: 12px; }
.pop p.org svg { margin-top: 1px; color: var(--ink-soft); }
.pop .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pop .btn {
  flex: 1 1 auto;
  display: inline-flex; justify-content: center; align-items: center; gap: 6px;
  min-height: 40px; padding: 8px 12px;
  border-radius: 6px;
  font-size: 13.5px; font-weight: 700;
  text-decoration: none;
}
.leaflet-container .pop a.btn-primary { background: var(--navy); color: #fff; }
.leaflet-container .pop a.btn-primary:hover { background: var(--navy-deep); }
.leaflet-container .pop a.btn-ghost { background: var(--sky-soft); color: var(--navy); }

.leaflet-touch .leaflet-bar,
.leaflet-bar { border: 1px solid var(--line-strong) !important; border-radius: 6px; box-shadow: none; overflow: hidden; }
.leaflet-container .leaflet-bar a,
.leaflet-container a.home-btn { color: var(--navy); background: #fff; }
.leaflet-bar a:hover { background: var(--sky-soft); }
.leaflet-top.leaflet-left { margin: 6px 0 0 6px; }

.leaflet-bar.home-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
}

.credits {
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
  margin: 0 12px 12px 0 !important;
  font-size: 11.5px;
}
.credits button {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line); padding: 0;
  background: rgba(255, 255, 255, .95);
  color: var(--ink-soft);
  font: italic 700 13px/22px Georgia, serif;
  cursor: pointer;
}
.credits-text {
  display: none;
  padding: 4px 9px; border-radius: 5px;
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  white-space: nowrap;
}
.credits.is-open .credits-text { display: inline-block; }

.leaflet-container { font-family: "Golos Text", system-ui, sans-serif; background: #ebe8e1; }

.site-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 16px 28px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}
.site-footer img { width: 28px; height: 28px; flex: none; }
.site-footer p { margin: 0; }
.site-footer strong { color: var(--navy); font-weight: 600; }

@media (max-width: 899px) {
  .pop { padding: 11px 13px 12px; }
  .pop h3 { font-size: 15px; margin: 2px 24px 8px 0; }
  .pop ul { margin-bottom: 8px; }
  .pop li { font-size: 13px; padding: 2px 0; }
  .pop li small { font-size: 12px; }
  .pop p { font-size: 13px; margin-bottom: 10px; line-height: 1.4; }
  .pop .btn { min-height: 38px; padding: 6px 12px; }
  .leaflet-popup-content { width: min(290px, 80vw) !important; }

  .map-wrap .leaflet-top,
  .map-wrap .legend { transition: opacity .15s; }
  .map-wrap.popup-open .leaflet-top,
  .map-wrap.popup-open .legend { opacity: 0; pointer-events: none; }
}

@media (min-width: 900px) {
  .header-inner { padding: 20px 24px 18px; }
  .lede { font-size: 15px; }
  .controls { margin: 0; padding: 0; overflow: visible; flex-wrap: wrap; gap: 10px; }
  .layout {
    padding: 16px 24px 0;
    grid-template-columns: minmax(0, 1fr) 380px;
    height: calc(100vh - 200px);
    min-height: 560px;
  }
  .map-wrap { height: 100%; min-height: 0; }
  .list-wrap { min-height: 0; }
  .event-list { flex: 1; }
  .site-footer { padding: 16px 24px 24px; }
}
