/* ======================================
   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 .book-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);
}

/* ======================================
   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;
}

.book-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); /* На мобилках категории можно сделать чуть крупнее */
    }
}
/* ======================================
   Book Grid (Adaptive)
   ====================================== */
.book-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) {
    .book-grid {
        /* Фиксируем 3 колонки для стабильности верстки на мобилках пошире */
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Мобильные устройства (средние) */
@media (min-width: 484px) {
    .book-grid {
        /* Фиксируем 3 колонки для стабильности верстки на мобилках пошире */
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

/* Планшеты */
@media (min-width: 766px) {
    .book-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Десктоп и большие планшеты */
@media (min-width: 990px) {
    .book-grid {
        /* Возвращаемся к твоим 5 колонкам, когда места достаточно */
        grid-template-columns: repeat(5, 1fr);
        gap: 1.25rem; /* На больших экранах можно чуть увеличить расстояние */
    }
}

/* Экстра-широкие экраны */
@media (min-width: 1200px) {
    .book-grid {
        /* На 4K мониторах сетка не будет бесконечно растягиваться, если есть обертка */
        gap: 1.5rem;
    }
}

/* ======================================
   Book Card (Adaptive & Clean)
   ====================================== */

.book-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;
}

.book-card:hover {
    /* Используем rem для смещения */
    transform: translateY(-0.25rem);
}

.book-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3; /* Книжный стандарт */
    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;
}

.book-card:hover .book-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;
}

/* Стили для реального изображения обложки */
.book-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; }
}

/* Контейнер с информацией под книгой (название, автор) */
.book-info {
    padding: 0.25rem 0.1rem;
}
/* ======================================
   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; }

/* =================================================
   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;
   }
}
/* ======================================
   Full Book Info & Edit Logic
   ====================================== */

.book-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: 2.75rem;
}

/* Сброс маржинов, чтобы кнопка не "падала" из-за отступов текста */
.book-title, .book-author {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.25;
}

.book-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;
}

.book-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;
   }
}
/* Твой селектор: Появление при наведении и коричневый цвет */
.book-card:has(.edit-info-minimal) .book-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: 4px;
    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"] {
    /* Пунктирная рамка для визуального отличия от обычного инпута */
    border: 1.5px dashed var(--primary) !important;
    outline: none;

    background-color: var(--input-bg);
    border-radius: var(--radius);
    padding: 0.125rem 0.5rem; /* Адаптивные 2px 8px */
    min-width: 3.125rem;
    display: inline-block;

    /* Мягкое свечение в тон основной темы */
    box-shadow: 0 0 12px rgba(from var(--primary) r g b / 0.15);

    /* Цвет курсора */
    caret-color: var(--primary);
    transition: all 0.2s ease-in-out;
}

[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);
}

/* Вспомогательные классы для анимации текста */
.book-title, .book-author {
    transition: background 0.3s ease, color 0.2s ease;
}

/* Интеллектуальная подсветка (только если есть права на редактирование) */
.book-card:has(.edit-info-minimal) .title-group:hover .book-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;
}

/* Блокировка интерактивности карточки в режиме правки */
.book-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) {
    .book-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;
}

/* Приватность */
/* Контейнер обложки должен быть относительным */
.book-cover {
    position: relative;
    overflow: hidden;
}


/* Кнопка смены Инфо о книге */
.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;
}

.book-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#books-container .books-grid .book-card {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Это правило ДОЛЖНО быть ниже в файле и иметь такой же или больший вес */
div#books-container .books-grid .book-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 .book-title,
.is-editing .book-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; /* Добавляем то самое многоточие (...) */
}
/* Оптимизация отрисовки карточек */
.book-card {
    contain: layout style; /* Подсказываем браузеру не пересчитывать всё дерево */
}
/* Убираем задержку JS, добавляем плавное появление через CSS */
.book-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. Родительская карточка */
.book-card {
    display: flex;
    flex-direction: column;
    min-width: 0;       /* Позволяет дочерним элементам сжиматься */
    width: 100%;
}

/* 2. Контейнер категории (Наплыв на обложку) */
.book-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. ЭФФЕКТЫ ПРИ НАВЕДЕНИИ */
.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);
}

/* Основной контейнер инфо-блока */
/* Общие стили (Desktop) */
.book-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;
}

.book-title, .book-author {
    width: 100%;
    outline: none;
    text-align: center;
    unicode-bidi: plaintext;
    -webkit-user-modify: read-write-plaintext-only;
    overflow: hidden;
    margin: 0;
}

.book-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;
}

.book-author {
  /*  font-size: 0.85rem; */
    color: var(--accent);
    opacity: 0.8;
    margin-top: 4px;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: block;
}

/* Сдвижка срабатывает ТОЛЬКО когда на родителе (.book-info) есть класс .is-editing */
.book-info.is-editing .title-group {
    padding-right: 45px;
}
/* Стили для мобильных (Mobile) */
@media (max-width: 480px) {
    .book-title {
        font-size: 1.1rem; /* Увеличили с 1rem */
        line-height: 1.3;
        max-height: 3.9em; /* 1.3 * 3 */
    }

    .book-author {
        font-size: 0.95rem; /* Увеличили с 0.85rem */
        margin-top: 6px;
    }

}

.book-title, .book-author {
    margin: 0 !important; /* Обнуляем дефолтные отступы браузера */
    padding: 0;
}

.book-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) */
.book-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;
}

/* Дополнительно: стиль при наведении на активную кнопку */
.book-info.is-editing .edit-info-minimal:hover {
    filter: brightness(0.95); /* Легкое потемнение при наведении */
    transform: scale(1.1);
}

/* Убедимся, что иконка внутри тоже наследует цвет */
.book-info.is-editing .edit-info-minimal svg {
    stroke: var(--accent) !important;
}


/* Категория (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: 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);
}

.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);
}