/* ============================================
   СИСТЕМА ТЕМ — Пользовательские CSS-свойства
   ============================================ */
:root {
    /* Светлая тема (по умолчанию) */
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f9fafb;
    --bg-modal-overlay: rgba(0, 0, 0, 0.5);

    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --border-color: #e5e7eb;
    --border-light: #f3f4f6;

    --accent-primary: #4f46e5;
    --accent-secondary: #6366f1;
    --accent-hover: #4338ca;

    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Тёмная тема */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --bg-modal-overlay: rgba(0, 0, 0, 0.75);

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --border-color: #475569;
    --border-light: #334155;

    --accent-primary: #818cf8;
    --accent-secondary: #a5b4fc;
    --accent-hover: #6366f1;

    --success: #4ade80;
    --error: #f87171;
    --warning: #fbbf24;
    --info: #60a5fa;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.5);
}

/* Высококонтрастная тема */
[data-theme="high-contrast"] {
    --bg-primary: #000000;
    --bg-secondary: #000000;
    --bg-card: #000000;
    --bg-input: #1a1a1a;
    --bg-modal-overlay: rgba(0, 0, 0, 0.9);

    --text-primary: #ffffff;
    --text-secondary: #ffffff;
    --text-muted: #cccccc;

    --border-color: #ffffff;
    --border-light: #666666;

    --accent-primary: #ffff00;
    --accent-secondary: #00ffff;
    --accent-hover: #ffff00;

    --success: #00ff00;
    --error: #ff0000;
    --warning: #ffff00;
    --info: #00ffff;

    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
}

body {
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Применить цвета темы к ключевым элементам */
[data-theme="dark"] header,
[data-theme="high-contrast"] header {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] #card,
[data-theme="high-contrast"] #card {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

[data-theme="dark"] footer,
[data-theme="high-contrast"] footer {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .bg-white,
[data-theme="high-contrast"] .bg-white {
    background-color: var(--bg-card) !important;
}

[data-theme="dark"] .bg-gray-50,
[data-theme="high-contrast"] .bg-gray-50 {
    background-color: var(--bg-input) !important;
}

[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-gray-700,
[data-theme="high-contrast"] .text-gray-800,
[data-theme="high-contrast"] .text-gray-700 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-400,
[data-theme="high-contrast"] .text-gray-500,
[data-theme="high-contrast"] .text-gray-400 {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-100,
[data-theme="high-contrast"] .border-gray-200,
[data-theme="high-contrast"] .border-gray-100 {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="high-contrast"] input,
[data-theme="high-contrast"] select {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] #answerInput,
[data-theme="high-contrast"] #answerInput {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] #answerInput::placeholder,
[data-theme="high-contrast"] #answerInput::placeholder {
    color: var(--text-muted);
}

/* ============================================
   ТЁМНЫЙ РЕЖИМ — Полные переопределения
   ============================================ */

/* Цвета текста — обеспечить читаемость серых оттенков */
[data-theme="dark"] .text-gray-600,
[data-theme="dark"] .text-gray-500 {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .text-gray-400,
[data-theme="dark"] .text-gray-300 {
    color: #94a3b8 !important;
}

[data-theme="dark"] .text-gray-200,
[data-theme="dark"] .text-gray-100 {
    color: #e2e8f0 !important;
}

/* Переопределения фона */
[data-theme="dark"] .bg-gray-100 {
    background-color: #334155 !important;
}

[data-theme="dark"] .bg-gray-200 {
    background-color: #475569 !important;
}

/* Фоны модальных окон */
[data-theme="dark"] #settingsModal > div:last-child,
[data-theme="dark"] #achievementsModal > div:last-child,
[data-theme="dark"] #analyticsModal > div:last-child,
[data-theme="dark"] #levelUpModal > div:last-child,
[data-theme="dark"] #tipModal > div:last-child,
[data-theme="dark"] #shortcutsModal > div:last-child {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* Специфика модального окна настроек */
[data-theme="dark"] #settingsModal label {
    color: var(--text-primary);
}

[data-theme="dark"] #settingsModal .text-gray-400,
[data-theme="dark"] #settingsModal .text-xs.text-gray-400 {
    color: #94a3b8 !important;
}

/* Радиокнопки и чекбоксы — метки */
[data-theme="dark"] input[type="radio"] + span,
[data-theme="dark"] input[type="checkbox"] + span {
    color: var(--text-primary);
}

/* Карточки выбора режима */
[data-theme="dark"] input[name="mode"] + span,
[data-theme="dark"] input[name="numSystem"] + span {
    color: var(--text-primary) !important;
}

/* Кнопки в настройках */
[data-theme="dark"] .tts-speed-btn,
[data-theme="dark"] .theme-btn,
[data-theme="dark"] .lang-btn,
[data-theme="dark"] .minimal-pair-btn {
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .tts-speed-btn:not(.bg-indigo-600),
[data-theme="dark"] .theme-btn:not(.bg-indigo-600),
[data-theme="dark"] .lang-btn:not(.bg-indigo-600),
[data-theme="dark"] .minimal-pair-btn:not(.bg-indigo-600) {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .tts-speed-btn:not(.bg-indigo-600):hover,
[data-theme="dark"] .theme-btn:not(.bg-indigo-600):hover,
[data-theme="dark"] .lang-btn:not(.bg-indigo-600):hover,
[data-theme="dark"] .minimal-pair-btn:not(.bg-indigo-600):hover {
    background-color: #475569 !important;
}

/* Кнопки пресетов */
[data-theme="dark"] #presetsList button {
    background-color: #334155;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] #presetsList button:hover {
    background-color: #475569;
}

/* Список закладок */
[data-theme="dark"] #bookmarksList > div {
    background-color: #334155;
    border-color: var(--border-color);
}

/* Полосы прогресса / XP */
[data-theme="dark"] #xpBarWrapper {
    background-color: #334155;
}

[data-theme="dark"] #xpBar {
    background: linear-gradient(90deg, #818cf8 0%, #a5b4fc 100%);
}

/* Виджет дневной цели */
[data-theme="dark"] .daily-widget,
[data-theme="dark"] #dailySection {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] #dailyGoalCircle {
    background-color: #334155;
}

