/* ==========================================================================
   الشات العربي — chat application
   Palette: night #141631 · violet #5b4bff · rose #ff4f8b · mint #10b981
            gold #f5b100 · silver #94a3b8 · canvas #f4f5fb
   ========================================================================== */
:root {
    --ac-night: #141631;
    --ac-night-2: #1d2046;
    --ac-violet: #5b4bff;
    --ac-violet-2: #7c5cff;
    --ac-rose: #ff4f8b;
    --ac-mint: #10b981;
    --ac-gold: #f5b100;
    --ac-gold-ink: #8a5a00;
    --ac-silver: #94a3b8;
    --ac-ink: #171a35;
    --ac-text: #2b2f4a;
    --ac-muted: #6b7091;
    --ac-line: #e6e8f2;
    --ac-canvas: #f4f5fb;
    --ac-panel: #ffffff;
    --ac-soft: #f0efff;
    --ac-male: #2563eb;
    --ac-female: #db2777;
    --ac-radius: 14px;
    --ac-shadow: 0 10px 30px rgba(20, 22, 49, .12);
    --ac-font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body.ac-body-page { font-family: var(--ac-font); background: var(--ac-canvas); color: var(--ac-text); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--ac-violet); }
[hidden] { display: none !important; }

.ac { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); position: relative; overflow: hidden; width: 100%; contain: layout paint; }

/* ── Top bar ───────────────────────────────────────────────────────────── */
.ac-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--ac-night); color: #fff; box-shadow: 0 2px 14px rgba(0, 0, 0, .25); z-index: 30; }
.ac-logo { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.ac-logo-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--ac-violet), var(--ac-rose)); color: #fff; }
.ac-room-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding-inline-start: 14px; margin-inline-start: 6px; border-inline-start: 1px solid rgba(255, 255, 255, .12); }
.ac-room-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-room-count { font-size: .8rem; color: #a7f3d0; background: rgba(16, 185, 129, .16); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ac-room-count:empty { display: none; }
.ac-top-actions { display: flex; align-items: center; gap: 4px; }
.ac-icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: inherit; cursor: pointer; font-size: 1.15rem; transition: background .15s; }
.ac-icon-btn:hover { background: rgba(127, 127, 160, .14); }
.ac-badge { position: absolute; top: 3px; inset-inline-end: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ac-rose); color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }
.ac-me { border: 0; background: none; padding: 2px; cursor: pointer; border-radius: 50%; }
.ac-only-mobile { display: none; }

