/* ──────────────────────────────────────────────────────────────────────────
   AG Chat — futuristic stylesheet.
   Palette inherits AG (navy + orange) but layers in gradient accents,
   glassmorphism panels, soft shadows, and micro-animations throughout.
   ────────────────────────────────────────────────────────────────────────── */

:root[data-theme="dark"] {
  --bg-base:    #060a14;
  --bg-rail:    #04070d;
  --bg-sidebar: #080d18;
  --bg-chat:    #0a1220;
  --bg-hover:   rgba(255,255,255,.04);
  --bg-active:  rgba(56,189,248,.12);
  --bg-input:   rgba(255,255,255,.04);
  --bg-card:    rgba(255,255,255,.03);
  --bg-glass:   rgba(20,30,50,.55);
  --bg-msg:     rgba(255,255,255,.025);
  --accent:     #38bdf8;
  --accent-2:   #22d3ee;
  --accent-dim: #2563eb;
  --grad:       linear-gradient(135deg, #38bdf8 0%, #22d3ee 100%);
  --grad-soft:  linear-gradient(135deg, rgba(56,189,248,.18), rgba(34,211,238,.05));
  --grad-cool:  linear-gradient(135deg, #4a7dff 0%, #8b5cf6 100%);
  --glow:       0 0 24px rgba(56,189,248,.30);
  --glow-soft:  0 0 16px rgba(56,189,248,.18);
  --t1:         #f3f7fc;
  --t2:         #b3c2d6;     /* +readability: brighter than before */
  --t3:         #6a7d96;     /* +readability bump */
  --divider:    rgba(255,255,255,.06);
  --divider-2:  rgba(255,255,255,.10);
  --bubble-me:    linear-gradient(135deg, rgba(56,189,248,.16), rgba(56,189,248,.08));
  --bubble-other: rgba(255,255,255,.04);
  --col-error:  #f43f5e;
  --col-ok:     #22d3a5;
  --col-warn:   #f59e0b;
  --col-info:   #4a7dff;
  --st-online:  #22d3a5;
  --st-away:    #f59e0b;
  --st-busy:    #f43f5e;
  --st-offline: #4a5a78;
  --role-1:     #d4a800;
  --role-2:     #8b8b8b;
  --role-3:     #0ea5e9;
  --role-4:     #a855f7;
  --role-5:     #4a7dff;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.4);
  --shadow:     0 4px 16px rgba(0,0,0,.45);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.55);
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
}

:root[data-theme="light"] {
  --bg-base:    #f4f7fb;
  --bg-rail:    #1b2d5b;
  --bg-sidebar: #f8fafd;          /* slightly tinted for sidebar contrast */
  --bg-chat:    #ffffff;
  --bg-hover:   rgba(27,45,91,.06);
  --bg-active:  rgba(56,189,248,.10);
  --bg-input:   #f0f4f9;
  --bg-card:    #ffffff;
  --bg-glass:   rgba(255,255,255,.85);
  --bg-msg:     #eef3f9;
  --accent:     #2563eb;          /* darker orange — stronger contrast on white */
  --accent-2:   #38bdf8;
  --accent-dim: #1d4ed8;
  --grad:       linear-gradient(135deg, #2563eb, #38bdf8);
  --grad-soft:  linear-gradient(135deg, rgba(56,189,248,.10), rgba(34,211,238,.03));
  --grad-cool:  linear-gradient(135deg, #4a7dff, #8b5cf6);
  --glow:       0 0 24px rgba(56,189,248,.30);
  --glow-soft:  0 0 16px rgba(56,189,248,.15);
  --t1:         #14213d;          /* near-black navy for max readability */
  --t2:         #344563;
  --t3:         #5b6b85;
  --divider:    rgba(27,45,91,.14);
  --divider-2:  rgba(27,45,91,.22);
  --bubble-me:    linear-gradient(135deg, rgba(56,189,248,.14), rgba(34,211,238,.08));
  --bubble-other: #f0f4f9;
  --col-error:  #dc2626;
  --col-ok:     #059669;
  --col-warn:   #d97706;
  --col-info:   #2563eb;
  --st-online:  #22d3a5;
  --st-away:    #f59e0b;
  --st-busy:    #f43f5e;
  --st-offline: #b0bcc9;
  --role-1:     #d4a800;
  --role-2:     #6b7280;
  --role-3:     #0ea5e9;
  --role-4:     #a855f7;
  --role-5:     #4a7dff;
  --shadow-sm:  0 1px 2px rgba(27,45,91,.06);
  --shadow:     0 6px 24px rgba(27,45,91,.10);
  --shadow-lg:  0 20px 60px rgba(27,45,91,.18);
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body {
  height: 100%; margin: 0; overflow: hidden;
  background: var(--bg-base); color: var(--t1);
  font-family: -apple-system, "Segoe UI", "Inter", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
body::before {
  /* Subtle ambient gradient backdrop — adds depth without distraction. */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(74,125,255,.08), transparent 70%),
    radial-gradient(ellipse 60% 50% at 90% 90%, rgba(56,189,248,.10), transparent 70%);
}
button, input, textarea, select { font: inherit; color: inherit; outline: none; }
button { cursor: pointer; background: transparent; border: 0; }
input, textarea, select {
  background: var(--bg-input);
  border: 1px solid var(--divider);
  color: var(--t1); border-radius: var(--r-md); padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, textarea:hover, select:hover { border-color: var(--divider-2); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.18);
  background: var(--bg-card);
}
/* Native <option> elements ignore most CSS, but Chromium honors background
   + color when set explicitly. This is critical for dark-mode legibility —
   without it, the dropdown opens with white text on a near-white OS panel.
   `color-scheme: dark` triggers Chromium's dark dropdown chrome. */
:root[data-theme="dark"] select { color-scheme: dark; }
:root[data-theme="light"] select { color-scheme: light; }
select option, select optgroup {
  background: var(--bg-card);
  color: var(--t1);
}
select option:checked {
  background: var(--grad-soft);
  color: var(--t1);
}
ul { margin: 0; padding: 0; list-style: none; }
a  { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted  { color: var(--t2); }
.dim    { color: var(--t3); }
.error  { color: var(--col-error); }
.ok     { color: var(--col-ok); }
.warn   { color: var(--col-warn); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--divider-2); border-radius: 5px;
  border: 2px solid transparent; background-clip: padding-box;
  transition: background .2s;
}
::-webkit-scrollbar-thumb:hover { background: var(--t3); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px) scale(.98);} to { opacity: 1; transform: none; } }
@keyframes pulse  { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .6; transform: scale(1.06); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── View switcher ───────────────────────────────────────────────────────── */
.view { display: none; height: 100vh; position: relative; z-index: 1; }
.view.active { display: flex; animation: fadeIn .25s ease-out; }

/* ────────────────────────────────────────────────────────────────────────── */
/*                           LOGIN                                            */
/* ────────────────────────────────────────────────────────────────────────── */
.login-brand-img {
  height: 64px; width: auto; display: block; margin-bottom: 14px;
  filter: drop-shadow(0 8px 24px rgba(56,189,248,.30));
}
#login-view {
  align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 30% 25%, rgba(56,189,248,.18), transparent 55%),
    radial-gradient(circle at 70% 75%, rgba(74,125,255,.14), transparent 55%),
    var(--bg-base);
}
.login-card {
  width: 380px; padding: 36px 32px;
  background: var(--bg-glass); backdrop-filter: blur(24px);
  border: 1px solid rgba(56,189,248,.22);
  border-radius: var(--r-xl);
  box-shadow:
    0 24px 80px -8px rgba(56,189,248,.32),
    inset 0 1px 0 rgba(255,255,255,.06);
  display: flex; flex-direction: column; align-items: center;
  animation: slideUp .35s ease-out;
}
.login-logo {
  width: 72px; height: 72px; border-radius: 18px;
  background: linear-gradient(135deg, #1b2d5b 0%, #243966 100%);
  position: relative; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; color: #fff; font-size: 22px; letter-spacing: 1px;
  box-shadow: 0 8px 32px rgba(56,189,248,.20), inset 0 1px 0 rgba(255,255,255,.10);
}
.login-logo::after {
  content: ""; position: absolute; right: 6px; bottom: 6px;
  width: 18px; height: 18px; background: var(--grad); border-radius: 5px;
  box-shadow: var(--glow-soft);
}
.login-title {
  font-size: 24px; font-weight: 900; letter-spacing: 4px;
  background: linear-gradient(180deg, var(--t1), rgba(255,255,255,.6));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-subtitle {
  color: var(--accent); font-size: 11px; font-weight: 700;
  letter-spacing: 2.4px; margin-top: 2px;
}
.login-caption {
  color: var(--t3); font-size: 8px; letter-spacing: 2.5px;
  margin-top: 4px; margin-bottom: 18px;
}
.login-divider {
  width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56,189,248,.30), transparent);
  margin: 4px 0 18px;
}
#login-username {
  width: 100%; height: 48px; padding: 12px 14px;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  border-radius: var(--r-md); font-size: 14px; color: var(--t1);
  margin-bottom: 18px;
}
.pin-label {
  width: 100%; color: var(--t3); font-size: 11px;
  letter-spacing: 1.4px; text-transform: uppercase; margin-bottom: 10px;
}
.pin-dots {
  display: flex; justify-content: center; gap: 16px; margin-bottom: 24px;
}
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--t3); background: transparent;
  transition: all .18s cubic-bezier(.34, 1.56, .64, 1);
}
.pin-dot.filled {
  background: var(--grad); border-color: transparent;
  box-shadow: var(--glow-soft);
  transform: scale(1.1);
}
.pin-dot.error  { background: var(--col-error); border-color: var(--col-error); animation: pulse .4s ease; }

.numpad {
  display: grid; grid-template-columns: repeat(3, 76px);
  gap: 10px; margin-bottom: 14px;
}
.numpad button {
  height: 54px; border-radius: var(--r-md); font-size: 18px; font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--divider-2);
  color: var(--t1);
  transition: all .15s ease;
}
.numpad button:hover {
  background: rgba(56,189,248,.10);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.numpad button:active { transform: scale(.94); }
.numpad button.bs { color: var(--col-error); }
.numpad button.bs:hover { background: rgba(244,63,94,.10); border-color: var(--col-error); }
.numpad button.ok { color: var(--col-ok); }
.numpad button.ok:hover { background: rgba(34,211,165,.10); border-color: var(--col-ok); }
.login-status { color: var(--col-error); font-size: 12px; min-height: 18px; }

/* ────────────────────────────────────────────────────────────────────────── */
/*                           DASHBOARD SHELL                                  */
/* ────────────────────────────────────────────────────────────────────────── */
#chat-view { flex-direction: column; }

/* ── TopBar ──────────────────────────────────────────────────────────────── */
#topbar {
  height: 64px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(4,7,13,.97), rgba(8,13,24,.88));
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--divider);
  display: flex; align-items: center; padding: 0 18px;
  position: relative; z-index: 10;
  box-shadow: 0 4px 24px rgba(0,0,0,.30);
}
#topbar .brand .logo-img {
  height: 38px; width: auto; display: block;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.45));
}
:root[data-theme="light"] #topbar {
  background: linear-gradient(180deg, #1b2d5b, #243966);
  color: #fff;
}
#topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56,189,248,.40), transparent);
}
#topbar .brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
#topbar .brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #1b2d5b, #243966);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; color: #fff; font-size: 13px; letter-spacing: .5px;
  position: relative;
  box-shadow: 0 4px 16px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.10);
}
#topbar .brand-logo::after {
  content: ""; position: absolute; right: 4px; bottom: 4px;
  width: 10px; height: 10px; background: var(--grad); border-radius: 3px;
  box-shadow: var(--glow-soft);
}
#topbar .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
#topbar .brand-text .t1 {
  color: #fff; font-size: 14px; font-weight: 800; letter-spacing: 1.6px;
  background: linear-gradient(180deg, #fff, rgba(255,255,255,.7));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#topbar .brand-text .t2 { color: var(--accent-2); font-size: 9px; font-weight: 700; letter-spacing: 1.2px; }

#topbar .search-wrap { flex: 1; padding: 0 28px; }
#topbar .search-wrap input {
  width: 100%; max-width: 600px; height: 40px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff; border-radius: 999px;
  padding: 0 18px;
  transition: all .2s;
}
#topbar .search-wrap input:hover  { background: rgba(255,255,255,.12); }
#topbar .search-wrap input:focus  {
  background: rgba(255,255,255,.14);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.22);
}
#topbar .search-wrap input::placeholder { color: rgba(255,255,255,.55); }

#topbar .right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
#topbar .clock {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 12px; border-radius: var(--r-md);
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.06);
  line-height: 1.1; color: #fff;
}
#topbar .clock .time { font-size: 13px; font-weight: 700; letter-spacing: .5px; }
#topbar .clock .date { font-size: 9px; opacity: .7; margin-top: 1px; }
#topbar .icon-pill {
  width: 38px; height: 38px; border-radius: var(--r-md);
  background: rgba(255,255,255,.08); color: #fff;
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: all .15s;
  border: 1px solid transparent;
}
#topbar .icon-pill:hover {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.10);
  transform: translateY(-1px);
}
#topbar .icon-pill.signout {
  background: linear-gradient(135deg, rgba(244,63,94,.16), rgba(244,63,94,.06));
  border-color: rgba(244,63,94,.22);
  color: #ffb4be;
}
#topbar .icon-pill.signout:hover {
  background: var(--col-error); color: #fff;
  border-color: var(--col-error);
}
#topbar .icon-pill:active { transform: scale(.94); }
#topbar .pill-divider { width: 1px; height: 22px; background: rgba(255,255,255,.18); margin: 0 4px; }

#topbar .badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--grad); color: #fff;
  border-radius: 9px; font-size: 9px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(56,189,248,.40);
  border: 2px solid var(--bg-rail);
  animation: slideUp .3s ease-out;
}
#topbar .badge.error { background: var(--col-error); box-shadow: 0 2px 6px rgba(244,63,94,.40); }

#topbar .avatar-pill {
  width: 42px; height: 42px; border-radius: var(--r-md);
  background: rgba(255,255,255,.10); padding: 4px;
  position: relative; cursor: pointer; transition: all .15s;
  border: 1px solid rgba(255,255,255,.10);
}
#topbar .avatar-pill:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: var(--glow-soft);
}

/* Layout below TopBar */
#shell-row { flex: 1; display: flex; min-height: 0; position: relative; z-index: 1; }

/* ── AppRail ─────────────────────────────────────────────────────────────── */
#rail {
  width: 64px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(4,7,13,.85), rgba(4,7,13,.95));
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--divider);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 6px;
  transition: width .18s cubic-bezier(.4,0,.2,1);
}
:root[data-rail="expanded"] #rail { width: 196px; align-items: stretch; padding: 12px 8px; }
:root[data-rail="expanded"] #rail .nav-btn {
  width: 100%; justify-content: flex-start; padding: 0 12px; gap: 12px;
}
.nav-label {
  display: none;
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden;
}
:root[data-rail="expanded"] #rail .nav-label { display: inline; }
.rail-ctrl-row {
  display: flex; gap: 6px; margin: 6px 8px 10px; align-self: stretch;
}
/* Subtle theme-native rail control buttons.
   Default: low-contrast border, no fill — visually disappears when not in use.
   Hover: accent tint. Active (pinned): solid gradient pill. */
