/* ======================================
   Xobby - Theme Variables
   ====================================== */

:root {
  /* Адаптивный базовый шрифт:
     Минимум 14px на мелких телефонах,
     Максимум 18px на огромных мониторах,
     Плавно растет (1vw) между ними */
  font-size: clamp(14px, 1vw + 10px, 18px);
  /* Заголовок: от 18px до 24px */
    --fs-h3: clamp(1.125rem, 2vw + 1rem, 1.5rem);
    /* Основной текст чанков: от 15px до 18px */
    --fs-text: clamp(0.938rem, 1vw + 0.8rem, 1.125rem);
    /* Маленькие подписи/бейджы: от 11px до 13px */
    --fs-small: clamp(0.7rem, 0.5vw + 0.65rem, 0.813rem);
  /* Семантическая сетка размеров (теперь они зависят от базового выше) */
  --fs-xs: 0.75rem;   /* ~12px */
  --fs-sm: 0.875rem;  /* ~14px */
  --fs-base: 1rem;    /* ~16px */
  --fs-md: 1.125rem;  /* ~18px */
  --fs-lg: 1.25rem;   /* ~20px */
  --fs-xl: 1.5rem;    /* ~24px */
  --fs-2xl: 2rem;     /* ~32px */
  /* СВЕТЛАЯ ТЕМА (По умолчанию) */
  --background: hsl(40, 33%, 94%);
  --foreground: hsl(25, 30%, 15%);
  --card: hsl(40, 40%, 97%);
  --card-bg: hsl(40, 40%, 97%); /* Для твоей кнопки */
  --card-foreground: hsl(25, 30%, 15%);
  --primary: hsl(30, 53%, 35%);
  --primary-foreground: hsl(40, 40%, 98%);
  --secondary: hsl(35, 30%, 88%);
  --secondary-foreground: hsl(25, 30%, 20%);
  --muted: hsl(35, 20%, 90%);
  --muted-foreground: hsl(25, 15%, 45%);
  --accent: #8b6d45; /* Более темное золото для четкости */
  --accent-foreground: hsl(40, 40%, 98%);
  --border: hsl(35, 25%, 85%);
  --ring: hsl(25, 85%, 50%);
  --book-paper: hsl(40, 35%, 96%);
  --book-shadow: hsla(25, 30%, 15%, 0.1);
  --radius: 0.5rem; /* Это ровно 8px */
  /* ... твои старые переменные ... */
    /* Инпут: делаем его заметно темнее фона карточки */
    --input-bg: hsl(40, 25%, 91%);
    --input-border: hsl(40, 20%, 82%);
    --input-text: hsl(25, 30%, 15%);

    /* Цвет плейсхолдера (подсказки внутри) */
    --input-placeholder: hsl(25, 10%, 50%);
    /* Делаем фон списка таким же, как новый темный фон инпутов */
    --dropdown-bg: hsl(40, 25%, 91%);
    --dropdown-border: hsl(40, 20%, 82%);
    /* Светлая тема: приглушенный красный, не «кричащий» */
    --logout-bg: hsl(0, 70%, 55%);
    --logout-hover: hsl(0, 70%, 45%);
    --logout-text: #ffffff;
    /* Светлая тема: мягкий контраст */
    --back-btn-bg: rgba(0, 0, 0, 0.05);
    --back-btn-color: var(--foreground);
    /* Твой выбранный стиль для светлой темы */
    --btn-primary-bg: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%);
    --btn-primary-shadow: rgba(178, 124, 62, 0.3);
    --btn-primary-text: #ffffff;
    /* Цвет иконок для светлой темы: используем твой глубокий коричневый #8B5A2B */
    --nav-icon-color: #8B5A2B;
    --nav-icon-active: #5D3A1A; /* Еще темнее для активного состояния */
    --nav-icon-hover: #B27C3E;  /* Золотистый при наведении */
    --auth-msg-bg: #fdf5e6; /* Очень светлый бежевый/коричневый */
    --auth-msg-text: #5d4037; /* Глубокий коричневый */
    --auth-msg-border: #d7ccc8;
    --danger: #a62626;        /* Благородный кирпично-бордовый */
    --danger-bg: rgba(166, 38, 38, 0.08); /* Легкий фон для ошибок */
    --danger-hover: #8b1e1e;   /* Чуть темнее при наведении */
    --warning: #b38600;        /* Приглушенное золото / тёмный янтарь */
    --warning-bg: rgba(179, 134, 0, 0.08);
    --warning-hover: #997300;
}