/* ── Avatars & badges ──────────────────────────────────────────────────── */
.ac-avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: #64748b; color: #fff; font-weight: 800; font-size: .95rem; position: relative; text-transform: uppercase; }
.ac-avatar.gold { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ac-gold); }
.ac-avatar.silver { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ac-silver); }
.ac-avatar .ac-dot { position: absolute; bottom: -1px; inset-inline-end: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ac-mint); border: 2px solid #fff; }
.ac-tier-badge { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: .7rem; font-weight: 900; color: #fff; flex: 0 0 18px; }
.ac-tier-badge.gold { background: linear-gradient(135deg, #ffd25a, #f0a400); color: #6b4300; box-shadow: 0 0 0 1px rgba(240, 164, 0, .35), 0 2px 6px rgba(240, 164, 0, .45); }
.ac-tier-badge.silver { background: linear-gradient(135deg, #e2e8f0, #94a3b8); color: #334155; }
.ac-flag { width: 18px; height: 13px; border-radius: 2px; object-fit: cover; flex: 0 0 18px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }
.ac-g { font-weight: 800; font-size: .85rem; }
.ac-g.m { color: var(--ac-male); }
.ac-g.f { color: var(--ac-female); }
.ac-name { font-weight: 800; cursor: pointer; border: 0; background: none; padding: 0; display: inline-flex; align-items: center; gap: 5px; }
.ac-name.m { color: var(--ac-male); }
.ac-name.f { color: var(--ac-female); }
.ac-name.gold { color: #b07800; text-shadow: 0 0 10px rgba(245, 177, 0, .25); }
.ac-name.automated, .ac-user-nick.automated, .ac-profile-name.automated { color: #7c3aed; text-shadow: none; }
.ac-avatar.automated { box-shadow: 0 0 0 2px #fff, 0 0 0 3px #c4b5fd; }
.ac-automated-badge { display: none; align-items: center; flex: 0 0 auto; border: 1px solid #c4b5fd; border-radius: 999px; background: #f5f3ff; color: #6d28d9; padding: 0 5px; font-size: .65rem; font-weight: 700; line-height: 1.6; white-space: nowrap; }
.ac-automated-notice { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; padding: 10px 12px; border-radius: 10px; font-size: .85rem; margin: 10px 0; }

/* ── Layout ────────────────────────────────────────────────────────────── */
.ac-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) 260px; min-height: 0; }
.ac-side { background: var(--ac-panel); border-inline-end: 1px solid var(--ac-line); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ac-users { border-inline-end: 0; border-inline-start: 1px solid var(--ac-line); }
.ac-side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.ac-side-head h2 { margin: 0; font-size: 1rem; color: var(--ac-ink); }
.ac-side-head h2 span { color: var(--ac-muted); font-weight: 500; font-size: .85rem; }
.ac-chip { border: 1px solid var(--ac-line); background: var(--ac-soft); color: var(--ac-violet); border-radius: 999px; padding: 4px 10px; font-size: .82rem; font-weight: 700; cursor: pointer; }
.ac-chip:hover { background: #e5e2ff; }

.ac-room-list { overflow-y: auto; padding: 4px 8px 8px; flex: 1; }
.ac-room-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 12px; background: none; cursor: pointer; text-align: start; color: var(--ac-text); text-decoration: none; }
.ac-room-item:hover { background: var(--ac-canvas); }
.ac-room-item.active { background: linear-gradient(135deg, rgba(91, 75, 255, .12), rgba(255, 79, 139, .1)); color: var(--ac-ink); }
.ac-room-item .ac-room-emoji { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--ac-canvas); font-size: 1.1rem; flex: 0 0 34px; }
.ac-room-item .ac-room-label { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-room-item .ac-room-online { font-size: .78rem; color: var(--ac-mint); font-weight: 700; }
.ac-my-rooms { padding: 0 8px 6px; border-top: 1px solid var(--ac-line); }
.ac-my-rooms h3 { font-size: .85rem; color: var(--ac-muted); margin: 10px 6px 4px; }
.ac-create-room { margin: 8px 12px; }
.ac-side-upgrade { margin: 4px 12px 14px; padding: 12px; border-radius: 14px; background: linear-gradient(135deg, var(--ac-night), #33215f); color: #fff; text-decoration: none; display: grid; gap: 2px; }
.ac-side-upgrade strong { color: #ffd25a; }
.ac-side-upgrade span { font-size: .8rem; opacity: .85; }

.ac-search { margin: 0 12px 8px; padding: 9px 12px; border: 1px solid var(--ac-line); border-radius: 12px; background: var(--ac-canvas); outline: none; }
.ac-search:focus { border-color: var(--ac-violet); background: #fff; }
.ac-user-list { overflow-y: auto; padding: 0 6px 12px; flex: 1; }
.ac-user-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; border: 0; border-radius: 12px; background: none; cursor: pointer; text-align: start; }
.ac-user-item:hover { background: var(--ac-canvas); }
.ac-user-item .ac-user-main { flex: 1; min-width: 0; display: grid; }
.ac-user-item .ac-user-top { display: flex; align-items: center; gap: 5px; min-width: 0; }
.ac-user-item .ac-user-nick { font-weight: 700; color: var(--ac-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-user-item .ac-user-sub { font-size: .75rem; color: var(--ac-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-user-item.me .ac-user-nick::after { content: ' (أنت)'; color: var(--ac-muted); font-weight: 500; font-size: .75rem; }
.ac-user-item.typing .ac-user-sub { color: var(--ac-violet); }
.ac-user-group { font-size: .72rem; color: var(--ac-muted); padding: 10px 10px 4px; font-weight: 700; }

/* ── Main stream ───────────────────────────────────────────────────────── */
.ac-main { position: relative; min-height: 0; min-width: 0; display: flex; flex-direction: column; background:
    radial-gradient(circle at 15% 0%, rgba(91, 75, 255, .06), transparent 40%),
    radial-gradient(circle at 90% 100%, rgba(255, 79, 139, .05), transparent 40%), var(--ac-canvas); }
.ac-stream { display: flex; flex-direction: column; min-height: 0; flex: 1; position: relative; }
.ac-messages { flex: 1; overflow-y: auto; padding: 14px 16px 6px; overscroll-behavior: contain; }
.ac-msg { display: flex; gap: 10px; padding: 6px 8px; border-radius: 12px; position: relative; }
.ac-msg:hover { background: rgba(255, 255, 255, .7); }
.ac-msg.mine { background: rgba(91, 75, 255, .06); }
.ac-msg.mention { background: rgba(245, 177, 0, .12); box-shadow: inset 3px 0 0 var(--ac-gold); }
.ac-msg-body { flex: 1; min-width: 0; }
.ac-msg-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ac-msg-time { font-size: .72rem; color: var(--ac-muted); }
.ac-msg-text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; line-height: 1.65; color: var(--ac-text); font-size: 1rem; }
.ac-msg-text .ac-at { color: var(--ac-violet); font-weight: 700; }
.ac-msg-text .ac-at.me { background: rgba(245, 177, 0, .25); color: #7a4d00; border-radius: 4px; padding: 0 3px; }
.ac-msg-quote { font-size: .82rem; color: var(--ac-muted); border-inline-start: 3px solid var(--ac-violet); padding: 2px 8px; margin: 2px 0 3px; background: rgba(91, 75, 255, .05); border-radius: 6px; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-msg-actions { position: absolute; top: 2px; inset-inline-end: 6px; display: none; gap: 2px; background: #fff; border: 1px solid var(--ac-line); border-radius: 10px; padding: 2px; box-shadow: 0 4px 14px rgba(0, 0, 0, .08); }
.ac-msg:hover .ac-msg-actions, .ac-msg.show-actions .ac-msg-actions { display: flex; }
.ac-msg-actions button { border: 0; background: none; cursor: pointer; padding: 3px 7px; border-radius: 8px; font-size: .8rem; color: var(--ac-muted); }
.ac-msg-actions button:hover { background: var(--ac-canvas); color: var(--ac-ink); }
.ac-sys { text-align: center; font-size: .78rem; color: var(--ac-muted); padding: 3px 0; }
.ac-sys b { color: var(--ac-text); font-weight: 700; }
.ac-sys.join b { color: var(--ac-mint); }
.ac-divider { display: flex; align-items: center; gap: 10px; color: var(--ac-muted); font-size: .75rem; margin: 8px 0; }
.ac-divider::before, .ac-divider::after { content: ''; flex: 1; height: 1px; background: var(--ac-line); }
.ac-audio { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.ac-audio audio { height: 36px; max-width: 260px; }
.ac-jump { position: absolute; bottom: 76px; inset-inline-start: 50%; transform: translateX(50%); border: 0; background: var(--ac-violet); color: #fff; padding: 6px 14px; border-radius: 999px; font-weight: 700; cursor: pointer; box-shadow: var(--ac-shadow); z-index: 4; }
.ac-typing { min-height: 22px; padding: 0 20px; font-size: .8rem; color: var(--ac-violet); }
.ac-typing .dots { display: inline-flex; gap: 3px; margin-inline-end: 6px; vertical-align: middle; }
.ac-typing .dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: acBlink 1.2s infinite; }
.ac-typing .dots i:nth-child(2) { animation-delay: .2s; }
.ac-typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes acBlink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.ac-reply-bar { display: flex; align-items: center; gap: 8px; margin: 0 14px; padding: 6px 12px; background: #fff; border: 1px solid var(--ac-line); border-bottom: 0; border-radius: 12px 12px 0 0; font-size: .85rem; color: var(--ac-muted); }
.ac-reply-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-reply-bar button { border: 0; background: none; cursor: pointer; color: var(--ac-muted); }
.ac-composer { display: flex; align-items: flex-end; gap: 6px; margin: 0 12px 12px; margin-bottom: max(12px, env(safe-area-inset-bottom)); padding: 6px; background: #fff; border: 1px solid var(--ac-line); border-radius: 18px; box-shadow: 0 6px 20px rgba(20, 22, 49, .06); }
.ac-composer:focus-within { border-color: rgba(91, 75, 255, .5); box-shadow: 0 0 0 4px rgba(91, 75, 255, .1); }
.ac-composer textarea { flex: 1; min-width: 0; width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 9px 6px; max-height: 120px; line-height: 1.5; font-size: 1rem; }
.ac-composer .ac-icon-btn { color: var(--ac-muted); width: 38px; height: 38px; }
.ac-mic.locked { opacity: .55; }
.ac-mic.recording { color: var(--ac-rose); }
.ac-send { display: inline-grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 14px; background: linear-gradient(135deg, var(--ac-violet), var(--ac-violet-2)); color: #fff; cursor: pointer; flex: 0 0 42px; }
.ac-send:disabled { opacity: .5; cursor: default; }
.ac-recorder { display: flex; align-items: center; gap: 10px; margin: 0 12px 12px; padding: 10px 14px; background: #fff; border-radius: 16px; border: 1px solid rgba(255, 79, 139, .4); }
.ac-recorder #acRecTime { flex: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.ac-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ac-rose); animation: acBlink 1s infinite; }
.ac-emoji-panel { position: absolute; bottom: 72px; inset-inline-start: 12px; width: min(340px, calc(100% - 24px)); display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; background: #fff; border: 1px solid var(--ac-line); border-radius: 16px; box-shadow: var(--ac-shadow); z-index: 6; max-height: 220px; overflow-y: auto; }
.ac-emoji-panel button { border: 0; background: none; font-size: 1.35rem; padding: 4px; border-radius: 8px; cursor: pointer; }
.ac-emoji-panel button:hover { background: var(--ac-canvas); }

/* ── Lobby ─────────────────────────────────────────────────────────────── */
.ac-lobby { flex: 1; overflow-y: auto; padding: 28px 18px; }
.ac-lobby-inner { max-width: 860px; margin: 0 auto; }
.ac-lobby h1 { margin: 0 0 6px; font-size: 1.6rem; color: var(--ac-ink); }
.ac-lobby p { margin: 0 0 18px; color: var(--ac-muted); }
.ac-lobby-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.ac-lobby-card { display: grid; gap: 6px; padding: 16px; border-radius: 18px; background: #fff; border: 1px solid var(--ac-line); cursor: pointer; text-align: start; transition: transform .15s, box-shadow .15s; }
.ac-lobby-card:hover { transform: translateY(-3px); box-shadow: var(--ac-shadow); }
.ac-lobby-card .em { font-size: 1.6rem; }
.ac-lobby-card strong { color: var(--ac-ink); font-size: 1.05rem; }
.ac-lobby-card small { color: var(--ac-muted); line-height: 1.5; }
.ac-lobby-card .on { color: var(--ac-mint); font-weight: 700; font-size: .85rem; }

/* ── DM panel ──────────────────────────────────────────────────────────── */
.ac-dm { position: fixed; top: 58px; bottom: 0; inset-inline-end: 0; width: min(400px, 100%); background: #fff; box-shadow: -10px 0 40px rgba(20, 22, 49, .18); z-index: 40; display: flex; flex-direction: column; }
html[dir="rtl"] .ac-dm { box-shadow: 10px 0 40px rgba(20, 22, 49, .18); }
.ac-dm-inbox, .ac-dm-conv { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.ac-dm-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--ac-line); }
.ac-dm-head h2 { flex: 1; margin: 0; font-size: 1.05rem; }
.ac-dm-head .ac-icon-btn { color: var(--ac-muted); }
.ac-dm-peer { flex: 1; display: flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; text-align: start; min-width: 0; }
.ac-dm-peer .meta { display: grid; min-width: 0; }
.ac-dm-peer .meta small { color: var(--ac-muted); font-size: .75rem; }
.ac-dm-list { overflow-y: auto; flex: 1; }
.ac-dm-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid #f1f2f8; background: none; cursor: pointer; text-align: start; }
.ac-dm-item:hover { background: var(--ac-canvas); }
.ac-dm-item.unread { background: rgba(91, 75, 255, .05); }
.ac-dm-item .meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ac-dm-item .meta span { color: var(--ac-muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-dm-item.unread .meta span { color: var(--ac-ink); font-weight: 700; }
.ac-dm-item .side { display: grid; justify-items: end; gap: 4px; font-size: .72rem; color: var(--ac-muted); }
.ac-dm-item .count { background: var(--ac-rose); color: #fff; border-radius: 9px; min-width: 18px; padding: 0 5px; text-align: center; font-weight: 700; }
.ac-dm-empty { padding: 30px 20px; text-align: center; color: var(--ac-muted); line-height: 1.8; }
.ac-dm-messages { flex: 1; overflow-y: auto; padding: 12px; background: var(--ac-canvas); display: flex; flex-direction: column; gap: 4px; }
.ac-bubble { max-width: 82%; padding: 7px 12px; border-radius: 16px; background: #fff; border: 1px solid var(--ac-line); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.ac-bubble.mine { align-self: flex-end; background: linear-gradient(135deg, var(--ac-violet), var(--ac-violet-2)); color: #fff; border: 0; }
.ac-bubble .t { display: block; font-size: .68rem; opacity: .65; margin-top: 2px; text-align: end; }
.ac-bubble audio { max-width: 220px; height: 34px; }
.ac-dm-locked { margin: 0 12px 10px; padding: 12px; border-radius: 14px; background: linear-gradient(135deg, #fff7e0, #fff); border: 1px solid #ffe08a; font-size: .9rem; line-height: 1.7; text-align: center; }
.ac-dm .ac-composer { margin: 8px 10px 10px; }

.ac-scrim { position: fixed; inset: 0; background: rgba(15, 17, 40, .45); z-index: 35; backdrop-filter: blur(2px); }

/* ── Modals & forms ────────────────────────────────────────────────────── */
.ac-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(15, 17, 40, .55); backdrop-filter: blur(4px); overflow-y: auto; }
.ac-card { position: relative; width: min(420px, 100%); background: #fff; border-radius: 22px; padding: 26px 22px 20px; box-shadow: 0 30px 80px rgba(10, 10, 40, .35); animation: acPop .18s ease-out; }
.ac-card-wide { width: min(720px, 100%); }
.ac-card h2 { margin: 0 0 6px; color: var(--ac-ink); font-size: 1.35rem; }
.ac-card-brand { display: flex; justify-content: center; margin-bottom: 8px; }
.ac-card-brand .ac-logo-mark { width: 52px; height: 52px; border-radius: 16px; }
#mJoin .ac-card h2, #mJoin .ac-card > .ac-muted { text-align: center; }
.ac-card-close { position: absolute; top: 10px; inset-inline-end: 10px; border: 0; background: var(--ac-canvas); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--ac-muted); }
@keyframes acPop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.ac-muted { color: var(--ac-muted); margin: 0 0 14px; line-height: 1.7; }
.ac-small { font-size: .82rem; }
.ac-form { display: grid; gap: 12px; }
.ac-form label { display: grid; gap: 5px; font-weight: 700; font-size: .88rem; color: var(--ac-ink); }
.ac-form input:not([type=radio]):not([type=checkbox]), .ac-form select, .ac-form textarea { width: 100%; padding: 11px 13px; border: 1.5px solid var(--ac-line); border-radius: 12px; background: var(--ac-canvas); outline: none; font-weight: 500; transition: border-color .15s, background .15s; }
.ac-form input:focus, .ac-form select:focus, .ac-form textarea:focus { border-color: var(--ac-violet); background: #fff; }
.ac-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ac-gender { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ac-gender label { display: block; cursor: pointer; }
.ac-gender input { position: absolute; opacity: 0; pointer-events: none; }
.ac-gender span { display: block; text-align: center; padding: 11px; border: 1.5px solid var(--ac-line); border-radius: 12px; font-weight: 800; background: var(--ac-canvas); transition: all .15s; }
.ac-gender label:first-child input:checked + span { border-color: var(--ac-male); color: var(--ac-male); background: #eef4ff; }
.ac-gender label:last-child input:checked + span { border-color: var(--ac-female); color: var(--ac-female); background: #fff0f6; }
.ac-gender input:focus-visible + span { outline: 3px solid rgba(91, 75, 255, .3); }
.ac-more summary { cursor: pointer; color: var(--ac-violet); font-weight: 700; font-size: .88rem; }
.ac-more[open] summary { margin-bottom: 8px; }
.ac-check { display: flex !important; grid-template-columns: none; align-items: flex-start; gap: 8px !important; font-weight: 500 !important; line-height: 1.6; }
.ac-check input { margin-top: 5px; width: 17px; height: 17px; accent-color: var(--ac-violet); flex: 0 0 auto; }
.ac-error { margin: 0; color: #dc2626; font-size: .88rem; font-weight: 700; min-height: 0; }
.ac-error:empty { display: none; }
.ac-switch { text-align: center; margin: 14px 0 0; font-size: .9rem; color: var(--ac-muted); }
.ac-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border: 0; border-radius: 12px; background: linear-gradient(135deg, var(--ac-violet), var(--ac-violet-2)); color: #fff; font-weight: 800; cursor: pointer; text-decoration: none; transition: transform .12s, box-shadow .12s, opacity .12s; }
.ac-btn:hover { box-shadow: 0 8px 22px rgba(91, 75, 255, .35); }
.ac-btn:active { transform: translateY(1px); }
.ac-btn:disabled { opacity: .6; cursor: default; }
.ac-btn-block { width: 100%; padding: 13px; font-size: 1.02rem; }
.ac-btn-gold { background: linear-gradient(135deg, #ffd25a, #f0a400); color: #4a2f00; }
.ac-btn-gold:hover { box-shadow: 0 8px 22px rgba(240, 164, 0, .35); }
.ac-btn-ghost { background: var(--ac-canvas); color: var(--ac-text); }
.ac-btn-ghost:hover { box-shadow: none; background: var(--ac-line); }
.ac-btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.ac-btn-outline { background: #fff; color: var(--ac-violet); border: 1.5px solid rgba(91, 75, 255, .35); }

.ac-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ac-plan { border: 1.5px solid var(--ac-line); border-radius: 18px; padding: 16px; display: grid; gap: 10px; align-content: start; }
.ac-plan-gold { border-color: #f6cf5c; background: linear-gradient(180deg, #fffaf0, #fff); }
.ac-plan-head { display: flex; align-items: center; gap: 8px; }
.ac-plan-head h3 { margin: 0; font-size: 1.15rem; }
.ac-plan-head .ac-tier-badge { width: 26px; height: 26px; font-size: .9rem; }
.ac-plan ul { margin: 0; padding-inline-start: 18px; line-height: 1.9; color: var(--ac-text); font-size: .92rem; }
.ac-plan-options { display: grid; gap: 8px; }
.ac-plan-option { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ac-plan-option .ac-btn { flex: 0 0 auto; padding: 9px 14px; }

.ac-card-profile { text-align: center; }
.ac-profile-avatar { width: 76px; height: 76px; font-size: 2rem; flex-basis: 76px; margin: 0 auto 8px; }
.ac-profile-name { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 1.3rem; font-weight: 800; color: var(--ac-ink); }
.ac-profile-meta { color: var(--ac-muted); margin: 4px 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 12px; font-size: .9rem; }
.ac-profile-status { background: var(--ac-canvas); border-radius: 12px; padding: 8px 12px; margin: 10px 0; color: var(--ac-text); }
.ac-profile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.ac-profile-actions .wide { grid-column: 1 / -1; }
.ac-me-actions { display: grid; gap: 8px; margin-top: 14px; }
.ac-me-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ac-me-head .info { display: grid; gap: 2px; }
.ac-me-head .info small { color: var(--ac-muted); }
.ac-tier-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: var(--ac-canvas); color: var(--ac-muted); }
.ac-tier-pill.gold { background: #fff4cc; color: #8a5a00; }
.ac-tier-pill.silver { background: #eef2f7; color: #475569; }

.ac-toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--ac-night); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 80; box-shadow: var(--ac-shadow); max-width: calc(100% - 32px); text-align: center; font-weight: 600; }
.ac-toast.err { background: #b91c1c; }
.ac-loader { position: fixed; inset: 0; display: none; place-items: center; grid-auto-flow: column; gap: 8px; align-content: center; justify-content: center; background: var(--ac-canvas); z-index: 50; }
.ac[data-state="loading"] .ac-loader { display: grid; }
.ac-loader span { width: 12px; height: 12px; border-radius: 50%; background: var(--ac-violet); animation: acBlink 1s infinite; }
.ac-loader span:nth-child(2) { animation-delay: .15s; background: var(--ac-rose); }
.ac-loader span:nth-child(3) { animation-delay: .3s; background: var(--ac-mint); }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .ac-layout { grid-template-columns: minmax(0, 1fr) 240px; }
    .ac-rooms { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(300px, 86vw); z-index: 45; transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--ac-shadow); }
    html[dir="ltr"] .ac-rooms { transform: translateX(-105%); }
    .ac-rooms.open { transform: none !important; }
    .ac-only-mobile#acRoomsToggle { display: inline-grid; }
}
@media (max-width: 760px) {
    .ac-layout { grid-template-columns: minmax(0, 1fr); }
    .ac-users { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(300px, 86vw); z-index: 45; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--ac-shadow); }
    html[dir="ltr"] .ac-users { transform: translateX(105%); }
    .ac-users.open { transform: none !important; }
    .ac-only-mobile { display: inline-grid; }
    .ac-logo-text { display: none; }
    .ac-room-title { padding-inline-start: 8px; margin-inline-start: 0; }
    .ac-messages { padding: 10px 8px 4px; }
    .ac-msg { padding: 5px 6px; gap: 8px; }
    .ac-avatar { width: 30px; height: 30px; flex-basis: 30px; font-size: .85rem; }
    .ac-dm { top: 0; width: 100%; z-index: 55; }
    .ac-plans { grid-template-columns: 1fr; }
    .ac-composer { margin: 0 8px 8px; }
    .ac-msg-actions { top: -10px; }
    .ac-side-head { padding-top: max(14px, env(safe-area-inset-top)); }
}
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Monochrome identity layer (black / white / gray + blue accent).
   Keeps the structure above and restyles the surface.
   ========================================================================== */
:root {
    --ac-night: #000;
    --ac-night-2: #111;
    --ac-violet: #0056b3;
    --ac-violet-2: #2563eb;
    --ac-rose: #e11d48;
    --ac-mint: #16a34a;
    --ac-gold: #d4a017;
    --ac-gold-ink: #7a5600;
    --ac-ink: #111;
    --ac-text: #1f2937;
    --ac-muted: #6b7280;
    --ac-line: #e5e7eb;
    --ac-canvas: #f9fafb;
    --ac-panel: #fff;
    --ac-soft: #f0f4ff;
    --ac-male: #2563eb;
    --ac-female: #db2777;
    --ac-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    --ac-font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    --ac-gold-grad: linear-gradient(135deg, #fde68a 0%, #eab308 50%, #b7791f 100%);
}
body.ac-body-page { background: var(--ac-canvas); }
a { color: var(--ac-violet); }

/* Top bar */
.ac-top { background: #000; border-bottom: 1px solid #1f1f1f; box-shadow: none; }
.ac-logo-mark { width: 34px; height: 34px; border-radius: 0; background: none; }
.ac-logo-text { font-weight: 800; font-size: 1.25rem; color: #fff; }
.ac-room-title { border-inline-start-color: #333; }
.ac-room-name { font-weight: 700; color: #fff; }
.ac-room-count { color: #bbf7d0; background: rgba(34, 197, 94, .16); }
.ac-top .ac-icon-btn { color: #e5e7eb; }
.ac-top .ac-icon-btn:hover { background: #1f1f1f; color: #fff; }
.ac-badge { background: var(--ac-violet-2); box-shadow: 0 0 0 2px #000; }

/* Tier badges */
.ac-tier-badge.gold { background: var(--ac-gold-grad); color: #3d2a00; box-shadow: 0 0 0 1.5px #fff; }
.ac-tier-badge.silver { background: linear-gradient(135deg, #f8fafc, #94a3b8); color: #111; box-shadow: 0 0 0 1.5px #fff; }
.ac-avatar.gold { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #eab308; }
.ac-avatar.silver { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #94a3b8; }
.ac-name.gold { color: #a16207; text-shadow: none; }

/* Side panels */
.ac-side { background: #fff; border-color: var(--ac-line); }
.ac-side-head h2, .ac-my-rooms h3, .ac-dm-head h2 { font-weight: 800; color: var(--ac-ink); }
.ac-chip { background: #fff; border-color: var(--ac-line); color: var(--ac-ink); font-weight: 700; }
.ac-chip:hover { background: var(--ac-ink); border-color: var(--ac-ink); color: #fff; }
.ac-room-item { border-radius: 10px; position: relative; transition: background .15s; }
.ac-room-item:hover { background: var(--ac-canvas); }
.ac-room-item.active { background: var(--ac-soft); box-shadow: inset -3px 0 0 var(--ac-violet-2); }
html[dir="ltr"] .ac-room-item.active { box-shadow: inset 3px 0 0 var(--ac-violet-2); }
.ac-room-item .ac-room-emoji { width: 38px; height: 38px; border-radius: 50%; background: #111; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--ac-line); font-size: 1rem; }
.ac-room-item .ac-room-emoji img { width: 22px; height: 16px; border-radius: 2px; }
.ac-room-item .ac-room-label { font-weight: 700; color: var(--ac-ink); }
.ac-room-item .ac-room-online { color: var(--ac-mint); }
.ac-create-room { font-weight: 700; border-radius: 10px; }
.ac-side-upgrade { background: #111; border: 0; border-radius: 14px; text-align: center; padding: 16px 12px 12px; position: relative; overflow: hidden; }
.ac-side-upgrade::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ac-violet-2); }
.ac-side-upgrade strong { color: #fff; font-size: 1.02rem; font-weight: 800; }
.ac-side-upgrade span { color: #d1d5db; }
.ac-search { background: var(--ac-canvas); border-color: var(--ac-line); border-radius: 10px; }
.ac-search:focus { border-color: var(--ac-ink); background: #fff; box-shadow: 0 0 0 3px rgba(17, 17, 17, .08); }
.ac-user-item { border-radius: 10px; }
.ac-user-item:hover { background: var(--ac-canvas); }
.ac-user-item .ac-user-nick { font-weight: 700; }
.ac-user-item.typing .ac-user-sub { color: var(--ac-violet); }

/* Stream */
.ac-main { background: var(--ac-canvas); }
.ac-msg { border-radius: 10px; }
.ac-msg:hover { background: #fff; }
.ac-msg.mine { background: var(--ac-soft); }
.ac-msg.mention { background: #fff7ed; box-shadow: inset -3px 0 0 #f97316; }
html[dir="ltr"] .ac-msg.mention { box-shadow: inset 3px 0 0 #f97316; }
.ac-msg-text .ac-at { color: var(--ac-violet); font-weight: 700; }
.ac-msg-text .ac-at.me { background: #dbeafe; color: #1e3a8a; }
.ac-msg-quote { border-inline-start-color: var(--ac-ink); background: #fff; }
.ac-sys.join b { color: var(--ac-mint); }
.ac-divider { color: var(--ac-muted); font-weight: 700; }
.ac-divider::before, .ac-divider::after { background: var(--ac-line); }
.ac-jump { background: #111; color: #fff; border: 0; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); }
.ac-typing { color: var(--ac-muted); }
.ac-composer { border-color: var(--ac-line); background: #fff; border-radius: 16px; box-shadow: 0 4px 14px rgba(0, 0, 0, .06); }
.ac-composer:focus-within { border-color: var(--ac-ink); box-shadow: 0 0 0 3px rgba(17, 17, 17, .08); }
.ac-send { background: #111; color: #fff; border-radius: 50%; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); transition: background .18s, transform .18s; }
.ac-send:hover { background: var(--ac-violet-2); transform: translateY(-1px); }
.ac-reply-bar { background: #fff; border-color: var(--ac-line); }
.ac-emoji-panel { background: #fff; border-color: var(--ac-line); }

/* Lobby: profile-style cards with sliding blue bar */
.ac-lobby h1 { font-weight: 800; color: var(--ac-ink); }
.ac-lobby-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.ac-lobby-card { justify-items: center; text-align: center; padding: 1.5rem 1rem 1.1rem; background: #fff; border: 0; border-radius: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, .06); position: relative; overflow: hidden; transition: transform .2s, box-shadow .2s; }
.ac-lobby-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ac-violet-2); transform: scaleX(0); transition: transform .3s ease; }
.ac-lobby-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.ac-lobby-card:hover::before { transform: scaleX(1); }
.ac-lobby-card .em { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: #111; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--ac-line), 0 6px 14px rgba(0, 0, 0, .12); }
.ac-lobby-card .em img { width: 34px !important; height: 24px !important; border-radius: 3px; }
.ac-lobby-card strong { font-weight: 700; color: #222; }
.ac-lobby-card small { color: var(--ac-violet); }
.ac-lobby-card .on { color: var(--ac-mint); }

/* DM */
.ac-dm { background: #fff; }
.ac-dm-head { border-bottom-color: var(--ac-line); background: #fff; }
.ac-dm-messages { background: var(--ac-canvas); }
.ac-bubble { background: #fff; border-color: var(--ac-line); }
.ac-bubble.mine { background: #111; color: #fff; border-color: #111; }
.ac-bubble.mine .t { color: #9ca3af; }
.ac-dm-item { border-bottom-color: #f3f4f6; }
.ac-dm-item:hover { background: var(--ac-canvas); }
.ac-dm-item.unread { background: var(--ac-soft); }
.ac-dm-locked { background: var(--ac-canvas); border-color: var(--ac-line); }

/* Modals */
.ac-modal { background: rgba(0, 0, 0, .6); }
.ac-card { background: #fff; border: 0; border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); position: relative; overflow: hidden; }
.ac-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ac-violet-2); }
.ac-card h2 { font-weight: 800; color: var(--ac-ink); }
.ac-card-brand { gap: 8px; }
.ac-card-brand img { width: 48px; height: 48px; }
.ac-card-brand span { font-weight: 800; font-size: 1.25rem; color: var(--ac-ink); }
.ac-form input:not([type=radio]):not([type=checkbox]), .ac-form select, .ac-form textarea { background: #fff; border-color: #d1d5db; border-radius: 10px; }
.ac-form input:focus, .ac-form select:focus, .ac-form textarea:focus { border-color: var(--ac-ink); background: #fff; box-shadow: 0 0 0 3px rgba(17, 17, 17, .08); }
.ac-gender span { border-radius: 10px; }
.ac-gender input:checked + span { background: #111; border-color: #111; color: #fff; }
.ac-check input { accent-color: #111; }
.ac-more summary { color: var(--ac-violet); }
.ac-btn { background: #111; color: #fff; border-radius: 30px; font-weight: 700; box-shadow: 0 4px 18px rgba(0, 0, 0, .18); transition: transform .18s, box-shadow .18s, background .18s; }
.ac-btn:hover { background: #000; transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0, 0, 0, .24); }
.ac-btn-gold { background: var(--ac-violet); color: #fff; box-shadow: 0 6px 20px rgba(0, 86, 179, .35); }
.ac-btn-gold:hover { background: var(--ac-violet-2); box-shadow: 0 10px 26px rgba(37, 99, 235, .4); }
.ac-btn-ghost { background: var(--ac-canvas); color: var(--ac-ink); box-shadow: none; border: 1px solid var(--ac-line); }
.ac-btn-ghost:hover { background: #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, .08); }
.ac-btn-outline { background: #fff; color: var(--ac-ink); border-color: var(--ac-ink); box-shadow: none; }
.ac-btn-outline:hover { background: #111; color: #fff; }
.ac-btn-danger { background: #dc2626; color: #fff; }
.ac-btn-danger:hover { background: #b91c1c; }
.ac-switch a, .ac-check a { color: var(--ac-violet); }
.ac-plan { border-color: var(--ac-line); background: #fff; border-radius: 14px; transition: transform .2s, box-shadow .2s; }
.ac-plan:hover { transform: translateY(-4px); box-shadow: 0 10px 26px rgba(0, 0, 0, .1); }
.ac-plan-gold { border: 2px solid #111; background: #fff; }
.ac-plan-head h3 { font-weight: 800; }
.ac-plan-head .ac-tier-badge { width: 26px; height: 26px; font-size: .8rem; }
.ac-tier-pill.gold { background: #fef3c7; color: #78350f; }
.ac-tier-pill.silver { background: #f1f5f9; color: #334155; }
.ac-profile-name { font-weight: 800; }
.ac-toast { background: #111; border: 0; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.ac-loader { background: var(--ac-canvas); }
.ac-loader span { background: #111; }
.ac-loader span:nth-child(2) { background: #6b7280; }
.ac-loader span:nth-child(3) { background: var(--ac-violet-2); }
@media (max-width: 760px) { .ac-logo-text { display: none; } }
.ac-room-item .ac-room-emoji img.ac-room-glyph { width: 24px; height: 24px; border-radius: 0; box-shadow: none; }
.ac-lobby-card .em img.ac-room-glyph { width: 38px !important; height: 38px !important; border-radius: 0; }
