/* ═══════════════════════════════════════════════════════════════════════════
   WIPED MESSENGER — App UI
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Core palette */
  --bg:           #080810;
  --bg-0:         #0d0d0f;
  --bg-1:         #0e0e1a;
  --bg-2:         #141424;
  --bg-3:         #1a1a2e;
  --bg-hover:     #1e1e32;
  --bg-glass:     rgba(14, 14, 26, 0.7);

  /* Borders */
  --border:       rgba(120, 100, 255, 0.12);
  --border-soft:  rgba(255, 255, 255, 0.05);
  --border-glow:  rgba(124, 106, 247, 0.35);

  /* Text */
  --text:         #f0effe;
  --text-2:       #8b88b0;
  --text-3:       #44415e;

  /* Brand */
  --accent:       #7c6af7;
  --accent-2:     #9b8cff;
  --accent-dark:  #5b4dd6;
  --accent-soft:  rgba(124, 106, 247, 0.12);
  --accent-glow:  rgba(124, 106, 247, 0.25);

  /* Status */
  --danger:       #f05d7a;
  --danger-soft:  rgba(240, 93, 122, 0.12);
  --green:        #4ecca3;
  --green-soft:   rgba(78, 204, 163, 0.15);
  --gold:         #f4b942;

  /* Messages */
  --bubble-out:      linear-gradient(135deg, #7c6af7, #9b8cff);
  --bubble-in:       rgba(26, 26, 46, 0.9);
  --bubble-in-hover: rgba(30, 30, 52, 0.95);

  /* Layout */
  --sidebar-w: 300px;
  --radius:    16px;
  --radius-sm: 10px;
  --radius-xs: 7px;

  /* Type */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;

  /* Shadows */
  --shadow:    0 8px 40px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.4);
  --glow:      0 0 30px rgba(124, 106, 247, 0.2);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: inherit; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.hidden { display: none !important; }

/* ── Registration ID preview ─────────────────────────────────────────────── */
.id-preview-box {
  background: var(--accent-soft);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-align: center;
  display: flex; flex-direction: column; gap: 6px;
}
.id-preview-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); }
.id-preview-box code {
  font-family: var(--mono); font-size: 20px; font-weight: 700;
  letter-spacing: 3px; color: var(--accent-2);
}
.id-preview-hint { font-size: 11px; color: var(--text-2); }

.handle-status { font-size: 11px; margin-top: 4px; min-height: 14px; }
.handle-status.ok       { color: #4ade80; }
.handle-status.taken    { color: var(--danger); }
.handle-status.checking { color: var(--text-2); }

/* ── Account created box ──────────────────────────────────────────────────── */
.created-box {
  background: var(--accent-soft);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center;
}
.created-icon { font-size: 36px; }
.created-label { font-weight: 700; font-size: 15px; }
.created-hint { font-size: 12px; color: var(--text-2); }
.created-id-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 8px 12px;
}
.created-id-row code {
  font-family: var(--mono); font-size: 18px; font-weight: 700;
  letter-spacing: 3px; color: var(--accent-2);
}

/* ── Sidebar branding ─────────────────────────────────────────────────────── */
.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.sidebar-brand-link {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none;
}
.sidebar-brand-link:hover .sidebar-brand-name { color: var(--accent-2); }
.sidebar-brand-name {
  font-weight: 800; font-size: 17px; letter-spacing: -.4px;
  background: linear-gradient(135deg, var(--text) 60%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  transition: filter .15s;
}
.sidebar-brand-link:hover .sidebar-brand-name { filter: brightness(1.2); }

/* ── Sidebar profile card ────────────────────────────────────────────────── */
.sidebar-profile {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: default;
  background: var(--bg-2);
  flex-shrink: 0;
}
.sidebar-profile-av {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(124,106,247,.3);
}
.sidebar-self-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.sidebar-self-name-row {
  display: flex; align-items: baseline; gap: 6px;
  min-width: 0;
}
#sidebar-self-name {
  font-weight: 700; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
#sidebar-self-id {
  font-size: 11px; color: var(--text-3); font-family: var(--mono);
  white-space: nowrap; flex-shrink: 0;
}

/* Status dot pill button (right side of profile) */
.sidebar-profile-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.btn-status-pill {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 0;
  background: none; border: none; cursor: pointer;
  overflow: hidden; flex-shrink: 0;
  transition: background .15s;
}
.btn-status-pill:hover { background: var(--bg-hover); width: auto; padding: 0 10px; gap: 6px; }
.btn-status-pill .status-dot { width: 14px; height: 14px; }
.btn-status-label {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; display: none;
}
.btn-status-pill:hover .btn-status-label { display: inline; }

.self-status-msg {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-style: italic; min-height: 14px; cursor: text;
}
.self-status-msg:empty::before {
  content: 'Add a status…';
  opacity: .4; font-style: italic;
}
.self-bio-input {
  width: 100%; font-size: 11px; color: var(--text);
  background: var(--bg-3); border: 1px solid var(--accent);
  border-radius: 3px; padding: 1px 4px; outline: none;
  font-family: inherit; box-sizing: border-box;
}

/* ── Section header (Contacts label + add button) ────────────────────────── */
.sidebar-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 4px;
  flex-shrink: 0;
}
.sidebar-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .9px;
  text-transform: uppercase; color: var(--text-3);
}
.sidebar-add-btn {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent-soft); border: 1px solid var(--border-glow);
  color: var(--accent-2); font-size: 16px; font-weight: 400;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
  line-height: 1;
}
.sidebar-add-btn:hover { background: var(--accent); color: #fff; }
.sidebar-add-btn { position: relative; }
.requests-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff;
  border-radius: 8px; font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.requests-badge.hidden { display: none; }

/* ── Contact requests button + modal ────────────────────────────────────── */
.sidebar-header-actions {
  display: flex; align-items: center; gap: 6px;
}
.sidebar-requests-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700;
  background: var(--accent-soft); border: 1px solid var(--border-glow);
  color: var(--text-2); cursor: pointer; transition: background .15s;
}
.sidebar-requests-btn:hover { background: var(--accent); color: #fff; }
.sidebar-requests-btn.hidden { display: none; }
.requests-badge-inline {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}
.requests-badge-inline.hidden { display: none; }

/* Requests modal */
.modal-requests-box { max-width: 420px; width: 100%; padding: 0; overflow: hidden; }
.modal-req-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700; color: var(--text);
}
.requests-modal-list { padding: 8px 0; max-height: 60vh; overflow-y: auto; }
.req-empty { padding: 24px; text-align: center; font-size: 13px; color: var(--text-3); }
.request-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; transition: background .12s;
}
.request-row:hover { background: var(--bg-hover); }
.request-av {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--av-color, var(--accent-soft));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
}
.request-av-img { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.request-info { flex: 1; min-width: 0; }
.request-name   { font-size: 14px; font-weight: 600; color: var(--text); }
.request-handle { font-size: 11px; color: var(--text-3); }
.request-msg    { font-size: 12px; color: var(--text-2); margin-top: 2px;
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.request-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* Danger/block button */
.btn-danger {
  background: rgba(220,53,69,.18); border: 1px solid rgba(220,53,69,.4);
  color: #e05c6a; border-radius: 8px; cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-danger:hover { background: rgba(220,53,69,.35); color: #fff; }

.sidebar-icon-action {
  width: 30px; height: 30px; border-radius: 8px;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.sidebar-icon-action:hover { background: var(--bg-hover); }
.sidebar-brand-actions {
  display: flex; align-items: center; gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}

.inbox-btn-wrap { position: relative; }

/* ── Panic button ────────────────────────────────────────────────────────── */
.panic-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
}

.admin-shortcut {
  background: none;
  border: 1px solid rgba(160,120,255,0.55);
  border-radius: 4px;
  color: rgba(160,120,255,0.85);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  flex-shrink: 0;
}
.admin-shortcut:hover {
  color: rgba(160,120,255,1);
  border-color: rgba(160,120,255,1);
}

/* "BETA" badge — sits right after the brand name in both the normal
   sidebar (`#app-shell .sidebar-brand`) and the retro top bar
   (`.fb-top-left`). Same visual weight as the ADMIN chip so the row
   reads as a coherent set, but in amber to signal "feature warning"
   rather than ADMIN's purple "privileged surface" or PANIC's red.
   Cursor stays default (the badge isn't actionable; it's a status
   tag), and a `title` on the markup carries the support address. */
.beta-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(245, 185, 66, 0.10);
  border: 1px solid rgba(245, 185, 66, 0.55);
  border-radius: 4px;
  color: rgba(245, 185, 66, 0.95);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  flex-shrink: 0;
  user-select: none;
  cursor: help;
  /* Subtle pulse so it remains noticeable without being distracting.
     Only the border-color animates — text stays steady, the chip
     doesn't flash like an unread badge. */
  animation: beta-pulse 4s ease-in-out infinite;
}
@keyframes beta-pulse {
  0%, 100% { border-color: rgba(245, 185, 66, 0.55); }
  50%      { border-color: rgba(245, 185, 66, 0.95); }
}

.panic-btn {
  position: relative;
  overflow: hidden;
  background: none;
  border: 1px solid rgba(255,59,59,0.7);
  border-radius: 4px;
  color: rgba(255,59,59,0.85);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s, border-color 0.2s;
  user-select: none;
  -webkit-user-select: none;
}
.panic-btn:hover {
  color: #ff3b3b;
  border-color: #ff3b3b;
}
.panic-btn.holding {
  border-color: #ff3b3b;
}

.panic-fill {
  position: absolute;
  inset: 0;
  background: #ff3b3b;
  border-radius: 3px;
  transform-origin: left center;
  transform: scaleX(0);
  pointer-events: none;
}

/* Info badge + tooltip */
.panic-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.3);
  font-size: 8px;
  font-style: italic;
  font-weight: 700;
  cursor: default;
  position: relative;
  flex-shrink: 0;
  transition: color 0.2s, border-color 0.2s;
}
.panic-info:hover {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.5);
}
.panic-tooltip {
  display: none;
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  background: var(--bg-2);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 400;
  line-height: 1.5;
  padding: 8px 10px;
  white-space: nowrap;
  width: max-content;
  max-width: 220px;
  white-space: normal;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.panic-tooltip::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--border-glow);
  border-top: none;
}
.panic-info:hover .panic-tooltip { display: block; }

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-2); border: 1px solid var(--border-glow);
  color: var(--text); font-size: 12px; font-family: var(--mono);
  padding: 5px 10px; border-radius: var(--radius-xs);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .1s, transform .1s;
  box-shadow: var(--shadow-sm); z-index: 200;
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Multi-line tooltip variant */
[data-tooltip-wide] { position: relative; }
[data-tooltip-wide]::after {
  content: attr(data-tooltip-wide);
  position: absolute; bottom: calc(100% + 6px); right: 0;
  background: var(--bg-2); border: 1px solid var(--border-glow);
  color: var(--text); font-size: 12px; font-family: var(--mono);
  padding: 8px 12px; border-radius: var(--radius-xs);
  white-space: normal; width: 240px; line-height: 1.5;
  pointer-events: none;
  opacity: 0; transform: translateY(4px);
  transition: opacity .1s, transform .1s;
  box-shadow: var(--shadow-sm); z-index: 200;
}
[data-tooltip-wide]:hover::after {
  opacity: 1; transform: translateY(0);
}


/* P2P button — tooltip appears below, left-anchored (right:0 would clip outside #chat-panel) */
#btn-p2p-send[data-tooltip-wide]::after {
  bottom: auto; top: calc(100% + 6px);
  right: auto; left: 0;
  transform: translateY(-4px);
}
#btn-p2p-send[data-tooltip-wide]:hover::after {
  transform: translateY(0);
}

/* Space header — tooltip appears below, left-aligned */
.space-header[data-tooltip] { position: relative; }
.space-header[data-tooltip]::after {
  top: calc(100% + 4px); bottom: auto;
  left: 14px; transform: translateY(-4px);
}
.space-header[data-tooltip]:hover::after {
  transform: translateY(0);
}

/* ── Noise texture overlay ─────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: .4;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .01em;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .2s;
  box-shadow: 0 4px 20px var(--accent-glow);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(255,255,255,.08), transparent);
}
.btn-primary:hover { opacity: .92; box-shadow: 0 6px 28px var(--accent-glow); }
.btn-primary:active { transform: scale(.97); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-glow); }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg-3); color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 22px; font-weight: 500; font-size: 14px;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-glow); color: var(--text); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(240,93,122,.2);
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-full { width: 100%; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text-2);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
/* Variant for buttons that show a short text label instead of an emoji
   (e.g. the P2P transfer button — text disambiguates from the standard
   attach-file paperclip nearby). Slightly wider + bolder + smaller font
   so 3-4 chars sit centered without overflow. */
.icon-btn-text {
  width: auto;
  min-width: 44px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FIELDS
   ═══════════════════════════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; color: var(--text-2); font-weight: 500; letter-spacing: .03em; text-transform: uppercase; }

input[type="text"], input[type="password"], input[type="search"], input[type="datetime-local"], textarea, .field input, .field textarea {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  background: rgba(124,106,247,.06);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }

.field select, select.field-select {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 36px 11px 15px;
  color: var(--text);
  outline: none;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.field select:focus, select.field-select:focus {
  border-color: var(--accent);
  background-color: rgba(124,106,247,.06);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field select option, select.field-select option {
  background: var(--bg-2);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════════════════════════ */
#auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 100;
  overflow: hidden;
}

/* Animated gradient background */
#auth-screen::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,106,247,.18) 0%, transparent 70%);
  top: -150px; left: 50%;
  transform: translateX(-50%);
  animation: breathe 6s ease-in-out infinite;
}
#auth-screen::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(155,140,255,.1) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  animation: breathe 8s ease-in-out infinite reverse;
}
@keyframes breathe {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: .6; }
  50% { transform: translateX(-50%) scale(1.15); opacity: 1; }
}

.auth-wrap {
  position: relative; z-index: 1;
  width: 100%; max-width: 380px;
  padding: 44px 36px 40px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glow);
  border-radius: 24px;
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow), var(--glow), inset 0 1px 0 rgba(255,255,255,.06);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}

.auth-logo {
  width: 64px; height: 64px;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px rgba(124,106,247,.6));
  animation: floatLogo 4s ease-in-out infinite;
}
@keyframes floatLogo {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.auth-wrap h1 {
  font-size: 24px; font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(135deg, var(--text), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

.auth-sub { color: var(--text-2); font-size: 13px; margin-bottom: 20px; text-align: center; }

.auth-panel { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.auth-panel.hidden { display: none; }
.auth-toggle { text-align: center; font-size: 13px; color: var(--text-2); }

/* Plain-English intro at the top of the signup card — explains the
   three-piece identity model (ID / handle / password) before the
   form asks for anything. Replaces the old "auto-generated ID
   preview" box that confused first-time users. */
.auth-intro {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}
.auth-intro p { margin: 0; }
.auth-intro strong { color: var(--text); font-weight: 600; }

/* Inline form-field hint — used after the field label to give the
   "why this matters" without making the form noisier. Smaller +
   muted than the label itself so the eye lands on the label first. */
.field-hint {
  font-weight: 400;
  color: var(--text-3);
  font-size: 11.5px;
  margin-left: 2px;
}

/* "or" divider between Sign in and Create account on the login card.
   Two thin lines flanking a tiny centered label — same pattern as
   most "Sign in with…" forms so the visual language is familiar.
   Used to make the secondary CTA feel like a real alternative path,
   not a buried link.

   Implementation: flex container, the label gets its own background
   colour so the line appears to "go behind" it. The CSS pseudo-
   elements are the lines themselves.
*/
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}
.auth-divider span { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════════════════════════════════════════ */
#app-shell {
  display: flex;
  height: 100vh; width: 100vw;
  overflow: hidden;
  position: relative; z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LEFT PANEL — rail + sidebar, always visible
   ═══════════════════════════════════════════════════════════════════════════ */
#left-panel {
  display: flex;
  height: 100%;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ICON RAIL
   ═══════════════════════════════════════════════════════════════════════════ */
#icon-rail {
  width: 64px; min-width: 64px;
  background: var(--bg-0, #0d0d0f);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  height: 100%;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;
  flex-shrink: 0;
  position: relative; z-index: 2;
  transition: width .2s ease, min-width .2s ease;
}
#icon-rail::-webkit-scrollbar { display: none; }

#icon-rail.rail-expanded {
  width: 215px; min-width: 215px;
  align-items: stretch;
  padding: 10px 8px;
}
#icon-rail.rail-expanded #rail-top,
#icon-rail.rail-expanded #rail-bottom {
  align-items: stretch;
}

/* Expanded nav items — fond transparent, seul l'actif est coloré */
#icon-rail.rail-expanded .rail-btn,
#icon-rail.rail-expanded .space-rail-icon {
  width: 100%; height: 38px;
  justify-content: flex-start;
  padding: 0 10px; gap: 10px;
  border-radius: 8px;
  background: transparent;
  border-color: transparent;
}
#icon-rail.rail-expanded .rail-btn:hover,
#icon-rail.rail-expanded .space-rail-icon:hover {
  border-radius: 8px;
  background: var(--bg-hover, rgba(255,255,255,.06));
  border-color: transparent;
}
#icon-rail.rail-expanded .rail-btn.active,
#icon-rail.rail-expanded .space-rail-icon.active {
  border-radius: 8px;
  background: var(--accent-soft);
  border-color: var(--border-glow);
}

/* Séparateur élargi + petit label de section "SPACES" */
#icon-rail.rail-expanded .rail-divider {
  width: 100%; height: auto; background: none;
  margin: 6px 0 0;
}
#icon-rail.rail-expanded .rail-divider::after {
  content: 'SPACES';
  display: block;
  font-size: 9px; font-weight: 700; letter-spacing: .8px;
  color: var(--text-3);
  padding: 10px 4px 6px;
  text-transform: uppercase;
}
#icon-rail.rail-expanded #space-icons {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%;
}
.rail-icon-emoji { flex-shrink: 0; }

/* Rail label */
.rail-label {
  display: none;
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
#icon-rail.rail-expanded .rail-label { display: block; }

/* Toggle button */
.rail-toggle-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 13px; font-weight: 700;
  width: 44px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: color .15s, background .15s;
  flex-shrink: 0; align-self: center;
}
.rail-toggle-btn:hover { color: var(--text); background: var(--bg-3); }
#icon-rail.rail-expanded .rail-toggle-btn {
  width: 100%; justify-content: flex-end;
  padding-right: 6px; align-self: auto;
}

/* "New Space" en mode action (pas nav) */
#icon-rail.rail-expanded #nav-create-space {
  background: transparent;
  border: 1px dashed var(--border-soft);
  border-radius: 8px;
  margin-top: 4px;
}
#icon-rail.rail-expanded #nav-create-space:hover {
  background: var(--bg-hover, rgba(255,255,255,.06));
  border-color: var(--accent-2);
}
#icon-rail.rail-expanded #nav-create-space .rail-label {
  font-size: 12px; font-weight: 400; color: var(--text-3);
}
#icon-rail.rail-expanded #nav-create-space:hover .rail-label { color: var(--accent-2); }

#rail-top, #rail-bottom {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  width: 100%;
}

.rail-notif-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: #f04747; color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-1);
  pointer-events: none; z-index: 2;
}

.rail-btn {
  width: 44px; height: 44px;
  border-radius: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-radius .2s, background .15s;
  overflow: hidden; position: relative;
  position: relative;
}
.rail-btn:hover { border-radius: 12px; background: var(--bg-3); }
.rail-btn.active { border-radius: 12px; background: var(--accent-soft); border-color: var(--border-glow); }
.rail-btn.active::before {
  content: '';
  position: absolute; left: -1px; top: 30%; bottom: 30%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent-2);
}

.rail-btn-add {
  font-size: 22px; font-weight: 300;
  color: var(--accent-2);
  background: var(--accent-soft);
  border-color: var(--border-glow);
}
.rail-btn-add:hover { border-radius: 12px; }

.rail-divider {
  width: 32px; height: 1px;
  background: var(--border-soft);
  margin: 4px 0;
}

.space-rail-icon {
  width: 44px; height: 44px;
  border-radius: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  transition: border-radius .2s, background .15s;
  position: relative;
}
.space-rail-icon:hover { border-radius: 12px; background: var(--bg-3); }
.space-rail-icon.active { border-radius: 12px; background: var(--accent-soft); border-color: var(--border-glow); }
.space-rail-icon.active::before {
  content: '';
  position: absolute; left: -1px; top: 30%; bottom: 30%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent-2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SPACE PANEL (inside sidebar)
   ═══════════════════════════════════════════════════════════════════════════ */
.space-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 700; font-size: 15px;
}
#space-header-icon { font-size: 20px; }
#space-header-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-header-btn {
  padding: 6px 12px; border-radius: 4px; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text-2); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.space-header-btn:hover {
  background: var(--hover-bg); border-color: var(--accent); color: var(--text);
}

.space-section-label {
  padding: 8px 14px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--text-3);
}

.channel-list { list-style: none; padding: 0 8px; margin: 0; }
/* Voice channel participant mini-avatars in channel list */
/* ── Voice channel member rows (Discord-style) ──────────────────────────── */
.vc-member-row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 10px 3px 28px;
  font-size: 12.5px; color: var(--text-2);
  list-style: none;
}
.vc-member-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.12); border: 1.5px solid rgba(255,255,255,0.2);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.vc-member-dot.speaking {
  background: #43b581; border-color: #43b581;
  box-shadow: 0 0 0 3px rgba(67,181,129,.3);
  animation: speaking-ring 1s ease infinite;
}
.vc-member-av {
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.vc-member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-view-btn {
  margin-left: auto; flex-shrink: 0;
  padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 600;
  background: rgba(67,181,129,.12); border: 1px solid rgba(67,181,129,.3);
  color: #43b581; cursor: pointer;
  transition: background .1s;
}
.vc-view-btn:hover { background: rgba(67,181,129,.22); }

/* ── Voice participant context menu (right-click volume) ─────────────────── */
.vc-ctx-menu {
  position: fixed; z-index: 320;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.55);
  min-width: 200px; user-select: none;
}
.vc-ctx-menu.hidden { display: none; }
.vc-ctx-name { font-size: 12px; font-weight: 700; color: var(--text-2);
  margin-bottom: 10px; letter-spacing: .3px; }
.vc-ctx-vol-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.vc-ctx-vol-row input[type=range] { flex: 1; accent-color: var(--accent); cursor: pointer; height: 4px; }
.vc-ctx-vol-pct { font-size: 12px; color: var(--text-2); min-width: 38px; text-align: right; }