/* Календарь в настройках */
[data-theme="dark"] #calendar .text-gray-300 {
    color: #64748b !important;
}

[data-theme="dark"] #calendar .text-gray-800 {
    color: #e2e8f0 !important;
}

/* Фон графиков аналитики */
[data-theme="dark"] #analyticsModal canvas {
    filter: brightness(0.95);
}

/* Список достижений */
[data-theme="dark"] #achievementsList > div {
    background-color: #334155;
    border-color: var(--border-color);
}

[data-theme="dark"] #achievementsList .text-gray-300 {
    color: #64748b !important;
}

/* Список званий в достижениях */
[data-theme="dark"] #titlesList > div {
    background-color: #334155;
    border-color: var(--border-color);
}

/* Отключённые состояния — обеспечить видимость */
[data-theme="dark"] button:disabled,
[data-theme="dark"] input:disabled {
    opacity: 0.5;
    color: #94a3b8 !important;
}

[data-theme="dark"] #btnAction:disabled {
    background-color: #475569 !important;
    color: #94a3b8 !important;
}

/* Кнопки подвала */
[data-theme="dark"] #btnSkip {
    color: #94a3b8;
}

[data-theme="dark"] #btnSkip:hover {
    color: #cbd5e1;
    background-color: #334155;
}

/* Текст обратной связи */
[data-theme="dark"] #feedbackText {
    color: var(--text-primary);
}

[data-theme="dark"] #feedbackSub {
    color: var(--text-secondary);
}

/* Элементы цвета индиго — осветлить в тёмном режиме */
[data-theme="dark"] .text-indigo-600,
[data-theme="dark"] .text-indigo-500 {
    color: #a5b4fc !important;
}

