/* ============================================================================
   BASE.CSS — общий фундамент всего сайта Mordvin Pro
   ----------------------------------------------------------------------------
   Здесь живёт ТОЛЬКО общая логика оформления: каркас, шапка, меню, кнопки,
   формы, карточки, чат, анимации и адаптивность.
   Цвета, фон и характер темы задаются переменными в:
     assets/css/theme-light.css  → светлая тема (публичная часть, коты)
     assets/css/theme-dark.css   → тёмная тема  (раздел «Управление», технологии)
   Подключение на странице:
     <link rel="stylesheet" href="/assets/css/base.css">
     <link rel="stylesheet" href="/assets/css/theme-light.css"> (ИЛИ theme-dark.css)
   ============================================================================ */

/* ============================================================================
   1. ПЕРЕМЕННЫЕ ПО УМОЛЧАНИЮ
   — Значения нейтральные: их всегда переопределяет файл выбранной темы.
   ============================================================================ */

:root {
    /* Фон страницы */
    --bg-image: none;
    --bg-color: #f2f4f8;

    /* Поверхности (шапка, подвал, панели, карточки) */
    --surface: rgba(255, 255, 255, 0.85);
    --surface-strong: rgba(255, 255, 255, 0.95);
    --surface-soft: rgba(255, 255, 255, 0.55);
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(0, 0, 0, 0.10);

    /* Текст */
    --text: #1d2330;
    --text-muted: rgba(29, 35, 48, 0.65);

    /* Акцент темы (кнопки, ссылки, активные элементы) */
    --accent: #e8890c;
    --accent-strong: #c97807;
    --accent-soft: rgba(232, 137, 12, 0.14);
    --accent-glow: rgba(232, 137, 12, 0.35);
    --on-accent: #ffffff;

    /* Статусы */
    --success: #2f9e63;
    --success-bg: rgba(47, 158, 99, 0.15);
    --danger: #e5484d;
    --danger-bg: rgba(229, 72, 77, 0.14);
    --warning: #d97b06;
    --warning-bg: rgba(217, 123, 6, 0.14);

    /* Формы */
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: rgba(0, 0, 0, 0.16);
    --input-text: #1d2330;

    /* Форма и тени */
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.18);

    /* Каркас */
    --header-height: 60px;
    --footer-height: 64px;
}

/* ============================================================================
   2. СБРОС И БАЗА ДОКУМЕНТА
   ============================================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth; /* плавная прокрутка по якорям */
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.55;

    color: var(--text);
    background-color: var(--bg-color);
    background-image: var(--bg-image);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;

    /* Отступ под фиксированные шапку и подвал */
    padding: calc(var(--header-height) + 24px) 16px calc(var(--footer-height) + 24px);

    /* Лёгкая анимация появления страницы — без перегруза */
    animation: page-in 0.35s ease both;
}

/* Плавное появление страницы */
@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Заголовки */
h1 {
    font-size: clamp(24px, 4.5vw, 32px);
    font-weight: 900;
    margin: 0 0 18px;
    text-align: center;
}

h2 {
    font-size: clamp(19px, 3vw, 24px);
    font-weight: 800;
    margin: 0 0 12px;
}

h3 {
    font-size: 18px;
    font-weight: 800;
    margin: 18px 0 10px;
}

p {
    margin: 10px 0;
}

/* Ссылки внутри контента */
a {
    color: var(--accent-strong);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    text-decoration: underline;
}

/* Длинные строки (токены, URL) — корректный перенос */
.word-break,
.device-details *,
.value li {
    word-break: break-all;
    overflow-wrap: anywhere;
    white-space: normal;
}

/* Зелёное «значение» — используется в профиле и whitelist */
.value {
    font-weight: bold;
    color: var(--success);
}

/* Центрированный блок-обёртка логотипа и заголовка страницы */
.page-head {
    text-align: center;
    margin: 6px auto 22px;
}

.page-head img {
    width: 150px;
    height: auto;
    display: block;
    margin: 0 auto 10px;
}

/* ============================================================================
   3. ШАПКА САЙТА (единая для обеих тем)
   ============================================================================ */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;

    background: var(--surface);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow);

    transition: top 0.3s ease;
}

.header-inner {
    max-width: 1200px;
    height: var(--header-height);
    margin: 0 auto;
    padding: 0 20px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    position: relative; /* точка отсчёта для мобильного меню */
}