/* ── Voice channel panel — docked bottom of sidebar ─────────────────────── */
.voice-bar {
  border-top: 2px solid rgba(67,181,129,.35);
  background: var(--bg-0);
  padding: 14px 16px 16px;
  display: flex; flex-direction: column; gap: 12px;
  flex-shrink: 0;
}
.voice-bar.hidden { display: none; }
/* Voice settings panel (mic sensitivity + noise) */
.voice-settings-panel {
  padding: 8px 12px; border-bottom: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 8px;
}
.voice-settings-panel.hidden { display: none; }
.vsp-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2);
}
.vsp-label { min-width: 100px; flex-shrink: 0; }
.vsp-vad-slider { flex: 1; accent-color: var(--accent); cursor: pointer; height: 4px; }
.vsp-vad-val { min-width: 20px; text-align: right; font-size: 11px; color: var(--text-3); }
.vsp-level-bar { flex: 1; height: 8px; background: var(--bg-3); border-radius: 4px; position: relative; overflow: visible; }
.vsp-level-fill { height: 100%; background: var(--accent); border-radius: 4px; width: 0; transition: width 50ms linear; }
.vsp-level-marker { position: absolute; top: -3px; width: 2px; height: 14px; background: rgba(255,255,255,.75); border-radius: 1px; left: 0; pointer-events: none; transform: translateX(-50%); }
.vsp-test-row { gap: 10px; }
.vsp-test-btn { padding: 3px 10px; font-size: 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.vsp-test-btn.active { background: var(--accent); color: #fff; border-color: transparent; }
.vsp-listen-label { display: flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.voice-bar-info { display: flex; align-items: center; gap: 12px; }
.voice-bar-icon { font-size: 20px; flex-shrink: 0; }
.voice-bar-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.voice-bar-name   { font-size: 14px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-bar-status { font-size: 11px; color: #43b581; letter-spacing: .4px; }
.voice-bar-participants { display: flex; flex-direction: column; gap: 6px; }
.voice-bar-participant {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 0;
}
.voice-bar-av {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 13px;
  border: 2px solid var(--bg-0);
  flex-shrink: 0;
}
.voice-bar-pname {
  font-size: 13px; font-weight: 500; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.voice-bar-actions {
  display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap; padding-top: 2px;
}
.voice-bar-btn {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--bg-2); border: 1px solid var(--border);
  font-size: 17px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s; flex-shrink: 0;
}
.voice-bar-btn:hover { background: var(--bg-hover); }
.voice-bar-btn.active { background: var(--accent-soft); border-color: var(--accent); }
.voice-bar-btn.danger { background: var(--danger-soft); border-color: var(--danger); }
.voice-bar-btn.danger:hover { background: var(--danger); color: #fff; }
.voice-bar-btn.ptt-active {
  background: rgba(67,181,129,.25); border-color: #43b581;
  box-shadow: 0 0 0 3px rgba(67,181,129,.3);
}
.ptt-key-badge {
  font-size: 10px; font-family: inherit; font-weight: 600;
  padding: 2px 6px; border-radius: 5px;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; white-space: nowrap;
  transition: background .1s, border-color .1s;
  user-select: none; flex-shrink: 0;
}
.ptt-key-badge:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--text); }
.ptt-key-badge.capturing { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ptt-key-badge.hidden { display: none; }
.voice-bar-btn-text {
  height: 30px; padding: 0 10px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s; flex-shrink: 0;
}
.voice-bar-btn-text:hover { background: var(--bg-hover); }
.voice-bar-btn-text.hidden { display: none; }

/* ── Speaking ring (VAD) ──────────────────────────────────────────────────── */
@keyframes speaking-ring {
  0%   { box-shadow: 0 0 0 0   rgba(67,181,129,.8); }
  70%  { box-shadow: 0 0 0 5px rgba(67,181,129,0);  }
  100% { box-shadow: 0 0 0 0   rgba(67,181,129,0);  }
}
.vcm-av.speaking,
.voice-bar-av.speaking {
  animation: speaking-ring 1s ease infinite;
  border: 1.5px solid #43b581;
}

/* ── Screen share overlay ─────────────────────────────────────────────────── */
.screen-share-overlay {
  position: fixed; top: 20px; right: 20px;
  width: 480px; max-width: calc(100vw - 40px);
  z-index: 200;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}
.screen-share-overlay.hidden { display: none; }
.screen-share-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  cursor: grab; user-select: none;
}
.screen-share-header:active { cursor: grabbing; }
.screen-share-who { flex: 1; font-size: 12px; font-weight: 600; color: var(--text); }
.screen-share-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 15px; padding: 2px 5px;
  border-radius: 4px; transition: background .1s;
}
.screen-share-btn:hover { background: var(--bg-hover); color: var(--text); }
.screen-share-video {
  display: block; width: 100%; max-height: 300px;
  background: #000; object-fit: contain;
}
.screen-share-nav { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.screen-share-nav-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: 14px; padding: 2px 6px;
  border-radius: 4px; transition: background .1s;
}
.screen-share-nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.screen-share-nav-btn.hidden { display: none; }
.screen-share-counter {
  font-size: 11px; color: var(--text-3); min-width: 28px; text-align: center;
}
/* Grid mode */
.screen-share-overlay.grid-mode {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
}
.ss-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 3px; background: #000;
  max-height: calc(100vh - 80px); overflow-y: auto;
}
.ss-grid-item { position: relative; background: #000; }
.ss-grid-video {
  display: block; width: 100%; aspect-ratio: 16/9;
  background: #111; object-fit: contain; cursor: pointer;
}
.ss-grid-video:hover { outline: 2px solid var(--accent); }
.ss-grid-label {
  position: absolute; bottom: 5px; left: 6px;
  font-size: 11px; color: #fff; font-weight: 600;
  background: rgba(0,0,0,.65); padding: 2px 7px; border-radius: 4px;
  pointer-events: none;
}
/* Free-floating windows */
.ss-free-window {
  position: fixed; z-index: 195;
  width: 320px; min-width: 160px; min-height: 110px;
  display: flex; flex-direction: column;
  background: #000; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.65);
}
.ss-free-header {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  cursor: grab; user-select: none; flex-shrink: 0;
  font-size: 11px; font-weight: 600; color: var(--text);
}
.ss-free-header:active { cursor: grabbing; }
.ss-free-video { flex: 1; width: 100%; object-fit: contain; display: block; background: #000; }
.ss-free-close {
  margin-left: auto; background: none; border: none;
  cursor: pointer; color: var(--text-3); font-size: 13px; padding: 1px 5px;
  border-radius: 4px; line-height: 1;
}
.ss-free-close:hover { background: var(--bg-hover); color: var(--danger); }
.ss-free-resize {
  position: absolute; bottom: 0; right: 0;
  width: 14px; height: 14px; cursor: se-resize;
  background: linear-gradient(135deg, transparent 55%, rgba(255,255,255,.18) 55%);
}

/* ── Screen share mini floating player ──────────────────────────────────── */
.screen-share-mini {
  position: fixed; bottom: 80px; right: 20px;
  width: 240px; z-index: 190;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.55);
  cursor: pointer;
}
.screen-share-mini.hidden { display: none; }
.screen-share-mini-video {
  display: block; width: 100%; height: 135px;
  background: #000; object-fit: contain; pointer-events: none;
}
.screen-share-mini-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; background: var(--bg-2);
}
.screen-share-mini-who {
  flex: 1; font-size: 11px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.screen-share-mini-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 13px; padding: 2px 4px;
  border-radius: 4px; transition: background .1s; flex-shrink: 0;
}
.screen-share-mini-btn:hover { background: var(--bg-hover); color: var(--text); }

.channel-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px;
  cursor: pointer; font-size: 13.5px; color: var(--text-2);
  transition: background .12s, color .12s;
  position: relative;
}
.channel-item:hover { background: var(--bg-hover); color: var(--text); }
.channel-item.active { background: var(--accent-soft); color: var(--text); }
.channel-item.voice-active {
  background: rgba(67,181,129,.12); color: #43b581;
  box-shadow: inset 3px 0 0 #43b581;
}
.channel-icon { font-size: 15px; opacity: .7; }
.ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-unread {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent); color: #fff;
  border-radius: 9px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.channel-menu-btn {
  opacity: 0; margin-left: auto; background: none; border: none;
  cursor: pointer; color: var(--text-2); font-size: 16px; line-height: 1;
  padding: 0 2px; border-radius: 4px; flex-shrink: 0;
  transition: opacity .12s;
}
.channel-item:hover .channel-menu-btn { opacity: 1; }
.channel-menu-btn:hover { background: var(--bg-3); color: var(--text); }

/* Ephemeral live channel — indented below its voice channel */
.channel-item-ephemeral {
  padding-left: 26px;
  font-size: 12.5px;
}
.ch-live-dot {
  display: inline-block; width: 8px; height: 8px; flex-shrink: 0;
  background: #f04747; border-radius: 50%;
  box-shadow: 0 0 5px #f04747;
  animation: live-pulse 1.8s ease-in-out infinite;
  opacity: 1;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 4px #f04747; }
  50%       { box-shadow: 0 0 10px #f04747, 0 0 4px #f04747; }
}

.channel-menu-dropdown {
  position: fixed; z-index: 300;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 5px; min-width: 170px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 1px;
}
.channel-menu-dropdown button {
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: 13px; padding: 8px 12px;
  border-radius: 6px; text-align: left; width: 100%;
  display: flex; align-items: center; gap: 8px;
  transition: background .1s, color .1s;
}
.channel-menu-dropdown button:hover { background: var(--bg-hover); color: var(--text); }
.channel-menu-dropdown button.danger { color: var(--danger); }
.channel-menu-dropdown button.danger:hover { background: var(--danger-soft); }
.channel-menu-sep {
  height: 1px; background: var(--border); margin: 3px 6px;
}

.btn-add-channel {
  margin: 10px 12px 4px;
  padding: 6px 10px; width: calc(100% - 24px);
  background: none; border: 1px dashed var(--border-soft);
  border-radius: 6px; color: var(--text-3);
  font-size: 12px; cursor: pointer; text-align: left;
}
.btn-add-channel:hover { border-color: var(--accent-2); color: var(--accent-2); }

.space-invite-box {
  margin: auto 12px 10px;
  padding: 8px 10px;
  background: var(--bg-2); border-radius: 8px;
  font-size: 11px; color: var(--text-3);
  display: flex; align-items: center; gap: 6px;
}
#space-invite-code {
  flex: 1; font-family: var(--mono); font-size: 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Icon picker */
.icon-picker-wrap { position: relative; display: inline-block; }
.icon-picker-preview {
  width: 52px; height: 52px; border-radius: 12px;
  background: var(--bg-3); border: 1px solid var(--border-soft);
  font-size: 26px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color .15s;
}
.icon-picker-preview:hover { border-color: var(--accent-2); }
.icon-picker-preview img { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }

.icon-picker-popup {
  position: fixed; z-index: 9999;
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  width: 292px;
}
.icon-picker-grid {
  display: grid; grid-template-columns: repeat(9, 1fr);
  gap: 2px; max-height: 200px; overflow-y: auto;
  margin-bottom: 8px;
}
.icon-picker-grid button {
  width: 100%; aspect-ratio: 1; border-radius: 6px;
  background: none; border: none; font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .1s;
}
.icon-picker-grid button:hover { background: var(--bg-hover); }
.icon-picker-grid button.selected { background: var(--accent-soft); }

.icon-picker-upload-label {
  display: flex; align-items: center; justify-content: center;
  padding: 7px; border-radius: 8px;
  border: 1px dashed var(--border-soft);
  color: var(--text-3); font-size: 12px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.icon-picker-upload-label:hover { border-color: var(--accent-2); color: var(--accent-2); }
.icon-picker-upload-label input { display: none; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; flex-shrink: 0; }
.toggle-switch input { display: none; }
.toggle-track {
  display: block; width: 42px; height: 24px; border-radius: 12px;
  background: var(--bg-3); border: 1px solid var(--border-soft);
  cursor: pointer; transition: background .2s, border-color .2s;
  position: relative;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-3); transition: transform .2s, background .2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px); background: #fff;
}

/* Settings toggle row */
.settings-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 0;
  border-top: 1px solid var(--border-soft);
  margin-top: 8px;
}
.settings-toggle-info { display: flex; flex-direction: column; gap: 3px; }
.settings-toggle-label { font-size: 14px; font-weight: 500; color: var(--text); }
.settings-toggle-desc { font-size: 11px; color: var(--text-3); line-height: 1.4; }

/* Tabs (Create/Join modal) */
.tab-row { display: flex; gap: 4px; margin-bottom: 16px; }
.tab-btn {
  flex: 1; padding: 7px; border-radius: 7px;
  background: var(--bg-2); border: 1px solid var(--border-soft);
  color: var(--text-2); font-size: 13px; cursor: pointer;
}
.tab-btn.active { background: var(--accent-soft); border-color: var(--border-glow); color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR — always visible
   ═══════════════════════════════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  height: 100%;
  overflow: hidden;
  flex-shrink: 0;
}

#sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  pointer-events: none;
}

.sidebar-fixed-top { flex-shrink: 0; position: relative; }

#dm-panel, #space-panel {
  display: flex; flex-direction: column;
  flex: 1; overflow: hidden;
  min-height: 0;
}


.sidebar-search { padding: 10px 12px; }
.sidebar-search input {
  border-radius: 12px;
  padding: 9px 14px 9px 36px;
  font-size: 13.5px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b88b0' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

/* Conv list */
.conv-list { list-style: none; flex: 1; overflow-y: auto; padding: 6px 0; }

.conv-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  margin: 1px 6px;
  border-radius: 14px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item:hover .conv-actions { opacity: 1; pointer-events: auto; }
.conv-item.active {
  background: var(--accent-soft);
  border: 1px solid var(--border-glow);
}
.conv-item.active .conv-name { color: var(--accent-2); }

.conv-unread {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10px; font-weight: 700;
  line-height: 1;
}

.conv-actions {
  display: flex; gap: 4px; align-items: center;
  margin-left: auto; flex-shrink: 0;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
}
.conv-action-btn {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2);
  transition: background .12s, border-color .12s, color .12s;
}
.conv-action-btn:hover {
  background: var(--bg-3);
  border-color: var(--border);
  color: var(--text);
}
.conv-action-btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.conv-avatar {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  color: var(--accent-2);
  flex-shrink: 0;
  position: relative;
}
.conv-avatar .status-dot {
  position: absolute; bottom: -3px; right: -3px;
  width: 12px; height: 12px;
  border: 2.5px solid var(--bg-1);
}

.conv-body { flex: 1; min-width: 0; }
.conv-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.conv-time { font-size: 11px; color: var(--text-3); }
.conv-badge {
  background: var(--accent);
  color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 8px; padding: 2px 7px; min-width: 18px; text-align: center;
}


/* ═══════════════════════════════════════════════════════════════════════════
   CHAT PANEL
   ═══════════════════════════════════════════════════════════════════════════ */
#chat-panel {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

/* Background pattern */
#chat-panel::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(124,106,247,.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(155,140,255,.03) 0%, transparent 50%);
  pointer-events: none;
}

.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  color: var(--text-3); position: relative; z-index: 1;
}
.chat-empty img {
  width: 80px; opacity: .12; filter: grayscale(1) brightness(2);
  animation: floatLogo 5s ease-in-out infinite;
}
.chat-empty p { font-size: 15px; color: var(--text-3); }

/* ── Home panel ──────────────────────────────────────────────────────────────── */
.home-panel {
  flex: 1; display: flex; flex-direction: column;
  overflow-y: auto; padding: 48px 60px;
  gap: 40px; position: relative; z-index: 1;
  max-width: 960px; width: 100%; margin: 0 auto; align-self: flex-start;
  box-sizing: border-box;
}
.home-profile-card {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
}
/* Banner: full width */
.home-banner {
  height: 200px; flex-shrink: 0; position: relative;
  background: repeating-linear-gradient(
    -45deg,
    var(--accent)18 0px, var(--accent)18 1px,
    transparent 1px, transparent 18px
  ), linear-gradient(135deg, var(--accent-2)44 0%, var(--accent)22 100%);
  background-size: cover; background-position: center;
  cursor: pointer;
}
/* Hint text visible by default, brighter on hover */
.home-banner::after {
  content: '🖼️  Click to set a banner';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: rgba(255,255,255,.45);
  letter-spacing: .3px; pointer-events: none;
  transition: color .2s;
}
.home-banner.has-image::after { display: none; }
.home-banner:hover::after { color: rgba(255,255,255,.85); }
.home-banner:hover .home-banner-edit { opacity: 1; }
.home-banner-edit {
  position: absolute; bottom: 10px; right: 12px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 12px;
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
/* Body below banner: two columns (1/3 info — 2/3 secrets) */
.home-card-body {
  display: grid; grid-template-columns: 1fr 2fr;
  flex: 1;
}
.home-card-left { padding: 0 28px 28px; min-width: 0; display: flex; flex-direction: column; }
.home-account-info {
  margin-top: auto; padding-top: 20px; display: flex; flex-direction: column; gap: 12px;
}
.home-tier-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 4px;
}
.home-tier-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 18px; border-radius: 999px; font-size: 13px; font-weight: 800;
  letter-spacing: .6px; text-transform: uppercase;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  /* Reset native <button> styles so the gradient/colors below take over */
  border: 0;
  font-family: inherit;
}
.home-tier-badge:focus-visible {
  outline: 2px solid rgba(108, 99, 255, 0.6);
  outline-offset: 2px;
}
.home-tier-badge:hover {
  transform: translateY(-1px);
}
.home-tier-badge.free {
  background: var(--bg-3); color: var(--text-3); border: 1px solid var(--border-soft);
}
.home-tier-badge.paid {
  background: linear-gradient(135deg, #6c63ff, #8d7bff);
  color: #fff; border: none;
  box-shadow: 0 4px 16px rgba(108, 99, 255, 0.5);
}
.home-tier-badge.paid:hover {
  box-shadow: 0 6px 22px rgba(108, 99, 255, 0.65);
}
.home-tier-badge.super {
  background: linear-gradient(135deg, #ffb547, #ff8a3d);
  color: #fff; border: none;
  box-shadow: 0 4px 16px rgba(255, 138, 61, 0.5);
}
.home-tier-badge.super:hover {
  box-shadow: 0 6px 22px rgba(255, 138, 61, 0.65);
}
.home-upgrade-btn {
  padding: 4px 12px; border-radius: 20px; border: none; cursor: pointer;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; transition: opacity .15s;
}
.home-upgrade-btn:hover { opacity: .85; }
.home-stats-row {
  display: flex; gap: 0; border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden;
}
.home-stat-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px; gap: 2px;
}
.home-stat-item + .home-stat-item { border-left: 1px solid var(--border-soft); }
.home-stat-value { font-size: 16px; font-weight: 700; color: var(--text); }
.home-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-3); }
.home-card-top {
  display: flex; align-items: flex-end; gap: 16px;
  margin-top: -44px; margin-bottom: 20px;
  position: relative; z-index: 1;
}
.home-av {
  width: 88px; height: 88px; flex-shrink: 0;
  border-radius: 50%; background: var(--av-color, var(--bg-3));
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700; color: #fff; overflow: hidden;
  border: 3px solid var(--bg-2);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.home-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.home-name-row { display: flex; flex-direction: column; gap: 2px; padding-bottom: 4px; min-width: 0; }
/* Fields grid */
.home-fields { display: grid; grid-template-columns: 72px 1fr; gap: 10px 16px; align-items: start; }
.home-field-row { display: contents; }
.home-field-label {
  font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: var(--text-3); padding-top: 2px; white-space: nowrap;
}
.home-field-value { min-width: 0; }
.home-editable-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.home-editable-row::after {
  content: '✏️'; font-size: 11px; opacity: 0;
  transition: opacity .15s; pointer-events: none; flex-shrink: 0;
}
.home-editable-row:hover::after { opacity: .6; }
.home-display-name {
  font-size: 22px; font-weight: 800; color: var(--text);
  cursor: pointer; border-radius: 4px; padding: 1px 4px; margin: -1px -4px;
}
.home-display-name:hover { background: var(--bg-hover); }
.home-handle { font-size: 13px; color: var(--text-2); }
.home-bio {
  font-size: 14px; color: var(--text-2); white-space: pre-wrap;
  cursor: pointer; border-radius: 4px; padding: 1px 4px; margin: -1px -4px;
  min-height: 20px;
}
.home-bio:empty::before { content: 'Add a bio…'; opacity: .4; font-style: italic; }
.home-bio:hover { background: var(--bg-hover); }
.home-status-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; position: relative; }
.home-status-left { display: flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 4px; padding: 2px 6px; margin: -2px -6px; }
.home-status-left:hover { background: var(--bg-hover); }
.home-status-label { font-size: 12px; color: var(--text-2); }
.home-status-msg-label {
  font-size: 12px; color: var(--text-2); font-style: italic;
  cursor: pointer; border-radius: 4px; padding: 1px 4px; margin: -1px -4px;
  min-height: 18px;
}
.home-status-msg-label:empty::before { content: 'Add a status message…'; opacity: .4; font-style: italic; }
.home-status-msg-label:hover { background: var(--bg-hover); }
.home-status-picker {
  position: absolute; top: 28px; left: -6px;
  background: var(--bg-glass); backdrop-filter: blur(20px);
  border: 1px solid var(--border-glow); border-radius: 10px;
  box-shadow: var(--shadow); padding: 4px; z-index: 20;
  display: flex; flex-direction: column; gap: 1px; min-width: 130px;
}
.home-status-option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 7px; border: none;
  background: none; cursor: pointer; color: var(--text); font-size: 13px;
  text-align: left; width: 100%;
}
.home-status-option:hover { background: var(--bg-hover); }
.home-status-option.active { background: var(--accent-soft); }
.home-edit-input {
  flex: 1; background: var(--bg-3); border: 1px solid var(--accent);
  border-radius: 6px; padding: 3px 8px; color: var(--text); font-size: 14px;
  min-width: 0; outline: none;
}
.home-edit-input:focus { border-color: var(--accent-2); }