[data-theme="dark"] .bg-indigo-50 {
    background-color: rgba(129, 140, 248, 0.15) !important;
}

[data-theme="dark"] .bg-indigo-100 {
    background-color: rgba(129, 140, 248, 0.2) !important;
}

/* Метка и текст вопроса */
[data-theme="dark"] #qLabel {
    color: #94a3b8;
}

[data-theme="dark"] #qText {
    color: var(--text-primary);
}

/* Значок режима */
[data-theme="dark"] #modeBadge {
    background-color: #334155;
    color: #a5b4fc;
}

/* Элементы шапки */
[data-theme="dark"] #appTitle {
    color: var(--text-primary);
}

[data-theme="dark"] #levelDisplay {
    color: var(--text-secondary);
}

[data-theme="dark"] #xpDisplay {
    color: var(--text-muted);
}

/* Отображение серии */
[data-theme="dark"] #streakDisplay {
    color: var(--text-primary);
}

/* Всплывающие уведомления */
[data-theme="dark"] #comboToast > div {
    background-color: #334155;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] #genericToast > div {
    background-color: #334155;
    color: var(--text-primary);
}

/* Полоса прокрутки в тёмном режиме */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #1e293b;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background-color: #475569;
}

/* Подсказка обучения в тёмном режиме — сохранить фиолетовый */
[data-theme="dark"] .tutorial-tooltip {
    box-shadow:
        0 8px 32px rgba(124, 58, 237, 0.35),
        0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Контейнер режима экзамена */
[data-theme="dark"] #examModeContainer {
    background-color: rgba(251, 146, 60, 0.1);
    border-color: #f97316;
}

/* Кнопка аудио */
[data-theme="dark"] #btnAudio {
    background-color: rgba(129, 140, 248, 0.15);
    color: #a5b4fc;
}

[data-theme="dark"] #btnAudio:hover {
    background-color: rgba(129, 140, 248, 0.25);
}

/* Кнопка микрофона */
[data-theme="dark"] #btnMic {
    background-color: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] #btnMic:hover {
    background-color: #475569;
}

/* Кнопки минимальных пар */
[data-theme="dark"] #btnPairA {
    background-color: rgba(129, 140, 248, 0.2);
    color: #a5b4fc;
    border-color: rgba(129, 140, 248, 0.3);
}

[data-theme="dark"] #btnPairA:hover {
    background-color: rgba(129, 140, 248, 0.3);
}

[data-theme="dark"] #btnPairB {
    background-color: rgba(168, 85, 247, 0.2);
    color: #c4b5fd;
    border-color: rgba(168, 85, 247, 0.3);
}

[data-theme="dark"] #btnPairB:hover {
    background-color: rgba(168, 85, 247, 0.3);
}

/* Поля ввода пар в тёмном режиме */
[data-theme="dark"] #pairInputA {
    background-color: rgba(129, 140, 248, 0.1);
    border-color: rgba(129, 140, 248, 0.3);
    color: var(--text-primary);
}

[data-theme="dark"] #pairInputB {
    background-color: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
    color: var(--text-primary);
}

/* Содержимое советов */
[data-theme="dark"] #tipContent {
    color: var(--text-primary);
}

/* Клавиши сочетаний */
[data-theme="dark"] #shortcutsModal kbd {
    background-color: #334155;
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Кнопки экспорта в аналитике */
[data-theme="dark"] #analytics-export button {
    background-color: #334155;
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] #analytics-export button:hover {
    background-color: #475569;
}

/* Специфические улучшения высокой контрастности */
[data-theme="high-contrast"] * {
    border-radius: 0 !important;
}

[data-theme="high-contrast"] button,
[data-theme="high-contrast"] .btn,
[data-theme="high-contrast"] [class*="rounded"] {
    border: 2px solid var(--border-color) !important;
}

[data-theme="high-contrast"] .text-indigo-600,
[data-theme="high-contrast"] .text-indigo-500 {
    color: var(--accent-primary) !important;
}

