/* ==========================================
КОМНАТЫ: dropdown «Комнаты», модалка (плавное закрытие), страница поиска
========================================== */
.rm-wrap { position: relative; }
.rm-trigger {
    display: inline-flex; align-items: center; gap: 10px;
    background: #1d1e24; border: 1px solid #2c2e36; color: #ffffff;
    font-family: 'MyCustomFont'; font-size: 14px; font-weight: 700;
    padding: 12px 18px; border-radius: 12px; cursor: pointer; transition: all .2s;
}
.rm-trigger:hover { border-color: #3a3d46; color: #fff; transform: translateY(-1px); }
.rm-trigger svg { width: 16px; height: 16px; color: #8b8e98; flex-shrink: 0; }
.rm-trigger .rm-chev { width: 16px; height: 16px; transition: transform .2s; }
.rm-wrap.open .rm-chev { transform: rotate(180deg); }
.rm-wrap.open .rm-trigger { border-color: rgba(255,77,109,.5); color: #fff; }

.rm-menu {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 99999 !important;
    min-width: 230px; padding: 6px;
    background: rgba(13,14,17,.97); border: 1px solid #2c2e36; border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,.6); backdrop-filter: blur(12px);
    display: none; flex-direction: column; gap: 2px; animation: rmIn .16s ease both;
}
.rm-wrap.open .rm-menu,
.rm-menu.open { display: flex !important; }
@keyframes rmIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.rm-item {
    display: flex; align-items: center; gap: 10px;
    background: none; border: none; cursor: pointer; text-align: left;
    color: #ffffff; font-family: 'MyCustomFont'; font-size: 13.5px; font-weight: 600;
    padding: 11px 12px; border-radius: 10px; transition: all .15s;
}
.rm-item:hover { background: rgba(255,77,109,.12); color: #fff; }
.rm-item svg { width: 16px; height: 16px; color: #ff8fa3; flex-shrink: 0; }

/* ---------- Модалка создания ---------- */
.cr-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.cr-modal.hidden { display: none; }
.cr-backdrop { position: absolute; inset: 0; background: rgba(5,6,8,.7); backdrop-filter: blur(6px); animation: crFadeIn .2s ease both; }
.cr-card {
    position: relative; width: min(560px, calc(100% - 32px)); max-height: calc(100vh - 64px);
    display: flex; flex-direction: column;
    background: linear-gradient(160deg, #191a20, #121318);
    border: 1px solid rgba(255,77,109,.35); border-radius: 18px;
    box-shadow: 0 30px 80px rgba(0,0,0,.65), 0 0 30px rgba(255,77,109,.15);
    overflow: hidden; animation: crIn .22s ease both;
}
@keyframes crIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes crFadeIn { from { opacity: 0; } to { opacity: 1; } }
.cr-modal.closing .cr-card { animation: crOut .19s ease both; }
.cr-modal.closing .cr-backdrop { animation: crFadeOut .19s ease both; }
@keyframes crOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes crFadeOut { to { opacity: 0; } }

.cr-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #23252c; }
.cr-head b { font-size: 16px; color: #fff; }
.cr-x { background: none; border: none; color: #8b8e98; cursor: pointer; font-size: 15px; padding: 6px 10px; border-radius: 8px; }
.cr-x:hover { color: #fff; background: rgba(255,255,255,.06); }
.cr-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.cr-label { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: #8b8e98; font-weight: 600; }
.cr-hint { font-size: 12px; color: #6f727c; font-weight: 500; line-height: 1.4; }
.cr-input {
    background: #20212a; border: 1px solid #2c2e36; color: #e8e8ec;
    font-family: inherit; font-size: 14px; padding: 11px 14px; border-radius: 12px; outline: none;
    transition: border-color .15s;
}
.cr-input:focus { border-color: rgba(255,77,109,.6); }
.cr-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.cr-pill {
    background: #262831; border: 1px solid #33363f; color: #c9ccd4;
    font-family: inherit; font-size: 12.5px; font-weight: 600;
    padding: 8px 14px; border-radius: 999px; cursor: pointer; transition: all .15s;
}
.cr-pill:hover { border-color: #3a3d46; color: #fff; }
.cr-pill.active { background: linear-gradient(135deg, #ff4d6d, #d63a6a); border-color: transparent; color: #fff; }
.cr-check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: #c9ccd4; }
.cr-check input { display: none; }
.cr-check span {
    width: 16px; height: 16px; border-radius: 5px; border: 2px solid #4a4d57;
    position: relative; flex-shrink: 0; transition: all .15s;
}
.cr-check input:checked + span { border-color: #ff4d6d; background: #ff4d6d; }
.cr-check input:checked + span::after {
    content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.cr-perms { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cr-pass-row { display: flex; gap: 8px; }
.cr-pass-row.hidden { display: none; }
.cr-pass-row .cr-input { flex: 1; }
.cr-pass-row .cr-btn svg { width: 15px; height: 15px; display: block; }
.cr-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid #23252c; }
.cr-btn {
    font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
    padding: 11px 20px; border-radius: 12px; border: 1px solid transparent; transition: all .15s;
    display: inline-flex; align-items: center; gap: 8px;
}
.cr-btn.ghost { background: #20212a; border-color: #2c2e36; color: #c9ccd4; }
.cr-btn.ghost:hover { color: #fff; border-color: #3a3d46; }
.cr-btn.primary { background: linear-gradient(135deg, #ff4d6d, #d63a6a); color: #ffffff; box-shadow: 0 6px 18px rgba(255,77,109,.35); }
.cr-btn.primary:hover { transform: translateY(-1px); }

/* ---------- Тост ---------- */
.cr-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px);
    z-index: 9999; background: rgba(13,14,17,.94); border: 1px solid rgba(255,77,109,.5);
    color: #fff; font-size: 13px; font-weight: 700; padding: 10px 20px; border-radius: 999px;
    backdrop-filter: blur(8px); opacity: 0; transition: all .25s; pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.cr-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 768px) {
    .cr-toast {
        bottom: calc(85px + env(safe-area-inset-bottom, 0px)) !important;
        z-index: 99999 !important;
    }
}

/* ---------- Страница /rooms ---------- */
.rm-page { max-width: 1200px; margin: 0 auto; padding: 26px 40px 80px; color: #fff; font-family: 'MyCustomFont'; }
.rm-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.rm-head h1 { margin: 0; font-size: 26px; font-weight: 800; }
.rm-searchrow { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 22px; }
.rm-search-wrap {
    flex: 1;
    min-width: 280px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1d1e24;
    border: 1px solid #2c2e36;
    border-radius: 16px;
    padding: 0 18px;
    height: 52px;
    box-sizing: border-box;
    transition: border-color .25s ease, box-shadow .25s ease, background .25s ease;
}
html.is-mobile-device .rm-search-wrap {
    height: 54px !important;
    border-radius: 16px !important;
    padding: 0 18px !important;
}
.rm-search-wrap:focus-within {
    border-color: rgba(255, 77, 109, .65) !important;
    box-shadow: 0 0 0 4px rgba(255, 77, 109, .15) !important;
    background: #20212a !important;
}
.rm-search-wrap svg {
    width: 18px;
    height: 18px;
    color: #7a7d87;
    flex-shrink: 0;
    transition: color .25s;
}
.rm-search-wrap:focus-within svg {
    color: #ff4d6d !important;
}
.rm-search-wrap .rm-search {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    height: 100%;
    padding: 0;
    font-size: 15px;
    font-family: 'MyCustomFont';
}
.rm-search-wrap .rm-search::placeholder {
    color: #5d6068;
}
.rm-search-wrap .search-clear {
    background: none;
    border: none;
    color: #7a7d87;
    cursor: pointer;
    font-size: 15px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, transform .15s;
}
.rm-search-wrap .search-clear:hover {
    color: #ff4d6d !important;
    transform: scale(1.15);
}

.rm-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.rm-pill {
    background: #262831; border: 1px solid #33363f; color: #c9ccd4;
    font-family: inherit; font-size: 12.5px; font-weight: 600;
    padding: 9px 15px; border-radius: 999px; cursor: pointer; transition: all .15s;
}
.rm-pill:hover { border-color: #3a3d46; color: #fff; }
.rm-pill.active { background: linear-gradient(135deg, #ff4d6d, #d63a6a); border-color: transparent; color: #fff; }
.rm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

.rm-card.is-full .rm-members {
    background: rgba(248, 113, 113, 0.18) !important;
    border-color: rgba(248, 113, 113, 0.5) !important;
    color: #f87171 !important;
}
.rm-join.is-full-btn {
    background: #282a35 !important;
    color: #7e818c !important;
    box-shadow: none !important;
}
.rm-card {
    background: #1d1e24; border: 1px solid #2c2e36; border-radius: 16px; padding: 16px;
    display: flex; flex-direction: column; gap: 12px; transition: all .2s;
}
.rm-card:hover { transform: translateY(-3px); border-color: rgba(255,77,109,.5); }
.rm-card-head { display: flex; align-items: center; gap: 12px; }
.rm-priv {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.rm-priv svg { width: 18px; height: 18px; }
.rm-priv.public { background: rgba(110,231,160,.12); color: #6ee7a0; }
.rm-priv.hidden { background: rgba(148,163,184,.12); color: #94a3b8; }
.rm-priv.password { background: rgba(255,77,109,.12); color: #ff8fa3; }
.rm-card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rm-card-title b { font-size: 14px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-card-title span { font-size: 12px; color: #8b8e98; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-members {
    font-size: 12px; font-weight: 800; color: #ff8fa3;
    background: rgba(255,77,109,.12); border: 1px solid rgba(255,77,109,.4);
    padding: 4px 10px; border-radius: 999px; flex-shrink: 0;
}
.rm-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rm-host {
    display: inline-flex; align-items: center; gap: 6px; min-width: 0;
    font-size: 12px; color: #8b8e98;
}
.rm-host svg { width: 12px; height: 12px; color: #ffc861; flex-shrink: 0; }
.rm-host-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-join {
    background: linear-gradient(135deg, #ff4d6d, #d63a6a); color: #fff;
    font-family: inherit; font-size: 12.5px; font-weight: 700;
    border: none; border-radius: 10px; padding: 9px 16px; cursor: pointer;
    transition: all .15s; box-shadow: 0 4px 14px rgba(255,77,109,.3);
}
.rm-join:hover { transform: translateY(-1px); }
.rm-empty { text-align: center; color: #6f727c; font-size: 14px; padding: 60px 0; }
.rm-empty.hidden { display: none; }

@media (max-width: 768px) {
    .rm-page {
        padding: 16px 12px calc(70px + env(safe-area-inset-bottom, 0px)) !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    .rm-head {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .rm-head h1 {
        font-size: 20px !important;
        line-height: 1.25 !important;
        word-break: break-word !important;
    }

    .rm-trigger {
        width: 100% !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        padding: 10px 14px !important;
        font-size: 13.5px !important;
    }

    .rm-searchrow {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .rm-search-wrap {
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        height: 54px !important;
        padding: 0 18px !important;
        border-radius: 16px !important;
        background: #1d1e24 !important;
        border: 1px solid #2c2e36 !important;
        transition: border-color .25s ease, box-shadow .25s ease, background .25s ease !important;
    }

    .rm-search-wrap:focus-within {
        border-color: rgba(255, 77, 109, .65) !important;
        box-shadow: 0 0 0 4px rgba(255, 77, 109, .15) !important;
        background: #20212a !important;
    }

    .rm-search-wrap svg {
        width: 20px !important;
        height: 20px !important;
    }

    .rm-search-wrap .rm-search {
        font-size: 15.5px !important;
    }

    .rm-pills {
        width: 100% !important;
        display: flex !important;
        gap: 6px !important;
        overflow-x: auto !important;
        scrollbar-width: none !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 2px !important;
    }

    .rm-pills::-webkit-scrollbar {
        display: none !important;
    }

    .rm-pill {
        flex-shrink: 0 !important;
        padding: 7px 13px !important;
        font-size: 12px !important;
    }

    .rm-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .rm-card {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        padding: 14px !important;
    }

    .rm-card-head {
        min-width: 0 !important;
    }

    .rm-card-title {
        min-width: 0 !important;
    }

    .rm-card-foot {
        min-width: 0 !important;
        gap: 8px !important;
    }

    /* Модалка создания комнаты на мобильных */
    .cr-modal {
        padding: 12px !important;
        box-sizing: border-box !important;
    }

    .cr-card {
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100vh - 24px) !important;
        border-radius: 14px !important;
        box-sizing: border-box !important;
    }

    .cr-head {
        padding: 12px 14px !important;
    }

    .cr-head b {
        font-size: 14.5px !important;
        line-height: 1.25 !important;
        word-break: break-word !important;
    }

    .cr-body {
        padding: 12px 14px !important;
        gap: 12px !important;
    }

    .cr-perms {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .cr-input {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .cr-pills {
        gap: 6px !important;
    }

    .cr-pill {
        padding: 6px 11px !important;
        font-size: 11.5px !important;
    }

    .cr-foot {
        padding: 10px 14px !important;
        gap: 8px !important;
    }

    .cr-btn {
        flex: 1 1 auto !important;
        justify-content: center !important;
        padding: 9px 14px !important;
        font-size: 12.5px !important;
    }
}

/* ---------- Плавное появление ---------- */
@keyframes pgIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.fanfic-topbar-wrap { animation: pgIn .4s ease both; }
.ad-topline   { animation: pgIn .40s ease both; }
.ad-hero-inner{ animation: pgIn .45s ease .06s both; }
.ad-layout    { animation: pgIn .50s ease .14s both; }
.aw-top       { animation: pgIn .40s ease both; }
.awp-shell    { animation: pgIn .45s ease .06s both; }
.aw-controls  { animation: pgIn .50s ease .14s both; }
.rm-head      { animation: pgIn .40s ease both; }
.rm-searchrow { animation: pgIn .45s ease .06s both; }
.rm-grid      { animation: pgIn .50s ease .12s both; }
.ad-char, .ad-sim-card, .rm-card { animation: pgIn .35s ease both; }