.rail-toggle, .rail-pin {
  flex: 1; height: 30px; border-radius: 8px;
  background: transparent; color: var(--t3);
  border: 1px solid var(--divider);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s ease;
  padding: 0;
}
.rail-toggle .icn, .rail-pin .icn { width: 14px; height: 14px; }
.rail-toggle:hover, .rail-pin:hover {
  color: var(--accent); border-color: var(--accent);
  background: rgba(56,189,248,.06);
}
.rail-pin.on {
  background: var(--grad); color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px rgba(56,189,248,.35);
}
.rail-pin.on:hover { color: #fff; }
:root[data-rail="expanded"] .rail-ctrl-row { gap: 6px; }
#rail .rail-logo { width: 30px; height: 30px; margin-bottom: 8px; opacity: .9; }
#rail .nav-btn {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--t2); position: relative;
  transition: all .2s cubic-bezier(.4, 0, .2, 1);
  cursor: pointer;
}
#rail .nav-btn::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 0; border-radius: 0 4px 4px 0;
  background: var(--grad);
  transition: height .25s cubic-bezier(.4, 0, .2, 1);
  box-shadow: var(--glow-soft);
}
#rail .nav-btn:hover {
  background: var(--bg-hover);
  color: var(--t1);
  transform: translateX(2px);
}
#rail .nav-btn.active {
  background: var(--grad-soft);
  color: var(--accent);
}
#rail .nav-btn.active::before { height: 24px; }
#rail .nav-btn .badge {
  position: absolute; top: 6px; right: 6px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--grad); color: #fff;
  border-radius: 9px; font-size: 9px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(56,189,248,.40);
  border: 2px solid var(--bg-rail);
}
#rail .spacer { flex: 1; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: 256px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(8,13,24,.80), rgba(8,13,24,.90));
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--divider);
  display: flex; flex-direction: column; min-height: 0;
}
:root[data-theme="light"] #sidebar {
  /* Solid tinted background (no glassy translucency) so light text never
     fights the gradient body backdrop. */
  background: var(--bg-sidebar);
  backdrop-filter: none;
}
:root[data-theme="light"] .room-row { color: var(--t1); }
:root[data-theme="light"] .room-row .label { opacity: 1; font-weight: 500; }
:root[data-theme="light"] .room-row .icn  { color: var(--t2); }
:root[data-theme="light"] #sidebar .section-head { color: var(--t2); }
:root[data-theme="light"] #sidebar .me-bar .name { color: var(--t1); }
:root[data-theme="light"] #sidebar .ws-header .name { color: var(--t1); }
:root[data-theme="light"] .room-row.active { color: var(--accent); }
:root[data-theme="light"] .room-row.active .icn { color: var(--accent); }

/* Self-chat — pinned at the top of the DM list (shows your own name, Teams style) */
.saved-row { border-bottom: 1px solid rgba(127,127,127,.16); }
.self-you { color: var(--t3); font-weight: 400; font-size: .92em; }

/* ── Help Center ─────────────────────────────────────────────────────────── */
.help-center {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(8,12,22,.55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
}
.hc-panel {
  width: min(920px, 100%); height: min(86vh, 900px);
  display: flex; flex-direction: column;
  background: var(--bg-app, #fff); color: var(--t1);
  border: 1px solid rgba(127,127,127,.18); border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0,0,0,.4); overflow: hidden;
}
.hc-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid rgba(127,127,127,.15);
}
.hc-search {
  flex: 1; height: 40px; border-radius: 10px; padding: 0 14px;
  border: 1px solid rgba(127,127,127,.25); background: var(--bg-sidebar, #f6f8fc);
  color: var(--t1); font-size: 15px;
}
.hc-iconbtn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--t2); cursor: pointer;
}
.hc-iconbtn:hover { background: rgba(127,127,127,.12); color: var(--t1); }
.hc-close:hover { color: var(--col-error, #e5484d); }
.hc-body { flex: 1; overflow-y: auto; padding: 22px 26px; }
.hc-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 18px; border-top: 1px solid rgba(127,127,127,.15);
  font-size: 12.5px; flex-wrap: wrap;
}
.hc-foot a { color: var(--accent); text-decoration: none; }
.hc-foot-credit { font-size: 11.5px; }

.hc-title { font-size: 20px; margin: 0 0 6px; color: var(--t1); }
.hc-sub { color: var(--t2); margin: 0 0 18px; }
.hc-h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--t2); margin: 22px 0 10px; }
.hc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.hc-cat {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  padding: 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(127,127,127,.18); background: var(--bg-sidebar, #f7f9fc);
}
.hc-cat:hover { border-color: var(--accent); transform: translateY(-1px); }
.hc-cat-ic { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px;
  display: grid; place-items: center; background: var(--accent); color: #fff; }
.hc-cat-name { font-weight: 600; color: var(--t1); }
.hc-cat-blurb { font-size: 12.5px; color: var(--t2); margin-top: 2px; }

.hc-list { display: flex; flex-direction: column; gap: 4px; }
.hc-link {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 12px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--t1); font-size: 14.5px;
}
.hc-link:hover { background: rgba(127,127,127,.1); }
.hc-link-c { color: var(--t3); font-size: 12.5px; }

.hc-crumb { font-size: 12.5px; color: var(--t2); margin-bottom: 8px; }
.hc-crumb-link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12.5px; }
.hc-intro { color: var(--t1); margin: 4px 0 14px; line-height: 1.5; }
.hc-steps { margin: 0 0 14px; padding-left: 22px; line-height: 1.7; }
.hc-steps li { margin-bottom: 6px; }
.hc-shot-wrap { margin: 10px 0 16px; }
.hc-shot { max-width: 100%; border-radius: 10px; border: 1px solid rgba(127,127,127,.2); }
.hc-note {
  display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; margin: 6px 0 14px;
  border-radius: 10px; background: rgba(127,127,127,.08); font-size: 13.5px;
}
.hc-tips {
  border-left: 3px solid var(--accent); background: rgba(196,82,30,.06);
  padding: 10px 14px; border-radius: 8px; margin: 6px 0 14px;
}
.hc-tips-h { font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); margin-bottom: 4px; }
.hc-tips ul { margin: 0; padding-left: 18px; line-height: 1.6; font-size: 13.5px; }
.hc-backrow { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.hc-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 9px 14px; border-radius: 9px; font-size: 13.5px;
  border: 1px solid rgba(127,127,127,.22); background: var(--bg-sidebar, #f7f9fc); color: var(--t1);
}
.hc-btn:hover { border-color: var(--accent); }

/* Contextual "?" help pill in the top bar */
.icon-pill.help-pill { font-weight: 700; font-size: 16px; line-height: 1; }

/* Mobile-friendly */
@media (max-width: 640px) {
  .help-center { padding: 0; }
  .hc-panel { width: 100%; height: 100%; border-radius: 0; }
  .hc-body { padding: 16px; }
  .hc-grid { grid-template-columns: 1fr; }
}
#sidebar .ws-header {
  padding: 14px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--divider); cursor: pointer;
  transition: background .15s;
}
#sidebar .ws-header:hover { background: var(--bg-hover); }
#sidebar .ws-header .hex {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--grad-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px;
  border: 1px solid rgba(56,189,248,.20);
}
#sidebar .ws-header .name { font-size: 13px; font-weight: 700; flex: 1; letter-spacing: .3px; }

#sidebar .me-bar {
  padding: 10px 14px; border-bottom: 1px solid var(--divider);
  display: flex; align-items: center; gap: 10px;
}
#sidebar .me-bar .name { font-size: 12px; flex: 1; color: var(--t1); font-weight: 600; }
#sidebar .me-bar select {
  font-size: 11px; padding: 5px 22px 5px 8px; cursor: pointer;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  color: var(--t1); font-weight: 600;
  border-radius: 6px;
  /* Custom chevron (themed) — replaces the OS-native one for consistency */
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%23a0a8b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
}
#sidebar .me-bar select:hover  { border-color: var(--accent); color: var(--t1); }
#sidebar .me-bar select:focus  { border-color: var(--accent); }
#sidebar .me-bar select option {
  background: var(--bg-card);
  color: var(--t1);
  padding: 6px;
}

#sidebar .section-head {
  padding: 16px 16px 6px;
  font-size: 10px; font-weight: 800; letter-spacing: 1.5px;
  color: var(--t2); text-transform: uppercase;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
  transition: color .15s;
}
#sidebar .section-head:hover { color: var(--t2); }
#sidebar .section-head .chev { transition: transform .15s; font-size: 12px; opacity: .7; }
#sidebar .section-head.collapsed .chev { transform: rotate(-90deg); }
#sidebar .section-body { padding: 2px 0 4px; }
#sidebar .section-body.collapsed { display: none; }
#sidebar .scroll-area { flex: 1; overflow-y: auto; }

.room-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 1px 8px;
  border-radius: var(--r-md); cursor: pointer; font-size: 14px;
  color: var(--t1);
  transition: all .15s ease;
  position: relative;
}
.room-row .label, .dm-row .label { color: inherit; opacity: .92; font-weight: 500; }
.room-row:hover { background: var(--bg-hover); transform: translateX(2px); }
.room-row:hover .label { opacity: 1; }
.room-row.active {
  background: var(--grad-soft); color: var(--t1); font-weight: 600;
  border: 1px solid rgba(56,189,248,.20);
}
.room-row.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 0 3px 3px 0;
  background: var(--grad); box-shadow: var(--glow-soft);
}
.room-row .icn { font-size: 13px; opacity: .8; flex-shrink: 0; }
.room-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-row.has-mention .label { color: var(--col-warn); font-weight: 700; }
.room-row .badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--grad); color: #fff; border-radius: 10px;
  font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(56,189,248,.30);
}
.dm-row .stack {
  position: relative; width: 26px; height: 26px;
}
.dm-row .dm-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.1; }
.dm-row .dm-meta .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-row .dm-meta .dm-status {
  font-size: 10px; font-weight: 600; letter-spacing: .3px;
  text-transform: capitalize; opacity: .85;
}
.dm-row .dm-meta .dm-status.online  { color: var(--st-online); }
.dm-row .dm-meta .dm-status.away    { color: var(--st-away); }
.dm-row .dm-meta .dm-status.busy    { color: var(--st-busy); }
.dm-row .dm-meta .dm-status.offline { color: var(--t3); }

#sidebar .section-head .online-count {
  font-size: 9px; font-weight: 700; letter-spacing: .8px;
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--st-online); background: rgba(34,211,165,.08);
  padding: 2px 8px; border-radius: 999px;
  text-transform: none;
}

/* Per-row mute button (bell) */
.row-mute {
  width: 26px; height: 26px; border-radius: 6px;
  display: none; align-items: center; justify-content: center;
  color: var(--t3); transition: all .12s;
  flex-shrink: 0;
}
.row-mute:hover { background: var(--bg-hover); color: var(--accent); }
.room-row:hover .row-mute,
.room-row.muted   .row-mute { display: flex; }
.room-row.muted   { opacity: .82; }
.room-row.muted .row-mute { color: var(--accent); }
.room-row.muted .row-mute.on { color: var(--accent); }
.room-row.muted .label::after {
  content: " · muted"; font-size: 10px; color: var(--t3); font-weight: 400;
}

/* Mute popup menu */
.mute-menu {
  position: fixed; z-index: 1500;
  background: var(--bg-glass); backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--divider-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 220px;
  animation: slideUp .15s ease-out;
}
.mute-menu .mh {
  padding: 6px 10px 8px; font-size: 11px; font-weight: 700;
  letter-spacing: .8px; text-transform: uppercase; color: var(--t3);
  border-bottom: 1px solid var(--divider);
}
.mute-menu .mi {
  padding: 8px 10px; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; border-radius: 6px;
  transition: background .12s;
}
.mute-menu .mi:hover { background: var(--bg-hover); }

/* Bulk select bar */
.bulk-bar {
  padding: 10px 18px; display: flex; align-items: center; gap: 10px;
  background: var(--grad-soft);
  border-bottom: 1px solid rgba(56,189,248,.20);
  animation: slideUp .2s ease-out;
}
.bulk-bar strong { font-size: 13px; color: var(--accent); }
.bulk-bar button { padding: 6px 12px; font-size: 12px; }
.bulk-mode .msg.mine { padding-left: 36px; }
.bulk-mode .bulk-check {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; accent-color: var(--accent);
  cursor: pointer;
}
.bulk-mode .msg:not(.mine) .bulk-check { opacity: .25; cursor: not-allowed; }
.bulk-mode .msg.selected { background: var(--grad-soft); border-radius: 8px; }

/* Rail icon contrast bump */
#rail .nav-btn .icn { width: 22px; height: 22px; stroke-width: 2.2; }
#rail .nav-btn { color: rgba(234,241,250,.62); }
#rail .nav-btn:hover { color: rgba(234,241,250,.95); }
#rail .nav-btn.active { color: var(--accent); }
#rail .rail-logo { opacity: 1; }
#rail .nav-btn.help { margin-bottom: 4px; color: rgba(234,241,250,.45); }
#rail .nav-btn.help:hover { color: var(--accent); }

/* Help modal */
.help-card { text-align: center; padding: 6px; }
.help-card .help-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  background: var(--grad-soft); color: var(--accent);
}
.help-card .help-icon .icn { width: 24px; height: 24px; }
.help-card h3 { margin: 0 0 6px; font-size: 18px; font-weight: 800; }
.help-card .help-contact {
  margin-top: 16px; padding: 14px; border-radius: var(--r-md);
  background: var(--bg-card); border: 1px solid var(--divider-2);
  display: flex; flex-direction: column; gap: 6px;
  align-items: center;
}
.help-card .help-contact strong {
  font-size: 10px; font-weight: 800; letter-spacing: 1.5px;
  color: var(--t3); text-transform: uppercase;
}
.help-card .help-contact a {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent); font-weight: 700;
  padding: 8px 12px; border-radius: 8px;
  background: var(--grad-soft);
  border: 1px solid rgba(56,189,248,.30);
  transition: all .15s;
}
.help-card .help-contact a:hover {
  background: var(--grad); color: #fff; border-color: transparent;
  text-decoration: none; transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(56,189,248,.40);
}

