/* === base.css ===
   Variables, Reset, Typography, Text elements, Debug sections */

[x-cloak] {
	display: none !important;
	/* Critical: Hide elements before Alpine.js is initialized */
}

:root .hidden {
	display: none !important;
}

:root .flex-1 {
	flex: 1;
}

:root .text-accent {
	color: var(--interactive-accent);
}

:root .is-clickable {
	cursor: pointer;
}

:root .mt-0 {
	margin-top: 0;
}

html {
	/* font-size здесь - это значение, которое принимает 1rem. На его основе рассчитываются отступы, размеры панелей и прочее.
	16px — стандарт, который не вызывает агрессивного авто-масштабирования на iOS, но слишком крупный для других устройств */
	font-size: var(--font-size-rem);
	/* Запрет на изменение размера шрифта при повороте экрана или специфических настройках */
	-webkit-text-size-adjust: 100%;
	-moz-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

:root {
	/* Semantic Map for Telegram Compatibility (Legacy support) */
	--tg-bg: var(--tg-theme-bg-color, var(--background-primary));
	--tg-secondary-bg: var(--tg-theme-secondary-bg-color, var(--background-secondary));
	--tg-text: var(--tg-theme-text-color, var(--text-normal));
	--tg-hint: var(--tg-theme-hint-color, var(--text-muted));
	--tg-link: var(--tg-theme-link-color, var(--text-link));
	--tg-button: var(--tg-theme-button-color, var(--interactive-accent));
	--tg-button-text: var(--tg-theme-button-text-color, var(--text-on-accent));
}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	hyphens: none;
}

img {
	max-width: 100%;
	height: auto;
}

/* Выравнивание по центру для абзацев с изображениями */
.screen-content p:has(img:not(.tg-emoji)) {
	text-align: center;
}

/* Контентные изображения и изображения в блоках */
.screen-content img:not(.tg-emoji):not(.att-preview-thumb),
.content-img {
	border-radius: var(--radius-m);
	margin: var(--size-4-2);
	display: inline-block;
	vertical-align: middle;
}

body {
	background-color: var(--background-primary);
	color: var(--text-normal);
	margin: 0;
	padding: 0;
	min-height: 100vh;
}

body,
button,
input,
select,
textarea {
	font-family: var(--font-main);
	line-height: var(--line-height-snug);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
	width: var(--scrollbar-width);
	height: var(--scrollbar-width);
}

::-webkit-scrollbar-track {
	background-color: var(--scrollbar-bg);
	border-radius: var(--scrollbar-radius);
}

::-webkit-scrollbar-thumb {
	background-color: var(--scrollbar-thumb-bg);
	border-radius: var(--scrollbar-radius);
	transition: background-color var(--anim-fast);
}

::-webkit-scrollbar-thumb:hover {
	background-color: var(--scrollbar-active-thumb-bg);
}

h1 {
	font-size: var(--h1-size);
	font-weight: var(--h1-weight);
	color: var(--h1-color);
	margin-top: var(--size-4-6);
	margin-bottom: var(--size-4-3);
	line-height: var(--line-height-tight);
}

h2 {
	font-size: var(--h2-size);
	font-weight: var(--h2-weight);
	color: var(--h2-color);
	margin-top: var(--size-4-5);
	margin-bottom: var(--size-4-2);
}

h3,
.linter-heading {
	font-size: var(--h3-size);
	font-weight: var(--h3-weight);
	color: var(--h3-color);
	margin-top: var(--size-4-5);
	margin-bottom: var(--size-4-2);
}

.heading-icon {
	display: inline-flex;
	align-self: center;
	margin-right: var(--size-4-1);
	width: 1em;
	height: 1em;
	vertical-align: -0.15em;
	color: var(--text-muted);
}

/* Контент экранов */
.screen-content {
	font-size: var(--font-size-paragraph);
	margin-bottom: var(--size-4-6);
	line-height: var(--line-height-loose);
	text-align: left;
	text-indent: 0;
}

.screen-content p,
.screen-content div,
.screen-content li {
	text-indent: 0;
	text-align: left;
}

.screen-content b,
.screen-content strong,
.news-body-text b,
.news-body-text strong,
.bubble-text b,
.bubble-text strong {
	font-weight: var(--font-weight-bold);
	color: inherit;
}

.screen-content em,
.screen-content i,
.news-body-text em,
.news-body-text i,
.bubble-text em,
.bubble-text i {
	font-weight: var(--font-weight-medium);
	color: inherit;
}

/* Выделение ключевых мыслей (жирного и курсива) при включенной настройке */
.highlight-text .screen-content b,
.highlight-text .screen-content strong,
.highlight-text .news-body-text b,
.highlight-text .news-body-text strong,
.highlight-text .bubble-text b,
.highlight-text .bubble-text strong {
	color: var(--text-bold);
}

