/* ── Variables ── */
:root {
  --bg:        #f8fafc;
  --bg2:       #f1f5f9;
  --bg3:       #e2e8f0;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --text2:     #64748b;
  --accent:    #06b6d4;
  --accent2:   #3b82f6;
  --grad:       linear-gradient(135deg, #06b6d4, #3b82f6);
  --bubble-in:  #e2e8f0;
  --bubble-out: #3b82f6;
  --nav-bg:    #ffffff;
  --sheet-bg:  #ffffff;
  --danger:    #ef4444;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:        #0a0a0f;
    --bg2:       #111118;
    --bg3:       #1a1a2a;
    --surface:   #111118;
    --border:    #1e1b4b;
    --text:      #e2e8f0;
    --text2:     #94a3b8;
    --accent:    #7c3aed;
    --accent2:   #4f46e5;
    --grad:       linear-gradient(135deg, #7c3aed, #4f46e5);
    --bubble-in:  #1e1b4b;
    --bubble-out: #5b21b6;
    --nav-bg:    #0f0f1a;
    --sheet-bg:  #111118;
  }
}

html[data-theme="dark"] {
  --bg:        #0a0a0f;
  --bg2:       #111118;
  --bg3:       #1a1a2a;
  --surface:   #111118;
  --border:    #1e1b4b;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --accent:    #7c3aed;
  --accent2:   #4f46e5;
  --grad:       linear-gradient(135deg, #7c3aed, #4f46e5);
  --bubble-in:  #1e1b4b;
  --bubble-out: #5b21b6;
  --nav-bg:    #0f0f1a;
  --sheet-bg:  #111118;
}

html[data-theme="light"] {
  --bg:        #f8fafc;
  --bg2:       #f1f5f9;
  --bg3:       #e2e8f0;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --text2:     #64748b;
  --accent:    #06b6d4;
  --accent2:   #3b82f6;
  --grad:       linear-gradient(135deg, #06b6d4, #3b82f6);
  --bubble-in:  #e2e8f0;
  --bubble-out: #3b82f6;
  --nav-bg:    #ffffff;
  --sheet-bg:  #ffffff;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
button   { background: none; border: none; cursor: pointer; color: inherit; font: inherit; }
input    { border: none; outline: none; font: inherit; background: none; color: inherit; }
textarea { outline: none; font: inherit; }
a      { color: inherit; text-decoration: none; }

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Auth Screen ── */
#auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px; z-index: 100;
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 28px 28px;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
}
.auth-logo {
  text-align: center; margin-bottom: 28px;
}
.auth-mark {
  font-size: 44px; line-height: 1;
  background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px; display: block;
}
.auth-logo h1 {
  font-size: 26px; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: -0.5px;
}
.auth-logo p { color: var(--text2); font-size: 14px; margin-top: 4px; }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 7px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.auth-field-inner { position: relative; }
.auth-field input {
  width: 100%; padding: 13px 16px;
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 12px; font-size: 15px; color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.auth-field-inner input { padding-right: 48px; }
.auth-field input:focus { border-color: var(--accent); background: var(--bg); outline: none; }
.auth-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  padding: 6px; color: var(--text2); display: flex; align-items: center;
  transition: color 0.15s;
}
.auth-eye:hover { color: var(--accent); }
.auth-forgot { text-align: right; margin: -6px 0 14px; }
.auth-forgot a { color: var(--text2); font-size: 13px; cursor: pointer; transition: color 0.15s; }
.auth-forgot a:hover { color: var(--accent); }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 4px; min-height: 16px; }
.auth-success { color: #22c55e; font-size: 13px; margin-top: 4px; min-height: 16px; }
.auth-submit {
  width: 100%; padding: 14px;
  background: var(--grad); color: #fff;
  border-radius: 12px; font-size: 15px; font-weight: 700;
  margin-top: 8px; transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.2px;
}
.auth-submit:hover { opacity: 0.92; }
.auth-submit:active { transform: scale(0.98); }
.auth-submit:disabled { opacity: 0.5; cursor: default; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--text2); font-size: 14px; }
.auth-switch a { color: var(--accent); font-weight: 600; cursor: pointer; }

/* ── App Layout ── */
#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.tab-content {
  flex: 1; overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Bottom Nav ── */
#bottom-nav {
  display: flex;
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 0 10px; gap: 3px;
  color: var(--text2); font-size: 11px; font-weight: 500;
  transition: color 0.15s;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--accent); }

/* ── Section Headers ── */
.screen-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.screen-header h2 { font-size: 20px; font-weight: 700; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2); flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; }

/* ── Chat List ── */
#view-chats { position: relative; }
.chat-list { padding: 8px 0; }
.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer;
  transition: background 0.1s; border-radius: 0;
}
.chat-item:active { background: var(--bg2); }
.chat-item .av {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; color: #fff; flex-shrink: 0;
}
.chat-item .info { flex: 1; min-width: 0; }
.chat-item .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .preview { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-item .time { font-size: 11px; color: var(--text2); }
.chat-list-empty { text-align: center; padding: 60px 24px; color: var(--text2); }
.chat-list-empty p { font-size: 15px; }

/* ── FAB ── */
.fab {
  position: fixed; bottom: calc(68px + env(safe-area-inset-bottom, 0px)); right: 20px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--grad); color: #fff;
  font-size: 26px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3); z-index: 5;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.93); }