.home-card-right {
  border-left: 1px solid var(--border-soft);
  padding: 24px 20px;
  display: flex; flex-direction: column; gap: 12px;
  align-items: center; text-align: center;
}
.home-secrets-title-row { display: flex; align-items: center; gap: 10px; justify-content: center; position: relative; width: 100%; }
.home-btn-settings {
  position: absolute; right: 0;
  background: none; border: none; cursor: pointer; font-size: 15px;
  color: var(--text-3); padding: 2px 4px; border-radius: 6px;
  transition: color .15s, background .15s; line-height: 1;
}
.home-btn-settings:hover { color: var(--text); background: var(--bg-hover); }
.home-secrets-title { font-size: 13px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-2); }
.home-secrets-counter { font-size: 12px; font-weight: 700; color: var(--accent-2); font-family: var(--mono); }
.home-secrets-hint { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.home-secrets-grid {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: center; margin-top: 4px;
}
.home-secret-group {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.home-secret-pair { display: flex; gap: 6px; }
.home-secret-badge {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.home-secret-icon {
  width: 46px; height: 46px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  border: 2px solid var(--border-soft);
  background: var(--bg-2);
  position: relative; overflow: visible;
}
.home-secret-icon.unlocked { border-color: var(--accent-2); background: var(--accent-soft); }
.home-secret-icon.gold { border-color: #ffd700; background: rgba(255,215,0,.12); box-shadow: 0 0 8px rgba(255,215,0,.2); }
.home-secret-icon.locked { filter: grayscale(1); opacity: .25; }
.home-secret-gold-star {
  position: absolute; top: -6px; right: -6px;
  font-size: 13px; line-height: 1;
}
.home-secret-label { font-size: 9px; color: var(--text-2); text-align: center; line-height: 1.2; max-width: 46px; }
.home-secret-rarity {
  font-size: 9px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
}
.rarity-common   { color: var(--text-2); }
.rarity-uncommon { color: #43b581; }
.rarity-rare     { color: #9b84ee; }
.rarity-unique   { color: #ffd700; }

/* ── Banner crop modal ───────────────────────────────────────────────────────── */
.banner-crop-box { max-width: 860px; width: 92vw; }
.banner-crop-viewport {
  position: relative; width: 100%; aspect-ratio: 900/280;
  background: #000; overflow: hidden; border-radius: 8px;
  cursor: grab; user-select: none;
}
.banner-crop-viewport:active { cursor: grabbing; }
#banner-crop-img {
  position: absolute; transform-origin: top left;
  pointer-events: none; max-width: none;
}
/* Dark vignette outside the crop rectangle */
.banner-crop-overlay {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 9999px rgba(0,0,0,.55);
}
.banner-crop-rect {
  position: absolute; inset: 0; pointer-events: none;
  border: 2px solid rgba(255,255,255,.7);
  box-shadow: none;
}
.banner-crop-hint {
  font-size: 12px; color: var(--text-2); margin-top: 8px; text-align: center;
}

/* ── Space home ──────────────────────────────────────────────────────────────── */
#space-home {
  display: flex; flex-direction: column; height: 100%;
  overflow-y: auto; position: relative; z-index: 1;
}
.space-home-banner {
  height: 180px; flex-shrink: 0; position: relative;
  background: linear-gradient(135deg, var(--accent)44 0%, var(--bg-2) 100%);
  /* Dark fade at the bottom so the overlapping header stays readable */
}
.space-home-banner::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,.45) 100%);
  pointer-events: none;
}
.space-home-banner-edit {
  position: absolute; bottom: 10px; right: 12px; z-index: 2;
  background: rgba(0,0,0,.6); color: #fff; font-size: 13px;
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
  transition: background .15s;
}
.space-home-banner-edit:hover { background: rgba(0,0,0,.85); }
.space-home-body { padding: 0 28px 36px; }
.space-home-header {
  display: flex; align-items: flex-end; gap: 18px;
  margin-top: -56px; margin-bottom: 24px;
  position: relative; z-index: 1;
}
.space-home-icon {
  width: 100px; height: 100px; border-radius: 18px;
  background: var(--bg-3); border: 4px solid var(--bg-1);
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; flex-shrink: 0; overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.space-home-icon img { width: 100%; height: 100%; object-fit: cover; }
.space-home-banner-title {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  left: 24px; right: 80px; z-index: 2;
  margin: 0; font-size: 24px; font-weight: 800;
  color: #fff; letter-spacing: -.3px;
  text-shadow: 0 2px 12px rgba(0,0,0,.8);
}
.space-home-meta {
  flex: 1; min-width: 0;
  padding: 6px 0 6px 4px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.space-home-desc {
  color: var(--text); font-size: 14px;
  margin: 0 0 6px; line-height: 1.5;
}
#btn-space-home-edit-desc { align-self: flex-start; }
.space-home-desc-edit {
  width: 100%; background: var(--bg-3); border: 1px solid var(--accent);
  border-radius: 6px; color: var(--text-1); font-size: 14px;
  padding: 6px 8px; resize: vertical; margin-bottom: 6px;
  font-family: inherit;
}
.space-home-announcements { margin-top: 8px; }
.space-home-ann-header {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 12px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.space-home-ann-form {
  background: var(--bg-2); border-radius: 8px;
  padding: 12px; margin-bottom: 12px; border: 1px solid var(--border);
}
.space-home-ann-form textarea {
  width: 100%; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-1); font-size: 14px;
  padding: 8px 10px; resize: vertical; font-family: inherit;
  box-sizing: border-box;
}
.space-home-ann-form-actions {
  display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end;
}
.space-home-ann-card {
  background: var(--bg-2); border-radius: 10px; padding: 14px 16px;
  margin-bottom: 10px; border: 1px solid var(--border);
  transition: border-color .15s;
}
.space-home-ann-card:hover { border-color: var(--accent)66; }
.space-home-ann-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; font-size: 13px;
}
.space-home-ann-author { font-weight: 600; color: var(--accent); }
.space-home-ann-time { color: var(--text-3); font-size: 12px; }
.space-home-ann-del {
  margin-left: auto; opacity: 0; font-size: 12px;
  transition: opacity .15s; color: var(--text-3);
}
.space-home-ann-card:hover .space-home-ann-del { opacity: 1; }
.space-home-ann-del:hover { color: #f04747; }
.space-home-ann-content {
  color: var(--text-1); font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.space-home-ann-empty {
  color: var(--text-3); font-size: 14px;
  text-align: center; padding: 24px 0;
}
.ann-footer {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px; margin-top: 10px; position: relative;
}
.ann-reactions { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.ann-reaction-pill {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 12px; padding: 2px 8px; font-size: 13px;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.ann-reaction-pill:hover { background: var(--bg-hover); border-color: var(--accent)66; }
.ann-reaction-pill.reacted {
  background: var(--accent)22; border-color: var(--accent)88; color: var(--accent);
}
.ann-react-add {
  font-size: 13px; padding: 2px 6px; opacity: 0;
  transition: opacity .15s; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-3);
}
.space-home-ann-card:hover .ann-react-add,
.space-event-card:hover .ann-react-add { opacity: 1; }
.ann-react-picker {
  position: absolute; bottom: calc(100% + 4px); left: 0;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 8px; display: flex; gap: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); z-index: 10;
}
.ann-react-quick {
  font-size: 18px; background: none; border: none; cursor: pointer;
  padding: 2px 4px; border-radius: 6px; transition: background .1s;
}
.ann-react-quick:hover { background: var(--bg-3); }
.ann-footer-actions { display: flex; gap: 6px; align-items: center; }
.ev-comments-toggle,
.ann-comments-toggle {
  font-size: 12px; color: var(--text-3); background: none;
  border: none; cursor: pointer; padding: 2px 6px; border-radius: 8px;
  transition: color .12s, background .12s;
}
.ev-comments-toggle:hover,
.ann-comments-toggle:hover { color: var(--text-1); background: var(--bg-3); }
.ev-comments-section { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.ann-comments-section {
  margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px;
}
.ann-comments-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.ann-comment {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  font-size: 13px; padding: 4px 0;
}
.ann-comment:hover .ann-comment-del { opacity: 1; }
.ann-comment-author { font-weight: 600; color: var(--accent); flex-shrink: 0; }
.ann-comment-content { color: var(--text-1); flex: 1; word-break: break-word; }
.ann-comment-time { color: var(--text-3); font-size: 11px; flex-shrink: 0; }
.ann-comment-del {
  font-size: 11px; color: var(--text-3); opacity: 0;
  background: none; border: none; cursor: pointer; padding: 0 2px;
  transition: opacity .12s; flex-shrink: 0;
}
.ann-comment-del:hover { color: #f04747; }
.ann-comment-input-row { display: flex; }
.ann-comment-input {
  flex: 1; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-1); font-size: 13px;
  padding: 6px 10px; font-family: inherit;
}
.ann-comment-input:focus { border-color: var(--accent); outline: none; }
.ann-no-comments { color: var(--text-3); font-size: 13px; text-align: center; padding: 8px 0; }

#chat-active { display: flex; flex-direction: column; height: 100%; position: relative; z-index: 1; }

/* Chat header */
#chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-soft);
  min-height: 62px;
  position: relative; z-index: 10;
}
.back-btn { display: none; }
.chat-peer-info { flex: 0 0 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
.chat-peer-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.chat-peer-av {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--av-color, var(--bg-3)); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; overflow: hidden; color: #fff;
}
#chat-peer-name { font-weight: 700; font-size: 15px; display: block; }
.peer-status { font-size: 11px; color: var(--text-3); }
.peer-status-online  { color: #43b581; }
.peer-status-away    { color: #faa61a; }
.peer-status-busy    { color: #f04747; }
.peer-status-offline { color: var(--text-3); }
.chat-actions-peer { display: flex; gap: 4px; align-items: center; flex: 1; }
.chat-actions { display: flex; gap: 4px; }

/* ── Messages ──────────────────────────────────────────────────────────────── */
.messages-list {
  flex: 1; overflow-y: auto;
  padding: 8px 0 48px;
  display: flex;
  flex-direction: column;
}

.msg-date-sep {
  text-align: center; font-size: 11px;
  color: var(--text-3); padding: 14px 16px 6px;
  display: flex; align-items: center; gap: 10px;
  letter-spacing: .05em; text-transform: uppercase;
  font-weight: 500;
}
.msg-date-sep::before, .msg-date-sep::after {
  content: ''; flex: 1; border-top: 1px solid var(--border-soft);
}

.msgs-sentinel {
  height: 32px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-3); letter-spacing: .04em;
}

/* "New messages" unread separator — red, Discord-style */
.msg-unread-sep {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px;
  font-size: 11px; font-weight: 600;
  color: #ed4245; letter-spacing: .04em;
}
.msg-unread-sep::before, .msg-unread-sep::after {
  content: ''; flex: 1; border-top: 1px solid #ed424566;
}
.msg-unread-sep span { flex-shrink: 0; }

/* ── Message rows — Discord-style, all left-aligned ── */
@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 2px 16px;
  width: 100%;
  box-sizing: border-box;
  transition: background .1s;
}
.msg-row.out { border-left: 3px solid rgba(99, 84, 220, 0.3); padding-left: calc(16px - 3px); }
.msg-row:hover { background: rgba(255,255,255,.04); }
.msg-row.group-start { margin-top: 18px; }
.msg-row.group-mid,
.msg-row.group-end   { margin-top: 1px; }

/* ── Avatar ── */
.msg-avatar-sm {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--av-color, var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  margin-top: 2px;
}
.msg-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
/* Non-group-start: hide avatar, indent with padding instead */
.msg-row.group-mid .msg-avatar-sm,
.msg-row.group-end .msg-avatar-sm { display: none; }
.msg-row.group-mid,
.msg-row.group-end { padding-left: calc(16px + 40px + 14px); }

/* ── Bubble = content wrapper (no background) ── */
.msg-bubble {
  flex: 1;
  min-width: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  position: relative;
}

/* ── Header: name + time ── */
.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
  line-height: 1;
}
.msg-sender {
  font-size: 14px;
  font-weight: 600;
  color: var(--av-color, var(--accent));
}
.msg-header .msg-time {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}
.msg-header .msg-status { font-size: 11px; color: var(--text-3); }

/* ── Message text ── */
.msg-text {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
  display: block;
}

/* ── Meta: tick + burn timer (below text) ── */
.msg-meta {
  display: flex; align-items: center; gap: 5px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-3);
}
.msg-meta:empty { display: none; }
.msg-status { font-size: 11px; color: var(--text-3); }
.msg-status.read { color: var(--accent); }
.msg-edited { font-size: 10px; color: var(--text-3); font-style: italic; }

/* Ephemeral */
.msg-bubble.ephemeral .msg-text { color: var(--gold); }
.msg-burn-timer {
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
}

/* Reply */
.msg-reply {
  background: var(--bg-3);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 5px 10px;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: background .1s;
}
.msg-reply:hover { background: var(--bg-hover); border-left-color: var(--accent-2); }

/* Link / URL preview card */
.msg-preview-card {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2);
  max-width: 340px;
  transition: opacity .15s;
}
.msg-preview-card:hover { opacity: .88; }
.msg-preview-thumb {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  background: var(--bg-3);
}
.msg-preview-video {
  position: relative;
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  cursor: pointer;
}
.msg-preview-video img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; opacity: .8;
}
.msg-preview-play {
  position: relative;
  z-index: 1;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: #fff;
  pointer-events: none;
}
.msg-preview-iframe {
  display: block;
  width: 100%;
  height: 200px;
  border: none;
}
.msg-preview-body {
  padding: 8px 12px 10px;
}
.msg-preview-site {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 3px;
}
.msg-preview-site img { border-radius: 2px; }
.msg-preview-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-preview-desc {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Inline image in message bubble */
.msg-img-wrap {
  margin-top: 6px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 280px;
  position: relative;
}
.img-ttl-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 11px; font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,.55);
  padding: 3px 8px;
  border-radius: 0 0 10px 10px;
  text-align: center;
  backdrop-filter: blur(4px);
}
.msg-img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 10px;
}

/* Image lightbox */
.img-lightbox {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.img-lightbox-img {
  max-width: 92vw; max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}

/* ─── Voice message bubble ─────────────────────────────────────────────────── */
/* ── Weather card ─────────────────────────────────────────────────────────── */
.weather-card {
  width: min(300px, 100%);
  background: linear-gradient(145deg, #1a1a3a 0%, #0f0f25 100%);
  border: 1px solid rgba(124, 106, 247, 0.2);
  border-radius: 16px;
  overflow: hidden;
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.wc-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.wc-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wc-city {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
}
.wc-country {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  margin-left: 5px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.wc-temp {
  font-size: 52px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -2px;
  margin-top: 6px;
}
.wc-unit {
  font-size: 22px;
  font-weight: 400;
  color: var(--text-2);
  letter-spacing: 0;
}
.wc-desc {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}
.wc-feels {
  font-size: 11px;
  color: var(--text-3);
}
.wc-icon {
  font-size: 56px;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(124,106,247,0.3));
  flex-shrink: 0;
}

.wc-stats {
  display: flex;
  gap: 16px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-2);
}

.wc-forecast {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wc-day {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 4px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.wc-day:last-child { border-bottom: none; }
.wc-day-name {
  width: 44px;
  color: var(--text-2);
  font-weight: 500;
}
.wc-day-icon { font-size: 15px; flex: 1; }
.wc-day-range { color: var(--text); }
.wc-day-range b { font-weight: 600; margin-right: 4px; }
.wc-day-range em { font-style: normal; color: var(--text-2); }

.msg-row.out .weather-card {
  background: linear-gradient(145deg, #1e1a42 0%, #130f2a 100%);
}

/* ── Weather help modal ───────────────────────────────────────────────────── */
.wh-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: wh-fade-in .15s ease;
}
@keyframes wh-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.wh-modal {
  background: var(--bg-2);
  border: 1px solid var(--border-glow);
  border-radius: 18px;
  padding: 28px 28px 24px;
  width: min(480px, 92vw);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(124,106,247,0.1);
  animation: wh-slide-up .18s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@keyframes wh-slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.wh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wh-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.3px;
}
.wh-close {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.wh-close:hover { color: var(--text); background: var(--bg-hover); }

.wh-subtitle {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}
.wh-subtitle b { color: var(--accent); font-weight: 600; }

.wh-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-3);
}
.wh-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
}
.wh-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.wh-row:last-child { border-bottom: none; }
.wh-row code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--accent);
  background: rgba(124,106,247,0.1);
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.wh-row span {
  font-size: 12px;
  color: var(--text-2);
}

.wh-examples {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wh-example {
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  color: var(--text-2);
  padding: 7px 12px;
  background: var(--bg-1);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.wh-example::before { content: '› '; color: var(--accent); font-weight: 700; }

/* ── Hourly weather card ──────────────────────────────────────────────────── */
.weather-card-hourly { width: min(340px, 100%); }

.wc-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--accent);
  margin-top: 2px;
}
.wc-range {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-top: 6px;
}
.wc-range b { font-weight: 800; margin-right: 6px; }
.wc-range em { font-style: normal; color: var(--text-2); font-size: 18px; }

.wc-hourly-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(124,106,247,.3) transparent;
}
.wc-hourly-strip::-webkit-scrollbar { height: 3px; }
.wc-hourly-strip::-webkit-scrollbar-thumb { background: rgba(124,106,247,.3); border-radius: 2px; }

.wc-hour {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 48px;
  padding: 8px 4px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  flex-shrink: 0;
}
.wc-hour-now {
  background: rgba(124,106,247,0.15);
  border-color: rgba(124,106,247,0.3);
}
.wc-hour-label {
  font-size: 10px;
  color: var(--text-2);
  font-weight: 500;
}
.wc-hour-now .wc-hour-label { color: var(--accent); font-weight: 700; }
.wc-hour-icon { font-size: 18px; }
.wc-hour-temp {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.wc-hour-precip {
  font-size: 9px;
  color: var(--text-2);
  min-height: 12px;
}

/* ── Voice message ────────────────────────────────────────────────────────── */
.msg-voice-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  max-width: 320px;
  padding: 8px 4px 4px;
}
.voice-play-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.voice-play-btn:hover { opacity: .85; }
.voice-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.voice-progress-wrap {
  height: 4px;
  background: rgba(255,255,255,.15);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
}
.voice-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .1s linear;
}
.voice-time {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: .02em;
}
.voice-speed-btn {
  flex-shrink: 0;
  width: 32px; height: 22px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  color: var(--text-2);
  background: var(--bg-hover);
}
.voice-speed-btn:hover { color: var(--accent); }
.voice-ttl-label {
  font-size: 10px;
  color: var(--gold);
  white-space: nowrap;
}

/* ─── Voice recording bar (compose) ───────────────────────────────────────── */
.voice-record-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 6px 4px;
}
.voice-rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #e74c3c;
  animation: voicePulse 1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes voicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}
.voice-rec-timer {
  font-size: 14px; font-weight: 600;
  color: var(--text);
  min-width: 36px;
}
.voice-rec-label {
  flex: 1;
  font-size: 13px;
  color: var(--text-3);
}
.voice-stop-btn {
  flex-shrink: 0;
  color: #e74c3c;
}
.voice-stop-btn:hover { background: rgba(231,76,60,.12); }

/* ─── Voice preview bar (compose, before send) ─────────────────────────────── */
.voice-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 6px 4px;
  background: var(--bg-hover);
  border-radius: 12px;
}
.voice-preview-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.voice-preview-progress-wrap {
  height: 4px;
  background: rgba(255,255,255,.15);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
}
.voice-preview-progress {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .1s linear;
}
.voice-preview-dur {
  font-size: 11px;
  color: var(--text-3);
}

/* System */
.msg-system {
  text-align: center; font-size: 12px;
  color: var(--text-3); padding: 4px 0;
}

/* Typing */
.typing-indicator {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 14px;
  margin-left: 70px;
  width: fit-content;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typingBounce 1.3s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Reply preview (above compose) ── */
#reply-preview {
  margin: 0 16px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--bg-3);
  border-radius: 0 8px 8px 0;
  display: flex; align-items: center;
}
#reply-preview.hidden { display: none; }
.reply-preview-inner {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; gap: 8px;
}
.reply-preview-text {
  font-size: 12.5px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}

/* ── Message action bar (hover) ── */
.msg-row { position: relative; }
.msg-actions {
  position: absolute; right: 10px; top: -18px;
  display: flex; gap: 2px;
  opacity: 0; pointer-events: none;
  transition: opacity .12s;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 5px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.msg-row:hover .msg-actions { opacity: 1; pointer-events: auto; }
.msg-action-btn {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--text-2);
  padding: 2px 5px; border-radius: 4px; line-height: 1;
}
.msg-action-btn:hover { background: var(--bg-3); color: var(--text); }
.msg-action-del:hover    { background: var(--danger-soft); color: var(--danger); }
.msg-action-report:hover { background: var(--danger-soft); color: var(--danger); }

/* Report modal */
.report-reason-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.12s;
}
.report-reason-opt:hover { background: var(--bg-3); }
.report-reason-opt input { accent-color: var(--accent); cursor: pointer; }

/* inline URL links */
.msg-link { color: var(--accent-2); text-decoration: underline; word-break: break-all; }
.msg-link:hover { opacity: .8; }

/* @mention */
.msg-mention        { color: var(--accent-2); font-weight: 600; }
.msg-mention.mine   { background: rgba(124,106,247,.18); border-radius: 3px; padding: 0 2px; color: var(--accent-2); }
.msg-mention-row    { border-left: 3px solid var(--accent); padding-left: 6px; margin-left: -9px; }

/* Mention autocomplete dropdown */
.mention-dropdown {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  background: var(--bg-2); border: 1px solid var(--border-glow);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 -4px 20px rgba(0,0,0,.4);
  max-height: 220px; overflow-y: auto;
}
.mention-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; cursor: pointer; transition: background .1s;
}
.mention-item:hover, .mention-item.active { background: var(--bg-hover); }
.mention-name   { font-weight: 600; font-size: 14px; color: var(--text); }
.mention-handle { font-size: 12px; color: var(--text-2); }
.mention-all-badge { color: var(--accent-2); font-weight: 600; }

/* Reactions */
.msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px; padding: 0 2px;
}
.reaction-pill {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 2px 8px;
  font-size: 13px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; gap: 4px;
  transition: background .12s, border-color .12s;
}
.reaction-pill:hover { background: var(--bg-hover); border-color: var(--accent-2); }
.reaction-pill span { font-size: 11px; color: var(--text-2); }
.reaction-picker {
  position: fixed; z-index: 400;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px;
  display: flex; gap: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.reaction-picker.hidden { display: none; }
.reaction-picker button {
  background: none; border: none; cursor: pointer;
  font-size: 22px; padding: 4px 6px; border-radius: 8px;
  transition: background .1s, transform .1s;
}
.reaction-picker button:hover { background: var(--bg-hover); transform: scale(1.2); }
.reaction-picker-more {
  font-size: 16px !important; font-weight: 700; color: var(--text-2) !important;
  padding: 4px 8px !important; transform: none !important;
}
.reaction-picker-more:hover { color: var(--text) !important; transform: scale(1.05) !important; }

/* Full emoji picker floating (for reaction "+") */
.react-full-picker {
  position: fixed; z-index: 500;
  width: 280px; max-height: 230px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  animation: scaleIn .12s ease;
}
.react-full-picker .emoji-cat-bar { padding: 4px 6px; border-bottom: 1px solid var(--border); }
.react-full-picker .emoji-grid { padding: 4px 6px 6px; overflow-y: auto; flex: 1; }

/* "+" button in ann/event reaction picker */
.ann-react-more {
  background: none; border: none; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--text-2);
  padding: 2px 6px; border-radius: 6px;
  transition: background .1s, color .1s;
}
.ann-react-more:hover { background: var(--bg-hover); color: var(--text); }

/* Inline message edit */
.msg-edit-input {
  width: 100%; min-width: 200px;
  background: var(--bg-1); color: var(--text);
  border: 1px solid var(--accent); border-radius: 6px;
  padding: 5px 8px; font-size: 14px; font-family: inherit;
  resize: vertical; outline: none;
}
.msg-edit-actions {
  display: flex; gap: 6px; margin-top: 5px;
}
.msg-edit-save {
  background: var(--accent); color: #fff;
  border: none; border-radius: 5px;
  padding: 3px 12px; font-size: 12px; cursor: pointer;
}
.msg-edit-cancel {
  background: var(--bg-3); color: var(--text-2);
  border: none; border-radius: 5px;
  padding: 3px 12px; font-size: 12px; cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMPOSE
   ═══════════════════════════════════════════════════════════════════════════ */
#compose {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
  position: relative; z-index: 1;
}

/* Wrapper that holds textarea + emoji button */
.msg-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

/* Picker anchored inside the wrap */
.msg-input-wrap .media-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0; left: auto;
}

/* Emoji button inside the textarea */
.msg-emoji-btn {
  position: absolute;
  right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 19px;
  background: none; border: none; cursor: pointer;
  line-height: 1; padding: 2px;
  border-radius: 6px;
  transition: transform .12s, opacity .12s;
  opacity: .65; z-index: 2;
}
.msg-emoji-btn:hover { opacity: 1; transform: translateY(-50%) scale(1.15); }
.msg-mic-btn {
  position: absolute;
  right: 46px; top: 50%; transform: translateY(-50%);
  font-size: 17px;
  background: none; border: none; cursor: pointer;
  line-height: 1; padding: 2px;
  border-radius: 6px;
  transition: transform .12s, opacity .12s;
  opacity: .55; z-index: 2;
}
.msg-mic-btn:hover { opacity: 1; transform: translateY(-50%) scale(1.12); }
.msg-mic-btn.recording { opacity: 1; color: #e74c3c; animation: voicePulse 1s ease-in-out infinite; }

#msg-input {
  flex: 1; width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 11px 76px 11px 16px; /* right: room for mic + emoji */
  resize: none;
  max-height: 140px; overflow-y: auto;
  line-height: 1.45; font-size: 14.5px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
#msg-input:focus {
  border-color: var(--accent);
  background: rgba(124,106,247,.06);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-send {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 50%;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: transform .12s, box-shadow .2s, opacity .15s;
}
.btn-send:hover  { transform: scale(1.06); box-shadow: 0 6px 24px var(--accent-glow); }
.btn-send:active { transform: scale(.92); }
.btn-send svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Ephemeral picker */
.ephemeral-btn.active { color: var(--gold); }
.ephemeral-menu {
  position: absolute;
  bottom: calc(100% + 8px); left: 56px;
  background: var(--bg-2);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow), var(--glow);
  overflow: hidden;
  display: flex; flex-direction: column;
  z-index: 10;
  backdrop-filter: blur(16px);
  animation: scaleIn .15s ease;
}
.ephemeral-menu-header {
  padding: 8px 16px 4px;
  font-size: 10px; font-weight: 700;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .08em;
}
.ephemeral-menu button {
  padding: 9px 22px; text-align: left;
  font-size: 13px; color: var(--text-2);
  transition: background .1s, color .1s;
  width: 100%;
}
.ephemeral-menu button:hover { background: var(--bg-hover); color: var(--text); }
.ephemeral-menu button.selected { color: var(--gold); font-weight: 600; background: rgba(244,185,66,.06); }

/* Attachment preview bar (shows above compose when file/image is pending) */
.attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
}
.attach-preview-thumb {
  width: 40px; height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}
.attach-preview-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--text-1);
}