[data-theme="high-contrast"] .bg-indigo-600,
[data-theme="high-contrast"] .bg-indigo-500 {
    background-color: var(--accent-primary) !important;
    color: #000000 !important;
}

[data-theme="high-contrast"] #qText {
    font-weight: 900;
    letter-spacing: 0.05em;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Базовые анимации */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-4px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(4px);
    }
}

.animate-shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes pop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1.0);
        opacity: 1;
    }
}

.animate-pop {
    animation: pop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(99, 102, 241, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

/* ============================================
   СИСТЕМА ОБУЧЕНИЯ — Утончённое свечение
   Без тёмного оверлея, элегантный современный стиль
   ============================================ */

/* Элегантное свечение для целевых элементов */
.tutorial-highlight {
    position: relative;
    z-index: 50;
    border-radius: inherit;
    animation: tutorialHighlight 2s ease-in-out infinite;
    box-shadow:
        0 0 0 2px rgba(139, 92, 246, 0.5),
        0 0 8px 2px rgba(139, 92, 246, 0.3),
        0 0 16px 4px rgba(139, 92, 246, 0.15);
    transition: box-shadow 0.3s ease;
}

@keyframes tutorialHighlight {
    0%, 100% {
        box-shadow:
            0 0 0 2px rgba(139, 92, 246, 0.5),
            0 0 8px 2px rgba(139, 92, 246, 0.3),
            0 0 16px 4px rgba(139, 92, 246, 0.15);
    }
    50% {
        box-shadow:
            0 0 0 3px rgba(139, 92, 246, 0.6),
            0 0 12px 4px rgba(139, 92, 246, 0.35),
            0 0 24px 6px rgba(139, 92, 246, 0.2);
    }
}

/* Усиленное свечение после бездействия */
.tutorial-highlight-intense {
    animation: tutorialHighlightIntense 1s ease-in-out infinite;
    box-shadow:
        0 0 0 3px rgba(139, 92, 246, 0.8),
        0 0 16px 4px rgba(139, 92, 246, 0.5),
        0 0 32px 8px rgba(139, 92, 246, 0.3);
}

@keyframes tutorialHighlightIntense {
    0%, 100% {
        box-shadow:
            0 0 0 3px rgba(139, 92, 246, 0.8),
            0 0 16px 4px rgba(139, 92, 246, 0.5),
            0 0 32px 8px rgba(139, 92, 246, 0.3);
    }
    50% {
        box-shadow:
            0 0 0 4px rgba(139, 92, 246, 0.9),
            0 0 24px 8px rgba(139, 92, 246, 0.6),
            0 0 48px 12px rgba(139, 92, 246, 0.35);
    }
}

/* Анимация тряски для неправильных кликов */
.tutorial-shake {
    animation: tutorialShake 0.5s ease-in-out;
}

@keyframes tutorialShake {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-4px); }
    30%, 60%, 90% { transform: translateX(4px); }
}

/* Анимация успеха при выполнении действия */
.tutorial-success {
    animation: tutorialSuccess 0.5s ease-out;
}

@keyframes tutorialSuccess {
    0% {
        box-shadow:
            0 0 0 2px rgba(34, 197, 94, 0.8),
            0 0 12px rgba(34, 197, 94, 0.6);
    }
    100% {
        box-shadow:
            0 0 0 10px rgba(34, 197, 94, 0),
            0 0 30px rgba(34, 197, 94, 0);
    }
}

/* ============================================
   ПОДСКАЗКА ОБУЧЕНИЯ — Умное позиционирование
   ============================================ */
.tutorial-tooltip {
    position: fixed;
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
    color: white;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    box-shadow:
        0 8px 32px rgba(124, 58, 237, 0.25),
        0 4px 12px rgba(0, 0, 0, 0.12);
    max-width: 320px;
    min-width: 260px;
    z-index: 1001;
    pointer-events: auto;
    overflow: visible;
}

.tutorial-tooltip.hidden {
    display: none !important;
}

/* Заголовок подсказки с названием и номером шага */
.tutorial-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tutorial-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
}

