/* ═══════════════════════════════════════════════════════════════════════════
   GamerZone · Design system
   A neon-gamer aesthetic: deep space backdrop, glassmorphism surfaces,
   luminous accents and buttery micro-interactions.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Backdrop */
  --bg-0: #07060f;
  --bg-1: #0c0a17;
  --bg-2: #12101f;
  --bg-3: #191627;
  --bg-4: #211d33;

  /* Glass */
  --glass: rgba(30, 26, 48, 0.55);
  --glass-strong: rgba(24, 20, 40, 0.82);
  --stroke: rgba(255, 255, 255, 0.06);
  --stroke-strong: rgba(255, 255, 255, 0.12);

  /* Text */
  --text: #ece9f7;
  --text-dim: #a29fc0;
  --text-faint: #6f6b8a;

  /* Accents */
  --violet: #7c5cff;
  --violet-2: #9b7bff;
  --cyan: #00e5ff;
  --magenta: #ff4ecd;
  --lime: #4effa1;
  --amber: #ffb24e;

  --accent: var(--violet);
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #b14eff 45%, #ff4ecd 100%);
  --cyan-grad: linear-gradient(135deg, #00e5ff, #7c5cff);

  /* Presence */
  --online: #3ddc84;
  --idle: #ffb24e;
  --dnd: #ff5470;
  --offline: #6b6880;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-glow: 0 0 0 1px rgba(124, 92, 255, 0.35), 0 8px 40px -8px rgba(124, 92, 255, 0.45);
  --shadow-soft: 0 12px 40px -12px rgba(0, 0, 0, 0.7);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Outfit', var(--font);

  --rail: 76px;
  --sidebar: 248px;
  --members: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
::selection { background: rgba(124, 92, 255, 0.4); }

/* Custom scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(124,92,255,0.4) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(124,92,255,0.35); border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,92,255,0.6); background-clip: padding-box; }

/* Animated aurora backdrop shared by auth + app */
.aurora {
  position: fixed; inset: 0; z-index: -2; overflow: hidden; background: var(--bg-0);
}
.aurora::before, .aurora::after {
  content: ''; position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%;
  filter: blur(90px); opacity: 0.45; will-change: transform;
}
.aurora::before { background: radial-gradient(circle, #7c5cff, transparent 60%); top: -20vmax; left: -10vmax; animation: drift1 26s ease-in-out infinite; }
.aurora::after { background: radial-gradient(circle, #00b3ff, transparent 60%); bottom: -25vmax; right: -10vmax; animation: drift2 32s ease-in-out infinite; }
.aurora span {
  position: absolute; width: 40vmax; height: 40vmax; border-radius: 50%;
  background: radial-gradient(circle, #ff4ecd, transparent 60%); filter: blur(100px); opacity: 0.3;
  top: 30%; left: 40%; animation: drift3 38s ease-in-out infinite;
}
@keyframes drift1 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(20vmax,10vmax) scale(1.2)} }
@keyframes drift2 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(-18vmax,-12vmax) scale(1.1)} }
@keyframes drift3 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(-15vmax,15vmax) scale(1.3)} }

.hidden { display: none !important; }

/* ─────────────────────────────────────────────────────────────────────────
   AUTH
   ───────────────────────────────────────────────────────────────────────── */
.auth-wrap {
  height: 100%; display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--stroke-strong);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-soft), 0 0 80px -30px rgba(124,92,255,0.6);
  animation: rise .6s cubic-bezier(.2,.9,.3,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
.brand {
  display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 6px;
}
.brand-logo {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-size: 26px; background: var(--accent-grad); box-shadow: 0 8px 24px -6px rgba(124,92,255,.7);
  animation: floaty 4s ease-in-out infinite;
}
@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }
.brand-name {
  font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -.02em;
  background: linear-gradient(90deg, #fff, #b9a8ff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-sub { text-align: center; color: var(--text-dim); margin: 4px 0 26px; font-size: 14px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.input {
  width: 100%; padding: 13px 15px; border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.35); border: 1px solid var(--stroke-strong); color: var(--text);
  font-size: 15px; transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(124,92,255,.18); background: rgba(0,0,0,0.5); }

