:root {
	/* нейтральная палитра (графит/серый); контраст всех пар текст/фон ≥ 4.5:1 (WCAG AA), проверено расчётом */
	--bg: #f4f4f3;
	--card: #ffffff;
	--text: #1c1c1b;
	--muted: #5c5c58;
	--line: #e2e2df;
	--accent: #2b2b29;
	--on-accent: #ffffff;
	--acc2: #56606b;
	--on-acc2: #ffffff;
	--diff-bg: #ececea;
	--danger: #a3271f;
	--map-ui: #ffffff;
	color-scheme: light;
}
/* тёмная: по системе, если вручную не выбрана светлая; либо вручную */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #141414;
		--card: #1d1d1d;
		--text: #ececea;
		--muted: #a6a6a1;
		--line: #2f2f2e;
		--accent: #e6e6e3;
		--on-accent: #1c1c1b;
		--acc2: #9aa5b1;
		--on-acc2: #151719;
		--diff-bg: #2c2c2b;
		--danger: #f0a29b;
		--map-ui: #1d1d1d;
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #141414;
	--card: #1d1d1d;
	--text: #ececea;
	--muted: #a6a6a1;
	--line: #2f2f2e;
	--accent: #e6e6e3;
	--on-accent: #1c1c1b;
	--acc2: #9aa5b1;
	--on-acc2: #151719;
	--diff-bg: #2c2c2b;
	--danger: #f0a29b;
	--map-ui: #1d1d1d;
	color-scheme: dark;
}
* { box-sizing: border-box; }
/* атрибут hidden всегда скрывает элемент, даже если у класса задан display (иначе не скрывалась плашка об условиях) */
[hidden] { display: none !important; }
body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh; /* видимая высота с учётом выезжающих панелей мобильного браузера */
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	/* viewport-fit=cover: в горизонтальной ориентации отступ не меньше безопасной зоны («чёлки») */
	padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}
a { color: inherit; }