/* ── Panel (full-screen slide-in) ── */
.panel {
  position: fixed; inset: 0;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  z-index: 10;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel.open { transform: translateX(0); }

/* ── Chat Panel Header ── */
.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--bg); flex-shrink: 0;
  cursor: pointer;
}
.chat-header .back,
.group-info-header .back {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; flex-shrink: 0;
  transition: background 0.1s;
  position: relative;
}
.back-unread-dot {
  position: absolute; top: 1px; right: 1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--nav-bg);
  pointer-events: none;
}
.chat-header .back:active,
.group-info-header .back:active { background: var(--bg2); }
.chat-header .back svg,
.group-info-header .back svg { width: 22px; height: 22px; }
.chat-header .hav {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.chat-header .hinfo { flex: 1; min-width: 0; }
.chat-header .hname { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header .hstatus { font-size: 12px; color: var(--text2); }

/* ── Messages List ── */
.messages-list {
  flex: 1; overflow-y: auto; padding: 12px 0;
  display: flex; flex-direction: column;
}
.msg-date-divider {
  text-align: center; font-size: 11px; color: var(--text2);
  padding: 10px 0 4px; user-select: none;
  display: flex; align-items: center; gap: 8px;
}
.msg-date-divider::before, .msg-date-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.msg {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 2px 12px; max-width: 100%;
}
.msg.sent { flex-direction: row-reverse; }
.msg .msg-av {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff; flex-shrink: 0; margin-bottom: 2px;
}
.msg.sent .msg-av { display: none; }
.msg-body { display: flex; flex-direction: column; max-width: 72%; }
.msg.sent .msg-body { align-items: flex-end; }
.msg-sender { font-size: 11px; color: var(--text2); margin-bottom: 2px; padding-left: 2px; }
.msg.sent .msg-sender { display: none; }
.bubble {
  padding: 8px 12px; border-radius: 18px;
  font-size: 15px; line-height: 1.45; word-break: break-word;
  white-space: pre-wrap;
}
.msg.received .bubble {
  background: var(--bubble-in); color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg.sent .bubble {
  background: var(--bubble-out); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.system {
  justify-content: center; padding: 4px 16px;
}
.msg.system .bubble {
  background: transparent; color: var(--text2);
  font-size: 12px; padding: 2px 8px; border-radius: 0;
}

/* ── Composer ── */
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border); background: var(--bg);
  flex-shrink: 0;
}
.composer textarea {
  flex: 1; resize: none; overflow: hidden;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 10px 14px;
  font-size: 15px; line-height: 1.4; max-height: 120px;
  transition: border-color 0.15s;
  color: var(--text); -webkit-text-fill-color: var(--text);
}
.composer textarea:focus { border-color: var(--border); outline: none; }
.composer .send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity 0.15s;
}
.composer .send-btn:disabled { opacity: 0.4; }
.composer .send-btn svg { width: 18px; height: 18px; }

/* ── Friends Screen (legacy, kept for groups.js) ── */
.section-label {
  padding: 16px 16px 8px; font-size: 12px; font-weight: 700;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em;
}
.person-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.person-item .av {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff; flex-shrink: 0;
}
.person-item .pinfo { flex: 1; min-width: 0; }
.person-item .pname { font-weight: 600; font-size: 15px; }
.person-item .psub  { font-size: 13px; color: var(--text2); }
.person-item .pactions { display: flex; gap: 8px; }

/* ── Add Friend Sheet ── */
.af-header { padding: 8px 16px 0; }
.af-header h3 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.af-search-wrap {
  position: relative; padding: 0 16px 12px;
  position: sticky; top: 0; background: var(--sheet-bg); z-index: 1;
}
.af-search-icon {
  position: absolute; left: 28px; top: 50%; transform: translateY(-50%);
  color: var(--text2); pointer-events: none;
}
.af-search-icon svg { width: 16px; height: 16px; display: block; }
.af-search-input {
  width: 100%; padding: 11px 14px 11px 38px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; font-size: 15px; color: var(--text);
  -webkit-text-fill-color: var(--text);
}
.af-search-input:focus { border-color: var(--accent); }
.af-section-label {
  padding: 12px 16px 6px; font-size: 11px; font-weight: 700;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.07em;
}
.af-person {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; transition: background 0.1s;
}
.af-person:active { background: var(--bg2); }
.af-person .av {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff; flex-shrink: 0;
}
.af-person-info { flex: 1; min-width: 0; }
.af-person-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.af-person-sub  { font-size: 13px; color: var(--text2); margin-top: 1px; }
.af-person-actions { display: flex; gap: 6px; flex-shrink: 0; }
.af-btn {
  padding: 7px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 600; transition: opacity 0.15s;
  white-space: nowrap;
}
.af-btn:active { opacity: 0.75; }
.af-btn:disabled { opacity: 0.4; }
.af-btn-primary { background: var(--grad); color: #fff; }
.af-btn-accept  { background: var(--accent); color: #fff; }
.af-btn-ghost   { background: var(--bg2); color: var(--text); border: 1px solid var(--border); }
.af-empty { padding: 20px 16px; color: var(--text2); font-size: 14px; }
.no-results { text-align: center; padding: 24px; color: var(--text2); font-size: 14px; }

/* ── Profile / Settings Screen ── */
.profile-view { display: flex; flex-direction: column; padding-bottom: 16px; }
.profile-av {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 30px; color: #fff;
}
.settings-hero {
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 24px 20px; gap: 2px;
}
.settings-av-wrap {
  position: relative; width: 96px; height: 96px;
  cursor: pointer; margin-bottom: 12px;
}
.settings-av-wrap .profile-av { width: 96px; height: 96px; font-size: 34px; }
.settings-av-badge {
  position: absolute; bottom: 1px; right: 1px;
  width: 28px; height: 28px; background: var(--accent);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 2.5px solid var(--bg);
}
.settings-av-badge svg { width: 13px; height: 13px; stroke: #fff; fill: none; }
.settings-name { font-size: 21px; font-weight: 700; margin-top: 2px; }
.settings-username { font-size: 14px; color: var(--text2); }
.settings-group {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; margin: 0 16px 12px; overflow: hidden;
}
.settings-group-premium {
  border-color: rgba(124,58,237,.35);
  background: linear-gradient(135deg, rgba(124,58,237,.06), rgba(59,130,246,.06));
}
.grad-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.grad-swatch {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: transform 0.15s, border-color 0.15s; flex-shrink: 0;
}
.grad-swatch:active { transform: scale(0.88); }
.grad-swatch-active { border-color: var(--text) !important; transform: scale(1.1); }
.grad-preview { min-height: 22px; }
.settings-group-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text2); padding: 12px 16px 4px;
}
.settings-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-top: 1px solid var(--border);
}
.settings-row-body { flex: 1; min-width: 0; }
.settings-row-label { font-size: 11px; color: var(--text2); margin-bottom: 1px; font-weight: 500; }
.settings-input {
  background: transparent; border: none; color: var(--text);
  font-size: 15px; width: 100%; padding: 0; outline: none;
}
.settings-row-toggle { justify-content: flex-start; }
.settings-toggle-label { flex: 1; font-size: 15px; }
.settings-group-btn { margin: 8px 16px 12px; width: calc(100% - 32px); }
.settings-group-err { padding: 0 16px; }
.settings-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.settings-icon svg { width: 17px; height: 17px; }
.si-purple { background: rgba(139,92,246,.15); color: #8b5cf6; }
.si-blue   { background: rgba(59,130,246,.15);  color: #3b82f6; }
.si-sky    { background: rgba(14,165,233,.15);  color: #0ea5e9; }
.si-teal   { background: rgba(20,184,166,.15);  color: #14b8a6; }
.si-orange { background: rgba(249,115,22,.15);  color: #f97316; }
.si-red    { background: rgba(239,68,68,.15);   color: #ef4444; }
.si-amber  { background: rgba(245,158,11,.15);  color: #d97706; }
.si-green  { background: rgba(34,197,94,.15);   color: #22c55e; }

/* ── Theme segmented control ── */
.theme-seg {
  display: flex; gap: 3px;
  background: var(--bg3); border-radius: 9px; padding: 3px;
}
.theme-seg-btn {
  flex: 1; padding: 5px 0; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--text2);
  transition: background 0.15s, color 0.15s;
}
.theme-seg-btn.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* ── VIP gradient name ── */
.name-vip {
  background: linear-gradient(90deg, #7c3aed, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}
.name-mark {
  position: relative; display: inline-block;
  margin-left: 3px; cursor: default; vertical-align: baseline;
  font-weight: 700; font-style: normal; line-height: 1;
}
.name-mark-tip {
  position: absolute; bottom: calc(100% + 5px); left: 50%;
  transform: translateX(-50%) scale(.9);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px 9px;
  font-size: 12px; font-weight: 800;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .15s, transform .15s;
  z-index: 200; box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.name-mark:hover .name-mark-tip,
.name-mark:focus .name-mark-tip {
  opacity: 1; transform: translateX(-50%) scale(1);
}
.name-mark:focus { outline: none; }

/* ── Buttons ── */
.btn {
  padding: 10px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; transition: opacity 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:active { opacity: 0.75; }
.btn-primary { background: var(--grad); color: #fff; }
.btn-ghost {
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary { background: var(--bg2); color: var(--text2); }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-full { width: 100%; justify-content: center; padding: 13px; }

/* Confirm dialog */
#prism-confirm { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.confirm-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.confirm-card { position: relative; background: var(--sheet-bg); border-radius: 18px; padding: 24px 20px 18px; max-width: 310px; width: 90%; text-align: center; }
.confirm-msg { color: var(--text1); font-size: 15px; font-weight: 500; margin-bottom: 18px; line-height: 1.4; }
.confirm-btns { display: flex; gap: 8px; justify-content: center; }
.confirm-btns .btn { flex: 1; }

/* ── Bottom Sheets ── */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 19;
}
.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--sheet-bg);
  border-radius: 20px 20px 0 0;
  padding: 8px 0 calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  z-index: 20; max-height: 80vh; overflow-y: auto;
}
.bottom-sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 0 auto 16px;
}
.bottom-sheet h3 { padding: 0 20px 12px; font-size: 16px; font-weight: 700; }
.sheet-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; width: 100%; font-size: 16px;
  transition: background 0.1s; text-align: left;
}
.sheet-btn:active { background: var(--bg2); }
.sheet-btn svg { width: 22px; height: 22px; color: var(--accent); }

/* ── Group Info Panel ── */
.group-info-header {
  padding: 20px 16px 16px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.group-info-av {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.group-info-name { font-size: 18px; font-weight: 700; flex: 1; }
.group-info-count { font-size: 13px; color: var(--text2); }
.group-info-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.member-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
}
.member-item .av {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.member-item .minfo { flex: 1; }
.member-item .mname { font-weight: 600; font-size: 14px; }
.member-item .mrole { font-size: 12px; color: var(--accent); }
.group-info-footer { padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

/* ── Toast ── */
#toast-container {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 99;
  pointer-events: none;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 10px 20px; border-radius: 20px; font-size: 14px; font-weight: 500;
  animation: toastIn 0.2s ease, toastOut 0.3s ease 2.5s forwards;
  white-space: nowrap; pointer-events: auto; cursor: pointer;
}

/* ── Chat notification toasts (top-right) ── */
#notif-container {
  position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  z-index: 200; width: 300px; max-width: calc(100vw - 28px); pointer-events: none;
}
.toast-chat {
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; width: 100%;
  cursor: pointer; pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.22);
  animation: notifIn 0.28s cubic-bezier(0.34,1.4,0.64,1), notifOut 0.25s ease 4.2s forwards;
}
.toast-chat:active { opacity: 0.75; }
.toast-body { flex: 1; min-width: 0; }
.toast-from { font-size: 13px; font-weight: 700; margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-group { font-weight: 400; color: var(--text2); }
.toast-preview { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes toastIn  { from { opacity:0; transform:translateY(8px) } to { opacity:1; transform:translateY(0) } }
@keyframes toastOut { to   { opacity:0; transform:translateY(-8px) } }
@keyframes notifIn  { from { opacity:0; transform:translateX(24px) } to { opacity:1; transform:translateX(0) } }
@keyframes notifOut { to   { opacity:0; transform:translateX(12px) } }

/* ── Typing dots in chat list ── */
.preview-typing { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); font-size: 12px; }
.td {
  display: inline-block; width: 3px; height: 3px;
  background: var(--accent); border-radius: 50%;
  animation: tdBounce 1.1s infinite ease-in-out;
}
.td:nth-child(2) { animation-delay: 0.18s; }
.td:nth-child(3) { animation-delay: 0.36s; }
@keyframes tdBounce { 0%,60%,100% { transform:scale(0.7); opacity:0.5 } 30% { transform:scale(1.2); opacity:1 } }

/* ── Typing Indicator ── */
.typing-indicator {
  padding: 4px 16px;
  font-size: 12px; color: var(--text2);
  min-height: 20px;
}

/* ── Context Menu ── */
.ctx-menu {
  position: fixed; z-index: 1000;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  min-width: 180px;
}
.ctx-menu.hidden { display: none; }
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background 0.1s;
}
.ctx-item:hover { background: var(--bg2); }
.ctx-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.ctx-item.danger { color: var(--danger); }

/* ── Avatar Image ── */
.av-img { object-fit: cover; width: 100%; height: 100%; border-radius: 50%; }

/* ── Link Previews ── */
.msg-link { color: var(--accent); text-decoration: underline; word-break: break-all; }
.link-preview {
  display: block; text-decoration: none; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; margin-top: 6px;
  max-width: 260px; transition: opacity 0.15s;
}
.link-preview:active { opacity: 0.75; }
.lp-img { width: 100%; height: 130px; object-fit: cover; display: block; }
.lp-body { padding: 8px 10px; }
.lp-domain { font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; margin-bottom: 3px; }
.lp-title { font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 2px; }
.lp-desc { font-size: 12px; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }

/* ── Reaction who-reacted tooltip ── */
.reaction-tooltip {
  position: fixed; z-index: 200;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  pointer-events: none; max-width: 220px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Saved message indicator ── */
.bubble.msg-saved::after {
  content: '🔖';
  font-size: 10px;
  position: absolute;
  top: 4px; right: 4px;
  opacity: 0.6;
  pointer-events: none;
}
.bubble { position: relative; }

/* ── Drag & Drop ── */
#chat-screen.drag-over::after {
  content: 'Drop image to send';
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: grid; place-items: center;
  color: #fff; font-size: 22px; font-weight: 700;
  letter-spacing: 0.01em; z-index: 100; pointer-events: none;
}

/* ── Privacy Toggle ── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0;
}
.toggle-row span { font-size: 14px; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 24px; transition: 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Pin Badge ── */
.pin-badge {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}

/* ── Unread Badge ── */
.unread-badge {
  min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px; flex-shrink: 0;
}
.chat-item.unread .preview { color: var(--text); font-weight: 500; }
.unread-name { font-weight: 700 !important; }

/* ── Nav Unread Dot ── */
.nav-unread-dot {
  position: absolute; top: 6px; right: calc(50% - 14px);
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--nav-bg);
}

/* ── Map Tab ── */
#view-map {
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.map-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0; z-index: 1;
}
.map-header h2 { font-size: 20px; font-weight: 700; }
#map-container {
  flex: 1;
  min-height: 0;
  background: var(--bg2);
}
.map-loading {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text2); font-size: 14px;
}
.map-sharing-badge {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; color: var(--text2);
  padding: 4px 10px; border-radius: 20px;
  background: var(--bg2); border: 1px solid var(--border);
}
.map-sharing-badge.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.map-marker {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  overflow: hidden; cursor: pointer;
}
.map-marker-me {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent), 0 2px 8px rgba(0,0,0,0.35);
}
.map-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text2); gap: 10px; padding: 32px;
}
.map-empty svg { width: 48px; height: 48px; opacity: 0.4; }
.map-empty p { font-size: 14px; text-align: center; line-height: 1.5; }

/* ── Context menu profile card ── */
.ctx-profile {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.ctx-profile .av {
  flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; overflow: hidden;
}
.ctx-profile-info { flex: 1; min-width: 0; }
.ctx-profile-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-profile-sub  { font-size: 12px; color: var(--text2); margin-top: 1px; }

/* ── Friend request dot ── */
.friend-req-dot {
  position: absolute; top: 4px; right: 4px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg);
  pointer-events: none;
}

/* ── Read Receipts ── */
.read-receipt {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 4px; padding: 2px 14px 1px;
  font-size: 11px; color: var(--text2);
}
.read-receipt .av {
  width: 14px !important; height: 14px !important;
  font-size: 6px !important;
}
.rr-stack { display: flex; cursor: pointer; }
.rr-stack .av { margin-left: -3px; border: 1.5px solid var(--bg); }
.rr-stack .av:first-child { margin-left: 0; }
.rr-extra { font-size: 9px; color: var(--text2); display: flex; align-items: center; margin-left: 3px; }
.rr-everyone { font-size: 11px; color: var(--text2); font-style: italic; }

/* ── Group avatar edit ── */
.group-info-av-wrap {
  position: relative; cursor: pointer; flex-shrink: 0;
  width: 52px; height: 52px;
}
.group-info-av-wrap .group-info-av { margin: 0; }
.group-av-edit {
  position: absolute; bottom: 0; right: -2px;
  width: 20px; height: 20px; background: var(--accent);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.group-av-edit svg { width: 10px; height: 10px; stroke: #fff; }

/* ── Consecutive message grouping ── */
.msg.msg-cont { padding-top: 1px; }
.msg-av-spacer { width: 24px; height: 1px; flex-shrink: 0; }

/* ── Message reactions ── */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction-pill {
  display: flex; align-items: center; gap: 3px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 2px 8px;
  font-size: 13px; cursor: pointer;
  transition: background 0.12s;
  line-height: 1.4;
}
.reaction-pill:active { opacity: 0.7; }
.reaction-pill.mine {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: var(--accent);
}

/* ── Message reply quote ── */
.msg-quoted {
  border-left: 2px solid var(--accent);
  padding: 4px 8px; margin-bottom: 5px;
  background: rgba(0,0,0,0.05); border-radius: 0 6px 6px 0;
  cursor: pointer; opacity: 0.75;
}
@media (prefers-color-scheme: dark) {
  .msg-quoted { background: rgba(255,255,255,0.06); }
}
.quoted-sender { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 1px; }
.quoted-content { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }

/* ── Deleted bubble ── */
.bubble-deleted { opacity: 0.55; font-style: italic; }

/* ── Reply preview (above composer) ── */
.reply-preview-wrap {
  display: flex; align-items: stretch; gap: 10px;
  padding: 8px 12px 6px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.reply-preview-bar { width: 3px; border-radius: 2px; background: var(--accent); flex-shrink: 0; }
.reply-preview-info { flex: 1; min-width: 0; }
.reply-preview-sender { font-size: 12px; font-weight: 700; color: var(--accent); }
.reply-preview-text { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-preview-close { color: var(--text2); font-size: 18px; line-height: 1; align-self: center; padding: 4px; }

/* ── Message context menu emoji bar ── */
.ctx-emoji-bar {
  display: flex; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.ctx-emoji-btn {
  font-size: 22px; padding: 4px 5px; border-radius: 8px;
  transition: background 0.1s; line-height: 1;
}
.ctx-emoji-btn:active { background: var(--bg2); }

/* ── SW update banner ── */
.update-banner {
  position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  padding: 10px 16px; border-radius: 24px;
  display: flex; align-items: center; gap: 12px;
  z-index: 1500; box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  animation: banner-in 0.3s ease;
}
.update-banner.hidden { display: none; }
.update-banner button {
  background: rgba(255,255,255,0.25); color: #fff;
  padding: 5px 14px; border-radius: 14px;
  font-size: 13px; font-weight: 700;
}
@keyframes banner-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Admin role badge ── */
.role-badge {
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  padding: 1px 6px; border-radius: 8px; margin-right: 4px;
}

/* ── Message highlight (scroll-to) ── */
.msg-highlight { animation: msg-flash 1.4s ease; }
@keyframes msg-flash {
  0%, 100% { background: transparent; }
  20%       { background: color-mix(in srgb, var(--accent) 18%, transparent); }
}

/* ── Media upload button ── */
.media-btn {
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  color: var(--text2); transition: background 0.1s; flex-shrink: 0;
}
.media-btn:hover { background: var(--bg2); }
.media-btn svg { width: 20px; height: 20px; }

/* ── Image message bubble ── */
.bubble-img { padding: 3px !important; background: transparent !important; box-shadow: none !important; }
.msg-image {
  max-width: 240px; max-height: 300px; border-radius: 14px;
  display: block; cursor: zoom-in; object-fit: cover;
}
.msg.received .bubble-img .msg-image { border-bottom-left-radius: 4px; }
.msg.sent     .bubble-img .msg-image { border-bottom-right-radius: 4px; }

/* ── Lightbox ── */
.img-viewer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; cursor: zoom-out;
}
.img-viewer-img {
  max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 8px;
  cursor: default; pointer-events: none;
}
.img-viewer-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.15); color: #fff;
  border-radius: 50%; width: 36px; height: 36px;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ── PWA Install Prompt ── */
.install-prompt {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1900;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 40px rgba(0,0,0,0.25);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
}
.install-prompt.visible { transform: translateY(0); }

.install-prompt-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.install-prompt-icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.install-prompt-titles { flex: 1; min-width: 0; }
.install-prompt-title { font-size: 16px; font-weight: 700; }
.install-prompt-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }
.install-prompt-close {
  color: var(--text2); font-size: 18px; padding: 6px 8px;
  border-radius: 50%; line-height: 1; flex-shrink: 0;
  transition: background 0.1s;
}
.install-prompt-close:active { background: var(--bg2); }

.install-steps {
  list-style: none; margin: 0; padding: 0;
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
}
.install-steps li {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; font-size: 14px; line-height: 1.4;
  border-bottom: 1px solid var(--border);
  counter-increment: step;
}
.install-steps li:last-child { border-bottom: none; }
.install-steps li::before {
  content: counter(step);
  counter-increment: none;
  min-width: 26px; height: 26px;
  background: var(--grad); color: #fff;
  border-radius: 50%; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.install-steps { counter-reset: step; }

.install-prompt-btn {
  width: 100%; background: var(--grad); color: #fff;
  padding: 15px; border-radius: 14px;
  font-size: 16px; font-weight: 700; letter-spacing: 0.01em;
  box-shadow: 0 4px 16px rgba(124,58,237,0.35);
}

/* ── Admin Panel ── */
.admin-panel {
  position: fixed; inset: 0; z-index: 80;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
}
.admin-panel.open { transform: translateX(0); }
.admin-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.admin-header .back {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); background: none; position: relative;
  transition: background 0.1s;
}
.admin-header .back:active { background: var(--bg2); }
.admin-header .back svg { width: 22px; height: 22px; }
.admin-title { font-size: 17px; font-weight: 700; flex: 1; }
.admin-search-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.admin-search-wrap svg { width: 17px; height: 17px; color: var(--text2); flex-shrink: 0; }
.admin-search-input {
  flex: 1; font-size: 15px; background: none;
  color: var(--text); border: none; outline: none;
}
.admin-loading { padding: 32px; text-align: center; color: var(--text2); font-size: 15px; }
.admin-user-list { flex: 1; overflow-y: auto; }
.admin-user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.admin-user-row:active { background: var(--bg2); }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.admin-user-meta { font-size: 12px; color: var(--text2); margin-top: 2px; }
.admin-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 100px;
}
.ab-admin    { background: rgba(139,92,246,.15); color: #8b5cf6; }
.ab-premium  { background: rgba(124,58,237,.15); color: #7c3aed; }
.ab-suspended{ background: rgba(245,158,11,.15);  color: #f59e0b; }
.ab-banned   { background: rgba(239,68,68,.15);   color: #ef4444; }

/* Admin user detail */
.admin-detail-scroll { flex: 1; overflow-y: auto; padding-bottom: 40px; }
.admin-detail-hero {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px 16px; border-bottom: 1px solid var(--border);
}
.admin-detail-name { font-size: 20px; font-weight: 700; margin-top: 10px; }
.admin-detail-un { font-size: 14px; color: var(--text2); margin-top: 2px; }
.admin-section {
  padding: 16px 16px 4px;
  border-bottom: 1px solid var(--border);
}
.admin-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text2); margin-bottom: 10px;
}
.admin-field { margin-bottom: 10px; }
.admin-field label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; font-weight: 500; }
.admin-field input {
  width: 100%; padding: 9px 12px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; color: var(--text); outline: none;
  transition: border-color 0.15s;
}
.admin-field input:focus { border-color: var(--accent); }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 8px; }
.admin-action-btn {
  flex: 1; min-width: 80px; padding: 9px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 600; text-align: center;
  transition: opacity 0.15s;
}
.admin-action-btn:active { opacity: 0.75; }
.aab-warn         { background: rgba(245,158,11,.12); color: #f59e0b; }
.aab-warn-active  { background: rgba(245,158,11,.25); color: #f59e0b; }
.aab-danger       { background: rgba(239,68,68,.12);  color: #ef4444; }
.aab-danger-active{ background: rgba(239,68,68,.25);  color: #ef4444; }
.aab-primary      { background: rgba(124,58,237,.12); color: var(--accent); }
.aab-primary-active{background: rgba(124,58,237,.25); color: var(--accent); }
.aab-premium      { background: rgba(124,58,237,.12); color: #7c3aed; }
.aab-premium-active{ background: linear-gradient(135deg,#7c3aed,#6366f1,#3b82f6); color: #fff; }
.admin-friends-list { display: flex; flex-direction: column; gap: 4px; padding-bottom: 4px; }
.admin-friend-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.admin-friend-name { font-size: 14px; font-weight: 500; }
.admin-friend-un { font-size: 12px; color: var(--text2); margin-left: 4px; }
.admin-msgs-list { display: flex; flex-direction: column; gap: 1px; padding-bottom: 4px; }
.admin-msg-row {
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.admin-msg-row:last-child { border-bottom: none; }
.admin-msg-conv { font-size: 11px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.admin-msg-content { font-size: 14px; color: var(--text); }
.admin-msg-time { font-size: 11px; color: var(--text2); margin-top: 3px; }

/* ── Message timestamps ── */
.msg-time {
  font-size: 10px; color: var(--text2);
  padding: 1px 2px 0; margin-top: 1px;
  opacity: 0.75;
}
.msg.sent .msg-time { text-align: right; }
.msg.received .msg-time { text-align: left; }

/* ── Disappearing messages ── */
.disappear-badge {
  margin-left: 5px; font-size: 13px;
}

/* ── Admin conversation history ── */
.admin-conv-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; gap: 8px;
}
.admin-conv-row:last-child { border-bottom: none; }
.admin-conv-row:active { opacity: 0.7; }
.admin-conv-name { font-size: 14px; font-weight: 600; }
.admin-conv-meta { font-size: 12px; color: var(--text2); white-space: nowrap; }

/* ── Profile sheet ── */
.profile-sheet {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; flex-direction: column; justify-content: flex-end;
  pointer-events: none;
}
.profile-sheet.open { pointer-events: all; }
.profile-sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.45);
  opacity: 0; transition: opacity .2s;
}
.profile-sheet.open .profile-sheet-backdrop { opacity: 1; }
.profile-sheet-card {
  position: relative; background: var(--bg); border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 16px);
  transform: translateY(100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.profile-sheet.open .profile-sheet-card { transform: translateY(0); }
.profile-sheet-handle {
  width: 36px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 10px auto 0;
}
.profile-sheet-hero { text-align: center; padding: 16px 24px 4px; }
.profile-sheet-hero .av { margin: 0 auto; }
.profile-sheet-name { font-size: 19px; font-weight: 700; margin-top: 10px; }
.profile-sheet-un { font-size: 14px; color: var(--text2); margin-top: 2px; }
.profile-bio { font-size: 14px; color: var(--text2); margin-top: 6px; max-width: 260px; line-height: 1.4; text-align: center; }
.profile-friends-since { font-size: 12px; color: var(--text2); margin-top: 5px; opacity: .8; }
.profile-sheet-stats {
  display: flex; gap: 28px; justify-content: center; margin-top: 14px;
}
.profile-stat { text-align: center; }
.profile-stat-num { font-size: 18px; font-weight: 700; }
.profile-stat-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; margin-top: 1px; }
.profile-sheet-actions {
  display: flex; gap: 10px; padding: 16px 20px 8px;
}
.profile-sheet-actions .btn { flex: 1; }

/* ── @mention picker ── */
.mention-list {
  position: fixed; left: 8px; right: 8px; z-index: 1900;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 -4px 20px rgba(0,0,0,.15);
  display: none;
}
.mention-list.open { display: block; }
.mention-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer;
}
.mention-item:active { background: var(--bg2); }
.mention-item .av { flex-shrink: 0; }
.mention-item-name { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-item-un { font-size: 12px; color: var(--text2); }

/* @mention highlight in messages */
.msg-mention { color: var(--accent); font-weight: 600; }

/* ── Online presence dot ── */
.av-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.av-wrap .online-dot {
  width: 10px; height: 10px; background: #22c55e;
  border: 2px solid var(--bg); border-radius: 50%;
  position: absolute; bottom: 0; right: 0; pointer-events: none;
}
/* Larger dot for header avatar */
.av-wrap .hav ~ .online-dot,
.av-wrap:has(.hav) .online-dot {
  width: 11px; height: 11px; border-width: 2px;
}

/* ── Message sender row with add button ── */
.msg-sender-row { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.msg-sender-row .msg-sender { margin-bottom: 0; }
.msg-add-btn {
  font-size: 10px; font-weight: 600; color: var(--accent);
  background: none; border: 1px solid var(--accent); border-radius: 6px;
  padding: 1px 6px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: opacity 0.15s;
}
.msg-add-btn:disabled { opacity: 0.5; }

/* ── Prism+ premium names ── */
.name-premium {
  background: linear-gradient(90deg,#7c3aed,#6366f1,#3b82f6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; font-weight: 700;
}
.prism-plus-badge {
  display: inline-block; font-size: 10px; font-weight: 800;
  background: linear-gradient(135deg,#7c3aed,#6366f1,#3b82f6); color: white;
  padding: 1px 6px; border-radius: 5px;
  vertical-align: middle; margin-left: 6px; letter-spacing: 0.5px;
  -webkit-text-fill-color: white;
}

/* Prism+ welcome screen */
@keyframes prism-bg-shift {
  0%,100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
@keyframes prism-float {
  0%,100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 24px rgba(124,58,237,.7)); }
  50%     { transform: translateY(-10px) scale(1.04); filter: drop-shadow(0 0 40px rgba(99,102,241,.9)); }
}
@keyframes prism-fade-up {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes prism-welcome-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.prism-welcome-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg,#0d0a1e,#1a1040,#0d1a33,#0a1628);
  background-size: 300% 300%;
  animation: prism-bg-shift 8s ease infinite, prism-welcome-in .4s ease;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  overflow: hidden;
}
.prism-welcome-overlay::before {
  content: ''; position: absolute; width: 500px; height: 500px; border-radius: 50%;
  background: radial-gradient(circle,rgba(124,58,237,.25) 0%,transparent 70%);
  top: -150px; left: 50%; transform: translateX(-50%);
  animation: prism-float 5s ease-in-out infinite;
  pointer-events: none;
}
.prism-welcome-card {
  max-width: 340px; width: 100%; text-align: center; position: relative; z-index: 1;
}
.prism-welcome-mark {
  font-size: 72px; line-height: 1; display: inline-block;
  background: linear-gradient(135deg,#7c3aed,#6366f1,#3b82f6);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  animation: prism-float 3s ease-in-out infinite;
  opacity: 0; animation: prism-float 3s ease-in-out infinite, prism-fade-up .5s .1s ease forwards;
}
.prism-welcome-title {
  font-size: 36px; font-weight: 900; letter-spacing: -.02em; margin-top: 12px;
  background: linear-gradient(135deg,#a78bfa,#818cf8,#60a5fa);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  opacity: 0; animation: prism-fade-up .5s .2s ease forwards;
}
.prism-welcome-sub {
  font-size: 15px; color: rgba(255,255,255,.5); margin-top: 6px;
  opacity: 0; animation: prism-fade-up .5s .3s ease forwards;
}
.prism-welcome-perks {
  margin-top: 28px; display: flex; flex-direction: column; gap: 12px; text-align: left;
}
.prism-welcome-perk {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; backdrop-filter: blur(8px);
  opacity: 0; animation: prism-fade-up .5s ease forwards;
}
.prism-perk-icon {
  font-size: 20px; flex-shrink: 0; margin-top: 1px;
  background: linear-gradient(135deg,#a78bfa,#60a5fa);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.prism-perk-title { font-size: 14px; font-weight: 700; color: #fff; }
.prism-perk-desc  { font-size: 12px; color: rgba(255,255,255,.5); margin-top: 2px; }
.prism-welcome-btn {
  margin-top: 24px; width: 100%; padding: 14px; border-radius: 14px; border: none;
  background: linear-gradient(135deg,#7c3aed,#6366f1,#3b82f6); color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer; letter-spacing: .01em;
  opacity: 0; animation: prism-fade-up .5s .85s ease forwards;
  -webkit-text-fill-color: white;
  transition: opacity .15s, transform .15s;
}
.prism-welcome-btn:active { opacity: .8; transform: scale(.98); }

/* ── GC custom checkboxes ── */
.gc-member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer;
  border-radius: 12px; transition: background 0.12s;
}
.gc-member-row:hover { background: var(--bg2); }
.gc-check { display: none; }
.gc-check-icon {
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 50%; border: 2px solid var(--border);
  position: relative; transition: all 0.15s;
}
.gc-member-row:has(.gc-check:checked) { background: var(--bg2); }
.gc-member-row:has(.gc-check:checked) .gc-check-icon {
  background: var(--grad); border-color: transparent;
}
.gc-member-row:has(.gc-check:checked) .gc-check-icon::after {
  content: ''; position: absolute;
  left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: 2.5px solid white; border-top: none; border-left: none;
  transform: rotate(45deg);
}

/* ── Edit message ── */
.msg-edited {
  font-size: 11px; color: var(--text2);
  margin-top: 2px; font-style: italic;
}
.msg-edit-wrap { width: 100%; }
.msg-edit-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg2); border: 1.5px solid var(--accent);
  border-radius: 12px; font-size: 14px; color: var(--text);
  resize: none; font-family: inherit; line-height: 1.4;
}
.msg-edit-input:focus { outline: none; }
.msg-edit-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 6px;
}