.highlight-text .screen-content em,
.highlight-text .screen-content i,
.highlight-text .news-body-text em,
.highlight-text .news-body-text i,
.highlight-text .bubble-text em,
.highlight-text .bubble-text i {
	color: var(--text-italic);
}



p {
	color: var(--text-normal);
	font-size: var(--font-size-paragraph);
	line-height: var(--p-line-height);
	margin-bottom: var(--p-margin-bottom);
	text-indent: 0;
	text-align: left;
	hyphens: none;
}

a {
	color: var(--text-link);
	text-decoration: var(--link-decoration);
	font-weight: var(--link-weight);
	transition: opacity 0.15s ease, color 0.15s ease;
}

a:hover {
	opacity: 0.9;
	color: var(--text-link-hover);
}

/* Теги, Упоминания и Даты (Tags, Mentions & Dates) */
.tag,
.mention,
.date-tag {
	display: inline-block;
	color: var(--tag-color);
	background-color: var(--tag-background);
	border: var(--tag-border-width) solid var(--tag-border-color);
	border-radius: var(--tag-radius);
	padding: var(--tag-padding-y) var(--tag-padding-x);
	/*font-size: var(--font-size-paragraph);*/
	font-size: inherit;
	font-weight: var(--tag-weight);
	text-decoration: none;
	line-height: normal;
	transition: background-color var(--anim-fast);
	white-space: nowrap;
}

.tag:hover,
.date-tag:hover {
	background-color: var(--tag-background-hover);
	text-decoration: none;
	color: var(--tag-color);
	opacity: 1;
}

a.tag,
a.mention,
a.date-tag {
	color: var(--tag-color);
	text-decoration: none;
}

a.tag:hover,
a.mention:hover,
a.date-tag:hover {
	color: var(--tag-color);
	opacity: 1;
}

.hint-text {
	color: var(--text-muted);
	font-size: var(--font-content-medium);
	line-height: var(--line-height-snug);
	margin-bottom: var(--size-4-2);
}

.small-label {
	color: var(--text-muted);
	font-size: var(--font-ui-small);
	text-transform: uppercase;
	letter-spacing: 0.036rem;
	font-weight: var(--font-weight-semibold);
	display: flex;
	align-items: center;
	min-height: var(--nav-item-height);
	padding: 0 var(--size-4-5);
}

.workbook-week-header.small-label {
	justify-content: space-between;
	width: 100%;
	box-sizing: border-box;
}

.workbook-week-badge {
	margin-left: auto;
	white-space: nowrap;
}


.error-text {
	color: var(--text-error);
	font-size: var(--font-size-paragraph);
	text-align: center;
	margin-top: var(--size-4-4);
}

/* Иконки Lucide до отрисовки */
[data-lucide] {
	display: inline-block;
	width: var(--rail-icon-size, 1.25rem);
	height: var(--rail-icon-size, 1.25rem);
	background: transparent;
	flex-shrink: 0;
}

[data-lucide]:not(svg) {
	opacity: 0;
	/* Скрываем сырой текст или пустой <i> до замены на SVG */
}

/* Навигация (кнопки) */
.btn-icon {
	width: var(--rail-icon-size, 1.25rem);
	height: var(--rail-icon-size, 1.25rem);
}

.input-relative {
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
}

.input-relative input {
	flex: 1;
	width: 100%;
}

.password-toggle {
	position: absolute;
	right: var(--size-4-3);
	top: 50%;
	transform: translateY(-50%);
	width: auto;
	height: auto;
	margin: 0;
	cursor: pointer;
	color: var(--text-muted);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color var(--anim-fast);
	z-index: var(--z-dropdown);
	background: none;
	border: none;
	padding: 0;
	pointer-events: all;
}

.password-toggle:active {
	transform: translateY(-50%) scale(0.9);
}

.password-field {
	padding-right: 2.857rem;
	/* Увеличиваем отступ справа, чтобы текст не заходил под иконку */
}

.input-relative input[type="password"],
.input-relative input.password-field {
	padding-right: 2.857rem;
	/* ~40px */
}

/* Статусы и оверлеи */
#startup-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	height: 100dvh;
	background-color: var(--background-primary);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: var(--z-overlay);
	/* Поверх всего */
	text-align: center;
	color: var(--text-muted);
	transition: opacity var(--anim-speed) ease, visibility var(--anim-speed) ease;
}

#startup-overlay.hidden {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

#app-status {
	font-weight: var(--font-weight-medium);
	animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {

	0%,
	100% {
		opacity: 1;
	}

	50% {
		opacity: 0.5;
	}
}

.user-badge {
	background-color: var(--background-secondary);
	padding: var(--size-4-3) var(--size-4-4);
	border-radius: var(--container-radius);
	margin-bottom: var(--size-4-6);
	font-size: var(--font-content-medium);
	border: var(--divider-width) solid var(--background-modifier-border);
}