/* Логотип */
.logo {
    display: flex;
    align-items: center;
    gap: 9px;

    color: var(--text);
    font-weight: 900;
    font-size: 18px;
    text-decoration: none;
    white-space: nowrap;
}

.logo:hover {
    text-decoration: none;
}

.logo img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    transition: transform 0.25s ease;
}

/* Кот в логотипе слегка «оживает» при наведении */
.logo:hover img {
    transform: scale(1.08) rotate(-3deg);
}

/* Блок «лого + бургер» */
.logo-burger {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* ============================================================================
   4. МЕНЮ
   — На ПК: строка ссылок. На мобильных: выпадающая панель по бургеру.
   ============================================================================ */

.menu {
    display: flex;
    align-items: center;
    gap: 4px;
}

.menu a {
    display: inline-block;
    padding: 9px 14px;

    border-radius: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;

    transition: background-color 0.25s ease, color 0.25s ease,
                transform 0.18s ease, box-shadow 0.25s ease;
}

.menu a:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
    text-decoration: none;
    transform: translateY(-2px);
}

/* Активный пункт меню (текущая страница) */
.menu a.current {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

/* Бургер — виден только на мобильных */
.burger {
    display: none;
    width: 42px;
    height: 42px;

    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-size: 26px;
    line-height: 1;

    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;

    transition: background-color 0.25s ease, transform 0.18s ease;
}

.burger:hover {
    background: var(--accent-soft);
}

.burger:active {
    transform: scale(0.88);
}

/* Ссылки входа/выхода в шапке */
.auth-links {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.auth-links .sep {
    font-weight: bold;
    opacity: 0.55;
}

/* ============================================================================
   5. КНОПКИ — единый стиль + эффект нажатия на ВСЁ
   — :hover  → подсветка/подъём (наведение)
   — :active → «вдавливание» (инерция нажатия)
   ============================================================================ */

/* Универсальное правило нажатия: applies to любые интерактивные элементы */
button,
.tab,
.btn,
.menu a,
.auth-links a,
.burger,
.chat-toggle,
.trash-btn,
input[type="submit"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* убираем задержку 300ms на мобильных */
}

/* Базовая «кнопка-ссылка»: .btn */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: 11px 20px;
    border: none;
    border-radius: var(--radius);

    background: var(--accent);
    color: var(--on-accent);
    font-weight: 800;
    font-size: 15px;
    font-family: inherit;
    text-decoration: none;
    text-align: center;

    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);

    transition: transform 0.18s ease, box-shadow 0.25s ease,
                background-color 0.25s ease, filter 0.25s ease;
}

.btn:hover {
    background: var(--accent-strong);
    box-shadow: 0 6px 18px var(--accent-glow);
    transform: translateY(-2px);
    text-decoration: none;
}