/* Select field */
.select-field {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 15px; padding-right: 36px;
  color: var(--text); outline: none; width: 100%;
  cursor: pointer; font-size: 14px; font-family: var(--font);
  transition: border-color .2s; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b88b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.select-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select-field option { background: #1a1a2e; color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════════════
   SIDE PANELS
   ═══════════════════════════════════════════════════════════════════════════ */
.side-panel {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 360px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  border-left: 1px solid var(--border-glow);
  box-shadow: var(--shadow), var(--glow);
  display: flex; flex-direction: column;
  z-index: 50;
  animation: slideIn .22s cubic-bezier(.25,.46,.45,.94);
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-header h2 { font-size: 17px; font-weight: 700; }

/* ── Inbox main panel (fills #chat-panel like wiki-panel) ───────────────── */
.inbox-main-panel {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
  position: relative; z-index: 1;
  background: var(--bg);
}
.inbox-main-topbar {
  display: flex; align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.inbox-main-topbar h2 { font-size: 17px; font-weight: 700; }

/* ── Inbox tabs (Drops / Email) ─────────────────────────────────────────── */
.inbox-tabs { gap: 4px; }
.inbox-tab {
  background: transparent; border: none; color: var(--text-3);
  padding: 10px 16px; cursor: pointer; font-size: .9em; font-weight: 500;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
  display: flex; align-items: center; gap: 6px;
}
.inbox-tab:hover { color: var(--text); }
.inbox-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.inbox-tab-count {
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 600;
  border-radius: 10px; padding: 1px 6px; min-width: 16px; text-align: center;
}
.inbox-tabpane.hidden { display: none; }
.inbox-card.inbox-card-email { border-left: 3px solid var(--accent); padding-left: 11px; }
.inbox-email-address:hover { text-decoration: underline; }

/* ── Inbox share link card ──────────────────────────────────────────────── */
.inbox-share-card {
  display: flex; align-items: center; gap: 12px;
  margin: 12px 16px 4px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(108,92,231,.10) 0%, rgba(0,209,178,.06) 100%);
  border: 1px solid rgba(108,92,231,.25);
  border-radius: 12px;
  flex-shrink: 0;
}
.inbox-share-card-icon { font-size: 22px; flex-shrink: 0; }
.inbox-share-card-body { flex: 1; min-width: 0; }
.inbox-share-card-title { font-size: 13px; font-weight: 700; color: var(--text); }
.inbox-share-card-desc  { font-size: 11px; color: var(--text-2); margin-top: 2px; line-height: 1.4; }
.inbox-share-card-btn   { flex-shrink: 0; font-size: 12px; padding: 6px 14px; border-radius: 20px; }

/* ── P2P File Transfer banners ───────────────────────────────────────────── */
#ft-bar {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  width: calc(100vw - 32px);
}
.ft-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-glow);
  box-shadow: var(--shadow);
  animation: scaleIn .18s cubic-bezier(.25,.46,.45,.94);
}
.ft-incoming { border-color: rgba(108,92,231,.4); }
.ft-progress { border-color: rgba(0,209,178,.3); }
.ft-sender   { border-color: rgba(253,203,110,.3); }
.ft-icon     { font-size: 20px; flex-shrink: 0; }
.ft-info     { flex: 1; min-width: 0; }
.ft-name     { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-size     { font-size: 11px; color: var(--text-2); font-weight: 400; margin-left: 4px; }
.ft-status   { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.ft-pct      { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.ft-bar-wrap { height: 4px; background: var(--bg-3); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.ft-bar      { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2, #00d1b2)); border-radius: 2px; transition: width .2s; }
.ft-actions  { display: flex; gap: 6px; flex-shrink: 0; }
.ft-cancel   { font-size: 12px; color: var(--text-2); background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.ft-cancel:hover { background: var(--bg-hover); color: var(--text); }
.btn-ghost-sm { font-size: 12px; padding: 5px 10px; border-radius: 8px; background: var(--bg-3); border: 1px solid var(--border); color: var(--text-2); cursor: pointer; }
.btn-ghost-sm:hover { background: var(--bg-hover); color: var(--text); }

/* DM request banners */
#dm-req-bar { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 0; }
.dm-request-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid rgba(108,92,231,.4);
  box-shadow: var(--shadow);
  animation: scaleIn .18s cubic-bezier(.25,.46,.45,.94);
}
.dm-req-av {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.dm-req-info { flex: 1; min-width: 0; font-size: 13px; }
.dm-req-info strong { display: block; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-req-info span { color: var(--text-2); font-size: 11px; }
.dm-req-btns { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Conversation locked banner (read-only state after contact removal) ────── */
.conv-lock-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; margin: 0 0 0 0;
  background: rgba(108,92,231,.08); border-top: 1px solid rgba(108,92,231,.2);
  color: var(--text-2); font-size: 13px;
}
.conv-lock-banner .lock-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.conv-lock-banner .lock-msg { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.conv-lock-banner .lock-msg strong { color: var(--text); font-size: 13px; }
.conv-lock-banner .lock-msg span { font-size: 12px; line-height: 1.4; }
.conv-lock-banner .lock-actions { display: flex; gap: 6px; flex-shrink: 0; align-self: center; }

/* ── Conversation clear-request banner ──────────────────────────────────────── */
#conv-clear-bar { padding: 6px 12px 0; }
.conv-clear-request-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid rgba(231,76,60,.35);
  animation: scaleIn .18s cubic-bezier(.25,.46,.45,.94);
}
.clear-req-info { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.clear-req-icon { font-size: 16px; flex-shrink: 0; }
.clear-req-info strong { display: block; color: var(--text); }
.clear-req-info span   { color: var(--text-2); font-size: 12px; }
.clear-req-btns { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Wiki panel (fills #chat-panel like #space-home) ─────────────────────── */
.wiki-panel {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
  position: relative; z-index: 1;
  background: var(--bg);
}
.wiki-topbar {
  display: flex; align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.wiki-topbar-title { font-size: 17px; font-weight: 700; margin: 0; }
.wiki-tree-back-btn { display: none; }
.wiki-body { flex: 1; display: flex; overflow: hidden; }

/* ── Notebooks grid ──────────────────────────────────────────────────────── */
.notebooks-view {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 0 20px 24px;
}

/* Tabs */
.nb-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  padding-top: 16px;
  margin-bottom: 20px;
}
.nb-tab {
  background: none; border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2); cursor: pointer;
  transition: color .15s, border-color .15s;
}
.nb-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.nb-tab:hover:not(.active) { color: var(--text); }

.notebooks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
  align-content: start;
}

/* Shared-with-me view */
.nb-shared-view { display: flex; flex-direction: column; gap: 20px; }
.nb-shared-add { display: flex; gap: 8px; }
.nb-share-link-inp {
  flex: 1;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 13px; color: var(--text); outline: none;
}
.nb-share-link-inp:focus { border-color: var(--accent); }
.nb-share-link-btn {
  background: var(--accent); border: none;
  border-radius: var(--radius-sm); padding: 8px 14px;
  font-size: 13px; font-weight: 600; color: #fff;
  cursor: pointer; white-space: nowrap;
  transition: background .15s;
}
.nb-share-link-btn:hover { background: var(--accent-2); }

/* Book card */
.nb-card {
  display: flex;
  height: 250px;
  border-radius: 3px 8px 8px 3px;
  box-shadow: 0 2px 10px rgba(0,0,0,.28);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  overflow: hidden;
  position: relative;
}
.nb-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 22px rgba(0,0,0,.38);
}
.nb-card-spine {
  width: 14px;
  flex-shrink: 0;
  background: #7c5cfc; /* overridden inline per card */
}
.nb-card-body {
  flex: 1;
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  padding: 12px 10px 8px;
  overflow: hidden;
  gap: 4px;
}
.nb-card-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  -webkit-box-orient: vertical;
  color: var(--text-1);
  word-break: break-word;
  flex: 1;
}
.nb-card-count {
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
  margin-bottom: 4px;
}
.nb-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.nb-card-btn {
  background: var(--bg-3);
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.nb-card-btn:hover { background: var(--bg-4, var(--bg-3)); color: var(--text-1); }
.nb-btn-delete:hover { color: var(--danger); }
.nb-btn-share:hover { color: var(--accent); }
.nb-card-shared-badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 9px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 3px; padding: 2px 5px;
}
.nb-card-readonly .nb-card-body { opacity: .9; }
.nb-card-readonly .nb-card-spine { background: var(--text-3) !important; }

/* "+" add card */
.nb-card-add {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-2);
  border: 2px dashed var(--border-soft);
  box-shadow: none;
  border-radius: 8px;
  color: var(--text-3);
  transition: border-color .15s, color .15s, transform .15s;
}
.nb-card-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: none;
}
.nb-add-icon { font-size: 28px; line-height: 1; }
.nb-add-label { font-size: 12px; text-align: center; padding: 0 6px; }

/* Topbar share button */
.nb-topbar-share-btn {
  margin-left: auto;
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.nb-topbar-share-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ── Notebook share modal ──────────────────────────────────────────────────── */
.nb-share-modal-box {
  max-width: 440px;
  width: 100%;
}
.nb-share-modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-soft);
  margin: 14px 0 18px;
}
.nb-share-modal-tab {
  background: none; border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 7px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2); cursor: pointer;
  transition: color .15s, border-color .15s;
}
.nb-share-modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.nb-share-modal-tab:hover:not(.active) { color: var(--text); }
.nb-share-tab-pane { display: flex; flex-direction: column; gap: 14px; }
.nb-share-hint {
  font-size: 12px; color: var(--text-3); margin: 0;
  line-height: 1.5;
}
.nb-share-perm-row {
  display: flex; align-items: center; gap: 12px;
}
.nb-share-perm-label { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.nb-share-perm-btns { display: flex; gap: 4px; }
.nb-perm-btn {
  background: var(--bg-3); border: 1px solid var(--border-soft);
  border-radius: 4px; padding: 4px 10px;
  font-size: 12px; font-weight: 500;
  color: var(--text-2); cursor: pointer;
  transition: all .12s;
}
.nb-perm-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.nb-perm-btn:hover:not(.active) { border-color: var(--text-3); color: var(--text); }
.nb-share-link-row {
  display: flex; gap: 6px; align-items: center;
}
.nb-share-link-out {
  flex: 1;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px;
  font-size: 11px; color: var(--text-2); outline: none;
  font-family: monospace;
}
.nb-action-btn {
  background: var(--bg-3); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 6px 12px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s;
}
.nb-action-btn:hover { background: var(--accent-soft); color: var(--accent); }
.nb-share-link-actions { display: flex; gap: 8px; }
.nb-share-user-inp-row { display: flex; gap: 8px; }
.nb-share-user-inp {
  flex: 1;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 13px; color: var(--text); outline: none;
}
.nb-share-user-inp:focus { border-color: var(--accent); }
.nb-share-user-status { font-size: 12px; color: var(--text-3); min-height: 18px; }
.nb-share-user-status.ok { color: var(--success, #56b6c2); }
.nb-share-user-status.err { color: var(--danger); }
.nb-share-access-list { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.nb-share-access-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--bg-3); border-radius: 6px;
  font-size: 13px;
}
.nb-share-access-item .nb-access-who { flex: 1; color: var(--text-1); font-weight: 500; }
.nb-share-access-item .nb-access-perm {
  font-size: 11px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 3px; padding: 2px 6px;
}
.nb-share-access-item .nb-access-perm.write {
  background: rgba(152,195,121,.15); color: #98c379;
}
.nb-share-access-item .nb-access-revoke {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; font-size: 14px; padding: 0 2px;
  transition: color .12s;
}
.nb-share-access-item .nb-access-revoke:hover { color: var(--danger); }
.nb-share-access-loading { font-size: 12px; color: var(--text-3); }

/* Inline rename input inside card */
.nb-rename-input {
  font-size: 12px;
  font-weight: 600;
  width: 100%;
  background: var(--bg-input, var(--bg-3));
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--text-1);
  padding: 1px 3px;
  outline: none;
}

/* Tree column */
.wiki-tree-col {
  width: 230px; min-width: 160px; flex-shrink: 0;
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; overflow: hidden;
}
.wiki-tree {
  flex: 1; overflow-y: auto;
  padding: 6px 0;
}
.wiki-root-add-btn {
  flex-shrink: 0;
  padding: 10px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--text-1);
  background: none; border: none;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer; text-align: left;
  transition: color .15s, background .15s;
}
.wiki-root-add-btn:hover { color: var(--accent); background: var(--bg-hover); }

/* Tree rows */
.wiki-tree-row {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 8px;
  border-radius: 6px; margin: 1px 4px;
  cursor: pointer; font-size: 13px; color: var(--text-1);
  transition: background .1s;
  position: relative;
}
.wiki-tree-row:hover { background: var(--bg-hover); }
.wiki-tree-row.active { background: rgba(var(--accent-rgb, 120,90,255),.15); color: var(--accent); }
.wiki-tree-toggle {
  flex-shrink: 0; width: 14px;
  font-size: 10px; text-align: center;
  color: var(--text-2); user-select: none;
  cursor: pointer;
}
.wiki-tree-label {
  flex: 1; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px;
}
.wiki-tree-actions { display: none; gap: 2px; flex-shrink: 0; }
.wiki-tree-row:hover .wiki-tree-actions { display: flex; }
.wiki-tree-btn {
  background: none; border: none;
  padding: 2px 5px; font-size: 13px;
  color: var(--text-2); cursor: pointer;
  border-radius: 4px; line-height: 1;
  transition: color .1s, background .1s;
}
.wiki-tree-btn:hover { color: var(--accent); background: rgba(255,255,255,.06); }
.wiki-tree-btn-del:hover { color: var(--danger) !important; background: rgba(255,50,50,.1) !important; }

/* Editor column */
.wiki-editor-col {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  min-width: 0;
}
.wiki-empty-state {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-2); padding: 24px; text-align: center;
}

/* Shared topbar (read + edit modes) */
.wiki-page-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

/* Read mode */
.wiki-view-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.wiki-view-title {
  flex: 1; font-size: 18px; font-weight: 700; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wiki-rendered-content {
  flex: 1; overflow-y: auto;
  padding: 24px 28px;
  font-size: 14px; line-height: 1.8; color: var(--text-1);
}
.wiki-rendered-content h1,.wiki-rendered-content h2,.wiki-rendered-content h3 {
  margin: 1.2em 0 .5em; font-weight: 700; color: var(--text-1);
}
.wiki-rendered-content h1 { font-size: 1.6em; }
.wiki-rendered-content h2 { font-size: 1.3em; }
.wiki-rendered-content h3 { font-size: 1.1em; }
.wiki-rendered-content p  { margin: .8em 0 !important; }
.wiki-rendered-content ul,.wiki-rendered-content ol { padding-left: 1.5em; margin: .6em 0; }
.wiki-rendered-content li { margin: .25em 0; }
.wiki-rendered-content code {
  background: var(--bg-3); border-radius: 4px; padding: 2px 6px;
  font-size: 13px; font-family: monospace;
}
.wiki-rendered-content pre {
  background: var(--bg-3); border-radius: 8px; padding: 14px 16px;
  overflow-x: auto; margin: .8em 0;
}
.wiki-rendered-content pre code { background: none; padding: 0; }
.wiki-rendered-content blockquote {
  border-left: 3px solid var(--accent); margin: .8em 0;
  padding: 6px 16px; color: var(--text-2);
}
.wiki-rendered-content a { color: var(--accent); }
.wiki-rendered-content hr { border: none; border-top: 1px solid var(--border-soft); margin: 1.2em 0; }
.wiki-rendered-content table { border-collapse: collapse; width: 100%; margin: .8em 0; }
.wiki-rendered-content th,.wiki-rendered-content td {
  border: 1px solid var(--border); padding: 6px 12px; text-align: left;
}
.wiki-rendered-content th { background: var(--bg-3); font-weight: 600; }

/* Edit mode */
.wiki-edit-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.wiki-title-input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 17px; font-weight: 700; color: var(--text-1); padding: 0;
}
.wiki-title-input::placeholder { color: var(--text-2); font-weight: 400; }
/* EasyMDE fills remaining space in private wiki */
#wiki-edit-wrap .EasyMDEContainer {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}
#wiki-edit-wrap .CodeMirror {
  flex: 1; height: auto !important; font-size: 14px; min-height: 0;
}
#wiki-edit-wrap .CodeMirror-scroll {
  flex: 1; min-height: 0 !important; height: 100%;
}

/* Inbox view content — keep pre-wrap for newlines */
.modal-note-view-content {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px; line-height: 1.7; color: var(--text);
  min-height: 120px; max-height: 55vh;
  overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  padding: 30px 28px 26px;
  width: 100%; max-width: 800px;
  box-shadow: var(--shadow), var(--glow);
  display: flex; flex-direction: column; gap: 16px;
  animation: scaleIn .18s cubic-bezier(.25,.46,.45,.94);
  position: relative;
  /* Cap to viewport with internal scroll so tall settings modals
     (space settings, profile) don't push the page off-screen. The
     previous `overflow: hidden` meant the whole page scrolled instead
     of the modal, which hid Cancel/Save below the fold. */
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  /* Thin scrollbar so it doesn't dominate the modal visually. */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.modal-box::-webkit-scrollbar { width: 8px; }
.modal-box::-webkit-scrollbar-track { background: transparent; }
.modal-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
.modal-box::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}
.modal-box::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}
@keyframes scaleIn {
  from { transform: scale(.94) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-box h3 { font-size: 18px; font-weight: 800; letter-spacing: -.3px; }

.modal-buttons {
  display: flex; gap: 10px; margin-top: 4px;
  /* Sticky at the bottom of the scrollable modal-box so Cancel/Save
     stay reachable on tall settings modals. The translucent backdrop
     gives a subtle separation from the scrolled content above. */
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg-2) 80%, rgba(0,0,0,0));
  padding-top: 12px;
  margin-left: -28px; margin-right: -28px; padding-left: 28px; padding-right: 28px;
  margin-bottom: -26px; padding-bottom: 22px;
}
.modal-buttons button { flex: 1; }
.modal-confirm-box { max-width: 340px; }
#modal-inbox-view .modal-box { max-width: 1000px; }