/* ТЕМНАЯ ТЕМА (Принудительно через класс) */
/* ВАЖНО: Мы убрали @media (prefers-color-scheme: dark) и заменили на это */
body.dark-mode {
    /* Основной фон: глубокий темно-серый с легким синим оттенком */
    --background: hsl(222, 15%, 12%);
    --foreground: hsl(210, 20%, 88%);

    /* Карточки: чуть светлее фона, чтобы создать объем */
    --card: hsl(222, 15%, 16%);
    --card-bg: hsl(222, 15%, 16%);
    --card-foreground: hsl(210, 20%, 90%);

    /* Акцентный оранжевый делаем чуть мягче (приглушеннее) */
    --primary: hsl(30, 53%, 35%);
    --primary-foreground: hsl(222, 15%, 10%);

    /* Вторичные элементы (кнопки категорий) */
    --secondary: hsl(222, 12%, 22%);
    --secondary-foreground: hsl(210, 15%, 80%);

    /* Мягкий текст и границы */
    --muted: hsl(222, 12%, 20%);
    --muted-foreground: hsl(215, 12%, 60%);

    --border: hsl(222, 12%, 18%);
    --ring: hsl(25, 70%, 55%);

    /* Для режима чтения: мягкая темная бумага */
    --book-paper: hsl(222, 15%, 13%);
    --book-shadow: rgba(0, 0, 0, 0.4);

    /* Дополнительно: мягкое свечение для акцентов */
    --accent: #E6B980; /* Яркое золото */
    /* ... твои старые переменные ... */
    --input-bg: hsl(222, 15%, 16%); /* Благородный темный из предыдущего шага */
    --input-text: #eaddca;
    --input-border: hsl(222, 12%, 25%);
    /* Темная тема (твой благородный темный) */
    --dropdown-bg: hsl(222, 15%, 16%);
    --dropdown-border: hsl(222, 12%, 25%);
    /* Темная тема: более глубокий, «винный» оттенок */
    --logout-bg: hsl(0, 50%, 40%);
    --logout-hover: hsl(0, 50%, 35%);
    --logout-text: hsl(0, 0%, 90%);
    /* Темная тема: полупрозрачное стекло */
    --back-btn-bg: rgba(255, 255, 255, 0.08);
    --back-btn-color: var(--foreground);
    --btn-gradient: linear-gradient(135deg, #3a7bd5 0%, #00d2ff 100%);
    --btn-shadow: rgba(0, 0, 0, 0.4);
    /* Чуть более насыщенный вариант для темной темы */
    --btn-primary-bg: linear-gradient(135deg, #C69052 0%, #9E6B3A 100%);
    --btn-primary-shadow: rgba(0, 0, 0, 0.4);
    --btn-primary-text: #ffffff;
    /* Для темной темы оставляем твое благородное золото и белый */
    --nav-icon-color: #E6B980;
    --nav-icon-active: #ffffff;
    --nav-icon-hover: #ffffff;
    --auth-msg-bg: #3e2723; /* Темно-коричневый */
        --auth-msg-text: #d7ccc8; /* Светло-коричневый (песочный) */
        --auth-msg-border: #5d4037;
        --danger: #e65c5c;        /* Более светлый бордовый, чтобы не пропадал на черном */
    --danger-bg: rgba(230, 92, 92, 0.12);
    --danger-hover: #ff7373;   /* Ярче при наведении в темной теме */
    --warning: #e6ac00;        /* Теплый золотистый, светится на темном фоне */
    --warning-bg: rgba(230, 172, 0, 0.12);
    --warning-hover: #ffbf00;
}

/* Добавь это, чтобы улучшить вид карточек в темном режиме */
body.dark-mode .tour-card {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Делаем header чуть прозрачным с блюром */
body.dark-mode .header {
 /*   background-color: rgba(18, 20, 24, 0.85) !important; */
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* По умолчанию скрываем админские кнопки на карточках */
.tour-card .admin-controls {
    display: none;
}

/* Когда включен глобальный режим редактирования - показываем их */
body.is-editing-active .tour-card .admin-controls {
    display: flex;
}

/* И для твоей галереи тоже используем body как триггер */
body.is-editing-active .delete-photo-btn {
    display: inline-flex;
}

body.is-editing-active .add-photo-placeholder {
    display: flex !important;
}

body.is-editing-active #edit-mode-toggle {
    border-color: var(--accent);
  background: var(--secondary);
  color: var(--accent);
}
/* ======================================
   Theme Toggle Button (Desktop Only)
   ====================================== */
.theme-btn-modern {
    display: flex;
    /* Используем rem, чтобы кнопка росла вместе с базовым шрифтом */
    width: 2.5rem;   /* Примерно 40px при базе 16px */
    height: 2.5rem;
    border-radius: var(--radius);
    background: var(--card-bg);

    /* Упрощаем границы, используя твой цвет из переменных или жесткий код */
    border: 1.5px solid #8B5A2B;

    cursor: pointer;
    align-items: center;
    justify-content: center;

    /* Иконка теперь тоже адаптивна */
    font-size: var(--fs-lg); /* Примерно 20px-22px */

    transition: all 0.2s ease;
    padding: 0;
    box-shadow: 0 2px 5px var(--book-shadow);
}

.theme-btn-modern:hover {
    transform: translateY(-2px);
    background: var(--secondary);
}

.theme-btn-modern:active {
    transform: translateY(0);
}

/* Масштабирование иконок внутри кнопки, если они SVG */
.theme-btn-modern svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Скрытие иконок в зависимости от темы */
body.dark-mode .icon-sun { display: block; }
body.dark-mode .icon-moon { display: none; }
body:not(.dark-mode) .icon-sun { display: none; }
body:not(.dark-mode) .icon-moon { display: block; }

/* Адаптивность для мобилок */

/* Когда поиск активен, даем ему приоритет */
body.search-active #header-left-zone,
body.search-active #header-right-zone {
    /* На мобилках скрываем полностью, на планшетах можно просто уменьшить */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Скрывать солнышко, если в приложении открыт экран с кнопкой назад */
/*body:has(.back-btn-modern.active) .theme-btn-desktop {
    display: none !important;
}  */
/* CSS Variables */


/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ======================================
   Reset & Base Scaling
   ====================================== */

html {
  /* Убираем жесткие 16px.
     Теперь базовый размер шрифта определяется в :root через clamp.
     Это позволяет пользователям с особыми настройками зрения в браузере
     корректно масштабировать твое приложение. */
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
}

body {
  /* Используем системные шрифты с приоритетом Inter */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Применяем нашу адаптивную переменную */
  font-size: var(--fs-base);

  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;

  /* Улучшенное сглаживание шрифтов */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Плавный переход тем */
  transition: background-color 0.3s ease, color 0.3s ease;

  /* Убираем лишние отступы, которые могут ломать верстку на мобилках */
  margin: 0;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

a {
  text-decoration: none;
  color: inherit;
  /* Добавим плавный переход для ссылок, если они будут менять цвет */
  transition: opacity 0.2s ease;
}

/* Удобство для тач-интерфейсов */
a:active {
  opacity: 0.7;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

/* App Container */
.app {
  min-height: 100vh;
  max-width: 100%;
  padding-bottom: 5rem;
}

/* ======================================
   Header
   ====================================== */
/* ======================================
   Header & Search (Adaptive)
   ====================================== */

.header {
    position: sticky;
    top: 0;
    z-index: 40;
    /* Используем современный синтаксис прозрачности и блюр */
    background-color: rgba(from var(--background) r g b / 0.7);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);

    /* Адаптивные отступы: верх/низ чуть меньше для экономии места */
    padding: 0.75rem 1rem 0.4rem;

    /* Центрирование контента на больших экранах */
    padding-left: clamp(1rem, (100% - 800px) / 2, 20%);
    padding-right: clamp(1rem, (100% - 800px) / 2, 20%);

    transition: background-color 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    /* Размер иконки теперь зависит от шрифта (2.5 базовых единицы) */
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Используем lg размер шрифта для эмодзи/буквы в лого */
    font-size: var(--fs-lg);
}

.logo-text h1 {
    font-size: var(--fs-lg); /* Адаптивный заголовок */
    font-weight: 700;
    color: var(--foreground);
    line-height: 1.2;
}

.logo-text p {
    font-size: var(--fs-xs); /* Мелкий подзаголовок */
    color: var(--muted-foreground);
}
.logo-text {
    font-display: swap;
}
/* Search Bar */
.search-bar {
    position: relative;
    margin-top: 0.5rem;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    pointer-events: none;
    /* Размер иконки поиска */
    width: 1.1rem;
    height: 1.1rem;
}

.search-input {
    width: 100%;
    /* Высота инпута теперь тоже адаптивна через rem */
    height: 2.8rem;
    padding: 0 2.5rem;
    font-size: var(--fs-base);
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    outline: none;
    transition: all 0.2s ease;
}

.search-input::placeholder {
    color: var(--muted-foreground);
    font-size: var(--fs-sm);
}

.search-input:focus {
    border-color: var(--ring);
    background-color: var(--background);
    box-shadow: 0 0 0 3px rgba(from var(--ring) r g b / 0.15);
}

/* На мобилках делаем поиск чуть компактнее */
@media (max-width: 480px) {
    .logo-icon {
        width: 2.2rem;
        height: 2.2rem;
    }
    .search-input {
        height: 2.5rem;
    }
}

/* ======================================
   Main Content & Categories (Adaptive)
   ====================================== */

.main-content {
    /* Используем адаптивный отступ, чтобы на больших экранах контент не прижимался */
    padding: 0 1rem;
  /*  max-width: 800px;  Ограничиваем ширину контента для удобства чтения */
    margin: 0 auto;
}

/* Categories */
.categories {
    padding: 0.75rem 0;
    /* Отрицательный маржин позволяет скроллу категорий доходить до краев экрана на мобилках */
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

.category-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.25rem 0;
    /* Убираем стандартные скроллбары */
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Плавный скролл для мобилок */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    /* Паддинги в rem сделают кнопку пропорциональной размеру текста */
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: var(--fs-sm); /* Адаптивный шрифт категорий */
    font-weight: 500;
    white-space: nowrap;
    background-color: var(--secondary);
    color: var(--secondary-foreground);
    transition: all 0.2s ease;
    /* Защита от случайного выделения текста при кликах */
    user-select: none;
}

.category-tab:hover {
    background-color: var(--secondary);
    opacity: 0.8;
}

.category-tab:active {
    transform: scale(0.96); /* Чуть более заметный отклик при нажатии */
}

.category-tab.active {
    background-color: var(--primary);
    color: var(--primary-foreground);
    box-shadow: 0 2px 8px rgba(from var(--primary) r g b / 0.3);
}

/* Section Header */
.section-header {
    display: flex;
    flex-wrap: wrap; /* Чтобы на очень узких экранах текст и счетчик могли перенестись */
    align-items: baseline;
    justify-content: center; /* Центрируем заголовок согласно твоему стилю */
    margin-top: 1rem;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.section-header h2 {
    font-size: var(--fs-md); /* Адаптивный размер заголовка раздела */
    font-weight: 600;
    text-align: center;
}

.title-wrapper{
  min-width: 0;
  flex: 1;
  display: ruby;
  flex-direction: column;
  gap: 0.125rem;
}

.tour-count {
    font-size: var(--fs-sm);
    color: var(--muted-foreground);
    /* Заменяем 10px на rem */
    padding-left: 0.5rem;
    font-weight: 400;
}

/* Улучшение для мобильных: делаем табы категорий чуть крупнее для удобства тапа */
@media (max-width: 480px) {
    .category-tab {
        padding: 0.6rem 1.1rem;
        font-size: var(--fs-base); /* На мобилках категории можно сделать чуть крупнее */
    }
}
/* Основной контейнер страницы */
.tour-details-page {
    /* Цвета из твоих переменных */
    background-color: var(--card-bg) !important;
    color: var(--foreground);
    border: 1px solid var(--border);

    min-height: 100vh;
    padding-bottom: 5rem;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Твои настройки центрирования и адаптивности */
    max-width: 45rem;

    padding: clamp(1.5rem, 5vw, 2.5rem);
    border-radius: 1.25rem;
    box-shadow: 0 0.625rem 1.875rem var(--book-shadow);
    transition: background-color 0.3s ease, color 0.3s ease;
}
/* ======================================
   Book Grid (Adaptive)
   ====================================== */
.tour-grid {
    display: grid;
    /* На самых маленьких экранах используем auto-fill с минимальным порогом */
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    /* Заменяем 16px на 1rem, чтобы зазор масштабировался */
    gap: 1rem;
    padding-bottom: 2rem;
}
/* Мобильные устройства (маленькие) */
@media (min-width: 360px) {
    .tour-grid {
        /* Фиксируем 3 колонки для стабильности верстки на мобилках пошире */
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Мобильные устройства (средние) */
@media (min-width: 484px) {
    .tour-grid {
        /* Фиксируем 3 колонки для стабильности верстки на мобилках пошире */
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

/* Планшеты */
@media (min-width: 766px) {
    .tour-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Десктоп и большие планшеты */
@media (min-width: 990px) {
    .tour-grid {
        /* Возвращаемся к твоим 5 колонкам, когда места достаточно */
        grid-template-columns: repeat(5, 1fr);
        gap: 1.25rem; /* На больших экранах можно чуть увеличить расстояние */
    }
}

/* Экстра-широкие экраны */
@media (min-width: 1200px) {
    .tour-grid {
        /* На 4K мониторах сетка не будет бесконечно растягиваться, если есть обертка */
        gap: 1.5rem;
    }
}

@media (min-width: 1900px) {
    .tour-grid {
        /* Возвращаемся к твоим 5 колонкам, когда места достаточно */
        grid-template-columns: repeat(6, 1fr);
        gap: 1.7rem; /* На больших экранах можно чуть увеличить расстояние */
    }
}

@media (min-width: 2800px) {
    .tour-grid {
        /* Возвращаемся к твоим 5 колонкам, когда места достаточно */
        grid-template-columns: repeat(8, 1fr);
        gap: 2.0rem; /* На больших экранах можно чуть увеличить расстояние */
    }
}
/* ======================================
   Book Card (Adaptive & Clean)
   ====================================== */

.tour-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); /* Более "живая" анимация */
    text-decoration: none;
    color: inherit;
}

.tour-card:hover {
    /* Используем rem для смещения */
    transform: translateY(-0.25rem);
}

.tour-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4; /* Книжный стандарт */
    border-radius: var(--radius);
    background-color: var(--secondary);
    overflow: hidden;
    /* Улучшенная тень с использованием твоей переменной */
    box-shadow: 0 4px 12px -4px var(--book-shadow);
    transition: box-shadow 0.3s ease;
}

.tour-card:hover .tour-cover {
    box-shadow: 0 8px 20px -6px var(--book-shadow);
}

/* Внутренняя часть для книг без обложки (заглушка) */
.book-cover-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg,
        rgba(from var(--primary) r g b / 0.15),
        var(--secondary),
        rgba(from var(--accent) r g b / 0.15)
    );
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
}

.book-emoji {
    /* Размер эмодзи теперь зависит от адаптивной сетки */
    font-size: var(--fs-2xl);
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.book-cover-title {
    /* Мелкий текст внутри обложки */
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--foreground);
    opacity: 0.6;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* До трех строк для длинных названий */
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
}

/* Стили для реального изображения обложки */
.tour-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Мягкое появление картинки после загрузки */
    animation: fadeInImg 0.5s ease-in;
}

@keyframes fadeInImg {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Контейнер с информацией под книгой (название, автор) */
.tour-info {
    padding: 0.25rem 0.1rem;
    cursor: default;
}
/* ======================================
   Favorite Button (Adaptive)
   ====================================== */
/* =================================================
   1. БАЗОВЫЕ КНОПКИ (Общие размеры и структура)
   ================================================= */
.action-btn,
.favorite-btn,
.edit-info-minimal,
.edit-cover-btn,
.delete-btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    cursor: pointer;
    z-index: 10;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1.5px solid transparent;
    background: rgba(255, 255, 255, 0.1); /* Резервный фон */
}

/* Иконки внутри */
.action-btn svg,
.favorite-btn svg {
    width: 1.2rem;
    height: 1.2rem;
    stroke-width: 2;
    stroke: currentColor;
}

/* Контейнер тулбара */
.card-actions-toolbar {
    position: absolute;
    top: 0.3rem;
    left: 0.3rem;
    right: 0.3rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    z-index: 10;
    pointer-events: none;
}
.card-actions-toolbar button { pointer-events: auto; }


.cover-edit-icon {
  display: none;
  position: absolute;
  top: 1.3rem;
  left: 3.3rem;
  background: var(--accent);
  border-radius: 50%;
  width: 1.2rem;
  height: 1.2rem;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.7rem;
  border: 2px solid var(--secondary);
  pointer-events: auto;   /* КРИТИЧНО: разрешаем клик */
  z-index: 10;
}
body.is-editing-active .cover-edit-icon {
  display: flex;
}
.cover-edit-icon:hover {
    background: #dc3545;
    transform: scale(1.1);
}

/* Скрываем крестик, если у карточки нет обложки (через спец. класс) */
.tour-card.no-cover .cover-edit-icon {
    display: none;
}
/* =================================================
   2. ЦВЕТОВЫЕ СХЕМЫ (Темы)
   ================================================= */

/* СВЕТЛАЯ ТЕМА */
body:not(.dark-mode) .action-btn,
body:not(.dark-mode) .favorite-btn {
    background: rgba(255, 255, 255, 0.85);
    border-color: #D4A017;
    color: #B8860B;
    box-shadow: 0 0.125rem 0.5rem rgba(212, 160, 23, 0.2);
}

/* ТЕМНАЯ ТЕМА */
body.dark-mode .action-btn,
body.dark-mode .favorite-btn {
    background: rgba(40, 44, 52, 0.7);
    border-color: rgba(230, 185, 128, 0.3);
    color: #E6B980;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.3);
}

/* Общий Ховер */
.action-btn:hover, .favorite-btn:hover {
    transform: scale(1.1) translateY(-1px);
}

/* =================================================
   3. СПЕЦИАЛЬНЫЕ СОСТОЯНИЯ (Приоритетные)
   ================================================= */

/* Кнопка ПРИВАТНОСТИ (Активна) - Всегда красная */
.action-btn.privacy-btn.is-private {
    color: var(--danger, #e74c3c) !important;
    border-color: var(--danger, #e74c3c) !important;
    background: rgba(255, 77, 77, 0.1) !important;
}

/* ИЗБРАННОЕ (Активно) - Всегда красное */
.favorite-btn.favorited {
    color: #e74c3c !important;
}
.favorite-btn.favorited svg {
    fill: var(--danger, #e74c3c) !important;
    stroke: var(--danger, #e74c3c) !important;
}

/* УДАЛЕНИЕ - Всегда красная */
.delete-btn {
    background: var(--danger, #e74c3c) !important;
    color: white !important;
 /*   border: none !important; */
}

/* СМЕНА ОБЛОЖКИ (Отдельно в углу) */
.edit-cover-btn {
    position: absolute;
    bottom: 0.6rem;
    left: 0.6rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
/* --- ЛОГИКА ЗАМКА (Открыт/Закрыт) --- */

/* По умолчанию скрываем дужку закрытого замка */
.privacy-btn .lock-closed { display: none; }
/* По умолчанию показываем дужку открытого замка */
.privacy-btn .lock-open { display: block; }

/* Когда активен режим ПРИВАТ */
.privacy-btn.is-private {
    color: #ff4d4d !important;
    border-color: #ff4d4d !important;
    background: rgba(255, 77, 77, 0.1) !important;
}

.privacy-btn.is-private .lock-open { display: none; }
.privacy-btn.is-private .lock-closed { display: block; }
/* =================================================
   4. АДАПТИВНОСТЬ
   ================================================= */
@media (max-width: 480px) {
    .card-actions-toolbar { top: 0.4rem; left: 0.4rem; gap: 0.6rem; }
    /* Кнопки на мобильных чуть меньше, если нужно */
    .action-btn, .favorite-btn {
        width: 1.8rem;
        height: 1.8rem;
    }
}
@media (max-width: 321px) {
    .card-actions-toolbar { top: 0.6rem; left: 0.6rem; gap: 0.8rem; }
    /* Кнопки на мобильных чуть меньше, если нужно */
    .action-btn, .favorite-btn {
        width: 3.4rem;
        height: 3.4rem;
    }
    .action-btn svg, .favorite-btn svg {
  width: 2.2rem;
  height: 2.2rem;
  stroke-width: 1.5;
  stroke: currentColor;
   }
}

/* Скрываем все кнопки действий по умолчанию */
.action-btn {
    display: none;
}

/* Исключаем favorite-btn, чтобы она оставалась видимой */
/* Либо используем более специфичный селектор: */
.action-btn.favorite-btn {
    display: inline-flex; /* или flex, в зависимости от твоей верстки */
}

/* Если нужно, чтобы в режиме редактирования остальные кнопки появлялись: */
body.is-editing-active .action-btn:not(.favorite-btn) {
    display: inline-flex;
}

/* Если поле пустое, прячем системную маску дд.мм.гггг */
.tour-input-small[value=""]::-webkit-datetime-edit {
    display: none;
}

/* Вместо нее рисуем текст из data-placeholder */
.tour-input-small[value=""]:before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
}

/* Когда поле в фокусе или заполнено - возвращаем нормальный вид */
.tour-input-small:focus::-webkit-datetime-edit {
    display: inline-block;
}
.tour-input-small:focus:before {
    display: none;
}

.action-btn.delete-btn{
   color: var(--danger, #e74c3c) !important;
  border-color: var(--danger, #e74c3c) !important;
  background: rgba(255, 77, 77, 0.1) !important;
}
/* ======================================
   Full Book Info & Edit Logic
   ====================================== */

/*.tour-info {
    padding: 0.75rem 0.5rem;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}  */

.title-group {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-height: 2.25rem; /* Высота не меньше размера кнопки */
}

/* ЗАЩИТА ОТ НАЕЗДА: Текст не зайдет на территорию кнопки */
.title-group.has-edit-btn {
    padding-right: 0;
}

/* Сброс маржинов, чтобы кнопка не "падала" из-за отступов текста */
.tour-title, .tour-author {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.25;
}

.tour-title {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--foreground);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.tour-author {
    font-size: var(--fs-sm);
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px !important;
}

/* ======================================
   Кнопка редактирования (Фирменный стиль)
   ====================================== */

.edit-info-minimal {
    position: absolute;
    right: 0;
    top: 0; /* В обычном режиме выровнена по верху первой строки */

    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;

    background: transparent;
    border: none;
    color: var(--muted-foreground);
    border-radius: var(--radius);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
}

.edit-info-minimal svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke: currentColor; /* Цвет иконки зависит от color кнопки */
    stroke-width: 2;
    fill: none;
}
@media (max-width: 321px) {
    /* Кнопки на мобильных чуть меньше, если нужно */
    .edit-info-minimal {
        width: 3.4rem;
        height: 3.4rem;
    }
    .edit-info-minimal svg {
  width: 2.2rem;
  height: 2.2rem;
  stroke-width: 1.5;
  stroke: currentColor;
   }
}
/* Твой селектор: Появление при наведении и коричневый цвет */
.tour-card:has(.edit-info-minimal) .tour-info:hover .edit-info-minimal {
    opacity: 1 !important;
    transform: scale(1.1);
}

.edit-info-minimal:hover {
    background: var(--secondary) !important; /* Фон при наведении на саму кнопку */
}

/* ======================================
   РЕЖИМ РЕДАКТИРОВАНИЯ (is-editing)
   ====================================== */

/* ФИКС: Кнопка по центру и в полном коричневом цвете */
.is-editing .edit-info-minimal {
    opacity: 1 !important;
    top: 50% !important;
    transform: translateY(-50%) !important; /* Идеальный центр по вертикали */

    background: var(--primary) !important; /* Коричневый фон */
    color: #ffffff !important;           /* Белая иконка */
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(from var(--primary) r g b / 0.3);
}

/* Подсветка редактируемых полей */
.is-editing [contenteditable="true"] {
    background: var(--secondary);
    border-radius: var(--radius);
    padding: 0 4px !important;
    outline: none;
    box-shadow: 0 0 0 1px var(--accent);
}

@media (max-width: 768px) {
    .edit-info-minimal {
        opacity: 0.7;
    }
}
/* ======================================
   Editing Mode & Interactive States
   ====================================== */

/* Поле ввода в режиме редактирования */
[contenteditable="true"] {
    outline: none;
    border-radius: var(--radius);
    padding: 0.125rem 0.5rem; /* Адаптивные 2px 8px */
    min-width: 3.125rem;
    display: inline-block;
    /* Цвет курсора */
    caret-color: var(--primary);
    transition: all 0.2s ease-in-out;
}

body.is-editing-active [contenteditable="true"] {
   /* Пунктирная рамка для визуального отличия от обычного инпута */
    border: 1.5px dashed var(--primary) !important;
    background-color: var(--input-bg);
    /* Мягкое свечение в тон основной темы */
    box-shadow: 0 0 12px rgba(from var(--primary) r g b / 0.15);
}

[contenteditable="true"]:hover {
    filter: brightness(1.05);
    border-color: var(--accent) !important;
}

/* Состояние при фокусе (когда начали печатать) */
[contenteditable="true"]:focus {
    border-style: solid;
    background-color: var(--card);
    box-shadow: 0 0 0 3px rgba(from var(--primary) r g b / 0.1);
}

/* Адаптация кнопки под темную тему */
body.dark-mode .edit-info-minimal:hover {
    background: rgba(from var(--accent) r g b / 0.15);
    color: var(--accent);
}

/* Вспомогательные классы для анимации текста */
.tour-title, .tour-author {
    transition: background 0.3s ease, color 0.2s ease;
}

/* Интеллектуальная подсветка (только если есть права на редактирование) */
.tour-card:has(.edit-info-minimal) .title-group:hover .tour-title {
    color: var(--accent) !important;
}

/* Рейтинг */
.book-rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.book-rating svg {
    color: var(--primary);
    width: 0.875rem;
    height: 0.875rem;
    fill: currentColor;
}

.book-rating span {
    font-size: var(--fs-xs);
    color: var(--muted-foreground);
    font-weight: 500;
}

/* Блокировка интерактивности карточки в режиме правки */
.tour-info.is-editing {
    cursor: default !important;
}

/* Для старых браузеров (фолбек без :has) */
.editing-active {
    background-color: var(--input-bg) !important;
    outline: 2px solid var(--primary) !important;
    border-radius: var(--radius);
    padding: 2px 4px;
    cursor: text;
}

/* ======================================
   Bottom Navigation (Adaptive & Mobile First)
   ====================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* Используем clamp для высоты, чтобы на больших экранах панель была чуть солиднее */
    height: clamp(60px, 8vh, 70px);

    background-color: rgba(from var(--background) r g b / 0.90);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);

    /* Тонкая линия акцента сверху */
    border-top: 1px solid rgba(from var(--accent) r g b / 0.3);

    display: flex;
    justify-content: center;
    z-index: 1000;

    /* Поддержка iPhone Safe Area (отступ снизу для "полоски") */
    padding-bottom: env(safe-area-inset-bottom);

    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav-container-limited {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
}

.nav-item-modern {
    display: flex;
    flex-direction: column; /* Позволяет добавить микро-текст под иконкой в будущем */
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: var(--nav-icon-color);
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; /* Убираем синий квадрат при клике на мобилках */
}

.nav-item-modern svg {
    /* Адаптивный размер иконки */
    width: 1.65rem;
    height: 1.65rem;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
    transition: stroke-width 0.2s ease, transform 0.2s ease;
}

/* Эффект при наведении (только для десктопов) */
@media (hover: hover) {
    .nav-item-modern:hover {
        color: var(--nav-icon-hover);
        transform: translateY(-2px);
    }
}

/* Активное состояние */
.nav-item-modern.active {
    color: var(--nav-icon-active);
}

.nav-item-modern.active svg {
    stroke-width: 2.8;
    transform: scale(1.1);
}

/* Точка-индикатор под активной кнопкой */
.nav-item-modern.active::after {
    content: "";
    position: absolute;
    bottom: 0.1rem;
    width: 5px;
    height: 5px;
 /*   background: var(--nav-icon-active); */
    background: var(--accent) !important;
    border-radius: 50%;
    box-shadow: 0 0 8px var(--nav-icon-active);
    animation: dotPop 0.3s ease-out;
}

@keyframes dotPop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Смещение контента страницы, чтобы навигация его не перекрывала */
body {
    padding-bottom: clamp(60px, 8vh, 70px);
}
/* ======================================
   Utilities & Auth (Adaptive & Polish)
   ====================================== */

/* Touch feedback для мобильных устройств */
@media (hover: none) {
    .tour-card:active,
    .category-tab:active,
    .nav-item-modern:active,
    .favorite-btn:active,
    .btn-primary:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Empty State (Когда книг нет) */
.empty-state {
    text-align: center;
    padding: clamp(2rem, 10vh, 5rem) 1rem;
}

.empty-state .emoji {
    font-size: var(--fs-2xl);
    margin-bottom: 1rem;
    display: block;
}

.empty-state p {
    font-size: var(--fs-base);
    color: var(--muted-foreground);
    max-width: 300px;
    margin: 0 auto;
}

/* Шрифт для чтения (из режима ридера) */
.font-reading {
    font-family: 'Literata', Georgia, serif;
    font-size: var(--fs-md);
    line-height: 1.8;
}

/* --- Auth Container (Gemini Style) --- */

.auth-container {
    /* Используем rem для ширины, чтобы форма не была мелкой на 4K */
  /*  width: 90%; */
    max-width: 25rem;
    margin: clamp(2rem, 8vh, 5rem) auto;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    background-color: var(--card-bg) !important;
    border-radius: 1.25rem; /* ~20px */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
    transition: background-color 0.3s ease;
}

.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--muted-foreground);
    padding-left: 0.25rem;
}

/* Сообщения об ошибках */
.error-message-box {
    color: var(--destructive);
    background-color: rgba(from var(--destructive) r g b / 0.1);
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    margin-bottom: 1rem;
    text-align: center;
    border: 1px solid rgba(from var(--destructive) r g b / 0.2);
    display: none;
}

.error-message-box:not(:empty) {
    display: block;
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

#parse-btn{
   background: var(--btn-primary-bg);
   color: var(--logout-text);
}
.btn-primary.logout-btn, .btn-primary.btn-enter{
   background: var(--btn-primary-bg);
   color: var(--logout-text);
}

/* Кнопка с эффектом блика */
.btn-primary {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding: 0.875rem; /* Адаптивный паддинг */
    border: none;
    border-radius: var(--radius);
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px var(--btn-primary-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

/* Эффект блика */
.btn-primary::after, .file-upload-custom::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -100%;
    width: 30%;
    height: 200%;
    background: linear-gradient(
        to right,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transform: rotate(35deg);

    opacity: 0;
    pointer-events: none;
}

.btn-primary:hover::after, .file-upload-custom:hover::after {
    left: 150%;
    opacity: 1;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--btn-primary-shadow);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(1px);
}

/* Тёмная тема для форм */
body.dark-mode .auth-container {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.05);
}

/* ======================================
   Reading Mode (The Paper Experience)
   ====================================== */

.reader-container {
    max-width: 800px;
    margin: 0 auto;
    /* Адаптивные отступы: сверху под шапку, снизу под навигацию */
    padding: 1rem 1rem 100px;
    background-color: var(--book-paper);
    min-height: 100vh;
    transition: background-color 0.4s ease;
}

/* Стили для текстовых блоков (Чанков) */
.chunk-wrapper.text-chunk,
.text-chunk {
    font-family: 'Literata', Georgia, serif;
    /* Используем md размер для комфортного чтения */
    font-size: var(--fs-md);
    line-height: 1.8;
    color: var(--foreground);
    margin-bottom: 1.5rem;
    /* Улучшенная типографика */
    text-rendering: optimizeLegibility;
 /*   word-wrap: break-word; */
    /* На мобильных лучше не использовать justify, чтобы избежать дыр в тексте */
    text-align: left;
}

/* Изображения в книге */
.chunk-wrapper.image-chunk {
 /*   margin: 2rem -1rem;  Вылет картинки чуть за края текста на мобилках */
    display: flex;
    justify-content: center;
}

.chunk-wrapper.image-chunk img,
.image-chunk img {
    display: block;
 /*   width: 100% !important; */
    max-width: 100%;
    height: auto !important;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px var(--book-shadow);
    transition: transform 0.3s ease;
}

/* Эффект при клике на картинку (если будет зум) */
.image-chunk img:active {
    transform: scale(1.02);
}

/* Адаптивность для больших экранов */
@media (min-width: 768px) {
    .reader-container {
        padding: 40px 3rem 120px;
        /* Создаем эффект лежащей на столе книги за счет тени */
        box-shadow: 0 0 50px var(--book-shadow);
        margin-top: 1rem;
        margin-bottom: 2rem;
        border-radius: var(--radius);
    }

    .chunk-wrapper.image-chunk {
        margin: 2.5rem 0; /* На ПК возвращаем картинку в границы текста */
    }

    .text-chunk {
        text-align: justify; /* На больших экранах оправдано */
        hyphens: auto;      /* Автоматические переносы */
    }
}

/* Специальные настройки для темной темы ридера */
body.dark-mode .reader-container {
    /* Делаем бумагу чуть менее контрастной, чтобы не резало глаза */
    background-color: hsl(222, 15%, 13%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

body.dark-mode .text-chunk {
    color: hsl(210, 20%, 85%);
}

/* ======================================
   Search Logic & Feedback
   ====================================== */

/* Индикатор загрузки внутри поиска */
.search-bar.loading::after {
    content: "";
    position: absolute;
    right: 1rem;
    top: 50%;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: -0.625rem;
    border: 2px solid var(--muted);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Контейнер для живого поиска */
#search-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0.5rem 1rem;
    margin: 0 auto;
}

#live-search {
    width: 100%;
    max-width: 500px;
    padding: 0.75rem 1.25rem;
    font-size: var(--fs-base);
    border-radius: var(--radius);
    background-color: var(--input-bg);
    color: var(--foreground);
    border: 1px solid var(--input-border) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06) !important;
    outline: none;
    transition: all 0.3s ease;
}

#live-search:focus {
    border-color: var(--accent) !important;
    background-color: var(--card); /* В светлой теме белый, в темной — карточка */
}

/* Подсветка найденного текста */
.search-highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Контейнер поиска с твоей семантической сеткой */
.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto 2rem auto;
    display: block;
}

/* Кнопка очистки */
#clear-search {
  position: absolute;
  right: 1.25rem; /* Около 20px, но лучше в rem для гибкости */
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;

  /* Адаптивный размер: база ~18px, плавно уменьшается */
  font-size: var(--fs-md);

  color: var(--muted-foreground);
  padding: 4px; /* Чуть меньше паддинг, чтобы область клика была адекватной */
  line-height: 1;
  z-index: 10;

  /* Чтобы крестик не "прыгал" при изменении размера экрана,
     можно зафиксировать его через clamp */
  font-size: clamp(16px, 1.2vw, 20px);

  transition: color 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Эффект при наведении (как мы договаривались ранее) */
#clear-search:hover {
  transform: translateY(-50%) scale(1.15);
}
/* --- ПОВЕДЕНИЕ ПРИ НАВЕДЕНИИ --- */

/* 1. Общее наведение (легкое увеличение) */
#clear-search:hover {
    transform: translateY(-50%) scale(1.1);
}

/* 2. Светлая тема: Ярко-золотистый (используем твой --nav-icon-hover #B27C3E) */
body:not(.dark-mode) #clear-search:hover {
  /*  color: var(--accent);  Насыщенное золото для максимальной яркости */
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.4));
    color: var(--nav-icon-active);
}

/* 3. Темная тема: используем твое золото --accent (#E6B980) */
body.dark-mode #clear-search:hover {
    color: var(--accent);
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}


