/* Общий стиль всех страниц. Цвета — только через переменные. */
/* По умолчанию тёмная тема (решение Макса); светлая — по выбору или «Авто» при светлой системе. */
:root {
	--bg: #141414; --card: #1f1f1f; --fg: #ececec; --mute: #9a9a9a;
	--line: #333; --accent: #e6e6e6; --accent-fg: #141414; --tile: #2a2a2a;
	color-scheme: dark;
	font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-text-size-adjust: 100%;
}
:root[data-theme="light"] {
	--bg: #f2f2f2; --card: #fff; --fg: #1c1c1c; --mute: #6e6e6e;
	--line: #dcdcdc; --accent: #1c1c1c; --accent-fg: #fff; --tile: #e0e0e0;
	color-scheme: light;
}
@media (prefers-color-scheme: light) {
	:root[data-theme="system"] {
		--bg: #f2f2f2; --card: #fff; --fg: #1c1c1c; --mute: #6e6e6e;
		--line: #dcdcdc; --accent: #1c1c1c; --accent-fg: #fff; --tile: #e0e0e0;
		color-scheme: light;
	}
}

*, *::before, *::after { box-sizing: border-box; }
body {
	margin: 0; background: var(--bg); color: var(--fg);
	display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh;
}
header.top, main, footer {
	width: 100%;
	max-width: 720px;
	margin: 0 auto;
	padding-left: max(16px, env(safe-area-inset-left));
	padding-right: max(16px, env(safe-area-inset-right));
}
a { color: var(--accent); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 8px 0; }
h2 { font-size: 1.2rem; margin: 32px 0 8px; }
h3 { font-size: 1rem; margin: 16px 0 4px; }

