/* ============================================================
   chatWS — modals.css   (loaded LAST, after responsive.css)
   ------------------------------------------------------------
   The element box (#elementBox — room list, room settings, room
   create, settings, …) was styled by FOUR stylesheets that fought
   each other (base / chat / social / responsive). The result on
   phones:
     • the × button sat on top of the first row (it covered "+ New"),
     • the box was 95–100vh tall PLUS margins PLUS padding, so it
       overflowed the screen and its top/bottom were clipped,
     • the × scrolled away with long content (Room Settings).
   This file is the single source of truth. Keep it last.
============================================================ */

/* ── Overlay ───────────────────────────────────────────────── */
.element-box {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding:
        max(12px, env(safe-area-inset-top, 0px))
        max(12px, env(safe-area-inset-right, 0px))
        max(12px, env(safe-area-inset-bottom, 0px))
        max(12px, env(safe-area-inset-left, 0px));
    background: rgba(7,7,7, .74);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 1;
    transition: none;
}
.element-box.visible { display: flex; }
.element-box-backdrop { position: absolute; inset: 0; }

/* ── Card ──────────────────────────────────────────────────── */
/* max-height:100% is measured inside the overlay's padding, so the card
   can never be taller than the visible screen (no more clipped top/bottom). */
.element-box-inner {
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    max-height: 100%;
    margin: 0;
    padding: 18px 18px 20px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-card, #111111);
    color: var(--text-primary, #f5f5f5);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .65);
    transform: none;
    transition: none;
    animation: elementBoxIn .18s ease-out;
}
.element-box.visible .element-box-inner { transform: none; }
@keyframes elementBoxIn {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

/* ── Close button ──────────────────────────────────────────── */
/* A sticky flex item that takes NO vertical space (negative bottom margin):
   it stays pinned in the top-right corner while long content scrolls, and it
   sits on top of the first row — so content headers reserve a lane for it
   (padding-right on .rl-head, .rs-title, .rc-title …). */
.element-box-inner > .element-close {
    position: sticky;
    top: 8px;
    z-index: 6;
    align-self: flex-end;
    flex: 0 0 auto;
    width: 34px;  height: 34px;
    min-width: 34px; min-height: 34px;
    margin: 0 -4px -34px 8px;
    padding: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; line-height: 1;
    color: #d4d4d4;
    background: rgba(39,39,39, .92);
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 50%;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.element-box-inner > .element-close:hover,
.element-box-inner > .element-close:focus-visible { background: rgba(255, 255, 255, .16); color: #fff; outline: none; }

/* Elements that draw their own header + × (Settings, Users in Room, Search Users):
   show ONLY theirs, in the header row, instead of two stacked × buttons. */
.element-box-inner:has(.element-header .element-close) > .element-close { display: none; }
/* Same for boxes with their own × in a custom header (Settings .st-x, News .nw-x, …):
   any other button that calls closeElementBox() replaces the generic one. */
.element-box-inner:has(> :not(.element-close) [onclick*="closeElementBox"]) > .element-close,
.element-box-inner > .element-close.cws-dup-close { display: none; }
.element-header .element-close {
    position: static;
    flex: 0 0 auto;
    margin: 0;
    width: 34px; height: 34px; min-width: 34px; min-height: 34px;
    padding: 0; font-size: 22px; line-height: 1;
    color: #d4d4d4;
    background: rgba(255, 255, 255, .06);
    border-radius: 50%;
}
.element-header .element-close:hover { background: rgba(255, 255, 255, .16); color: #fff; }

/* ── Header lanes: keep titles clear of the × ──────────────── */
.rs-title, .rc-title { min-height: 34px; padding-right: 40px; box-sizing: border-box; }

/* ── Phones ────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .element-box-inner { max-width: 100%; padding: 16px 14px 18px; border-radius: 14px; }
}

/* ── Room password prompt (js/room_function.js -> cwsAskRoomPassword) ── */
.cws-pw {
    position: fixed; inset: 0; z-index: 2100;
    display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box;
    background: rgba(7,7,7, .78);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.cws-pw-card {
    width: 100%; max-width: 360px; box-sizing: border-box; padding: 26px 22px 20px; text-align: center;
    background: var(--bg-card, #111111); color: #f5f5f5;
    border: 1px solid rgba(255, 255, 255, .09); border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .65);
    animation: elementBoxIn .18s ease-out;
}
.cws-pw-icon {
    width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 22px;
    color: #d4b26a; background: rgba(184, 150, 79, .16);
}
.cws-pw-card h3 { margin: 0 0 6px; font-size: 19px; font-weight: 800; }
.cws-pw-card p  { margin: 0 0 16px; font-size: 14px; color: #a3a3a3; line-height: 1.5; }
.cws-pw-card p strong { color: #e5e5e5; }
.cws-pw-input {
    display: block; width: 100%; box-sizing: border-box; height: 46px; padding: 0 14px;
    background: #0a0a0a; color: #f5f5f5; font-size: 16px; font-family: inherit; outline: none;
    border: 1px solid rgba(255, 255, 255, .14); border-radius: 10px;
}
.cws-pw-input:focus { border-color: #b8964f; box-shadow: 0 0 0 3px rgba(184, 150, 79, .18); }
.cws-pw-err { min-height: 20px; margin: 8px 0 4px; font-size: 13px; font-weight: 600; color: #f87171; }
.cws-pw-actions { display: flex; gap: 10px; margin-top: 8px; }
.cws-pw-btn {
    flex: 1; height: 42px; border: none; border-radius: 10px; cursor: pointer;
    font-size: 14px; font-weight: 700; font-family: inherit;
}
.cws-pw-btn.primary { background: #b8964f; color: #fff; box-shadow: 0 6px 18px rgba(184, 150, 79, .32); }
.cws-pw-btn.primary:hover { background: #957637; }
.cws-pw-btn.ghost { background: rgba(255, 255, 255, .07); color: #d4d4d4; border: 1px solid rgba(255, 255, 255, .12); }

/* ── Sign-up popups (Register / Guest login) get taller with gender + date of birth ── */
.popup-content { max-height: calc(100% - 8px); overflow-y: auto; box-sizing: border-box; -webkit-overflow-scrolling: touch; }
.popup .form-group select,
.popup .form-group input[type="date"] { width: 100%; box-sizing: border-box; }
.popup .form-group input[type="date"] { min-height: 44px; }

/* ── Guest notice (avatar menu + Edit Profile) ── */
.menu-guest-note {
    display: flex; align-items: flex-start; gap: 9px;
    margin: 8px 10px 4px; padding: 10px 12px; cursor: pointer;
    font-size: 12.5px; line-height: 1.4; color: #ecfccb;
    background: rgba(116, 177, 12, .22); border: 1px solid rgba(116, 177, 12, .5); border-radius: 10px;
}
.menu-guest-note i { margin-top: 2px; }
.menu-guest-note:hover { background: rgba(116, 177, 12, .32); }
.guest-banner {
    display: flex; align-items: flex-start; gap: 9px;
    margin: 0 0 4px; padding: 11px 16px; cursor: pointer;
    font-size: 13.5px; line-height: 1.4; color: #fff; background: #74b10c;
}
.guest-banner:hover { background: #82c50f; }
.guest-banner i { margin-top: 2px; }

/* ── Modules switched off in Admin -> Modules ── */
body.mod-off-friends .rpanel-tab[data-tab="friends"] { display: none !important; }

/* ── Stacking ──────────────────────────────────────────────────
   Overlay boxes get their z-index at runtime from js/layer_stack.js
   (last opened = on top, 20000+). Toasts must sit above all of them
   — they were at 5000/9999, i.e. hidden behind the profile box. */
#cwsToastHost, #toastContainer, .toast-container, body > .notification { z-index: 2147483000 !important; }

/* ── System bot (rank 69) messages — join / leave lines ─────── */
.message-rank--bot { color: #22d3ee !important; background: rgba(34, 211, 238, .12) !important; }
.message--bot .bot-jl { display: inline-flex; align-items: center; gap: 6px; font-style: italic; color: #a3a3a3; }
.message--bot .bot-jl b { font-style: normal; font-weight: 700; color: #e5e5e5; }
.message--bot .bot-jl i { font-size: 12px; }
.message--bot .bot-jl-join  i { color: #4ade80; }
.message--bot .bot-jl-leave i { color: #f87171; }
.adm-badge.bot { background: rgba(34, 211, 238, .14); color: #22d3ee; }

/* ── System bot moderation / name / rank lines ─────────────── */
.message--bot .bot-act { display:inline-flex; align-items:center; flex-wrap:wrap; gap:6px; font-style:italic; color:#a3a3a3; }
.message--bot .bot-act b { font-style:normal; font-weight:700; color:#e5e5e5; }
.message--bot .bot-act i { font-size:12px; }
.message--bot .bot-act-kick i, .message--bot .bot-act-ban i, .message--bot .bot-act-room_block i { color:#f87171; }
.message--bot .bot-act-mute i, .message--bot .bot-act-room_mute i { color:#fb923c; }
.message--bot .bot-act-unban i, .message--bot .bot-act-unmute i, .message--bot .bot-act-unkick i,
.message--bot .bot-act-room_unmute i, .message--bot .bot-act-room_unblock i { color:#4ade80; }
.message--bot .bot-act-rank i { color:#fbbf24; }
.message--bot .bot-act-rename i { color:#d4b26a; }
.message--bot .bot-act-reason { font-style:italic; color:#737373; }

/* ── Owner console (/console — js/console.js) ───────────────────────────── */
#cws-console{position:fixed;z-index:100050;left:50%;top:50%;transform:translate(-50%,-50%);width:min(860px,calc(100vw - 24px));height:min(560px,calc(100dvh - 24px));
  display:none;flex-direction:column;background:#121212;color:#d1d7e0;border:1px solid #363636;border-radius:10px;box-shadow:0 18px 60px rgba(0,0,0,.55);
  font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace}
#cws-console.open{display:flex}
#cws-console .cwsc-head{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-bottom:1px solid #363636;background:#1c1c1c;border-radius:10px 10px 0 0}
#cws-console .cwsc-title{font-weight:600;color:#f0f6fc;letter-spacing:.02em}
#cws-console .cwsc-x{background:none;border:0;color:#8b949e;font-size:22px;line-height:1;cursor:pointer;padding:0 4px}
#cws-console .cwsc-x:hover{color:#f0f6fc}
#cws-console .cwsc-out{flex:1;overflow:auto;padding:10px 12px;white-space:pre;overscroll-behavior:contain}
#cws-console .cwsc-line{min-height:1.45em}
#cws-console .cwsc-cmd{color:#7ee787}
#cws-console .cwsc-err{color:#ff7b72}
#cws-console .cwsc-dim{color:#8b949e}
#cws-console .cwsc-row{display:flex;align-items:center;gap:8px;padding:8px 12px;border-top:1px solid #363636;margin:0}
#cws-console .cwsc-ps{color:#7ee787}
#cws-console .cwsc-in{flex:1;min-width:0;background:transparent;border:0;outline:0;color:#f0f6fc;font:inherit;font-size:16px}
@media (min-width:700px){#cws-console .cwsc-in{font-size:13px}}
#cws-console.cwsc-busy .cwsc-ps{animation:cwscBlink .8s steps(2) infinite}
@keyframes cwscBlink{50%{opacity:0}}
@media (max-width:600px){#cws-console{top:auto;bottom:0;transform:translateX(-50%);width:100vw;height:70dvh;border-radius:12px 12px 0 0}#cws-console .cwsc-out{font-size:11.5px;padding:8px 10px}}