.tutorial-step-num {
    font-size: 0.7rem;
    opacity: 0.6;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

.tutorial-tooltip-content {
    padding: 12px 16px;
}

.tutorial-tooltip-content p {
    margin: 0;
}

#tutorialMessage {
    font-weight: 500;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.85rem;
}

/* Текст подсказки с состояниями */
.tutorial-hint-text {
    font-size: 0.8rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    margin-top: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.25s ease;
}

.tutorial-hint-text.visible {
    opacity: 1;
    max-height: 80px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.tutorial-hint-text.error {
    color: #fca5a5;
    font-weight: 600;
}

.tutorial-hint-text.warning {
    color: #fde047;
    font-weight: 600;
}

.tutorial-hint-text.success {
    color: #86efac;
    font-weight: 600;
}

/* Управление обучением (кнопки Назад, Пропустить, Далее) */
.tutorial-tooltip-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 14px 14px;
    gap: 8px;
}

.tutorial-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px; /* Сенсорная цель для мобильных */
}

.tutorial-btn .btn-icon {
    font-size: 0.9rem;
}

.tutorial-btn-back {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.tutorial-btn-back:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.18);
}

.tutorial-btn-back:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tutorial-btn-skip {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 10px;
}

.tutorial-btn-skip:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.08);
}

.tutorial-btn-close {
    background: #10b981;
    color: white;
    padding: 8px 16px;
    font-weight: 600;
    border-radius: 8px;
}

.tutorial-btn-close:hover {
    background: #059669;
}

.tutorial-btn-close.hidden {
    display: none;
}

.tutorial-btn-next {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    margin-left: auto;
}

.tutorial-btn-next:disabled {
    cursor: not-allowed;
}

.tutorial-btn-next.enabled,
.tutorial-btn-next:not(:disabled) {
    background: #fff;
    color: #6D28D9;
}

.tutorial-btn-next.enabled:hover,
.tutorial-btn-next:not(:disabled):hover {
    background: #f3f4f6;
    transform: translateX(2px);
}

/* Всплывающее приветствие */
.tutorial-welcome-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
    color: white;
    padding: 20px 32px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 10px 40px rgba(124, 58, 237, 0.4);
    z-index: 1100;
    animation: welcomeToastIn 0.4s ease-out;
}

.tutorial-welcome-toast.fade-out {
    animation: welcomeToastOut 0.3s ease-in forwards;
}

@keyframes welcomeToastIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes welcomeToastOut {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

/* Всплывающее уведомление о пропуске */
.tutorial-skip-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1100;
    animation: skipToastIn 0.3s ease-out;
}

@keyframes skipToastIn {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Мобильные адаптивные настройки для подсказки */
@media (max-width: 480px) {
    .tutorial-tooltip {
        max-width: calc(100vw - 32px);
        min-width: 280px;
    }

    .tutorial-tooltip-header {
        padding: 10px 14px 6px;
    }

    .tutorial-title {
        font-size: 0.9rem;
    }

    .tutorial-tooltip-content {
        padding: 10px 14px;
    }

    #tutorialMessage {
        font-size: 0.82rem;
    }

    .tutorial-tooltip-controls {
        padding: 8px 10px;
        gap: 6px;
    }

    .tutorial-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .tutorial-btn-skip {
        padding: 8px 8px;
    }
}

/* Стрелка подсказки — позиционирование по data-position */
.tutorial-tooltip-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
    transform: rotate(45deg);
    z-index: -1;
}

/* Позиции стрелки */
.tutorial-tooltip[data-position="bottom"] .tutorial-tooltip-arrow {
    top: -6px;
    left: calc(50% - 6px);
}

