/* Верхние кнопки «Меню» и «Параметры»: значок и подпись; когда ширины не хватает — остаются только значки */
.top-controls {
    position: absolute;
    top: 65px;
    right: 60px;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.top-controls .menu-container { position: relative; top: auto; right: auto; }

.top-button,
.menu-button.top-button {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    min-height: 40px;
    background-color: darkgreen;
    border: none;
    border-radius: 7px;
    color: #fff;
    padding: 7px 16px;
    font-size: 20px;
    line-height: 1.1;
    cursor: pointer;
}
.top-button .btn-icon { font-size: 1.15em; }
.top-button:hover { background-color: #0a6a0a; margin-right: 0; }
.top-button:focus-visible, .settings-option:focus-visible { outline: 3px solid #b35c00; outline-offset: 2px; }

/* Параметры */
.settings { position: relative; }
.settings.floating { position: fixed; bottom: 1.75rem; right: 0.5rem; z-index: 2000; }
.settings.floating .top-button { padding: 4px 10px; font-size: 16px; min-height: 36px; }
.settings-card {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 240px;
    background: #fff;
    color: #222;
    border: 1px solid #b9c2b0;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    font: 16px/1.3 system-ui, sans-serif;
}
.settings-card[hidden] { display: none; }
.settings.floating .settings-card { top: auto; bottom: calc(100% + 6px); }
.settings-row { padding: 6px 4px; }
.settings-row + .settings-row { border-top: 1px solid rgba(128, 128, 128, 0.35); }
.settings-title { display: block; font-weight: 700; margin-bottom: 4px; }
.settings-options { display: flex; flex-wrap: wrap; gap: 6px; }
.settings-option {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    min-height: 36px;
    padding: 4px 10px;
    border: 1px solid #8a9a7e;
    border-radius: 6px;
    background: #f4f7f1;
    color: #1f3a12;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}
.settings-option:hover { background: #e3efd8; }
.settings-option.current,
.settings-option[aria-pressed="true"] { background: #2f5d17; color: #fff; border-color: #2f5d17; }

/* Подсказка у кнопки звука (при наведении) */
.has-tip { position: relative; }
.has-tip:hover::after,
.has-tip:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: max-content;
    max-width: 260px;
    padding: 6px 10px;
    background: #fff8d6;
    color: #1f3a12;
    border: 2px solid #4a7a2a;
    border-radius: 6px;
    font: 600 14px/1.3 system-ui, sans-serif;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    z-index: 10;
    pointer-events: none;
}
/* Звук нужен там, где есть наведение мышью; на телефоне строки звука нет */
@media (hover: none) { .settings-sound { display: none; } }

/* Тесно: подписи на кнопках убираем, значки остаются */
@media (max-width: 640px) {
    .top-button .btn-label { display: none; }
    .top-button, .menu-button.top-button { padding: 7px 11px; font-size: 20px; }
    .top-controls { top: 30px; right: 14px; gap: 6px; }
}
@media (max-width: 450px) { .top-controls { top: 15px; right: 8px; } }
@media (max-width: 280px) { .top-controls { top: 3px; right: 1px; } }
.settings-option .opt-label { white-space: nowrap; }

/* Панель «Коротко»: промежутки между новостями прозрачные — карта видна лучше; текст лежит на светлых карточках */
#sliding-panel { background-color: rgba(200, 200, 200, 0.25) !important; backdrop-filter: blur(2px); }
#panel-handle { background-color: rgba(200, 200, 200, 0.55); }
.news-item {
    background-color: rgba(255, 255, 255, 0.78);
    border-radius: 10px;
    padding: 6px 14px 10px;
}
.gap { height: 60px; background: transparent; }
.map.transparent { opacity: 0.88; }

/* ============ Тёмная тема: палитра для основных элементов (первая версия; карта остаётся светлой) ============ */
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] body { background-color: #14171c; color: #e8e8e8; }
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .menu-dropdown { background: #1e232b; color: #f0f0f0; border-color: #4a5160; }
html[data-theme="dark"] .menu-item_drop { color: #f0f0f0; }
html[data-theme="dark"] .menu-item_drop:hover { background-color: #2c333d; }
html[data-theme="dark"] .settings-option { background: #262d37; color: #f0f0f0; border-color: #566074; }
html[data-theme="dark"] .settings-option:hover { background: #313a47; }
html[data-theme="dark"] .settings-option.current,
html[data-theme="dark"] .settings-option[aria-pressed="true"] { background: #8ec1ff; color: #10202e; border-color: #8ec1ff; }
html[data-theme="dark"] .news-item { background-color: rgba(20, 23, 28, 0.8); color: #e8e8e8; }
html[data-theme="dark"] .news-item h2, html[data-theme="dark"] .news-item p { color: #e8e8e8; }
html[data-theme="dark"] #sliding-panel { background-color: rgba(20, 23, 28, 0.35) !important; }
html[data-theme="dark"] #panel-handle { background-color: rgba(30, 35, 43, 0.85); }
html[data-theme="dark"] #panel-handle h2 { color: #e8e8e8; }
html[data-theme="dark"] .faq-container, html[data-theme="dark"] .faq-item { background-color: #1e232b; color: #e8e8e8; }
html[data-theme="dark"] .faq-toc li a { background-color: #262d37; color: #e8e8e8; }
html[data-theme="dark"] .key { background-color: #262d37; border-color: #8a8f98; color: #e8e8e8; }
html[data-theme="dark"] .contact-info a, html[data-theme="dark"] .contact-info span { color: #e8e8e8; }
html[data-theme="dark"] .has-tip:hover::after { background: #2b2a1a; color: #ffe9a3; border-color: #ffb454; }
html[data-theme="dark"] .custom-text h1,
html[data-theme="dark"] .custom_text_media p,
html[data-theme="dark"] .custom_text_media span { color: #e8e8e8; }

/* ===== Карточка «Параметры» v2: строка = подпись слева, кнопки справа; тема — одна группа в строку ===== */
.settings-card { min-width: 330px; padding: 6px 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; }
.settings-title { margin: 0; min-width: 4.5em; text-align: left; }
.settings-options { flex-wrap: nowrap; gap: 0; }
.settings-option { border-radius: 0; margin-left: -1px; }
.settings-option:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.settings-option:last-child { border-radius: 0 6px 6px 0; }
.settings-option:only-child { border-radius: 6px; }
.settings-option.current, .settings-option[aria-pressed="true"] { position: relative; z-index: 1; }
@media (max-width: 400px) { .settings-card { min-width: 0; width: calc(100vw - 24px); } .settings-options .settings-option .opt-label { display: none; } .menu-dropdown { min-width: 200px; } }

/* ===== Тёмная тема: заголовки и подписи на тёмном фоне ===== */
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3,
html[data-theme="dark"] .h1, html[data-theme="dark"] .region_h1,
html[data-theme="dark"] .faq-header h1, html[data-theme="dark"] .contact-info h1 { color: #f2f2f2; }
html[data-theme="dark"] .settings-title { color: #ffd966; }
html[data-theme="dark"] .top-button { background-color: #2f7d32; }
html[data-theme="dark"] .top-button:hover { background-color: #3a9a3e; }
html[data-theme="dark"] a { color: #9fd0ff; }

/* ===== Меню: та же карточка, что у «Параметров» ===== */
.top-controls .menu-dropdown {
    top: calc(100% + 6px);
    right: auto;
    left: 0;
    min-width: 220px;
    background: #fff;
    color: #222;
    border: 1px solid #b9c2b0;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    font: 16px/1.3 system-ui, sans-serif;
}
.top-controls .menu-dropdown.show { display: flex; flex-direction: column; gap: 6px; }
.top-controls .menu-item_drop.settings-option {
    display: flex;
    justify-content: flex-start;
    margin: 0;
    border-radius: 6px;
    padding: 6px 12px;
    color: #1f3a12;
    background: #f4f7f1;
}
.top-controls .menu-item_drop.settings-option:hover { background: #e3efd8; }
html[data-theme="dark"] .top-controls .menu-dropdown { background: #1e232b; border-color: #4a5160; }
html[data-theme="dark"] .top-controls .menu-item_drop.settings-option { background: #262d37; color: #f0f0f0; }
html[data-theme="dark"] .top-controls .menu-item_drop.settings-option:hover { background: #313a47; }

/* Внутренние страницы: «Меню» и «Параметры» вверху справа, как на главной; при прокрутке остаются на месте */
.top-controls--fixed { position: fixed; top: 10px; right: 12px; }
.top-controls--fixed .top-button { font-size: 18px; }
@media (max-width: 640px) { .top-controls--fixed { top: 8px; right: 8px; } }

/* Основа выпадающего меню — здесь, чтобы работало на страницах без main.css */
.top-controls .menu-dropdown { display: none; position: absolute; z-index: 1100; }
.top-controls .menu-dropdown.show { display: flex; }

/* Карты областей: «Меню» над «Параметрами», справа внизу; списки раскрываются влево, чтобы не закрывать соседнюю кнопку */
.top-controls--bottom { position: fixed; top: auto; right: 8px; bottom: 28px; flex-direction: column; align-items: flex-end; gap: 6px; }
.top-controls--bottom .top-button { font-size: 16px; min-height: 36px; padding: 4px 12px; }
.top-controls--bottom .menu-dropdown,
.top-controls--bottom .settings-card { top: auto; bottom: 0; left: auto; right: calc(100% + 8px); }
.top-controls--bottom .menu-container,
.top-controls--bottom .settings { position: relative; }

/* ===== Тёмная тема, правки 2: белые блоки и тёмные цвета на тёмном ===== */
html[data-theme="dark"] .header-container { background-color: transparent; }
html[data-theme="dark"] .container { background-color: #1a1e25; border-color: #3a4150; }
html[data-theme="dark"] .faq-toc { background-color: #1e232b; }
html[data-theme="dark"] .faq-toc h3 { color: #ffd966; }
html[data-theme="dark"] .faq-toc li a { background-color: #262d37; color: #e8e8e8; border-color: #566074; }
html[data-theme="dark"] .faq-header p, html[data-theme="dark"] .faq-subtitle { color: #b8bec9; }
html[data-theme="dark"] .contact-info a[style*="darkgreen"], html[data-theme="dark"] .contact-info a[style*="darkgreen"] * { color: #7fd48a !important; }
html[data-theme="dark"] .contact-info svg, html[data-theme="dark"] .contact-info i { color: #7fd48a; }
html[data-theme="dark"] .key a { color: #7fd48a; }
html[data-theme="dark"] .news-item h2 { background-color: #27402a; color: #eaf5ea; }
html[data-theme="dark"] .news-item a { color: #9fd0ff; }
html[data-theme="dark"] .back-link-container { background-color: #1a1e25; }
html[data-theme="dark"] .filter-dropdown-content { background-color: #1e232b; border-color: #4a5160; }

/* Карта области остаётся светлой, поэтому всё, что лежит на карте (заголовок, поиск, переключатели, формы, подсказки), — со светлой схемой и тёмным текстом */
html[data-theme="dark"] #map { color-scheme: light; color: #222; }
html[data-theme="dark"] #map h1, html[data-theme="dark"] #map h2, html[data-theme="dark"] #map .reg_custom-text * { color: darkgreen; }
html[data-theme="dark"] #map a { color: #0b5cad; }
html[data-theme="dark"] #map label, html[data-theme="dark"] #map input, html[data-theme="dark"] #map textarea, html[data-theme="dark"] #map select { color: #222; }
html[data-theme="dark"] #map .top-controls, html[data-theme="dark"] #map .top-controls * { color-scheme: dark; }

/* Карта области: «Параметры» справа вверху, под кнопками видов карты (Карта / Спут / Рельеф) — «Меню» */
.top-controls--map { position: static; display: block; }
.top-controls--map .settings { position: fixed; top: 10px; right: 10px; z-index: 1200; }
.top-controls--map .menu-container { position: fixed; top: 104px; right: 10px; z-index: 1200; }
.top-controls--map .top-button { font-size: 16px; min-height: 36px; padding: 4px 12px; }
.top-controls--map .settings-card, .top-controls--map .menu-dropdown { top: calc(100% + 6px); bottom: auto; right: 0; left: auto; }
@media (max-width: 640px) { .top-controls--map .settings { top: 8px; right: 8px; } .top-controls--map .menu-container { top: 100px; right: 8px; } }
