/* ==========================================================================
   SETTINGS PANEL — плавающая кнопка настроек оформления + выезжающая панель
   ========================================================================== */

/* Повторяет геометрию и анимацию раскрытия #drafts-float-btn:
   top:100px, left:0, 40x50 — наша кнопка стоит ровно над ней (top:50px),
   та же логика "сворачивается до иконки, на hover выезжает с текстом".
   В разметке страницы: <div id="settings-float-btn" class="settings-on">Настройки</div> */
#settings-float-btn {
    box-sizing: border-box;
    position: fixed;
    background: #362e26;
    top: 50px;
    left: 0;
    z-index: 11;
    width: 40px;
    height: 50px;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    color: var(--text4);
    font-size: 0;
    transition: width 0.25s ease, font-size 0.15s ease;
}

#settings-float-btn:hover {
    width: 130px;
    flex-direction: row;
    justify-content: flex-start;
    padding-left: 8px;
    gap: 8px;
    font-size: 11px;
}

#settings-float-btn.settings-on:before {
    content: "\f890";
    font-family: "Font Awesome 6 Pro", "FontAwesome";
    font-size: 15px;
    color: var(--text3);
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    margin: 0;
}

/* ---------- Панель ---------- */

.settings-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
}

.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 300px;
    max-width: 90vw;
    background: var(--beg100);
    box-shadow: 4px 0 20px rgba(0,0,0,0.4);
    padding: 20px;
    box-sizing: border-box;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    pointer-events: auto;
    overflow-y: auto;
}

.settings-panel.is-open {
    transform: translateX(0);
}

.settings-panel-close {
    position: absolute;
    top: 14px;
    right: 14px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text2);
}

.settings-panel-close:before {
    content: "\f0d9";
    font-family: "Font Awesome 6 Pro", "FontAwesome";
    font-size: 16px;
}

.settings-panel-title {
    margin: 0 0 16px;
    font: 600 14px var(--font);
    color: var(--text1);
}

.settings-panel-section {
    margin-bottom: 20px;
}

.settings-panel-label {
    font: 400 11px var(--font);
    color: var(--text2);
    margin-bottom: 6px;
}

/* ---------- Шрифт в постах ---------- */

#chfont {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}

#chfontbut {
    color: var(--text1);
    font: 400 12px var(--font);
}

/* Свой арроу вместо браузерного — appearance:none снимает стандартный вид */
#chfontfam {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--beg300);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0L5 6L10 0Z' fill='%23999'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 9px 6px;
    color: var(--text1);
    border: 1px solid var(--borders);
    border-radius: 6px;
    padding: 5px 24px 5px 10px;
    font: 400 11px var(--font);
    cursor: pointer;
    max-width: 150px;
}

#chfontfam option {
    background: var(--beg100);
    color: var(--text1);
}

#chfontsize {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text1);
    font: 400 12px var(--font);
}

.fsizeplus,
.fsizeminus {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    background: var(--beg300);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0;
    transition: background 0.15s ease;
}

.fsizeplus:hover,
.fsizeminus:hover {
    background: var(--accent);
}

.fsizeplus:before,
.fsizeminus:before {
    font-family: "Font Awesome 6 Pro", "FontAwesome";
    font-size: 10px;
    color: var(--text1);
}

.fsizeplus:before { content: "\2b"; }
.fsizeminus:before { content: "\f068"; }

.fsize {
    min-width: 18px;
    text-align: center;
}

/* ---------- Кнопка "Сбросить" ---------- */