/* ── Playground ──────────────────────────────────────────────────────────── */
.playground { padding: 18px 22px; }
.playground .panel-head { margin-bottom: 12px; }
.play-grid {
  flex: 1; display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(440px, 1.4fr);
  gap: 16px; min-height: 0;
}
.play-pane {
  background: var(--bg-card); border: 1px solid var(--divider);
  border-radius: var(--r-md); display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.play-pane .pane-head {
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--divider);
  font-size: 12px;
  flex-shrink: 0;
}
.play-pane .pane-head .save-status {
  font-size: 10px; color: var(--col-ok); font-weight: 600;
  letter-spacing: .4px;
}
.play-pane .pane-head .notes-search {
  width: 220px; height: 32px; font-size: 12px;
  background: var(--bg-input); border: 1px solid var(--divider);
}
.play-pane .pane-head .notes-search:focus {
  border-color: var(--accent); background: var(--bg-card);
}
/* Multi-note layout */
.notes-layout {
  flex: 1; display: grid; grid-template-columns: 220px 1fr;
  min-height: 0; overflow: hidden;
}
.notes-sidebar {
  border-right: 1px solid var(--divider);
  padding: 10px; overflow: hidden;
  display: flex; flex-direction: column; min-height: 0;
}
.new-note-btn { width: 100%; margin-bottom: 10px; }
.notes-list { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; }
.note-item {
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid transparent;
  transition: all .12s;
}
.note-item:hover { background: var(--bg-hover); }
.note-item.active { background: var(--grad-soft); border-color: rgba(56,189,248,.30); }
.note-item-title { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item-preview { font-size: 11px; color: var(--t3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.note-item-date { font-size: 10px; color: var(--t3); margin-top: 2px; }
.notes-editor { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.editor-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--divider);
  font-size: 11px; color: var(--t3);
  flex-shrink: 0;
}
.editor-head .note-meta-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-del-btn { padding: 4px 9px !important; font-size: 11px !important; }
.note-title {
  margin: 12px 14px 0; font-size: 18px; font-weight: 800;
  background: transparent; border: 0; padding: 4px 0; box-shadow: none;
  flex-shrink: 0;
}
.note-title:focus { box-shadow: none; }
.note-body {
  flex: 1; min-height: 0;
  resize: none; border: 0; padding: 12px 14px 16px;
  font-family: -apple-system, "Segoe UI", Inter, sans-serif;
  font-size: 14px; line-height: 1.55; background: transparent; box-shadow: none;
  overflow-y: auto;
}
.note-body:focus { box-shadow: none; }

.canvas-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--divider);
  flex-wrap: wrap;
}
.canvas-toolbar button { font-size: 12px; padding: 6px 10px; }
.canvas-toolbar .btn-ghost.on {
  background: var(--grad-soft); border-color: var(--accent); color: var(--accent);
}
.canvas-wrap { flex: 1; padding: 8px; overflow: hidden; position: relative; }
.play-canvas-el {
  width: 100%; height: 100%;
  background: var(--bg-base);
  border-radius: var(--r-sm);
  cursor: crosshair; touch-action: none;
}
.swatches { display: flex; gap: 4px; }
.swatches .sw {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--divider-2);
  cursor: pointer; padding: 0;
  transition: transform .12s;
}
.swatches .sw:hover  { transform: scale(1.15); }
.swatches .sw.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(56,189,248,.30); }

@media (max-width: 900px) {
  .play-grid { grid-template-columns: 1fr; }
}

/* ── Unified Playground (notes + embedded drawings) ──────────────────────── */
/* play-grid-unified is a single full-height pane (no separate Whiteboard
   column). Inside, notes-layout-v3 is sidebar | editor. The editor has
   three view modes: text, drawing, split — toggled via tabs. */
.play-grid-unified {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
  padding: 12px; gap: 0;
}
.play-pane.play-unified {
  flex: 1; min-height: 0;
  background: var(--bg-card);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.play-pane.play-unified .pane-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--t2);
  flex-shrink: 0;
}
.play-pane.play-unified .save-status {
  font-size: 11px; color: var(--col-ok);
  padding: 2px 8px; border-radius: 999px;
  background: rgba(34,211,165,.10);
  min-height: 18px;
}
.notes-layout-v3 {
  flex: 1; display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 0; overflow: hidden;
}

/* Editor — flex column with text on top, drawing below. View-mode classes
   (.view-text / .view-drawing / .view-split) collapse one section as the
   user toggles between modes. */
.notes-editor-v3 {
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
  position: relative;
}
.notes-editor-v3 .editor-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--divider);
  font-size: 11px; color: var(--t3); flex-shrink: 0;
}
.notes-editor-v3 .note-meta-text {
  flex-shrink: 0; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notes-editor-v3 .save-note-btn {
  padding: 6px 14px !important; font-size: 12px !important;
  display: inline-flex; align-items: center; gap: 5px;
}

/* View-mode tabs — pill segmented control */
.view-mode-tabs {
  display: flex; gap: 2px; padding: 3px;
  background: var(--bg-input);
  border: 1px solid var(--divider-2);
  border-radius: var(--r-md);
  margin-left: auto;
}
.vm-tab {
  padding: 5px 12px; font-size: 11px; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase;
  background: transparent; color: var(--t3);
  border: 0; border-radius: calc(var(--r-md) - 4px); cursor: pointer;
  transition: all .15s ease;
}
.vm-tab:hover { color: var(--t1); }
.vm-tab.active {
  background: var(--grad); color: #fff;
  box-shadow: var(--glow-soft);
}

.notes-editor-v3 .note-title {
  margin: 14px 16px 0; font-size: 20px; font-weight: 800;
  background: transparent; border: 0; padding: 4px 0;
  flex-shrink: 0;
  color: var(--t1);
}
.notes-editor-v3 .note-title:focus { box-shadow: none; outline: 0; }
.notes-editor-v3 .note-body {
  flex: 1 1 0; min-height: 80px;
  resize: none; border: 0; padding: 10px 16px 14px;
  font-family: -apple-system, "Segoe UI", Inter, sans-serif;
  font-size: 14px; line-height: 1.55;
  background: transparent; box-shadow: none;
  overflow-y: auto;
  color: var(--t1);
}
.notes-editor-v3 .note-body:focus { box-shadow: none; outline: 0; }

/* View-mode visibility — exact size split per mode */
.notes-editor-v3.view-text .note-draw-section { display: none; }
.notes-editor-v3.view-text .note-body { flex: 1 1 0; max-height: none; }

.notes-editor-v3.view-drawing .note-title,
.notes-editor-v3.view-drawing .note-body { display: none; }
.notes-editor-v3.view-drawing .note-draw-section {
  flex: 1 1 0; border-top: 0;
}

.notes-editor-v3.view-split .note-body {
  flex: 0 0 35%; min-height: 100px; max-height: 45%;
}
.notes-editor-v3.view-split .note-draw-section {
  flex: 1 1 0;
}

/* Embedded drawing section inside the editor */
.note-draw-section {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--divider);
  background: var(--bg-base);
}
/* Fullscreen mode — covers whole viewport for distraction-free drawing */
.note-draw-section.fullscreen {
  position: fixed; inset: 0; z-index: 4000;
  border: 0; border-radius: 0;
  background: var(--bg-card);
  flex: 1; height: 100vh; width: 100vw;
}
.note-draw-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--divider);
  font-size: 12px; color: var(--t2);
  flex-shrink: 0;
}
.note-draw-head .draw-meta { font-size: 11px; }
.note-draw-head .fs-btn {
  padding: 5px 10px; font-size: 11px;
  display: inline-flex; align-items: center; gap: 4px;
}
.note-draw-section .canvas-toolbar { background: var(--bg-card); }

/* Toolbar groups — visual cohesion via "pill" cluster blocks */
.canvas-toolbar-grouped {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; flex-wrap: wrap;
}
.tb-group {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  background: var(--bg-input);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
}
.tb-group.tb-tools { padding: 3px 4px; gap: 2px; }
.tb-group .tb-glyph { color: var(--t3); font-size: 14px; }
.tb-size {
  padding: 4px 8px !important; font-size: 11px !important;
  border: 0 !important; background: transparent !important;
  min-width: 64px;
}
.tb-btn {
  padding: 5px 10px !important; font-size: 11px !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 6px !important;
  display: inline-flex; align-items: center; gap: 4px;
}
.tb-btn:hover { background: var(--bg-hover) !important; }
.tb-btn.danger:hover { background: rgba(244,63,94,.10) !important; color: var(--col-error) !important; }
.tb-btn.on  { background: var(--grad-soft) !important; color: var(--accent) !important; }
/* Whiteboard canvas — scrolls in both axes. Wrapper is overflow:auto so
   the canvas's natural pixel size (CANVAS_W × CANVAS_H) is preserved for
   crisp strokes; the displayed size is fixed at 1600×900 so the user gets
   a guaranteed minimum drawable area but can scroll to reach the rest. */
.note-draw-section .canvas-wrap {
  flex: 1 1 0; min-height: 240px;
  padding: 12px;
  overflow: auto;        /* both vertical & horizontal scroll */
  position: relative;
  background: var(--bg-base);
  scroll-behavior: smooth;
}
.note-draw-section .play-canvas-el {
  display: block;
  width: 1600px; height: 900px;
  background: #ffffff;
  border-radius: var(--r-sm);
  cursor: crosshair; touch-action: none;
  box-shadow: inset 0 0 0 1px var(--divider), 0 1px 8px rgba(0,0,0,.10);
  margin: 0 auto;        /* centre when wrap is wider than canvas */
}
:root[data-theme="dark"] .note-draw-section .play-canvas-el {
  background: #0e1422;
}
/* Fullscreen: canvas grows to fill more space comfortably */
.note-draw-section.fullscreen .canvas-wrap {
  padding: 16px;
  background: var(--bg-base);
}
.note-draw-section.fullscreen .play-canvas-el {
  width: min(2400px, 95vw);
  height: min(1350px, calc(95vh - 140px));
}
/* Custom scrollbars — slim & themed */
.note-draw-section .canvas-wrap::-webkit-scrollbar {
  width: 12px; height: 12px;
}
.note-draw-section .canvas-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.note-draw-section .canvas-wrap::-webkit-scrollbar-thumb {
  background: var(--divider-2); border-radius: 6px;
  border: 2px solid var(--bg-base);
}
.note-draw-section .canvas-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
.note-item-pen {
  display: inline-flex; align-items: center;
  color: var(--accent);
}
.note-item-pen .icn { width: 11px; height: 11px; }

@media (max-width: 900px) {
  .notes-layout-v3 { grid-template-columns: 1fr; }
  .notes-editor-v3 .note-body { height: auto; max-height: none; min-height: 80px; }
}

/* ── Layout height ───────────────────────────────────────────────────────── */
/* Footer removed — views now use the full viewport height. */
.view.active   { height: 100vh; }
#login-view.active { height: 100vh; }      /* login is full-bleed */

/* Highlighted developer credit inside the Help & About modal */
.help-credit {
  margin-top: 18px;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, rgba(56,189,248,.14), rgba(27,45,91,.18));
  border: 1px solid rgba(56,189,248,.30);
}
.help-credit .hc-spark {
  font-size: 20px; color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(56,189,248,.5));
}
.help-credit .hc-line {
  font-size: 10px; font-weight: 700; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--t3);
}
.help-credit .hc-name {
  font-size: 18px; font-weight: 900; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--accent), #ffae84);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ── Member picker (admin "New group" form) ──────────────────────────────── */
.form-section { margin-top: 4px; }
.form-section .section-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.member-picker {
  background: var(--bg-card); border: 1px solid var(--divider-2);
  border-radius: var(--r-md); max-height: 260px; overflow-y: auto;
  margin-top: 6px;
}
.member-pick {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; cursor: pointer;
  border-bottom: 1px solid var(--divider);
  transition: background .12s;
}
.member-pick:last-child { border-bottom: 0; }
.member-pick:hover { background: var(--bg-hover); }
.member-pick.on   { background: var(--grad-soft); }
.member-pick input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.member-pick .info .meta { font-size: 11px; color: var(--t3); }

/* ── TopBar clock (ticks every second, full date) ────────────────────────── */
#topbar .clock {
  padding: 6px 14px; min-width: 220px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--r-md);
  display: flex; flex-direction: column; align-items: center;
  line-height: 1.1; color: #fff;
}
#topbar .clock .time {
  font-size: 14px; font-weight: 700; letter-spacing: .6px;
  font-variant-numeric: tabular-nums;
}
#topbar .clock .date {
  font-size: 10px; opacity: .82; margin-top: 2px;
  white-space: nowrap;
}

/* ── History lazy-load banner ────────────────────────────────────────────── */
.history-loading, .history-loaded {
  margin: 4px 0 12px; padding: 8px 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--t3); font-size: 11px; letter-spacing: .5px;
  text-transform: uppercase;
}
.history-loading .dots { display: inline-flex; gap: 3px; }
.history-loading .dots span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: blink 1.2s ease-in-out infinite;
}
.history-loading .dots span:nth-child(2) { animation-delay: .2s; }
.history-loading .dots span:nth-child(3) { animation-delay: .4s; }
.history-loaded { color: var(--t3); font-style: italic; }

/* ── Quote-reply (composer + bubble) ─────────────────────────────────────── */
.compose .reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; margin-bottom: 4px;
  background: var(--grad-soft);
  border: 1px solid rgba(56,189,248,.30); border-radius: var(--r-md);
  font-size: 12px;
}
.compose .reply-bar .icn { color: var(--accent); flex-shrink: 0; }
.compose .reply-bar .rb-body { flex: 1; min-width: 0; }
.compose .reply-bar .rb-body strong { color: var(--accent); margin-right: 6px; }
.compose .reply-bar .rb-snippet {
  display: block; color: var(--t1); opacity: .8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.msg .reply-quote {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 6px 10px; margin-bottom: 4px;
  border-left: 3px solid var(--accent);
  background: var(--grad-soft);
  border-radius: 0 6px 6px 0;
  cursor: pointer; transition: background .12s;
  max-width: 80%;
}
.msg .reply-quote:hover { background: rgba(56,189,248,.20); }
.msg .reply-quote .icn { color: var(--accent); margin-top: 2px; }
.msg .reply-quote .rq-body strong { display: block; font-size: 12px; color: var(--accent); }
.msg .reply-quote .rq-body .rq-snippet {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px; color: var(--t2); line-height: 1.35;
}

/* ── Forward modal target list ───────────────────────────────────────────── */
.forward-list { margin-top: 10px; max-height: 360px; overflow-y: auto; }
.fw-section {
  font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t3); text-transform: uppercase;
  padding: 8px 8px 4px;
}
.fw-target {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: var(--r-md); cursor: pointer;
  transition: all .12s;
}
.fw-target:hover { background: var(--bg-hover); transform: translateX(2px); }
.fw-target .fw-icn {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--grad-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.fw-target .fw-label { font-size: 13px; font-weight: 600; }

/* ── DND schedule (Settings) ─────────────────────────────────────────────── */
.dnd-section { margin-top: 6px; }
.dow-row { display: flex; gap: 4px; margin-top: 8px; }
.dow-btn {
  flex: 1; padding: 6px 0; font-size: 11px; font-weight: 700;
  letter-spacing: .5px;
  background: var(--bg-card); color: var(--t2);
  border: 1px solid var(--divider-2); border-radius: var(--r-sm);
  transition: all .12s;
}
.dow-btn:hover { border-color: var(--accent); color: var(--t1); }
.dow-btn.on { background: var(--grad); color: #fff; border-color: transparent; }

/* ⭐ saved-button highlight */
.msg .actions button.starred {
  color: var(--col-warn);
  background: rgba(245,158,11,.10);
}
.msg .actions button.starred:hover { background: rgba(245,158,11,.20); }
.msg .actions button.more { font-size: 18px; font-weight: 800; line-height: 1; }

/* ── Emoji picker (categorized, scrollable, searchable) ───────────────────── */
.emoji-picker {
  position: fixed; z-index: 1500;
  width: 340px; max-width: 90vw; max-height: 360px;
  background: var(--bg-glass); backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--divider-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideUp .14s ease-out;
}
.emoji-picker .ep-search {
  margin: 8px 8px 4px; padding: 7px 10px;
  background: var(--bg-input); border: 1px solid var(--divider);
  border-radius: 8px; font-size: 12px;
}
.emoji-picker .ep-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56,189,248,.16);
}
.emoji-picker .ep-tabs {
  display: flex; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--divider);
}
.emoji-picker .ep-tab {
  flex: 1; height: 30px; border-radius: 6px;
  font-size: 18px; transition: background .12s;
}
.emoji-picker .ep-tab:hover  { background: var(--bg-hover); }
.emoji-picker .ep-tab.active { background: var(--grad-soft); }
.emoji-picker .ep-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 6px 8px;
}
.emoji-picker .ep-section {
  grid-column: 1 / -1;
  font-size: 10px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--t3);
  padding: 8px 2px 4px;
}
.emoji-picker .ep-btn {
  width: 100%; aspect-ratio: 1;
  font-size: 22px; border-radius: 6px;
  transition: all .1s;
}
.emoji-picker .ep-btn:hover { background: var(--bg-hover); transform: scale(1.18); }

