:root {
    /* Точные цвета из макета */
    --header-bg: #1a6b6d;
    --settings-icon: #7fc241;
    --lock-circle: #1a6b6d;
    --title-text: #1a6b6d;
    --yellow-btn: #fce94a;
    --orange-icon: #ff6b35;
    --card-border: #b0b0b0;
    --card-bg: #ffffff;
    --body-bg: #f8f8f8;
    --text-dark: #333333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Убирает синюю вспышку при тапе на Android Chrome */
    -webkit-tap-highlight-color: transparent;
}

/* Убираем 300ms задержку на тап — кнопки реагируют мгновенно */
button, a, [role="button"] {
    touch-action: manipulation;
}

/* Safe area для полноэкранного режима на мобильных устройствах */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Статичный градиент фона (бывш. animated-bg) — без анимации, растягивается по высоте страницы */
body.animated-bg {
    background: linear-gradient(135deg, #b8dff0 0%, #c8eaf8 38%, #e8f4f0 72%, #f0ece4 100%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-attachment: scroll;
    min-height: 100vh;
    min-height: 100dvh;
}

body {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: var(--text-dark);
    background: var(--body-bg);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh; /* dvh учитывает адресную строку браузера на мобильных */
    display: flex;
    flex-direction: column;
}

/*
 * Тёмный фон сайта — только подписи НА фоне страницы (не хранилище, не вкладки, не кнопки).
 */
body.theme-on-dark .service-control__title,
body.theme-on-dark .dodzu-game-embed__title,
body.theme-on-dark .links-catalog__title {
    color: #eaf6f6;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

body.theme-on-dark .links-catalog__subtitle {
    color: rgba(234, 246, 246, 0.78);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

body.theme-on-dark .widget-btn-wrap__label {
    color: rgba(20, 40, 45, 0.85);
    background-color: rgba(255, 255, 255, 0.88);
}

body.theme-on-dark .dodzu-game-embed__collapse,
body.theme-on-dark .dodzu-game-embed__icon-btn {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(255, 255, 255, 0.55);
    color: #1a6b6d;
}

/* Тёмный фон хранилища — только подписи иконок внутри карточки */
.storage__card.theme-storage-dark .link-card__name-label {
    color: #f5f7f7;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    outline: none;
}

/* Режим фокуса на хранилище */
/* Скрываем элементы header */
body.focus-mode .header__login-btn,
body.focus-mode .theme-settings,
body.focus-mode .header__center {
    visibility: hidden;
}

/* В фокус-режиме скрываем кнопку чат-комнат и блок каталога ссылок */
body.focus-mode .header__find-room-btn {
    display: none !important;
}

body.focus-mode .links-catalog {
    display: none !important;
}

/* Скрываем логотип, индикатор хранилища, подпись в панели управления */
body.focus-mode .service-control__lock-icon,
body.focus-mode .service-control__title,
body.focus-mode .storage-indicator,
body.focus-mode .storage-indicator-wrap,
body.focus-mode .service-control::after {
    visibility: hidden;
}

/* Полностью скрываем ИИ поиск в режиме фокуса */
body.focus-mode .service-control__ai-search {
    /* Скрываем визуально, но сохраняем место в потоке,
       чтобы кнопка глаза не смещалась влево */
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Полностью скрываем блок №6 (AI helper) в режиме фокуса - ГЛОБАЛЬНАЯ кнопка */
/* ВАЖНО: используем максимальную специфичность для гарантированного скрытия */
body.focus-mode section.ai-helper#aiHelper {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Скрываем пульсирующую кнопку свёрнутого ИИ помощника */
body.focus-mode .ai-helper__icon-toggle {
    display: none !important;
}

/* Скрываем меню управления хранилищем */
body.focus-mode .storage-controls {
    display: none !important;
}

/* Скрываем кнопку чата в хедере */
body.focus-mode .header__chat-btn {
    display: none !important;
}

/* Скрываем блок №6 (виджеты) в режиме фокуса */
body.focus-mode .widgets-section {
    display: none !important;
}

/* Скрываем блок №7 "Узнать о сервисе" (landing-section) */
body.focus-mode .landing-section {
    display: none !important;
}

body.focus-mode .site-footer__landing-btn {
    display: none !important;
}

/* Встроенная игра (вне .container) — тоже убираем в режиме фокуса */
body.focus-mode .dodzu-game-embed {
    display: none !important;
}

/* Кнопка фокуса становится серой полупрозрачной */
body.focus-mode .service-control__btn--focus {
    color: rgba(128, 128, 128, 0.5);
}

body.focus-mode .service-control__btn--focus:hover {
    transform: none;
}

/* ========================================== */
/* RESPONSIVE - МОБИЛЬНАЯ АДАПТАЦИЯ           */
/* ========================================== */

/* Первый диапазон: от 880px до 490px */
@media (max-width: 880px) {
    /* Запрет горизонтального скролла на мобильных.
       Причина: десятки tooltip'ов (::before с white-space: nowrap) и dropdown-меню
       создают scrollWidth > clientWidth в кнопках по всему интерфейсу.
       На десктопе это нормально (tooltip'ы всплывают при hover),
       на мобильных — каскадируется до body и вызывает горизонтальный скролл.
       overflow-x: hidden на html — стандартная практика для мобильных responsive-сайтов. */
    html {
        overflow-x: hidden;
    }

    .container {
        padding: 0 10px;
    }

    /* Тот же статичный градиент — без отдельного упрощения */
    body.animated-bg {
        background: linear-gradient(135deg, #b8dff0 0%, #c8eaf8 38%, #e8f4f0 72%, #f0ece4 100%);
        background-size: 100% 100%;
        background-repeat: no-repeat;
    }
}

/* Второй диапазон: от 490px до 340px */
@media (max-width: 490px) {
    .container {
        padding: 0 4px;
    }
}

/* ========== ФУТЕР ========== */
/* Основной контент растягивается на всю высоту */
.main {
    flex: 1;
}

.site-footer {
    background: #1a6b6d;
    padding: 14px 20px;
    text-align: center;
    margin-top: auto;
}
.site-footer__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px 20px;
    flex-wrap: wrap;
}
.site-footer__copy {
    color: rgba(255,255,255,0.7);
    font-size: 0.8em;
}
.site-footer__email {
    color: rgba(255,255,255,0.9);
    font-size: 0.8em;
    text-decoration: none;
}
.site-footer__email:hover {
    text-decoration: underline;
}

/* Кнопка «Узнать о сервисе» в подвале — заметный SEO-CTA
   По умолчанию: спокойный белый контур (как «Свернуть описание»).
   Жёлтый фон — только при наведении. */
.site-footer__landing-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 10px 20px;
    border: 2px solid rgba(255, 255, 255, 0.55);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 1em;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.25;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.site-footer__landing-btn:hover {
    background: #fce94a;
    border-color: #fce94a;
    color: #134e50;
    transform: translateY(-1px);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.16), 0 6px 16px rgba(252, 233, 74, 0.45);
}
.site-footer__landing-btn.is-expanded {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.55);
    color: #ffffff;
    box-shadow: none;
}
.site-footer__landing-btn.is-expanded:hover {
    background: #fce94a;
    border-color: #fce94a;
    color: #134e50;
    transform: translateY(-1px);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.16), 0 6px 16px rgba(252, 233, 74, 0.45);
}
.site-footer__landing-icon {
    font-size: 0.9em;
    line-height: 1;
    transition: transform 0.25s ease;
}
.site-footer__landing-btn.is-expanded .site-footer__landing-icon {
    transform: rotate(180deg);
}
.site-footer__landing-text {
    line-height: 1;
}

@media (max-width: 490px) {
    .site-footer {
        padding: 12px 12px;
    }
    .site-footer__inner {
        gap: 8px 12px;
    }
    .site-footer__copy,
    .site-footer__email {
        font-size: 0.72em;
    }
    .site-footer__landing-btn {
        padding: 9px 14px;
        font-size: 0.92em;
        gap: 6px;
        border-width: 2px;
    }
}

/* Защита: закрытые модалки внутри хранилища не перехватывают клики.
   Все модалки с display:none автоматически не получают pointer events,
   но на случай рассинхрона — принудительно блокируем. */
.add-link-modal:not(.active),
.add-text-modal:not(.active),
.add-chat-modal:not(.active),
.edit-modal:not(.active),
.edit-chat-modal:not(.active),
.edit-file-modal-new:not(.active),
.edit-text-modal:not(.active),
.view-text-modal:not(.active),
.ai-response-modal:not(.active),
.chat-modal:not(.active),
.chatrooms-modal:not(.active) {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* Дочерние элементы закрытых чат-модалок тоже не должны перехватывать клики
   (иначе сайдбар ~280px блокирует левую часть хранилища) */
.chat-modal:not(.active) *,
.chatrooms-modal:not(.active) * {
    pointer-events: none !important;
}