.settings-reset-btn {
    display: block;
    width: fit-content;
    margin: 10px auto 0;
    font: 500 10px var(--font);
    color: var(--text2);
    border: 1px solid var(--borders);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.settings-reset-btn:hover {
    background: var(--beg300);
    color: var(--text1);
}

/* ---------- Иконки стиля (светлый/тёмный) — строго в один ряд, без переносов ---------- */

.settings-style-icons {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.settings-style-icons li {
    border-radius: 8px;
    background: var(--beg300);
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.settings-style-icons li.active {
    background: var(--accent);
}

.settings-style-icons li a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.settings-style-icon {
    font-family: "Font Awesome 6 Pro", "FontAwesome";
    font-style: normal;
    font-size: 16px;
    color: var(--text1);
    transition: color 0.2s ease;
}

.settings-style-icons li.active .settings-style-icon {
    color: #fff;
}

/* ---------- Переключатель анимаций — тумблер on/off, не чекбокс ---------- */

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-toggle-row .settings-panel-label {
    margin-bottom: 0;
    font-size: 12px;
    color: var(--text1);
}

.settings-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.settings-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--beg300);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.25s ease;
}

.settings-toggle-track:before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text4);
    transition: transform 0.25s ease;
}

.settings-toggle input:checked + .settings-toggle-track {
    background: var(--accent);
}

.settings-toggle input:checked + .settings-toggle-track:before {
    transform: translateX(18px);
}

/* ---------- Слайдер затемнения/осветления: центр = без изменений ----------
   Стандартный браузерный range заменён на свой трек с отметкой середины
   и стилизованным ползунком, так как дефолтный вид смотрелся чужеродно */

.settings-dim-slider-wrap {
    position: relative;
    padding: 10px 0;
}

#settings-dim-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(to right, #1a1a1a 0%, var(--beg300) 50%, #f2f2f2 100%);
    outline: none;
    margin: 0;
    cursor: pointer;
}

/* Метка нулевой (нейтральной) точки по центру шкалы */
.settings-dim-slider-wrap:after {
    content: "";
    position: absolute;
    top: 10px;
    left: 50%;
    width: 2px;
    height: 4px;
    background: var(--text2);
    transform: translateX(-1px);
    pointer-events: none;
    opacity: 0.5;
}

#settings-dim-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--beg100);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.15s ease;
}

#settings-dim-slider::-webkit-slider-thumb:active {
    transform: scale(1.15);
}

#settings-dim-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--beg100);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.15s ease;
}

#settings-dim-slider::-moz-range-thumb:active {
    transform: scale(1.15);
}

#settings-dim-slider::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: transparent;
}

.settings-dim-labels {
    display: flex;
    justify-content: space-between;
    font: 400 10px var(--font);
    color: var(--text2);
    margin-top: 2px;
}

/* ---------- Слой затемнения/осветления ----------
   pointer-events: none задан здесь, в CSS, а не через JS — чтобы контент
   форума гарантированно оставался кликабельным независимо от логики скрипта */

#settings-dim-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    pointer-events: none;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    opacity: 0;
}

/* ---------- Статичное положение планет при отключённых анимациях ----------
   Без анимации спутники просто остаются в исходной (верх-лево) точке орбиты —
   это выглядит как "сбились в кучу" рядом с ядром. Явно ставим их в те точки,
   которые они и так проходят во время вращения: малый — низ-лево, большой — верх-право. */

body.dune-animations-disabled .orbit-large {
    animation: none !important;
    transform: rotate(90deg) !important;
}

body.dune-animations-disabled .orbit-small {
    animation: none !important;
    transform: rotate(-90deg) !important;
}

body.dune-animations-disabled .dune-info,
body.dune-animations-disabled .dune-title-img,
body.dune-animations-disabled .dune-subtitle {
    animation: none !important;
    opacity: 1 !important;
}

/* ---------- Защита от повторения сдвига шапки ----------
   #stylelist создаётся оригинальным скриптом стиля напрямую в body, если
   его ещё нет на странице — JS теперь переносит его в панель сразу на
   pun_mainReady, но это правило на случай, если он всё же на секунду
   окажется "голым" блочным элементом прямо в body до переноса. */
body > ul#stylelist:not(.settings-style-icons) {
    display: none;
}