/* ==========================================================================
   FIRECOMMENDS — mobile layer
   Подключается последним после theme/theme-toc/fire-minimal/admin.
   Все правила спрятаны в media queries, десктоп не затрагивается.
   ========================================================================== */

@media (max-width: 768px) {

	/* ---------- База ---------- */
	html {
		-webkit-text-size-adjust: 100%;
		text-size-adjust: 100%;
	}
	html,
	body {
		max-width: 100%;
		overflow-x: hidden;
	}
	body {
		overflow-wrap: break-word;
	}
	h1, h2, h3, h4 {
		overflow-wrap: anywhere;
	}
	img, svg, video {
		max-width: 100%;
	}

	/* ---------- Верхнее меню (toc-страницы) ---------- */
	.toc-nav-inner {
		padding: 0.5rem 0.9rem;
		gap: 0.6rem;
	}
	.toc-nav-brand {
		gap: 0.45rem;
		min-width: 0;
	}
	.toc-nav-brand img {
		width: 30px;
		height: 30px;
	}
	.toc-nav-brand .toc-callsign {
		font-size: 0.55rem;
		letter-spacing: 0.13em;
	}
	.toc-nav-brand .toc-name {
		font-size: 0.9rem;
	}
	.toc-nav-toggle {
		width: 42px;
		height: 42px;
		border-radius: 10px;
		flex-shrink: 0;
	}

	/* Выпадающее мобильное меню: фиксируем под шапкой и анимируем */
	.toc-nav-actions {
		position: fixed !important;
		top: 56px;
		left: 0;
		right: 0;
		z-index: 95;
		display: flex;
		flex-direction: column;
		align-items: stretch;
		gap: 0.55rem;
		padding: 1rem 0.95rem 1.2rem !important;
		background: rgba(11, 15, 19, 0.98) !important;
		-webkit-backdrop-filter: blur(14px);
		backdrop-filter: blur(14px);
		border-bottom: 1px solid var(--bd-1);
		max-height: calc(100vh - 56px);
		max-height: calc(100dvh - 56px);
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		transform: translateY(-8px);
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
	}
	.toc-nav-actions.open,
	.toc-nav-actions.is-open {
		transform: none;
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
	}
	.toc-nav-actions .btn {
		width: 100%;
		min-height: 46px;
	}
	.toc-nav-actions .toc-nav-link {
		padding: 0.75rem 0.9rem;
		border-bottom: 1px solid var(--bd-1);
	}
	.toc-nav-actions .toc-lang {
		justify-content: center;
	}
	.toc-lang button,
	.lang-switch button {
		min-width: 44px;
		min-height: 40px;
	}
	.toc-nav-actions .toc-status-pulse {
		align-self: center;
	}

	/* ---------- Hero ---------- */
	.toc-hero {
		min-height: auto;
		padding: 2.6rem 1rem 2.2rem !important;
	}
	.toc-hero-content {
		max-width: 100%;
	}
	.toc-hero-meta {
		font-size: 0.56rem;
		letter-spacing: 0.1em;
		line-height: 1.6;
		padding: 0.4rem 0.75rem;
		text-align: center;
	}
	.toc-hero h1 {
		font-size: clamp(1.8rem, 8.4vw, 2.55rem) !important;
		line-height: 1.1 !important;
		letter-spacing: -0.03em;
		margin-top: 0.9rem;
	}
	.toc-hero-desc {
		font-size: 0.93rem;
		line-height: 1.6;
		margin-top: 0.9rem;
	}
	.toc-trustline {
		font-size: 0.6rem !important;
		letter-spacing: 0.05em;
		line-height: 1.8;
	}
	.toc-hero-actions {
		display: flex;
		flex-direction: column;
		gap: 0.6rem;
		margin-top: 1.4rem;
	}
	.toc-hero-actions .btn {
		width: 100%;
	}
	.toc-hero-stats {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
		gap: 1px;
		margin-top: 1.5rem;
	}
	.toc-stat-tile {
		padding: 0.85rem 0.35rem;
	}
	.toc-stat-tile .v {
		font-size: 1.35rem;
	}
	.toc-stat-tile .l {
		font-size: 0.56rem;
		letter-spacing: 0.04em;
		margin-top: 0.3rem;
	}

	/* ---------- Секции ---------- */
	.toc-section {
		padding: 2.2rem 1rem !important;
	}
	.toc-section-head {
		margin-bottom: 1.5rem !important;
	}
	.toc-section-head .toc-label {
		font-size: 0.56rem;
		letter-spacing: 0.12em;
	}
	.toc-section-head h2 {
		font-size: clamp(1.4rem, 6vw, 1.85rem);
		line-height: 1.2;
	}
	.toc-section-head p {
		font-size: 0.87rem;
		line-height: 1.55;
	}

	/* ---------- Сетки карточек ---------- */
	.toc-ops-grid {
		grid-template-columns: 1fr !important;
		gap: 0.7rem;
	}
	.toc-op {
		padding: 1.25rem 1rem;
		gap: 0.6rem;
	}
	.toc-op h3 {
		font-size: 1.1rem;
	}
	.toc-op p {
		font-size: 0.85rem;
	}
	.toc-op-foot {
		font-size: 0.66rem;
	}
	.toc-cap-grid {
		grid-template-columns: 1fr !important;
	}
	.toc-cap {
		padding: 1.15rem 1rem;
	}
	.toc-reviews {
		grid-template-columns: 1fr !important;
		gap: 0.8rem;
	}

	/* ---------- Промо-блок ---------- */
	.toc-promo {
		padding: 1.7rem 1rem !important;
		border-radius: 16px;
	}
	.toc-promo h2 {
		font-size: clamp(1.35rem, 5.6vw, 1.8rem);
		line-height: 1.2;
	}
	.toc-promo p {
		font-size: 0.88rem;
		line-height: 1.55;
	}
	.toc-promo-actions {
		flex-direction: column;
		gap: 0.55rem;
	}
	.toc-promo-actions .btn {
		width: 100%;
	}

	/* ---------- FAQ ---------- */
	.toc-faq {
		gap: 0.4rem;
	}
	.toc-faq-item summary {
		padding: 0.85rem 0.9rem !important;
		font-size: 0.88rem;
		line-height: 1.5;
		padding-right: 2.2rem !important;
	}
	.toc-faq-item p {
		padding: 0 0.9rem 1rem !important;
		font-size: 0.85rem;
		line-height: 1.6;
	}

	/* ---------- Подвал ---------- */
	.toc-footer {
		padding: 2rem 1rem 1.5rem !important;
	}
	.toc-footer-grid {
		grid-template-columns: 1fr 1fr !important;
		gap: 1.3rem 1rem !important;
	}
	.toc-footer-col strong {
		font-size: 0.62rem;
	}
	.toc-footer-col a {
		display: inline-block;
		padding: 0.25rem 0;
		font-size: 0.8rem;
		line-height: 1.5;
	}
	.toc-footer-bottom {
		margin-top: 1.4rem !important;
		padding-top: 1rem !important;
		flex-direction: column;
		gap: 0.35rem;
		text-align: center;
		font-size: 0.64rem;
		line-height: 1.6;
	}

	/* ---------- Логин / регистрация ---------- */
	.toc-login-main {
		padding: 1.2rem 0.75rem 2rem !important;
		align-items: flex-start;
	}
	.toc-login-card {
		max-width: 100% !important;
	}
	.toc-login-header {
		padding: 1.2rem 1rem !important;
	}
	.toc-login-body {
		padding: 1.1rem !important;
	}
	.toc-login-card .toc-label {
		font-size: 0.55rem;
		letter-spacing: 0.1em;
	}
	.auth-tabs {
		gap: 0.25rem;
		padding: 0.2rem;
	}
	.auth-tabs button {
		padding: 0.7rem 0.4rem;
		font-size: 0.82rem;
	}

	/* ---------- Формы и кнопки (общее) ---------- */
	input[type="text"],
	input[type="email"],
	input[type="password"],
	input[type="number"],
	input[type="search"],
	input[type="tel"],
	select,
	textarea,
	.input {
		font-size: 16px !important; /* iOS не зумит при фокусе */
		min-height: 46px;
	}
	.btn {
		min-height: 46px;
	}
	.btn-sm {
		min-height: 40px;
	}
	.btn-lg {
		padding: 0.9rem 1.1rem;
	}
	.form-row,
	.field-row {
		grid-template-columns: 1fr !important;
	}

	/* ---------- Модальные окна ---------- */
	.modal {
		padding: 0.7rem;
	}
	.modal-card {
		max-width: 100%;
		padding: 1.25rem 1rem;
		max-height: calc(100vh - 1.4rem);
		max-height: calc(100dvh - 1.4rem);
		overflow-y: auto;
		border-radius: 16px;
	}
	.modal-head h3 {
		font-size: 1rem;
	}

	/* ---------- Тосты ---------- */
	.toast {
		left: 10px;
		right: 10px;
		max-width: none;
	}

	/* ---------- Пакеты / покупка ---------- */
	.pkg-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 0.55rem;
	}
	.pkg-card {
		padding: 0.9rem 0.5rem;
	}
	.pkg-amount {
		font-size: 1.45rem;
	}
	.pkg-unit {
		font-size: 0.58rem;
	}

	/* ---------- Кабинет ---------- */
	.page-main {
		padding: 1rem 0.8rem 2.2rem !important;
	}
	.nav-inner {
		padding: 0.5rem 0.9rem;
	}
	.nav-actions {
		max-height: calc(100vh - 60px);
		max-height: calc(100dvh - 60px);
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		z-index: 45;
	}
	.grid {
		gap: 0.85rem;
	}
	.card {
		padding: 1rem !important;
		border-radius: 14px;
	}
	.card h2 {
		font-size: 1.05rem;
	}
	.statusbar {
		padding: 0.7rem 0.8rem;
		gap: 0.45rem;
		border-radius: 12px;
	}
	.statusbar .st-left {
		font-size: 0.85rem;
	}
	.statusbar .st-right {
		margin-left: 0;
		width: 100%;
		gap: 0.6rem;
		font-size: 0.7rem;
	}
	.type-chip {
		flex: 1 1 calc(50% - 0.35rem);
		justify-content: center;
		min-height: 46px;
		padding: 0.6rem 0.5rem;
		font-size: 0.8rem;
	}
	.profile-preview {
		align-items: flex-start;
	}
	.profile-preview .avatar {
		width: 38px;
		height: 38px;
	}
	.profile-preview .commends-line {
		font-size: 0.74rem;
	}
	.server-card code {
		font-size: 0.68rem;
		padding: 0.45rem 0.55rem;
	}
	.tx-table {
		font-size: 0.78rem;
		min-width: 520px;
	}
	.tx-table th,
	.tx-table td {
		padding: 0.55rem 0.6rem;
		white-space: nowrap;
	}
	.balance-chip {
		font-size: 0.72rem;
	}
	.pager button {
		min-width: 38px;
		min-height: 38px;
	}

	/* ---------- Админка ---------- */
	#adminPanel > nav {
		height: auto;
		padding: 8px 12px !important;
		flex-wrap: wrap;
		gap: 8px;
	}
	#adminPanel > nav .font-bold.text-lg {
		font-size: 0.9rem !important;
	}
	#adminPanel > nav span.rounded-full:not(#maintenanceBadge) {
		display: none !important; /* бейдж ADMIN на телефоне не нужен */
	}
	#liveIndicator,
	#headerBotCount {
		display: none !important;
	}
	#adminPanel > nav .flex.items-center.gap-4 {
		gap: 0.5rem !important;
	}
	#hitlBellBtn {
		min-width: 40px;
		min-height: 40px;
	}
	#adminPanel .flex.flex-1.min-h-0 {
		flex-direction: column !important;
	}
	#adminPanel aside {
		width: 100% !important;
		border-right: 0 !important;
		border-bottom: 1px solid var(--ad-bd-1) !important;
		padding: 8px !important;
		overflow-x: auto !important;
		overflow-y: hidden !important;
		-webkit-overflow-scrolling: touch;
	}
	#sidebarNav {
		flex-direction: row !important;
		flex-wrap: nowrap !important;
		gap: 6px !important;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		padding-bottom: 2px;
	}
	#sidebarNav .nav-btn {
		white-space: nowrap;
		flex: 0 0 auto;
		font-size: 0.8rem;
		padding: 0.55rem 0.75rem;
		min-height: 44px;
	}
	#sectionRoot {
		padding: 12px !important;
		min-height: 0;
	}
	#sectionRoot table {
		font-size: 0.78rem;
	}
	.log-viewer {
		height: 60vh;
	}
	#adminPanel .modal .modal-card,
	#modalContent {
		max-width: 100% !important;
	}

	/* ---------- HITL ---------- */
	.hitl-wrap,
	.hitl-page {
		padding: 0 0.85rem !important;
	}
}

/* Узкие телефоны */
@media (max-width: 400px) {
	.toc-hero h1 {
		font-size: clamp(1.6rem, 8.8vw, 2.1rem) !important;
	}
	.toc-section {
		padding-left: 0.8rem !important;
		padding-right: 0.8rem !important;
	}
	.toc-footer-grid {
		grid-template-columns: 1fr !important;
		gap: 1.1rem !important;
	}
	.pkg-grid {
		grid-template-columns: 1fr 1fr !important;
	}
	.toc-stat-tile .v {
		font-size: 1.15rem;
	}
	.type-chip {
		flex-basis: 100%;
	}
}

/* Планшеты: чуть плотнее, но без мобильной раскладки */
@media (min-width: 769px) and (max-width: 1024px) {
	.toc-section {
		padding-left: 1.5rem;
		padding-right: 1.5rem;
	}
}