/* Эффект пульсации для найденного блока (чанка) */
.chunk-highlight-active {
    animation: highlight-pulse 2s ease-out;
    border-left: 4px solid #ffeb3b;
    background-color: rgba(255, 235, 59, 0.05);
    transition: background-color 0.5s ease;
}

@keyframes highlight-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 235, 59, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 235, 59, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 235, 59, 0); }
}

/* Счетчик результатов поиска */
#search-results-count {
    display: none;
    position: absolute;
    top: 115%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background-color: var(--input-bg);
    color: var(--accent);
    border: 1px solid var(--input-border);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    font-size: var(--fs-xs);
    font-weight: 600;
    z-index: 1001;
    box-shadow: 0 4px 12px var(--book-shadow);
    pointer-events: none;
}

/* ======================================
   Validation & Errors (Shake & Red)
   ====================================== */

.error-message-box {
    color: #e53e3e;
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: var(--radius);
    padding: 0; /* По умолчанию пусто */
    margin-bottom: 1rem;
    font-size: var(--fs-sm);
    text-align: center;
    transition: all 0.3s ease;
}

.error-message-box:not(:empty) {
    padding: 0.75rem;
    animation: fadeInDown 0.3s ease forwards;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/*.input-error {
    border: 1px solid var(--danger, #e74c3c);
    background-color: rgba(231, 76, 60, 0.05);
    border-radius: var(--radius);
} */

.shake {
    animation: shake-anim 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake-anim {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
    40%, 60% { transform: translate3d(3px, 0, 0); }
}

/* ======================================
   Code Blocks (Inside Reader)
   ====================================== */

.chunk-wrapper.text-chunk pre,
.chunk-wrapper.text-chunk code {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: pre;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: var(--fs-sm);
    background: #2d2d2d; /* Темный фон для кода даже в светлой теме */
    color: #f8f8f2;
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Скролл для кода */
pre::-webkit-scrollbar {
    height: 6px;
}
pre::-webkit-scrollbar-thumb {
    background: var(--muted-foreground);
    border-radius: 10px;
}

/* Настройка Reader для поиска */
.reader-container, .chunk-wrapper {
    scroll-margin-top: 100px; /* Чтобы при переходе к результату поиска заголовок не закрывал текст */
}
/* Настройка Reader для чтения, чтобы текст не выходил за границы */
.chunk-wrapper {
    display: block;
    width: 100%;
    min-height: 1.5em; /* Дает высоту пустой строке */
    position: relative;
    clear: both;       /* Чтобы плавающие элементы (если есть) не мешали */
    margin-bottom: 8px; /* Небольшой отступ между текстами */
}
/* Контейнер, внутри которого находится текст и фото */
.reader-container {
    position: relative;
    width: 100%;
    max-width: 800px; /* Или твоя ширина окна чтения */
    margin: 0 auto;
}

/* Стили для самих изображений внутри чанков */
.chunk-wrapper img {
    /* Ограничиваем по ширине контейнера */
    max-width: 100% !important;
    /* Высота подстраивается сама, сохраняя пропорции */
    height: auto !important;
    /* Если в инлайновых стилях (как в твоем примере) стоит position: absolute,
       делаем его relative, чтобы картинка не улетела в угол экрана */
    position: relative !important;
    top: auto !important;
    left: auto !important;
    display: block !important;
    margin: 10px auto !important; /* Центрируем */
    border-radius: var(--radius, 8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Контейнер для фото-чанка */
.image-chunk {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Чтобы ничего не вылазило */
}
/* Магия для пустых блоков contenteditable */
.chunk-wrapper:empty:not(:focus)::before {
    content: attr(data-placeholder); /* Можно добавить подсказку */
    color: #aaa;
    pointer-events: none;
}

/* Если блок пустой, но в фокусе — держим высоту */
.chunk-wrapper:focus {
    outline: none;
    min-height: 1.5em;
}

/* Приватность */
/* Контейнер обложки должен быть относительным */
.tour-cover {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}


/* Кнопка смены Инфо о книге */
.edit-info-btn {
    position: absolute;
    top: 10px;
    right: 115px; /* Размещаем левее кнопки смены приватности */
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: 0.2s;
}

.edit-info-btn:hover {
    background: var(--accent);
    color: white;
}

/* Стили иконки карандаша */
.edit-text-btn {
    opacity: 0.3; /* Почти прозрачная в покое */
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tour-card:hover .edit-text-btn {
    opacity: 1; /* Проявляется при наведении на карточку */
}

.edit-text-btn:hover {
    transform: scale(1.2); /* Увеличивается при наведении на саму кнопку */
}

.modern-form-group {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 100%;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

/* Базовые стили для современных инпутов */
.modern-input {
  background-color: var(--input-bg);
  color: var(--input-text) !important;
  border: 1px solid var(--input-border) !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06) !important;

  /* Увеличиваем шрифт */
  font-size: 1.1rem !important; /* Было по умолчанию около 1rem */
  font-weight: 500;            /* Делаем текст чуть плотнее */
  line-height: 1.4;            /* Улучшаем читаемость */

  padding: 0.8rem;
  border-radius: var(--radius);
  width: 100%;
  outline: none;
  transition: all 0.3s ease;
}

/* Опционально: увеличиваем шрифт плейсхолдера, чтобы он соответствовал */
.modern-input::placeholder {
  font-size: 1rem;
  opacity: 0.7;
}

.modern-input:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(from var(--accent) r g b / 0.2);
}

/* Исправляем цвет текста внутри <option> для выпадающих списков */
.modern-input option {
    background-color: var(--input-bg);
    color: var(--input-text);
}
/* Стилизация Select */
.modern-select {
    appearance: none;
    cursor: pointer;
}

.select-container::after {
    content: '▼';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: var(--input-focus);
    pointer-events: none;
    opacity: 0.7;
}

/* Анимация появления нового поля */
.hidden-animate {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hidden-animate.show {
    max-height: 100px;
    opacity: 1;
    margin-top: 0.5rem;
}

/* Предупреждение */
.modern-warning {
    font-size: 0.75rem;
    color: #ff4d4d;
    margin-top: 0.4rem;
    padding-left: 0.5rem;
    display: none;
}

.modern-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 10px 0;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
    margin-left: 4px;
    opacity: 0.9;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Спец-эффект при фокусе */
.focus-border {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: all 0.4s ease;
    transform: translateX(-50%);
}

.modern-input:focus + .focus-border {
    width: 80%;
}

/* Кастомная стрелка для селекта */


/* Анимация ошибки */
.error-text {
    display: none;
    align-items: center;
    gap: 5px;
    color: var(--danger, #e74c3c);
    font-size: 0.75rem;
    margin-top: 5px;
    padding-left: 5px;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Плавное раскрытие новой категории */
.hidden-animate {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.4s ease-in-out;
    transform: translateY(-10px);
}

.hidden-animate.show {
    max-height: 100px;
    opacity: 1;
    transform: translateY(0);
    margin-top: 5px;
}

/* Исправление видимости текста в выпадающем списке */
.modern-input option {
    background-color: #1a1a1a; /* Темный фон, под цвет вашего сайта */
    color: #ffffff;            /* Чистый белый текст */
    padding: 10px;
}

/* Для Safari и Chrome на мобильных устройствах */
.modern-select {
    background-color: var(--input-bg);
    color: white;
}

/* Стилизация первой опции (Placeholder) */
.modern-input option:disabled {
    color: rgba(255, 255, 255, 0.5);
}

/* Стиль для кнопки "Создать новую" внутри списка */
.special-option {
    color: var(--accent);
    font-weight: bold;
}

.custom-select-container {
    position: relative;
    cursor: pointer;
    user-select: none;
    border: 1.5px solid #8B5A2B;
    border-top-color: rgb(139, 90, 43);
    border-right-color: rgb(139, 90, 43);
    border-bottom-color: rgb(139, 90, 43);
    border-left-color: rgb(139, 90, 43);
  border-radius: var(--radius);
}

/* Базовое состояние (как обычный инпут) */
.custom-select-trigger.modern-input {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: var(--input-bg);
  color: var(--accent) !important;
  border: 1px solid var(--input-border) !important;
  transition: all 0.4s ease;
  z-index: 1;
}

/* Состояние при наведении И когда категория выбрана */
.custom-select-trigger.modern-input:hover,
.custom-select-trigger.modern-input.has-value {
  background: var(--btn-primary-bg) !important;
  color: var(--btn-primary-text) !important;
  border-color: #B27C3E !important;
  box-shadow: 0 4px 15px var(--btn-primary-shadow) !important;
}

/* Стеклянный блик (только при наведении, чтобы не раздражать) */
.custom-select-trigger.modern-input::after, .file-upload-custom::after, .btn-primary::after {
  content: '';
  position: absolute;
  top: 0;
  left: -150%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-25deg);
  z-index: 2;
  pointer-events: none;
}

.custom-select-trigger.modern-input:hover::after, .file-upload-custom:hover::after, .btn-primary:hover::after {
  left: 150%;
  transition: all 0.7s ease-in-out;
}

/* Текст и стрелка */
#selected-val-text { position: relative; z-index: 3; font-weight: 600; }

/* Поворот стрелки при активном состоянии */
.custom-select-container.active .custom-arrow {
    transform: rotate(180deg);
}

/* Обновляем базовый стиль стрелки для поддержки трансформации */
.custom-arrow {
    position: absolute;
    right: 15px;
    z-index: 3;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--input-text);
    /* Добавляем transform в transition для плавности */
    transition: border-color 0.4s ease, transform 0.3s ease;
    pointer-events: none; /* Чтобы клик по стрелке не мешал клику по триггеру */
}

/* Стрелка становится белой при ховере или если есть значение */
.custom-select-trigger.modern-input:hover .custom-arrow,
.custom-select-trigger.modern-input.has-value .custom-arrow {
  border-top-color: #ffffff;
}

/* Выпадающий блок */
.custom-options-wrapper {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;

    /* Используем переменные */
    background-color: var(--dropdown-bg);
    border: 1.5px solid var(--dropdown-border);

    border-radius: 12px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Тень делаем мягкой, чтобы список "парил" */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Цвет текста для опций внутри списка */
/* Выбранный пункт в списке */
.custom-option.selected {
    /* Используем базовый цвет твоей бронзовой темы */
    background-color: #8B5A2B !important;
    color: #ffffff !important;
    font-weight: 600;
}

/* Эффект при наведении на обычные пункты */
.custom-option:hover {
    /* Мягкий песочный фон при наведении, чтобы не перебивать фокус */
    background-color: rgba(178, 124, 62, 0.15) !important;
    color: var(--input-text);
}

/* Если хочешь, чтобы при наведении на уже выбранный пункт он не менялся */
.custom-option.selected:hover {
    background-color: #8B5A2B !important;
    color: #ffffff !important;
}

/* Добавим небольшое скругление для пунктов внутри обертки */
.custom-option {
    margin: 2px 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-transform: lowercase;
}

.custom-select-container.active .custom-options-wrapper {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-options-list {
    max-height: 200px;
    overflow-y: auto;
}

/* Стилизация опций */

.custom-option.special-option {
    color: var(--accent);
    font-weight: bold;
    border-top: 1px solid rgba(255, 255, 255, 0.05);

}
.custom-option.special-option.selected{
    color: white;
}

/* Анимация стрелки */


/* Добавим плавный скроллбар для списка категорий */
.custom-options-list::-webkit-scrollbar {
    width: 5px;
}
.custom-options-list::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

/* Класс ошибки для полей */
.modern-input.input-error {
    border-color: #ff4d4d !important;
    box-shadow: 0 0 8px rgba(255, 77, 77, 0.3) !important;
    background: rgba(255, 77, 77, 0.05) !important;
}

/* Анимация встряски для привлечения внимания */
@keyframes shake-input {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.input-error {
    animation: shake-input 0.3s ease-in-out;
}

/* ======================================
   Notification System (Fixed & Adaptive)
   ====================================== */

/* Глобальный контейнер уведомлений */
#notif-fixed-container {
    position: fixed;
    top: 0.2rem;
    right: 0.2rem;
    z-index: 9999;
    /* Используем cubic-bezier для эффекта "выпрыгивания" */
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: block;
}

/* Скрываем блок, если бадж пуст или скрыт */
#notif-fixed-container:has(#notif-badge.hidden),
#notif-fixed-container:has(#notif-badge:empty) {
    opacity: 0;
    transform: scale(0.5) translateY(-20px);
    pointer-events: none;
}

/* Круг колокольчика */
.notif-circle {
    background: var(--card); /* Адаптивный фон под тему */
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--book-shadow);
    border: 2px solid var(--primary); /* Бронзовый акцент */
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

/* Анимация тряски колокольчика */
#notif-fixed-container:not(.hidden-notif) .notif-circle svg {
    animation: ring-shake 2.5s infinite ease-in-out;
    transform-origin: top center;
}

@keyframes ring-shake {
    0%, 100% { transform: rotate(0); }
    5%, 15%, 25% { transform: rotate(15deg); }
    10%, 20%, 30% { transform: rotate(-15deg); }
    35% { transform: rotate(0); }
}

.notif-circle:hover {
    transform: scale(1.1);
    background: var(--secondary);
}

.notif-circle:hover svg {
    animation-play-state: paused;
}

/* Бейдж (цифра сверху) */
#notif-badge {
    position: absolute;
    top: 0px;
    right: 0px;
    background: var(--destructive);
    color: var(--nav-icon-color);
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border: 2px solid var(--card);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Выпадающее меню уведомлений */
#notif-dropdown {
    position: absolute;
    top: 3.5rem;
    right: 0;
    width: clamp(280px, 80vw, 320px);
    z-index: 10000;
    background-color: var(--card) !important;
    color: var(--foreground) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: 0 10px 30px var(--book-shadow);

    /* Плавное появление */
    animation: fadeInDown 0.3s ease forwards;
}
/* --- КРЕСТИК (АДАПТИВНЫЙ) --- */
.close-manual-btn {
    cursor: pointer;
    /* Цвет берется из основного текста темы */
    color: var(--foreground) !important;
    font-size: 1.8rem;
    font-weight: bold;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
}

.close-manual-btn:hover {
    opacity: 1;
    color: var(--primary) !important; /* При наведении подсветим оранжевым */
    transform: scale(1.1);
}
/* Стили для элементов внутри списка уведомлений */
.notif-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-sm);
    transition: background 0.2s ease;
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: rgba(from var(--accent) r g b / 0.05); }

/* Адаптация для мобильных: смещаем меню в центр, если экран мал */
@media (max-width: 480px) {
    #notif-dropdown {
        right: calc(-1 * (100vw - 320px) / 2); /* Примерное центрирование */
        position: fixed;
        top: 5rem;
        left: 1rem;
        right: 1rem;
        width: auto;
    }
    #notif-fixed-container {
  top: 0.5rem;
  right: 0.8rem;
}
}

/* ======================================
   Accent Borders & Warning Styles
   ====================================== */

/* Кнопки управления (редактирование, обложка, уведомления) */
.edit-cover-btn,
.edit-info-btn,
.notif-circle {
    border-color: var(--accent) !important;
    border-width: 1px;
    border-style: solid;
}

/* Состояние ошибки в инпутах с акцентной окантовкой */
.modern-input.input-error {
    border-color: var(--accent) !important; /* Твое требование по акценту */
    background-color: rgba(from var(--destructive) r g b / 0.05) !important;
    box-shadow: 0 0 8px rgba(from var(--accent) r g b / 0.2) !important;
}

/* Кастомный селект в состоянии предупреждения или выбора */
.custom-select-trigger.modern-input.input-error {
    border-color: var(--accent) !important;
}

/* Если есть блок прямого предупреждения (modern-warning) */
.modern-warning {
    border: 1px solid var(--accent) !important;
    background: rgba(from var(--accent) r g b / 0.05);
    color: var(--destructive);
    padding: 0.5rem;
    border-radius: var(--radius);
    font-size: var(--fs-xs);
    margin-top: 0.5rem;
}


/* ======================================
   Pagination & Outline Buttons
   ====================================== */

/* Базовая контурная кнопка */
.btn-outline {
    background-color: transparent;
    color: var(--foreground);
    border: 2px solid var(--accent) !important;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
    width: 100%;
    margin-bottom: 1rem;
    text-align: center;
}

.btn-outline:hover,
.btn-outline:active {
    background-color: var(--accent);
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(from var(--accent) r g b / 0.3);
}

.btn-outline:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Кнопка "Загрузить предыдущие" (Верхняя пагинация) */
#btn-load-prev {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem; /* ~10px 24px */
    background: transparent;
  /*  color: var(--primary);  Бронзовый из темы
    border: 1.5px solid var(--primary); */
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 1rem auto !important;
    width: fit-content;
}

#btn-load-prev:hover {
    background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(139, 90, 43, 0.4);
}

/* Кнопка "Загрузить еще" (Нижняя пагинация) */
.btn-load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem; /* ~12px 28px */
    background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%);
 /*   color: #ffffff !important; */
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 2rem auto !important;
    width: fit-content;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.btn-load-more:hover {
    background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  transform: translateY(3px);
  box-shadow: 0 5px 15px rgba(139, 90, 43, 0.4);
}

.btn-load-more:active {
    transform: translateY(2px);
}

/* --- Адаптация под темную тему --- */

body.dark-mode #btn-load-prev {
    color: var(--accent); /* Песочный/Золотистый в покое */
 /*   border-color: var(--primary); */
}

body.dark-mode .btn-load-more {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    /* Дополнительный блеск для темной темы */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Спиннер загрузки внутри кнопок */
.btn-loading-icon {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}


/* Используем цепочку классов, чтобы повысить приоритет */
div#tours-container .books-grid .tour-card {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Это правило ДОЛЖНО быть ниже в файле и иметь такой же или больший вес */
div#tours-container .books-grid .tour-card.visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
}

/* ======================================
   Navigation (Bordered & Filled Active State)
   ====================================== */

nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--card);
    padding: 0.6rem;
    border-top: 1px solid var(--border);
    transition: background-color 0.3s ease;
    /* Учет безопасной зоны iPhone */
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom));
}

nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex: 1;
    position: relative;
    color: var(--muted-foreground);
    padding: 0.5rem 0;
    margin: 0 5px; /* Небольшой отступ между "кнопками" */
    border-radius: var(--radius);
    border: 1px solid transparent; /* Резервируем место под границу */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

/* Активное состояние: Заливка + Окантовка */
nav a.active {
    background: var(--secondary) !important;
    border-color: var(--accent) !important;
    color: var(--accent) !important; /* Текст в цвет акцента для гармонии */
}

/* Состояние при наведении (только десктоп) */
@media (hover: hover) {
    nav a:not(.active):hover {
        background: rgba(from var(--secondary) r g b / 0.5);
        color: var(--foreground);
    }
}

.nav-icon {
    font-size: 1.4rem;
    line-height: 1;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    transition: transform 0.2s ease;
}

/* Текстовая подпись */
nav a span:not(.nav-icon) {
    font-size: 0.7rem;
    font-weight: 700; /* Делаем текст чуть жирнее для читаемости */
    letter-spacing: 0.3px;
    text-transform: uppercase; /* Опционально: для более строгого вида меню */
}

/* Темная тема */
body.dark-mode nav {
    background: var(--background);
}

body.dark-mode nav a.active {
    /* Добавляем легкое внутреннее свечение в темной теме */
    box-shadow: inset 0 0 10px rgba(from var(--accent) r g b / 0.1);
}
/* ======================================
   Кнопка Выход (Logout Button)
   ====================================== */

/* Сначала добавим переменные для управления цветом выхода, если их еще нет */


.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    background-color: var(--logout-bg) !important;
 /*   color: var(--logout-text) !important; */
    border: none;
    padding: 14px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: var(--fs-base);
    width: 100%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-top: 20px;

    /* Убираем стандартное выделение */
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.logout-btn:hover {
    background-color: var(--logout-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.12);
}

.logout-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Стили иконки внутри кнопки (если есть) */
.logout-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke: currentColor;
    stroke-width: 2px;
    fill: none;
}

/* В темном режиме делаем кнопку более глубокой */
body.dark-mode .logout-btn {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(239, 68, 68, 0.2) !important; /* Тонкая красная кайма */
}