.top, main, .foot { width: 100%; max-width: 760px; margin: 0 auto; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 20px; }
.brand svg { width: 30px; height: 30px; }
.brand circle { fill: var(--accent); }
.brand path { fill: none; stroke: var(--on-accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.tools { display: flex; gap: 8px; }
.lang, .theme {
	border: 1px solid var(--line); background: var(--card); color: var(--text);
	border-radius: 8px; padding: 6px 12px; font: inherit; font-weight: 600; cursor: pointer;
}

main { flex: 1; display: flex; flex-direction: column; gap: 20px; padding-bottom: 32px; }

.meter {
	background: var(--card); border: 1px solid var(--line); border-radius: 18px;
	padding: 28px 20px; display: flex; flex-direction: column; align-items: center; position: relative;
}
.gauge { width: min(100%, 360px); }
.gauge path { fill: none; stroke-width: 14; stroke-linecap: round; }
.gauge .track { stroke: var(--line); }
.gauge .fill { stroke: var(--accent); stroke-dasharray: 0 200; opacity: 0; transition: stroke-dasharray .2s linear; }
.readout { margin-top: -78px; text-align: center; min-height: 110px; }
.value { font-size: 48px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.unit { color: var(--muted); }
.phase { color: var(--muted); font-size: 13px; margin-top: 6px; }
.go {
	margin-top: 18px; min-width: 180px; padding: 13px 28px; border: 0; border-radius: 999px;
	background: var(--accent); color: var(--on-accent); font: inherit; font-size: 17px; font-weight: 700; cursor: pointer;
}
.go:disabled { opacity: .5; cursor: default; }
.go.running { background: transparent; color: var(--text); border: 1px solid var(--line); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
	background: var(--card); border: 1px solid var(--line); border-radius: 14px;
	padding: 14px; display: flex; flex-direction: column;
}
.stat .k { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stat .ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stat .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .u { color: var(--muted); font-size: 12px; }

.servers { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.servers label { color: var(--muted); }
.servers select {
	flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 16px; /* < 16px — iOS Safari увеличивает страницу при фокусе */
	border: 1px solid var(--line); background: var(--card); color: var(--text);
}

.about h2 { font-size: 16px; margin: 8px 0 4px; }
.about p { color: var(--muted); margin: 0; }

.foot {
	display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
	padding: 18px 0 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px;
}

.notfound { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }
.notfound .code { font-size: 72px; font-weight: 800; color: var(--accent); line-height: 1; }
.notfound a { color: var(--accent); font-weight: 600; }

/* блок «Ваше подключение» */
.ipbox {
	background: var(--card); border: 1px solid var(--line); border-radius: 18px;
	padding: 18px 20px; display: flex; flex-direction: column; gap: 12px;
}
.ipbox h2 { font-size: 16px; margin: 0; }
.iphead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); }
.iphead:empty, .ipnote:empty { display: none; }
.iplink { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.ipcards { display: grid; gap: 12px; }
.ipcards.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .ipcards.two { grid-template-columns: 1fr; } }
.ipcard { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.ipaddr { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.ipver { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 6px; color: var(--on-accent); background: var(--accent); }
.ipver6 { background: var(--acc2); color: var(--on-acc2); }
.ipval { font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ipfields { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 4px 12px; margin: 0; }
.ipfields dt { color: var(--muted); }
/* на телефоне подписи не шире 40%: значениям хватает места без разрыва слов */
@media (max-width: 480px) { .ipfields { grid-template-columns: fit-content(40%) minmax(0, 1fr); } }
.ipfields dd { margin: 0; overflow-wrap: break-word; min-width: 0; }
.ipfields dd.diff { background: var(--diff-bg); border-radius: 4px; padding: 0 4px; margin-left: -4px; }
.ipmsg { color: var(--muted); margin: 0; }
.ipnote { margin: 0; font-size: 13px; color: var(--acc2); }
.ipmap { height: 260px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); z-index: 0; }
.ipform label { color: var(--muted); font-size: 13px; }
.iprow { display: flex; gap: 8px; margin-top: 4px; }
.iprow input {
	flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 16px; /* < 16px — iOS Safari увеличивает страницу при фокусе */
	border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.iprow button {
	padding: 10px 16px; border: 0; border-radius: 10px; background: var(--accent); color: var(--on-accent);
	font: inherit; font-weight: 700; cursor: pointer;
}
.iperr { color: var(--danger); font-size: 13px; }
.iperr:empty { display: none; }
.ipsrc { margin: 0; font-size: 12px; color: var(--muted); }
/* элементы поверх карты: тайлы OSM светлые в любой теме, поэтому цвета здесь от темы не зависят */
.ipmap .leaflet-control-attribution {
	background: none; padding: 0 6px 2px; font-size: 10px; line-height: 1.4; color: rgba(28, 28, 27, .7);
	text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 4px #fff;
}
.ipmap .leaflet-control-attribution a { color: inherit; text-decoration: none; }
.ipmap .leaflet-control-attribution a:hover { text-decoration: underline; }
.ipmap .leaflet-bar {
	border: 0; border-radius: 10px; overflow: hidden;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .08);
}
.ipmap .leaflet-bar a {
	width: 30px; height: 30px; line-height: 30px; font-size: 18px; font-weight: 400;
	background: rgba(255, 255, 255, .88); color: #2b2b29; border-bottom: 1px solid rgba(0, 0, 0, .08);
	-webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); transition: background .15s;
}
.ipmap .leaflet-bar a:last-child { border-bottom: 0; }
.ipmap .leaflet-bar a:hover { background: #fff; color: #000; }
.ipmap .leaflet-bar a.leaflet-disabled { color: #b5b5b0; background: rgba(255, 255, 255, .7); }
.ipmap .leaflet-control-zoom { margin: 10px 0 0 10px; }

/* ссылки в подвале */
.foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.foot a:hover { color: var(--text); }

/* плашка об условиях использования */
.consent {
	position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%);
	bottom: calc(12px + env(safe-area-inset-bottom, 0px));
	width: calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)); max-width: 720px;
	display: flex; align-items: center; gap: 12px 16px;
	padding: 12px 14px 12px 18px; border-radius: 14px;
	background: var(--card); color: var(--text); border: 1px solid var(--line);
	box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
}
.consent p { margin: 0; flex: 1; font-size: 14px; }
.consent a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.consent button {
	flex: none; align-self: center; padding: 6px 16px; border: 0; border-radius: 8px; cursor: pointer;
	background: var(--accent); color: var(--on-accent); font: inherit; font-size: 14px; font-weight: 700;
}
@media (max-width: 480px) { .consent { gap: 12px; padding: 10px 10px 10px 14px; } .consent p { font-size: 13px; } }
/* пока плашка видна, низ страницы не прячется под ней */
body.has-consent { padding-bottom: calc(var(--consent-h, 64px) + 24px + env(safe-area-inset-bottom, 0px)); }
body.consent-away .consent { display: none; }

/* страница условий */
.terms { max-width: 760px; }
.terms h1 { font-size: 24px; margin: 8px 0 4px; }
.terms h2 { font-size: 17px; margin: 22px 0 6px; }
.terms p, .terms li { color: var(--text); }
.terms .upd { color: var(--muted); font-size: 13px; margin-top: 0; }
.terms ul { padding-left: 20px; }
.terms li { margin: 4px 0; }
.terms a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.terms code { font-size: 13px; background: var(--diff-bg); border-radius: 4px; padding: 0 4px; }
.terms [lang] { display: none; }
html[lang="ru"] .terms [lang="ru"], html[lang="en"] .terms [lang="en"] { display: block; }