hr {
	border: none;
	border-top: var(--divider-width) solid var(--background-modifier-border);
	margin: var(--size-4-6) 0;
}

/* Оформление текста */
blockquote {
	border-left: var(--quote-border-width) solid var(--quote-border-color);
	background-color: var(--background-modifier-hover);
	margin: var(--size-4-4) 0;
	padding: var(--size-4-2) var(--size-4-5);
	border-radius: var(--radius-s);
	color: var(--text-normal);
	font-style: normal;
	text-indent: 0;
}

blockquote>p:last-child {
	margin-bottom: 0;
}

/* Callouts (Obsidian Standard) */
.callout {
	overflow: hidden;
	margin: var(--size-4-4) 0;
	background-color: var(--callout-background, transparent);
	border: var(--callout-border-width) solid var(--background-modifier-border);
	border-left: var(--callout-border-width-left) solid var(--interactive-accent);
	border-radius: var(--callout-radius);
	mix-blend-mode: var(--callout-blend-mode);
}

.callout-title {
	display: flex;
	align-items: center;
	padding: var(--callout-title-padding);
	gap: var(--size-4-2);
	font-weight: var(--callout-title-weight);
	background-color: var(--callout-title-background);
	color: var(--callout-title-color);
	cursor: default;
	min-height: var(--size-4-8);
}

.callout-title-inner {
	flex: 1;
	font-size: var(--callout-title-size);
}

.callout-content {
	padding: var(--callout-content-padding);
	font-size: var(--font-size-paragraph);
	line-height: var(--p-line-height);
}

/* Collapsible Callout Logic */
.callout.is-collapsible .callout-title {
	cursor: pointer;
}

.callout.is-collapsed .callout-content {
	display: none;
}

/* === Media and Spoilers (Content Blocks) === */
.media-wrapper {
	margin: var(--size-4-4) 0;
	border-radius: var(--container-radius);
	overflow: hidden;
	background: var(--background-secondary);
	border: var(--divider-width) solid var(--background-modifier-border);
}

.media-wrapper img {
	width: 100%;
	display: block;
	max-height: 25rem;
	object-fit: cover;
}

.media-caption {
	padding: var(--size-4-3) var(--size-4-4);
	font-size: var(--font-content-medium);
	color: var(--text-muted);
	border-top: var(--divider-width) solid var(--background-modifier-border);
	line-height: var(--line-height-normal);
}

.ui-spoiler {
	margin: var(--size-4-3) 0;
	background: var(--callout-background, transparent);
	border-radius: var(--callout-radius);
	border: var(--callout-border-width, var(--divider-width)) solid var(--background-modifier-border);
	border-left: var(--callout-border-width-left, var(--size-4-1)) solid var(--interactive-accent);
	overflow: hidden;
}

.ui-spoiler summary {
	padding: var(--callout-title-padding);
	cursor: pointer;
	font-weight: var(--callout-title-weight);
	user-select: none;
	background-color: var(--callout-title-background, transparent);
	color: var(--callout-title-color, var(--text-normal));
	list-style: none;
	font-size: var(--callout-title-size);
	display: flex;
	align-items: center;
	min-height: var(--size-4-8);
}

.ui-spoiler summary::-webkit-details-marker {
	display: none;
}

.ui-spoiler summary::before {
	content: '▼ ';
	/* Using a cleaner arrow */
	font-size: var(--font-content-smaller);
	display: inline-block;
	transition: transform var(--anim-fast);
	margin-right: var(--size-4-2);
	opacity: 0.5;
}

.ui-spoiler[open] summary::before {
	transform: rotate(0);
}

.ui-spoiler:not([open]) summary::before {
	transform: rotate(-90deg);
}

.spoiler-content {
	padding: var(--callout-content-padding);
	border-top: var(--callout-border-width, var(--divider-width)) solid var(--background-modifier-border);
	font-size: var(--font-size-paragraph);
	line-height: var(--p-line-height);
}

/* --- Контентные блоки (Markdown и Logic Render) --- */
.screen-content code,
.news-body-text code,
.bubble-text code {
	background-color: var(--background-secondary);
	padding: 0.15em 0.3em;
	border-radius: var(--radius-s);
	font-family: var(--font-mono);
	font-size: var(--font-content-medium);
	border: var(--divider-width) solid var(--background-modifier-border);
}

.screen-content pre,
.news-body-text pre,
.bubble-text pre {
	display: block;
	padding: var(--size-4-3);
	margin: var(--size-4-3) 0;
	background-color: var(--background-secondary);
	border-radius: var(--radius-m);
	overflow-x: auto;
	font-family: var(--font-mono);
	font-size: var(--font-content-medium);
	line-height: var(--line-height-relaxed);
	border: var(--divider-width) solid var(--background-modifier-border);
	white-space: pre-wrap;
	word-break: break-word;
}