.tutorial-tooltip[data-position="top"] .tutorial-tooltip-arrow {
    bottom: -6px;
    left: calc(50% - 6px);
    background: linear-gradient(315deg, #7C3AED 0%, #6D28D9 100%);
}

.tutorial-tooltip[data-position="left"] .tutorial-tooltip-arrow {
    right: -6px;
    top: calc(50% - 6px);
    background: linear-gradient(225deg, #7C3AED 0%, #6D28D9 100%);
}

.tutorial-tooltip[data-position="right"] .tutorial-tooltip-arrow {
    left: -6px;
    top: calc(50% - 6px);
}

/* Уведомление о завершении обучения */
.tutorial-complete-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1100;
    animation: toastAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tutorial-complete-inner {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    padding: 18px 28px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 8px 32px rgba(34, 197, 94, 0.35);
    text-align: center;
}

@keyframes toastAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Режим лихорадки */
body.fever-mode header {
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.4);
}

body.fever-mode #timeAttackBar {
    background-color: #f97316;
}

body.fever-mode #card {
    animation: feverPulse 0.5s ease-in-out infinite alternate;
}

@keyframes feverPulse {
    0% {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
    100% {
        box-shadow: 0 4px 20px -1px rgba(249, 115, 22, 0.3), 0 2px 4px -1px rgba(249, 115, 22, 0.2);
    }
}

/* Переходы слайдов вопросов */
@keyframes questionExit {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-20px);
    }
}

@keyframes questionEnter {
    0% {
        opacity: 0;
        transform: translateX(20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.question-exit {
    animation: questionExit 0.18s ease-out forwards;
}

.question-enter {
    animation: questionEnter 0.18s ease-out forwards;
}

/* Обратная связь успеха */
@keyframes successGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        box-shadow: 0 0 0 14px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.success-ring {
    animation: successGlow 0.5s ease-out;
}

@keyframes particleUp {
    0% {
        transform: translate(-50%, -5px);
        opacity: 0.9;
    }
    100% {
        transform: translate(-50%, -30px);
        opacity: 0;
    }
}

.success-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background-color: #22c55e;
    top: 50%;
    transform: translate(-50%, -5px);
    opacity: 0;
    animation: particleUp 0.5s ease-out forwards;
}

@keyframes answerCorrect {
    0% {
        transform: scale(1);
        color: inherit;
    }
    40% {
        transform: scale(1.04);
        color: #16a34a;
    }
    100% {
        transform: scale(1);
        color: #16a34a;
    }
}

.answer-correct {
    animation: answerCorrect 0.25s ease-out;
}

/* Обратная связь неудачи */
@keyframes flashBg {
    0% {
        background-color: #fee2e2;
    }
    100% {
        background-color: #f3f4f6;
    }
}

body.screen-flash {
    animation: flashBg 0.25s ease-out;
}

/* Эффекты комбо */
@keyframes comboPulse {
    0% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.5);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes comboWiggle {
    0% {
        transform: translateY(-1px) rotate(-1deg);
    }
    100% {
        transform: translateY(1px) rotate(1deg);
    }
}

.combo-pulse {
    animation: comboPulse 0.35s ease-out;
}

.combo-glow {
    text-shadow: 0 0 8px rgba(249, 115, 22, 0.9);
}

.combo-crazy {
    animation: comboPulse 0.35s ease-out, comboWiggle 0.18s infinite alternate;
    color: #dc2626 !important;
}

/* Плавающий текст XP */
@keyframes xpFloat {
    0% {
        transform: translate(-50%, 0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -30px);
        opacity: 0;
    }
}

.xp-float {
    position: absolute;
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 800;
    color: #facc15;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    animation: xpFloat 0.7s ease-out forwards;
}

/* Блеск полосы XP */
#xpBarWrapper {
    position: relative;
}

#xpBar {
    transition: width 0.5s ease-out;
}

.xp-shine::after {
    content: "";
    position: absolute;
    top: 0;
    left: -30%;
    width: 30%;
    height: 100%;
    background: linear-gradient(120deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0));
    transform: skewX(-20deg) translateX(-100%);
    animation: xpShine 0.8s ease-out;
    pointer-events: none;
}

@keyframes xpShine {
    0% {
        transform: skewX(-20deg) translateX(-100%);
        opacity: 0.6;
    }
    100% {
        transform: skewX(-20deg) translateX(260%);
        opacity: 0;
    }
}