/* Эффект нажатия — «инерция» */
.btn:active {
    transform: translateY(1px) scale(0.96);
    box-shadow: 0 2px 6px var(--accent-glow);
    filter: brightness(0.94);
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Кнопка «назад» — вторичная, спокойная */
.btn-secondary {
    display: inline-block;
    padding: 10px 18px;
    border-radius: var(--radius);

    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text);
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;

    cursor: pointer;
    transition: transform 0.18s ease, background-color 0.25s ease,
                border-color 0.25s ease, box-shadow 0.25s ease;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.btn-secondary:active {
    transform: translateY(1px) scale(0.96);
}

/* Красная кнопка «выход» */
.logout {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 10px;

    background: var(--danger-bg);
    color: var(--danger) !important;
    font-weight: 800;
    font-size: 14px;
    text-decoration: none;

    transition: transform 0.18s ease, background-color 0.25s ease;
}

.logout:hover {
    background: var(--danger);
    color: #fff !important;
    text-decoration: none;
    transform: translateY(-2px);
}

.logout:active {
    transform: translateY(1px) scale(0.94);
}

/* Маленькие кнопки-действия (копировать, сохранить, удалить…) */
.btn-sm {
    display: inline-block;
    padding: 8px 14px;
    border: none;
    border-radius: 10px;

    font-weight: 700;
    font-size: 14px;
    font-family: inherit;
    color: var(--on-accent);
    text-decoration: none;
    cursor: pointer;

    transition: transform 0.18s ease, background-color 0.25s ease,
                box-shadow 0.25s ease, filter 0.25s ease;
}

.btn-sm:hover {
    transform: translateY(-2px);
    filter: brightness(1.08);
}

.btn-sm:active {
    transform: translateY(1px) scale(0.94);
    filter: brightness(0.92);
}

/* Цветовые варианты маленьких кнопок */
.btn-neutral  { background: var(--card-bg); color: var(--text); border: 1px solid var(--card-border); }
.btn-primary  { background: var(--accent); }
.btn-danger   { background: var(--danger); }
.btn-success  { background: var(--success); }

.btn-neutral:hover { background: var(--surface-strong); color: var(--accent-strong); border-color: var(--accent); }

/* ============================================================================
   6. ПАНЕЛИ И КАРТОЧКИ
   ============================================================================ */

/* Основная контентная панель страницы */
.panel,
.container,
.about-container,
.auth-switch,
.manage-wrapper {
    max-width: 860px;
    margin: 0 auto 24px;
    padding: 30px 34px;

    background: var(--surface);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    border-radius: var(--radius-lg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
}

/* Широкие версии для таблиц и галереи */
body[data-page="users"] .manage-wrapper {
    max-width: 1200px;
}

/* Широкая панель (галерея картинок) */
.panel-wide {
    max-width: 1100px;
}

/* Вложенный блок (секция внутри панели) */
.block {
    margin: 0 0 22px;
    padding: 20px;

    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);

    transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.block:hover {
    border-color: var(--accent-glow);
}

/* Карточка-«строка» (устройства, whitelist-правила, заявки) */
.item-card {
    margin-bottom: 14px;
    padding: 16px 18px;

    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);

    cursor: pointer;
    transition: background-color 0.25s ease, border-color 0.25s ease,
                transform 0.18s ease, box-shadow 0.25s ease;
}

.item-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.item-card:active {
    transform: scale(0.995);
}

.item-card.no-click {
    cursor: default;
}

/* Заголовок карточки (гибкий) */
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================================================
   7. СТАТУСЫ И БЕЙДЖИ
   ============================================================================ */

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 8px;

    font-size: 13px;
    font-weight: 800;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-ok      { background: var(--success-bg); color: var(--success); }
.badge-bad     { background: var(--danger-bg);  color: var(--danger); }
.badge-warn    { background: var(--warning-bg); color: var(--warning); }
.badge-accent  { background: var(--accent-soft); color: var(--accent-strong); }

/* Точки онлайн/оффлайн */
.online-dot,
.offline-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.online-dot {
    background: var(--success);
    box-shadow: 0 0 5px var(--success);
    animation: pulse-dot 2s ease infinite;
}

.offline-dot {
    background: var(--danger);
    box-shadow: 0 0 5px var(--danger);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

/* ============================================================================
   8. ФОРМЫ
   ============================================================================ */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="datetime-local"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 11px 13px;

    border: 1px solid var(--input-border);
    border-radius: 10px;

    background: var(--input-bg);
    color: var(--input-text);
    font-size: 15px;
    font-family: inherit;

    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
    min-height: 110px;
    resize: vertical;
    line-height: 1.5;
}

select option {
    background: var(--surface-strong);
    color: var(--text);
}

/* Подписи полей */
label {
    display: block;
    margin: 14px 0 6px;
    font-weight: 700;
    font-size: 14px;
}

/* Чекбоксы протоколов */
.proto-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    white-space: nowrap;
    word-break: normal !important;
    cursor: pointer;
}

.proto-item input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Счётчик символов под textarea */
.char-counter {
    margin-top: 6px;
    text-align: right;
    font-size: 13px;
    color: var(--text-muted);
}

/* Информационные окна */
.notice {
    margin: 14px 0;
    padding: 13px 16px;
    border-radius: 10px;
    font-weight: 700;
}

.notice-ok   { background: var(--success-bg); color: var(--success); }
.notice-err  { background: var(--danger-bg);  color: var(--danger); }
.notice-warn { background: var(--warning-bg); color: var(--warning); }

/* ============================================================================
   9. ВКЛАДКИ (login/register, users)
   ============================================================================ */

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 22px;
    overflow-x: auto; /* на узких экранах вкладки прокручиваются вбок */
    padding-bottom: 4px;
}