/* ── More overflow menu (action bar legacy moved here) ─────────────────────── */
.more-menu {
  position: fixed; z-index: 1500;
  background: var(--bg-glass); backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--divider-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 200px;
  animation: slideUp .15s ease-out;
}
.more-menu .mm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; font-size: 13px;
  border-radius: 6px; cursor: pointer;
  transition: background .12s;
  color: var(--t1);
}
.more-menu .mm-item:hover { background: var(--bg-hover); }
.more-menu .mm-item.active { color: var(--col-warn); }
.more-menu .mm-item.danger:hover { background: rgba(244,63,94,.12); color: var(--col-error); }

/* ── Mentions / Saved row layout (shared) ────────────────────────────────── */
.mentions-section {
  font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t3); text-transform: uppercase;
  padding: 14px 6px 6px;
}
.mentions-section.unread { color: var(--accent); }
.mention-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; margin-bottom: 6px;
  background: var(--bg-card); border: 1px solid var(--divider);
  border-radius: var(--r-md); cursor: pointer;
  transition: all .15s; position: relative;
}
.mention-row:hover { border-color: var(--accent); transform: translateX(2px); }
.mention-row.unread {
  border-left: 3px solid var(--accent);
  background: var(--grad-soft);
}
.mention-row .info { flex: 1; min-width: 0; }
.mention-row .info .head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--t3); margin-bottom: 4px; flex-wrap: wrap;
}
.mention-row .info .head strong { color: var(--t1); font-weight: 700; font-size: 14px; }
.mention-row .info .head .room-tag {
  background: var(--bg-msg); padding: 2px 7px; border-radius: 999px;
  font-size: 11px; color: var(--accent); font-weight: 600;
}
.mention-row .info .head .ts { margin-left: auto; }
.mention-row .info .body {
  font-size: 13px; color: var(--t1); line-height: 1.45;
  word-wrap: break-word;
}
.mention-row .unread-dot {
  position: absolute; right: 12px; top: 14px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px rgba(56,189,248,.55);
}
.saved-row .unsave-btn { color: var(--col-warn); flex-shrink: 0; }
.saved-row .unsave-btn:hover { background: rgba(245,158,11,.16); }

/* ── Audit log table ─────────────────────────────────────────────────────── */
.audit-list { display: flex; flex-direction: column; gap: 0; }
.audit-row {
  display: grid;
  grid-template-columns: 170px 140px 130px 1fr 110px;
  gap: 12px; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid var(--divider);
  font-size: 12px;
}
.audit-row .summary-col { color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-row .actor-col   { color: var(--t1); font-weight: 600; }
.audit-row .ts-col, .audit-row .ip-col { color: var(--t3); font-family: ui-monospace, "Consolas", monospace; font-size: 11px; }
.audit-row-head {
  font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t3); text-transform: uppercase;
  border-bottom: 1px solid var(--divider-2);
}
.audit-pill {
  font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 999px; letter-spacing: .3px;
  display: inline-block;
}
.audit-pill.ok     { background: rgba(34,211,165,.16); color: var(--col-ok); }
.audit-pill.danger { background: rgba(244,63,94,.16); color: var(--col-error); }
.audit-pill.warn   { background: rgba(245,158,11,.16); color: var(--col-warn); }
.audit-pill.info   { background: rgba(74,125,255,.16); color: var(--col-info); }

/* ── Admin Trash (deleted-message recovery) ──────────────────────────────── */
.trash-list { display: flex; flex-direction: column; gap: 0; }
.trash-row {
  display: grid;
  grid-template-columns: 150px 110px 130px 1fr 110px;
  gap: 12px; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid var(--divider);
  font-size: 12px;
}
.trash-row .tr-content {
  color: var(--t1); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; cursor: help;
}
.trash-row .tr-author { color: var(--t1); font-weight: 600; }
.trash-row .tr-where  { font-family: ui-monospace, "Consolas", monospace; color: var(--t2); }
.trash-row .tr-when   { color: var(--t3); font-size: 11px; }
.trash-row .tr-acts   { display: flex; justify-content: flex-end; }
.trash-row .tr-acts button { font-size: 11px; padding: 4px 10px; }
.trash-row-head {
  font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t3); text-transform: uppercase;
  border-bottom: 1px solid var(--divider-2);
}
@media (max-width: 720px) {
  .trash-row { grid-template-columns: 1fr; gap: 4px; }
  .trash-row .tr-acts { justify-content: flex-start; }
}

/* Trash split-pane extras (left rail) */
.trash-window-row {
  display: flex; align-items: center; gap: 8px; padding: 0 4px;
  margin-bottom: 6px;
}
.trash-window-row select {
  flex: 1; padding: 5px 8px; font-size: 12px;
}
/* Per-user header is bolder than the per-type sub-rows below it */
.audit-actor-row.trash-actor-head .aa-name {
  font-size: 13px; font-weight: 700;
}
.audit-actor-row.trash-type-row {
  padding-left: 22px;          /* indent under the user header */
  border-left: 2px solid var(--divider);
  margin-left: 6px;
}
.audit-actor-row.trash-type-row .aa-name {
  font-size: 11px; color: var(--t2); font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
}
.audit-actor-row.trash-type-row .aa-name .icn { width: 11px; height: 11px; }
.audit-actor-row.trash-type-row .aa-meta { font-size: 10px; }
.audit-actor-row.trash-type-row.active {
  border-left-color: var(--accent);
}

/* ── Admin Backups tab ───────────────────────────────────────────────────── */
.backup-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.backup-head code {
  font-family: ui-monospace, "Consolas", monospace;
  font-size: 11px; padding: 1px 6px; border-radius: 4px;
  background: var(--bg-input);
}
.backup-list { display: flex; flex-direction: column; gap: 0; }
.backup-row {
  display: grid;
  grid-template-columns: 180px 1fr 90px 220px;
  gap: 12px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--divider);
  font-size: 12px;
}
.backup-row .bk-when { color: var(--t3); font-size: 11px; }
.backup-row .bk-name {
  color: var(--t1); font-weight: 600;
  font-family: ui-monospace, "Consolas", monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.backup-row .bk-size { color: var(--t2); font-family: ui-monospace, monospace; }
.backup-row .bk-acts { display: flex; gap: 6px; justify-content: flex-end; }
.backup-row .bk-acts button { font-size: 11px; padding: 5px 10px; }
.backup-row-head {
  font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t3); text-transform: uppercase;
  border-bottom: 1px solid var(--divider-2);
}
@media (max-width: 720px) {
  .backup-row { grid-template-columns: 1fr; }
  .backup-row .bk-acts { justify-content: flex-start; }
}

/* Email local-part + fixed domain suffix (admin user form) */
.email-suffix-row {
  display: flex; align-items: stretch;
  border: 1px solid var(--divider-2); border-radius: var(--r-sm);
  overflow: hidden; background: var(--bg-input);
}
.email-suffix-row .email-local {
  flex: 1; min-width: 0; border: 0 !important; background: transparent !important;
  border-radius: 0;
}
.email-suffix-row .email-local:focus { box-shadow: none; }
.email-suffix-row .email-suffix {
  display: inline-flex; align-items: center; padding: 0 10px;
  background: var(--bg-card); color: var(--t3);
  font-size: 12px; white-space: nowrap;
  border-left: 1px solid var(--divider);
}

/* Super Admin recovery link on the login screen */
.login-recovery-link {
  margin-top: 14px; background: none; border: 0;
  color: var(--t3); font-size: 12px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
  transition: color .15s;
}
.login-recovery-link:hover { color: var(--accent); }

/* Member-manager "Full history" toggle */
.hist-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  margin-left: auto; margin-right: 8px;
  font-size: 11px; color: var(--t3); cursor: pointer;
  white-space: nowrap;
}
.hist-toggle input { accent-color: var(--accent); cursor: pointer; }

/* ── Admin Branding tab ──────────────────────────────────────────────────── */
.branding-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.branding-preview { margin-bottom: 14px; }
.branding-preview-card {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  border: 1px solid var(--divider); border-radius: var(--r-md);
  padding: 12px;
}
.branding-preview-bg {
  display: flex; align-items: center; justify-content: center;
  height: 110px; border-radius: var(--r-sm);
  position: relative;
}
.branding-preview-bg.dark  { background: #0e1422; }
.branding-preview-bg.light { background: #ffffff; border: 1px solid #e5e8ee; }
.branding-preview-bg::after {
  content: attr(class);
  position: absolute; top: 6px; left: 8px;
  font-size: 9px; letter-spacing: 1.2px; text-transform: uppercase;
  font-weight: 700; opacity: .35;
}
.branding-preview-bg.dark::after  { color: #fff;     content: "Dark";  }
.branding-preview-bg.light::after { color: #1B2D5B; content: "Light"; }
.branding-preview-img {
  max-width: 70%; max-height: 70px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.20));
}
.branding-meta { padding: 8px 0; }
.branding-meta strong { color: var(--t1); }
@media (max-width: 600px) {
  .branding-preview-card { grid-template-columns: 1fr; }
}

/* ── Settings card grid + cards ──────────────────────────────────────────── */
.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
@media (max-width: 720px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-card {
  background: var(--bg-card); border: 1px solid var(--divider);
  border-radius: var(--r-md); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.settings-card.danger { border-color: rgba(244,63,94,.30); }
.settings-card .sc-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--t3);
  padding-bottom: 6px; border-bottom: 1px solid var(--divider);
}
.settings-card .sc-head strong { color: var(--t1); }
.settings-card label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; color: var(--t3); font-weight: 600; letter-spacing: .3px;
}
.settings-card label.toggle {
  flex-direction: row; align-items: center;
  font-size: 13px; color: var(--t1); font-weight: 500;
}

/* ── Calendar participant chips ──────────────────────────────────────────── */
.event-card .ev-participants {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px;
}
.event-card .ev-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px 2px 2px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--divider-2);
  font-size: 11px; line-height: 1; font-weight: 600;
}
.event-card .ev-chip .avatar { width: 18px; height: 18px; font-size: 9px; }
.event-card .ev-chip-name { white-space: nowrap; }
.event-card .ev-chip.organizer { border-color: var(--accent); color: var(--accent); }
.event-card .ev-chip.accepted  { border-color: rgba(34,211,165,.45); color: var(--col-ok); }
.event-card .ev-chip.rejected  { border-color: rgba(244,63,94,.45);  color: var(--col-error); opacity: .8; }
.event-card .ev-chip.pending   { border-color: rgba(245,158,11,.45); color: var(--col-warn); }
.event-card .ev-chip.more {
  padding: 2px 8px; color: var(--t3);
}

/* ── Meeting reminder popup ──────────────────────────────────────────────── */
.reminder-card { text-align: center; }
.reminder-card .reminder-icon { font-size: 36px; margin-bottom: 6px; }
.reminder-card h3 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.reminder-card .reminder-when { color: var(--accent); font-weight: 700; font-size: 13px; }
.reminder-card .reminder-desc {
  text-align: left; margin-top: 10px; padding: 10px;
  background: var(--bg-msg); border-radius: 8px;
  font-size: 12px; color: var(--t1); max-height: 140px; overflow-y: auto;
}

/* ── Permission help (inside Settings) ───────────────────────────────────── */
.notif-help {
  margin-top: 8px; padding: 10px 12px; border-radius: var(--r-md);
  background: rgba(244,63,94,.08);
  border: 1px solid rgba(244,63,94,.24);
  color: var(--col-error); font-size: 12px;
}
.notif-help.granted {
  background: rgba(34,211,165,.08);
  border-color: rgba(34,211,165,.24);
  color: var(--col-ok);
}
.notif-help strong { display: block; margin-bottom: 4px; }
.notif-help ol { margin: 6px 0 0 18px; padding: 0; line-height: 1.5; color: var(--t1); }
.notif-help kbd {
  background: var(--bg-card); border: 1px solid var(--divider-2);
  border-radius: 4px; padding: 1px 6px; font-family: ui-monospace, monospace;
  font-size: 11px; color: var(--t1);
}

/* ── Avatar ──────────────────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; flex-shrink: 0;
  font-size: 12px;
  background-size: cover; background-position: center;
  position: relative; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.08);
}
.avatar > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.role-1 { background: linear-gradient(135deg, #d4a800, #fcb900); }
.avatar.role-2 { background: linear-gradient(135deg, #6b7280, #9ca3af); }
.avatar.role-3 { background: linear-gradient(135deg, #0ea5e9, #38bdf8); }
.avatar.role-4 { background: linear-gradient(135deg, #a855f7, #c084fc); }
.avatar.role-5 { background: linear-gradient(135deg, #4a7dff, #818cf8); }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--st-offline);
  border: 2px solid var(--bg-sidebar);
  position: absolute; right: -2px; bottom: -2px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,.20);
}
.status-dot.online  { background: var(--st-online); box-shadow: 0 0 8px rgba(34,211,165,.55), 0 0 0 1px rgba(0,0,0,.10); }
.status-dot.away    { background: var(--st-away);   box-shadow: 0 0 6px rgba(245,158,11,.40); }
.status-dot.busy    { background: var(--st-busy);   box-shadow: 0 0 6px rgba(244,63,94,.40); }
.status-dot.offline { background: var(--st-offline); }

/* Status pill — used in chat header DM under the user name. Color-coded.
   Subtle by design (10px, no background fill on offline) so the layout
   stays understated. */
