/* retain HFS layout and interactions, including other plugins' content */
:root body {
    --tide-color: var(--tide-theme-color, #196d56);
    --bg: color-mix(in srgb, var(--tide-color) 3%, white);
    --text: color-mix(in srgb, var(--tide-color) 20%, #444);
    --text-high-contrast: color-mix(in srgb, var(--tide-color) 15%, #171717);
    --link: color-mix(in srgb, var(--tide-color) 40%, #222);
    --button-bg: color-mix(in srgb, var(--tide-color) 12%, white);
    --button-text: var(--link);
    --focus-color: var(--link);
    --ghost-contrast: #00000002;
    --ghost-contrast-alt: color-mix(in srgb, var(--tide-color) 7%, white);
    --faint-contrast: color-mix(in srgb, var(--tide-color) 16%, white);
    --mild-contrast: color-mix(in srgb, var(--tide-color) 25%, #888);
    --good-contrast: var(--text);
    --tide-surface: #ffffff;
    --tide-accent: color-mix(in srgb, var(--tide-color) 45%, black);
    --tide-on-accent: #ffffff;
    --tide-selected: color-mix(in srgb, var(--tide-color) 18%, white);
    --tide-folder: #9b6916;
    --tide-shadow: 0 12px 40px #00000009;
    --tide-success: #397b62;
    --tide-warning: #8c6c2e;
    --tide-error: #a0525c;
    background: var(--bg);
    line-height: 1.5;
    color-scheme: light;
}
:root body.theme-dark {
    --bg: color-mix(in srgb, var(--tide-color) 6%, #151515);
    --text: color-mix(in srgb, var(--tide-color) 12%, #ddd);
    --text-high-contrast: color-mix(in srgb, var(--tide-color) 4%, white);
    --link: color-mix(in srgb, var(--tide-color) 30%, white);
    --button-bg: color-mix(in srgb, var(--tide-color) 15%, #292929);
    --button-text: var(--link);
    --focus-color: var(--link);
    --ghost-contrast: #ffffff03;
    --ghost-contrast-alt: color-mix(in srgb, var(--tide-color) 12%, #303030);
    --faint-contrast: color-mix(in srgb, var(--tide-color) 15%, #3b3b3b);
    --mild-contrast: color-mix(in srgb, var(--tide-color) 20%, #999);
    --good-contrast: var(--text);
    --tide-surface: color-mix(in srgb, var(--tide-color) 8%, #202020);
    --tide-accent: color-mix(in srgb, var(--tide-color) 30%, white);
    --tide-on-accent: #161616;
    --tide-selected: color-mix(in srgb, var(--tide-color) 20%, #333);
    --tide-folder: #e7bd77;
    --tide-shadow: 0 12px 40px #0002;
    --tide-success: #8ebba4;
    --tide-warning: #c9b17c;
    --tide-error: #d29ca3;
    color-scheme: dark;
}
.list-wrapper {
    max-width: 68em;
    padding: 1.5em 1.25em 0;
    box-sizing: border-box;
}
.list-wrapper.tiles-mode { margin: auto; }
.list-wrapper > header {
    padding: 1em 0 .75em;
    border-top: 3px solid var(--tide-accent);
    margin-bottom: .8em;
    background: var(--bg);
}
.breadcrumb {
    border: 0;
    background: transparent;
    color: var(--text);
    line-height: 2.6;
    padding: .5em .65em;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    overflow-wrap: anywhere;
}
/* match the current location independently of text nodes or custom icons */
.breadcrumb:not(:has(~ .breadcrumb)) {
    background: var(--button-bg);
    color: var(--text-high-contrast);
    font-weight: 600;
}
#folder-stats { float: none; margin: .5em .6em 0; }
#filter-bar { height: auto; min-height: 2.75em; padding: .4em .6em; flex-wrap: wrap; }
#filter { min-width: 9em; padding: .65em .8em; background: var(--tide-surface); }
ul.dir {
    background: var(--tide-surface);
    border: 1px solid var(--faint-contrast);
    border-radius: 1em;
    box-shadow: var(--tide-shadow);
}
ul.dir > li { padding: .85em 1em; }
ul.dir > li:first-child { border-radius: 1em 1em 0 0; }
ul.dir > li:last-child { border-bottom: 0; border-radius: 0 0 1em 1em; }
ul.dir > li:only-child { border-radius: 1em; }
ul.dir > li:focus-within { background-color: var(--ghost-contrast-alt); }
ul.dir > li:has(input:checked) {
    background-color: var(--tide-selected);
    box-shadow: inset 3px 0 var(--tide-accent);
}
ul.dir .entry-name { color: var(--text-high-contrast); font-weight: 500; }
ul.dir > li.folder > .link-wrapper > a > .icon { color: var(--tide-folder); }
.list-mode ul.dir > li > .link-wrapper > a > .icon { font-size: 1.3em; }
ul.dir .entry-panel { color: var(--text); }
ul.dir .entry-comment { font-size: .9em; }
ul.dir li .entry-panel .icon-button { width: 36px; height: 36px; font-size: .9em; }
.list-wrapper input[type=checkbox] { transform: none; width: 1.25em; height: 1.25em; vertical-align: middle; }
.bottom-bar-stack-positioner {
    /* taller theme rows can overflow after HFS has measured the initial list */
    bottom: 0;
    width: min(calc(100% - 2.5em), 65.5em);
    background: var(--bg);
    border-top: 1px solid var(--faint-contrast);
    padding: .65em 0 max(.65em, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 20px var(--bg);
}
#menu-bar button { min-height: 44px; border-radius: .7em; }
#menu-bar > * { min-width: 0; }
#menu-bar button.toggled:enabled {
    background: var(--tide-accent);
    color: var(--tide-on-accent);
    text-shadow: none;
}
#menu-bar button:disabled { background: var(--button-bg); color: var(--button-text); opacity: .45; text-shadow: none; cursor: default; }
#paging { gap: .25em; padding-bottom: .5em; }
#paging button { border-radius: .5em; min-height: 40px; }
.dialog { background: var(--tide-surface); border: 1px solid var(--faint-contrast); box-shadow: var(--tide-shadow); }
.dialog-title { font-weight: 600; }
.toasts .toast {
    --tide-status: var(--link);
    background: color-mix(in srgb, var(--tide-status) 12%, var(--tide-surface));
    border: 1px solid color-mix(in srgb, var(--tide-status) 35%, var(--tide-surface));
    box-shadow: var(--tide-shadow);
}
.toasts .toast-success { --tide-status: var(--tide-success); }
.toasts .toast-warning { --tide-status: var(--tide-warning); }
.toasts .toast-error { --tide-status: var(--tide-error); }
.toast .toast-icon { color: var(--tide-status); }
.toast .toast-content a { color: inherit; }
.dialog button:not(.as-text) { min-height: 40px; }
:root #root .dialog-backdrop { backdrop-filter: none; }
button, .breadcrumb { transition: background-color .12s; }
:is(a, button, input, select, textarea):focus-visible { outline: 3px solid var(--focus-color); outline-offset: 3px; }
.tiles-mode ul.dir { gap: .75em; padding: .75em; background: transparent; border: 0; box-shadow: none; }
.tiles-mode ul.dir > li { border: 1px solid var(--faint-contrast); border-radius: .85em; background-color: var(--tide-surface); }
.tiles-mode ul.dir > li:has(input:checked) { background-color: var(--tide-selected); }
@media (hover: hover) {
    ul.dir > li:hover { background-color: var(--ghost-contrast-alt); }
    ul.dir > li:has(input:checked):hover { background-color: var(--tide-selected); }
}
/* match HFS's mobile breakpoint so labels never disappear between layouts */
@media (max-width: 42em) {
    .list-wrapper { padding: .5em .6em 0; }
    .list-wrapper > header { padding-top: .65em; }
    ul.dir > li { padding: .75em; }
    .bottom-bar-stack-positioner { width: calc(100% - 1.2em); }
    #menu-bar button { flex-direction: column; font-size: .78em; gap: .3em; min-height: 52px; }
    /* HFS hides mobile labels; the vertical layout has room to keep them */
    #menu-bar button .icon + .label { display: block; margin-left: 0; max-width: 100%; overflow-wrap: anywhere; line-height: 1.2; }
    #filter-bar > span { flex-basis: 100%; }
    ul.dir li .entry-panel .icon-button { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
    button, .breadcrumb { transition: none; }
}
@media (max-width: 360px) {
    #menu-bar > :not(.hide-sliding) { flex-basis: calc(33.333% - .3em); }
}


/* ==========================================================================
   СТИЛИЗАЦИЯ ПОДВАЛА (FOOTER) БЕЗ ВЫДЕЛЕНИЯ БЛОКА — ТОЛЬКО КНОПКИ И ТЕКСТ
   ========================================================================= */

/* Убираем фон, рамки и закругления самого подвала */
html body footer.gp-footer,
html body .gp-footer,
#gp-footer {
    background-color: transparent !important; /* Делаем подвал прозрачным */
    background: transparent !important;
    border: none !important; /* Убираем верхнюю фиолетовую линию */
    border-radius: 0 !important; /* Убираем закругления блока */
    margin: 40px 0 0 0 !important;
    padding: 16px 20px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Контейнер элементов подвала: распределение по ширине */
html body .gp-footer-credits,
.gp-footer-credits {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 90% !important;
    max-width: 90% !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    gap: 20px !important;
}

/* Копирайт и текст слева */
html body .gp-footer-copyright,
.gp-footer-credits p {
    color: var(--gp-color-fg-muted, #656565) !important; /* Цвет текста берется из приглушенного тона темы */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    margin: 0 !important;
    padding: 0 !important;
    white-space: nowrap !important;
}

/* Контейнер кнопок внешних ссылок (справа) */
html body .gp-footer-actions,
.gp-footer-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important; 
    justify-content: flex-end !important;
    align-items: center !important;
    gap: 8px 6px !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Фирменные кнопки-подложки в подвале */
html body .gp-footer-action-btn,
.gp-footer-action-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 28px !important; /* Одинаковая фиксированная высота */
    padding: 0 10px !important;
    background-color: var(--gp-color-canvas-inset, #fbfbfb) !important; /* Светлая подложка из вашей темы */
    border: 1px solid var(--gp-color-border-muted, #e4e4e4) !important; /* Граница из темы */
    border-radius: 8px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02) !important;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
    text-decoration: none !important;
}

/* Эффект наведения и выделения (Hover) на кнопки */
html body .gp-footer-action-btn:hover,
.gp-footer-action-btn:hover {
    background-color: var(--gp-color-white, #ffffff) !important; /* Кнопка становится чисто белой */
    border-color: var(--gp-color-primary, #826eb4) !important; /* Фирменная фиолетовая рамка темы */
    transform: translateY(-2px) !important; /* Приподнятие */
    box-shadow: 0 6px 16px rgba(130, 110, 180, 0.16) !important; /* Мягкое фиолетовое свечение в стиле темы */
}

/* Логотипы внутри кнопок в спокойном состоянии */
html body .gp-footer-action-img,
.gp-footer-action-img {
    display: block !important;
    height: 18px !important; /* Пропорциональная высота */
    width: auto !important;
    max-width: 90px !important;
    object-fit: contain !important;
    filter: grayscale(10%) opacity(0.85) !important; /* Слегка приглушаем картинку по вашей дефолтной логике */
    transition: filter 0.2s ease !important;
}

/* При наведении на саму кнопку — картинка становится сочной на 100% */
html body .gp-footer-action-btn:hover .gp-footer-action-img,
.gp-footer-action-btn:hover .gp-footer-action-img {
    filter: grayscale(0%) opacity(1) !important;
}

/* ==========================================================================
   АДАПТИВНОСТЬ ДЛЯ СМАРТФОНОВ И ПЛАНШЕТОВ (ДО 980px)
   ========================================================================== */
@media screen and (max-width: 980px) {
    html body footer.gp-footer,
    #gp-footer {
        padding: 16px 14px !important;
    }
    
    html body .gp-footer-credits,
    .gp-footer-credits {
        flex-direction: column !important; /* Перестраиваем в колонку на мобильных */
        justify-content: center !important;
        align-items: center !important;
        gap: 16px !important;
    }

    html body .gp-footer-actions,
    .gp-footer-actions {
        width: 100% !important;
        justify-content: center !important; /* Центрируем ряд кнопок */
        gap: 10px 8px !important;
    }

    html body .gp-footer-action-btn,
    .gp-footer-action-btn {
        height: 38px !important; /* Крупные тач-цели на мобильных */
        padding: 0 14px !important;
        flex: 1 1 auto !important; /* Растягивание в ряду */
        max-width: 130px !important;
    }
    
    html body .gp-footer-action-img,
    .gp-footer-action-img {
        height: 22px !important;
    }
}