.tab {
    flex-shrink: 0;
    padding: 11px 20px;

    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text);

    font-weight: 700;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;

    transition: background-color 0.25s ease, color 0.25s ease,
                transform 0.18s ease, box-shadow 0.25s ease;
}

.tab:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.tab:active {
    transform: translateY(1px) scale(0.96);
}

.tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 3px 12px var(--accent-glow);
}

/* Формы входа/регистрации */
.auth-form {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.auth-form.active {
    display: flex;
}

/* ============================================================================
   10. ПОДВАЛ
   ============================================================================ */

.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;

    padding: 10px 12px;
    text-align: center;

    background: var(--surface);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.10);

    transition: bottom 0.3s ease;
}

.site-footer p {
    margin: 3px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.site-footer a {
    color: var(--text);
    font-weight: 700;
}

.site-footer a:hover {
    color: var(--accent-strong);
}

/* Скрытие шапки/подвала при прокрутке вниз (управляется site.js) */
body.scrolled-down .site-header { top: calc(-1 * var(--header-height) - 6px); }
body.scrolled-down .site-footer { bottom: calc(-1 * var(--footer-height) - 10px); }

/* ============================================================================
   11. КНОПКА ПРОКРУТКИ ВВЕРХ/ВНИЗ
   ============================================================================ */

#scroll-direction-btn {
    position: fixed;
    right: 20px;
    bottom: calc(var(--footer-height) + 16px);
    z-index: 1400;

    display: none;
    padding: 10px 15px;

    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: var(--surface-strong);
    color: var(--text);

    font-weight: 800;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--shadow);

    transition: transform 0.18s ease, background-color 0.25s ease,
                color 0.25s ease, box-shadow 0.25s ease;
}

#scroll-direction-btn:hover {
    background: var(--accent);
    color: var(--on-accent);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px var(--accent-glow);
}

#scroll-direction-btn:active {
    transform: translateY(1px) scale(0.92);
}

/* ============================================================================
   12. ЧАТ-ВИДЖЕТ (кот-помощник)
   — Единая разметка в components/chat.php, цвета — через переменные темы.
   ============================================================================ */

.chat-widget {
    position: fixed;
    right: 20px;
    bottom: calc(var(--footer-height) + 16px);
    z-index: 1600;

    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* Страница users: чат не должен перекрывать кнопку прокрутки */
body[data-page="users"] .chat-widget {
    bottom: calc(var(--footer-height) + 74px);
}

/* Круглая кнопка с котом */
.chat-toggle {
    width: 62px;
    height: 62px;
    padding: 0;

    border: 2px solid var(--card-border);
    border-radius: 50%;
    background: var(--surface-strong);
    cursor: pointer;
    overflow: hidden;

    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.chat-toggle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
    transition: transform 0.25s ease;
}

.chat-toggle:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 22px var(--accent-glow);
    transform: translateY(-3px);
}

.chat-toggle:hover img {
    transform: scale(1.1) rotate(-6deg); /* кот поворачивает голову */
}

.chat-toggle:active {
    transform: scale(0.9);
}

/* Кружок с числом непрочитанных */
.chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;

    min-width: 21px;
    height: 21px;
    padding: 0 5px;

    border-radius: 999px;
    background: var(--danger);
    color: #fff;

    font-size: 12px;
    font-weight: 900;
    line-height: 21px;
    text-align: center;

    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Панель чата */
.chat-panel {
    position: absolute;
    right: 0;
    bottom: 76px;

    width: min(370px, calc(100vw - 24px));
    height: min(520px, calc(100vh - 160px));

    display: flex;
    flex-direction: column;
    overflow: hidden;

    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    background: var(--surface-strong);
    box-shadow: var(--shadow-lg);

    transform-origin: bottom right;
    transform: translateY(12px) scale(0.92);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s;
}

.chat-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Шапка чата */
.chat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;

    background: var(--accent);
    color: var(--on-accent);
}

.chat-head img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    object-fit: contain;
    padding: 3px;
}

.chat-head-title {
    flex: 1;
    min-width: 0;
    text-align: left;
    line-height: 1.25;
}

.chat-head-title b {
    display: block;
    font-size: 15px;
}

.chat-head-title small {
    opacity: 0.85;
    font-size: 12px;
}

.chat-close {
    width: 32px;
    height: 32px;

    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
    font-size: 16px;
    cursor: pointer;

    transition: background-color 0.2s ease, transform 0.18s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.32);
}