/* Конфетти */
.confetti-piece {
    position: fixed;
    top: -10px;
    width: 6px;
    height: 12px;
    border-radius: 9999px;
    opacity: 0;
    transform: translateY(0) rotate(0deg);
    animation: confettiFall 2s linear forwards;
    z-index: 130;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

/* Индикатор распознавания речи */
#speechIndicator {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Активное состояние кнопки микрофона */
#btnMic.bg-red-500 {
    animation: micPulse 1s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

/* Контейнер графиков аналитики */
#analyticsModal canvas {
    max-width: 100%;
}

/* Плавная прокрутка для модальных окон */
#settingsModal > div:last-child,
#achievementsModal > div:last-child,
#analyticsModal > div:last-child {
    scroll-behavior: smooth;
}

/* Кастомная полоса прокрутки для модальных окон */
#settingsModal > div:last-child::-webkit-scrollbar,
#achievementsModal > div:last-child::-webkit-scrollbar,
#analyticsModal > div:last-child::-webkit-scrollbar {
    width: 6px;
}

#settingsModal > div:last-child::-webkit-scrollbar-track,
#achievementsModal > div:last-child::-webkit-scrollbar-track,
#analyticsModal > div:last-child::-webkit-scrollbar-track {
    background: transparent;
}

#settingsModal > div:last-child::-webkit-scrollbar-thumb,
#achievementsModal > div:last-child::-webkit-scrollbar-thumb,
#analyticsModal > div:last-child::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Эффект конфетти модального окна повышения уровня */
#levelUpModal .animate-pop {
    position: relative;
}

/* Контейнер обратной связи — плавные переходы */
#feedbackContainer {
    transition: opacity 0.3s ease-in-out;
}

/* Анимация продлённой обратной связи успеха */
@keyframes feedbackFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

#feedbackContainer.show {
    animation: feedbackFadeIn 0.3s ease-out forwards;
}

/* Празднование выполнения дневной цели */
@keyframes goalComplete {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

#dailyGoalCircle.complete {
    animation: goalComplete 0.5s ease-out;
}

/* Стилизация всплывающего уведомления о достижении */
#achievementToast > div {
    backdrop-filter: blur(10px);
}

/* Эффект наведения на карточку (отключён во время обучения) */
#card:not(.tutorial-highlight):hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Улучшение фокуса поля ввода */
#answerInput:focus {
    border-color: #4f46e5;
    transition: border-color 0.2s ease;
}

/* ============================================
   КНОПКА ДЕЙСТВИЯ — Состояния Подтвердить/Проверить/Далее
   ============================================ */

/* Базовая стилизация кнопки */
.btn-action {
    border: none;
    cursor: pointer;
    outline: none;
    position: relative;
    overflow: hidden;
}

/* Отключённое состояние — ожидание ввода */
.btn-action-disabled {
    background-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

[data-theme="dark"] .btn-action-disabled {
    background-color: #475569;
    color: #64748b;
}

/* Состояние Подтвердить/Проверить — готов к отправке ответа */
.btn-action-confirm {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.4);
}

.btn-action-confirm:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
    transform: translateY(-1px);
}

.btn-action-confirm:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
}

[data-theme="dark"] .btn-action-confirm {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: #052e16;
    box-shadow: 0 4px 14px rgba(74, 222, 128, 0.3);
}

[data-theme="dark"] .btn-action-confirm:hover {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
}

[data-theme="high-contrast"] .btn-action-confirm {
    background: #00ff00;
    color: #000000;
    border: 2px solid #00ff00 !important;
}

/* Состояние Далее — переход к следующему вопросу */
.btn-action-next {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-action-next:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.btn-action-next:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

[data-theme="dark"] .btn-action-next {
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    box-shadow: 0 4px 14px rgba(129, 140, 248, 0.3);
}

[data-theme="dark"] .btn-action-next:hover {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    box-shadow: 0 6px 20px rgba(129, 140, 248, 0.4);
}

[data-theme="high-contrast"] .btn-action-next {
    background: #ffff00;
    color: #000000;
    border: 2px solid #ffff00 !important;
}

/* Кнопка пропуска */
#btnSkip {
    transition: all 0.2s ease;
}