/* Шапка */
header.top {
	/* слева «Домой», по центру название (сайта на главной, иначе — страницы), справа шестерёнка */
	display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px;
	padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 12px;
}
/* длинное название (например, «Приватный браузер: Loopius») на узком экране переносится на вторую строку */
.title { justify-self: center; max-width: 100%; overflow: hidden; text-align: center; line-height: 1.2; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 22px; font-weight: 600; }
/* у приложений название со значком — одна ссылка на App Store, при наведении подсвечивается */
a.title.app {
	display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 14px 6px 8px;
	border-radius: 18px; color: var(--fg); text-decoration: none;
}
a.title.app:hover { background: var(--card); }
a.title.app img { flex: none; width: 32px; height: 32px; border-radius: 8px; }
a.title.app span { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
/* на узком экране значок и название чуть меньше, иначе не помещаются между кнопками */
@media (max-width: 440px) {
	header.top:has(a.title.app) { gap: 4px; }
	header.top:has(a.title.app) .to-home, header.top:has(a.title.app) .menu summary { min-width: 50px; }
	a.title.app { gap: 7px; padding: 6px; }
	a.title.app img { width: 28px; height: 28px; }
	a.title.app span { font-size: min(18px, 4.6vw); }
}

.to-home, .menu summary {
	display: inline-flex; align-items: center; justify-content: center; min-width: 66px; min-height: 66px;
	border-radius: 18px; color: var(--fg); text-decoration: none;
}
a.to-home:hover, .menu summary:hover, .menu[open] summary { background: var(--card); }

/* Меню-шестерёнка */
.menu { position: relative; justify-self: end; }
.menu summary { padding: 0; cursor: pointer; list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu .panel {
	position: absolute; right: 0; z-index: 2; margin-top: 6px; padding: 8px; width: min(260px, calc(100vw - 32px));
	background: var(--card); border: 1px solid var(--line); border-radius: 16px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
}
.menu .panel { text-align: center; }
.menu .label { margin: 8px 8px 4px; font-size: 13px; color: var(--mute); }
.menu .item {
	display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 10px;
	border-radius: 10px; color: var(--fg); text-decoration: none;
}
.menu .item:hover { background: var(--bg); }
.menu .item[aria-current] { background: var(--bg); font-weight: 600; }
.menu .mail { margin-top: 6px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; color: var(--accent); }
.seg { display: flex; gap: 2px; padding: 2px; background: var(--bg); border-radius: 12px; }
.seg button {
	flex: 1; min-height: 40px; border: 0; border-radius: 10px; background: none;
	font: inherit; font-size: 15px; color: var(--fg); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }

/* Заголовок инструмента со значком справки «?» */
.head { position: relative; min-height: 44px; margin-bottom: 16px; }
.head.with-help { padding: 0 52px; }
.help summary {
	position: absolute; top: 0; right: 0; width: 44px; height: 44px;
	display: flex; align-items: center; justify-content: center; list-style: none; cursor: pointer;
	border-radius: 50%; color: var(--mute); font-weight: 600; font-size: 18px; box-shadow: inset 0 0 0 1.5px var(--line);
}
.help summary::-webkit-details-marker { display: none; }
.help summary:hover, .help[open] summary { color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.help .card { margin: 12px -52px 16px 0; }
.help h2:first-child { margin-top: 0; }

/* Главная: ссылки на инструменты по центру экрана */
main.home { flex: 1; display: flex; align-items: center; justify-content: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cards { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 12px; }
/* каталог — столбиком, кнопки одной ширины: фон как у страницы, жирная рамка цвета текста; при наведении — серее */
main.home .cards { flex-direction: column; width: min(340px, 100%); }
main.tool { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; }
button.button { border: 0; cursor: pointer; }
.button.big {
	align-self: center; justify-content: center; min-width: 220px; min-height: 120px; padding: 0 48px;
	font-size: clamp(32px, 9vw, 48px); border-radius: 32px;
}
main.home a.card { justify-content: center; min-height: 65px; padding: 0 24px; font-size: clamp(24px, 6vw, 28px); background: var(--bg); border: 1.5px solid var(--fg); }
main.home a.card:hover { background: var(--tile); border-color: var(--fg); }
/* значок приложения слева, название остаётся по центру */
main.home a.card { position: relative; }
main.home a.card .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 9px; }
a.card {
	display: flex; align-items: center; min-height: 56px; margin: 0; padding: 0 24px;
	color: var(--fg); text-decoration: none; font-weight: 600; border: 1px solid var(--line);
}

/* Карточки и формы */
.card { background: var(--card); border-radius: 20px; padding: 16px; margin: 0 0 16px; }
a.card:hover { border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; color: var(--mute); font-size: 15px; }
input, select, button { font: inherit; font-size: 16px; color: var(--fg); }
input, select {
	min-height: 44px; width: 100%; padding: 0 12px; margin: 0;
	background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
input[type="date"] { -webkit-appearance: none; appearance: none; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--accent); }
label.check { flex-direction: row; align-items: center; gap: 10px; min-height: 44px; color: var(--fg); }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row > label { flex: 1 1 140px; }
.row > label.narrow { flex: 0 0 72px; }
.button {
	display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px;
	border-radius: 12px; background: var(--accent); color: var(--accent-fg); text-decoration: none; font-weight: 600;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

footer { text-align: center; color: var(--mute); font-size: 15px; padding-top: 32px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
footer p { margin: 4px 0; }

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; animation: none !important; }
}

[hidden] { display: none !important; }
.result { display: block; margin-top: 12px; color: var(--mute); }
.result b { display: block; font-size: 2rem; line-height: 1.2; color: var(--fg); }
.result span { display: block; }
.card h2 { margin-top: 0; }

/* Суперэллипс (непрерывные углы, как в iOS) там, где браузер умеет corner-shape.
   Скругления крупнее: у суперэллипса при том же радиусе угол визуально острее.
   Остальные браузеры показывают обычные скругления выше. */
@supports (corner-shape: squircle) {
	.seg, input, select, .button { border-radius: 20px; corner-shape: squircle; }
	.to-home, .menu summary, a.title.app { border-radius: 28px; corner-shape: squircle; }
	a.title.app img { border-radius: 10px; corner-shape: squircle; }
	.menu .item, .seg button { border-radius: 17px; corner-shape: squircle; }
	.menu .mail { border-radius: 0 0 17px 17px; }
	.menu .panel { border-radius: 28px; corner-shape: squircle; }
	.card { border-radius: 34px; corner-shape: squircle; }
	main.home a.card .icon { border-radius: 12px; corner-shape: squircle; }
	.button.big { border-radius: 48px; }
}
