/* Навигация и общение на телефоне: нижняя панель, компактная лента форума, новое с прошлого визита,
   «Сейчас обсуждают» на главной, строка обсуждения на странице аниме. */

/* ---------- Нижняя панель ---------- */

.av-tabbar {
    display: none;
}

@media (max-width: 768px) {
    .av-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1200;
        display: flex;
        align-items: stretch;
        height: calc(58px + env(safe-area-inset-bottom, 0px));
        padding: 0 4px env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
        background: rgba(21, 19, 42, 0.97);
        border-top: 1px solid rgba(148, 163, 184, 0.16);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        transition: transform 0.22s ease;
    }

    body.tabbar-hidden .av-tabbar,
    body.tabbar-typing .av-tabbar,
    body.tabbar-locked .av-tabbar,
    body.cm2-docked .av-tabbar {
        transform: translateY(100%);
    }

    .av-tabbar__item {
        position: relative;
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #a8a6c4;
        font-size: 11px;
        font-weight: 500;
        line-height: 1.1;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }

    .av-tabbar__item:hover,
    .av-tabbar__item:focus-visible {
        color: #e6e4f3;
    }

    .av-tabbar__item.is-active {
        color: var(--accent, #d8c8a8);
        font-weight: 600;
    }

    .av-tabbar__icon {
        width: 24px;
        height: 24px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .av-tabbar__label {
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .av-tabbar__badge {
        position: absolute;
        top: 5px;
        left: 50%;
        margin-left: 5px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        box-sizing: border-box;
        border-radius: 9px;
        background: #ff7a59;
        color: #1b1930;
        font-size: 11px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .av-tabbar__dot {
        position: absolute;
        top: 8px;
        left: 50%;
        margin-left: 7px;
        width: 9px;
        height: 9px;
        border-radius: 50%;
        background: #ff7a59;
        box-shadow: 0 0 0 2px #15132a;
    }

    .av-tabbar__dot[hidden] {
        display: none;
    }

    body.has-tabbar {
        padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    }

    /* Кнопка чата живёт над панелью и опускается, когда панель уехала */
    body.has-tabbar .anime-chat.closed {
        bottom: calc(70px + env(safe-area-inset-bottom, 0px));
        transition: bottom 0.22s ease;
    }

    body.has-tabbar.tabbar-hidden .anime-chat.closed,
    body.has-tabbar.tabbar-locked .anime-chat.closed {
        bottom: 14px;
    }
}

/* ---------- Лента форума ---------- */

.fh-new {
    display: inline-flex;
    align-items: center;
    height: 20px;
    margin-left: 8px;
    padding: 0 7px;
    border-radius: 10px;
    background: var(--accent, #d8c8a8);
    color: #1b1930;
    font-size: 0.75rem;
    font-weight: 700;
    vertical-align: 2px;
    white-space: nowrap;
}

.fh-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid rgba(216, 200, 168, 0.35);
    border-radius: 14px;
    background: rgba(216, 200, 168, 0.08);
    color: var(--fh-text, #e5eefb);
    font-size: 0.92rem;
    text-decoration: none;
}

.fh-notice:hover {
    border-color: rgba(216, 200, 168, 0.6);
}

.fh-notice > i:first-child {
    color: var(--accent, #d8c8a8);
}

.fh-notice > span {
    flex: 1 1 auto;
}

.fh-notice > i:last-child {
    color: var(--fh-muted, #9fb3ca);
}

.fh-pages--auto [data-fh-next],
.fh-pages--auto > span {
    display: none;
}

.fh-pages--auto::after {
    content: '';
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-top-color: var(--fh-accent, #60a5fa);
    animation: av-spin 0.8s linear infinite;
}

@keyframes av-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 640px) {
    /* Одна последняя реплика на тему, вся карточка — ссылка в тему */
    .fh-topic.has-msgs .fh-msgs > .fh-msg:not(:last-of-type),
    .fh-topic.has-msgs .fh-topic__more,
    .fh-topic.has-msgs .fh-topic__foot {
        display: none;
    }

    .fh-topic {
        cursor: pointer;
    }

    .fh-msg__acts a.fh-link-btn {
        display: none;
    }

    .fh-msg__acts .fh-link-btn,
    .fh-topic__foot .fh-link-btn {
        min-height: 40px;
        padding: 0 4px;
    }

    .fh-topic .fh-msg__body {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .fh-topic__thumb img {
        width: 44px;
        height: 62px;
    }

    .fh-sort {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .fh-sort::-webkit-scrollbar {
        display: none;
    }
}

/* ---------- Тема: новое с прошлого визита ---------- */

.ft-new-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    color: var(--accent, #d8c8a8);
    font-size: 0.82rem;
    font-weight: 700;
    scroll-margin-top: 90px;
}

.ft-new-divider::before,
.ft-new-divider::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: rgba(216, 200, 168, 0.35);
}

article.cm2.cm2--unread {
    border-radius: 10px;
    background: rgba(216, 200, 168, 0.07);
}

/* ---------- Главная: «Сейчас обсуждают» ---------- */

.av-pulse__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.av-pulse__head .section-title {
    margin: 0;
}

.av-pulse__all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    color: var(--accent, #d8c8a8);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.av-pulse__list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.av-pulse__item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--border, #4a4a6c);
    border-radius: 14px;
    background: var(--card, rgba(25, 25, 45, 0.6));
    color: var(--text, #e0e0e0);
    text-decoration: none;
}

.av-pulse__item:hover {
    border-color: rgba(216, 200, 168, 0.5);
}

.av-pulse__poster {
    width: 38px;
    height: 54px;
    flex: 0 0 38px;
    border-radius: 7px;
    object-fit: cover;
}

.av-pulse__poster--icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(216, 200, 168, 0.12);
    color: var(--accent, #d8c8a8);
    font-size: 18px;
}

.av-pulse__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.av-pulse__title,
.av-pulse__last {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.av-pulse__title {
    font-size: 0.95rem;
    font-weight: 600;
}

.av-pulse__last {
    color: var(--muted, #a0a0b8);
    font-size: 0.82rem;
}

.av-pulse__last b {
    color: var(--text, #e0e0e0);
    font-weight: 600;
}

.av-pulse__new {
    flex: 0 0 auto;
    height: 22px;
    padding: 0 8px;
    border-radius: 11px;
    background: var(--accent, #d8c8a8);
    color: #1b1930;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.av-pulse__count {
    flex: 0 0 auto;
    color: var(--muted, #a0a0b8);
    font-size: 0.8rem;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .av-pulse__list {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Страница аниме: вход в обсуждение ---------- */

.av-discuss {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 520px;
    min-height: 60px;
    margin-top: 14px;
    padding: 10px 12px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(20, 18, 40, 0.55);
    color: #eeedf6;
    text-decoration: none;
}

.av-discuss:hover {
    border-color: rgba(216, 200, 168, 0.5);
    color: #fff;
}

.av-discuss__icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 12px;
    background: rgba(216, 200, 168, 0.14);
    color: var(--accent, #d8c8a8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.av-discuss__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
}

.av-discuss__title {
    font-size: 0.95rem;
    font-weight: 600;
}

.av-discuss__last {
    /* Одна строка без nowrap: иначе длинная реплика растягивает весь блок героя шире экрана */
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    color: #b9b7d0;
    font-size: 0.82rem;
}

.av-discuss__last b {
    color: #e3e2ee;
    font-weight: 600;
}

.av-discuss__chevron {
    color: #a8a6c4;
}

@media (max-width: 768px) {
    .av-discuss {
        width: 100%;
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .av-tabbar,
    body.has-tabbar .anime-chat.closed {
        transition: none;
    }
}

/* ---------- Лента форума на телефоне: карточки, как в макете ---------- */

@media (max-width: 640px) {
    .fh-feed {
        gap: 10px;
    }

    .fh .fh-topic {
        padding: 12px;
        border: 1px solid rgba(148, 163, 184, 0.14);
        border-radius: 16px;
        background: rgba(35, 33, 64, 0.92);
    }

    .fh .fh-topic.is-pinned {
        border-color: rgba(240, 183, 101, 0.35);
    }

    .fh .fh-topic__thumb img {
        width: 46px;
        height: 64px;
        border-radius: 8px;
    }

    .fh .fh-topic__titlebox {
        position: relative;
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .fh .fh-topic.has-new .fh-topic__titlebox {
        padding-right: 46px;
    }

    .fh .fh-topic__title {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-size: 16px;
        font-weight: 600;
        line-height: 1.3;
    }

    .fh .fh-new {
        position: absolute;
        top: 0;
        right: 0;
        height: 22px;
        margin: 0;
        padding: 0 8px;
        border-radius: 11px;
        font-size: 12px;
        vertical-align: 0;
    }

    .fh .fh-topic__meta {
        margin-top: 0;
        gap: 2px 8px;
        font-size: 13px;
    }

    /* Последняя реплика — на подложке, кнопка ответа круглая справа */
    .fh .fh-topic .fh-msg {
        position: relative;
        gap: 10px;
        margin-top: 10px;
        padding: 8px 52px 8px 10px;
        border: 0;
        border-radius: 12px;
        background: rgba(20, 18, 40, 0.72);
    }

    .fh .fh-topic > .fh-msg {
        padding-right: 10px;
    }

    .fh .fh-topic .fh-msg__av img {
        width: 26px;
        height: 26px;
    }

    .fh .fh-topic .fh-msg__hd {
        font-size: 13px;
    }

    .fh .fh-topic .fh-msg__body {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        max-height: none;
        overflow: hidden;
        font-size: 14px;
        line-height: 1.4;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .fh .fh-topic .fh-msg__acts {
        position: absolute;
        top: 50%;
        right: 4px;
        margin: 0;
        gap: 0;
        transform: translateY(-50%);
    }

    .fh .fh-topic .fh-msg__acts .fh-link-btn[data-fh-reply] {
        width: 44px;
        height: 44px;
        min-height: 44px;
        padding: 0;
        justify-content: center;
        border-radius: 12px;
        font-size: 0;
    }

    .fh .fh-topic .fh-msg__acts .fh-link-btn[data-fh-reply] i {
        font-size: 17px;
    }
}