#btnSkip:active {
    transform: scale(0.98);
}

/* Адаптивные настройки для маленьких экранов */
@media (max-height: 600px) {
    #card {
        min-height: 280px;
    }

    #questionArea {
        margin-top: 0;
        margin-bottom: 10px;
    }

    #qText {
        font-size: 2rem;
    }
}

/* Поддержка тёмного режима (если понадобится в будущем) */
@media (prefers-color-scheme: dark) {
    /* Можно добавить стили тёмного режима здесь */
}

/* Стили печати (скрыть ненужные элементы) */
@media print {
    #tutorialTooltip,
    #comboToast,
    #achievementToast,
    #speechIndicator,
    .tutorial-tooltip,
    .tutorial-complete-toast {
        display: none !important;
    }
}

/* Доступность — уменьшение движения */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Поддержка высококонтрастного режима */
@media (forced-colors: active) {
    .tutorial-highlight,
    .tutorial-highlight-intense {
        outline: 3px solid CanvasText;
        box-shadow: none;
    }

    .tutorial-tooltip {
        border: 2px solid CanvasText;
    }
}

/* ============================================
   НОВЫЕ ФУНКЦИИ — Закладки, Пресеты, Советы
   ============================================ */

/* Анимация кнопки закладки */
#btnBookmark {
    transition: all 0.2s ease;
}

#btnBookmark:hover {
    transform: scale(1.1);
}

#btnBookmark.text-yellow-500 svg {
    filter: drop-shadow(0 0 4px rgba(234, 179, 8, 0.5));
}

@keyframes bookmarkPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

#btnBookmark:active {
    animation: bookmarkPop 0.3s ease;
}

/* Кнопки пресетов */
#presetsList button {
    transition: all 0.2s ease;
}

#presetsList button:hover {
    transform: translateY(-2px);
}

#presetsList button:active {
    transform: scale(0.95);
}

/* Стили модального окна советов */
#tipModal .animate-pop {
    position: relative;
}

#tipContent {
    white-space: pre-line;
    line-height: 1.8;
}

/* Модальное окно клавиатурных сочетаний */
#shortcutsModal kbd {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

/* Анимация вкладок аналитики */
.analytics-tab-btn {
    transition: all 0.2s ease;
}

.analytics-tab-btn:hover:not(.bg-indigo-600) {
    background-color: rgba(99, 102, 241, 0.1);
}

/* Карточки статистики в подробном виде */
#analytics-detailed .bg-gray-50 {
    transition: all 0.2s ease;
}

#analytics-detailed .bg-gray-50:hover {
    background-color: #f0f0f4;
    transform: translateX(4px);
}

/* Эффект наведения на кнопки экспорта */
#analytics-export button {
    transition: all 0.2s ease;
}

#analytics-export button:hover {
    transform: translateX(4px);
}

/* Анимация общего всплывающего уведомления */
#genericToast > div {
    animation: toastSlide 0.3s ease-out;
}

@keyframes toastSlide {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Список закладок в настройках */
#bookmarksList {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

#bookmarksList::-webkit-scrollbar {
    width: 4px;
}

#bookmarksList::-webkit-scrollbar-track {
    background: transparent;
}

#bookmarksList::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Пульсация кнопки советов при первом появлении */
@keyframes tipButtonPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(99, 102, 241, 0);
    }
}

#btnTips.highlight {
    animation: tipButtonPulse 2s ease-in-out 3;
}

/* Видимость кнопки клавиатурных сочетаний */
#btnShortcuts {
    transition: opacity 0.2s ease;
}

@media (max-width: 768px) {
    #btnShortcuts {
        display: none !important;
    }

    /* Скрыть блок логотипа/названия на мобильных для экономии места */
    .header-left-brand {
        display: none;
    }
}