/* ── Share space modal ──────────────────────────────────────────────────── */
.modal-share-box { max-width: 360px; }
.share-qr-wrap {
  display: flex; justify-content: center;
  margin: 16px 0;
  padding: 12px;
  background: #11111b;
  border-radius: 12px;
}
.share-qr-wrap canvas { border-radius: 8px; display: block; }
.share-field-group { margin-bottom: 10px; }
.share-field-label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); margin-bottom: 5px;
}
.share-copy-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px;
}
.share-code {
  flex: 1; font-size: 12px; color: var(--text);
  word-break: break-all; font-family: 'Fira Mono', monospace;
  background: none; border: none;
}
.modal-confirm-msg { font-size: 15px; line-height: 1.5; color: var(--text); margin-bottom: 20px; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover { background: #d94060; }

/* Self profile edit modal */
.self-profile-av-wrap { display: flex; justify-content: center; margin: 12px 0 20px; }
.self-profile-av {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--av-color, var(--bg-2)); border: 3px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: #fff; overflow: hidden;
}
.self-profile-av img { width: 100%; height: 100%; object-fit: cover; }

/* Theme picker */
.theme-picker-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.theme-swatch {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer; transition: transform .15s, border-color .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  position: relative;
}
.theme-swatch:hover { transform: scale(1.12); }
.theme-swatch.active { border-color: var(--accent-2); }
.theme-swatch[data-slug="default"]    { background: linear-gradient(135deg, #7c6af7, #080810); }
.theme-swatch[data-slug="neon-green"] { background: linear-gradient(135deg, #00c853, #050f05); }
.theme-swatch[data-slug="crimson"]    { background: linear-gradient(135deg, #e53935, #0f0508); }
.theme-swatch[data-slug="ocean"]      { background: linear-gradient(135deg, #0288d1, #050c14); }
.theme-swatch[data-slug="amber"]      { background: linear-gradient(135deg, #ff8f00, #0e0900); }
.theme-swatch[data-slug="mono"]       { background: linear-gradient(135deg, #cccccc, #080808); }
.theme-swatch[data-slug="pinky"]      { background: linear-gradient(135deg, #ff4da6, #100810); }
.theme-swatch[data-slug="neon-pink"]       { background: linear-gradient(135deg, #ed21ff, #070307); }
.theme-swatch[data-slug="midnight-hacker"] { background: linear-gradient(135deg, #00ff41, #000000); }
.theme-swatch[data-slug="warm-sepia"]      { background: linear-gradient(135deg, #d4956a, #1a1209); }
.theme-swatch[data-slug="ice-white"]       { background: linear-gradient(135deg, #3b6bff, #f5f7fa); }

/* ── Wizz ──────────────────────────────────────────────────────────────────── */
@keyframes wizz-shake {
  0%,100% { transform: translate(0,0) rotate(0); }
  10%     { transform: translate(-10px, 5px) rotate(-1.5deg); }
  20%     { transform: translate(10px, -5px) rotate(1.5deg); }
  30%     { transform: translate(-7px, 6px) rotate(-1deg); }
  40%     { transform: translate(7px, -4px) rotate(1deg); }
  50%     { transform: translate(-4px, 4px) rotate(-.5deg); }
  60%     { transform: translate(4px, -2px) rotate(.5deg); }
  75%     { transform: translate(-2px, 2px); }
  88%     { transform: translate(2px, -1px); }
}
.wizz-shaking { animation: wizz-shake 0.75s cubic-bezier(.36,.07,.19,.97) 4; }

@keyframes wizz-banner-in {
  from { transform: translateY(8px) scale(.88); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.wizz-banner {
  display: block; text-align: center;
  color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: .02em;
  padding: 8px 18px; margin: 10px auto;
  background: var(--accent-soft); border: 1px solid var(--border-glow);
  border-radius: 20px; width: fit-content; max-width: 280px;
  animation: wizz-banner-in 0.28s ease;
  transition: opacity 0.4s;
}
.btn-wizz {
  font-size: 17px; padding: 4px 7px; border-radius: 8px;
  background: none; border: none; cursor: pointer;
  color: var(--text-2); transition: color .15s, transform .15s;
  line-height: 1;
}
.btn-wizz:hover { color: var(--accent); transform: scale(1.15); }

/* ── Pref toggle (checkbox row) ────────────────────────────────────────────── */
.pref-toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  user-select: none;
}
.pref-toggle input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.pref-toggle-label { font-size: 12px; color: var(--text-3); }

/* ── Boutique ─────────────────────────────────────────────────────────────── */
.boutique-panel {
    display: flex; flex-direction: column;
    height: 100%; overflow: hidden;
    position: relative; z-index: 1;
    background: var(--bg);
}
.boutique-topbar {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px 12px; border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}
.boutique-topbar h2 { margin: 0; font-size: 16px; font-weight: 700; }
.boutique-tabs {
    display: flex; gap: 4px; padding: 12px 16px 0; flex-shrink: 0;
    border-bottom: 1px solid var(--border-soft);
}
.boutique-tab {
    padding: 6px 16px; border: none; background: transparent; cursor: pointer;
    font-size: 13px; color: var(--text-3); border-bottom: 2px solid transparent;
    margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.boutique-tab:hover { color: var(--text); }
.boutique-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.boutique-section {
    flex: 1; overflow-y: auto; padding: 16px;
}
.boutique-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    align-items: start;
}
.boutique-section-title {
    grid-column: 1 / -1;
    font-size: 10px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--text-3);
    padding: 12px 2px 4px;
}
.boutique-section-title:first-child { padding-top: 2px; }
.boutique-loading, .boutique-empty {
    color: var(--text-3); font-size: 13px; text-align: center; padding: 40px 0;
}
.boutique-soon {
    color: var(--text-3); font-size: 14px; text-align: center;
    padding: 60px 20px; opacity: .6;
}
/* Card */
.boutique-theme-card {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-2); border: 1px solid var(--border-soft);
    border-radius: 10px; padding: 10px 12px; transition: border-color .15s;
}
.boutique-theme-card:hover  { border-color: var(--border); }
.boutique-theme-card.is-active    { border-color: var(--accent); }
.boutique-theme-card.is-previewing { border-color: var(--accent); border-style: dashed; }
/* Swatch */
.boutique-swatch {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    border: 2px solid var(--border-soft);
}
/* Info */
.boutique-theme-info { flex: 1; min-width: 0; }
.boutique-theme-name {
    font-size: 14px; font-weight: 600; color: var(--text);
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.boutique-theme-desc { font-size: 12px; color: var(--text-3); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Badges */
.boutique-badge {
    font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
    text-transform: uppercase; letter-spacing: .04em; flex-shrink: 0;
}
.boutique-badge-active  { background: var(--accent); color: #000; }
.boutique-badge-preview { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
/* Actions */
.boutique-card-actions {
    display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
}
.boutique-btn-primary, .boutique-btn-secondary {
    font-size: 12px; padding: 5px 13px; border-radius: 6px;
    border: none; cursor: pointer; font-weight: 600; white-space: nowrap;
    transition: opacity .15s;
}
.boutique-btn-primary         { background: var(--accent); color: #000; }
.boutique-btn-primary:hover   { opacity: .85; }
.boutique-btn-remove          { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.boutique-btn-remove:hover    { background: var(--danger); color: #fff; }
.boutique-btn-secondary       { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border-soft); }
.boutique-btn-secondary:hover { border-color: var(--border); color: var(--text); }

/* Profile card modal */
.profile-card { padding: 0; overflow: hidden; min-width: 280px; }
.profile-card-banner {
  height: 70px;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent-2));
  position: relative; flex-shrink: 0;
}
.profile-card-av {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--av-color, var(--bg-2)); border: 3px solid var(--bg-1);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: #fff;
  position: absolute; bottom: -30px; left: 20px;
  overflow: hidden;
}
.profile-card-body { padding: 38px 20px 16px; }
.profile-card-name { font-size: 18px; font-weight: 800; color: var(--text); }
.profile-card-handle { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.profile-card-status { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.profile-card-bio { font-size: 13px; color: var(--text); margin-top: 8px; line-height: 1.5; }
.profile-card-since { font-size: 11px; color: var(--text-3); margin-top: 10px; }
.profile-card-secrets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pc-secret {
  width: 34px; height: 34px; border-radius: 9px; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent; background: var(--bg-2);
}
.pc-secret-common   { border-color: var(--accent-2); background: var(--accent-soft); }
.pc-secret-uncommon { border-color: #43b581; background: rgba(67,181,129,.12); }
.pc-secret-rare     { border-color: #9b84ee; background: rgba(155,132,238,.12); }
.pc-secret-unique   { border-color: #ffd700; background: rgba(255,215,0,.12); box-shadow: 0 0 6px rgba(255,215,0,.2); }
.pc-secret-gold     { border-color: #ffd700; background: rgba(255,215,0,.15); box-shadow: 0 0 8px rgba(255,215,0,.3); }
.profile-card .modal-buttons { padding: 0 20px 16px; margin: 0; }

/* Call modal */
#modal-call .modal-box { text-align: center; padding: 40px 28px; }

/* Pinned messages modal */
.modal-pinned-box {
    padding: 0;
    max-width: 520px;
    width: 100%;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-pinned-box .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-2); font-size: 18px; line-height: 1;
    padding: 4px 6px; border-radius: 4px;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.pinned-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
}
.pinned-empty {
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
    padding: 32px 20px;
}
.pinned-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-soft);
    transition: background .12s;
}
.pinned-item:last-child { border-bottom: none; }
.pinned-item:hover { background: var(--bg-hover); }
.pinned-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.pinned-sender { font-weight: 700; font-size: 13px; color: var(--text); }
.pinned-time   { font-size: 11px; color: var(--text-3); flex: 1; }
.pinned-unpin-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-3); font-size: 14px; padding: 2px 5px;
    border-radius: 4px; line-height: 1;
}
.pinned-unpin-btn:hover { background: var(--bg-hover); color: var(--danger); }
.pinned-item-body {
    font-size: 14px;
    color: var(--text);
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
.pinned-item-footer {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-3);
}
/* Space settings members list */
.space-members-manage-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 10px;
}
.space-members-manage-list .group-member-chip {
    border-radius: 8px;
    padding: 5px 8px 5px 12px;
}
.chip-role-badge {
    font-size: 10px;
    opacity: .65;
    margin-left: 2px;
    white-space: nowrap;
}
/* Group members in conv-settings */
.group-members-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.group-member-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-3);
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    padding: 3px 8px 3px 10px;
    font-size: 12px;
    color: var(--text);
}
.chip-kick-btn, .chip-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    font-size: 11px;
    line-height: 1;
    padding: 1px 3px;
    border-radius: 3px;
}
.chip-kick-btn:hover { color: var(--danger); background: rgba(237,66,69,.1); }
.chip-action-btn:hover { color: var(--accent-2); background: rgba(124,106,247,.12); }
.add-member-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    position: relative;
}
.add-member-row input {
    flex: 1;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-soft);
    background: var(--bg-3);
    color: var(--text);
    font-size: 13px;
}
.btn-sm { padding: 7px 14px; font-size: 13px; }
.add-member-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 48px;
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    overflow: hidden;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.add-member-suggestion {
    padding: 9px 12px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}
.add-member-suggestion:hover { background: var(--bg-hover); }

/* Flash highlight when jumping to a pinned message */
.msg-highlight {
    animation: _msg-pin-flash .6s ease 2;
}
@keyframes _msg-pin-flash {
    0%, 100% { background: transparent; }
    50%       { background: rgba(124,106,247,.18); }
}
#call-modal-from { font-size: 30px; font-weight: 800; margin: 8px 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   ACCOUNT PAGE
   ═══════════════════════════════════════════════════════════════════════════ */
body.page-account {
  overflow: auto;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 48px 16px;
  min-height: 100vh;
  background: var(--bg);
}
body.page-account::after {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,106,247,.12) 0%, transparent 60%);
  pointer-events: none; z-index: 0;
}

.account-wrap {
  position: relative; z-index: 1;
  width: 100%; max-width: 520px;
  display: flex; flex-direction: column; gap: 10px;
}

.account-header { margin-bottom: 20px; }
.account-header h1 { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.back-link { font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; transition: color .15s; }
.back-link:hover { color: var(--text); text-decoration: none; }

.account-section {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 24px;
  display: flex; flex-direction: column; gap: 14px;
  backdrop-filter: blur(16px);
  transition: border-color .2s;
}
.account-section:hover { border-color: var(--border-glow); }
.account-section h2 {
  font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .08em;
}

/* ── Account page redesign ───────────────────────────────────────────────── */
.acc-section-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .08em;
}

.acc-field-label {
  display: block;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  margin-bottom: 6px;
}
.acc-field-hint-inline {
  font-size: 11px; font-weight: 400; color: var(--text-3);
}
.acc-field-hint {
  font-size: 12px; color: var(--text-3); margin-top: 5px;
}
.acc-field-hint.danger { color: var(--danger); }

.acc-input {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
}
.acc-input:focus { border-color: var(--accent); }
.acc-textarea { resize: vertical; min-height: 72px; font-family: inherit; }

.acc-btn-sm {
  padding: 7px 14px !important;
  font-size: 13px !important;
  border-radius: 8px !important;
}

.acc-identity-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 480px) {
  .acc-identity-row { grid-template-columns: 1fr; }
}

.acc-handle-locked {
  display: flex; align-items: center; gap: 8px;
}
.acc-handle-text {
  font-size: 17px; font-weight: 700; color: var(--text);
  font-family: var(--mono); letter-spacing: .02em;
}
.acc-handle-lock { font-size: 14px; opacity: .5; }

.acc-handle-input-row {
  display: flex; align-items: center; gap: 6px;
}
.acc-handle-prefix {
  font-size: 16px; font-weight: 600; color: var(--text-2);
  flex-shrink: 0;
}
.acc-handle-input-row .acc-input { margin: 0; }

.acc-id-row {
  display: flex; align-items: center; gap: 8px;
}
.acc-account-code {
  font-family: var(--mono); font-size: 14px; font-weight: 700;
  letter-spacing: 2px; color: var(--text);
  background: rgba(255,255,255,.04);
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.acc-copy-btn { flex-shrink: 0; }

.acc-profile-card { display: flex; flex-direction: column; }
.acc-avatar-row { display: flex; align-items: center; gap: 16px; }
.acc-avatar-actions { display: flex; flex-direction: column; gap: 6px; }

.acc-card { display: flex; flex-direction: column; gap: 6px; }
.acc-danger-card { flex-direction: row; gap: 10px; flex-wrap: wrap; }
.acc-muted { font-size: 13px; color: var(--text-3); }

.account-number-card { display: flex; flex-direction: column; gap: 8px; }
.account-number-card label { font-size: 13px; color: var(--text-2); }
.account-number-row { display: flex; align-items: center; gap: 10px; }
.account-number-row code {
  font-family: var(--mono); font-size: 22px; font-weight: 700;
  letter-spacing: 3px; color: var(--text);
  background: rgba(255,255,255,.04);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.account-hint { font-size: 12.5px; color: var(--text-3); }

.field-row { display: flex; gap: 10px; align-items: flex-end; }
.field-row input { flex: 1; }
.field-row .btn-primary { white-space: nowrap; height: 42px; }
.profile-edit-av-row { display: flex; align-items: center; gap: 16px; }
.profile-edit-av {
  width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-2); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: var(--text);
  overflow: hidden;
}
.profile-edit-av-actions { display: flex; flex-direction: column; gap: 6px; }

.subscription-card {
  background: rgba(124,106,247,.06);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  padding: 18px;
  display: flex; flex-direction: column; gap: 10px; min-height: 80px;
  justify-content: center;
}

.tier-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 700; width: fit-content;
}
.tier-badge.free { background: var(--bg-3); color: var(--text-2); }
.tier-badge.paid {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-glow);
}

/* Recovery phrase words display */
.recovery-phrase-box {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 14px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--border);
}
.recovery-word {
  padding: 4px 12px; border-radius: 16px;
  background: var(--bg-3); color: var(--text-1);
  font-family: monospace; font-size: .9rem; font-weight: 600;
  border: 1px solid var(--border);
}
.btn-danger-ghost {
  color: var(--danger); border-color: var(--danger);
}
.btn-danger-ghost:hover { background: rgba(var(--danger-rgb, 220,50,50),.08); }

/* ── Subscription upgrade UI ── */
.sub-tier-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.sub-plan-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.sub-plan-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft); background: var(--bg-2);
  color: var(--text-1); cursor: pointer; text-align: left; transition: border-color .15s, background .15s;
}
.sub-plan-btn strong { font-size: .88rem; }
.sub-plan-btn span { font-size: .74rem; color: var(--text-3); }
.sub-plan-btn.active { border-color: var(--accent); background: rgba(124,106,247,.12); }
.sub-plan-btn:hover:not(.active) { border-color: var(--border-focus); }

.sub-interval-toggle { display: flex; gap: 6px; margin-top: 8px; }
.sub-interval-btn {
  flex: 1; padding: 7px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft); background: var(--bg-2);
  color: var(--text-2); cursor: pointer; font-size: .82rem; transition: border-color .15s, background .15s;
}
.sub-interval-btn.active { border-color: var(--accent); background: rgba(124,106,247,.12); color: var(--text-1); }
.sub-discount { background: rgba(52,211,153,.18); color: #34d399; border-radius: 4px; padding: 1px 5px; font-size: .72rem; margin-left: 4px; }

.sub-price-display { font-size: 1.3rem; font-weight: 700; margin-top: 12px; color: var(--text-1); }

.danger-zone { border-color: rgba(240,93,122,.15); gap: 10px; }
.danger-zone .acc-section-label { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════════════
   ERROR PAGES
   ═══════════════════════════════════════════════════════════════════════════ */
body.error-page {
  overflow: auto;
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.error-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.error-icon { font-size: 72px; animation: floatLogo 4s ease-in-out infinite; }
.error-wrap h1 { font-size: 80px; font-weight: 800; color: var(--text-3); letter-spacing: -4px; }
.error-wrap p { font-size: 18px; color: var(--text-2); }

/* ═══════════════════════════════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999; pointer-events: none;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-glow);
  color: var(--text);
  padding: 11px 22px;
  border-radius: 30px; font-size: 13.5px;
  box-shadow: var(--shadow-sm);
  animation: toastIn .22s cubic-bezier(.25,.46,.45,.94);
  white-space: nowrap;
  backdrop-filter: blur(12px);
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--danger); color: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   CALL OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */
.call-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8, 8, 16, 0.92);
  backdrop-filter: blur(24px);
  display: flex; align-items: center; justify-content: center;
}
.call-overlay.hidden { display: none; }

.call-overlay-inner {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 48px 32px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  min-width: 280px; text-align: center;
}
.call-minimize-btn {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 8px;
  background: none; border: 1px solid var(--border-soft);
  color: var(--text-3); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; transition: background .15s, color .15s;
}
.call-minimize-btn:hover { background: var(--bg-hover); color: var(--text); }

.call-peer-avatar {
  width: 72px; height: 72px; border-radius: 22px;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff;
  box-shadow: 0 0 32px var(--accent-glow);
}
.call-overlay-name   { font-size: 18px; font-weight: 600; color: var(--text); }
.call-overlay-status { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.call-videos { position: relative; width: 100%; }
.call-video-remote {
  display: block; width: 100%; max-width: 480px; border-radius: 12px;
  background: #000; aspect-ratio: 16/9;
}
.call-video-local {
  position: absolute; bottom: 8px; right: 8px;
  width: 110px; border-radius: 8px;
  background: #000; cursor: pointer; z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  transition: box-shadow .15s;
}
.call-video-local:not(.hidden):hover { box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(0,0,0,.5); }

/* PiP swapped: local = main, remote = PiP */
.call-videos.pip-swapped .call-video-local {
  position: static; width: 100%; max-width: 480px;
  border-radius: 12px; aspect-ratio: 16/9; cursor: default;
  box-shadow: none; transition: none;
}
.call-videos.pip-swapped .call-video-local:hover { box-shadow: none; }
.call-videos.pip-swapped .call-video-remote {
  position: absolute; bottom: 8px; right: 8px;
  width: 110px; max-width: none; aspect-ratio: auto;
  border-radius: 8px; cursor: pointer; z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.call-videos.pip-swapped .call-video-remote:not(.hidden):hover {
  box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(0,0,0,.5);
}
/* Main video click hint (subtle ring on hover) */
.call-video-remote:not(.hidden) { cursor: default; }

.call-controls {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 8px;
}
.call-ctrl-btn {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--border);
  font-size: 20px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, box-shadow .15s;
}
.call-ctrl-btn:hover   { background: var(--bg-hover); }
.call-ctrl-btn.active  { background: var(--accent-soft); border-color: var(--accent); }
.call-ctrl-btn.danger  { background: var(--danger-soft); border-color: var(--danger); }
.call-ctrl-btn.danger:hover { background: var(--danger); color: #fff; box-shadow: 0 0 16px var(--danger); }
.call-ptt-badge {
  display: inline-flex; align-items: center;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px;
  font-size: 10px; font-family: monospace; font-weight: 700;
  color: var(--text-2); cursor: pointer;
  transition: background .1s; flex-shrink: 0;
}
.call-ptt-badge:hover { background: var(--bg-hover); }
.call-ptt-badge.hidden { display: none; }

/* ── Floating mini-player ────────────────────────────────────────────────── */
.call-miniplayer {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 150;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-glass); border: 1px solid var(--border-glow);
  border-radius: 40px; padding: 8px 10px 8px 8px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,.55);
  min-width: 230px; cursor: default;
}
.call-mini-drag {
  font-size: 16px; line-height: 1; color: var(--text-muted); cursor: grab; flex-shrink: 0;
  padding: 0 2px; user-select: none;
}
.call-mini-drag:active { cursor: grabbing; }
.call-miniplayer.hidden { display: none; }
.call-mini-main {
  display: flex; align-items: center; gap: 10px;
  flex: 1; cursor: pointer; border-radius: 30px;
  padding: 2px 6px 2px 2px; transition: background .15s;
}
.call-mini-main:hover { background: var(--bg-hover); }
.call-mini-av {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 14px;
}
.call-mini-info { display: flex; flex-direction: column; gap: 1px; }
.call-mini-name  { font-size: 13px; font-weight: 600; color: var(--text); }
.call-mini-timer { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.call-mini-actions { display: flex; gap: 6px; align-items: center; }
.call-mini-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--border);
  font-size: 15px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.call-mini-btn:hover { background: var(--bg-hover); }
.call-mini-btn.active { background: var(--accent-soft); border-color: var(--accent); }
.call-mini-btn.danger { background: var(--danger-soft); border-color: var(--danger); }
.call-mini-btn.danger:hover { background: var(--danger); color: #fff; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {

  /* ── Icon rail → bottom navigation bar ──────────────────────────────────── */
  #icon-rail {
    position: fixed;
    bottom: 0; left: 0; right: 0; top: auto;
    height: calc(54px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    padding: 6px 8px env(safe-area-inset-bottom, 6px);
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
    border-top: 1px solid var(--border-soft);
    border-right: none;
    z-index: 40;
  }
  #icon-rail::-webkit-scrollbar { display: none; }

  #rail-top {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex: 1;
    width: auto;
    overflow: hidden;     /* clip — #space-icons handles its own scroll */
    min-width: 0;
  }

  #rail-bottom {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    width: auto;
    margin-left: 4px;
  }

  .rail-divider { display: none; }
  .rail-toggle-btn { display: none; }
  .rail-label { display: none !important; }

  /* Space icons: independently scrollable, takes remaining space after nav buttons */
  #space-icons {
    display: flex; flex-direction: row; align-items: center; gap: 4px;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
    flex: 1; min-width: 0;
  }
  #space-icons::-webkit-scrollbar { display: none; }

  .rail-btn, .space-rail-icon {
    width: 42px; height: 42px; flex-shrink: 0;
  }

  /* ── Left panel collapses (rail is now at bottom) ───────────────────────── */
  #left-panel { width: 0; height: 0; overflow: visible; }

  /* ── Sidebar: full-screen, visible by default ───────────────────────────── */
  #sidebar {
    position: fixed;
    left: 0; top: 0; right: 0;
    bottom: calc(54px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    transform: none;
    transition: none;
    z-index: 25;
    border-right: none;
  }
  #sidebar.sidebar-open { transform: none; } /* no-op, kept for JS compat */
  #sidebar.hidden-mobile { display: none !important; }

  /* ── Chat panel: full-screen, shown when sidebar is hidden ──────────────── */
  #chat-panel {
    position: fixed;
    left: 0; top: 0; right: 0;
    bottom: calc(54px + env(safe-area-inset-bottom, 0px));
    margin-left: 0;
    width: 100%;
  }

  /* ── Back button visible ────────────────────────────────────────────────── */
  .back-btn { display: flex; }

  /* ── Side panels (notes, contacts, etc.) ───────────────────────────────── */
  .side-panel {
    left: 0; right: 0;
    width: 100%;
    bottom: calc(54px + env(safe-area-inset-bottom, 0px));
  }
  /* ── Notes: two-screen mobile navigation ───────────────────────────────── */
  .wiki-tree-col { width: 100%; min-width: 0; border-right: none; }
  .wiki-editor-col { display: none; }
  .wiki-panel.wiki-note-open .wiki-tree-col { display: none; }
  .wiki-panel.wiki-note-open .wiki-editor-col { display: flex; width: 100%; }
  .wiki-tree-back-btn { display: flex; }
  .wiki-topbar-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ── Notebooks grid: 2 columns on mobile ───────────────────────────────── */
  .notebooks-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .nb-card { height: 160px; }
  .nb-card-add { height: 160px; }

  /* ── Modals ─────────────────────────────────────────────────────────────── */
  .modal-box { margin: 12px; max-width: calc(100vw - 24px); }
  .modal-body { max-height: 65vh; }

  /* ── Members panel: full overlay ───────────────────────────────────────── */
  .members-panel {
    position: fixed;
    left: 0; top: 0; right: 0;
    bottom: calc(54px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    z-index: 35;
  }
  .members-panel.hidden { display: none; }

  /* ── Chat header ────────────────────────────────────────────────────────── */
  #chat-header {
    position: relative;
    flex-shrink: 0;
    z-index: 10;
    padding: 10px 12px;
    min-height: 52px;
    background: var(--bg-1);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 2px 12px rgba(0,0,0,.3);
  }
  #chat-peer-name { font-size: 14px; }

  /* ── Compose area ───────────────────────────────────────────────────────── */
  #compose { padding: 8px 10px 10px; }
  #msg-input { font-size: 16px; } /* Prevent iOS auto-zoom */

  /* ── Messages ───────────────────────────────────────────────────────────── */
  .msg-row { padding: 2px 10px; }
  .msg-row.group-mid,
  .msg-row.group-end { padding-left: calc(10px + 36px + 10px); }
  .msg-avatar-sm { width: 36px; height: 36px; }
  .msg-avatar-sm.group-mid,
  .msg-avatar-sm.group-end { display: none; }

  /* ── Home panel / profile card ──────────────────────────────────────────── */
  .home-panel { padding: 16px; gap: 20px; }
  .home-banner { height: 110px; }
  .home-card-body { grid-template-columns: 1fr; }
  .home-card-left { padding: 0 16px 20px; }
  .home-card-right { border-left: none; border-top: 1px solid var(--border-soft); }

  /* ── Space home ─────────────────────────────────────────────────────────── */
  .space-home-banner { height: 120px; }
  .space-home-body { padding: 0 14px 24px; }
  .space-home-header {
    margin-top: -40px;
    gap: 12px;
    margin-bottom: 16px;
  }
  .space-home-icon {
    width: 72px; height: 72px;
    border-radius: 14px; font-size: 34px;
  }
  .space-home-banner-title {
    font-size: 17px;
    left: 14px; right: 60px;
  }
  .space-home-meta { padding: 4px 0 4px 2px; }

  /* Composer dates stack vertically */
  .composer-event-dates { flex-direction: column; gap: 8px; }

  /* Feed cards */
  .ann-card, .event-card { padding: 12px; }

  /* ── Icon picker: centered overlay ─────────────────────────────────────── */
  .icon-picker-popup {
    position: fixed;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: calc(100vw - 32px);
    z-index: 9999;
  }

  /* ── Misc ───────────────────────────────────────────────────────────────── */
  body.page-account { padding: 24px 12px; }
  .account-number-row code { font-size: 16px; letter-spacing: 2px; }
  .space-invite-box { display: none; } /* Too cluttered on mobile */

  /* ── Override rail-expanded (may be set from desktop localStorage) ──────── */
  #icon-rail.rail-expanded {
    width: 100% !important; min-width: unset !important;
    align-items: center !important;
    padding: 6px 8px env(safe-area-inset-bottom, 6px) !important;
    flex-direction: row !important;
  }
  #icon-rail.rail-expanded #rail-top,
  #icon-rail.rail-expanded #rail-bottom { align-items: center; flex-direction: row; }
  /* Critical: space-icons must be a flex row on mobile regardless of expanded state */
  #icon-rail.rail-expanded #space-icons {
    flex-direction: row !important; width: auto !important;
  }
  #icon-rail.rail-expanded .rail-btn,
  #icon-rail.rail-expanded .space-rail-icon {
    width: 42px !important; height: 42px !important;
    justify-content: center !important; padding: 0 !important;
    border-radius: 12px !important;
  }
  #icon-rail.rail-expanded .rail-label { display: none !important; }
  #icon-rail.rail-expanded .rail-divider { display: none !important; }
  #icon-rail.rail-expanded .rail-btn.active::before,
  #icon-rail.rail-expanded .space-rail-icon.active::before { display: none; }

  /* ── Voice bar: keep buttons above safe area ─────────────────────────────── */
  .voice-bar {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  }
  .voice-bar-actions { flex-wrap: nowrap; }

  /* ── Global top bar hidden on mobile — rail-based nav takes over ──────────── */
  #fb-top-bar { display: none; }
  .sidebar-brand { display: flex; }
  #app-shell { padding-top: 0; box-sizing: content-box; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   STATUS DOTS
   ═══════════════════════════════════════════════════════════════════════════ */
.status-dot {
  width: 11px; height: 11px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
  border: 2px solid var(--bg-2);
  box-sizing: border-box;
}
.status-online  { background: #43b581; }
.status-away    { background: #faa61a; }
.status-busy    { background: #f04747; }
.status-offline { background: #747f8d; }


/* ═══════════════════════════════════════════════════════════════════════════
   STATUS PICKER DROPDOWN
   ═══════════════════════════════════════════════════════════════════════════ */
.status-picker {
  position: absolute;
  left: 14px; top: calc(100% + 4px);
  width: 220px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 200;
  padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.status-picker.hidden { display: none; }

.status-picker-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-xs);
  background: none; border: none; color: var(--text-2);
  font-size: 13px; cursor: pointer; text-align: left;
  transition: background .1s, color .1s;
}
.status-picker-option:hover { background: var(--bg-hover); color: var(--text); }
.status-picker-option.active { color: var(--text); font-weight: 600; }

.status-picker-sep {
  height: 1px; background: var(--border-soft); margin: 4px 0;
}
.status-picker-msg-wrap { padding: 2px 4px 4px; }
.status-picker-msg-wrap input {
  width: 100%; background: var(--bg-3);
  border: 1px solid var(--border-soft); border-radius: var(--radius-xs);
  color: var(--text); font-size: 12px; padding: 6px 8px;
  outline: none;
}
.status-picker-msg-wrap input:focus {
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MEMBERS PANEL (right column)
   ═══════════════════════════════════════════════════════════════════════════ */
.members-panel {
  width: 210px; flex-shrink: 0;
  background: var(--bg-1);
  border-left: 1px solid var(--border-soft);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
}
.members-panel.hidden { display: none; }

.members-panel-inner { padding: 12px 8px; }

.members-panel-title {
  font-size: 10px; font-weight: 700; letter-spacing: .9px;
  text-transform: uppercase; color: var(--text-3);
  padding: 0 8px 8px;
}

.members-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: .7px;
  text-transform: uppercase; color: var(--text-3);
  padding: 10px 8px 4px;
}
.members-group-label:first-child { padding-top: 0; }

.member-row {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 8px; border-radius: var(--radius-xs);
  cursor: default; transition: background .12s;
}
.member-row:hover { background: var(--bg-hover); }

.member-av {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--av-color, linear-gradient(135deg, var(--accent), var(--accent-2)));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  position: relative;
  /* No overflow:hidden here — the status dot sits outside the circle */
}
.member-av img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.member-av .status-dot {
  position: absolute; bottom: -2px; right: -2px;
  width: 10px; height: 10px;
  border-color: var(--bg-1);
  z-index: 1;
}

.member-info { flex: 1; min-width: 0; }
.member-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.member-msg {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.member-role-badge {
  font-size: 9px; color: var(--accent-2); font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase; flex-shrink: 0;
}

/* ── Agenda ─────────────────────────────────────────────────────────────── */
.space-home-agenda { margin-top: 24px; }

/* Event form */
.space-home-event-form { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.space-home-event-form input[type="text"],
.space-home-event-form textarea { width: 100%; box-sizing: border-box; }
.space-home-event-dates { display: flex; gap: 12px; flex-wrap: wrap; }
.space-home-event-dates label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--text-3); flex: 1; min-width: 160px;
}
.space-home-event-dates input { font-size: 13px; }

/* Event cards */
.space-event-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 8px;
  position: relative; transition: border-color .15s;
}
.space-event-card:hover { border-color: var(--accent)66; }
.space-event-card-header { display: flex; align-items: flex-start; gap: 10px; }
.space-event-date-badge {
  background: var(--accent)22; color: var(--accent);
  border-radius: 8px; padding: 6px 10px; text-align: center;
  min-width: 44px; flex-shrink: 0; line-height: 1.2;
}
.space-event-date-badge .ev-day { font-size: 20px; font-weight: 800; display: block; }
.space-event-date-badge .ev-mon { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
.space-event-card-body { flex: 1; }
.space-event-title { font-weight: 700; font-size: 15px; color: var(--text); }
.space-event-time { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.space-event-desc { font-size: 13px; color: var(--text-2); margin-top: 6px; line-height: 1.5; }
.space-event-del {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; cursor: pointer; color: var(--text-3);
  font-size: 14px; opacity: 0; transition: opacity .15s;
}
.space-event-card:hover .space-event-del { opacity: 1; }
.space-event-del:hover { color: var(--danger); }
.space-event-empty { color: var(--text-3); font-size: 13px; font-style: italic; padding: 8px 0; }

/* Sidebar next-event widget */
.space-next-event {
  margin: 6px 8px 0;
  background: var(--accent)18;
  border: 1px solid var(--accent)44;
  border-radius: 10px;
  overflow: hidden;
}
.space-next-event-inner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; cursor: pointer;
  transition: background .15s;
}
.space-next-event-inner:hover { background: var(--accent)28; }
.space-next-event-icon { font-size: 16px; flex-shrink: 0; }
.space-next-event-info { display: flex; flex-direction: column; min-width: 0; }
.space-next-event-title {
  font-size: 12px; font-weight: 700; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.space-next-event-date { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* ── Space home tabs ─────────────────────────────────────────────────────── */
.space-home-tabs {
    display: flex; gap: 4px;
    margin-top: 18px; margin-bottom: 2px;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 0;
}
.space-home-tab {
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-3); font-size: 13px; font-weight: 600;
    padding: 6px 14px 8px; cursor: pointer; transition: color .15s, border-color .15s;
    margin-bottom: -1px;
}
.space-home-tab:hover { color: var(--text); }
.space-home-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Wiki ────────────────────────────────────────────────────────────────── */
#space-home-wiki { margin-top: 8px; display: flex; flex-direction: column; }

/* Wiki tab bar */
.wiki-pages-bar {
  display: flex; flex-direction: column; gap: 2px;
  padding-bottom: 14px;
  position: relative;
  z-index: 5;
}
.wiki-pages-bar::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--border-soft);
}
.wiki-page-tabs {
  display: flex; flex-direction: column; gap: 2px;
  scrollbar-width: none;
  padding-bottom: 10px;
}
.wiki-page-tabs::-webkit-scrollbar { display: none; }
#wiki-view-mode, #wiki-edit-mode { flex: 1; min-width: 0; }

/* Parent tab row */
.wiki-tab-row-parent {
  display: flex; gap: 2px; align-items: center;
  padding-bottom: 10px;
}

/* Child tab row */
.wiki-tab-row-children {
  display: flex; gap: 2px; align-items: center; padding-left: 4px;
  padding-bottom: 8px;
  margin-top: 2px;
}

/* Individual tab — relative for + button positioning */
.wiki-tab-wrap {
  position: relative; flex-shrink: 0;
  padding-bottom: 8px;
}
.wiki-page-tab {
  padding: 6px 14px;
  border: none; border-bottom: 2px solid transparent;
  background: none; color: var(--text-2);
  font-size: 13px; font-family: inherit; cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap; display: block; width: 100%;
}
.wiki-page-tab:hover { background: var(--bg-hover); color: var(--text); }
.wiki-page-tab.active {
  color: var(--accent); border-bottom-color: var(--accent);
  background: rgba(124,106,247,.07);
}

/* Delete button on tabs */
.wiki-tab-delete {
  position: absolute;
  top: -5px; right: -5px;
  width: 14px; height: 14px;
  font-size: 10px; line-height: 12px;
  color: #fff;
  background: #e53e3e; border: none;
  cursor: pointer;
  padding: 0; border-radius: 50%;
  opacity: 0; transition: opacity .15s;
  z-index: 10; text-align: center;
}
.wiki-tab-wrap:hover .wiki-tab-delete { opacity: 1; }
.wiki-tab-delete:hover { background: #c53030; }

/* Floating + button — half in, half out of tab */
.wiki-tab-add-child {
  position: absolute;
  bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 20px;
  font-size: 14px; font-weight: 700; line-height: 18px;
  color: #fff;
  background: var(--bg-3); border: 1.5px solid var(--border);
  cursor: pointer;
  padding: 0; border-radius: 50%;
  opacity: 0; transition: opacity .15s, color .15s, background .15s;
  z-index: 10; text-align: center;
}
.wiki-tab-wrap:hover .wiki-tab-add-child { opacity: 1; }
.wiki-tab-add-child:hover {
  color: var(--accent);
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* Top-level + button (add root page) — same style as tab + */
.wiki-add-page {
  width: 20px; height: 20px;
  font-size: 14px; font-weight: 700; line-height: 18px;
  color: #fff;
  background: var(--bg-3); border: 1.5px solid var(--border);
  cursor: pointer;
  padding: 0; border-radius: 50%;
  z-index: 10; text-align: center;
  flex-shrink: 0;
  align-self: center;
  margin-left: 4px;
}
.wiki-add-page:hover {
  color: var(--accent);
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* View header (edit btn top-right) */
.wiki-view-header {
  display: flex; justify-content: flex-end; margin-bottom: 8px; min-height: 28px;
}
/* View footer (meta) */
.wiki-view-footer {
  display: flex; align-items: center; gap: 12px; margin-top: 14px;
}
.wiki-view-footer .wiki-meta { margin: 0; flex: 1; }

/* Edit mode */
.wiki-title-input {
  width: 100%; background: var(--bg-3);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 15px; font-weight: 600;
  color: var(--text); font-family: inherit; outline: none;
  box-sizing: border-box;
}
.wiki-title-input:focus { border-color: var(--accent); }
.wiki-rendered {
    font-size: 14px; line-height: 1.75; color: var(--text);
}
.wiki-rendered h1, .wiki-rendered h2, .wiki-rendered h3 {
    font-weight: 700; margin: 1.2em 0 .5em; color: var(--text);
    border-bottom: 1px solid var(--border-soft); padding-bottom: .3em;
}
.wiki-rendered h1 { font-size: 1.5em; }
.wiki-rendered h2 { font-size: 1.25em; }
.wiki-rendered h3 { font-size: 1.05em; }
.wiki-rendered p  { margin: .6em 0; }
.wiki-rendered ul, .wiki-rendered ol { padding-left: 1.4em; margin: .5em 0; }
.wiki-rendered li { margin: .25em 0; }
.wiki-rendered code {
    background: var(--bg-3); border-radius: 4px;
    padding: 1px 5px; font-size: .85em; font-family: 'Fira Mono', monospace;
}
.wiki-rendered pre {
    background: var(--bg-3); border-radius: 8px; padding: 12px 16px;
    overflow-x: auto; margin: .8em 0;
}
.wiki-rendered pre code { background: none; padding: 0; }
.wiki-rendered blockquote {
    border-left: 3px solid var(--accent); padding-left: 12px;
    color: var(--text-3); margin: .6em 0;
}
.wiki-rendered a { color: var(--accent-2); text-decoration: underline; }
.wiki-rendered img { max-width: 100%; border-radius: 8px; margin: .5em 0; }
.wiki-rendered hr { border: none; border-top: 1px solid var(--border-soft); margin: 1em 0; }
.wiki-rendered table { border-collapse: collapse; width: 100%; font-size: 13px; margin: .8em 0; }
.wiki-rendered th, .wiki-rendered td { border: 1px solid var(--border-soft); padding: 6px 10px; }
.wiki-rendered th { background: var(--bg-3); font-weight: 600; }
.wiki-empty { color: var(--text-3); font-size: 13px; margin: 8px 0; }
.wiki-meta  { color: var(--text-3); font-size: 11px; margin-top: 12px; }
.wiki-edit-actions-top {
  display: flex; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-2); padding: 8px 0; margin-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
}
/* EasyMDE dark theme overrides */
.EasyMDEContainer { width: 100%; }
.EasyMDEContainer .CodeMirror {
  background: var(--bg-3) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-top: none !important;
  border-radius: 0 0 8px 8px !important;
  font-size: 13px !important;
  line-height: 1.65 !important;
  font-family: 'Fira Mono', 'Consolas', monospace !important;
  min-height: 320px !important;
  padding: 8px 4px !important;
}
.EasyMDEContainer .CodeMirror-scroll { min-height: 320px; }
.EasyMDEContainer .CodeMirror-cursor { border-left-color: var(--text) !important; }
.EasyMDEContainer .CodeMirror-selected { background: rgba(124,106,247,.25) !important; }
.EasyMDEContainer .editor-toolbar {
  background: var(--bg-2) !important;
  border: 1px solid var(--border) !important;
  border-bottom: none !important;
  border-radius: 8px 8px 0 0 !important;
  opacity: 1 !important;
}
.EasyMDEContainer .editor-toolbar button {
  color: var(--text-2) !important;
  border-radius: 5px !important;
}
.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
  background: var(--bg-3) !important;
  color: var(--accent) !important;
  border-color: transparent !important;
}
.EasyMDEContainer .editor-toolbar i.separator {
  border-color: var(--border) !important;
}
.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
  background: var(--bg-1) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
/* Fullscreen */
.EasyMDEContainer .CodeMirror-fullscreen,
.EasyMDEContainer .editor-toolbar.fullscreen,
.EasyMDEContainer .editor-preview-side.editor-preview-active-side {
  background: var(--bg-1) !important;
  z-index: 9999 !important;
}
.editor-statusbar { display: none !important; }

/* ── Unified feed composer ───────────────────────────────────────────────── */
.space-home-feed-section { margin-top: 8px; }

.btn-space-post {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 20px;
  border: 1px dashed var(--border); color: var(--text-3);
  font-size: 13px; margin-bottom: 12px; transition: border-color .15s, color .15s;
}
.btn-space-post:hover { border-color: var(--accent); color: var(--accent); background: var(--accent)0d; }

.space-home-composer {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 14px;
}
.composer-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.composer-tab {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: none; color: var(--text-2); font-size: 13px; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.composer-tab:hover { background: var(--bg-3); color: var(--text); }
.composer-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.composer-form textarea, .composer-form input[type="text"] { width: 100%; box-sizing: border-box; }
.composer-form { display: flex; flex-direction: column; gap: 8px; }
.composer-event-dates { display: flex; gap: 12px; flex-wrap: wrap; }
.composer-event-dates label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--text-3); flex: 1; min-width: 160px;
}

.composer-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* ── Feed type badge ─────────────────────────────────────────────────────── */
.feed-type-badge {
  font-size: 12px; opacity: .65; margin-right: 4px; flex-shrink: 0;
}

/* ── Inbox badge ─────────────────────────────────────────────────────────── */
.inbox-badge {
  position: absolute;
  top: -5px; right: -8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 0 5px;
  border-radius: 10px;
  min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

.inbox-list {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 0; overflow-y: auto; flex: 1;
}

.inbox-card {
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.inbox-card:hover { background: var(--bg-3); border-color: var(--border-glow); }
.inbox-card.inbox-unread { border-color: var(--accent); background: var(--accent-soft); }

.inbox-card-subject {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.inbox-card.inbox-unread .inbox-card-subject { color: var(--accent-2); }
.inbox-card-from {
  font-size: 11px; color: var(--text-3); margin-bottom: 3px;
}
.inbox-card-preview {
  font-size: 12px; color: var(--text-2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* ── Member search in space settings ─────────────────────────────────────── */
#modal-space-settings .sidebar-search input {
  width: 100%; padding: 7px 10px; font-size: 13px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); outline: none;
}
#modal-space-settings .sidebar-search input:focus {
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   EMOJI + GIF PICKER
   ═══════════════════════════════════════════════════════════════════════════ */
.media-picker {
  width: 340px; max-height: 360px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  backdrop-filter: blur(18px);
  animation: scaleIn .15s ease;
  z-index: 200;
  display: flex; flex-direction: column;
}
.media-picker-tabs {
  display: flex; gap: 4px; padding: 8px 10px 4px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.mpick-tab {
  padding: 5px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--text-2);
  transition: background .12s, color .12s;
}
.mpick-tab:hover { background: var(--bg-hover); color: var(--text); }
.mpick-tab.active { background: var(--accent); color: #fff; }

.mpick-pane { display: flex; flex-direction: column; overflow: hidden; flex: 1; }

/* Emoji grid */
.emoji-cat-bar {
  display: flex; gap: 2px; padding: 6px 8px 4px;
  overflow-x: auto; flex-shrink: 0;
}
.emoji-cat-bar::-webkit-scrollbar { height: 3px; }
.emoji-cat-btn {
  font-size: 18px; width: 34px; height: 34px;
  border-radius: 8px; transition: background .1s;
  flex-shrink: 0;
}
.emoji-cat-btn:hover { background: var(--bg-hover); }
.emoji-cat-btn.active { background: var(--bg-3); }
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 4px 8px 8px;
  overflow-y: auto; flex: 1;
}
.emoji-btn {
  font-size: 20px; width: 36px; height: 36px;
  border-radius: 8px; transition: background .1s;
  display: flex; align-items: center; justify-content: center;
}
.emoji-btn:hover { background: var(--bg-hover); }

/* GIF search */
.gif-search-input {
  margin: 8px; padding: 7px 12px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: 13px;
  outline: none; flex-shrink: 0;
}
.gif-search-input:focus { border-color: var(--accent); }
.gif-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; padding: 0 8px 8px;
  overflow-y: auto; flex: 1;
}
.gif-thumb {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 8px; cursor: pointer;
  transition: opacity .15s, transform .12s;
}
.gif-thumb:hover { opacity: .85; transform: scale(1.03); }
.gif-placeholder {
  grid-column: 1/-1; padding: 24px; text-align: center;
  color: var(--text-3); font-size: 13px;
}

/* GIF message bubble */
.msg-gif {
  max-width: 260px; max-height: 200px;
  border-radius: 10px; display: block; cursor: pointer;
}

/* ── Markdown extra blank lines ─────────────────────────────────────────── */
.wiki-rendered p:has(> br:only-child),
#nwiki-rendered-content p:has(> br:only-child) {
  min-height: 0.75em; margin: 0;
}

/* ── Account — toggle switch ─────────────────────────────────────────────── */
.acc-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.acc-toggle-switch {
  position: relative; display: inline-block;
  width: 44px; height: 24px; flex-shrink: 0; cursor: pointer;
}
.acc-toggle-switch input { opacity: 0; width: 0; height: 0; }
.acc-toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-3); border-radius: 24px;
  transition: background .2s;
}
.acc-toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; left: 3px; top: 3px;
  transition: transform .2s;
}
.acc-toggle-switch input:checked + .acc-toggle-slider { background: var(--accent); }
.acc-toggle-switch input:checked + .acc-toggle-slider::before { transform: translateX(20px); }

/* ── Mod — Mute / Warn buttons ─────────────────────────────────────────────── */
.chip-mute-btn:hover  { color: #f59e0b; background: rgba(245,158,11,.12); }
.chip-warn-btn:hover  { color: #ef4444; background: rgba(239,68,68,.12); }
.chip-warns-badge {
    background: none; border: none; cursor: pointer;
    color: var(--text-3); font-size: 13px; line-height: 1;
    padding: 1px 3px; border-radius: 3px;
}
.chip-warns-badge:hover { color: var(--accent-2); background: rgba(124,106,247,.12); }

/* Warns modal list */
.warn-row {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 7px;
    background: var(--bg-3); margin-bottom: 6px; font-size: 13px;
}
.warn-reason { flex: 1; color: var(--text); }
.warn-date   { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.warn-del-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-3); font-size: 14px; padding: 1px 4px; border-radius: 3px;
}
.warn-del-btn:hover { color: var(--danger); background: rgba(237,66,69,.1); }

/* ── Wiki grants modal ─────────────────────────────────────────────────────── */
.grant-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; border-radius: 7px;
    background: var(--bg-3); margin-bottom: 6px; font-size: 13px;
}
.grant-name { flex: 1; color: var(--text); }
.grant-del-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-3); font-size: 14px; padding: 1px 4px; border-radius: 3px;
}
.grant-del-btn:hover { color: var(--danger); background: rgba(237,66,69,.1); }

/* ── Audit log ────────────────────────────────────────────────────────────── */
.audit-log-list { max-height: 480px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.audit-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; padding: 6px 8px; border-radius: 6px; background: rgba(255,255,255,.04); font-size: .84rem; line-height: 1.4; }
.audit-date { color: var(--muted); font-size: .74rem; white-space: nowrap; min-width: 108px; flex-shrink: 0; }
.audit-action { font-weight: 600; white-space: nowrap; }
.audit-actor { color: var(--accent); }
.audit-label { background: rgba(255,255,255,.09); border-radius: 4px; padding: 1px 5px; font-size: .8rem; }
.audit-role { background: rgba(99,102,241,.25); border-radius: 4px; padding: 1px 5px; font-size: .8rem; }
.audit-loading, .audit-empty { color: var(--muted); text-align: center; padding: 28px 0; font-size: .88rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   SOUNDBOARD PANEL
   ═══════════════════════════════════════════════════════════════════════════ */
.soundboard-panel {
  position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%);
  z-index: 160;
  width: 340px; max-width: calc(100vw - 32px);
  background: var(--bg-glass); border: 1px solid var(--border-glow);
  border-radius: 16px; padding: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.55);
  backdrop-filter: blur(20px);
  animation: scaleIn .15s ease;
  display: flex; flex-direction: column; gap: 10px;
}
.soundboard-panel.hidden { display: none; }

.sb-header {
  display: flex; align-items: center; justify-content: space-between;
}
.sb-title { font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: .02em; }
.sb-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 14px; padding: 2px 6px; border-radius: 6px;
  transition: background .1s, color .1s;
}
.sb-close:hover { background: var(--bg-hover); color: var(--text); }

.sb-section-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); margin-bottom: -4px;
}