.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .3px;
  padding: 1px 6px 1px 5px; border-radius: 999px;
  text-transform: uppercase;
  line-height: 1.3;
}
.status-pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
}
.status-pill.online  { color: var(--st-online); background: rgba(34,211,165,.14); }
.status-pill.online::before  { background: var(--st-online); box-shadow: 0 0 6px rgba(34,211,165,.65); }
.status-pill.away    { color: var(--st-away);   background: rgba(245,158,11,.14); }
.status-pill.away::before    { background: var(--st-away); }
.status-pill.busy    { color: var(--st-busy);   background: rgba(244,63,94,.14); }
.status-pill.busy::before    { background: var(--st-busy); }
.status-pill.offline { color: var(--t3); background: rgba(148,163,184,.12); }
.status-pill.offline::before { background: var(--st-offline); }
/* DND - same red as busy but with a stronger background to flag urgency.
   Status dot uses a small dash inside, rendered via box-shadow trick. */
.status-pill.dnd { color: #fff; background: var(--col-error); font-weight: 800; }
.status-pill.dnd::before {
  background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--col-error);
}
.status-dot.dnd {
  background: var(--col-error);
  box-shadow: 0 0 0 1.5px var(--col-error), 0 0 6px rgba(244,63,94,.50);
  position: relative;
}
.status-dot.dnd::after {
  content: ""; position: absolute; left: 2px; right: 2px; top: 50%;
  height: 2px; margin-top: -1px;
  background: #fff; border-radius: 1px;
}
.h-status-line { display: flex; align-items: center; gap: 4px; }

/* DND-blocked synthetic system bubble - centered, muted, ephemeral */
.msg.system.dnd-block {
  display: flex; justify-content: center; padding: 10px 16px;
  animation: slideUp .2s ease-out;
}
.msg.system.dnd-block .system-bubble {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 540px; padding: 10px 14px;
  background: rgba(244,63,94,.08);
  border: 1px solid rgba(244,63,94,.25);
  border-radius: var(--r-md);
  font-size: 12px; color: var(--t2);
  line-height: 1.45;
}
.msg.system.dnd-block .icn-wrap {
  font-size: 18px; line-height: 1; flex-shrink: 0;
}
.msg.system.dnd-block strong { color: var(--col-error); }
.msg.system.dnd-block em {
  color: var(--t1); font-style: italic;
  background: rgba(255,255,255,.04);
  padding: 1px 5px; border-radius: 3px;
  font-family: ui-monospace, "Consolas", monospace;
  font-size: 11px;
}

/* ── User info modal — rich profile card with Name/Title/Dept/Location ──── */
.user-info-modal { display: flex; flex-direction: column; gap: 16px; }
.user-info-header {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 6px 0 8px;
  border-bottom: 1px solid var(--divider);
}
.user-info-header .ui-name {
  margin: 0; font-size: 18px; font-weight: 800; color: var(--t1);
}
.user-info-header .ui-username {
  margin-top: 2px; font-size: 12px; color: var(--t3);
}
.user-info-header .ui-status-row { margin-top: 6px; }
.user-info-details {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
}
.user-info-details .ui-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 0;
}
.user-info-details .ui-row-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--grad-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info-details .ui-row-icon .icn { width: 14px; height: 14px; }
.user-info-details .ui-row-body { min-width: 0; flex: 1; }
.user-info-details .ui-row-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  color: var(--t3); text-transform: uppercase;
}
.user-info-details .ui-row-value {
  font-size: 13px; color: var(--t1); margin-top: 2px;
  word-break: break-word;
}
.user-info-details .ui-row-value.muted { color: var(--t3); font-style: italic; }
.user-info-modal .ui-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  color: var(--t3); text-transform: uppercase; margin-bottom: 4px;
}
.user-info-modal .ui-bio {
  background: var(--bg-input); padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13px; color: var(--t2);
}
.user-info-modal .ui-ooo {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; background: rgba(245,158,11,.12);
  border-left: 3px solid var(--col-warn); border-radius: var(--r-sm);
  font-size: 12px; color: var(--t1);
}
@media (max-width: 480px) {
  .user-info-details { grid-template-columns: 1fr; }
}

/* ── Settings — left rail of categories + right pane ────────────────────── */
/* Settings modal — sized to the viewport so nothing overflows; grid inside
   the right pane is single-column to prevent cards getting squashed. */
.settings-modal {
  display: flex; flex-direction: column;
  min-height: 0;
  width: 100%;
}
.settings-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px; min-height: 0; flex: 1;
  overflow: hidden;
}
.settings-nav {
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px 12px 4px 0;
  border-right: 1px solid var(--divider);
  overflow-y: auto;
  min-height: 0;
}
.settings-nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent;
  color: var(--t2); font-size: 13px; font-weight: 600;
  text-align: left; cursor: pointer;
  transition: all .12s;
  flex-shrink: 0;
}
.settings-nav-btn .icn { width: 14px; height: 14px; flex-shrink: 0; }
.settings-nav-btn:hover {
  background: var(--bg-hover); color: var(--t1);
}
.settings-nav-btn.active {
  background: var(--grad-soft);
  color: var(--accent);
  border-color: rgba(56,189,248,.30);
}
.settings-main {
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0; min-height: 0;
  overflow: hidden;
}
.settings-search {
  width: 100%; padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--divider-2);
  border-radius: var(--r-md);
  color: var(--t1); font-size: 13px;
  flex-shrink: 0;
}
.settings-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.18);
}
.settings-content {
  display: flex; flex-direction: column; gap: 14px;
  min-width: 0; min-height: 0;
  overflow-y: auto;
  padding-right: 4px;       /* room for scrollbar without clipping */
  /* Bound the visible height so long Notifications card etc. scroll inside
     this pane rather than blowing out the whole modal. 84vh modal − ~220px
     for chrome (header, padding, search) leaves a comfortable scrollable
     content region. */
  max-height: calc(84vh - 220px);
}
.settings-nav {
  max-height: calc(84vh - 160px);
}
.settings-section-head {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0 8px; border-bottom: 1px solid var(--divider);
  position: sticky; top: 0;
  background: var(--bg-glass); backdrop-filter: blur(8px);
  z-index: 1;
}
.settings-section-head .icn { color: var(--accent); width: 18px; height: 18px; }
.settings-section-head h2 {
  margin: 0; font-size: 16px; font-weight: 800; color: var(--t1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Inside the settings panel the cards stack — single column avoids the
   horizontal overflow you'd otherwise get with the 2-col global rule. */
.settings-main .settings-grid {
  display: flex; flex-direction: column; gap: 12px;
}
@media (max-width: 720px) {
  .settings-layout { grid-template-columns: 1fr; gap: 10px; }
  .settings-nav {
    flex-direction: row; flex-wrap: wrap;
    border-right: 0; border-bottom: 1px solid var(--divider);
    padding: 0 0 10px;
    overflow-y: visible;
  }
  .settings-nav-btn { flex: 1 1 45%; justify-content: center; }
}

/* ── Reaction info button + breakdown modal ──────────────────────────────── */
.reactions .reaction-info-btn {
  width: 22px; height: 22px; padding: 3px;
  margin-left: 4px;
  border-radius: 50%;
  background: transparent; border: 1px solid transparent;
  color: var(--t3); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.reactions .reaction-info-btn:hover {
  background: var(--bg-hover); color: var(--accent);
  border-color: var(--divider-2);
}
.reactions .reaction-info-btn .icn { width: 12px; height: 12px; }
.reaction-details { display: flex; flex-direction: column; gap: 12px; }
.reaction-details .rd-section {
  border: 1px solid var(--divider);
  border-radius: var(--r-sm); padding: 8px 10px;
  background: var(--bg-input);
}
.reaction-details .rd-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--divider);
  margin-bottom: 6px;
}
.reaction-details .rd-emoji { font-size: 22px; line-height: 1; }
.reaction-details .rd-count {
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  color: var(--t3); text-transform: uppercase;
}
.reaction-details .rd-people {
  display: flex; flex-direction: column; gap: 4px;
}
.reaction-details .rd-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px;
}
.reaction-details .rd-info { flex: 1; min-width: 0; }
.reaction-details .rd-name {
  font-size: 13px; font-weight: 600; color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reaction-details .rd-sub { font-size: 11px; color: var(--t3); }

/* ── Directory: group-by tabs + hover card ───────────────────────────────── */
.dir-groupby {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--divider-2);
  border-radius: var(--r-md);
  padding: 3px;
  margin-right: 8px;
}
.dir-groupby .dir-gb-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--t3);
  padding: 0 6px 0 4px;
}
.dir-gb-tab {
  padding: 5px 10px; font-size: 11px; font-weight: 700;
  letter-spacing: .3px;
  background: transparent; color: var(--t2);
  border: 0; border-radius: calc(var(--r-md) - 4px);
  cursor: pointer; transition: all .12s;
}
.dir-gb-tab:hover  { color: var(--t1); }
.dir-gb-tab.active {
  background: var(--grad); color: #fff;
  box-shadow: var(--glow-soft);
}

.person-row.dir-row { user-select: none; }
.person-row.dir-row:hover { background: var(--bg-hover); }
.person-row.dir-row .dir-actions {
  display: flex; gap: 4px;
  margin-left: auto;
  opacity: 0; transition: opacity .12s;
}
.person-row.dir-row:hover .dir-actions,
.person-row.dir-row:focus-within .dir-actions { opacity: 1; }
.dir-action-btn {
  width: 32px; height: 32px; padding: 6px;
  border-radius: 8px;
  background: transparent; color: var(--t2);
  border: 1px solid var(--divider-2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .12s;
}
.dir-action-btn .icn { width: 14px; height: 14px; }
.dir-action-btn:hover {
  background: var(--grad-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── File preview modal ──────────────────────────────────────────────────── */
.file-preview-body {
  display: flex; flex-direction: column;
  min-height: 0; height: min(78vh, 820px);
  margin: -8px -4px;          /* tighten inside modal-body padding */
}
.file-preview-body:fullscreen {
  height: 100vh; width: 100vw; background: var(--bg-base); padding: 0; margin: 0;
}
.file-preview-pdf {
  flex: 1; width: 100%; min-height: 0;
  border: 0; border-radius: var(--r-sm);
  background: var(--bg-base);
}
/* PDF viewer app-level toolbar (sits above the native PDF engine toolbar) */
.pdf-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; margin-bottom: 6px;
  background: var(--bg-card); border: 1px solid var(--divider);
  border-radius: var(--r-sm); flex-wrap: wrap;
}
.pdf-toolbar .pdfctl-group {
  display: inline-flex; align-items: center; gap: 4px;
}
.pdfctl-btn {
  min-width: 30px; height: 28px; padding: 0 8px;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  border-radius: 6px; color: var(--t1); font-size: 14px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.pdfctl-btn .icn { width: 14px; height: 14px; }
.pdfctl-btn:hover { border-color: var(--accent); color: var(--accent); }
.pdfctl-zoom {
  min-width: 42px; text-align: center; font-size: 12px;
  color: var(--t2); font-variant-numeric: tabular-nums;
}
.pdfctl-page {
  width: 54px; height: 28px; padding: 2px 6px; font-size: 12px;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  border-radius: 6px; color: var(--t1);
}
.pdf-hint { font-size: 11px; }
@media (max-width: 600px) { .pdf-hint { display: none; } }
.file-preview-text {
  flex: 1; min-height: 0; margin: 0;
  padding: 14px 16px;
  background: var(--bg-base);
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  color: var(--t1);
  font-family: ui-monospace, "Consolas", "Cascadia Code", monospace;
  font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  overflow: auto;
}
/* Per-attachment download button — sits on the file card, doesn't trigger
   the preview modal click. Subtle until hovered. */
.file-card .fc-dl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: transparent; border: 1px solid transparent;
  color: var(--t3); border-radius: 6px;
  transition: all .12s;
}
.file-card .fc-dl-btn .icn { width: 14px; height: 14px; }
.file-card:hover .fc-dl-btn {
  border-color: var(--divider-2);
  color: var(--t1);
}
.file-card .fc-dl-btn:hover {
  background: var(--grad-soft);
  color: var(--accent); border-color: var(--accent);
}

/* ── Credential reset row — input + show/hide + copy ─────────────────────── */
.cred-row { display: flex; gap: 6px; align-items: center; }
.cred-row > input {
  flex: 1; min-width: 0; font-family: ui-monospace, "Consolas", monospace;
  letter-spacing: .5px;
}
.cred-row .cred-eye {
  width: 38px; padding: 6px; font-size: 16px; line-height: 1;
}
.cred-row .cred-copy {
  padding: 6px 10px; font-size: 11px; white-space: nowrap;
}
.cred-row.hidden { display: none; }

/* ── Reminder pill in topbar (next event + count badge) ──────────────────── */
.reminder-pill { display: inline-flex; align-items: center; gap: 6px; }
.reminder-pill .reminder-pill-label {
  font-size: 11px; font-weight: 600; color: var(--t2);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.reminder-pill.has-next { padding-right: 10px; }
.reminder-pill .badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--accent); color: #fff;
  font-size: 9px; font-weight: 800;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-base);
}