.chat-close:active {
    transform: scale(0.85);
}

/* Выбор пользователя (только для админа) */
.chat-adminbar {
    padding: 8px 10px;
    border-bottom: 1px solid var(--card-border);
    background: var(--card-bg);
}

.chat-adminbar select {
    margin: 0;
    padding: 8px 10px;
    font-size: 14px;
}

/* Лента сообщений */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;

    display: flex;
    flex-direction: column;
    gap: 10px;

    scrollbar-width: thin;
}

.chat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 88%;
}

/* Сообщения поддержки — слева, с котом */
.chat-msg.support {
    align-self: flex-start;
}

.chat-msg.support .chat-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--surface-soft);
    object-fit: contain;
    padding: 2px;
    flex-shrink: 0;
}

.chat-msg .bubble {
    padding: 9px 13px;

    border-radius: 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);

    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-msg .bubble time {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    opacity: 0.55;
}

/* Сообщения пользователя — справа, акцентные */
.chat-msg.me {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg.me .bubble {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

/* Плашка для гостей «войдите, чтобы писать» */
.chat-note {
    padding: 9px 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    border-top: 1px solid var(--card-border);
}

/* Поле ввода */
.chat-inputbar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--card-border);
    background: var(--card-bg);
}

.chat-inputbar textarea {
    min-height: 42px;
    max-height: 110px;
    padding: 9px 12px;
    font-size: 14px;
    resize: none;
}

.chat-send {
    flex-shrink: 0;
    width: 42px;
    height: 42px;

    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 17px;
    cursor: pointer;

    transition: transform 0.18s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

.chat-send:hover {
    background: var(--accent-strong);
    box-shadow: 0 4px 14px var(--accent-glow);
    transform: translateY(-2px);
}

.chat-send:active {
    transform: scale(0.88);
}

.chat-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================================================
   13. УТИЛИТЫ
   ============================================================================ */

.text-center { text-align: center; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.hidden { display: none !important; }

/* Гибкие «строки кнопок» */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin: 18px 0;
}

.btn-row .btn,
.btn-row .btn-secondary {
    margin: 0; /* отступы задаёт gap, а не margin */
}

/* ============================================================================
   14. АДАПТИВНОСТЬ
   ============================================================================ */

/* Планшеты и телефоны */
@media (max-width: 860px) {

    /* Показываем бургер, прячем строку меню */
    .burger {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .menu {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        left: 0;

        width: max-content;
        min-width: 200px;
        max-width: calc(100vw - 32px);

        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 12px;

        background: var(--surface-strong);
        border: 1px solid var(--card-border);
        border-radius: var(--radius);
        box-shadow: var(--shadow-lg);

        opacity: 0;
        transform: translateY(-8px);
        pointer-events: none;
        transition: opacity 0.25s ease, transform 0.25s ease;
    }

    .menu.open {
        display: flex;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .menu a {
        padding: 12px 16px;
        font-size: 15px;
        text-align: left;
    }
}

/* Телефоны */
@media (max-width: 600px) {

    body {
        padding-left: 10px;
        padding-right: 10px;
        padding-bottom: calc(var(--footer-height) + 20px);
    }

    .header-inner {
        padding: 0 12px;
    }

    .logo span {
        font-size: 16px;
    }

    /* Панели — компактнее */
    .panel,
    .container,
    .about-container,
    .auth-switch,
    .manage-wrapper {
        padding: 20px 16px;
        border-radius: var(--radius);
    }

    /* Карточки устройств/правил */
    .card-head {
        flex-direction: column;
        align-items: stretch;
    }

    /* Кнопочные строки — в столбик на всю ширину */
    .btn-row {
        flex-direction: column;
        align-items: stretch;
    }

    /* Чат — почти на весь экран */
    .chat-widget {
        right: 12px;
    }

    .chat-toggle {
        width: 56px;
        height: 56px;
    }

    .chat-panel {
        width: calc(100vw - 24px);
        height: min(62vh, 480px);
        bottom: 70px;
    }

    #scroll-direction-btn {
        right: 12px;
        bottom: calc(var(--footer-height) + 10px);
        padding: 9px 12px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .logo span {
        display: none; /* на самых узких остаётся только кот */
    }
}

/* ============================================================================
   15. ДОСТУПНОСТЬ: уважаем настройку «уменьшить движение»
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