/* Если кнопка находится внутри навигации или узкого меню */
@media (max-width: 480px) {
    .logout-btn {
        padding: 12px;
        font-size: var(--fs-sm);
    }
}
/* Кнопка Назад */
.back-btn-modern {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: transparent;
    color: #8B5A2B; /* Базовый бронзовый */
    border: 1.5px solid #8B5A2B;
    border-radius: var(--radius);
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.back-btn-modern:hover {
    /* Твой фирменный бронзовый градиент */
    background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%);
    color: white;
    border-color: transparent;

    /* Эффект легкого свечения */
    box-shadow: 0 4px 15px rgba(139, 90, 43, 0.3);

    /* Сдвиг влево, подчеркивающий действие "назад" */
  /*  transform: translateX(-5px);  */
    /* Сдвиг вверх */
 /*   transform: translateY(-2px); */
}

/* Добавим микро-анимацию стрелочке внутри кнопки, если она есть */
.back-btn-modern:hover svg {
    transform: translateX(-2px);
    transition: transform 0.2s ease;
}

/* Адаптация под темную тему */
body.dark-mode .back-btn-modern {
    color: #E6B980;
    border-color: #8B5A2B;
}

body.dark-mode .back-btn-modern:hover {
    color: white;
}

/* ======================================
   Чекбоксы и Метки (Branded Style)
   ====================================== */

.checkbox-group-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

input[type="checkbox"] {
    /* Используем твой основной коричневый цвет */
    accent-color: var(--accent);

    /* Удобный размер для клика */
    width: 1.125rem; /* ~18px */
    height: 1.125rem;
    cursor: pointer;

    /* Плавное уменьшение при нажатии */
    transition: transform 0.1s ease;
    vertical-align: middle;
}

input[type="checkbox"]:active {
    transform: scale(0.9);
}
/* Подсветка обычных инпутов */
.modern-input.input-error {
    border-color: var(--danger, #e74c3c) !important;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2);
}

/* Подсветка группы чекбоксов */
.checkbox-group-container.input-error {
    border: 1px solid var(--danger, #e74c3c);
    background-color: rgba(231, 76, 60, 0.05);
    border-radius: var(--radius);
    padding: 10px;
}
/* Базовое состояние (без ошибки) */
.custom-select-container .custom-select-trigger {
    border: 1px solid var(--border-color) !important; /* Твой стандартный цвет */
}


.modern-input,
.checkbox-group-container,
.custom-cat-select,
#up-file-label {
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    overflow: hidden;
}
/* Состояние ошибки */
.file-upload-custom.input-error, .custom-select-container.input-error {
    border: 1px solid var(--danger, #e74c3c);
    background-color: rgba(231, 76, 60, 0.05);
    border-radius: var(--radius);
}
.custom-select-container.input-error .custom-select-trigger {
    background-color: rgba(231, 76, 60, 0.05) !important;
}
/* Стиль для текста рядом с чекбоксом */
label {
    color: var(--foreground);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none; /* Защита от выделения текста при частом клике */

    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

/* При наведении на текст или чекбокс подсвечиваем бронзовым */
label:hover {
    color: var(--accent);
  box-shadow: 0 8px 20px var(--btn-primary-shadow);
  filter: brightness(1.1);
}

/* В режиме редактирования чекбоксы могут быть чуть ярче */
.is-editing input[type="checkbox"] {
    box-shadow: 0 0 0 2px rgba(from var(--accent) r g b / 0.2);
    border-radius: 2px;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    input[type="checkbox"] {
        width: 1.25rem; /* Увеличиваем до 20px на тач-экранах */
        height: 1.25rem;
    }

    label {
        font-size: 1rem;
        padding: 6px 0; /* Увеличиваем область нажатия */
    }
}
/* Дополнительно: стиль для редактирования Категории */
/* --- БЕЙДЖ КАТЕГОРИИ (ОСНОВНОЙ СТИЛЬ) --- */
.book-badge {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%) scale(1);

    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);

    color: white;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 2;

    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    max-width: 80%;
    overflow: hidden;

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Эффект наведения для владельца (Твой коричневый градиент) */
.book-badge.is-editable:hover {
    background: var(--btn-primary-bg) !important;
    cursor: pointer;
    /* Центровка сохранена */
    transform: translateX(-50%) translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* --- СОСТОЯНИЕ РЕДАКТИРОВАНИЯ --- */
.book-badge.is-editing-mode {
    background: var(--input-bg) !important;
    /* Пунктирная рамка в твоем цвете hsl(30, 53%, 35%) */
    border: 1.5px dashed hsl(30, 53%, 35%) !important;

    /* Мягкое свечение с использованием твоего HSL */
    box-shadow: 0 0 10px hsla(30, 53%, 35%, 0.3);

    cursor: text;
    transform: translateX(-50%) scale(1.05);
}

.book-badge.is-editing-mode .badge-text {
    color: var(--input-text) !important;
    outline: none;
    padding: 0 6px;
    letter-spacing: 0.02em;
}

/* Текст внутри бейджа */
.badge-text {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    vertical-align: middle;
    min-width: 20px;
    outline: none;
}

/* Иконка карандаша */
.book-badge .edit-mini-pen {
    font-size: 0.8em;
    opacity: 0.7;
    transition: opacity 0.2s;
    pointer-events: none;
}

.book-badge:hover .edit-mini-pen {
    opacity: 1;
}

/* --- АНИМАЦИЯ УСПЕХА (FLASH) --- */
.badge-success-flash {
    animation: badge-flash 0.8s ease;
}

@keyframes badge-flash {
    0% {
        filter: brightness(1);
        transform: translateX(-50%) scale(1.05);
    }
    50% {
        filter: brightness(1.3);
        /* Вспышка в твоем коричневом тоне */
        background: hsl(30, 53%, 45%) !important;
        transform: translateX(-50%) scale(1.15);
    }
    100% {
        filter: brightness(1);
        transform: translateX(-50%) scale(1);
    }
}

/* Оптимизация для мобилок */
@media (max-width: 768px) {
    .book-badge {
        padding: 3px 10px;
        font-size: 0.7rem;
    }
}

/* Редактирование контента книги */
/* 1. БАЗОВЫЕ СТИЛИ ЧАНКОВ */
.text-chunk {
    padding: 10px 15px;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    max-width: 65ch;
}

/* 2. РЕЖИМ РЕДАКТИРОВАНИЯ КОНТЕНТА (когда активирован в ридере) */
.is-editing-active .text-chunk {
    cursor: text;
    border-left: 2px dashed var(--primary);
    background: rgba(var(--primary-rgb), 0.02);
    margin-bottom: 5px;
}

.is-editing-active .text-chunk:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

.is-editing-active .text-chunk:focus {
    outline: none;
    background: var(--input-bg);
    border-left: 3px solid var(--primary);
    box-shadow: 0 4px 12px var(--book-shadow);
}

/* Индикация успешного сохранения в твоем стиле */
.save-success {
    border-left: 3px solid #8B5A2B !important; /* Твой коричневый */
    background: rgba(178, 124, 62, 0.05) !important; /* Очень легкий тон основного цвета */
    box-shadow: inset 5px 0 10px -5px rgba(139, 90, 43, 0.4);
    transition: all 0.3s ease;
}

/* Для темной темы сделаем цвет чуть светлее, чтобы он был заметен */
body.dark-mode .save-success {
    border-left-color: #C69052 !important;
    background: rgba(198, 144, 82, 0.05) !important;
    box-shadow: inset 5px 0 10px -5px rgba(198, 144, 82, 0.4);
}

.image-chunk {
    cursor: default;
    contenteditable: false;
}

/* 3. КНОПКА РЕДАКТИРОВАНИЯ В ХЕДЕРЕ */
#edit-mode-toggle {
  /*  min-width: 160px;*/
    justify-content: center;
    /* Отключаем смещение при наведении именно для этой кнопки */
    transform: none !important;
}

#edit-mode-toggle:hover {
    transform: none !important;
}

/* Состояние "Завершить" (Активный режим редактирования) */
.back-btn-modern.btn-editing-active {
    background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%) !important;
    color: white !important;
    border-color: transparent !important;
    box-shadow: 0 4px 15px rgba(139, 90, 43, 0.3);
}

/* Темная тема для активной кнопки */
body.dark-mode .back-btn-modern.btn-editing-active {
    color: white !important;
    background: linear-gradient(135deg, #C69052 0%, #9E6B3A 100%) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* Иконка внутри кнопки */
.edit-icon-container {
    display: flex;
    align-items: center;
}

/* Метка режима в логотипе (если используется) */
.edit-badge {
    font-size: 0.8rem;
    background: var(--accent);
    padding: 4px 10px;
    border-radius: 12px;
    color: white;
}

/* Стили для редактируемых полей в карточке */
.editable-info {
    outline: none;
    border-radius: 4px;
    transition: all 0.3s ease;
    border-bottom: 1px dashed transparent;
}

.editable-info:hover {
    background: rgba(139, 90, 43, 0.05);
    border-bottom: 1px dashed #8B5A2B;
}

.editable-info:focus {
    background: var(--input-bg);
    border-bottom: 1px solid #8B5A2B;
}

/* Индикация успеха (Твой коричневый) */
.save-success-info {
    color: #8B5A2B !important;
    text-shadow: 0 0 8px rgba(139, 90, 43, 0.3);
    transition: all 0.5s ease;
}

body.dark-mode .save-success-info {
    color: #E6B980 !important;
    text-shadow: 0 0 10px rgba(230, 185, 128, 0.4);
}

/* Подсветка полей, когда нажата кнопка редактирования */
.is-editing .tour-title,
.is-editing .tour-author {
    background: var(--input-bg);
    border-radius: 4px;
    padding-left: 5px;
    border-bottom: 1px dashed var(--primary);
    cursor: text;
}

/* Скрываем/меняем вид значка при редактировании, если нужно */
.is-editing .edit-info-minimal {
    opacity: 0.5;
    pointer-events: none;
}

/* Твоя индикация успеха */
.save-success-info {
    color: #8B5A2B !important;
    transition: color 0.5s ease;
}

/* Редактирование картинки в тексте книги */
/* Контейнер картинки в режиме редактирования */
/* Контейнер картинки */
.is-editing-active .image-chunk {
    position: relative;
    border: 1.5px dashed #8B5A2B;
    padding: 10px;
    margin: 15px 0;
    border-radius: var(--radius);
    background: rgba(139, 90, 43, 0.05);
}

/* Оверлей */
.image-edit-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10;
}

.is-editing-active .image-chunk:hover .image-edit-overlay {
    display: flex;
}

/* Кнопки управления (в стиле back-btn-modern) */
.img-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white; /* Светлый фон, чтобы выделяться на фоне фото */
    color: #8B5A2B;
    border: 1.5px solid #8B5A2B;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.img-action-btn:hover {
    border-color: var(--accent) !important;
  background: var(--secondary) !important;
  color: var(--accent) !important;
  transform: translateY(-1px);
  transform: translateY(-2px) !important;
}

/* Темная тема */
body.dark-mode .img-action-btn {
    background: #1a1a1a;
    color: #E6B980;
    border-color: #8B5A2B;
}

/* Кнопка удаления с красным акцентом при ховере */
.img-delete-btn:hover {
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%) !important;
    box-shadow: 0 4px 15px rgba(211, 47, 47, 0.4);
    color: white !important;
}

/* Кнопка-разделитель в твоем стиле */
.insert-divider {
    height: 6px;
    margin: 12px 0;
    background: rgba(139, 90, 43, 0.15);
    border-radius: var(--radius);
    cursor: pointer;
    display: none;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.is-editing-active .insert-divider {
    display: block;
}

.insert-divider:hover {
    height: 32px;
    background: transparent;
    border: 1.5px solid #8B5A2B;
    color: #8B5A2B;
    display: flex;
    align-items: center;
    justify-content: center;
}

.insert-divider::after {
    /* Берем текст из атрибута data-label */
    content: attr(data-label);
    font-weight: 600;
    color: #8B5A2B;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.insert-divider:hover::after {
    opacity: 1;
    transform: translateY(0);
}

/* Для темной темы */
body.dark-mode .insert-divider::after {
    color: #E6B980;
}

/* Анимация вращения */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Состояние загрузки для разделителя */
.insert-divider.loading {
    height: 40px !important;
    background: rgba(139, 90, 43, 0.05);
    border: 1.5px solid #8B5A2B;
    display: flex !important;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.insert-divider.loading::after {
    content: "" !important; /* Убираем текст */
    width: 20px;
    height: 20px;
    border: 3px solid rgba(139, 90, 43, 0.2);
    border-top-color: #8B5A2B;
    border-radius: var(--radius);
    animation: spin 0.8s linear infinite;
    opacity: 1 !important;
    display: block;
}

/* Анимация схлопывания при удалении */
.chunk-fade-out {
    opacity: 0;
    transform: scale(0.9);
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none; /* Чтобы нельзя было кликнуть во время удаления */
}

/* Лоадер для режима замены */
.image-chunk.replacing img {
    filter: blur(2px) brightness(0.7);
    pointer-events: none;
}

.image-chunk.replacing::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: var(--radius);
    animation: spin 0.8s linear infinite;
    z-index: 11;
}

/* Стиль кнопки, когда режим редактирования ВКЛЮЧЕН */
.back-btn-modern.btn-editing-active {
    background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%) !important;
    color: white !important;
    border-color: transparent !important;
    box-shadow: 0 4px 15px rgba(139, 90, 43, 0.4);
}

/* Фикс для иконок внутри активной кнопки */
.back-btn-modern.btn-editing-active svg {
    stroke: white;
}

/* По умолчанию скрываем графические стрелки */
.nav-arrow-icon {
    display: none;
    width: 24px;
    height: 24px;
}

/* Настройки для мобильной версии */
@media (max-width: 768px) {
    /* Скрываем текстовую надпись и символьные стрелки ↑ ↓ */
    .back-btn-modern .text-label {
        display: none;
    }

    /* Показываем графическую иконку */
    .nav-arrow-icon {
        display: inline-block;
        vertical-align: middle;
    }

    /* Делаем кнопку более квадратной и удобной для тапа */
    .back-btn-modern {
        padding: 10px 25px !important;
        min-width: 80px;
        justify-content: center;
    }
}

/* Боковые зоны: одинаковая база для идеального центра */
.header-side-area {
    flex: 1 1 30%; /* Позволяем им занимать до 30% ширины */
    display: flex;
    align-items: center;
    min-width: 45px; /* Минимальное место для одной кнопки-иконки */
}

/* На десктопе ограничиваем кнопки по ширине для красоты */
.back-btn-modern {
    min-width: 100px;
    height: 40px;
    justify-content: center;
}

@media (max-width: 768px) {
    /* На мобилках боковые зоны сжимаются до размера иконок */
    .header-side-area {
        flex: 0 0 45px;
    }

    .back-btn-modern {
        min-width: 40px;
        width: 40px;
        padding: 0 !important;
    }

    .back-btn-modern .text,
    .back-btn-modern .text-search {
        display: none !important;
    }

    /* Магия центра: поиск заберет всё остальное пространство */
    #header-center-zone {
        flex: 1;
    }
}

/* Когда поиск открыт, убираем бока совсем */
body.search-active .header-side-area {
    display: none !important;
}
/* Убираем смещение translateX для этой кнопки, чтобы она не «прыгала» влево в центре */
#edit-mode-toggle:hover {
    transform: translateY(-2px) !important; /* Лучше использовать вертикальный подъем */
}

/* Кнопка-разделитель в режиме редактирования (сразу видна) */
.is-editing-active .insert-divider {
    display: flex; /* Показываем */
    height: 32px;
    margin: 15px 0;
    background: transparent;
    border: 1.5px solid #8B5A2B;
    color: #8B5A2B;
    border-radius: var(--radius);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Текст внутри кнопки (всегда виден в режиме правки) */
.is-editing-active .insert-divider::after {
    content: attr(data-label);
    font-weight: 600;
    opacity: 1; /* Всегда виден */
    transform: none;
    transition: color 0.3s ease;
}

/* Эффект при наведении на кнопку + */
.is-editing-active .insert-divider:hover {
    background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%);
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(139, 90, 43, 0.3);
}

/* Меняем цвет текста на белый при наведении */
.is-editing-active .insert-divider:hover::after {
    color: white;
}

/* Темная тема */
body.dark-mode .is-editing-active .insert-divider {
    border-color: #8B5A2B;
    color: #E6B980;
}
body.dark-mode .is-editing-active .insert-divider:hover::after {
    color: white;
}

/* Контейнер для кнопок вставки */
.insert-divider-container {
    display: none; /* Скрыто по умолчанию */
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    padding: 10px 0;
    border-top: 1px solid rgba(139, 90, 43, 0.1);
}

.is-editing-active .insert-divider-container {
    display: flex;
}

/* Кнопки вставки (стиль как у back-btn-modern) */
.insert-divider-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    color: #8B5A2B;
    border: 1.5px solid #8B5A2B;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    transition: all 0.3s ease;
    min-width: 100px;
}

.insert-divider-btn:hover {
    border-color: var(--accent);
  background: var(--secondary);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Состояние загрузки для кнопок */
.insert-divider-btn.loading {
    pointer-events: none;
    color: transparent !important;
    position: relative;
}

.insert-divider-btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(139, 90, 43, 0.3);
    border-top-color: currentColor;
    border-radius: var(--radius);
    animation: spin 0.8s linear infinite;
}

/* Если блок пустой, показываем плейсхолдер через атрибут */
.text-chunk[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #a0a0a0;
    font-style: italic;
    cursor: text;
}

.is-editing-active .text-chunk[contenteditable="true"] {
    min-height: 1.5em; /* Чтобы курсор было видно */
    outline: none;
}

/* Опционально: можно подсветить активный блок, в котором стоит курсор */
.text-chunk[contenteditable="true"]:focus {
    background: rgba(139, 90, 43, 0.03);
    border-radius: 4px;
}

/* Состояние кнопки по умолчанию в темной теме */
body.dark-mode .img-action-btn {
  background: #1a1a1a;
  color: #E6B980;
  border: 1px solid #8B5A2B;
  transition: all 0.3s ease; /* Плавный переход цвета */
}

/* Состояние при наведении (hover) */
body.dark-mode .img-action-btn:hover {
  background: #8B5A2B; /* Коричневый фон */
  color: #ffffff;      /* Белый текст */
  border-color: #E6B980; /* Опционально: высветляем рамку при наведении */
}

/* Оверлей с эффектом размытия */
.confirm-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: hsla(25, 30%, 15%, 0.4); /* Полупрозрачный цвет из твоей палитры */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(8px);
}

/* Само модальное окно */
.confirm-modal {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 360px;
    width: 90%;
    text-align: center;
    color: var(--card-foreground);
    box-shadow: 0 20px 40px var(--book-shadow);
}

.confirm-modal h3 {
    margin-top: 0;
    color: var(--accent);
}

.confirm-modal p {
    color: var(--muted-foreground);
    line-height: 1.5;
}

/* Контейнер для кнопок */
.confirm-buttons {
    display: flex;
    gap: 12px;
    margin-top: 1.5rem;
    justify-content: center;
}
/* Применяем к твоим стилям */
.text-chunk {
    font-size: var(--fs-text);
    line-height: 1.6; /* Увеличиваем межстрочный интервал для читаемости */
}

.confirm-modal h3 {
    font-size: var(--fs-h3);
}

.edit-badge, .insert-divider::after, .insert-divider-btn {
    font-size: var(--fs-small);
}
@media (max-width: 480px) {
    .insert-divider-container {
        flex-wrap: wrap; /* Кнопки встанут друг под друга, если не влезут */
        gap: 10px;
    }

    .insert-divider-btn {
        flex: 1 1 40%; /* Кнопки растянутся по 2 в ряд */
        padding: 10px 12px;
    }

    .confirm-modal {
        padding: 1.5rem; /* Уменьшаем внутренние отступы в модалке */
    }
}
@media (max-width: 768px) {
    .img-action-btn {
        padding: 8px 12px;
        font-size: 12px; /* Чуть меньше для мобилок */
    }

    /* Если в чанке очень длинное слово, оно не должно рвать экран */
    .text-chunk {
        word-break: break-word;
        hyphens: auto;
    }
}