/* ── Reminder dropdown panel ─────────────────────────────────────────────── */
.reminder-panel {
  position: fixed; z-index: 1100; width: 360px; max-height: 70vh;
  background: var(--bg-card);
  border: 1px solid var(--divider-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideUp .14s ease-out;
}
.reminder-panel .rp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--divider);
  font-size: 13px; color: var(--t1);
}
.reminder-panel .rp-list {
  overflow-y: auto; padding: 4px 0;
}
.reminder-panel .rp-section-head {
  font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t3); text-transform: uppercase;
  padding: 8px 12px 4px;
}
.reminder-panel .rp-row {
  display: flex; gap: 12px; align-items: center;
  padding: 8px 12px; cursor: pointer;
  transition: background .12s;
}
.reminder-panel .rp-row:hover { background: rgba(56,189,248,.10); }
.reminder-panel .rp-time {
  font-size: 14px; font-weight: 800; color: var(--accent);
  width: 56px; flex-shrink: 0;
  font-family: ui-monospace, "Consolas", monospace;
}
.reminder-panel .rp-date-mini {
  font-size: 9px; font-weight: 600; color: var(--t3);
  font-family: -apple-system, "Segoe UI", Inter, sans-serif;
  letter-spacing: .3px;
}
.reminder-panel .rp-info { min-width: 0; flex: 1; }
.reminder-panel .rp-title {
  font-size: 13px; font-weight: 600; color: var(--t1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reminder-panel .rp-sub {
  font-size: 11px; color: var(--t3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reminder-panel .rp-empty {
  padding: 18px 12px; text-align: center;
  font-size: 12px; color: var(--t3);
}

/* ── Top notification banner (auto-dismiss) ──────────────────────────────── */
.top-notif-stack {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 3000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  width: min(90vw, 480px);
}
.top-notif {
  background: var(--bg-glass); backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--divider-2);
  border-radius: var(--r-md); padding: 10px 14px;
  box-shadow: 0 12px 40px -8px rgba(0,0,0,.40);
  display: flex; align-items: flex-start; gap: 10px;
  pointer-events: auto;
  animation: slideDown .25s cubic-bezier(.34, 1.56, .64, 1);
  border-left: 3px solid var(--accent);
}
.top-notif.ok    { border-left-color: var(--col-ok); }
.top-notif.error { border-left-color: var(--col-error); }
.top-notif.info  { border-left-color: var(--col-info); }
.top-notif .tn-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--grad-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.top-notif .tn-icon .icn { width: 14px; height: 14px; }
.top-notif .tn-body { flex: 1; min-width: 0; }
.top-notif .tn-title {
  font-size: 13px; font-weight: 700; color: var(--t1);
}
.top-notif .tn-msg {
  font-size: 12px; color: var(--t2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-notif .tn-close {
  width: 24px; height: 24px; padding: 4px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--t3); flex-shrink: 0;
  border-radius: 6px;
}
.top-notif .tn-close:hover { background: var(--bg-hover); color: var(--t1); }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Reminder chip below the chat composer ───────────────────────────────── */
.reminder-chip {
  display: flex; align-items: center; gap: 8px;
  margin: 0 12px 6px; padding: 6px 10px;
  background: rgba(56,189,248,.10);
  border: 1px solid rgba(56,189,248,.40);
  border-radius: 999px;
  color: var(--t1); font-size: 12px;
  cursor: pointer; transition: all .12s;
  width: fit-content; max-width: calc(100% - 24px);
  animation: slideUp .15s ease-out;
}
.reminder-chip:hover {
  background: rgba(56,189,248,.18);
  border-color: var(--accent);
}
.reminder-chip .rc-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.reminder-chip .rc-dismiss {
  width: 18px; height: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: transparent; color: var(--t3);
  font-size: 14px; cursor: pointer; flex-shrink: 0;
}
.reminder-chip .rc-dismiss:hover { background: var(--bg-hover); color: var(--col-error); }

/* ── Emoji picker (search + categories) ──────────────────────────────────── */
.emoji-picker-wrap {
  display: flex; flex-direction: column; gap: 8px; max-height: 60vh;
}
.emoji-search {
  width: 100%; padding: 8px 10px;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  border-radius: var(--r-sm); font-size: 13px;
}
.emoji-body { overflow-y: auto; padding: 0 2px; }
.emoji-cat-head {
  font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t3); text-transform: uppercase;
  padding: 8px 4px 4px;
}
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
}
.emoji-grid button {
  height: 34px; font-size: 20px; line-height: 1;
  background: transparent; border: 0; cursor: pointer;
  border-radius: 6px; transition: all .12s;
}
.emoji-grid button:hover {
  background: rgba(56,189,248,.12); transform: scale(1.15);
}
.emoji-empty {
  padding: 18px; text-align: center;
  font-size: 12px; color: var(--t3);
}

/* Content area */
#content { flex: 1; display: flex; min-width: 0; background: var(--bg-chat); position: relative; }
#content > * { animation: fadeIn .25s ease-out; }

/* ────────────────────────────────────────────────────────────────────────── */
/*                           CHAT VIEW                                        */
/* ────────────────────────────────────────────────────────────────────────── */
.chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.thread-pane {
  width: 380px; flex-shrink: 0;
  border-left: 1px solid var(--divider);
  background: var(--bg-chat);
  display: flex; flex-direction: column;
  animation: slideUp .25s ease-out;
}
.chat-header {
  height: 60px; flex-shrink: 0;
  padding: 0 22px; border-bottom: 1px solid var(--divider);
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}
.chat-header .h-icon {
  width: 36px; height: 36px; border-radius: var(--r-md);
  background: var(--grad-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(56,189,248,.18);
}
.chat-header .h-text { flex: 1; min-width: 0; }
.chat-header .h-text h2 {
  margin: 0; font-size: 16px; font-weight: 800; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-header .h-text small { font-size: 11px; color: var(--t3); }
.chat-header .e2e {
  background: rgba(34,211,165,.14); color: var(--col-ok);
  padding: 3px 8px; border-radius: 6px; font-size: 10px; font-weight: 700;
  letter-spacing: .4px;
}
.chat-header .h-actions { display: flex; gap: 4px; }
.chat-header .icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-md); color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.chat-header .icon-btn:hover { background: var(--bg-hover); color: var(--accent); transform: translateY(-1px); }

.pin-strip {
  padding: 10px 22px; background: var(--grad-soft);
  border-bottom: 1px solid rgba(56,189,248,.18);
  border-left: 3px solid var(--accent);
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  animation: slideUp .25s ease-out;
}
.pin-strip .lbl { color: var(--accent); font-weight: 700; }
.pin-strip .body { flex: 1; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-strip .icon-btn { color: var(--t2); width: 28px; height: 28px; border-radius: 6px; }
.pin-strip .icon-btn:hover { background: var(--bg-hover); color: var(--accent); }

.ooo-banner {
  padding: 10px 22px; background: rgba(245,158,11,.08);
  border-bottom: 1px solid rgba(245,158,11,.30);
  color: var(--col-warn); font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}

.feed {
  flex: 1; overflow-y: auto; padding: 16px 22px 8px;
  display: flex; flex-direction: column; gap: 0;
  outline: none;
}
.feed-empty {
  margin: auto; color: var(--t3); display: flex; flex-direction: column;
  align-items: center; gap: 12px;
}
.feed-empty .icn { width: 48px; height: 48px; opacity: .4; }
.system-row {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0; color: var(--t3); font-size: 11px;
  font-style: italic; font-weight: 500;
}
.system-row::before, .system-row::after {
  content: ""; flex: 1; height: 1px; background: var(--divider);
}

/* Message bubbles */
.msg {
  display: flex; gap: 12px; padding: 4px 8px; border-radius: var(--r-md);
  position: relative; transition: background .15s;
}
.msg.group-start { margin-top: 14px; }
.msg.continuation { margin-top: 2px; }
.msg:hover { background: var(--bg-hover); }
.msg .avatar { width: 36px; height: 36px; font-size: 13px; }
.msg .gutter { width: 36px; flex-shrink: 0; text-align: center; color: var(--t3); font-size: 10px; padding-top: 4px; }
.msg.continuation:hover .gutter::before {
  content: attr(data-time); display: block;
}
.msg .body { flex: 1; min-width: 0; }
.msg .meta { font-size: 12px; color: var(--t3); margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.msg .meta strong {
  color: var(--t1); font-weight: 700; font-size: 14px; cursor: pointer;
  transition: color .15s;
}
.msg .meta strong:hover { color: var(--accent); }
.msg .meta .role-tag {
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  letter-spacing: .4px;
}
.msg .role-tag.r1 { background: rgba(212,168,0,.16); color: var(--role-1); }
.msg .role-tag.r2 { background: rgba(139,139,139,.16); color: var(--role-2); }
.msg .role-tag.r3 { background: rgba(14,165,233,.16); color: var(--role-3); }
.msg .role-tag.r4 { background: rgba(168,85,247,.16); color: var(--role-4); }
.msg .role-tag.r5 { background: rgba(74,125,255,.16); color: var(--role-5); }

.msg .content {
  background: var(--bubble-other);
  padding: 9px 13px; border-radius: 12px;
  display: inline-block; max-width: 80%;
  white-space: pre-wrap; word-wrap: break-word; line-height: 1.45;
  user-select: text;
  border: 1px solid var(--divider);
}
.msg.mine .content {
  background: var(--bubble-me);
  border-color: rgba(56,189,248,.18);
}
.msg .content .mention {
  color: var(--col-warn);
  background: rgba(245,158,11,.12);
  padding: 1px 6px; border-radius: 4px; font-weight: 600;
  cursor: pointer;
}
.msg .content .mention.me {
  color: var(--accent);
  background: rgba(56,189,248,.18);
  box-shadow: 0 0 0 1px rgba(56,189,248,.30);
}
.msg .content .hashtag { color: var(--accent); font-weight: 600; }
.msg .content a { color: var(--accent); text-decoration: underline; }
.msg .edited-tag { font-size: 10px; color: var(--t3); margin-left: 6px; font-style: italic; }
.msg .deleted-marker { color: var(--t3); font-style: italic; }

/* Reaction action bar — floats ABOVE message on hover */
.msg .actions {
  position: absolute; top: -22px; right: 16px;
  background: var(--bg-glass); backdrop-filter: blur(12px);
  border: 1px solid var(--divider-2);
  border-radius: 999px; padding: 4px;
  display: flex; gap: 1px;
  box-shadow: var(--shadow);
  z-index: 5;
  opacity: 0; transform: translateY(6px) scale(.95);
  pointer-events: none;
  transition: all .18s cubic-bezier(.34, 1.56, .64, 1);
}
.msg:hover .actions {
  opacity: 1; transform: none; pointer-events: auto;
}
.msg .actions button {
  width: 32px; height: 32px; border-radius: 999px;
  color: var(--t2); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.msg .actions button:hover {
  background: var(--bg-hover); color: var(--t1);
  transform: scale(1.15);
}
.msg .actions button.danger:hover { color: var(--col-error); background: rgba(244,63,94,.10); }
.msg .actions .sep { width: 1px; align-self: stretch; background: var(--divider); margin: 4px 2px; }

.reactions { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.reactions .pill {
  background: var(--bg-card); border: 1px solid var(--divider-2);
  border-radius: 999px; padding: 2px 9px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  transition: all .15s;
}
.reactions .pill:hover { border-color: var(--accent); transform: translateY(-1px); }
.reactions .pill.mine {
  background: var(--grad-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.reactions .pill .count { font-size: 11px; font-weight: 700; opacity: .9; }

.thread-link {
  font-size: 12px; color: var(--accent); margin-top: 5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; font-weight: 600;
  transition: color .15s;
}
.thread-link:hover { color: var(--accent-2); }

/* Read receipts:
     ✓   delivered (default)
     ✓✓  read — peer's last-read >= this message id
   The glyph is generated entirely by CSS so the JS can stay tag-free. */
.read-receipt {
  display: inline-flex; align-items: center;
  font-size: 12px; color: var(--t3);
  margin-left: 6px; cursor: pointer;
  transition: color .15s;
  letter-spacing: -2px;       /* tighten the double-tick */
}
.read-receipt::before { content: "✓"; }
.read-receipt.read    { color: var(--accent); font-weight: 700; }
.read-receipt.read::before { content: "✓✓"; }
.read-receipt:hover   { color: var(--accent-2); }

.file-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid rgba(56,189,248,.20);
  border-radius: var(--r-md); padding: 10px 12px;
  width: 320px; max-width: 100%;
  text-decoration: none; color: var(--t1);
  transition: all .15s;
}
.file-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.file-card .ext {
  width: 42px; height: 46px; flex-shrink: 0;
  background: var(--grad); border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 9px; color: #fff; letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(56,189,248,.30);
}
.file-card .info { flex: 1; min-width: 0; }
.file-card .info .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card .info .size { font-size: 11px; color: var(--t3); }
.file-card .download { color: var(--accent); flex-shrink: 0; }

.image-attach {
  display: block; max-width: 360px; max-height: 280px;
  border-radius: var(--r-md); cursor: pointer; margin-top: 5px;
  border: 1px solid var(--divider);
  transition: all .15s;
}
.image-attach:hover { border-color: var(--accent); transform: scale(1.01); }

/* Poll card */
.poll-card {
  background: var(--grad-soft);
  border: 1px solid rgba(56,189,248,.28);
  border-radius: var(--r-md); padding: 12px 14px;
  width: 340px; max-width: 100%;
  box-shadow: 0 4px 16px rgba(56,189,248,.10);
}
.poll-card .head {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 800; letter-spacing: 1px;
  color: var(--accent); margin-bottom: 8px;
}
.poll-card .question { font-size: 14px; font-weight: 700; margin-bottom: 10px; line-height: 1.3; }
.poll-card .opt {
  position: relative; padding: 8px 12px; margin: 5px 0;
  border-radius: var(--r-sm); cursor: pointer; overflow: hidden;
  background: rgba(0,0,0,.18);
  border: 1px solid var(--divider);
  font-size: 13px; transition: all .15s;
}
:root[data-theme="light"] .poll-card .opt { background: rgba(27,45,91,.06); }
.poll-card .opt .fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: var(--grad-soft); transition: width .5s cubic-bezier(.4, 0, .2, 1);
  z-index: 0;
}
.poll-card .opt.voted { border-color: var(--accent); }
.poll-card .opt.voted .fill { background: var(--grad); opacity: .35; }
.poll-card .opt:hover { border-color: var(--accent); }
.poll-card .opt .row { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; }
.poll-card .opt .pct { color: var(--accent); font-weight: 700; font-size: 11px; }
.poll-card .foot {
  font-size: 11px; color: var(--t3); margin-top: 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.poll-card .foot .voted-mark { color: var(--col-ok); font-weight: 600; }

/* Typing indicator */
.typing-strip {
  padding: 4px 22px; min-height: 20px;
  font-size: 12px; color: var(--accent); font-style: italic;
  display: flex; align-items: center; gap: 8px;
}
.typing-strip .dots { display: inline-flex; gap: 3px; }
.typing-strip .dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: blink 1.2s ease-in-out infinite;
}
.typing-strip .dots span:nth-child(2) { animation-delay: .2s; }
.typing-strip .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: scale(.8); } 30% { opacity: 1; transform: scale(1.1); } }

/* ComposeBar */
.compose {
  margin: 10px 18px 16px;
  background: var(--bg-card); border: 1px solid var(--divider-2);
  border-radius: var(--r-lg); padding: 6px;
  transition: border-color .15s, box-shadow .15s;
}
.compose:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.12), var(--shadow-sm);
}
.compose-row { display: flex; align-items: flex-end; gap: 4px; }
.compose textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 180px;
  background: transparent; border: 0; padding: 9px 10px; box-shadow: none;
  font-size: 14px;
}
.compose textarea:focus { box-shadow: none; }
.compose .icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-md); color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.compose .icon-btn:hover { background: var(--bg-hover); color: var(--accent); }
.compose .send {
  background: var(--grad); color: #fff;
  box-shadow: 0 2px 8px rgba(56,189,248,.30);
}
.compose .send:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(56,189,248,.45);
  color: #fff;
}
.compose .send:active { transform: scale(.96); }
.compose-hint {
  display: flex; justify-content: flex-end;
  font-size: 10px; color: var(--t3); padding: 2px 8px 4px;
}
.compose-hint .shortcut-hint {
  background: transparent; color: var(--t3);
  padding: 2px 8px; border-radius: 6px;
  font-size: 10px; letter-spacing: .8px;
  border: 1px solid var(--divider);
  transition: all .12s;
}
.compose-hint .shortcut-hint:hover { color: var(--accent); border-color: var(--accent); }

