:root {
	--bg: var(--tg-theme-bg-color, #ffffff);
	--text: var(--tg-theme-text-color, #222222);
	--hint: var(--tg-theme-hint-color, #999999);
	--button: var(--tg-theme-button-color, #2481cc);
	--button-text: var(--tg-theme-button-text-color, #ffffff);
	--secondary-bg: var(--tg-theme-secondary-bg-color, #f2f2f2);
	/* единая высота элементов управления: поле промокода и кнопка рядом */
	--control-height: 44px;
}

* {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	padding: 16px 16px 96px;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	/* страница не должна «уезжать» вбок при фокусе на поле ввода */
	overflow-x: hidden;
}

h1 {
	font-size: 20px;
	margin-bottom: 16px;
}

.hidden {
	/* !important: правила ниже (.overlay, .action-bar, .summary .row и т.п.)
	   задают display и иначе перебивали бы скрытие по порядку в файле */
	display: none !important;
}

.tariff-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.tariff-card {
	background: var(--secondary-bg);
	border-radius: 12px;
	padding: 16px;
}

.tariff-card .name {
	font-size: 17px;
	font-weight: 600;
	margin-bottom: 4px;
}

.tariff-card .price {
	font-size: 22px;
	font-weight: 700;
	color: var(--button);
	margin-bottom: 8px;
}

.tariff-card .duration {
	color: var(--hint);
	font-size: 13px;
	margin-bottom: 8px;
}

.tariff-card .chats {
	font-size: 13px;
	color: var(--hint);
	margin-bottom: 8px;
}

.tariff-card .description {
	font-size: 14px;
	margin-bottom: 12px;
}

.tariff-card.current {
	border: 2px solid var(--button);
}

.select-btn {
	width: 100%;
	padding: 10px;
	border: none;
	border-radius: 8px;
	background: var(--button);
	color: var(--button-text);
	font-size: 15px;
	font-weight: 600;
}

.summary {
	background: var(--secondary-bg);
	border-radius: 12px;
	padding: 12px 16px;
	margin-bottom: 16px;
}

.summary .row {
	display: flex;
	justify-content: space-between;
	padding: 6px 0;
	font-size: 14px;
}

.summary .row.total {
	font-weight: 700;
	font-size: 17px;
	border-top: 1px solid var(--hint);
	margin-top: 4px;
	padding-top: 10px;
}

#promo-input {
	/* flex: поле занимает остаток строки и может сжиматься */
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	height: var(--control-height);
	margin-bottom: 0;
	padding: 0 12px;
	border-radius: 10px;
	border: 1px solid var(--hint);
	background: var(--bg);
	color: var(--text);
	/* 16px: при меньшем размере iOS/WebView зумит страницу при фокусе */
	font-size: 16px;
	font-family: inherit;
	line-height: normal;
	appearance: none;
	-webkit-appearance: none;
}

#promo-input:focus {
	outline: none;
	border-color: var(--button);
}

.secondary-btn {
	width: 100%;
	padding: 10px;
	border-radius: 8px;
	border: 1px solid var(--hint);
	background: transparent;
	color: var(--text);
	font-size: 14px;
	margin-bottom: 12px;
}

.method-select {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 16px;
}

.method-btn {
	padding: 12px;
	border: none;
	border-radius: 8px;
	background: var(--button);
	color: var(--button-text);
	font-size: 15px;
	font-weight: 600;
}

.history-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.history-item {
	background: var(--secondary-bg);
	border-radius: 10px;
	padding: 12px;
	font-size: 14px;
}

.history-item .status-paid {
	color: #2ecc71;
}

.history-item .status-pending {
	color: #e67e22;
}

.legal-links {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 20px;
	padding-top: 12px;
	border-top: 1px solid var(--hint);
}

.legal-links .legal-title {
	font-size: 13px;
	color: var(--hint);
}

.legal-links a {
	color: var(--button);
	font-size: 14px;
	text-decoration: none;
}

.method-btn:disabled {
	opacity: 0.5;
}

.notice {
	background: var(--secondary-bg);
	border-radius: 12px;
	padding: 16px;
	font-size: 14px;
	color: var(--hint);
	line-height: 1.4;
}

/* заголовок экрана оплаты */
.view-head {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 12px;
}

.view-head h1 {
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.icon-btn {
	border: none;
	background: var(--secondary-bg);
	color: var(--button);
	border-radius: 10px;
	padding: 8px 12px;
	font-size: 14px;
	white-space: nowrap;
}

/* баннер активной подписки */
.banner {
	border-radius: 12px;
	padding: 12px 14px;
	font-size: 13px;
	line-height: 1.4;
	margin-bottom: 14px;
	background: var(--secondary-bg);
	color: var(--hint);
}

.banner.active {
	background: rgba(46, 204, 113, 0.14);
	color: #2ecc71;
	font-weight: 600;
}

/* карточки тарифов */
.tariff-card {
	position: relative;
	border: 2px solid transparent;
	transition: border-color 0.15s ease, transform 0.1s ease;
}

.tariff-card.current {
	border-color: var(--button);
}

.card-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 10px;
	margin-bottom: 4px;
}

.card-head .duration {
	font-size: 12px;
	color: var(--hint);
	background: var(--bg);
	border-radius: 20px;
	padding: 4px 10px;
	white-space: nowrap;
}

.prices {
	display: flex;
	align-items: baseline;
	gap: 10px;
	margin: 4px 0 10px;
}

.prices .price {
	font-size: 24px;
	font-weight: 700;
	color: var(--button);
}

.prices .stars {
	font-size: 15px;
	font-weight: 600;
	color: var(--hint);
}

.tariff-card .description {
	opacity: 0.85;
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 10px;
}

.chats-label {
	font-size: 12px;
	color: var(--hint);
	margin-bottom: 6px;
}

.method-btn .method-title {
	font-weight: 600;
}

.chip {
	font-size: 12px;
	color: var(--hint);
	background: var(--bg);
	border-radius: 20px;
	padding: 4px 10px;
}

.select-mark {
	text-align: center;
	font-size: 14px;
	font-weight: 600;
	color: var(--button);
	border: 1px solid var(--button);
	border-radius: 10px;
	padding: 9px;
}

/* фон карточки тарифа: затемнение сверху, чтобы текст читался на тёмных фото */
.tariff-card.has-bg {
	background-image: linear-gradient(rgba(10, 12, 18, 0.58), rgba(10, 12, 18, 0.8)), var(--card-bg);
	background-size: cover;
	background-position: center;
	color: #ffffff;
}

.tariff-card.has-bg .name,
.tariff-card.has-bg .prices .price {
	color: #ffffff;
}

.tariff-card.has-bg .prices .stars {
	color: rgba(255, 255, 255, 0.78);
}

.tariff-card.has-bg .duration,
.tariff-card.has-bg .description,
.tariff-card.has-bg .chats-label,
.tariff-card.has-bg .chips .chip {
	color: rgba(255, 255, 255, 0.9);
}

.tariff-card.has-bg .duration,
.tariff-card.has-bg .chips .chip {
	background: rgba(255, 255, 255, 0.16);
}

.tariff-card.has-bg .select-mark {
	color: #ffffff;
	border-color: rgba(255, 255, 255, 0.7);
	background: rgba(255, 255, 255, 0.08);
}

.summary .row.discount {
	color: #2ecc71;
	font-weight: 600;
}

/* промокод */
.promo {
	margin-bottom: 16px;
}

.promo-line {
	display: flex;
	align-items: stretch;
	gap: 8px;
	min-width: 0;
}

.secondary-btn.compact {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: auto;
	height: var(--control-height);
	margin-bottom: 0;
	padding: 0 14px;
	font-family: inherit;
	font-size: 15px;
	white-space: nowrap;
}

.promo-status {
	min-height: 18px;
	font-size: 13px;
	margin-top: 6px;
	color: var(--hint);
}

.promo-status.ok {
	color: #2ecc71;
}

.promo-status.error {
	color: #e74c3c;
}

/* способы оплаты */
.method-btn {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	text-align: left;
}

.method-btn .method-price {
	font-size: 14px;
	opacity: 0.92;
}

.method-btn.card {
	background: var(--secondary-bg);
	color: var(--text);
	border: 1px solid var(--hint);
}

/* режим подарка */
.gift-toggle {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	margin-bottom: 14px;
	padding: 12px 14px;
	border: 2px solid transparent;
	border-radius: 12px;
	background: var(--secondary-bg);
	color: var(--text);
	text-align: left;
	font-family: inherit;
}

.gift-toggle .gift-icon {
	font-size: 22px;
	line-height: 1;
}

.gift-toggle .gift-text {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.gift-toggle .gift-title {
	font-size: 15px;
	font-weight: 600;
}

.gift-toggle .gift-hint {
	font-size: 12px;
	color: var(--hint);
	line-height: 1.3;
}

.gift-toggle .gift-check {
	font-size: 16px;
	font-weight: 700;
	color: var(--hint);
	opacity: 0.35;
}

.gift-toggle.active {
	border-color: var(--button);
}

.gift-toggle.active .gift-check {
	color: var(--button);
	opacity: 1;
}

.gift-note {
	font-size: 13px;
	line-height: 1.4;
	color: #2ecc71;
	margin: -6px 0 14px;
}

/* нижняя панель с выбранным тарифом */
.action-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
	background: var(--bg);
	border-top: 1px solid var(--secondary-bg);
	box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
	z-index: 20;
}

.action-info {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.action-info span:first-child {
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.action-price {
	font-size: 12px;
	color: var(--hint);
}

.primary-btn {
	flex: 1;
	padding: 12px 16px;
	border: none;
	border-radius: 10px;
	background: var(--button);
	color: var(--button-text);
	font-size: 15px;
	font-weight: 600;
}

/* оверлей со статусом операции */
.overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	z-index: 50;
}

.overlay-card {
	width: 100%;
	max-width: 320px;
	background: var(--bg);
	border-radius: 16px;
	padding: 22px 18px;
	text-align: center;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.overlay-icon {
	font-size: 40px;
	margin-bottom: 8px;
}

.overlay-text {
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
}

.overlay-hint {
	font-size: 13px;
	color: var(--hint);
	margin-top: 8px;
	line-height: 1.4;
}

.overlay-card .secondary-btn {
	margin-top: 16px;
	margin-bottom: 0;
}

.spinner {
	width: 34px;
	height: 34px;
	margin: 0 auto 12px;
	border: 3px solid var(--secondary-bg);
	border-top-color: var(--button);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}