.sb-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}

.sb-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text); font-size: 12px; text-align: center;
  transition: background .12s, border-color .12s, transform .08s;
  position: relative; min-width: 0; overflow: hidden;
}
.sb-btn:hover { background: var(--bg-hover); border-color: var(--accent); transform: scale(1.04); }
.sb-btn:active { transform: scale(.96); }
.sb-btn.playing { border-color: var(--accent); background: var(--accent-soft); }

.sb-btn-icon { font-size: 20px; line-height: 1; }
.sb-btn-label {
  font-size: 10px; color: var(--text-2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; width: 100%;
}
.sb-btn-del {
  position: absolute; top: 2px; right: 3px;
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 11px; padding: 1px 2px; border-radius: 4px;
  opacity: 0; transition: opacity .12s;
  line-height: 1;
}
.sb-btn:hover .sb-btn-del { opacity: 1; }
.sb-btn-del:hover { color: var(--danger); }

.sb-upload-row {
  display: flex; align-items: center; gap: 6px; margin-top: 2px;
}
.sb-upload-name {
  flex: 1; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 12px;
  padding: 5px 9px; outline: none;
}
.sb-upload-name:focus { border-color: var(--accent); }
.sb-upload-label {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .12s;
}
.sb-upload-label:hover { background: var(--accent-2); }

.sb-quota-bar-wrap {
  display: flex; align-items: center; gap: 8px; margin-top: 2px;
}
.sb-quota-bar {
  flex: 1; height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden;
}
.sb-quota-bar::after {
  content: ''; display: block; height: 100%;
  background: var(--accent); border-radius: 2px;
  width: var(--sb-quota-pct, 0%); transition: width .3s;
}
.sb-quota-label { font-size: 10px; color: var(--text-3); white-space: nowrap; }

.sb-free-hint {
  font-size: 12px; color: var(--text-3); text-align: center; padding: 4px 0;
}

/* ── More (⋯) popover menu ────────────────────────────────────────────────── */
.more-wrap {
  position: relative;
}
.more-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  z-index: 120;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  white-space: nowrap;
}
.more-menu.hidden { display: none; }
.more-menu::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
}

/* ══════════════════════════════════════════════════════════════════════════════
   FACEBOOK LAYOUT MODE
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Retro-only elements hidden by default ───────────────────────────────────── */
#fb-right-sidebar,
#fb-bottom-bar { display: none; }

/* ── Global top bar (always visible) ────────────────────────────────────────── */
#fb-top-bar {
  display: flex; align-items: center; gap: 12px;
  position: fixed; top: 0; left: 0; right: 0; height: 48px;
  background: var(--bg-0);
  border-bottom: 1px solid var(--border-soft);
  z-index: 300; padding: 0 12px 0 76px;
}
/* Top bar replaces the sidebar brand header */
.sidebar-brand { display: none; }
/* Push all app content below the top bar */
#app-shell { padding-top: 48px; box-sizing: border-box; }