/* Shortcuts modal table */
.shortcuts-grid {
  display: grid; grid-template-columns: 140px 1fr;
  gap: 8px 14px; align-items: center;
}
.shortcuts-grid kbd {
  background: var(--bg-card); border: 1px solid var(--divider-2);
  border-radius: 6px; padding: 4px 10px;
  font-family: ui-monospace, "Consolas", monospace;
  font-size: 12px; font-weight: 700; color: var(--t1);
  text-align: center; box-shadow: 0 1px 0 rgba(0,0,0,.20);
}
.shortcuts-grid > span { font-size: 13px; color: var(--t1); }
.msg .content code {
  background: var(--bg-card); border: 1px solid var(--divider);
  padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, "JetBrains Mono", "Consolas", monospace;
  font-size: 12.5px;
}
.compose .mention-popup {
  position: absolute; bottom: 100%; left: 12px; right: 12px;
  margin-bottom: 6px;
  background: var(--bg-glass); backdrop-filter: blur(16px);
  border: 1px solid var(--divider-2); border-radius: var(--r-md);
  box-shadow: var(--shadow);
  max-height: 220px; overflow-y: auto;
  z-index: 20;
}
.compose .mention-popup .item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; cursor: pointer;
  font-size: 13px;
}
.compose .mention-popup .item:hover, .compose .mention-popup .item.active {
  background: var(--bg-hover);
}
.compose .mention-popup .item .avatar { width: 24px; height: 24px; font-size: 10px; }

/* Thread pane */
.thread-pane .chat-header { padding: 0 16px; }
.thread-pane .feed { padding: 12px 16px; }

/* ────────────────────────────────────────────────────────────────────────── */
/*                           OTHER VIEWS                                      */
/* ────────────────────────────────────────────────────────────────────────── */
.panel { flex: 1; display: flex; flex-direction: column; padding: 22px 26px; overflow: hidden; }
.panel-head {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 14px; border-bottom: 1px solid var(--divider);
  margin-bottom: 18px; flex-shrink: 0;
}
.panel-head h1 {
  margin: 0; font-size: 20px; font-weight: 800; flex: 1;
  display: flex; align-items: center; gap: 12px; letter-spacing: .2px;
}
.panel-head .h-icon {
  width: 36px; height: 36px; border-radius: var(--r-md);
  background: var(--grad-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(56,189,248,.18);
}
.panel-body { flex: 1; overflow-y: auto; min-height: 0; padding-right: 6px; }
/* Calendar's panel-body holds the grid which manages its own scrolling */
.panel:has(.cal-grid) .panel-body { display: flex; flex-direction: column; }
.panel-empty {
  padding: 80px 30px; text-align: center; color: var(--t3);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.panel-empty .icn { width: 40px; height: 40px; opacity: .4; }

/* Buttons */
.btn-primary {
  background: var(--grad); color: #fff; border-radius: var(--r-md);
  padding: 9px 16px; font-weight: 700; font-size: 13px; letter-spacing: .2px;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 2px 8px rgba(56,189,248,.30);
  transition: all .15s;
}
.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(56,189,248,.42);
}
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .5; cursor: wait; transform: none; }
.btn-ghost {
  background: var(--bg-card); color: var(--t1);
  border: 1px solid var(--divider-2); border-radius: var(--r-md);
  padding: 9px 16px; font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.btn-danger {
  background: rgba(244,63,94,.12); color: var(--col-error);
  border: 1px solid rgba(244,63,94,.30); border-radius: var(--r-md);
  padding: 9px 16px; font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.btn-danger:hover { background: var(--col-error); color: #fff; transform: translateY(-1px); }
.btn-ok {
  background: rgba(34,211,165,.12); color: var(--col-ok);
  border: 1px solid rgba(34,211,165,.30); border-radius: var(--r-md);
  padding: 9px 16px; font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.btn-ok:hover { background: var(--col-ok); color: #fff; transform: translateY(-1px); }

/* Activity */
.activity-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--r-md); cursor: pointer;
  transition: all .15s;
}
.activity-item:hover { background: var(--bg-hover); transform: translateX(2px); }
.activity-item .room   { color: var(--t2); font-size: 12px; min-width: 100px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-item .author { font-size: 13px; font-weight: 600; min-width: 110px; }
.activity-item .preview{ flex: 1; color: var(--t2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-item .ts     { color: var(--t3); font-size: 11px; }

/* Channel/Group cards */
.channel-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--bg-card); border: 1px solid var(--divider);
  border-radius: var(--r-md); margin-bottom: 10px;
  transition: all .15s;
}
.channel-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.channel-card .icon-pill {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--grad-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(56,189,248,.18);
}
.channel-card .info { flex: 1; }
.channel-card .info .name { font-weight: 700; font-size: 14px; }
.channel-card .info .desc { font-size: 12px; color: var(--t3); }

/* People rows */
.person-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  border-radius: var(--r-md); cursor: pointer;
  transition: all .15s;
}
.person-row:hover { background: var(--bg-hover); transform: translateX(2px); }
.person-row .stack { position: relative; width: 40px; height: 40px; }
.person-row .stack .avatar { width: 40px; height: 40px; font-size: 13px; }
.person-row .info { flex: 1; }
.person-row .info .name { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.person-row .info .meta { font-size: 11px; color: var(--t3); margin-top: 2px; }

/* Directory groups */
.dept-group { margin-bottom: 22px; }
.dept-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 8px;
  font-size: 11px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t2); text-transform: uppercase;
}
.dept-head .count {
  background: var(--grad-soft); color: var(--accent);
  padding: 2px 9px; border-radius: 10px; font-size: 10px; font-weight: 700;
  border: 1px solid rgba(56,189,248,.18);
}

/* ── Files view ──────────────────────────────────────────────────────────── */
.file-table { padding-right: 4px; }
.file-row {
  display: grid;
  grid-template-columns: 2fr 1.4fr 1.4fr 80px 130px 90px;
  gap: 12px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--divider);
  cursor: pointer; transition: background .15s;
}
.file-row:hover { background: var(--bg-hover); }
.file-row .name-col { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-row .name-col .ext {
  width: 36px; height: 40px; border-radius: 6px; flex-shrink: 0;
  background: var(--grad); color: #fff;
  font-size: 9px; font-weight: 900; letter-spacing: .4px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(56,189,248,.30);
}
.file-row .fname { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .from-col, .file-row .src-col { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--t1); }
.file-row .size-col, .file-row .date-col { font-size: 12px; color: var(--t3); }
.file-row .act-col { display: flex; gap: 4px; justify-content: flex-end; }
.file-row .act-col .icon-btn {
  width: 32px; height: 32px; border-radius: 6px; color: var(--t2);
  display: flex; align-items: center; justify-content: center;
}
.file-row .act-col .icon-btn:hover { background: var(--bg-hover); color: var(--accent); }
.file-row-head {
  font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t3); text-transform: uppercase;
  cursor: default;
}
.file-row-head:hover { background: transparent; }

.file-preview {
  display: flex; align-items: center; justify-content: center;
  min-height: 320px; max-height: 60vh; overflow: auto;
  background: var(--bg-msg); border-radius: var(--r-md); padding: 12px;
}
.file-preview-img   { max-width: 100%; max-height: 60vh; border-radius: var(--r-sm); }
.file-preview-frame { width: 100%; height: 60vh; border: 0; border-radius: var(--r-sm); }
.file-preview-text  {
  width: 100%; max-width: 100%; max-height: 60vh; overflow: auto;
  background: var(--bg-card); padding: 12px; border-radius: var(--r-sm);
  font-family: ui-monospace, "JetBrains Mono", "Consolas", monospace;
  font-size: 12px; white-space: pre-wrap; word-break: break-word;
  color: var(--t1); margin: 0;
}
.file-preview-fallback {
  text-align: center; color: var(--t2);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}

/* ── Calendar (futuristic redesign) ──────────────────────────────────────── */
/* Both columns scroll independently. The grid never overflows the viewport
   because we cap its height at the panel; long content (lots of events,
   long upcoming list, long day-detail) scrolls inside its own column. */
.cal-grid {
  display: grid; grid-template-columns: 1fr 380px; gap: 18px;
  flex: 1; min-height: 0;
}
.cal-left  { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding-right: 4px; }
.cal-right { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding-right: 4px; }
.cal-month-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.cal-month-head h2 { margin: 0; flex: 1; font-size: 18px; font-weight: 800; letter-spacing: .2px; }
.cal-month-head .icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-md); color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--divider-2); background: var(--bg-card);
  transition: all .15s;
}
.cal-month-head .icon-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.cal-grid-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-day-name {
  text-align: center; font-size: 10px; color: var(--t3);
  font-weight: 700; letter-spacing: 1.2px; padding: 6px 0;
}
.cal-day {
  background: var(--bg-card); border: 1px solid var(--divider);
  border-radius: var(--r-md); min-height: 76px; padding: 8px;
  cursor: pointer; transition: all .18s cubic-bezier(.4, 0, .2, 1);
  position: relative;
  overflow: hidden;
}
.cal-day::before {
  content: ""; position: absolute; inset: 0;
  background: var(--grad-soft); opacity: 0;
  transition: opacity .2s; pointer-events: none;
}
.cal-day:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.cal-day:hover::before { opacity: .6; }
.cal-day.today {
  border-color: var(--accent);
  background: var(--grad-soft);
  box-shadow: 0 0 0 1px rgba(56,189,248,.15), var(--glow-soft);
}
.cal-day.today .num { color: var(--accent); font-weight: 800; }
.cal-day.selected {
  background: var(--grad);
  border-color: transparent;
  box-shadow: var(--glow-soft);
}
.cal-day.selected .num { color: #fff; }
.cal-day.selected::before { opacity: 0; }
.cal-day.outside { opacity: .35; }
.cal-day.weekend .num { color: var(--t3); }
.cal-day .num { font-size: 13px; font-weight: 600; position: relative; z-index: 1; }
.cal-day .dots {
  position: absolute; bottom: 8px; left: 8px;
  display: flex; gap: 3px;
  z-index: 1;
}
.cal-day .dots .d { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-day.selected .dots .d { background: #fff; }
.cal-upcoming { margin-top: 18px; flex-shrink: 0; }
.cal-upcoming h3 { margin: 0 0 8px; font-size: 11px; color: var(--t3); letter-spacing: 1.4px; text-transform: uppercase; font-weight: 800; }
.cal-upcoming .item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--r-md); cursor: pointer;
  border-left: 3px solid var(--t3);
  background: var(--bg-card); margin-bottom: 8px;
  transition: all .15s;
}
.cal-upcoming .item:hover { transform: translateX(3px); border-left-width: 4px; }
.cal-upcoming .item.accepted  { border-left-color: var(--col-ok); }
.cal-upcoming .item.rejected  { border-left-color: var(--col-error); }
.cal-upcoming .item.pending   { border-left-color: var(--col-warn); }
.cal-upcoming .item.organizer { border-left-color: var(--accent); }
.cal-upcoming .title { flex: 1; font-size: 13px; font-weight: 600; }
.cal-upcoming .when  { font-size: 11px; color: var(--t3); }

.cal-day-detail {
  padding: 14px; background: var(--bg-card);
  border: 1px solid var(--divider); border-radius: var(--r-lg);
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}
.cal-day-detail .head { padding-bottom: 10px; border-bottom: 1px solid var(--divider); margin-bottom: 10px; }
.cal-day-detail .head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.cal-day-detail .head small { color: var(--t3); font-size: 11px; }
.cal-day-detail .events { flex: 1; overflow-y: auto; }
.event-card {
  border-left: 3px solid var(--t3); padding: 10px 12px; margin-bottom: 10px;
  background: var(--bg-msg); border-radius: var(--r-md);
  transition: all .15s;
}
.event-card:hover { transform: translateX(2px); }
.event-card.accepted  { border-left-color: var(--col-ok); }
.event-card.rejected  { border-left-color: var(--col-error); }
.event-card.pending   { border-left-color: var(--col-warn); }
.event-card.organizer { border-left-color: var(--accent); }
.event-card .row { display: flex; align-items: center; gap: 10px; }
.event-card .title { font-weight: 700; flex: 1; font-size: 13px; }
.event-card .time { font-size: 11px; color: var(--t3); }
.event-card .meta { font-size: 11px; color: var(--t3); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.event-card .chip {
  font-size: 10px; padding: 2px 7px; border-radius: 4px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
}
.event-card .chip.accepted  { background: rgba(34,211,165,.16); color: var(--col-ok); }
.event-card .chip.rejected  { background: rgba(244,63,94,.16); color: var(--col-error); }
.event-card .chip.pending   { background: rgba(245,158,11,.16); color: var(--col-warn); }
.event-card .chip.organizer { background: rgba(56,189,248,.16); color: var(--accent); }
.event-card .actions { display: flex; gap: 8px; margin-top: 10px; }

.cal-shortcuts-bar {
  display: flex; gap: 8px; align-items: center;
  font-size: 10px; color: var(--t3); letter-spacing: .8px; text-transform: uppercase;
  margin-left: auto;
}
.cal-shortcuts-bar kbd {
  background: var(--bg-card); border: 1px solid var(--divider-2);
  border-radius: 4px; padding: 1px 6px; font-family: ui-monospace, "Consolas", monospace;
  font-size: 10px; color: var(--t1);
}

/* Profile edit */
.profile-cover {
  height: 180px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, #1b2d5b, #243966 50%, var(--accent));
  position: relative; margin-bottom: 70px;
  overflow: hidden;
}
.profile-cover::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 70% 50%, rgba(56,189,248,.30), transparent 60%);
}
.profile-avatar {
  position: absolute; left: 32px; bottom: -50px;
  width: 110px; height: 110px; border-radius: 50%;
  border: 4px solid var(--bg-base);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 34px;
  cursor: pointer; overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px var(--divider-2);
  transition: transform .15s;
  background: linear-gradient(135deg, #4a7dff, #818cf8);   /* fallback gradient */
  z-index: 2;
}
.profile-avatar:hover { transform: scale(1.04); }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar .overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s; z-index: 3;
}
.profile-avatar:hover .overlay { opacity: 1; }
.profile-name-row {
  position: absolute; left: 160px; bottom: 18px; color: #fff;
  z-index: 1;
}
.profile-name-row h2 { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.1; }
.profile-name-row small { opacity: .85; font-size: 13px; }
.profile-info-bar {
  display: flex; gap: 24px; flex-wrap: wrap;
  padding: 12px 4px 14px; color: var(--t2); font-size: 13px;
  border-bottom: 1px solid var(--divider); margin-bottom: 22px;
}
.profile-section { margin-bottom: 28px; }
.profile-section h3 {
  margin: 0 0 14px; font-size: 11px; font-weight: 800;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--t2);
}
.profile-section > label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; color: var(--t3); font-weight: 600; letter-spacing: .3px;
  margin-bottom: 12px;
}
.profile-section > label > input,
.profile-section > label > textarea { width: 100%; }
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.form-grid label, .form-stack label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11px; color: var(--t3); font-weight: 600; letter-spacing: .3px;
}
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.toggle {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 13px; color: var(--t1);
}
.toggle input { display: none; }
.toggle .track {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--divider-2); position: relative; transition: background .18s;
}
.toggle .track::after {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,.30);
}
.toggle input:checked + .track { background: var(--grad); }
.toggle input:checked + .track::after { transform: translateX(18px); }

/* Admin */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs .tab {
  padding: 9px 18px; border-radius: var(--r-md); font-size: 13px; font-weight: 700;
  color: var(--t2); border: 1px solid var(--divider-2);
  background: var(--bg-card);
  transition: all .15s;
}
.tabs .tab:hover { color: var(--t1); border-color: var(--accent); }
.tabs .tab.active { background: var(--grad-soft); color: var(--accent); border-color: var(--accent); }