.text-chunk {
    white-space: pre-wrap;      /* Сохраняет переносы строк как в оригинале */
 /*   word-break: break-all;       Разрывает длинный CSS-код, чтобы не было прокрутки */
    overflow-wrap: anywhere;    /* Современный стандарт переноса */
    line-height: 1.6;
    color: var(--foreground);
    padding: 0.5rem 0;
    /* Заставляет браузер использовать <br> вместо <div> при переносе строки */
    display: block;
    line-height: 1.5;
}
/* Кнопки */
.confirm-btn {
    padding: 0.75rem 1.5rem;
    border-radius: calc(var(--radius) / 1.5);
    border: 1px solid var(--border);
    background: var(--secondary);
    color: var(--secondary-foreground);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#confirm-cancel, #confirm-ok{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  transition: all 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.confirm-overlay {
    animation: fadeIn 0.2s ease-out;
}

.confirm-modal {
    animation: slideUp 0.3s ease-out;
}

.confirm-btn:hover {
  background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  transform: translateY(3px);
  box-shadow: 0 5px 15px rgba(139, 90, 43, 0.4);
}

/*.confirm-danger { border-color: var(--accent); color: var(--accent); } */
.confirm-danger:hover { background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%); color: white; }

/* Заголовок в модальном окне при удалении */
.confirm-modal h3 {
    transition: color 0.3s ease;
}

/* Кнопка подтверждения для опасных действий */
.confirm-danger {
    border: 1.5px solid var(--danger, #e74c3c) !important;
    color: var(--danger, #e74c3c) !important;
    border-color: var(--danger, #e74c3c) !important;
    background: transparent;
}

.confirm-danger:hover {
    background: var(--danger, #e74c3c) !important;
    color: #fff !important;
}

#file-name-display {
    display: block;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--muted-foreground);
    font-style: italic;
    transition: color 0.3s ease;
    width: 100%;             /* Занимает всю ширину контейнера */
    white-space: nowrap;     /* Запрещаем перенос текста на новую строку */
    overflow: hidden;        /* Прячем то, что не влезло */
    text-overflow: ellipsis; /* Добавляем то самое многоточие (...) */
}

#file-name-display.file-selected {
    color: var(--accent); /* Подсвечиваем акцентным цветом при успехе */
    font-style: normal;
    font-weight: 500;
}

/* Если внутри cover-name-display есть текст, можем подсветить рамку label */
/* Базовый вид: коричневый текст, пунктир */
/* Базовый вид кнопки */
/* Базовый стиль для кнопок PDF и Обложки */
.file-upload-custom, .cover-upload-custom {
    display: block;
    text-align: center;
    padding: 10px 16px;
    background: var(--secondary);
    border: 1.5px solid #8B5A2B; /* Сплошная линия как в твоем примере */
    border-radius: var(--radius);
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    color: var(--accent);
}

/* Цвет для ТЕМНОЙ темы */
/*body.dark-mode .file-upload-custom,
body.dark-mode .cover-upload-custom {
    border-color: #8B5A2B !important;
} */

/* СОСТОЯНИЕ: Наведение или Выбранный файл (Общее для обеих тем) */
.file-upload-custom:hover,
.file-upload-custom.has-file,
.cover-upload-custom:hover,
.cover-upload-custom.has-file {
    background: linear-gradient(135deg, #B27C3E 0%, #8B5A2B 100%) !important;
  color: white !important;
  border-color: transparent !important;
  box-shadow: 0 4px 15px rgba(139, 90, 43, 0.3);
}

/* Принудительно белый текст в темной теме при наведении */
body.dark-mode .file-upload-custom:hover,
body.dark-mode .file-upload-custom.has-file,
body.dark-mode .cover-upload-custom:hover,
body.dark-mode .cover-upload-custom.has-file {
    color: white !important;
}

/* Стили для имен файлов под кнопками */
.upload-name-status, #cover-name-display {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    text-align: center;
    color: var(--accent);
    min-height: 1.2em;
    font-weight: 500;
    width: 100%;             /* Занимает всю ширину контейнера */
    white-space: nowrap;     /* Запрещаем перенос текста на новую строку */
    overflow: hidden;        /* Прячем то, что не влезло */
    text-overflow: ellipsis; /* Добавляем то самое многоточие (...) */
}
/* Оптимизация отрисовки карточек */
.tour-card {
    contain: layout style; /* Подсказываем браузеру не пересчитывать всё дерево */
}
/* Убираем задержку JS, добавляем плавное появление через CSS */
.tour-card.visible-fast {
    animation: fadeInQuick 0.3s ease forwards;
    opacity: 0;
 /*   will-change: transform, opacity; */
}

@keyframes fadeInQuick {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Контейнер: выравнивает всё содержимое по центру строки */
.checkbox-group-container {
    display: flex;
    flex-direction: row;    /* В одну линию */
    justify-content: center; /* Центрирует группы чекбоксов по горизонтали */
    align-items: center;    /* Центрирует чекбокс и текст по вертикали */
    gap: 24px;              /* Расстояние между двумя группами */
    width: 100%;            /* Растягиваем на всю ширину для корректного центра */
    margin: 10px 0;         /* Небольшой отступ сверху и снизу */
}

/* Каждая пара (чекбокс + текст) */
.custom-checkbox-label {
    display: flex;
    align-items: center;    /* Центровка текста относительно квадратика */
    cursor: pointer;
    white-space: nowrap;    /* Чтобы текст не разрывался */
}

/* Отступ текста от "своего" чекбокса */
.custom-checkbox-label span {
    margin-left: 8px;
    line-height: 1;         /* Чтобы текст не "прыгал" выше/ниже центра */
}

/* Убираем лишние отступы у инпута для идеальной точности */
.custom-checkbox-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

/* Убеждаемся, что внутри центральной зоны элементы ведут себя предсказуемо */
#header-center-zone {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Обертка инпута должна занимать всю доступную ширину центра */
#header-search-input-wrapper {
    display: none; /* Скрыто по умолчанию, включается через JS */
    width: 100%;
    align-items: center;
    justify-content: center;
}

/* Когда поиск активен на мобилках, центр расширяется */
body.search-active #header-center-zone {
    flex: 1 1 100% !important;
}

/* УНИВЕРСАЛЬНАЯ МОБИЛЬНАЯ АДАПТАЦИЯ (768px и ниже) */
@media (max-width: 768px) {
    /* 1. Скрываем текст во всех кнопках хедера */
    #header-left-zone .text,
    #header-center-zone .text-search,
    #header-right-zone .text {
        display: none !important;
    }

    /* 2. Делаем зоны фиксированными по краям, чтобы поиск был в центре */
    .header-side-area {
        flex: 0 0 45px !important; /* Даем ровно столько места, сколько нужно кнопке */
    }

    /* 3. Очищаем центр от старых абсолютов */
    #header-center-zone {
        position: relative !important;
        left: auto !important;
        transform: none !important;
        max-width: none !important; /* Убираем лимит 160px/180px */
        flex: 1 !important;
        display: flex;
        justify-content: center;
    }

    /* 4. МАГИЯ ПОИСКА: когда поиск активен */
    body.search-active #header-left-zone,
    body.search-active #header-right-zone {
        display: none !important; /* Полностью убираем бока */
    }

    body.search-active #header-center-zone {
        flex: 0 0 100% !important; /* Центр занимает всю ширину */
        max-width: 100% !important;
        padding: 0;
    }

    #header-search-input-wrapper {
        width: 100% !important;
    }
}

/* Кнопка редактирования текста под книгой */
.edit-info-minimal {
    background: rgba(230, 185, 128, 0.1); /* Легкий фирменный фон */
    border: 1px solid rgba(230, 185, 128, 0.2);
    border-radius: var(--radius);
    color: var(--accent);
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
  /*  margin: 10px auto 0 auto;  Центрируем под автором */
}

.edit-info-minimal:hover {
    opacity: 1;
    background: rgba(230, 185, 128, 0.2);
    transform: scale(1.1);
}

/* Контейнер категории по центру */
/* 1. Родительская карточка */
.tour-card {
    display: flex;
    flex-direction: column;
    min-width: 0;       /* Позволяет дочерним элементам сжиматься */
    width: 100%;
}

/* 2. Контейнер категории (Наплыв на обложку) */
.tour-category-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: -1rem auto 0.5rem auto; /* Использование rem для консистентности */
    position: relative;
    z-index: 10;
    width: 100%;
    container-type: inline-size; /* Для внутренней адаптивности текста */
}

/* 3. Сама плашка (Кнопка) */
.category-badge-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.9rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    white-space: nowrap;
    max-width: 85%;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* --- СВЕТЛАЯ ТЕМА (Коричневый текст + Золотой ободок) --- */
body:not(.dark-mode) .category-badge-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid #D4A017; /* Твое яркое золото */
    color: #8B5A2B; /* Твой лаконичный коричневый */
    box-shadow: 0 4px 12px rgba(139, 90, 43, 0.15);
}

/* --- ТЕМНАЯ ТЕМА (Бронзовый акцент) --- */
body.dark-mode .category-badge-btn {
    background: rgba(40, 44, 52, 0.8);
    border: 1px solid rgba(230, 185, 128, 0.3);
    color: var(--accent); /* Золото #E6B980 */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* 4. Спан с текстом внутри */
.badge-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    flex: 1;
    min-width: 0;
    text-transform: lowercase;
}

/* Мини-карандаш (Редактирование) */
.edit-mini-pen {
    font-size: 0.85rem;
    opacity: 0.5;
    transition: all 0.2s ease;
}

/* 5. ЭФФЕКТЫ ПРИ НАВЕДЕНИИ */

body.is-editing-active .category-badge-btn:hover{
   transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 90, 43, 0.25);
}

body:not(.dark-mode) .category-badge-btn:hover {
    background: #ffffff;
    border-color: #FFD700; /* Яркое сияние при ховере */
}

body.dark-mode .category-badge-btn:hover {
    background: rgba(230, 185, 128, 0.15);
    border-color: var(--accent);
}

.category-badge-btn:hover .edit-mini-pen {
    opacity: 1;
    transform: rotate(15deg); /* Небольшая игривость при наведении */
}

.category-badge-btn:active {
    transform: scale(0.95) translateY(0);
}

/* По умолчанию карандаш скрыт */
.edit-text, .edit-mini-pen {
    display: none;
}
/* Если режим редактирования активен (на body есть класс) */
/* Прячем нормальный текст только если это МОЯ карточка и включен режим правки */
body.is-editing-active .is-owner-card .normal-text {
    display: none;
}

/* Показываем текст для редактирования (+ Категория) только в моих карточках */
body.is-editing-active .is-owner-card .edit-text {
    display: inline;
}

/* Карандаш тоже только для моих */
body.is-editing-active .is-owner-card .edit-mini-pen {
    display: inline-block;
}

.draft-category {
    color: #888 !important;
    font-style: italic;
    font-weight: 400;
}
/* Динамическое обновление title (подсказки) без JS */
/*body.is-editing-active .category-badge-btn[title]:not([title=""]):hover::after {
    content: attr(title);
     Тут добавь свои стили для всплывашки, если хочешь кастомную,
       либо просто смирись, что нативный title не умеет в динамику без перерендера
} */
/* Основной контейнер инфо-блока */
/* Общие стили (Desktop) */
/*.tour-info {
    position: relative;
    text-align: center;
    padding: 5px 10px 5px 10px;
    width: 100%;
    box-sizing: border-box;
} */

/*.title-group {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    box-sizing: border-box;
}  */

.tour-title, .tour-author {
    width: 100%;
    outline: none;
    text-align: center;
    unicode-bidi: plaintext;
    -webkit-user-modify: read-write-plaintext-only;
    overflow: hidden;
    margin: 0;
}

.tour-title {
 /*   font-size: 1rem; */
    font-weight: 700;
    line-height: 1.25; /* Чуть увеличил для читаемости */
    max-height: 3.75em; /* 1.25 * 3 строки */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.tour-author {
  /*  font-size: 0.85rem; */
    color: var(--accent);
    opacity: 0.8;
    margin-top: 4px;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: block;
}

/* Сдвижка срабатывает ТОЛЬКО когда на родителе (.tour-info) есть класс .is-editing */
.tour-info.is-editing .title-group {
    padding-right: 45px;
}
/* Стили для мобильных (Mobile) */
@media (max-width: 480px) {
    .tour-title {
        font-size: 1.1rem; /* Увеличили с 1rem */
        line-height: 1.3;
        max-height: 3.9em; /* 1.3 * 3 */
    }

    .tour-author {
        font-size: 0.95rem; /* Увеличили с 0.85rem */
        margin-top: 6px;
    }

}

.tour-title, .tour-author {
    margin: 0 !important; /* Обнуляем дефолтные отступы браузера */
    padding: 0;
}

.tour-author {
    margin-top: 4px !important; /* Твой фиксированный отступ, который не изменится после релоада */
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.edit-error {
    border-bottom: 2px solid #ff4444 !important;
    animation: shake 0.2s ease-in-out 0s 2;
}

/* Состояние кнопки в режиме редактирования (is-editing) */
.tour-info.is-editing .edit-info-minimal {
    border-color: var(--accent) !important;
    background: var(--secondary) !important;
    color: var(--accent) !important;

    /* Добавим небольшой эффект нажатия, чтобы кнопка выглядела активной */
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 1 !important;
}

/* Дополнительно: стиль при наведении на активную кнопку */
.tour-info.is-editing .edit-info-minimal:hover {
    filter: brightness(0.95); /* Легкое потемнение при наведении */
    transform: scale(1.1);
}

/* Убедимся, что иконка внутри тоже наследует цвет */
.tour-info.is-editing .edit-info-minimal svg {
    stroke: var(--accent) !important;
}

.edit-info-minimal {
    display: none;
}

/* Когда на body есть класс редактирования — показываем его */
body.is-editing-active .edit-info-minimal {
    display: inline-block;
}


body.is-editing-active .title-group.has-edit-btn {
  padding-right: 2.75rem;
}
/* Категория (Badge) по центру */
.category-badge-btn {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--accent); /* В светлой теме это #8b6d45 */
    font-weight: 800;
    /* Четкий текст без теней в светлой теме */
    text-shadow: none;
}

body.dark-mode .category-badge-btn {
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    border-color: rgba(230, 185, 128, 0.3);
}

/* 1. ГЛАВНЫЙ КОНТЕЙНЕР */
.header-inner {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
 /*   padding: 0 15px; */
    height: 100%;
}

/* 2. ЗОНЫ (Лево, Центр, Право) */
.header-zone {
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.header-left, .header-right {
    flex: 0 0 110px; /* Фиксированная ширина на десктопе */
}

.header-left { justify-content: flex-start; }
.header-right { justify-content: flex-end; }
.header-center {
    flex: 1;
    justify-content: center;
    min-width: 0;
    padding: 0 10px;
}

/* 3. УНИВЕРСАЛЬНАЯ КНОПКА (Единый стиль для всего хэдера) */
.header-btn-modern {
    height: 40px;
  min-width: 44px;
    padding: 0 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--nav-icon-color);
    font-size: 0.9rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    vertical-align: middle;
}

/* Настраиваем SVG, чтобы он не "прыгал" */
.header-btn-modern svg,
.header-btn-modern .nav-icons,
.header-btn-modern .theme-icons {
    display: flex;           /* Убирает лишние отступы снизу у inline-элементов */
    align-items: center;
    flex-shrink: 0;          /* Чтобы иконка не сжималась */
}

/* Убираем лишние отступы у текста, если они есть */
.header-btn-modern .btn-text {
    line-height: 1;          /* Чтобы высота строки не распирала кнопку */
    margin: 0;               /* Сбрасываем внешние отступы */
}

.header-btn-modern:hover {
    border-color: var(--accent);
    background: var(--secondary);
    color: var(--accent);
    transform: translateY(-1px);
}

/* Состояние кнопки, когда режим редактирования включен */
.header-btn-modern.is-active {
  border-color: var(--accent) !important;
  background: var(--secondary) !important;
  color: var(--accent) !important;
  transform: translateY(-1px);
}
/* Заглушка для симметрии */
.header-spacer {
    width: 44px;
    height: 40px;
    visibility: hidden;
}

/* 4. ТЕМА (Логика иконок) */
.theme-icons {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
}

body.dark-mode .icon-sun { display: inline-block; }
body.dark-mode .icon-moon { display: none; }
body:not(.dark-mode) .icon-sun { display: none; }
body:not(.dark-mode) .icon-moon { display: inline-block; }

/* 5. ПОИСК (Стилизация) */
.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    display: none; /* Управляется через JS */
    align-items: center;
    animation: fadeInSearch 0.2s ease-out;
}

#book-search-input {
    width: 100%;
    height: 40px;
    padding: 0 40px 0 15px;
    border-radius: var(--radius);
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 16px;
    outline: none;
    box-sizing: border-box;
}

.search-close-btn {
    position: absolute;
    right: 5px;
    background: none;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    display: flex;
    padding: 8px;
}
body.dark-mode .search-close-btn:hover {
  color: var(--accent);
}
body:not(.dark-mode) .search-close-btn:hover {
  /*  color: var(--accent);  Насыщенное золото для максимальной яркости */
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.4));
    color: var(--nav-icon-active);
}
.search-badge {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    z-index: 1001;
}

/* 6. СОСТОЯНИЕ АКТИВНОГО ПОИСКА */
.header-inner.search-active .header-left,
.header-inner.search-active .header-right {
    display: none;
}

.header-inner.search-active .header-center {
    flex: 1;
    max-width: 100%;
    padding: 0;
}

/* 7. МОБИЛЬНАЯ АДАПТАЦИЯ (До 600px) */
@media (max-width: 600px) {
    .header-left, .header-right {
        flex: 0 0 50px; /* Место под одну квадратную кнопку */
    }

    .header-btn-modern {
        width: 40px;
        min-width: 40px;
        padding: 0;
    }

    /* Прячем текст в кнопках */
    .header-btn-modern .btn-text,
    .header-btn-modern .theme-text-label {
        display: none;
    }

    .header-spacer {
        width: 40px;
    }
}