/* ── Retro layout overrides ──────────────────────────────────────────────────── */
body.fb-layout #sidebar       { display: none; }
body.fb-layout #members-panel { display: none; }
body.fb-layout #account-panel { display: none; }
body.fb-layout #chat-panel    { padding-bottom: 44px; margin-right: 220px; }
.fb-top-left  { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.fb-top-left img { display: block; }
.fb-brand {
  font-weight: 800; font-size: 17px; letter-spacing: -.4px;
  background: linear-gradient(135deg, var(--text) 60%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.fb-top-center { flex: 1; display: flex; justify-content: center; }
.fb-search-wrap { position: relative; width: 100%; max-width: clamp(280px, 40vw, 680px); }
.fb-search-input {
  width: 100%; background: var(--bg);
  border: 1px solid var(--border-soft); border-radius: 20px;
  padding: 6px 14px; font-size: 13px; color: var(--text); outline: none;
  box-sizing: border-box;
}
.fb-search-input:focus { border-color: var(--accent); }
.fb-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-0); border: 1px solid var(--border-soft);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 400; overflow: hidden; max-height: 320px; overflow-y: auto;
}
.fb-search-results.hidden { display: none; }
.fb-search-result {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; transition: background .12s;
  font-size: 13px; color: var(--text);
}
.fb-search-result:hover { background: var(--hover); }
.fb-search-result-av {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.fb-search-result-info { min-width: 0; }
.fb-search-result-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-search-result-sub  { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-search-section {
  padding: 6px 14px 2px; font-size: 10px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--text-3);
}
.fb-search-section:not(:first-child) { border-top: 1px solid var(--border-soft); margin-top: 2px; padding-top: 8px; }
.fb-top-btn {
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 6px 10px;
  cursor: pointer; color: var(--text); font-size: 16px;
  position: relative; transition: background .15s;
}
.fb-top-btn:hover { background: var(--hover); }
.fb-badge-wrap { position: relative; }
.fb-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  background: var(--danger); color: #fff;
  border-radius: 8px; font-size: 10px; line-height: 16px;
  text-align: center; padding: 0 3px;
}
.fb-btn-exit { font-size: 12px; color: var(--text-3); }

/* ── Right sidebar ───────────────────────────────────────────────────────────── */
body.fb-layout #fb-right-sidebar {
  display: flex; flex-direction: column;
  position: fixed; top: 48px; right: 0; bottom: 44px; width: 220px;
  background: var(--bg-0);
  border-left: 1px solid var(--border-soft);
  z-index: 100; overflow: hidden;
}
.fb-contacts-header {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 12px 14px 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.fb-contacts-header:has(.fb-sidebar-tabs) { padding: 0 8px 0 0; }
.fb-sidebar-search-wrap { padding: 6px 10px; flex-shrink: 0; }
.fb-sidebar-search {
  width: 100%; background: var(--bg);
  border: 1px solid var(--border-soft); border-radius: 14px;
  padding: 5px 12px; font-size: 12px; color: var(--text); outline: none;
}
.fb-sidebar-search:focus { border-color: var(--accent); }
.fb-contacts-list { flex: 1; overflow-y: auto; padding: 4px 0; scrollbar-width: thin; }
.fb-contact-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; cursor: pointer;
  background: none; border: none; color: var(--text);
  width: 100%; text-align: left; border-radius: 8px;
  transition: background .15s; position: relative;
}
.fb-contact-item:hover { background: var(--hover); }
.fb-contact-av {
  width: 36px; height: 36px; background: var(--accent);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0; position: relative;
  overflow: hidden;
}
/* The optional <img> rendered by _fbContactAvatarHtml. Fills the
   circle and clips via the parent's `overflow: hidden`. Letter
   fallback uses the same wrapper, so no img class needs to coexist. */
.fb-contact-av-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.fb-contact-status-dot {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--bg-0);
  /* Lift above the avatar image so the dot stays visible when an
     <img> covers the whole circle. */
  z-index: 1;
}
.fb-contact-name { font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fb-no-contacts { text-align: center; color: var(--text-3); font-size: 13px; padding: 20px; }

/* ── Boutique overlay in FB layout ──────────────────────────────────────────── */
body.fb-layout #boutique-panel:not(.hidden) {
  position: fixed; top: 48px; left: 64px; right: 220px; bottom: 44px;
  z-index: 400; border-radius: 8px; overflow-y: auto;
  background: var(--bg-1); border: 1px solid var(--border-soft);
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

/* ── Bottom bar ──────────────────────────────────────────────────────────────── */
body.fb-layout #fb-bottom-bar {
  display: flex; align-items: flex-end;
  position: fixed; bottom: 0; left: 64px; right: 220px; height: 44px;
  background: var(--bg-0); border-top: 1px solid var(--border-soft);
  z-index: 200; padding: 0; overflow: visible;
}
/* Tab rail — tabs are absolutely positioned by JS to match each chat window's
   `right` anchor exactly. This avoids any flex/gap rounding drift after
   close/reopen cycles and guarantees pixel-perfect tab/window alignment. */
.fb-conv-tabs {
  flex: 1; min-width: 0; height: 100%;
  position: relative;
  overflow: hidden;
  pointer-events: auto;
}

/* Tabs: width set dynamically by JS to match their chat window (300 or 480px).
   Open vs minimized is a visual state — border identical across states. */
.fb-conv-tab {
  display: flex; align-items: center; gap: 6px;
  position: absolute; bottom: 0;
  width: 300px; height: 40px; /* fallback — overridden by JS */
  background: var(--bg-1); border: 1px solid var(--border-soft);
  border-top: 2px solid var(--border-soft);
  border-radius: 6px 6px 0 0; padding: 5px 10px;
  cursor: pointer; color: var(--text); font-size: 13px;
  transition: opacity .15s, border-top-color .15s; pointer-events: auto;
}
.fb-conv-tab.tab-open      { border-top-color: var(--accent); }
.fb-conv-tab.tab-minimized { opacity: 0.55; }
.fb-conv-tab:hover         { opacity: 1; }
.fb-tab-av {
  width: 20px; height: 20px; background: var(--accent);
  border-radius: 50%; font-size: 10px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.fb-tab-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; }
.fb-tab-badge {
  background: var(--danger); color: #fff; border-radius: 10px;
  font-size: 10px; min-width: 16px; height: 16px; line-height: 16px;
  text-align: center; padding: 0 3px; flex-shrink: 0;
}
.fb-tab-close { color: var(--text-3); font-size: 12px; padding: 0 2px; flex-shrink: 0; transition: color .15s; }
.fb-tab-close:hover { color: var(--danger); }
.fb-new-chat-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 50%;
  width: 22px; height: 22px; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: opacity .15s;
}
.fb-new-chat-btn:hover { opacity: .85; }

/* ── Chat windows ────────────────────────────────────────────────────────────── */
.fb-chat-win {
  position: fixed; bottom: 44px; width: 300px; height: 400px;
  background: var(--bg-2);
  border-radius: 8px 8px 0 0;
  border: 1px solid var(--border-soft); border-bottom: none;
  display: flex; flex-direction: column;
  z-index: 190;
  box-shadow: 0 -4px 24px rgba(0,0,0,.3);
  transition: height .2s ease; overflow: hidden;
}
.fb-chat-win.win-minimized { display: none; }
.fb-chat-win.win-maximized { width: 480px; height: 560px; }
.fb-chat-win-header {
  background: var(--bg-0); border-radius: 8px 8px 0 0;
  display: flex; align-items: center; padding: 0 8px;
  height: 36px; flex-shrink: 0; cursor: pointer; gap: 7px;
  border-bottom: 1px solid var(--border-soft); user-select: none;
}
.fb-win-av {
  width: 24px; height: 24px; background: var(--accent); border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.fb-win-name-group {
  flex: 1; display: flex; align-items: center; gap: 2px; overflow: hidden; min-width: 0;
}
.fb-win-name, .fb-win-name-btn {
  font-size: 13px; font-weight: 600; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; color: var(--text); background: none; border: none;
  cursor: pointer; text-align: left; padding: 0; min-width: 0; flex-shrink: 1;
}
.fb-win-name-btn:hover { text-decoration: underline; }
.fb-win-btn-wizz { font-size: 14px !important; flex-shrink: 0; opacity: .7; }
.fb-win-btn-wizz:hover { opacity: 1; color: var(--danger) !important; }
.fb-win-btn-snap { color: var(--accent) !important; font-size: 15px !important; }
.fb-win-btn-snap:hover { background: rgba(124,106,247,.15) !important; }
.fb-win-btn {
  background: none; border: none; color: var(--text-3); font-size: 13px;
  cursor: pointer; padding: 2px 4px; border-radius: 4px;
  transition: background .15s, color .15s; flex-shrink: 0; line-height: 1;
}
.fb-win-btn:hover { background: var(--hover); color: var(--text); }
.fb-chat-win-body {
  flex: 1; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 4px; scrollbar-width: thin;
}
.fb-msg-bubble { max-width: 82%; padding: 6px 10px; border-radius: 14px; font-size: 13px; line-height: 1.4; word-break: break-word; }
.fb-msg-mine    { background: var(--accent); color: #fff; align-self: flex-end;  border-radius: 14px 14px 4px 14px; }
.fb-msg-theirs  { background: var(--bg);     color: var(--text); align-self: flex-start; border-radius: 14px 14px 14px 4px; }
.fb-msg-system  { color: var(--text-3); font-style: italic; font-size: 12px; align-self: center; text-align: center; }
.fb-chat-loading, .fb-chat-error { text-align: center; color: var(--text-3); font-size: 12px; padding: 16px; align-self: center; }
.fb-chat-win-footer {
  display: flex; align-items: center; padding: 6px;
  border-top: 1px solid var(--border-soft); gap: 6px; flex-shrink: 0;
}
.fb-win-input {
  flex: 1; background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: 16px; padding: 6px 12px;
  font-size: 13px; color: var(--text); outline: none; resize: none;
  font-family: inherit;
}
.fb-win-input:focus { border-color: var(--accent); }
.fb-win-send {
  background: var(--accent); color: #fff; border: none; border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; font-size: 14px; transition: opacity .15s;
}
.fb-win-send:hover { opacity: .85; }
.fb-win-emoji-btn {
  background: none; border: none; color: var(--text-3); font-size: 18px;
  cursor: pointer; padding: 0 4px; flex-shrink: 0; line-height: 1;
  transition: color .15s;
}
.fb-win-emoji-btn:hover { color: var(--text); }

@keyframes fb-wizz-shake {
  0%,100% { transform: translate(0,0) rotate(0deg); }
  10%      { transform: translate(-6px,-4px) rotate(-2deg); }
  20%      { transform: translate(6px,4px)  rotate(2deg); }
  30%      { transform: translate(-8px,2px)  rotate(-3deg); }
  40%      { transform: translate(8px,-2px)  rotate(3deg); }
  50%      { transform: translate(-6px,4px)  rotate(-2deg); }
  60%      { transform: translate(6px,-4px)  rotate(2deg); }
  70%      { transform: translate(-4px,2px)  rotate(-1deg); }
  80%      { transform: translate(4px,-2px)  rotate(1deg); }
  90%      { transform: translate(-2px,1px)  rotate(0deg); }
}
@keyframes fb-wizz-tab-flash {
  0%,100% { background: transparent; }
  25%     { background: rgba(240,93,122,.35); }
  75%     { background: rgba(240,93,122,.15); }
}
.win-wizzing { animation: fb-wizz-shake 0.75s ease-in-out 4; }
.tab-wizzing { animation: fb-wizz-tab-flash 3s ease-in-out; }

/* max-only: hidden by default, visible when window is maximized */
.fb-max-only { display: none !important; }
.win-maximized .fb-max-only { display: flex !important; align-items: center; }

/* ── Emoji picker for FB windows ────────────────────────────────────────────── */
.fb-emoji-picker {
  position: fixed; z-index: 9999;
  background: var(--bg-0); border: 1px solid var(--border-soft); border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.3); width: 220px; overflow: hidden;
}
.fb-emoji-cats {
  display: flex; overflow-x: auto; padding: 4px; gap: 2px;
  border-bottom: 1px solid var(--border-soft); scrollbar-width: none;
}
.fb-emoji-cats::-webkit-scrollbar { display: none; }
.fb-emoji-cat {
  background: none; border: none; font-size: 15px; cursor: pointer; padding: 3px 5px;
  border-radius: 5px; flex-shrink: 0; opacity: .6; transition: opacity .1s;
}
.fb-emoji-cat:hover, .fb-emoji-cat.active { opacity: 1; background: var(--hover); }
.fb-emoji-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; padding: 6px; max-height: 160px; overflow-y: auto; scrollbar-width: thin;
}
.fb-emoji-item {
  background: none; border: none; font-size: 17px; cursor: pointer;
  border-radius: 4px; padding: 3px; text-align: center; transition: background .1s;
}
.fb-emoji-item:hover { background: var(--hover); }

/* ── Space sidebar stays visible in retro mode (channel list) ───────────────── */
/* Brand header hidden to avoid duplicating the retro top bar. Bottom bar starts
   after the sidebar so its border doesn't cross the channel list. */
body.fb-layout.fb-in-space #sidebar    { display: flex; }
body.fb-layout.fb-in-space #fb-bottom-bar { left: calc(64px + var(--sidebar-w)); }
body.fb-layout.fb-in-space .space-invite-box { margin: auto 12px 0; }
body.fb-layout .sidebar-brand { display: none; }
/* Reserve room for the 44 px-tall retro bottom bar at the bottom of
   the channel sidebar — the bar itself starts to the right of the
   sidebar (rule above), but the sidebar's own bottom dock (Share /
   Members / Settings buttons) was extending into the same 44 px
   stripe at the screen's bottom edge, getting visually clipped by
   the bar's `border-top`. Padding it out of the way fixes the
   "Share button hidden under the bar" report. */
body.fb-layout.fb-in-space #sidebar    { padding-bottom: 44px; }
/* Mobile / narrow viewports collapse the bottom bar — undo the
   padding so we don't leave dead space. Matches the existing
   `display: none` for #fb-bottom-bar at the same breakpoint
   (line ~6309). */
@media (max-width: 700px) {
  body.fb-layout.fb-in-space #sidebar  { padding-bottom: 0; }
}

/* ── Friends/Users tabs in right sidebar ────────────────────────────────────── */
.fb-sidebar-tabs {
  display: flex; border-bottom: 1px solid var(--border-soft);
  flex: 1; min-width: 0;
}
.fb-sidebar-tab {
  flex: 1; background: none; border: none; color: var(--text-3);
  font-size: 12px; font-weight: 600; padding: 9px 6px;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.fb-sidebar-tab:hover { color: var(--text); }
.fb-sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.fb-member-role { font-size: 11px; margin-left: auto; flex-shrink: 0; }

/* ── Boutique layout card ────────────────────────────────────────────────────── */
.boutique-layout-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surface); border-radius: 10px;
  border: 1px solid var(--border-soft);
  margin-bottom: 10px; transition: border-color .2s;
}
.boutique-layout-card.is-active { border-color: var(--accent); }
.boutique-layout-preview {
  width: 80px; height: 54px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, #1c1e21 0%, #3a3b3c 100%);
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border-soft);
}
.boutique-layout-preview-topbar {
  height: 9px; background: #1c1e21; border-bottom: 1px solid #3a3b3c;
}
.boutique-layout-preview-body {
  flex: 1; display: flex;
}
.boutique-layout-preview-left  { width: 14px; background: #242526; border-right: 1px solid #3a3b3c; }
.boutique-layout-preview-center { flex: 1; background: #18191a; }
.boutique-layout-preview-right  { width: 20px; background: #242526; border-left: 1px solid #3a3b3c; }
.boutique-layout-preview-bottombar {
  height: 8px; background: #1c1e21; border-top: 1px solid #3a3b3c;
}

/* ── Calendar panel ──────────────────────────────────────────────────────────── */
.calendar-panel {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
}
.calendar-topbar {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg-0);
}
.calendar-topbar h2 {
  flex-shrink: 0; margin: 0; font-size: 18px;
}
.calendar-view-btns {
  display: flex; gap: 4px; flex-shrink: 0;
}
.cal-view-btn {
  padding: 4px 10px; font-size: 12px; background: transparent; border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-3); cursor: pointer; transition: all .15s;
}
.cal-view-btn:hover { color: var(--text); border-color: var(--text-3); }
.cal-view-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
#btn-calendar-new-event {
  margin-left: auto; flex-shrink: 0;
}
.calendar-body {
  display: flex; flex: 1; overflow: hidden; min-height: 0;
}
.calendar-sidebar {
  width: 200px; flex-shrink: 0; border-right: 1px solid var(--border);
  overflow-y: auto; padding: 12px; background: var(--bg-1);
  font-size: 13px;
}
.cal-sidebar-section {
  margin-bottom: 18px;
}
.cal-sidebar-heading {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.cal-item {
  margin-bottom: 6px;
}
.cal-item-row {
  display: flex; align-items: center; gap: 6px; padding: 4px;
  border-radius: 4px; cursor: pointer; transition: background .15s;
  border-left: 2px solid transparent;
}
.cal-item-row:hover {
  background: var(--bg-2);
}
.cal-item-row.active {
  background: var(--bg-2);
  border-left-color: var(--accent);
}
.cal-item-row.active .cal-name {
  font-weight: 600;
  color: var(--accent);
}
.cal-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1000;
  background: var(--bg-1, var(--bg)); border: 1px solid var(--border);
  border-radius: 7px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
  max-height: 220px; overflow-y: auto; padding: 4px;
}
.cal-suggest.hidden { display: none; }
.cal-suggest-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 5px; cursor: pointer; font-size: .85em;
}
.cal-suggest-item:hover, .cal-suggest-item.kbd-active { background: var(--bg-2); }
.cal-suggest-avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--bg-3);
  display: flex; align-items: center; justify-content: center; font-size: 11px;
  flex-shrink: 0; overflow: hidden;
}
.cal-suggest-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cal-suggest-name { font-weight: 500; }
.cal-suggest-handle { color: var(--text-3); font-size: .9em; }
.cal-suggest-empty { padding: 8px; color: var(--text-3); font-size: .8em; text-align: center; }

/* Reminder corner stack — persistent until dismissed */
.cal-reminder-stack {
  position: fixed; right: 16px; bottom: 16px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 360px; pointer-events: none;
}
.cal-reminder-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-1, var(--bg)); border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  pointer-events: auto; cursor: pointer;
  animation: calReminderIn .25s ease-out;
}
@keyframes calReminderIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.cal-reminder-icon { font-size: 24px; line-height: 1; }
.cal-reminder-body { flex: 1; min-width: 0; }
.cal-reminder-title {
  font-weight: 600; font-size: .92em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-reminder-sub { font-size: .8em; color: var(--text-3); margin-top: 2px; }
.cal-reminder-close {
  background: transparent; border: none; color: var(--text-3);
  cursor: pointer; padding: 4px 6px; font-size: 14px; flex-shrink: 0;
}
.cal-reminder-close:hover { color: var(--text); }

.cal-invite-card { border-color: var(--accent); }
.cal-invite-actions {
  display: flex; gap: 6px; margin-top: 8px;
}
.cal-invite-actions button { flex: 1; }
.cal-checkbox {
  flex-shrink: 0; width: 16px; height: 16px; cursor: pointer;
}
.cal-dot {
  flex-shrink: 0; width: 12px; height: 12px; border-radius: 50%;
}
.cal-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.cal-source-badge {
  flex-shrink: 0;
  font-size: 10px; font-weight: 700;
  width: 16px; height: 16px; line-height: 16px;
  text-align: center;
  border-radius: 4px;
  background: linear-gradient(135deg, #4285F4, #34A853);
  color: #fff;
  letter-spacing: 0;
}
.cal-menu-btn {
  flex-shrink: 0; padding: 0; width: 20px; height: 20px;
  font-size: 12px; opacity: 0;
}
.cal-item-row:hover .cal-menu-btn {
  opacity: 1;
}
.cal-add-btn {
  width: 100%; padding: 8px 6px; margin-bottom: 6px; background: var(--bg-2);
  border: 1px solid var(--border-soft); border-radius: 4px; color: var(--text-3);
  cursor: pointer; font-size: 12px; transition: all .15s;
}
.cal-add-btn:hover {
  background: var(--bg-3); color: var(--text);
}
.calendar-main {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.calendar-nav-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg-0);
}
.calendar-nav-row button {
  padding: 6px 12px; font-size: 12px;
}
.cal-period-label {
  flex: 1; text-align: center; font-weight: 600; color: var(--text);
}
.calendar-grid {
  flex: 1; overflow: auto; padding: 16px;
}
.cal-month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(100px, auto); gap: 8px; height: fit-content;
}
.cal-month-weekday {
  font-size: 11px; font-weight: 600; text-align: center; color: var(--text-3);
  text-transform: uppercase; padding: 8px 0;
}
.cal-month-day {
  background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 6px;
  padding: 8px; display: flex; flex-direction: column; position: relative;
  min-height: 100px; cursor: pointer; transition: all .15s;
}
.cal-month-day:hover {
  border-color: var(--accent); background: var(--bg-3);
}
.cal-month-day.today {
  border-color: var(--accent);
}
.cal-month-day.today .cal-day-num::before {
  content: ''; position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  background: var(--accent); border-radius: 50%; z-index: -1;
}
.cal-month-day.other-month {
  opacity: 0.4;
}
.cal-day-num {
  font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px;
}
.cal-events-in-day {
  display: flex; flex-direction: column; gap: 2px; font-size: 11px;
}
.cal-event-chip {
  border-radius: 3px; padding: 3px 5px; color: white; background: #6c63ff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; transition: opacity .15s;
}
.cal-event-chip:hover {
  opacity: 0.85;
}
.cal-more-text {
  font-size: 10px; color: var(--text-3); font-style: italic;
}
.cal-day-add-btn {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0;
  border-radius: 3px; border: 1px solid var(--border); background: var(--input-bg);
  color: var(--text-2); font-size: 12px; font-weight: bold; cursor: pointer;
  transition: all .15s; opacity: 0;
}
.cal-month-day:hover .cal-day-add-btn {
  opacity: 1;
}
.cal-day-add-btn:hover {
  background: var(--accent); color: white; border-color: var(--accent);
}
.cal-event-list-item {
  padding: 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px;
  cursor: pointer; transition: all .15s;
}
.cal-event-list-item:hover {
  background: var(--hover-bg); border-color: var(--accent);
}
.cal-event-list-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
}
.cal-event-list-title {
  font-weight: 500; margin-bottom: 2px;
}
.cal-event-list-meta {
  font-size: 12px; color: var(--text-3);
}

/* Week view */
.cal-week-grid {
  display: flex; flex-direction: column; height: 100%;
}
.cal-week-header {
  display: grid; grid-template-columns: 60px repeat(7, 1fr);
  gap: 0; border-bottom: 1px solid var(--border);
  background: var(--bg-0); flex-shrink: 0;
}
.cal-week-day-header {
  padding: 12px 8px; text-align: center; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.cal-week-day-header.today {
  background: var(--accent-soft);
}
.cal-week-day-name {
  font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase;
}
.cal-week-day-date {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.cal-week-time-grid {
  display: flex; flex-direction: column; flex: 1; overflow-y: auto;
  border-left: 1px solid var(--border);
}
.cal-week-hour-row {
  display: grid; grid-template-columns: 60px repeat(7, 1fr);
  gap: 0; border-bottom: 1px solid var(--border-soft);
  min-height: 50px; background: var(--bg-1);
}
.cal-week-hour-row:hover {
  background: var(--bg-2);
}
.cal-week-hour-label {
  padding: 8px; text-align: right; font-size: 11px; color: var(--text-3);
  border-right: 1px solid var(--border); background: var(--bg-0); flex-shrink: 0;
}
.cal-week-day-cell {
  padding: 4px; border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 2px; position: relative;
}
.cal-week-day-cell:last-child {
  border-right: none;
}
.cal-week-event-chip {
  background: #6c63ff; color: white; padding: 3px 5px; border-radius: 3px;
  font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; transition: opacity .15s;
}
.cal-week-event-chip:hover {
  opacity: 0.85;
}

/* Day view */
.cal-day-view {
  display: flex; flex-direction: column; height: 100%;
}
.cal-day-header {
  padding: 16px; background: var(--bg-0); border-bottom: 1px solid var(--border);
  text-align: center;
}
.cal-day-name {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.cal-day-date {
  font-size: 12px; color: var(--text-3); margin-top: 4px;
}
.cal-day-time-grid {
  display: flex; flex-direction: column; flex: 1; overflow-y: auto;
}
.cal-day-hour-slot {
  display: flex; border-bottom: 1px solid var(--border-soft);
  min-height: 60px; background: var(--bg-1);
}
.cal-day-hour-slot:hover {
  background: var(--bg-2);
}
.cal-day-hour-label {
  width: 60px; padding: 8px; text-align: right; font-size: 11px; color: var(--text-3);
  border-right: 1px solid var(--border); background: var(--bg-0); flex-shrink: 0;
}
.cal-day-hour-content {
  flex: 1; padding: 4px; display: flex; flex-direction: column; gap: 2px;
}
.cal-day-event-chip {
  background: #6c63ff; color: white; padding: 6px 8px; border-radius: 4px;
  font-size: 11px; cursor: pointer; transition: opacity .15s;
  overflow: hidden;
}
.cal-day-event-chip:hover {
  opacity: 0.85;
}
.cal-day-event-time {
  font-size: 10px; opacity: 0.9; margin-bottom: 2px;
}
.cal-day-event-title {
  font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Space module toggle */
.space-module-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--bg-2); border-radius: 6px;
  border: 1px solid var(--border-soft);
}
.space-module-info {
  display: flex; flex-direction: column; gap: 2px;
}
.space-module-name {
  font-weight: 500; color: var(--text); font-size: 13px;
}
.space-module-desc {
  font-size: 11px; color: var(--text-3);
}

/* Calendar modal inputs */
#modal-calendar-event input[type="text"],
#modal-calendar-event input[type="datetime-local"],
#modal-calendar-event input[type="color"],
#modal-calendar-event select,
#modal-calendar-event textarea {
  width: 100%; padding: 8px; margin-bottom: 8px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 4px; color: var(--text);
  font-family: inherit; font-size: 13px;
}
#modal-calendar-event textarea {
  resize: vertical; min-height: 60px;
}