.screen-content pre code,
.news-body-text pre code,
.bubble-text pre code {
	background-color: transparent;
	padding: 0;
	border-radius: 0;
	border: none;
	font-size: inherit;
	color: inherit;
}

ul {
	padding-left: var(--size-4-5);
}

/* Системные стили для списков в контенте экранов (Markdown) */
.screen-content ul,
.screen-content ol {
	padding-left: var(--size-4-5);
	margin-bottom: var(--size-4-4);
}

/* Сближение списка с предшествующим абзацем */
.screen-content p+ul,
.screen-content p+ol {
	margin-top: calc(var(--size-4-1) - var(--p-margin-bottom));
}

.screen-content li {
	margin-bottom: var(--size-4-2);
	line-height: var(--line-height-relaxed);
}

.screen-content li:last-child {
	margin-bottom: 0;
}

/* Статический список */
.bullet-list {
	list-style: none;
	padding: 0 0 0 var(--size-4-6);
	margin: var(--size-4-3) 0 var(--size-4-6) 0;
}

.bullet-list li {
	background: transparent;
	padding: var(--size-4-1) 0;
	margin-bottom: var(--size-4-2);
	border: none;
	font-size: var(--font-size-paragraph);
	color: var(--text-normal);
	line-height: var(--line-height-relaxed);
}

/* Оформление таблиц в контенте (Markdown) */
.screen-content table,
.news-body-text table,
.bubble-text table {
	display: table;
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	margin: var(--size-4-3) 0 var(--size-4-5) 0;
	border: var(--divider-width) solid var(--background-modifier-border);
	border-radius: var(--radius-m);
	overflow: hidden;
}

.screen-content th,
.news-body-text th,
.bubble-text th {
	padding: var(--size-4-2) var(--size-4-4);
	font-weight: var(--font-weight-semibold);
	color: var(--text-normal);
	text-align: left;
	border-bottom: 2px solid var(--background-modifier-border);
	border-right: var(--divider-width) solid var(--background-modifier-border);
	background: var(--interactive-accent-soft);
	word-wrap: break-word;
	overflow-wrap: break-word;
	word-break: break-word;
}

.screen-content td,
.news-body-text td,
.bubble-text td {
	padding: var(--size-4-2) var(--size-4-4);
	border-bottom: var(--divider-width) solid var(--background-modifier-border);
	border-right: var(--divider-width) solid var(--background-modifier-border);
	text-align: left;
	vertical-align: middle;
	word-wrap: break-word;
	overflow-wrap: break-word;
	word-break: break-word;
}

/* Убираем правые границы у последнего столбца */
.screen-content th:last-child,
.news-body-text th:last-child,
.bubble-text th:last-child,
.screen-content td:last-child,
.news-body-text td:last-child,
.bubble-text td:last-child {
	border-right: none;
}

/* Более компактные отступы для таблиц в мессенджере */
.bubble-text th,
.bubble-text td {
	padding: var(--size-4-2) var(--size-4-3);
}

.screen-content tr:last-child td,
.news-body-text tr:last-child td,
.bubble-text tr:last-child td {
	border-bottom: none;
}

/* Кастомные эмодзи внутри текста */
.tg-emoji {
	display: inline-block;
	height: 1.2em;
	width: auto;
	vertical-align: -0.2em;
	margin: 0 0.12em;
	object-fit: contain;
	cursor: default !important;
	/* safe_important */
	pointer-events: none;
	/* Отключаем клики и увеличение */
}

/* Подсветка целевого якоря при переходе по диплинку */
@keyframes anchor-highlight {
	0% {
		background-color: rgba(253, 224, 71, 0.4);
	}

	100% {
		background-color: transparent;
	}
}

.highlighted-anchor {
	animation: anchor-highlight 2s ease-out;
	border-radius: var(--radius-s);
	padding: var(--size-4-1) var(--size-4-2);
}

/* --- Стили для плашки версии PWA и переключателя отладки --- */
.pwa-version-info,
#pwa-version-display,
#pwa-version-sidebar {
	cursor: pointer;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

#pwa-version-display.pwa-version-info--has-update,
#pwa-version-sidebar.pwa-version-info--has-update,
.pwa-version-info.pwa-version-info--has-update {
	color: var(--interactive-accent);
	text-decoration: underline;
}

/* Двухколоночный макет для сопоставлений в задачах */
.exercise-row {
	display: flex;
	flex-wrap: wrap;
	gap: var(--size-4-6, 24px);
	margin-bottom: var(--size-4-4, 16px);
}

.exercise-col {
	flex: 1;
	min-width: 250px; /* Автоматический стек на мобильных экранах */
}