.admin-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--bg-card); border: 1px solid var(--divider);
  border-radius: var(--r-md); margin-bottom: 8px;
  transition: all .15s;
}
.admin-row:hover { border-color: var(--divider-2); transform: translateX(2px); }
.admin-row.inactive { opacity: .55; }
.admin-row .info { flex: 1; min-width: 0; }
.admin-row .name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-row .name { font-weight: 700; font-size: 14px; }
.admin-row .meta { font-size: 11px; color: var(--t3); margin-top: 2px; }
.admin-row .pill {
  font-size: 9px; padding: 2px 7px; border-radius: 4px;
  font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase;
}
.admin-row .pill.public  { background: rgba(34,211,165,.14); color: var(--col-ok); }
.admin-row .pill.private { background: rgba(168,85,247,.14); color: var(--role-4); }
.admin-row .pill.inactive{ background: rgba(244,63,94,.14); color: var(--col-error); }
.admin-row .pill.r1 { background: rgba(212,168,0,.16); color: var(--role-1); }
.admin-row .pill.r2 { background: rgba(139,139,139,.16); color: var(--role-2); }
.admin-row .pill.r3 { background: rgba(14,165,233,.16); color: var(--role-3); }
.admin-row .pill.r4 { background: rgba(168,85,247,.16); color: var(--role-4); }
.admin-row .pill.r5 { background: rgba(74,125,255,.16); color: var(--role-5); }
.admin-row .actions { display: flex; gap: 4px; }
.admin-row .actions .icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.admin-row .actions .icon-btn:hover { background: var(--bg-hover); color: var(--accent); }
.admin-row .actions .icon-btn.danger:hover { color: var(--col-error); background: rgba(244,63,94,.10); }

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(4,8,16,.65);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
  animation: fadeIn .18s ease-out;
}
.modal-card {
  width: 560px; max-width: 92vw; max-height: 84vh;
  background: var(--bg-glass); backdrop-filter: blur(28px) saturate(140%);
  border: 1px solid var(--divider-2);
  border-radius: var(--r-lg); display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp .22s cubic-bezier(.34, 1.56, .64, 1);
}
:root[data-theme="light"] .modal-card { background: rgba(255,255,255,.95); }
.modal-card.wide  { width: 760px; }
.modal-card.tight { width: 400px; }
.modal-card header {
  display: flex; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
}
.modal-card header h2 { margin: 0; font-size: 17px; font-weight: 800; flex: 1; letter-spacing: .2px; }
.modal-card header .icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--t2);
  display: flex; align-items: center; justify-content: center;
}
.modal-card header .icon-btn:hover { background: var(--bg-hover); color: var(--col-error); }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--divider);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* Emoji picker */
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  padding: 4px;
}
.emoji-grid button {
  font-size: 24px; width: 40px; height: 40px; border-radius: var(--r-sm);
  transition: all .12s;
}
.emoji-grid button:hover { background: var(--bg-hover); transform: scale(1.15); }

/* Member chips */
.member-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--grad-soft); color: var(--accent);
  font-size: 12px; font-weight: 600;
  border: 1px solid rgba(56,189,248,.18);
}
.chip .x { cursor: pointer; opacity: .7; transition: opacity .15s; }
.chip .x:hover { opacity: 1; color: var(--col-error); }

/* Toast notifications */
.toast-stack {
  position: fixed; right: 20px; bottom: 20px;
  display: flex; flex-direction: column-reverse; gap: 10px;
  z-index: 2000; pointer-events: none;
}
.toast {
  background: var(--bg-glass); backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--divider-2);
  border-radius: var(--r-md); padding: 12px 14px; width: 340px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 12px;
  pointer-events: auto;
  animation: slideUp .25s cubic-bezier(.34, 1.56, .64, 1);
  border-left: 3px solid var(--accent);
}
.toast.error { border-left-color: var(--col-error); }
.toast.ok    { border-left-color: var(--col-ok); }
.toast.info  { border-left-color: var(--col-info); }
.toast .body { flex: 1; min-width: 0; }
.toast .title { font-size: 13px; font-weight: 700; }
.toast .preview { font-size: 12px; color: var(--t2); margin-top: 2px; line-height: 1.35; }
.toast .x { color: var(--t3); cursor: pointer; transition: color .15s; }
.toast .x:hover { color: var(--col-error); }
.toast .actions { margin-top: 8px; display: flex; gap: 6px; }
.toast .actions button { padding: 5px 11px; font-size: 11px; }

/* Notification center list */
.notif-list .item {
  padding: 10px 12px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--divider); cursor: pointer;
  transition: all .15s;
}
.notif-list .item:hover { background: var(--bg-hover); transform: translateX(2px); }
.notif-list .item:last-child { border-bottom: 0; }
.notif-list .item .author { font-weight: 700; font-size: 13px; }
.notif-list .item .preview { color: var(--t2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.notif-list .item .ts { color: var(--t3); font-size: 11px; }

/* Reader receipts modal list */
.reader-list .item {
  display: flex; align-items: center; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--divider);
}
.reader-list .item:last-child { border-bottom: 0; }

/* SVG icon */
.icn { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icn.sm { width: 14px; height: 14px; }
.icn.md { width: 16px; height: 16px; }
.icn.lg { width: 22px; height: 22px; }
.icn.xl { width: 28px; height: 28px; }

/* ── Confirmation dialog ─────────────────────────────────────────────────── */
.confirm-dialog .modal-body { padding: 20px; }
.confirm-dialog .icon-circle {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.confirm-dialog .icon-circle.warn { background: rgba(245,158,11,.14); color: var(--col-warn); }
.confirm-dialog .icon-circle.danger { background: rgba(244,63,94,.14); color: var(--col-error); }
.confirm-dialog h3 { margin: 0 0 8px; text-align: center; font-size: 18px; }
.confirm-dialog p  { margin: 0; text-align: center; color: var(--t2); font-size: 13px; line-height: 1.5; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  #sidebar { width: 220px; }
  .thread-pane { width: 320px; }
}
@media (max-width: 900px) {
  #sidebar { width: 200px; }
  .thread-pane { width: 300px; }
  .cal-grid { grid-template-columns: 1fr; }
  #topbar .clock { display: none; }
}
@media (max-width: 720px) {
  #rail    { width: 56px; }
  #sidebar { width: 180px; }
  #topbar .search-wrap { padding: 0 10px; }
  #topbar .brand-text { display: none; }
}
@media (max-width: 540px) {
  #topbar .mobile-only { display: flex !important; }
  #rail    { position: fixed; left: 0; top: 60px; bottom: 0; z-index: 50;
             transform: translateX(-100%); transition: transform .2s; }
  #sidebar { position: fixed; left: 56px; top: 60px; bottom: 0; z-index: 49;
             transform: translateX(-200%); transition: transform .2s;
             box-shadow: var(--shadow-lg); }
  body.nav-open #rail    { transform: translateX(0); }
  body.nav-open #sidebar { transform: translateX(0); }
  .thread-pane { display: none; }
  #shell-row > #content { width: 100%; }
}

/* ────────────────────────────────────────────────────────────────────────── */
/*                      GLOBAL SEARCH PALETTE                                 */
/* Anchored under the topbar input. Categorized: Sections, People, Groups,    */
/* Messages, Files. Keyword highlighting via <mark>.                          */
/* ────────────────────────────────────────────────────────────────────────── */
.search-palette {
  position: fixed; z-index: 1000; max-height: 70vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--divider-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: 4px 0; min-width: 320px;
  animation: slideUp .14s ease-out;
}
.search-palette .sp-section { padding: 6px 0; border-bottom: 1px solid var(--divider); }
.search-palette .sp-section:last-child { border-bottom: 0; }
.search-palette .sp-head {
  font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--t3); text-transform: uppercase;
  padding: 8px 14px 4px;
}
.search-palette .sp-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; cursor: pointer; transition: background .12s;
}
.search-palette .sp-row:hover { background: rgba(56,189,248,.10); }
.search-palette .sp-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(74,125,255,.14); color: var(--col-info);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.search-palette .sp-info { min-width: 0; flex: 1; }
.search-palette .sp-primary {
  font-size: 13px; font-weight: 600; color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-palette .sp-secondary {
  font-size: 11px; color: var(--t3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-palette mark {
  background: rgba(56,189,248,.30); color: var(--t1);
  padding: 0 1px; border-radius: 2px;
}
.search-palette .sp-empty {
  padding: 16px 14px; color: var(--t3); font-size: 12px; text-align: center;
}
.search-palette .sp-empty.error { color: var(--col-error); }

/* ────────────────────────────────────────────────────────────────────────── */
/*                  PLAYGROUND — multi-drawing whiteboard                     */
/* ────────────────────────────────────────────────────────────────────────── */
.canvas-layout {
  display: grid; grid-template-columns: 240px 1fr;
  gap: 12px; height: 100%; min-height: 0;
}
.drawings-sidebar {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px; background: var(--bg-card);
  border: 1px solid var(--divider); border-radius: var(--r-md);
  overflow-y: auto; min-height: 0;
}
.drawings-sidebar .ds-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 800; letter-spacing: 1.2px;
  color: var(--t3); text-transform: uppercase;
  padding: 4px 6px 8px;
}
.new-drawing-btn {
  width: 100%; padding: 8px 10px; font-size: 12px; font-weight: 600;
  background: var(--grad); color: #fff; border: 0;
  border-radius: var(--r-sm); cursor: pointer; margin-bottom: 6px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.new-drawing-btn:hover { box-shadow: var(--glow-soft); }
.drawing-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: var(--r-sm);
  cursor: pointer; border: 1px solid transparent;
  transition: all .12s;
}
.drawing-item:hover { background: rgba(56,189,248,.08); }
.drawing-item.active {
  background: rgba(56,189,248,.14);
  border-color: rgba(56,189,248,.40);
}
.drawing-item .di-title {
  font-size: 13px; font-weight: 600; color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawing-item .di-meta { font-size: 10px; color: var(--t3); }
.drawing-item .di-acts {
  display: flex; gap: 4px; margin-top: 4px; opacity: 0;
  transition: opacity .12s;
}
.drawing-item:hover .di-acts,
.drawing-item.active .di-acts { opacity: 1; }
.drawing-item .di-acts button {
  padding: 2px 6px; font-size: 10px;
  background: transparent; color: var(--t2);
  border: 1px solid var(--divider-2); border-radius: 4px;
  cursor: pointer;
}
.drawing-item .di-acts button:hover { background: var(--bg-hover); color: var(--t1); }
.drawing-item .di-acts button.danger:hover { color: var(--col-error); border-color: var(--col-error); }
.canvas-area {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-card); border: 1px solid var(--divider);
  border-radius: var(--r-md); overflow: hidden;
}

/* ────────────────────────────────────────────────────────────────────────── */
/*                LOGIN — PIN / Password mode toggle + password input         */
/* ────────────────────────────────────────────────────────────────────────── */
.login-mode-row {
  display: flex; gap: 4px; width: 100%;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  border-radius: var(--r-md); padding: 3px; margin-bottom: 16px;
}
.lm-tab {
  flex: 1; padding: 8px 10px; font-size: 12px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  background: transparent; color: var(--t3);
  border: 0; border-radius: calc(var(--r-md) - 4px); cursor: pointer;
  transition: all .15s ease;
}
.lm-tab:hover { color: var(--t1); }
.lm-tab.active {
  background: var(--grad); color: #fff;
  box-shadow: var(--glow-soft);
}
.login-pin-section, .login-pw-section {
  width: 100%; display: flex; flex-direction: column; align-items: center;
}
.login-pw-section.hidden, .login-pin-section.hidden { display: none; }
.login-password {
  width: 100%; height: 48px; padding: 12px 14px;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  border-radius: var(--r-md); font-size: 14px; color: var(--t1);
  letter-spacing: 1px;
  transition: border-color .15s, box-shadow .15s;
}
.login-password:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.16);
  outline: 0;
}
.login-password.error {
  border-color: var(--col-error);
  animation: pulse .4s ease;
}

/* ────────────────────────────────────────────────────────────────────────── */
/*                  AUDIT LOG — per-user split panel                          */
/* ────────────────────────────────────────────────────────────────────────── */
.audit-layout {
  display: grid; grid-template-columns: 260px 1fr;
  gap: 12px; min-height: 0;
}
.audit-actors {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--divider);
  border-radius: var(--r-md); padding: 10px;
  max-height: 70vh; overflow-y: auto;
}
.audit-actors-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 800; letter-spacing: 1.2px;
  color: var(--t3); text-transform: uppercase;
  padding: 0 4px;
}
.audit-actor-search {
  width: 100%; padding: 7px 10px; font-size: 12px;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  border-radius: var(--r-sm); color: var(--t1);
}
.audit-actor-list { display: flex; flex-direction: column; gap: 2px; }
.audit-actor-row {
  padding: 8px 10px; border-radius: var(--r-sm);
  cursor: pointer; border: 1px solid transparent;
  transition: all .12s;
}
.audit-actor-row:hover { background: rgba(56,189,248,.08); }
.audit-actor-row.active {
  background: rgba(56,189,248,.14);
  border-color: rgba(56,189,248,.40);
}
.audit-actor-row .aa-name {
  font-size: 13px; font-weight: 600; color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.audit-actor-row .aa-meta { font-size: 10px; color: var(--t3); margin-top: 2px; }

.audit-detail {
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0; min-height: 0;
}
.audit-detail-head {
  display: flex; align-items: center; justify-content: space-between;
}
.audit-detail-title {
  font-size: 16px; font-weight: 800; color: var(--t1); margin: 0;
}
.audit-filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.audit-filters .audit-search {
  flex: 1; min-width: 220px;
  padding: 7px 10px; font-size: 12px;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  border-radius: var(--r-sm); color: var(--t1);
}
.audit-filters .audit-action-sel {
  padding: 7px 10px; font-size: 12px;
  background: var(--bg-input); border: 1px solid var(--divider-2);
  border-radius: var(--r-sm); color: var(--t1);
}
.audit-pagination {
  display: flex; gap: 10px; align-items: center;
  justify-content: space-between; padding: 6px 4px;
  border-top: 1px solid var(--divider);
}
.audit-pagination button:disabled { opacity: .35; cursor: not-allowed; }

@media (max-width: 880px) {
  .audit-layout    { grid-template-columns: 1fr; }
  .canvas-layout   { grid-template-columns: 1fr; }
  .drawings-sidebar { max-height: 200px; }
}

/* ── DEMO: mobile hardening — keep the topbar pills inside the viewport ── */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  #topbar { overflow: hidden; }
  #topbar .right { gap: 2px !important; flex-shrink: 1; flex-wrap: nowrap; }
  #topbar .icon-pill { width: 30px !important; height: 30px !important; }
  #topbar .pill-divider { display: none !important; }
  #topbar .brand-text { display: none; }       /* logo stays; wordmark hides on phones */
  #demo-ribbon { font-size: 10.5px; }
}