.btn {
  width: 100%; padding: 13px 18px; border-radius: var(--radius-sm); font-weight: 700; font-size: 15px;
  background: var(--accent-grad); color: #fff; letter-spacing: .01em;
  box-shadow: 0 10px 30px -10px rgba(124,92,255,.8); transition: transform .12s, box-shadow .2s, filter .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 36px -10px rgba(124,92,255,.95); filter: brightness(1.06); }
.btn:active { transform: translateY(0) scale(.99); }
.btn.ghost { background: rgba(255,255,255,0.06); box-shadow: none; color: var(--text); }
.btn.ghost:hover { background: rgba(255,255,255,0.12); }
.btn.small { width: auto; padding: 9px 16px; font-size: 13px; }
.btn:disabled { opacity: .6; pointer-events: none; }

.auth-switch { text-align: center; margin-top: 22px; font-size: 14px; color: var(--text-dim); }
.auth-switch a { color: var(--violet-2); font-weight: 600; cursor: pointer; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.auth-error {
  background: rgba(255,84,112,0.12); border: 1px solid rgba(255,84,112,0.35); color: #ff97a8;
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px;
}

/* ─────────────────────────────────────────────────────────────────────────
   APP LAYOUT
   ───────────────────────────────────────────────────────────────────────── */
#app-root, #auth-root { height: 100%; }
.app { display: grid; grid-template-columns: var(--rail) var(--sidebar) 1fr; grid-template-rows: minmax(0, 1fr); height: 100%; min-height: 0; }
.app.with-members { grid-template-columns: var(--rail) var(--sidebar) 1fr var(--members); }
/* Grid/flex children must be allowed to shrink below content so the messages
   list scrolls instead of pushing the composer off-screen. */
.app > * { min-height: 0; }

/* Server rail ------------------------------------------------------------- */
.rail {
  background: rgba(7,6,15,0.6); backdrop-filter: blur(12px);
  border-right: 1px solid var(--stroke);
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0; overflow-y: auto;
}
.rail::-webkit-scrollbar { display: none; }
.rail-item {
  position: relative; width: 50px; height: 50px; border-radius: 16px; flex: none;
  display: grid; place-items: center; font-size: 22px; color: #fff; font-weight: 700;
  transition: border-radius .22s cubic-bezier(.2,.9,.3,1), transform .15s, box-shadow .2s;
  cursor: pointer; user-select: none;
}
.rail-item .pill {
  position: absolute; left: -14px; top: 50%; transform: translateY(-50%) scaleY(.3);
  width: 5px; height: 42px; border-radius: 0 6px 6px 0; background: #fff; opacity: 0; transition: .2s;
}
.rail-item:hover .pill { opacity: .6; transform: translateY(-50%) scaleY(.6); }
.rail-item.active .pill { opacity: 1; transform: translateY(-50%) scaleY(1); background: var(--accent-grad); }
.rail-item:hover { border-radius: 18px; transform: translateY(-1px); }
.rail-item.active { border-radius: 18px; box-shadow: var(--shadow-glow); }
.rail-item .tip {
  position: absolute; left: 62px; top: 50%; transform: translateY(-50%) translateX(-6px);
  background: #000; color: #fff; padding: 7px 11px; border-radius: 8px; font-size: 13px; font-weight: 600;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: .16s; z-index: 50;
  box-shadow: 0 8px 20px -6px rgba(0,0,0,.8);
}
.rail-item .tip::before { content:''; position:absolute; left:-5px; top:50%; transform:translateY(-50%); border:5px solid transparent; border-right-color:#000; }
.rail-item:hover .tip { opacity: 1; transform: translateY(-50%) translateX(0); }
.rail-sep { width: 34px; height: 2px; border-radius: 2px; background: var(--stroke-strong); flex: none; }
.rail-add {
  background: rgba(62,220,132,0.12); color: var(--lime); font-size: 26px; font-weight: 300;
  border: 1px dashed rgba(62,220,132,0.4);
}
.rail-add:hover { background: var(--lime); color: #05130b; border-style: solid; }
.rail-home { background: var(--accent-grad); }

/* Sidebar ----------------------------------------------------------------- */
.sidebar {
  background: var(--glass); backdrop-filter: blur(18px);
  border-right: 1px solid var(--stroke); display: flex; flex-direction: column; min-width: 0;
}
.sidebar-head {
  height: 54px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--stroke); font-weight: 700; font-family: var(--display); font-size: 15.5px;
  box-shadow: 0 1px 0 rgba(0,0,0,.3); cursor: pointer; flex: none;
}
.sidebar-head:hover { background: rgba(255,255,255,0.03); }
.sidebar-head .chev { color: var(--text-faint); font-size: 12px; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 14px 8px; }

.chan-group-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint);
}
.chan-group-label button { color: var(--text-faint); font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 5px; }
.chan-group-label button:hover { color: var(--text); }