@keyframes fadeInSearch {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media screen and (max-width: 600px) {
    /* Кнопка "Загрузить еще" — Квадрат в твоем стиле */
    .btn-load-more.back-btn-modern {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 20px auto !important;
        /* Используем твой радиус скругления */
        border-radius: var(--radius) !important;
     /*   background: var(--card-bg) !important; */
        border: 1px solid var(--border) !important;
    }

    /* Прячем текст */
    .btn-load-more.back-btn-modern .text-label {
        display: none !important;
    }

    /* Центрируем иконку */
    .btn-load-more.back-btn-modern .btn-content {
        display: flex !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Сама стрелка */
    .btn-load-more.back-btn-modern .nav-arrow-icon {
        display: block !important;
        width: 20px !important;
        height: 20px !important;
        stroke-width: 3px !important;
        margin: 0 !important;
    }
}

.fb2-cover, .fb2-img { background: white; border-radius: 4px; }

/* Стиль когда файл выбран */
.file-upload-custom.has-file {
    background-color: #28a745 !important; /* Зеленый цвет */
    border-color: #1e7e34;
    color: white;
}

.upload-name-status {
    font-size: 0.85rem;
    margin-top: 8px;
    color: #666;
    font-style: italic;
    min-height: 1.2em; /* Чтобы верстка не прыгала при появлении текста */
}

/* Для темной темы, если она активна */
body.dark-theme .upload-name-status {
    color: #bbb;
}

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    max-width: 800px; /* Твой лимит */
    margin: 0 auto;   /* Центрируем контейнер по горизонтали */
    width: 100%;      /* Чтобы на мобилках он занимал всю ширину */

    /* Добавим боковые отступы, чтобы на экранах < 800px
       контент не прилипал к краям */
    padding-left: 15px;
    padding-right: 15px;
    box-sizing: border-box;
}

.category-item {
    background: var(--secondary);
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: hidden; /* Важно: чтобы контент не выходил за скругления */
}

.category-text {
    font-weight: 500;
    flex: 1;           /* Занимает всё свободное место */
    min-width: 0;      /* МАГИЯ: позволяет тексту сжиматься внутри flex */

    /* Триада для обрезки одной строки: */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    margin-right: 15px; /* Отступ до стрелки */
    text-transform: uppercase;
}

.category-name{
   text-transform: uppercase;
}

.category-arrow {
    opacity: 0.5;
    flex-shrink: 0;    /* Запрещает стрелке сжиматься */
}

.section-header {
  display: flex;
  align-items: center;
  /* Мы оставляем space-between, чтобы заголовок был слева, а счетчик справа */
  justify-content: space-between;
  margin-bottom: 0.75rem;
  margin-top: 0.5rem;
  width: 100%;
  box-sizing: border-box;
}

.section-header h2 {
  margin: 0;
 /*  flex: 1; Занимает все свободное место */
  min-width: 0; /* Критично: позволяет flex-элементу сжиматься и переносить текст */
  line-height: 1.2;

  /* Логика переноса для длинных слов (>15 символов) */
  word-break: break-word; /* Стандарт */
  overflow-wrap: break-word;
  /* Если нужно рвать СТРОГО любое длинное слово, используй: word-break: break-all; */
}

/* Центрирование на десктопе, если ширина экрана позволяет */
@media (min-width: 1024px) {
  .section-header {
    justify-content: center;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
  }
/*  .section-header h2 {
  font-size: 1.5rem;
  } */
}



.section-header {
  display: flex;
  align-items: flex-start; /* Прижимаем счетчик к верхней строке, если текст длинный */
  justify-content: space-between;
  margin-bottom: 0.75rem;
  margin-top: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  text-transform: uppercase;
}

.section-header h2 {
  margin: 0;
  flex: 1;
  min-width: 0; /* Магия для переноса текста во Flexbox */

/*  font-size: 1.5rem; */
  line-height: 1.2;
  font-weight: 700;

  /* Перенос длинных слов (больше 15 символов) */
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.category-prefix {
  font-size: 1.2rem; /* Делаем префикс чуть меньше, как ты просил ранее */
  font-weight: 400;
  opacity: 0.7;
  display: inline; /* Чтобы заголовок шел сразу за префиксом */
}

/* Центрирование на десктопе */
@media (min-width: 1024px) {
  .section-header {
    justify-content: center;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
  }
}

/*.category-name{
  font-size: 0.9em;
}  */
.chunk-wrapper.replacing {
    opacity: 0.5;
    pointer-events: none;
    filter: blur(2px);
    transition: all 0.3s ease;
}

/* Убираем оформление кнопки, делаем просто текстом */

/* Жесткое скрытие кнопки для мобилок */
.force-hide {
    display: none !important;
}
/* Ультимативное скрытие */
.hidden-completely {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
}

/* --- Индикаторы страниц в стиле Акцент (Золото) --- */

.page-counter-display {
    text-align: center;
    /* Используем твою переменную, она уже в rem */
    font-size: var(--fs-text);
    color: var(--accent);
    margin: 0.625rem auto; /* 10px */
    font-family: serif;
    opacity: 0.7;
    transition: all 0.3s ease;
}

/* Состояние завершения (Прочитано) */
.reading-finished {
    display: block;
    margin-top: 1.25rem; /* 20px */
    color: var(--accent) !important;
    opacity: 1 !important;
    font-weight: 600;
    border-top: 0.063rem solid var(--border); /* 1px оставляем минимальным */
    padding-top: 0.938rem; /* 15px */
    letter-spacing: 0.031rem; /* 0.5px */
}
/* По умолчанию скрываем текст внутри кнопок (для мобилок) */
.back-btn-modern .text-label {
    display: none;
}

/* На десктопах (экраны шире 768px) показываем текст */
@media (min-width: 768px) {
    .back-btn-modern .text-label {
        display: inline;
        margin: 0 8px;
    }

    .back-btn-modern .btn-content {
        display: flex;
        align-items: center;
        gap: 5px;
    }
}

/* Контейнер-обертка для позиционирования иконки */
.input-with-icon-wrapper {
    position: relative;
    width: 100%;
    margin-top: 15px;
}

/* Стили иконки */
.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--brown-medium, #8a5a44);
    font-size: 1.2rem;
    pointer-events: none; /* Чтобы клик проходил сквозь иконку в инпут */
    transition: color 0.3s ease;
    z-index: 5;
}

/* Обновленный инпут с учетом места под иконку */
.confirm-input {
    width: 100%;
    padding: 12px 16px 12px 42px; /* Увеличен левый отступ (42px) для иконки */
    border-radius: 8px;
    border: 2px solid var(--brown-medium, #8a5a44);
    background-color: var(--bg-card, #f4eade);
    color: var(--text-main, #4a2c2a);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
    display: block;
}

/* Эффект при фокусе — иконка тоже может менять цвет */
.input-with-icon-wrapper:focus-within .input-icon {
    color: var(--brown-dark, #5d3a2a);
}

.confirm-input:focus {
 /*   border-color: var(--brown-dark, #5d3a2a);*/
    background-color: var(--bg-input-focus, #ffffff);
    box-shadow: 0 4px 12px rgba(93, 58, 42, 0.15);
    border-color: var(--accent) !important;
}

/* Тряска при ошибке для всего контейнера */
.input-with-icon-wrapper.shake-animation {
    animation: shake 0.4s ease-in-out;
}

.input-with-icon-wrapper.shake-animation .confirm-input {
    border-color: var(--danger, #e74c3c);
}

/* Темная тема */
body.dark-mode .confirm-input {
 /*   background-color: #2c1e1a;*/
    background-color: var(--input-bg);
    color: #eaddca;
    border-color: #5d3a2a;
}

body.dark-mode .input-icon {
    color: #a68b7c;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/*  Отключение Scroll Anchoring для контейнера */
/*#reader-content-area {
    overflow-anchor: none;
}*/
/* Класс для вспышки (подсветки) */
/* Ярко-золотая вспышка без грязи */
.chunk-highlight-success {
    position: relative;
    animation: highlight-gold-pure 1.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes highlight-gold-pure {
    0% {
        background-color: var(--accent) !important;
        box-shadow: 0 0 20px 5px rgba(255, 215, 0, 0.6),
                    inset 0 0 15px rgba(255, 215, 0, 0.5);
        outline: 2px solid #ffcc00;
        z-index: 10; /* Чтобы тень была над другими элементами */
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0px transparent,
                    inset 0 0 0px transparent;
        outline: 2px solid transparent;
    }
}

/* Класс для успешного уведомления */
.error-message-box.success-mode {
    background-color: var(--auth-msg-bg);
    color: var(--auth-msg-text);
    border: 1px solid var(--auth-msg-border);
    padding: 10px;
    border-radius: 8px;
    transition: all 0.3s ease;
}
.success-mode {
    background-color: var(--auth-msg-bg);
    color: var(--auth-msg-text);
    border: 1px solid var(--auth-msg-border);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    margin: 10px 0;
}

.edit-btn-circle:hover {
    transform: scale(1.1);
    filter: brightness(1.1);
}

.user-name-container input:focus {
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2);
}

#parse-btn:disabled {
    background-color: #ccc !important;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none !important; /* Убираем эффекты наведения */
}

/* Эффект пульсации для процесса загрузки */
.btn-primary.loading {
    animation: pulse-loading 1.5s infinite;
}

@keyframes pulse-loading {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* Кнопка "Внимание" */
.confirm-attention {
    border: 1.5px solid var(--warning) !important;
    color: var(--warning) !important;
    background: transparent !important;
    font-weight: 600;
    transition: all 0.25s ease-in-out;
}

.confirm-attention:hover {
    background: var(--warning) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px var(--warning-bg);
    transform: translateY(-1px);
}

/* Заголовок при внимании */
#confirm-title[style*="color: var(--warning)"] {
    color: var(--warning) !important;
}

/* Эффект при наведении для админ-кнопки */
.admin-seo-panel button:hover {
    background: var(--btn-primary-bg) !important;
  color: var(--btn-primary-text) !important;
  border-color: #B27C3E !important;
  box-shadow: 0 4px 15px var(--btn-primary-shadow) !important;
    transform: translateY(-1px);
}

.admin-seo-panel button:active {
    transform: translateY(0);
}

/* ======================================
   Карта OpenStreetMap
   ====================================== */
/* 1. ОСНОВНОЙ КОНТЕЙНЕР (Без радиусов, на весь экран) */
.map-main-holder {
    width: 100%;
    height: calc(100vh - 70px); /* Высота до нижнего меню */
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    background: var(--background);
    overflow: hidden;
}

/* 2. КОНТЕЙНЕР КАРТЫ (Убрал старый padding и фиксированную высоту) */
#osm-map-ref {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    z-index: 1;
    border-radius: 0 !important; /* УБРАЛИ РАДИУСЫ */
    box-shadow: none !important; /* Убрали внутреннюю тень для чистоты края */
}

/* 3. КНОПКИ МАСШТАБИРОВАНИЯ (Фиксация на 58px) */
/*.leaflet-top.leaflet-right {
    top: 58px !important;
    right: 8px !important;
    position: absolute !important;
} */

.leaflet-control-zoom {
    transition: none !important;
    margin: 0 !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}

/* 4. ГЛОБАЛЬНЫЕ НАСТРОЙКИ LEAFLET */
.leaflet-container {
    height: 100% !important;
    width: 100% !important;
    background: var(--background) !important;
}

.leaflet-control-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.leaflet-control {
    pointer-events: auto;
}

/* Скрытый заголовок */
.map-header-simple {
    display: none;
}

/* 5. ПОПАПЫ (Твой модерн-дизайн) */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius) !important;
    background: var(--card) !important;
    color: var(--card-foreground) !important;
    padding: 5px;
}

.leaflet-popup-tip {
    background: var(--card) !important;
}

/* 6. КЛАСТЕРЫ (Адаптив под светлую и темную темы) */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
}

.marker-cluster div {
    color: var(--primary-foreground) !important;
    font-family: inherit;
    font-weight: 600;
}

/* Светлая тема кластеры */
.marker-cluster-small { background-color: hsla(30, 53%, 35%, 0.4) !important; }
.marker-cluster-small div { background-color: var(--primary) !important; }

.marker-cluster-medium { background-color: hsla(30, 53%, 25%, 0.5) !important; }
.marker-cluster-medium div { background-color: hsl(30, 53%, 25%) !important; }

.marker-cluster-large { background-color: hsla(30, 53%, 15%, 0.6) !important; }
.marker-cluster-large div { background-color: hsl(30, 53%, 15%) !important; }

/* ТЕМНАЯ ТЕМА ПРАВКИ */
body.dark-mode .marker-cluster div {
    color: var(--btn-primary-text) !important;
}

body.dark-mode .marker-cluster-small {
    background-color: rgba(198, 144, 82, 0.3) !important;
}
body.dark-mode .marker-cluster-small div {
    background-color: #9E6B3A !important;
}

/* Инверсия карты для темной темы */
body.dark-mode #osm-map-ref {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

body.dark-mode .leaflet-popup-content img {
    filter: invert(100%) hue-rotate(180deg);
}

/* Контейнер для кастомных кнопок зума */
.custom-zoom-controls {
    position: absolute;
    top: 5.1rem;
  right: 0.9rem;
    z-index: 1000; /* Поверх карты */
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

/* В темной теме можно чуть подсветить тени */
body.dark-mode .zoom-btn {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.zoom-btn {
    width: 2.9rem;
    height: 2.9rem;
    /* Полупрозрачный фон на основе твоего основного цвета */
    background: hsla(30, 53%, 35%, 0.6) !important;
    backdrop-filter: blur(8px); /* Эффект матового стекла */
    -webkit-backdrop-filter: blur(8px); /* Поддержка Safari */

    color: var(--btn-primary-text);
    border: 1px solid rgba(255, 255, 255, 0.1); /* Тонкая светлая кайма */
    border-radius: var(--radius);

    /* Мягкая тень */
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);

    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
}

/* Эффект при наведении/нажатии */
.zoom-btn:active {
    background: hsla(30, 53%, 35%, 0.8) !important;
    transform: scale(0.92);
}

/* Настройка иконок внутри */
.zoom-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    opacity: 0.9;
}

/* ТЕМНАЯ ТЕМА: Кнопки делаем чуть темнее */
body.dark-mode .zoom-btn {
  background: rgba(255, 255, 255, 0.22) !important;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.4);
  color: #6E420A;
}

/* Убираем стандартные стили divIcon */
.custom-leaflet-icon {
    background: none !important;
    border: none !important;
}

/* Контейнер для SVG метки */
.custom-marker-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0.125rem 0.25rem rgba(0,0,0,0.3)); /* Мягкая тень для метки */
    transition: transform 0.2s ease;
}

.custom-marker-wrapper:hover {
    transform: scale(1.2); /* Увеличение при наведении */
}

/* Заголовок в попапе */
.map-popup-title {
    font-family: inherit;
    font-weight: 600;
    font-size: var(--fs-base);
    color: var(--foreground);
    padding: 0.25rem;
}

/* Обнуляем стандартные отступы Leaflet для нашего класса */
.custom-popup .leaflet-popup-content {
    margin: 0 !important;
    line-height: 1.4;
}

.map-popup-card {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--card); /* Твоя переменная */

    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

body.dark-mode .map-popup-card {
    background: rgba(255, 255, 255, 0.22) !important;
}

/* Эффект при нажатии на мобилках и наведении на десктопе */
.map-popup-card:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.map-popup-img {
    width: 100%;
    height: 120px; /* Фиксированная высота для аккуратности */
    object-fit: cover; /* Чтобы картинка не растягивалась */
    display: block;
}

.map-popup-body {
    padding: 0.75rem; /* ~12px */
}

.map-popup-title {
    font-family: inherit;
    font-weight: 700;
    font-size: var(--fs-base); /* Твой адаптивный шрифт */
    color: var(--foreground);
    margin-bottom: 0.25rem;
    text-align: center;
}

.map-popup-desc {
    font-size: var(--fs-small);
    color: var(--accent);
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Обрезка текста после 2-й строки */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center;
}

/* Настройка тени и скруглений самого контейнера Leaflet */
.leaflet-popup-content-wrapper {
    background: var(--card) !important;
    color: var(--card-foreground) !important;
    border-radius: var(--radius) !important;
    padding: 0 !important;
    box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.15) !important;
}

.leaflet-popup-tip {
    background: var(--card) !important;
}

.map-search-container {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 2rem);
    max-width: 420px;
}

.map-search-wrapper {
    display: flex;
    align-items: center;
    background: hsla(30, 53%, 35%, 0.6); /* Твой коричневый полупрозрачный */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.search-icon {
    color: var(--btn-primary-text);
    margin-right: 0.75rem;
    display: flex;
}

/* Смещаем кнопки зума чуть ниже, чтобы не перекрывали поиск на мобильных */
.custom-zoom-controls {
    top: 8.3rem !important; /* Увеличили отступ сверху */
}

/* Темная тема */
body.dark-mode .map-search-wrapper {
    background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.4);
}

/* Основной контейнер поиска */
.map-search-container.left-top {
    position: absolute;
    top: 4rem;
    left: 9.5rem;
    z-index: 1200;
    width: 17.5rem; /* 280px */
}
@media (max-width: 460px) {
.map-search-container.left-top {
    top: 5rem;
    left: 50%;
    width: 100%;
  padding: 0 0.8rem;
}
}
/* Поле ввода */
.map-search-wrapper {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    backdrop-filter: blur(0.625rem);
    -webkit-backdrop-filter: blur(0.625rem);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    border: 0.063rem solid var(--input-border);
    box-shadow: 0 0.25rem 0.938rem var(--book-shadow);
}

#map-search-input {
    background: transparent;
    border: none;
    color: var(--input-text);
    width: 100%;
    outline: none;
    font-family: inherit;
    font-size: var(--fs-sm); /* ~14px */
    margin-left: 0.5rem;
    /* Добавляем отступ слева, чтобы текст не налезал на лупу */
    padding-left: 1.5rem;
}

#map-search-input::placeholder {
    color: var(--input-placeholder);
}
/* Если лупа и инпут находятся в flex-контейнере (map-search-wrapper),
   можно также добавить небольшой зазор между ними через gap */
.map-search-wrapper {
    gap: 0.25rem;
}
/* Выпадающий список результатов */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background: var(--dropdown-bg);
    backdrop-filter: blur(0.938rem);
    border-radius: var(--radius);
    max-height: 25.625rem; /* 250px */
    overflow-y: auto;
    border: 0.063rem solid var(--dropdown-border);
    box-shadow: 0 0.625rem 1.563rem var(--book-shadow);
    display: none;
}

/* Элемент списка */
.search-result-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.75rem;
    gap: 0.75rem;
    border-bottom: 0.063rem solid var(--border);
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-result-item:hover {
    background: var(--secondary);
}

/* Превью картинки */
.res-thumb {
    width: 3rem !important;  /* 48px */
    height: 3rem !important;
    min-width: 3rem;
    border-radius: 0.375rem; /* 6px */
    object-fit: cover;
}

/* Текстовый блок */
.res-title {
    color: var(--foreground);
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.2;
}

.res-sub {
    color: var(--muted-foreground);
    font-size: var(--fs-xs); /* ~12px */
}

/* Кнопки масштаба */
.custom-zoom-controls {
    position: absolute;
    top: 5.313rem; /* 85px (под поиском) */
    left: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    z-index: 1100;
    width: 2.5rem;
}

.zoom-btn {
    width: 2.5rem; /* 40px */
    height: 2.5rem;
    background: var(--card-bg) !important;
    border: 0.063rem solid var(--border);
    border-radius: var(--radius);
    color: var(--nav-icon-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0.25rem 0.75rem var(--book-shadow);
}

.zoom-btn:active {
    transform: scale(0.95);
    background: var(--secondary) !important;
}

.search-icon, #map-search-clear {
    color: var(--nav-icon-color);
    display: flex;
    align-items: center;
}
/* ======================================
   Tour Ditails
   ====================================== */
@media (min-width: 798px) {
  .tour-details-page{margin: clamp(2rem, 8vh, 5rem) auto;}
}


/* Кнопка "Назад" (используем твои переменные стека) */
.tour-nav-top {
    position: absolute;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 1;
}

.back-circle-btn {
    background: var(--back-btn-bg);
    backdrop-filter: blur(0.625rem);
    border: 1px solid var(--border);
    width: 2.813rem;
    height: 2.813rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
 /*   color: var(--back-btn-color); */
    color: var(--nav-icon-color);
    transition: all 0.2s ease;
}

.back-circle-btn:hover {
    background: var(--muted);
    color: var(--accent);
    transform: translateX(-0.25rem);
}

/* ГАЛЕРЕЯ */
.tour-gallery-container {
    position: relative;
    width: 100%;
 /*   background: #000;  Фон галереи оставляем черным для акцента на фото */
    height: 30rem; /* 400px */
    display: flex;
    align-items: center;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.gallery-scroll {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    height: 100%;
}

.gallery-scroll::-webkit-scrollbar {
    display: none;
}

.gallery-item {
    flex: 0 0 100%;
    scroll-snap-align: center;
    display: flex;
 /*   align-items: center; */
    justify-content: center;
}

.gallery-item img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    cursor: pointer;
}

