/* City Switcher */
:root {
	--csw-accent: #f37021;
	--csw-cols: 3;
	--csw-text: #1a1a1a;
	--csw-muted: #f0f0f0;
	--csw-radius: 12px;
}

/* ---------- Кнопка в шапке ---------- */
.csw-trigger {
	all: unset;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	gap: .35em;
	cursor: pointer;
	font: inherit;
	color: inherit;
	line-height: 1.2;
	white-space: nowrap;
}
.csw-trigger:hover .csw-trigger__name { color: var(--csw-accent); }
.csw-trigger:focus-visible { outline: 2px solid var(--csw-accent); outline-offset: 3px; border-radius: 4px; }
.csw-trigger__icon { width: 1.05em; height: 1.05em; flex: none; color: var(--csw-accent); }
.csw-trigger__arrow { width: .7em; height: .7em; flex: none; opacity: .6; transition: transform .2s; }
.csw-trigger[aria-expanded="true"] .csw-trigger__arrow { transform: rotate(180deg); }
.csw-trigger__name { border-bottom: 1px dashed currentColor; transition: color .15s; }

/* ---------- Окно ---------- */
html.csw-lock { overflow: hidden; }

.csw-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	font-size: 15px;
	line-height: 1.35;
}
.csw-modal[hidden] { display: none; }
.csw-modal *, .csw-modal *::before, .csw-modal *::after { box-sizing: border-box; }

.csw-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 15, 15, .55);
	opacity: 0;
	transition: opacity .2s ease;
}

.csw-modal__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(720px, 100%);
	height: min(760px, calc(100vh - 40px));
	height: min(760px, calc(100dvh - 40px));
	padding: 20px 8px 8px 24px;
	background: #fff;
	color: var(--csw-text);
	border-radius: var(--csw-radius);
	box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
	opacity: 0;
	transform: translateY(14px) scale(.98);
	transition: opacity .2s ease, transform .22s ease;
}

.csw-modal.is-open .csw-modal__overlay { opacity: 1; }
.csw-modal.is-open .csw-modal__dialog { opacity: 1; transform: none; }

/* Поиск + закрыть */
.csw-search {
	display: flex;
	align-items: center;
	gap: 8px;
	padding-right: 16px;
}
.csw-modal .csw-search__input {
	-webkit-appearance: none;
	appearance: none;
	flex: 1;
	min-width: 0;
	height: 48px;
	margin: 0;
	padding: 0 20px;
	border: 0;
	border-radius: 999px;
	background: var(--csw-muted);
	color: var(--csw-text);
	font: inherit;
	font-size: 15px;
	box-shadow: none;
	outline: none;
	transition: box-shadow .15s;
}
.csw-modal .csw-search__input::placeholder { color: #8a8a8a; opacity: 1; }
.csw-modal .csw-search__input:focus { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); }
.csw-modal .csw-search__input::-webkit-search-cancel-button { cursor: pointer; }

.csw-modal .csw-modal__close {
	all: unset;
	flex: none;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	color: #555;
	cursor: pointer;
	transition: background .15s, color .15s;
}
.csw-modal .csw-modal__close:hover { background: var(--csw-muted); color: #000; }
.csw-modal .csw-modal__close:focus-visible { outline: 2px solid var(--csw-accent); }
.csw-modal__close svg { width: 22px; height: 22px; }

/* Популярные */
.csw-modal .csw-popular {
	display: flex;
	flex-wrap: wrap;
	gap: 14px 38px;
	margin: 20px 0 4px;
	padding: 0 16px 0 0;
	list-style: none;
}
.csw-modal .csw-popular li { margin: 0; padding: 0; }
.csw-modal .csw-popular__link {
	color: #111;
	font-size: 18px;
	font-weight: 700;
	text-decoration: none;
	transition: color .15s;
}
.csw-modal .csw-popular__link:hover,
.csw-modal .csw-popular__link.is-current { color: var(--csw-accent); }

/* Список по буквам */
.csw-modal .csw-list {
	flex: 1 1 auto;
	min-height: 0;
	display: grid;
	grid-template-columns: repeat(var(--csw-cols), minmax(0, 1fr));
	align-content: start;
	gap: 30px 0;
	margin-top: 26px;
	padding: 0 12px 16px 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: #b5b5b5 transparent;
}
.csw-modal .csw-list::-webkit-scrollbar { width: 8px; }
.csw-modal .csw-list::-webkit-scrollbar-thumb { background: #b5b5b5; border-radius: 8px; }

.csw-modal .csw-group[hidden],
.csw-modal .csw-group li[hidden] { display: none; }
.csw-modal .csw-group__letter {
	margin: 0 0 12px;
	color: #222;
	font-size: 17px;
	font-weight: 700;
}
.csw-modal .csw-group__items {
	margin: 0;
	padding: 0;
	list-style: none;
}
.csw-modal .csw-group__items li { margin: 0; padding: 0; }
.csw-modal .csw-link {
	display: block;
	margin-left: -8px;
	padding: 7px 8px;
	color: var(--csw-accent);
	font-size: 15px;
	font-weight: 400;
	text-decoration: none;
	transition: background .12s;
}
.csw-modal .csw-link:hover,
.csw-modal .csw-link:focus-visible { background: var(--csw-muted); outline: none; }
.csw-modal .csw-link.is-current { color: var(--csw-text); font-weight: 600; }
.csw-modal .csw-link mark { background: none; color: inherit; font-weight: 700; }

.csw-modal .csw-empty { grid-column: 1 / -1; margin: 0; padding: 8px 0; color: #777; }
.csw-modal .csw-empty[hidden] { display: none; }

/* Режим поиска: популярные прячем */
.csw-modal.is-searching .csw-popular { display: none; }

/* ---------- Карта ---------- */
.csw-map { position: relative; width: 100%; overflow: hidden; border-radius: 8px; }
.csw-map iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Адаптив ---------- */
@media (max-width: 680px) {
	.csw-modal { padding: 0; align-items: flex-end; }
	.csw-modal__dialog {
		width: 100%;
		height: 92vh;
		height: 92dvh;
		padding: 14px 4px 0 16px;
		border-radius: 16px 16px 0 0;
		transform: translateY(40px);
	}
	.csw-modal .csw-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 0; margin-top: 18px; }
	.csw-modal .csw-popular { gap: 10px 22px; margin-top: 16px; }
	.csw-modal .csw-popular__link { font-size: 16px; }
	.csw-modal .csw-search__input { height: 44px; font-size: 16px; } /* 16px — чтобы iOS не зумил */
}
@media (max-width: 360px) {
	.csw-modal .csw-list { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
	.csw-modal__overlay, .csw-modal__dialog, .csw-trigger__arrow { transition: none; }
}