/* Calendar context menu */
.cal-context-menu {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000; min-width: 150px;
}
.cal-menu-item {
  display: block; width: 100%; padding: 10px 14px; background: transparent;
  border: none; text-align: left; color: var(--text); cursor: pointer;
  font-size: 13px; transition: background .15s;
}
.cal-menu-item:hover {
  background: var(--bg-3);
}
.cal-menu-item.danger:hover {
  background: rgba(244, 67, 54, 0.15); color: #f44336;
}
.cal-menu-item:first-child {
  border-radius: 6px 6px 0 0;
}
.cal-menu-item:last-child {
  border-radius: 0 0 6px 6px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE FOOTER — Copyright & Legal Links
   ═══════════════════════════════════════════════════════════════════════════ */
.page-footer {
  background: var(--bg-2);
  border-top: 1px solid var(--border-soft);
  padding: 20px 0;
  margin-top: auto;
  text-align: center;
}
.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.footer-copyright {
  font-size: 12px;
  color: var(--text-3);
  margin: 0;
}
.footer-links {
  font-size: 12px;
}
.footer-links a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover {
  color: var(--accent-bright);
  text-decoration: underline;
}
.footer-divider {
  color: var(--text-4);
  margin: 0 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE OVERRIDES (cascade tail)
   Must come AFTER the Retro Social / fb-layout rules to win the cascade.
   The main @media block is at ~line 4435 but fb-layout rules are defined
   later in this file and would otherwise override those mobile rules.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  /* fb-top-bar base rule (display:flex) is defined after the main mobile block
     and would show it on mobile — hide it here so the cascade is correct. */
  #fb-top-bar { display: none; }
  #app-shell  { padding-top: 0; box-sizing: content-box; }

  /* Retro Social layout is fully disabled on mobile — the bottom rail handles
     navigation. Override every fb-layout rule that would break mobile. */
  body.fb-layout #sidebar               { display: flex; }
  body.fb-layout #sidebar.hidden-mobile { display: none !important; }
  body.fb-layout #chat-panel            { padding-bottom: 0; margin-right: 0; }
  body.fb-layout #members-panel         { display: flex; }
  body.fb-layout #account-panel         { display: flex; }
  body.fb-layout #fb-right-sidebar      { display: none; }
  body.fb-layout #fb-bottom-bar         { display: none; }
  body.fb-layout .sidebar-brand         { display: flex; }
}

/* Feature-flag "coming soon" affordance. Applied by
   _applyFeatureFlagsToUi at boot to any rail/nav button whose backing
   feature is off. Half-opacity so it reads as "disabled but not gone"
   — admins still see the entry and click on it surfaces a toast that
   tells them which flag to flip in /admin. */
.ff-coming-soon {
  opacity: 0.45;
  cursor: not-allowed;
  position: relative;
}
.ff-coming-soon::after {
  content: 'SOON';
  position: absolute;
  top: 2px; right: 2px;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--accent, #7c5cff);
  background: rgba(124, 92, 255, 0.15);
  border: 1px solid rgba(124, 92, 255, 0.35);
  border-radius: 3px;
  padding: 1px 3px;
  line-height: 1;
}

/* ─── Kanban ──────────────────────────────────────────────────────── */
.kanban-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  overflow: hidden;
}
.kanban-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

/* Breadcrumb-style back pill — always visible in the topbar. Acts as
   "back to list" when inside a board, and as the title pill on the list
   itself. Designed to be obviously clickable: rounded, hover state,
   left-aligned arrow that animates. */
.kanban-back-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.kanban-back-pill:hover {
  background: rgba(108, 99, 255, 0.15);
  border-color: var(--primary);
}
.kanban-back-pill .kanban-back-arrow {
  display: inline-block;
  transition: transform 0.15s;
  font-size: 16px;
  line-height: 1;
}
.kanban-back-pill:hover .kanban-back-arrow {
  transform: translateX(-2px);
}
/* On the list view there's nowhere to go back to — the pill becomes
   non-interactive and the arrow hides. */
.kanban-back-pill.is-root .kanban-back-arrow { display: none; }
.kanban-back-pill.is-root {
  cursor: default;
  background: transparent;
  border-color: transparent;
}
.kanban-back-pill.is-root:hover {
  background: transparent;
  border-color: transparent;
}

.kanban-crumb-sep {
  color: var(--text-3);
  font-size: 16px;
}
.kanban-board-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.kanban-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  margin: 16px 0 8px;
}
.kanban-list-view {
  padding: 16px 20px 40px;
  overflow-y: auto;
  flex: 1;
}
.kanban-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.kanban-empty h3 { margin: 12px 0 4px; color: var(--text); }
.kanban-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kanban-card-tile {
  padding: 16px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  border-left: 4px solid var(--primary);
  position: relative;
}
.kanban-card-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}
.kanban-card-tile h4 { margin: 0 0 8px; color: var(--text); font-size: 15px; }
.kanban-card-tile .kt-meta {
  font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px;
}

/* Board detail */
.kanban-board-view {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px 20px;
}
.kanban-columns {
  display: flex;
  gap: 12px;
  height: 100%;
  align-items: flex-start;
}
.kanban-column {
  flex: 0 0 280px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  border-top: 3px solid var(--primary);
}
.kanban-column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.kanban-column-title {
  flex: 1; font-weight: 600; font-size: 14px; color: var(--text);
  cursor: text; padding: 2px 4px; border-radius: 4px;
}
.kanban-column-title:hover { background: var(--bg-3); }
.kanban-column-count {
  background: var(--bg-3);
  color: var(--text-3);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}
.kanban-cards {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 40px;
}
.kanban-cards.drag-over {
  background: rgba(108, 99, 255, 0.06);
}
.kanban-card {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  cursor: grab;
  transition: border-color 0.15s, transform 0.05s;
  user-select: none;
}
.kanban-card:hover { border-color: rgba(255, 255, 255, 0.15); }
.kanban-card.dragging { opacity: 0.5; cursor: grabbing; }
.kanban-card-title { font-size: 13px; color: var(--text); line-height: 1.4; }
.kanban-card-due {
  font-size: 11px; color: var(--text-3); margin-top: 6px;
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
}
.kanban-card-due.overdue { color: #ef4444; background: rgba(239, 68, 68, 0.1); }

.kanban-column-add {
  padding: 8px 12px;
  border-top: 1px solid var(--border-soft);
}
.kanban-add-card-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px dashed var(--border-soft);
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s;
}
.kanban-add-card-btn:hover {
  color: var(--text);
  border-color: var(--text-3);
}

.kanban-add-column-btn {
  flex: 0 0 240px;
  align-self: flex-start;
  padding: 14px;
  background: transparent;
  border: 1px dashed var(--border-soft);
  border-radius: 10px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
}
.kanban-add-column-btn:hover {
  color: var(--text);
  border-color: var(--text-3);
}

.modal-box-large { max-width: 600px; width: 90%; }

/* Rail button user-hidden state — user clicked the hover ✕ or unchecked
   the box in self profile → Sidebar items. CSS-only so apply/unapply
   is just a classList.toggle, no reflow. */
.rail-btn.rail-btn-user-hidden { display: none !important; }

/* Sidebar items prefs list — one row per tool, full-width, label on
   the left, switch on the right. Defeats the modal's default flex/center
   layout which was floating labels to the right column. */
.rail-prefs-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rail-pref-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.12s;
    font-size: 14px;
    color: var(--text);
}
.rail-pref-row:hover { background: rgba(255, 255, 255, 0.05); }
.rail-pref-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}
.rail-pref-emoji {
    font-size: 18px;
    line-height: 1;
    width: 22px;
    text-align: center;
}

/* Generic UI switch — iOS-style. Bumped from 38×22 to 46×26 so the
   thumb (now 20px) reads clearly against the dark background, and the
   OFF state uses a high-contrast lighter grey + visible border instead
   of the previous near-invisible 12% white. Used by sidebar prefs,
   space module toggles, and any future toggle. */
.ui-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}
.ui-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}
.ui-switch-track {
    position: absolute;
    inset: 0;
    background: #1f2937;        /* gray-800 — very dark, reads as "off" */
    border: 1px solid #374151;  /* gray-700 — visible outline */
    border-radius: 999px;
    transition: background 0.18s, border-color 0.18s;
    box-sizing: border-box;
}
.ui-switch-track::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #9ca3af;        /* gray-400 — dimmer thumb when OFF */
    transition: transform 0.18s, background 0.18s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.ui-switch input:checked + .ui-switch-track {
    background: #22c55e;        /* green-500 — universally "active" */
    border-color: #16a34a;
}
.ui-switch input:checked + .ui-switch-track::before {
    transform: translateX(20px);
    background: #ffffff;        /* full white thumb when ON */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 8px rgba(34, 197, 94, 0.5);
}
.ui-switch input:focus-visible + .ui-switch-track {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.ui-switch:hover .ui-switch-track {
    border-color: rgba(255, 255, 255, 0.25);
}

/* Compact variant for dense lists (e.g. Kanban Global sidebar) */
.ui-switch.ui-switch-sm { width: 32px; height: 18px; }
.ui-switch.ui-switch-sm .ui-switch-track::before {
    width: 14px; height: 14px; top: 1px; left: 1px;
}
.ui-switch.ui-switch-sm input:checked + .ui-switch-track::before {
    transform: translateX(14px);
}

/* ── Kanban Global view ─────────────────────────────────────────────────── */
.kanban-global-view {
    display: flex;
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}
.kbg-sidebar {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid var(--border, #1f2937);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.kbg-sidebar-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border, #1f2937);
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.kbg-sidebar-head .btn-link {
    background: none;
    border: 0;
    color: var(--primary, #6c63ff);
    cursor: pointer;
    padding: 0 2px;
    font-size: 12px;
}
.kbg-sidebar-head .btn-link:hover { text-decoration: underline; }
.kbg-sidebar-head .kbg-dot { color: var(--text-muted, #6b7280); }
.kbg-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.kbg-sidebar-empty {
    padding: 16px;
    color: var(--text-muted, #9ca3af);
    font-size: 13px;
    text-align: center;
}
.kbg-group { padding: 6px 0 10px; }
.kbg-group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 14px 6px;
}
.kbg-group-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text, #e5e7eb);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kbg-group-count {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 6px;
    border-radius: 999px;
}
.kbg-group-boards { display: flex; flex-direction: column; }
.kbg-board-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 26px;
    cursor: pointer;
    transition: background 0.12s;
}
.kbg-board-row:hover { background: rgba(255, 255, 255, 0.03); }
.kbg-dot-color {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.kbg-board-name {
    font-size: 13px;
    color: var(--text, #e5e7eb);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.kbg-main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 18px 22px;
}
.kbg-main-body { display: flex; flex-direction: column; gap: 18px; }
.kbg-board-section {
    border-left: 4px solid var(--primary, #6c63ff);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
}
.kbg-board-section-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}
.kbg-board-section-head h3 {
    margin: 0;
    font-size: 15px;
    color: var(--text, #e5e7eb);
}
.kbg-section-ctx {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.kbg-section-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
}
.kbg-open-board {
    background: none;
    border: 0;
    color: var(--primary, #6c63ff);
    cursor: pointer;
    font-size: 12px;
    padding: 0 4px;
}
.kbg-open-board:hover { text-decoration: underline; }
.kbg-card-list { display: flex; flex-direction: column; gap: 4px; }
.kbg-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
}
.kbg-card:hover { background: rgba(255, 255, 255, 0.04); }
.kbg-card-col {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #0b0f19;
    padding: 2px 7px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}
.kbg-card-title {
    flex: 1;
    color: var(--text, #e5e7eb);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kbg-card-due {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    font-variant-numeric: tabular-nums;
}
.kbg-no-cards {
    color: var(--text-muted, #9ca3af);
    font-size: 12px;
    font-style: italic;
    padding: 6px 4px;
}
.btn-xs {
    font-size: 11px;
    padding: 2px 8px;
}

/* ── Kanban tags ─────────────────────────────────────────────────────────── */
.kb-tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 6px 0 2px;
}
.kb-tag-chips.on-card { margin: 4px 0 0; }
.kb-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    color: #0b0f19;
    padding: 2px 8px;
    border-radius: 999px;
    line-height: 1.3;
}
.kb-tag-chip.removable { padding-right: 4px; }
.kb-tag-chip-x {
    background: rgba(0, 0, 0, 0.2);
    color: inherit;
    border: 0;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    line-height: 14px;
    padding: 0;
    cursor: pointer;
    font-size: 11px;
}
.kb-tag-chip-x:hover { background: rgba(0, 0, 0, 0.4); }

/* Picker inside the card modal */
.kb-tag-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    margin-bottom: 8px;
}
.kb-tag-add-row { display: flex; gap: 6px; }
.kb-tag-add-row input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border, #1f2937);
    color: var(--text, #e5e7eb);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}
.kb-tag-suggest {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg, #0b0f19);
    border: 1px solid var(--border, #1f2937);
    border-radius: 8px;
    max-height: 160px;
    overflow-y: auto;
    z-index: 40;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.kb-tag-suggest-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 0;
    background: transparent;
    color: var(--text, #e5e7eb);
    text-align: left;
    cursor: pointer;
    font-size: 13px;
}
.kb-tag-suggest-item:hover { background: rgba(255, 255, 255, 0.06); }
.kb-tag-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Global view tag filter bar */
.kbg-tag-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 0 14px;
    border-bottom: 1px solid var(--border, #1f2937);
    margin-bottom: 14px;
}
.kbg-tag-bar-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #9ca3af);
    margin-right: 4px;
}
.kbg-tag-pill {
    --tag-color: #6c63ff;
    background: transparent;
    border: 1px solid var(--tag-color);
    color: var(--text, #e5e7eb);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.12s;
}
.kbg-tag-pill:hover { background: color-mix(in srgb, var(--tag-color) 20%, transparent); }
.kbg-tag-pill.active {
    background: var(--tag-color);
    color: #0b0f19;
    font-weight: 600;
}
.kbg-tag-clear {
    background: transparent;
    border: 0;
    color: var(--text-muted, #9ca3af);
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
    padding: 3px 6px;
}
.kbg-tag-clear:hover { color: var(--text, #e5e7eb); }

/* Clickable chips on cards: turn into filter triggers */
.kb-tag-chip.clickable {
    cursor: pointer;
    transition: transform 0.08s, box-shadow 0.12s;
}
.kb-tag-chip.clickable:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* "Filter: [chip] Reset" strip, used on both Global and the board view.
   Replaces the always-visible tag bar — only shows when a filter is active. */
.kb-active-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.25);
    border-radius: 8px;
    margin: 0 0 12px;
}
.kb-active-filter-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #9ca3af);
}
.kb-active-filter-reset {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border, #374151);
    color: var(--text, #e5e7eb);
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
}
.kb-active-filter-reset:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ── Kanban assignees ────────────────────────────────────────────────────── */
.kb-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--av-color, #6c63ff);
    color: #fff;
    border-radius: 50%;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--bg, #0b0f19);
}
.kb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.kb-avatar-xs { width: 16px; height: 16px; font-size: 9px; }
.kb-avatar-sm { width: 22px; height: 22px; font-size: 11px; }
.kb-avatar-md { width: 28px; height: 28px; font-size: 12px; }
.kb-avatar.clickable {
    cursor: pointer;
    transition: transform 0.08s;
}
.kb-avatar.clickable:hover { transform: translateY(-1px) scale(1.08); }
.kb-avatar.kb-avatar-more {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text, #e5e7eb);
    font-size: 10px;
}

/* Avatar stack at bottom of card */
.kb-avatar-stack {
    display: inline-flex;
    align-items: center;
}
.kb-avatar-stack .kb-avatar + .kb-avatar { margin-left: -6px; }

/* Card foot: holds avatars + due date side-by-side */
.kanban-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}
.kanban-card-foot:empty { display: none; }

/* Assignee chip (picker selected + active filter strip) */
.kb-assignee-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}
.kb-assignee-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px 2px 2px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border, #1f2937);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text, #e5e7eb);
}
.kb-assignee-chip .kb-assignee-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.kb-assignee-chip.removable { padding-right: 4px; }

/* Picker container */
.kb-assignee-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    margin-bottom: 8px;
}

/* Global Kanban Sidebar @me button */
#kbg-my-cards {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Preserve the natural case of labels even if the parent .field has a
   text-transform:uppercase rule applied. Avoids the section header
   styling bleeding into the row items. */
.rail-pref-label { text-transform: none; }

/* Hover ✕ on each rail-btn. Sits in the top-right corner of the button,
   only visible on hover. Click hides the button (and toasts). Pure cosmetic
   element — the actual hiding logic lives in _railToggle. */
.rail-btn { position: relative; }
.rail-btn .rail-hide-x {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    line-height: 14px;
    text-align: center;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.85);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    transform: scale(0.7);
}
.rail-btn:hover .rail-hide-x {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}
.rail-btn .rail-hide-x:hover { background: #ef4444; }

/* Space "Home" shortcut at the top of the channels list. Centered
   button styled like the other small action buttons in the sidebar
   (matches .btn-add-channel and friends) — no icon, just the label. */
.channel-home-btn {
    display: block;
    width: 100%;
    margin: 6px 0 10px;
    padding: 8px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
}
.channel-home-btn:hover {
    background: rgba(108, 99, 255, 0.12);
    border-color: rgba(108, 99, 255, 0.35);
}
.channel-home-btn.active {
    background: rgba(108, 99, 255, 0.18);
    border-color: var(--primary);
    color: var(--primary);
}

/* ────────────────────────────────────────────────────────────
   Upgrade modal — used by #modal-upgrade
   ──────────────────────────────────────────────────────────── */
.modal-upgrade-box { max-width: 720px; width: 92vw; }
.upgrade-body { padding: 4px 4px 8px; }
.upgrade-tagline {
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 18px;
    text-align: center;
}
.upgrade-interval-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    margin: 0 auto 20px;
    width: max-content;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}
.upgrade-interval-btn {
    background: transparent;
    border: 0;
    padding: 8px 18px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background .15s, color .15s;
}
.upgrade-interval-btn.active {
    background: var(--primary);
    color: #fff;
}
.upgrade-save-badge {
    background: rgba(0, 200, 130, 0.18);
    color: #2bdc9a;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: .2px;
}
.upgrade-plans {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 4px;
}
@media (max-width: 600px) {
    .upgrade-plans { grid-template-columns: 1fr; }
}
.upgrade-plan {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    position: relative;
}
.upgrade-plan-super {
    border-color: rgba(108, 99, 255, 0.55);
    background: linear-gradient(180deg, rgba(108, 99, 255, 0.12), rgba(108, 99, 255, 0.02));
}
.upgrade-plan-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 999px;
    letter-spacing: .4px;
    text-transform: uppercase;
}
.upgrade-plan-name {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 6px;
}
.upgrade-plan-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 16px;
}
.upgrade-price-amount {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: -.5px;
}
.upgrade-price-unit {
    color: var(--muted);
    font-size: 13px;
}
.upgrade-plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13.5px;
    line-height: 1.4;
    flex: 1;
}
.upgrade-plan-features li { color: var(--text, #fff); }
.upgrade-plan-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    padding: 11px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, transform .12s;
    text-align: center;
}
.upgrade-plan-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}
.upgrade-plan-btn-super {
    background: var(--primary);
    border-color: var(--primary);
}
.upgrade-plan-btn-super:hover {
    background: #5a52e0;
    border-color: #5a52e0;
}
.upgrade-fine-print {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    margin: 18px 0 0;
}

/* Home-page Upgrade button — pump up visibility */
.home-upgrade-btn {
    background: var(--primary);
    color: #fff;
    border: 0;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(108, 99, 255, 0.45);
    transition: transform .12s, box-shadow .12s;
}
.home-upgrade-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(108, 99, 255, 0.6);
}

/* Boutique : section dédiée Subscription affichée comme une bannière en haut */
.boutique-upgrade-banner {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.22), rgba(108, 99, 255, 0.06));
    border: 1px solid rgba(108, 99, 255, 0.4);
    border-radius: 14px;
    padding: 18px 22px;
    margin: 8px 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.boutique-upgrade-banner .bub-title {
    font-size: 16px;
    font-weight: 800;
    margin: 0 0 4px;
}
.boutique-upgrade-banner .bub-desc {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}
.boutique-upgrade-banner .bub-cta {
    background: var(--primary);
    color: #fff;
    border: 0;
    padding: 11px 22px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 18px rgba(108, 99, 255, 0.45);
    transition: transform .12s, box-shadow .12s;
}
.boutique-upgrade-banner .bub-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(108, 99, 255, 0.6);
}
.boutique-upgrade-banner.hidden { display: none; }

/* Top-bar tier pill — visible to ALL users next to PANIC */
.topbar-tier-btn {
    background: var(--primary);
    color: #fff;
    border: 0;
    padding: 5px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .3px;
    cursor: pointer;
    margin-left: 8px;
    box-shadow: 0 3px 14px rgba(108, 99, 255, 0.45);
    transition: transform .12s, box-shadow .12s, background .12s;
    white-space: nowrap;
}
.topbar-tier-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 18px rgba(108, 99, 255, 0.6);
}
.topbar-tier-paid {
    background: linear-gradient(135deg, #6c63ff, #8d7bff);
}
.topbar-tier-super {
    background: linear-gradient(135deg, #ffb547, #ff8a3d);
    box-shadow: 0 3px 14px rgba(255, 138, 61, 0.45);
}
.topbar-tier-super:hover {
    box-shadow: 0 5px 18px rgba(255, 138, 61, 0.6);
}
.topbar-tier-btn.hidden { display: none; }

/* Manage subscription modal */
.modal-subscription-box { max-width: 460px; width: 92vw; }
.sub-body { padding: 6px 4px 4px; }
.sub-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 14px;
}
.sub-info-row:last-of-type { border-bottom: 0; }
.sub-label {
    color: var(--muted);
    font-size: 13px;
}
.sub-value { font-weight: 700; }
.sub-actions { margin-top: 18px; }
.sub-btn-portal {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: 0;
    padding: 12px 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, transform .12s;
}
.sub-btn-portal:hover {
    background: #5a52e0;
    transform: translateY(-1px);
}
.sub-portal-hint {
    color: var(--muted);
    font-size: 12px;
    margin: 12px 0 0;
    text-align: center;
    line-height: 1.4;
}
.sub-btn-cancel {
    width: 100%;
    background: transparent;
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.4);
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
    transition: background .15s, border-color .15s;
}
.sub-btn-cancel:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.7);
}
.sub-btn-cancel.hidden { display: none; }
.sub-info-row .sub-value.is-cancelled {
    color: #f87171;
    font-size: 13px;
}