/* СТРЕЛКИ НАВИГАЦИИ */
.gallery-nav {
    position: absolute;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: none;
    width: 3.125rem;
    height: 3.125rem;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.gallery-nav:hover {
    border-color: var(--accent);
  background: var(--secondary);
  color: var(--accent);
}

.gallery-nav.prev { left: 0.625rem; }
.gallery-nav.next { right: 0.625rem; }

.gallery-nav.prev:hover {
    transform: translateX(-0.25rem);
}
.gallery-nav.next:hover {
    transform: translateX(0.25rem);
}
@media (max-width: 48rem) { /* 768px */
    .gallery-nav { display: none; }
    .tour-gallery-container { height: 18.75rem; } /* 300px */
    .tour-details-page {
     /*   margin: 1rem;  */
        padding: 1rem;
    }
}

/* ИНФОРМАЦИОННЫЙ БЛОК */
.tour-info-content {
    background: var(--card);
    padding: 1.875rem 0.8rem;
    border-radius: 1.875rem 1.875rem 0 0;
    margin-top: -1.875rem;
    position: relative;
    box-shadow: 0 -0.938rem 1.875rem var(--book-shadow);
    min-height: 31.25rem;
}

.tour-header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.tour-header-main h1 {
    font-size: var(--fs-xl);
    font-weight: 800;
    margin: 0;
    color: var(--foreground);
    line-height: 1.2;
}

/* ЦЕНА (используем твой градиент для кнопок) */
.tour-price-tag {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    padding: 0.625rem 1.125rem;
    border-radius: 0.938rem;
    font-weight: 700;
    font-size: var(--fs-md);
    box-shadow: 0 0.25rem 0.625rem var(--btn-primary-shadow);
}

.tour-meta {
    margin-bottom: 1.875rem;
}

.location-badge {
    display: inline-block;
    background: var(--secondary);
    color: var(--secondary-foreground);
    padding: 0.5rem 0.875rem;
    border-radius: 0.625rem;
    font-size: var(--fs-sm);
    font-weight: 500;
}

/* ОПИСАНИЕ */
.tour-description h3 {
    font-size: var(--fs-h3);
    margin-bottom: 0.938rem;
    color: var(--foreground);
    border-left: 0.25rem solid var(--accent);
    padding-left: 0.75rem;
}

.description-body {
    line-height: 1.6;
    color: var(--foreground);
    font-size: var(--fs-text);
    /* Убрали лишние отступы, используем pre-line для сохранения структуры из БД */
    white-space: normal;
}

/* Ошибки / Пусто */
.error-state, .no-images {
    color: var(--muted-foreground);
    text-align: center;
    padding: 3.125rem;
    font-size: var(--fs-md);
}

/* Оверлей (фон) */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* Глубокий черный фон */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000; /* Выше всех элементов, включая хедер */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(0.313rem); /* Легкое размытие заднего плана */
}

/* Активное состояние */
.lightbox-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* Картинка внутри модалки */
.lightbox-content {
    max-width: 95%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 0 1.875rem rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.lightbox-overlay.is-active .lightbox-content {
    transform: scale(1);
}

/* Кнопка закрытия */
.lightbox-close {
    position: absolute;
    top: 1.25rem;
    right: 1.875rem;
    color: #fff;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
    transition: color 0.2s ease;
}

.lightbox-close:hover {
    color: var(--accent); /* Твое фирменное золото */
}

/* Адаптив для мобилок */
@media (max-width: 48rem) {
    .lightbox-close {
        top: 0.625rem;
        right: 1rem;
        font-size: 2rem;
    }
}

/* Контейнер для цен */
.tour-prices-container {
    display: flex;
 /*   flex-direction: column; */
    gap: 0.5rem;
    align-items: flex-end;
}

.price-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    background: var(--secondary);
    border: 1px solid var(--border);
}

/* Групповой тур выделим твоим основным градиентом */
.price-item.group {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    box-shadow: 0 0.25rem 0.625rem var(--btn-primary-shadow);
}

/* Индивидуальный сделаем в стиле "Акцент" */
.price-item.private {
    background: var(--card);
    border: 1px solid var(--accent);
    color: var(--foreground);
}

.price-label {
    font-size: var(--fs-xs);
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.03rem;
}

.price-value {
    font-size: var(--fs-md);
    font-weight: 800;
}

/* Адаптив для заголовка */
@media (max-width: 30rem) {
    .tour-header-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .tour-prices-container {
        flex-direction: row;
        width: 100%;
        justify-content: flex-start;
    }
    .price-item {
        align-items: flex-start;
    }
}

/* Мета-информация тура (локация и рейтинг) */
.tour-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* 12px */
    margin: 0.625rem 0; /* 10px */
    font-size: var(--fs-small);
    color: var(--muted-foreground);
}

.location-badge, .rating-badge {
    display: flex;
    align-items: center;
    padding: 0.125rem 0.5rem; /* 2px 8px */
    border-radius: var(--radius);
    background: var(--secondary);
    color: var(--secondary-foreground);
    transition: all 0.2s ease;
}

/* Особенный стиль для рейтинга (золотистый акцент) */
.rating-badge {
    background: var(--warning-bg);
    color: var(--warning);
    font-weight: 700;
    font-size: var(--fs-base);
}

.rating-badge-number{font-weight: 700; vertical-align: middle;}
.rating-badge-icon{color: #FFD700; margin-right: 0.2rem; vertical-align: middle;}

.rating-star-icon {
    color: var(--warning);
    margin-right: 0.25rem; /* 4px */
}

.season-badge {
/*  font-size: var(--fs-small);
  font-weight: 600; */
  display: inline-flex;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  margin-bottom: 1rem;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
  background: var(--secondary);
  color: var(--secondary-foreground);
  transition: all 0.2s ease;
}

.season-badge svg {
    margin-right: 8px;
    opacity: 0.8;
}

/* Основной контейнер бейджа */
.season-badge {
    display: inline-flex;
    align-items: flex-start; /* Чтобы иконка оставалась сверху при переносе строк */
    flex-wrap: wrap;
    max-width: 100%;
    padding: 8px 12px;
    background: rgba(var(--accent-rgb), 0.1);
    border-radius: 8px;
    gap: 8px;
}

/* Контейнер полей редактирования */
.edit-mode-container {
    display: flex !important; /* Переопределяем inline-flex */
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  /*  width: 100%;  Позволяем занимать всю ширину на мобильных */
}

/* Стили для инпутов */
.tour-input-small {
    position: relative; /* Важно для позиционирования псевдоэлемента */
    min-width: 100px;
    /* ... твои остальные стили ... */

    /* Гарантируем, что стандартные элементы управления Chromium не скрыты */
    -webkit-appearance: listbox !important;
  /*  flex: 1 1 auto;  Инпуты будут растягиваться, заполняя ряд */
    background: var(--card-bg);
    border: 1.5px dashed var(--primary) !important;
    color: var(--text-main);
    padding: 4px 6px;
    border-radius: 6px;
    font-size: var(--fs-xs);
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.03rem;
  margin-bottom: 1rem;
}

/* Принудительно настраиваем иконку календаря */
.tour-input-small::-webkit-calendar-picker-indicator {
    background-color: var(--primary); /* Или любой контрастный цвет */
    position: relative;
    z-index: 2; /* Чтобы иконка была поверх плейсхолдера, если они пересекутся */
    cursor: pointer;
    opacity: 0.6;
    margin-left: 0;
    right: 0;
    margin-left: 70px;
}

.edit-dates_text-row {
    display: inline-flex;    /* Или flex, если строка на всю ширину */
    align-items: center;     /* Центрирует инпуты и разделитель по вертикали */
    vertical-align: middle;  /* Важно для корректного отображения внутри span */
    gap: 5px;                /* Удобный отступ между элементами */
}

.tour-input-small {
    /* Edge любит добавлять лишние отступы инпутам даты */
    box-sizing: border-box;
    display: inline-block;
    vertical-align: middle;

    /* Убираем влияние высоты строки на позиционирование */
    line-height: normal;
}

/* Фикс конкретно для разделителя (тире), чтобы он не падал вниз */
.date-sep {
    display: flex;
    align-items: center;
    height: 100%;
    line-height: 1;
}

.edit-mode-container {
    display: inline-flex !important;
    align-items: center;
    vertical-align: middle;
}

.tour-input-small[value=""]:before {
    content: attr(data-placeholder);
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-style: italic;
    pointer-events: none; /* Чтобы клик сквозь текст падал на инпут */
    z-index: 1;

    /* Если текст длинный, ограничиваем, чтобы не налез на иконку */
    max-width: calc(100% - 30px);
    overflow: hidden;
    white-space: nowrap;
}

.tour-input-small::placeholder {
    text-transform: uppercase;
}

.view-mode {
    transition: opacity 0.3s ease;
}

/* Если мы в режиме редактирования, показываем блок даже если он пустой */
body.is-editing-active .tour-season-info {
    display: block !important;
}

/* Селектор сезона может быть чуть шире */
.season-select {
    min-width: 140px;
}

.date-separator {
    color: var(--text-muted);
    padding: 0 2px;
}

.tour-season-info {margin-top: 1rem;}
/* Мобільна адаптація */
@media (max-width: 580px) {
 /*   .tour-season-info {
        margin-right: 10px;
    }
      */
    .edit-mode-container {
        flex-direction: column; /* На очень узких экранах — в колонку */
        align-items: stretch;
    }

    .date-sep {
        display: none; /* Убираем тире, если они в колонку */
    }

    .tour-input-small {
        width: 100%;
    }
}

/* Полностью скрываем блок, если в нем нет данных (для владельца в режиме просмотра) */
.edit-only-block {
    display: none !important;
}

/* Показываем его только когда на body есть класс активного редактирования */
body.is-editing-active .edit-only-block {
    display: block !important;
}

/* Убираем лишние отступы у баджа, если он пустой внутри (страховка) */
.season-badge:empty {
    display: none;
}

/* Адаптивность для мобильных внутри режима редактирования */
.edit-mode-container {
    flex-wrap: wrap;
}

@media (max-width: 480px) {
  /*  .edit-mode-container {
        flex-direction: column;
        align-items: flex-start !important;
    }  */
    .date-separator { display: none; }
}
/* ======================================
   КАРТА ДЕТАЛЬНО
   ====================================== */
.panorama-container {
    width: 100%;
    height: 350px !important; /* Устанавливаем жесткую высоту */
    min-height: 350px;
    background: #f0f0f0;
    margin-top: 15px;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    border: 1px solid #ddd;
}

/* Фикс для Leaflet */
.leaflet-container {
    width: 100% !important;
    height: 100% !important;
}

.custom-zoom-controls.details {
  top: 0.4rem !important;
  left: 0.4rem !important;

}
body.dark-mode .custom-zoom-controls.details {
  filter: invert(1%) hue-rotate(180deg) !important;
}
body.dark-mode .zoom-btn.details {
  color: #060400 !important;
}

/* Стандартный вид карты (светлая тема) */
#tour-map {
    height: 21.875rem; /* 350px */
    width: 100%;
    filter: grayscale(0.2) contrast(0.9); /* Чуть приглушаем стандартные цвета */
    transition: filter 0.4s ease;
}
body.is-editing-active #tour-map {
    border: 1.5px dashed var(--primary) !important;
  background-color: var(--input-bg);
  box-shadow: 0 0 12px rgba(from var(--primary) r g b / 0.15);
}
/* Вид карты в темной теме */
body.dark-mode #tour-map {
    /* Инвертируем цвета, меняем тон и возвращаем правильные цвета текста/дорог */
    filter: invert(100%) hue-rotate(180deg) brightness(0.9) contrast(0.9);
}

/* Исключаем маркер и кнопки из инверсии, чтобы они сохранили свои цвета */
body.dark-mode .leaflet-marker-icon,
body.dark-mode .leaflet-marker-shadow,
body.dark-mode .custom-zoom-controls,
body.dark-mode .leaflet-control-attribution {
    filter: invert(100%) hue-rotate(180deg);
}

/* Фон подложки карты в темной теме, чтобы при загрузке не было белой вспышки */
body.dark-mode .leaflet-container {
    background: var(--background) !important;
}

/* Светлая тема по умолчанию */
.custom-marker-wrapper svg {
    stroke: var(--primary);
    color: var(--primary);
    filter: drop-shadow(0 0.125rem 0.125rem rgba(0, 0, 0, 0.2));
    transition: all 0.3s ease;
}



/* Фикс, чтобы инверсия карты не портила цвет маркера */
body.dark-mode .leaflet-marker-icon .custom-marker-wrapper {
    filter: invert(100%) hue-rotate(180deg); /* Нейтрализуем инверсию слоя карты */
}

/* Анимация появления для живости */
.custom-marker-wrapper {
    animation: markerBounce 0.4s ease-out;
}

@keyframes markerBounce {
    0% { transform: translateY(-1.25rem); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* ======================================
   КАРТА ДЕТАЛЬНО  МАРШРУТЫ
   ====================================== */
#map-title{
  font-size: var(--fs-h3);
  margin-bottom: 0.938rem;
  margin-top: 0.938rem;
  color: var(--foreground);
  border-left: 0.25rem solid var(--accent);
  padding-left: 0.75rem;
}

/* --- ОБЩИЕ СТИЛИ (Одинаковые размеры для всех схем) --- */
.route-info-card {
    background: var(--card-bg);
    color: var(--text-main);
    padding: 0.5rem; /* ~8px для комфортных отступов */
    border-radius: 0.375rem; /* 6px */
    box-shadow: 0 0.125rem 0.625rem rgba(0,0,0,0.2);
    font-size: 0.8125rem; /* 13px */
    line-height: 1.4;
    border: 0.0625rem solid var(--border-color);
    width: 12rem; /* Фиксированная ширина для стабильности геометрии */
    box-sizing: border-box;
}

.mode-switcher {
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.25rem; /* 4px */
    width: 100%;
}

.mode-btn {
    padding: 0.3125rem 0.5rem; /* 5px 8px */
    cursor: pointer;
    border: 0.0625rem solid var(--primary);
    background: none;
    color: var(--primary);
    border-radius: 0.375rem; /* 6px */
    font-size: 0.6875rem; /* 11px */
    flex: 1; /* Одинаковая ширина кнопок в обеих схемах */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: all 0.25s ease;
}

.mode-btn.active {
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.6) !important;
    color: #fff;
}

/* --- ТЕМНАЯ СХЕМА (Только цвета и фильтры) --- */
body.dark-mode .route-info-card {
    background: rgba(255, 255, 255, 0.12) !important;
    border: 0.0625rem solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(0.9375rem) saturate(150%); /* 15px */
}

body.dark-mode .mode-switcher {
    background: rgba(0, 0, 0, 0.15);
    padding: 0.25rem; /* 4px */
    border-radius: 0.3125rem; /* 5px */
}

body.dark-mode .mode-btn {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 0.0625rem solid transparent !important;
    color: #060400 !important;
    opacity: 1;
}

body.dark-mode .mode-btn.active {
    background: rgba(255, 255, 255, 0.8) !important;
    color: #000 !important;
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.4) !important;

}

body.dark-mode #route-stats {
    color: #060400 !important;
    font-size: 0.8125rem; /* 13px */
    padding-left: 0.25rem; /* 4px */
}

/* Полностью скрываем стандартную панель маршрутов Leaflet */
.leaflet-routing-container {
    display: none !important;
}
.leaflet-right .leaflet-control {
  margin-right: 0.5rem !important;
}
.leaflet-top .leaflet-control {
  margin-top: 0.5rem !important;
}





/* --- ОБЩИЕ СТИЛИ ПОПАПА --- */
.custom-popup .leaflet-popup-content-wrapper {
    background: var(--card-bg);
    color: var(--text-main);
    padding: 0;
    overflow: hidden;
    border-radius: 0.5rem; /* 8px */
    border: 0.0625rem solid var(--border-color);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
}

.custom-popup .leaflet-popup-content {
    margin: 0;
    width: 12.5rem !important; /* 200px */
}

.custom-popup .leaflet-popup-tip {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

/* Стили карточки внутри */
.map-popup-card {
    cursor: pointer;
    transition: transform 0.2s ease;
}

body.dark-mode .map-popup-card {
    filter: invert(1%) hue-rotate(180deg);
}

.map-popup-card:hover {
    transform: translateY(-2px);
}

.map-popup-img {
    width: 100%;
    height: 7.5rem; /* 120px */
    object-fit: cover;
    display: block;
}

.map-popup-body {
    padding: 0.5rem;
}

.map-popup-title {
    font-size: 0.6875rem; /* 11px */
    text-transform: uppercase;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.125rem;
}

.map-popup-desc {
    font-size: 0.8125rem; /* 13px */
    font-weight: 600;
    line-height: 1.3;
}

/* Кнопка закрытия */
.custom-popup .leaflet-popup-close-button {
    color: #fff !important;
    text-shadow: 0 0 3px rgba(0,0,0,0.5);
}

/* --- ТЕМНАЯ СХЕМА (Адаптация под твой зум) --- */
body.dark-mode .custom-popup .leaflet-popup-content-wrapper,
body.dark-mode .custom-popup .leaflet-popup-tip {
    filter: invert(1%) hue-rotate(180deg) !important;
    background: rgba(255, 255, 255, 0.22) !important;
    backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .map-popup-title,
body.dark-mode .map-popup-desc {
    color: #060400 !important; /* Твой контрастный цвет из зума */
}

body.dark-mode .map-popup-img {
    opacity: 0.9;
    filter: contrast(1.1);
}

/* Стили для кастомной иконки финиша */
.custom-finish-icon {
    font-size: 1.875rem; /* ~30px */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Чтобы иконка не инвертировалась в темной теме */
    filter: none !important;
    /* Легкая тень для объема */
    text-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.3);
}

/* На всякий случай, если используешь картинку внутри DivIcon */
.custom-finish-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.animated-bike {
    stroke-dasharray: 10, 10;
    animation: bike-flow 15s linear infinite;
}
@keyframes bike-flow {
    from { stroke-dashoffset: 200; }
    to { stroke-dashoffset: 0; }
}
/* ======================================
   ВИДЕО YOUTUBE ДЕТАЛЬНО
   ====================================== */
/* Контейнер секции видео */
.tour-video-section {
    margin-top: 2rem;
    width: 100%;
    box-sizing: border-box;
}

.tour-video-section h3 {
    margin-bottom: 1rem;
}

/* Сетка для видео */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Адаптивная обертка (16:9) */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* Пропорции видео */
    height: 0;
    overflow: hidden;

}
body.is-editing-active .video-wrapper {
      border: 1.5px dashed var(--primary) !important;
  background-color: var(--input-bg);
  box-shadow: 0 0 12px rgba(from var(--primary) r g b / 0.15);
}
.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Исправление для мобильных (до 480px) */
@media (max-width: 480px) {
    .video-grid {
        grid-template-columns: 1fr; /* Строго одна колонка */
        gap: 15px;
    }

    .tour-video-section {
        padding: 0;
        margin-left: 0;
        margin-right: 0;
    }
}

#map-video{
  font-size: var(--fs-h3);
  margin-bottom: 0.938rem;
  margin-top: 0.938rem;
  color: var(--foreground);
  border-left: 0.25rem solid var(--accent);
  padding-left: 0.75rem;
}

/* ======================================
   РЕДАКТИРОВАНИЕ ДЕТАЛЬНО
   ====================================== */
/* 1. ГАЛЕРЕЯ И УСТРАНЕНИЕ ПОЛОС */

/*.gallery-item {
    position: relative;
    width: 100%;
    min-width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #000;
    display: block;
} */
.gallery-item {
    position: relative; /* Чтобы кнопки не улетали в одну точку */
    overflow: hidden;
    border-radius: 12px;
}

.gallery-item.new-upload {
    border: 2px solid transparent;
    transition: transform 0.4s ease, opacity 0.4s ease, box-shadow 0.4s ease, border-color 0.4s ease;
}

/* Опционально: пульсация для оверлея загрузки */
.upload-progress-text {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}
.gallery-item img {
    width: 100%;
 /*   height: 450px;  Фиксированная высота как у вас */
    object-fit: cover; /* Растягивает фото без искажений и пустых зон */

    /* КРИТИЧНО ДЛЯ УДАЛЕНИЯ ПОЛОСЫ СНИЗУ */
    display: block;

    cursor: pointer;
    transition: filter 0.3s ease;
}
@media (max-width: 480px) {
.gallery-item img {
    height: auto; /* Фиксированная высота как у вас */
}
}
/* 2. КНОПКА РЕДАКТИРОВАНИЯ (ПО УМОЛЧАНИЮ СКРЫТА) */

.edit-photo-btn {
    /* Скрыта всегда, пока нет нужного класса у родителя */
    display: none;

    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 99; /* Поверх всех элементов слайдера */

    /* Размеры и форма */
    width: 44px;
    height: 44px;
    border-radius: 50%;

    /* Стилизация */
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);

    /* Центрирование иконки внутри */
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.edit-photo-btn:hover {
    background: #2563eb; /* Акцентный синий при наведении */
    transform: scale(1.1);
    border-color: #fff;
}

.edit-photo-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* 3. ЛОГИКА АКТИВАЦИИ ПО КНОПКЕ "РЕДАКТИРОВАТЬ" */

/* Кнопки появляются ТОЛЬКО когда ваша функция toggleEditMode
   добавляет класс .is-editing-active к контейнеру .tour-details-page
*/
.tour-details-page.is-editing-active .edit-photo-btn {
    display: flex !important;
}

/* Опционально: легкое затемнение фото в режиме ред., чтобы кнопки лучше читались */
/*.tour-details-page.is-editing-active .gallery-item img {
    filter: brightness(0.8);
} */