.chan {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-dim); font-weight: 550; font-size: 14.5px; cursor: pointer; margin: 1px 0;
  transition: background .12s, color .12s; position: relative;
}
.chan .hash { color: var(--text-faint); font-size: 18px; font-weight: 400; }
.chan .cname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.chan.active { background: rgba(124,92,255,0.16); color: #fff; }
.chan.active .hash { color: var(--violet-2); }
.chan .chan-actions { display: none; gap: 2px; }
.chan:hover .chan-actions { display: flex; }
.chan .chan-actions button { color: var(--text-faint); font-size: 13px; padding: 2px 4px; border-radius: 5px; }
.chan .chan-actions button:hover { color: #fff; background: rgba(255,255,255,.1); }
.chan .unread { width: 8px; height: 8px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }

/* DM list item */
.dm-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; cursor: pointer; margin: 1px 0; }
.dm-item:hover { background: rgba(255,255,255,0.05); }
.dm-item.active { background: rgba(124,92,255,0.16); }
.dm-item .dm-name { font-weight: 600; font-size: 14.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* User bar (bottom of sidebar) */
.userbar {
  height: 60px; padding: 0 10px; display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,0.35); border-top: 1px solid var(--stroke); flex: none;
}
.userbar .u-meta { flex: 1; min-width: 0; }
.userbar .u-name { font-weight: 700; font-size: 14px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbar .u-status { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbar .u-btns { display: flex; gap: 4px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--text-dim);
  transition: background .12s, color .12s; font-size: 16px;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* Avatar ------------------------------------------------------------------ */
.avatar {
  position: relative; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-weight: 700; flex: none; overflow: visible; user-select: none;
}
.avatar .ava-inner { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; overflow: hidden; }
.avatar .presence {
  position: absolute; right: -2px; bottom: -2px; width: 32%; height: 32%; min-width: 10px; min-height: 10px;
  border-radius: 50%; border: 3px solid var(--bg-1); background: var(--offline);
}
.presence.online { background: var(--online); box-shadow: 0 0 8px rgba(61,220,132,.7); }
.presence.idle { background: var(--idle); }
.presence.dnd { background: var(--dnd); }
.presence.offline { background: var(--offline); }

/* Chat -------------------------------------------------------------------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: rgba(12,10,23,0.5); }
.chat-head {
  height: 54px; padding: 0 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--stroke); backdrop-filter: blur(10px); background: rgba(7,6,15,0.35); flex: none;
}
.chat-head .ch-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.chat-head .ch-title .hash { color: var(--text-faint); font-size: 22px; font-weight: 400; }
.chat-head .ch-topic { color: var(--text-dim); font-size: 13px; padding-left: 12px; border-left: 1px solid var(--stroke-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .spacer { flex: 1; }

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 4px 8px; display: flex; flex-direction: column; }
.messages-inner { margin-top: auto; }

.msg-welcome { padding: 30px 20px 24px; }
.msg-welcome .mw-icon { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-size: 38px; background: var(--accent-grad); box-shadow: var(--shadow-glow); margin-bottom: 16px; }
.msg-welcome h2 { font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.msg-welcome p { color: var(--text-dim); margin-top: 6px; font-size: 15px; }

.day-divider { display: flex; align-items: center; gap: 12px; margin: 18px 20px 10px; color: var(--text-faint); font-size: 11.5px; font-weight: 700; letter-spacing: .05em; }
.day-divider::before, .day-divider::after { content: ''; flex: 1; height: 1px; background: var(--stroke-strong); }

.msg {
  display: flex; gap: 14px; padding: 3px 20px; position: relative;
}
.msg:hover { background: rgba(255,255,255,0.028); }
.msg.grouped { padding-top: 1px; padding-bottom: 1px; }
.msg .msg-gutter { width: 44px; flex: none; display: flex; justify-content: center; }
.msg .msg-gutter .hover-time { display: none; font-size: 10.5px; color: var(--text-faint); align-self: center; }
.msg.grouped:hover .msg-gutter .hover-time { display: block; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 1px; }
.msg-author { font-weight: 700; font-size: 15px; color: #fff; cursor: pointer; }
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 11.5px; color: var(--text-faint); }
.msg-text { font-size: 15px; line-height: 1.5; color: #dfe; color: var(--text); word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-text .edited { font-size: 10.5px; color: var(--text-faint); margin-left: 4px; }
.msg-text a { color: var(--cyan); text-decoration: none; }
.msg-text a:hover { text-decoration: underline; }
.msg-text code { background: rgba(0,0,0,0.4); padding: 2px 6px; border-radius: 5px; font-family: ui-monospace, monospace; font-size: 13px; border: 1px solid var(--stroke); }
.msg-text .mention { background: rgba(124,92,255,0.22); color: var(--violet-2); padding: 0 4px; border-radius: 4px; font-weight: 600; }
.msg-text strong { font-weight: 700; }
.msg-text em { font-style: italic; }

.reply-ref { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); margin-bottom: 3px; padding-left: 4px; }
.reply-ref::before { content: ''; width: 22px; height: 10px; border-left: 2px solid var(--stroke-strong); border-top: 2px solid var(--stroke-strong); border-top-left-radius: 6px; margin-left: 8px; }
.reply-ref .r-author { font-weight: 600; color: var(--violet-2); }
.reply-ref .r-text { opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50ch; }

.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 10px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--stroke); font-size: 13px; cursor: pointer; transition: .12s;
}
.reaction:hover { border-color: var(--stroke-strong); }
.reaction.mine { background: rgba(124,92,255,0.2); border-color: rgba(124,92,255,0.5); }
.reaction .rc { font-weight: 700; color: var(--text-dim); font-size: 12px; }
.reaction.mine .rc { color: var(--violet-2); }

.msg-actions {
  position: absolute; top: -14px; right: 16px; display: none; gap: 2px; padding: 3px;
  background: var(--bg-3); border: 1px solid var(--stroke-strong); border-radius: 10px; box-shadow: var(--shadow-soft);
}
.msg:hover .msg-actions { display: flex; }
.msg-actions button { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: var(--text-dim); font-size: 15px; }
.msg-actions button:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* Composer ---------------------------------------------------------------- */
.composer-wrap { padding: 0 20px 22px; flex: none; }
.reply-bar {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; font-size: 13px; color: var(--text-dim);
  background: var(--bg-3); border: 1px solid var(--stroke); border-bottom: none; border-radius: 12px 12px 0 0;
}
.reply-bar b { color: var(--violet-2); }
.reply-bar .spacer { flex: 1; }
.reply-bar button { color: var(--text-faint); font-size: 16px; }
.reply-bar button:hover { color: #fff; }
.composer {
  display: flex; align-items: flex-end; gap: 10px; padding: 8px 8px 8px 16px;
  background: var(--bg-3); border: 1px solid var(--stroke-strong); border-radius: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.composer.replying { border-radius: 0 0 16px 16px; }
.composer:focus-within { border-color: rgba(124,92,255,0.5); box-shadow: 0 0 0 4px rgba(124,92,255,0.12); }
.composer textarea {
  flex: 1; background: none; border: none; resize: none; outline: none; color: var(--text);
  font-size: 15px; line-height: 1.5; max-height: 180px; padding: 8px 0;
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer .c-btns { display: flex; align-items: center; gap: 4px; }
.send-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px;
  background: var(--accent-grad); color: #fff; box-shadow: 0 6px 18px -6px rgba(124,92,255,.8);
  transition: transform .12s, filter .2s, opacity .2s;
}
.send-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.send-btn:disabled { opacity: .35; box-shadow: none; transform: none; }

.typing-row { height: 22px; padding: 0 22px; display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 12.5px; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--violet-2); animation: tdot 1.2s infinite; }
.typing-dots i:nth-child(2){ animation-delay: .2s; } .typing-dots i:nth-child(3){ animation-delay: .4s; }
@keyframes tdot { 0%,60%,100%{ transform: translateY(0); opacity:.4 } 30%{ transform: translateY(-4px); opacity:1 } }

/* Members ----------------------------------------------------------------- */
.members {
  background: var(--glass); backdrop-filter: blur(18px); border-left: 1px solid var(--stroke);
  overflow-y: auto; padding: 16px 12px;
}
.members h4 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin: 14px 8px 6px; font-weight: 700; }
.member {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; cursor: pointer; transition: background .12s;
}
.member:hover { background: rgba(255,255,255,0.05); }
.member.off { opacity: .45; }
.member .m-meta { min-width: 0; }
.member .m-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.member .m-crown { color: var(--amber); font-size: 11px; }
.member .m-status { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─────────────────────────────────────────────────────────────────────────
   MODALS + TOASTS + POPOVERS
   ───────────────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(3,2,10,0.66); backdrop-filter: blur(6px); animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(460px, 100%); background: var(--glass-strong); backdrop-filter: blur(30px) saturate(150%);
  border: 1px solid var(--stroke-strong); border-radius: var(--radius-lg); padding: 30px;
  box-shadow: var(--shadow-soft), 0 0 100px -40px rgba(124,92,255,.7); animation: rise .3s cubic-bezier(.2,.9,.3,1);
}
.modal h3 { font-family: var(--display); font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
.modal .m-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn { flex: 1; }
.close-x { position: absolute; }

.emoji-grid-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.emoji-grid-pick button { width: 42px; height: 42px; font-size: 22px; border-radius: 10px; transition: .12s; }
.emoji-grid-pick button:hover { background: rgba(255,255,255,.08); }
.emoji-grid-pick button.sel { background: rgba(124,92,255,.25); box-shadow: 0 0 0 2px var(--violet); }

.invite-box {
  display: flex; gap: 8px; align-items: center; background: rgba(0,0,0,0.4); border: 1px solid var(--stroke-strong);
  border-radius: 12px; padding: 6px 6px 6px 16px; margin-top: 8px;
}
.invite-box code { flex: 1; font-family: ui-monospace, monospace; font-size: 18px; letter-spacing: .12em; color: var(--cyan); }

/* Toasts */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; max-width: 360px; padding: 14px 16px; border-radius: 14px; display: flex; gap: 12px; align-items: center;
  background: var(--glass-strong); backdrop-filter: blur(20px); border: 1px solid var(--stroke-strong);
  box-shadow: var(--shadow-soft); animation: toastIn .35s cubic-bezier(.2,.9,.3,1);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut .3s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
.toast .t-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; background: var(--accent-grad); flex: none; }
.toast .t-body { min-width: 0; }
.toast .t-title { font-weight: 700; font-size: 14px; }
.toast .t-msg { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Emoji picker popover */
.emoji-pop {
  position: fixed; z-index: 150; width: 340px; height: 380px; background: var(--glass-strong); backdrop-filter: blur(28px);
  border: 1px solid var(--stroke-strong); border-radius: 16px; box-shadow: var(--shadow-soft); display: flex; flex-direction: column;
  animation: rise .18s; overflow: hidden;
}
.emoji-pop .ep-search { padding: 10px; border-bottom: 1px solid var(--stroke); }
.emoji-pop .ep-search input { width: 100%; padding: 9px 12px; border-radius: 9px; background: rgba(0,0,0,.4); border: 1px solid var(--stroke); color: var(--text); font-size: 14px; }
.emoji-pop .ep-search input:focus { outline: none; border-color: var(--violet); }
.emoji-pop .ep-grid { flex: 1; overflow-y: auto; padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-pop .ep-grid button { aspect-ratio: 1; font-size: 22px; border-radius: 8px; transition: .1s; }
.emoji-pop .ep-grid button:hover { background: rgba(255,255,255,.1); transform: scale(1.15); }
.emoji-pop .ep-cat { grid-column: 1/-1; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; padding: 8px 4px 2px; }

/* Context popover (profile card) */
.profile-pop {
  position: fixed; z-index: 150; width: 320px; background: var(--glass-strong); backdrop-filter: blur(28px);
  border: 1px solid var(--stroke-strong); border-radius: 18px; box-shadow: var(--shadow-soft); overflow: hidden; animation: rise .18s;
}
.profile-pop .pp-banner { height: 90px; }
.profile-pop .pp-body { padding: 0 18px 18px; margin-top: -34px; }
.profile-pop .pp-name { font-family: var(--display); font-size: 20px; font-weight: 800; margin-top: 10px; }
.profile-pop .pp-tag { color: var(--text-dim); font-size: 13px; }
.profile-pop .pp-card { background: rgba(0,0,0,.35); border-radius: 12px; padding: 12px 14px; margin-top: 12px; border: 1px solid var(--stroke); }
.profile-pop .pp-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; margin-bottom: 5px; }
.profile-pop .pp-bio { font-size: 13.5px; color: var(--text-dim); line-height: 1.45; white-space: pre-wrap; }

/* Home / friends view ----------------------------------------------------- */
.home { display: flex; flex-direction: column; min-width: 0; }
.home-head { height: 54px; padding: 0 20px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--stroke); flex: none; }
.home-head .hh-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.home-tabs { display: flex; gap: 4px; }
.home-tab { padding: 6px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-dim); }
.home-tab:hover { background: rgba(255,255,255,.05); color: var(--text); }
.home-tab.active { background: rgba(124,92,255,.18); color: #fff; }
.home-body { flex: 1; overflow-y: auto; padding: 24px 30px; }
.home-body h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 12px; font-weight: 700; }
.friend-row { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 14px; transition: background .12s; }
.friend-row:hover { background: rgba(255,255,255,.04); }
.friend-row .fr-meta { flex: 1; min-width: 0; }
.friend-row .fr-name { font-weight: 700; }
.friend-row .fr-sub { font-size: 13px; color: var(--text-dim); }
.friend-row .fr-actions { display: flex; gap: 8px; }
.empty-state { text-align: center; color: var(--text-faint); padding: 60px 20px; }
.empty-state .es-emoji { font-size: 54px; margin-bottom: 12px; }

.add-friend-box { display: flex; gap: 10px; margin-bottom: 24px; }
.add-friend-box .input { flex: 1; }

.section-card { background: rgba(0,0,0,.22); border: 1px solid var(--stroke); border-radius: 16px; padding: 8px; }

/* Mobile menu toggle */
.mobile-bar { display: none; }

/* ─────────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app, .app.with-members { grid-template-columns: 1fr; }
  .members { display: none; }
  .rail, .sidebar { position: fixed; top: 0; bottom: 0; z-index: 60; transition: transform .28s cubic-bezier(.2,.9,.3,1); }
  .rail { left: 0; transform: translateX(-100%); }
  .sidebar { left: var(--rail); width: var(--sidebar); transform: translateX(-140%); }
  body.nav-open .rail { transform: none; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content:''; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.5); }
  .mobile-bar { display: flex; }
  .chat-head, .home-head { padding-left: 14px; }
}