/* Подсветка редактируемых текстовых полей */
.tour-details-page.is-editing-active [contenteditable="true"] {
    outline: 1px dashed rgba(37, 99, 235, 0.4);
    background: rgba(37, 99, 235, 0.05);
}

/* Контейнер для картинки в режиме редактирования */
.is-editing-active .image-chunk {
    position: relative;
    border: 1.5px dashed #8B5A2B;
    padding: 10px;
    margin: 15px 0;
    border-radius: var(--radius);
    background: rgba(139, 90, 43, 0.05);
}

/* Сама картинка внутри чанка */
.image-chunk img {
    width: 100%;
    height: 272px;
    object-fit: cover;
    display: block; /* УБИРАЕТ ПОЛОСУ СНИЗУ */
    border-radius: calc(var(--radius) - 4px);
}

/* Кнопки управления (ТВОЙ СТИЛЬ) */
.img-action-btn {
    display: none; /* Скрыты по умолчанию */
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    color: #8B5A2B;
    border: 1.5px solid #8B5A2B;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);

    /* Расположение поверх картинки в углу */
    position: absolute;
    top: 1rem;
    right: 1rem;
}
.delete-photo-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
}

/* Тёмная тема */
body.dark-mode .img-action-btn {
    background: #1a1a1a;
    color: #E6B980;
    border: 1px solid #8B5A2B;
    transition: all 0.3s ease;
}

/* ПОКАЗЫВАЕМ ТОЛЬКО ПРИ АКТИВАЦИИ */
.is-editing-active .img-action-btn {
    display: inline-flex;
}

.img-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 90, 43, 0.2);
}

/* Скрываем весь блок добавления, пока не включен режим редактирования */
.add-photo-item {
    display: none !important;
}

.is-editing-active .add-photo-item {
    display: block !important;
}

/* Стили для чанка-пустышки */
.add-chunk {
    height: 272px; /* Такая же высота, как у картинок */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(139, 90, 43, 0.1) !important; /* Чуть активнее фон */
}

/* Центрируем кнопку внутри пустого чанка */
.add-photo-placeholder {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Чтобы кнопка добавления была видна (перебиваем абсолютное позиционирование для этого случая) */
.add-chunk .img-action-btn {
    position: relative;
    top: 0;
    right: 0;
    display: inline-flex;
}

/* Уточняем позиционирование для кнопки УДАЛИТЬ (на картинках) */
.image-chunk .img-action-btn:not(.add-chunk .img-action-btn) {
    position: absolute;
    top: 20px;
    right: 20px;
}

/* Центрируем кнопку ДОБАВИТЬ внутри пустого чанка */
.add-chunk {
    height: 292px; /* 272px картинка + padding чанка 10px*2 */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 90, 43, 0.08) !important;
    position: relative;
}

.add-chunk .img-action-btn {
  position: absolute;
  top: auto;
  right: auto;
  margin: 0 auto;
  display: inline-flex;
}

.upload-progress-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 4px;
    background: rgba(255,255,255,0.2);
    z-index: 9999;
    display: none;
}
.upload-progress-bar {
    width: 0%; height: 100%;
    background: var(--primary-color, #007bff);
    transition: width 0.2s ease;
}

/* ======================================
   Добавление Карточки Тура
   ====================================== */
.add-new-tour-card {
    border: 2px dashed var(--accent, #3498db);
    background: rgba(52, 152, 219, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 300px; /* Подстрой под высоту твоих обычных карточек */
}

.add-new-tour-card:hover {
    background: rgba(52, 152, 219, 0.1);
    transform: translateY(-5px);
}

.add-tour-content {
    text-align: center;
    color: var(--accent, #3498db);
}

.add-tour-content .plus-icon {
    font-size: 64px;
    font-weight: 200;
    line-height: 1;
    margin-bottom: 10px;
}

.add-tour-content .add-text {
    font-size: 16px;
    font-weight: 500;
    text-transform: uppercase;
}

.add-new-tour-card {
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px; /* Должно совпадать с высотой обычных карточек */
    background: rgba(0,0,0,0.02);
    cursor: pointer;
    order: -1;
}
.add-new-tour-card .plus-icon {
    font-size: 50px;
    color: #999;
}
.add-new-tour-card:hover {
    border-color: var(--accent);
    background: rgba(0,0,0,0.05);
}

/* По умолчанию скрываем карточку добавления */
.add-new-tour-card {
    display: none !important;
}

/* Показываем её только когда активен режим редактирования */
body.is-editing-active .add-new-tour-card {
    display: flex !important; /* или block, смотря какая верстка */
}
/* ======================================
   Создание нового расширенной страницы
   ====================================== */
[contenteditable="true"].editable-field:focus {
    outline: none;
    border-bottom: 2px dashed var(--accent);
    background: rgba(0,0,0,0.02);
}
/* Плейсхолдер для пустых полей */
[contenteditable="true"]:empty:before {
    content: attr(placeholder);
    color: #aaa;
    font-style: italic;
}

/* По умолчанию запрещаем редактирование */
.editable-field {
    pointer-events: none; /* Поле нельзя кликнуть или сфокусировать */
    cursor: default;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

/* Когда режим редактирования ВКЛЮЧЕН */
body.is-editing-active .editable-field {
    pointer-events: auto; /* Разрешаем взаимодействие */
    cursor: text;
  /*   background: rgba(0, 0, 0, 0.03); Легкая подсветка активных зон */
    border-radius: 4px;
    padding: 2px 4px;
}

/* Стили при фокусе на поле */
body.is-editing-active .editable-field:focus {
    outline: none;
    background: rgba(0, 0, 0, 0.05);
    border-bottom: 2px dashed var(--accent, #3498db);
}
/* Стили для плейсхолдера в contenteditable */
.editable-field[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted, #999);
    font-style: italic;
    cursor: text;
 /*   font-size: 1.1rem !important; */
  font-weight: 500;
}
/* Специфично для span (город), чтобы он не пропадал из вида */
#editable-city.editable-field:empty {
    display: inline-block;
    min-width: 80px;
    border-bottom: 1px dashed #ccc; /* Пунктир, чтобы юзер видел зону ввода */
}
/* Специфично для блока описания */
#editable-description.editable-field {
    min-height: 100px; /* Чтобы всегда было куда кликнуть */
    padding: 10px;
    border: 1px transparent dashed;
    transition: border-color 0.3s;
}

/* Подсвечиваем зону ввода при наведении в режиме редактирования */
.is-editing-active #editable-description.editable-field:hover {
    border-color: #ccc;
}
/* Чтобы пустой элемент не схлопывался и его можно было кликнуть */
.editable-field[contenteditable="true"]:empty {
    min-width: 150px;
    display: inline-block;
}
/* Плейсхолдер, если поле пустое */
[contenteditable="true"]:empty:before {
    content: attr(placeholder);
    color: #aaa;
    font-style: italic;
}

/* По умолчанию скрываем инпуты цен */
.price-edit-input {
    display: none;
}

/* В режиме просмотра скрываем элементы с нулевой ценой */
.price-item.hide-in-view {
    display: none;
}

/* Когда режим редактирования ВКЛЮЧЕН */
body.is-editing-active .price-edit-input {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

body.is-editing-active .price-value.view-mode {
    display: none; /* Скрываем текстовую цену (с валютой) */
}

body.is-editing-active .price-item.hide-in-view {
    display: flex; /* Показываем пустые цены для заполнения */
}

/* Стилизация инпута */
.price-edit-input input {
    width: 90px;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 1.1rem !important;
    font-family: inherit;
    background-color: var(--input-bg);
  color: var(--input-text) !important;
}

/* Режим просмотра (по умолчанию) */
.edit-mode { display: none !important; }
.view-mode { display: inline; }

/* Режим редактирования (когда у body есть класс) */
body.is-editing-active .edit-mode {
    display: inline-flex !important;
    align-items: center;
    gap: 1rem;
}
body.is-editing-active .view-mode {
    display: none !important;
}

/* Скрываем пустые цены, если мы НЕ в режиме редактирования */
.price-item.hide-in-view:not(.is-editing-active *) {
    display: none;
}

/* Скрываем все элементы редактирования, если режим не активен */
body:not(.is-editing-active) .edit-only-element {
    display: none !important;
}

/* ======================================
   Редактирование Расширенной карты с маршрутами
   ====================================== */
.locate-btn {
    width: 2.5rem;
  height: 2.5rem;
  background: var(--card-bg) !important;
  border: 0.063rem solid var(--border);
  border-radius: var(--radius);
  color: var(--nav-icon-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0.25rem 0.75rem var(--book-shadow);
  margin-left: 0.4rem !important;
}
body.dark-mode .locate-btn {
  background: rgba(255, 255, 255, 0.22) !important;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.4);
  color: #6E420A;
  color: #060400 !important;
}
.locate-btn:hover { background: #f4f4f4; }
.locate-btn.leaflet-control {
  margin-top: 6.7rem !important;
}

/* 1. Прячем элементы редактирования по умолчанию */
.edit-only-ui {
    display: none !important;
}

/* 2. Показываем их только когда у body есть класс активного редактирования */
body.is-editing-active .edit-only-ui {
    display: flex !important;
    border: 1.5px dashed var(--primary) !important;
  background-color: var(--input-bg);
  box-shadow: 0 0 12px rgba(from var(--primary) r g b / 0.15);
  border-radius: 4px;
}

/* Селектор выбора режима (Метка/Маршрут) */
.map-select {
    padding: 6px 12px;
    font-size: var(--fs-sm); /* ~14px адаптивно */
    font-family: inherit;
    color: var(--foreground);
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.map-select:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px var(--warning-bg);
}

/* Контейнер для статистики маршрута */
.route-info-mini {
    margin-top: 10px;
    padding: 8px;
    font-size: var(--fs-small);
    color: var(--muted-foreground);
    background: var(--auth-msg-bg);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
}
.animated-boat { stroke-dasharray: 15, 10; animation: boat-flow 15s linear infinite; }
@keyframes boat-flow { from { stroke-dashoffset: 300; } to { stroke-dashoffset: 0; } }

.map-header{display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;background: var(--bg-card);}
/* Контейнер для инпута и результатов */
.map-search-container-small {
    position: relative; /* Обязательно: привязывает список к этому блоку */
    display: flex;
    flex-direction: column;
  /*  min-width: 250px;  Минимальная ширина поиска */
}

/* Сам инпут */
#map-search-input-small {
    width: 100%;
    box-sizing: border-box;
}

/* Выпадающий список */
/* Контейнер для результатов */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;

    /* Используем твои переменные темы */
    background-color: var(--dropdown-bg);
    border: 1px solid var(--dropdown-border);
    border-top: none;

    /* Скругление из твоей переменной --radius (0.5rem) */
    border-radius: 0 0 var(--radius) var(--radius);

    /* Твоя переменная тени для бумаги/карт */
    box-shadow: 0 0.25rem 0.938rem var(--book-shadow);

    z-index: 1100;
    max-height: 15.625rem; /* 250px */
    overflow-y: auto;
    margin-top: 0.125rem; /* 2px */
}

/* Элементы списка */
.search-item {
    padding: 0.625rem 0.75rem; /* 10px 12px */
    cursor: pointer;

    /* Используем твой адаптивный размер шрифта для маленьких подписей */
    font-size: var(--fs-small);

    /* Цвета текста и границ из темы */
    color: var(--foreground);
    border-bottom: 1px solid var(--border);

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: var(--dropdown-bg);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.search-item:last-child {
    border-bottom: none;
}

/* Состояние при наведении */
.search-item:hover {
    /* Используем твой акцентный золотой/коричневый */
    background-color: var(--secondary);
    color: var(--accent);
}

/* Если ничего не найдено */
.no-results {
    padding: 0.625rem;
    color: var(--muted-foreground);
    font-size: var(--fs-small);
    text-align: center;
    background-color: var(--dropdown-bg);
}

/* Кастомный скроллбар в стиле твоей темы */
.search-suggestions::-webkit-scrollbar {
    width: 0.3rem;
}
.search-suggestions::-webkit-scrollbar-track {
    background: var(--dropdown-bg);
}
.search-suggestions::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius);
}






/* Контейнер секции */

.video-title {
    font-size: var(--fs-h3);
    color: var(--foreground);
    margin-bottom: 1.5rem;
    border-left: 0.25rem solid var(--accent);
  padding-left: 0.75rem;
}

/* Сетка видео */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.4s ease;
}

.video-card {
    position: relative;
    background: var(--background);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform, opacity;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
}

.video-wrapper iframe {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border: none;
}

/* Кнопка удаления в твоем стиле (danger) */
.delete-video-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--danger);
    color: var(--logout-text);
    border: none;
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.delete-video-btn:hover {
    background: var(--danger-hover);
}

/* Современная форма ввода */
.add-video-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.modern-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--input-text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: var(--fs-text);
    outline: none;
    transition: border-color 0.2s;
}

.modern-input:focus {
    border-color: var(--ring);
}

/* Кнопка добавления в твоем стиле Primary */
.btn-primary-action {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--btn-primary-shadow);
    transition: opacity 0.2s;
    white-space: nowrap;
}

.btn-primary-action:hover {
    opacity: 0.9;
}

/* Управление видимостью через body */
.edit-only-video {
    display: none !important;
}

body.is-editing-active .edit-only-video {
    display: inline !important;
}

/* Адаптивность для мобилок */
@media (max-width: 480px) {
    .input-group {
        flex-direction: column;
    }
}

.empty-video-msg, .empty-description-msg{color: var(--muted-foreground); font-size: var(--fs-text); padding: 1rem 0; font-style: italic;}

.google-route-line {
    transition: stroke 0.3s ease, opacity 0.3s ease;
    pointer-events: none !important; /* На всякий случай */
}


[contenteditable="false"]:focus {
    outline: none;
}
/* Запрещаем правку и специфические эффекты фокуса по умолчанию */
.tour-title, .tour-author {
    -webkit-user-modify: read-only !important;
    user-select: text; /* Разрешаем выделять, но не править */
}

/* Разрешаем правку ТОЛЬКО когда активен класс редактирования */
.is-editing .tour-title,
.is-editing .tour-author {
    -webkit-user-modify: read-write-plaintext-only !important;
    user-select: contain;
}

.view-mode-date{
  margin-right: 4px;
  font-size: var(--fs-small);
}

/* Базовый стиль для всех полей */
.editable-field:empty:before {
    content: attr(data-placeholder);
    color: #aaa;
    font-style: italic;
    cursor: text;
}

/* Фикс для случая, когда редактирование отключено, но поле пустое */
.editable-field[contenteditable="false"]:empty:before {
    content: attr(data-placeholder);
    opacity: 0.7; /* Делаем чуть бледнее, когда нельзя редактировать */
}

/* Подсветка полей только в активном режиме редактирования */
.is-editing-active .editable-field[contenteditable="true"] {
    outline: 1px dashed var(--accent-color);
    outline-offset: 4px;
    border-radius: 4px;
    cursor: text;
}

.is-editing-active .editable-field[contenteditable="true"]:hover {
    background: rgba(var(--accent-rgb), 0.05);
}
/* ======================================
   Sort Photo
   ====================================== */
/* Блок сортировки под галереей */
.photo-sorter-wrapper {
    padding: 15px;
    display: none; /* Скрыто по умолчанию */
}

body.is-editing-active .photo-sorter-wrapper {
    display: block; /* Показываем только в режиме редактирования */
}

.photo-sort-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 10px;
    padding-bottom: 30px;
}

.sort-tile {
    position: relative;
    aspect-ratio: 1.04;
    cursor: grab;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--accent);
    transition: transform 0.2s;
}

.sort-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sort-tile.dragging {
    opacity: 0.5;
    transform: scale(1.05);
    border-color: #28a745;
}

.tile-order {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 4px;
}

.section-hint{
  color: var(--text-muted, #999);
  font-style: italic;
  cursor: text;
  font-size: 1.1rem !important;
  font-weight: 500;
}



#photoSortGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); /* Автоматическая сетка */
    gap: 10px;
    align-items: start;
}

.sort-tile {
    cursor: grab;
    user-select: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
    position: relative;
}

.sort-tile.drag-over {
    outline: 2px dashed #28a745;
    outline-offset: 2px;
    transform: scale(1.05);
}

.sort-tile img {
    pointer-events: none; /* Чтобы картинка внутри не перехватывала событие drag */
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
}

.empty-sort-msg-wrapper {
    grid-column: 1 / -1; /* Растягиваем на всю ширину сетки */
    text-align: center;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.sort-tile.empty-placeholder {
    cursor: default;
    opacity: 0.5;
    filter: grayscale(1);
    border: 2px dashed #ccc;
    pointer-events: none; /* Запрещаем перетаскивание заглушки */
}

.empty-text-hint {
    font-size: 14px;
    color: #888;
}

/* 1. Базовые стили для всех редактируемых полей (общие) */
#editable-title,
.tour-title[contenteditable="true"],
.tour-author[contenteditable="true"] {
    outline: none;
    min-height: 1.2em;
    min-width: 100px;
    display: block;
    transition: background 0.2s;
}

/* Подсветка при редактировании (только для карточек) */
.tour-title[contenteditable="true"],
.tour-author[contenteditable="true"] {
    background: rgba(255, 255, 255, 0.05);
    font-style: normal; /* Убираем курсив во время ввода */
}

/* 2. Общая логика плейсхолдера для всех полей */
#editable-title:empty:before,
.tour-title[contenteditable="true"]:empty:before,
.tour-author[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #999; /* Универсальный цвет плейсхолдера */
    font-style: italic;
    font-weight: normal;
    pointer-events: none;
    cursor: text;
}


/* 4. Поведение при фокусе (опционально, делает плейсхолдер еще бледнее) */
[contenteditable="true"]:focus:before {
    opacity: 0.5;
}

/* 5. Стиль "Черновика" (когда редактирование ЗАВЕРШЕНО, но текст — заглушка) */
.tour-title.draft-title {
    color: #888 !important;
    font-style: italic;
    font-weight: 400;
    content: attr(data-placeholder); /* Если есть атрибут, берем его */
}
.tour-author.draft-author {
    content: attr(data-placeholder); /* Или возьми значение из t('no_author') */
    color: var(--text-muted);
    font-style: italic;
}
.is-editing [contenteditable="true"]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    opacity: 0.5;
    pointer-events: none;
    display: block; /* Для Edge */
}

/* 1. Стили для плейсхолдера автора (режим чтения) */
.tour-author.draft-author:empty::before {
    content: attr(data-placeholder); /* Берет текст из HTML атрибута */
    color: var(--text-muted, #888);  /* Цвет заглушки */
    font-style: italic;
    opacity: 0.7;
}

/* 2. Стили для режима редактирования (когда атрибут contenteditable="true") */
.is-editing [contenteditable="true"]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted, #888);
    opacity: 0.5;
    pointer-events: none;
    display: block; /* Важно для корректного отображения в Edge */
}

/* 3. Дополнительно: чтобы пустой элемент не схлопывался в ноль */
.tour-author:empty {
    min-height: 1.2em;
    min-width: 50px;
    display: block; /* Убедись, что это не inline */
}
/* ======================================
   Аватар
   ====================================== */
/* По умолчанию (режим просмотра) */
.avatar-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 1rem;
    cursor: default; /* Обычный курсор */
    transition: opacity 0.2s ease;
}

/* Скрываем иконку камеры по умолчанию */
.avatar-edit-icon {
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--accent);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    border: 2px solid var(--secondary);
    pointer-events: none; /* Чтобы клик пролетал сквозь иконку в wrapper */
}

/* СОСТОЯНИЕ РЕДАКТИРОВАНИЯ */
body.is-editing-active .avatar-wrapper {
    cursor: pointer; /* Меняем курсор на руку */
}

body.is-editing-active .avatar-wrapper:hover {
    opacity: 0.9; /* Визуальный отклик при наведении */
}

body.is-editing-active .avatar-edit-icon {
    display: flex; /* Показываем камеру только в режиме правки */
}

/* Добавляем подсказку через CSS, так как атрибут title не умеет быть динамическим */
body.is-editing-active .avatar-wrapper:hover::after {
    content: attr(data-attr); /* Можно брать из t('change_avatar') вставив в data-attr */
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
}
