/* ════════════════════════════════════════════════════════════════
   ProfNoteChat — Fluent 2 Design System
   Complete ground-up rewrite · RTL Arabic · Dark + Light
   Every class from index.html accounted for
════════════════════════════════════════════════════════════════ */

/* ── FLUENT 2 DESIGN TOKENS ─────────────────────────────────── */
:root {
  --font: 'Cairo', sans-serif;
  --mono: 'JetBrains Mono', monospace;

  /* 4-px spacing grid */
  --s1: 4px;   --s2: 8px;   --s3: 12px;  --s4: 16px;
  --s5: 20px;  --s6: 24px;  --s8: 32px;  --s10: 40px;

  /* Fluent 2 Corner Radius */
  --r0: 2px;   --r1: 4px;   --r2: 6px;
  --r3: 8px;   --r4: 10px;  --r5: 12px;
  --r6: 16px;  --r7: 20px;  --r8: 24px;

  /* Fluent 2 Motion Curves */
  --e-enter:  .2s cubic-bezier(0, 0, 0, 1);
  --e-exit:   .15s cubic-bezier(0.7, 0, 1, 1);
  --e-fast:   .1s cubic-bezier(0.33, 1, 0.68, 1);
  --e-std:    .2s cubic-bezier(0.33, 1, 0.68, 1);
  --e-slow:   .35s cubic-bezier(0.22, 1, 0.36, 1);
  --e-spring: .4s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* aliases used in JS/HTML */
  --fast: var(--e-fast);
  --ease: var(--e-std);

  /* Fluent 2 Elevation / Shadow */
  --el-2:  0 1px 2px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
  --el-4:  0 2px 4px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
  --el-8:  0 4px 8px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
  --el-16: 0 8px 16px rgba(0,0,0,.14), 0 0 4px rgba(0,0,0,.10);
  --el-28: 0 14px 28px rgba(0,0,0,.24), 0 0 8px rgba(0,0,0,.16);
  --el-64: 0 32px 64px rgba(0,0,0,.30), 0 0 12px rgba(0,0,0,.20);

  /* Layout */
  --sb-w:   220px;
  --sb-min: 52px;
  --top-h:  48px;
}

/* ── DARK THEME (default) ────────────────────────────────────── */
:root, [data-theme="dark"] {
  /* Fluent 2 Neutral Ramp — dark */
  --bg:  #111113;
  --bg2: #1a1a1f;
  --bg3: #222228;
  --bg4: #2a2a32;
  --bg5: #36363f;

  /* Glass / Acrylic */
  --gl:  rgba(17,17,19,.84);
  --gl2: rgba(26,26,31,.92);
  --gl3: rgba(34,34,40,.97);

  /* Fluent 2 Stroke tokens */
  --b1: rgba(255,255,255,.0824); /* Stroke/Default */
  --b2: rgba(255,255,255,.1412); /* Stroke/Strong  */
  --b3: rgba(255,255,255,.2039); /* Stroke/Stronger*/

  /* Fluent 2 Text tokens */
  --t1: #f0f0f4;                 /* Text/Primary   */
  --t2: rgba(240,240,244,.65);   /* Text/Secondary */
  --t3: rgba(240,240,244,.42);   /* Text/Tertiary  */
  --t4: rgba(240,240,244,.22);   /* Text/Disabled  */

  /* Accent — elegant soft violet */
  --acc:  #7c4dff;
  --acc-d:#5e35b1;
  --acc-l:#9c6fff;
  --acc2: #9c6fff;
  --accd: #5e35b1;
  --abg:  rgba(124,77,255,.15);
  --abg2: rgba(124,77,255,.08);
  --glow: rgba(124,77,255,.28);

  /* Semantic — vivid */
  --grn: #3dd68c;  --gbg: rgba(61,214,140,.18);
  --red: #ff6b6b;  --rbg: rgba(255,107,107,.18);
  --org: #ffb347;  --obg: rgba(255,179,71,.18);
  --pur: #c27aff;  --pbg: rgba(194,122,255,.18);
  --teal:#00d8e0;  --tbg: rgba(0,216,224,.15);
}

/* ── LIGHT THEME ─────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:  #f5f5f5;
  --bg2: #ffffff;
  --bg3: #f0f0f0;
  --bg4: #e6e6e6;
  --bg5: #d6d6d6;
  --gl:  rgba(245,245,245,.88);
  --gl2: rgba(255,255,255,.94);
  --gl3: rgba(248,248,248,.98);
  --b1: rgba(0,0,0,.0824);
  --b2: rgba(0,0,0,.1412);
  --b3: rgba(0,0,0,.2039);
  --t1: rgba(0,0,0,.8863);
  --t2: rgba(0,0,0,.5412);
  --t3: rgba(0,0,0,.3608);
  --t4: rgba(0,0,0,.2000);
  --acc:  #5e35b1;
  --acc-d:#4527a0;
  --acc-l:#7c4dff;
  --acc2: #5e35b1;
  --accd: #4527a0;
  --abg:  rgba(94,53,177,.10);
  --abg2: rgba(94,53,177,.06);
  --glow: rgba(94,53,177,.20);
  --grn: #1a8a3a;  --gbg: rgba(26,138,58,.12);
  --red: #d93025;  --rbg: rgba(217,48,37,.12);
  --org: #e07000;  --obg: rgba(224,112,0,.12);
  --pur: #6b45d6;  --pbg: rgba(107,69,214,.12);
  --teal:#007585;  --tbg: rgba(0,117,133,.10);
  --el-2:  0 1px 2px rgba(0,0,0,.08), 0 0 2px rgba(0,0,0,.05);
  --el-4:  0 2px 4px rgba(0,0,0,.08), 0 0 2px rgba(0,0,0,.05);
  --el-8:  0 4px 8px rgba(0,0,0,.08), 0 0 2px rgba(0,0,0,.05);
  --el-16: 0 8px 16px rgba(0,0,0,.10), 0 0 4px rgba(0,0,0,.06);
  --el-28: 0 14px 28px rgba(0,0,0,.14), 0 0 8px rgba(0,0,0,.08);
  --el-64: 0 32px 64px rgba(0,0,0,.18), 0 0 12px rgba(0,0,0,.10);
}

/* ── BASE RESET ──────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--t1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button, input, textarea, select { font-family: var(--font); }

/* Fluent 2 scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--b3); }

/* Fluent 2 focus ring */
:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
  border-radius: var(--r1);
}

a { color: var(--acc2); text-decoration: none; }

/* ── SCREEN SYSTEM ───────────────────────────────────────────── */
.screen { position: fixed; inset: 0; z-index: 1; display: none; }
.screen.active { display: flex; flex-direction: column; }
#app-screen.active { display: flex; flex-direction: row; }

/* ════════════════════════════════════════════════════════════════
   AUTH PAGE — Fluent 2 Card Elevation
════════════════════════════════════════════════════════════════ */
#auth-screen {
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 85% 5%,  rgba(71,158,245,.13) 0%, transparent 55%),
    radial-gradient(ellipse 50% 55% at 15% 95%, rgba(192,132,245,.09) 0%, transparent 55%),
    var(--bg);
}

.auth-scroll-outer {
  width: 100%; min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 0;
}

.auth-wrap {
  width: 100%; max-width: 400px; padding: 20px;
  animation: f2SlideIn .28s var(--e-enter) both;
}
@keyframes f2SlideIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* Brand */
.brand {
  display: flex; align-items: center; gap: 14px;
  justify-content: center; margin-bottom: 20px;
}
.brand-ic {
  width: 48px; height: 48px; border-radius: var(--r6);
  background: linear-gradient(145deg, var(--acc-l), var(--acc-d));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px var(--glow);
}
.brand-nm {
  font-size: 1.4rem; font-weight: 900; letter-spacing: -.4px; color: var(--t1);
}

/* Auth card — Fluent 2 Elevation 8 */
.auth-card {
  background: var(--gl2);
  border: 1px solid var(--b2);
  border-radius: var(--r6);
  padding: 20px;
  box-shadow: var(--el-28);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
}
[data-theme="light"] .auth-card { background: rgba(255,255,255,.97); }

/* Auth tabs — Fluent 2 Pivot */
.auth-tabs {
  display: flex; border-bottom: 1px solid var(--b1); margin-bottom: 20px;
}
.auth-tab {
  flex: 1; padding: 10px 8px;
  border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: transparent; color: var(--t3);
  font-size: .82rem; font-weight: 700; cursor: pointer;
  font-family: var(--font);
  transition: color var(--e-fast), border-color var(--e-fast);
}
.auth-tab.active  { color: var(--acc2); border-bottom-color: var(--acc); }
.auth-tab:hover:not(.active) { color: var(--t2); }

/* Field group — Fluent 2 TextField */
.fg { margin-bottom: 16px; }
.fg label {
  display: block; font-size: .72rem; font-weight: 700; color: var(--t2); margin-bottom: 6px;
}
.fg input {
  width: 100%; padding: 9px 12px;
  background: var(--bg3); border: 1.5px solid var(--b2);
  border-radius: var(--r3); color: var(--t1);
  font-size: .86rem; outline: none; font-family: var(--font);
  transition: border-color var(--e-std), box-shadow var(--e-std), background var(--e-std);
}
.fg input::placeholder { color: var(--t3); }
.fg input:hover  { border-color: var(--b3); }
.fg input:focus  { border-color: var(--acc); background: var(--bg4); box-shadow: 0 0 0 1px var(--acc); }

/* Primary button — Fluent 2 Accent Button */
.btn-primary {
  width: 100%; padding: 10px 16px;
  border-radius: var(--r3); border: none; cursor: pointer;
  font-family: var(--font); font-size: .86rem; font-weight: 700;
  background: var(--acc); color: #fff;
  box-shadow: var(--el-4);
  transition: background var(--e-fast), box-shadow var(--e-fast), transform var(--e-fast);
  margin-top: 4px;
}
.btn-primary:hover  { background: var(--acc-l); box-shadow: var(--el-8); }
.btn-primary:active { background: var(--acc-d); transform: scale(.99); }

.auth-err  { min-height: 18px; margin-top: 10px; text-align: center; font-size: .76rem; color: var(--red); font-weight: 600; }
.auth-hint { font-size: .7rem; color: var(--t3); text-align: center; margin-top: 8px; }

/* ── THEME SWITCH ────────────────────────────────────────────── */
.theme-switch {
  width: 44px; height: 24px; border-radius: 12px;
  border: none; cursor: pointer; padding: 0; background: transparent; outline: none; flex-shrink: 0;
}
.ts-track {
  display: block; width: 100%; height: 100%;
  background: var(--bg4); border: 1.5px solid var(--b2); border-radius: 12px;
  position: relative;
  transition: background var(--e-std), border-color var(--e-std);
}
[data-theme="light"] .ts-track { background: #d8e8f5; }
.ts-thumb {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(145deg, var(--acc-l), var(--acc-d));
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--el-4); font-size: .68rem;
  transition: transform var(--e-spring), background var(--e-std);
}
.ts-icon { line-height: 1; user-select: none; }
[data-theme="light"] .ts-thumb {
  transform: translateX(-20px);
  background: linear-gradient(145deg, #f59e0b, #fbbf24);
}

/* ════════════════════════════════════════════════════════════════
   APP LAYOUT
════════════════════════════════════════════════════════════════ */
.layout { display: flex; height: 100vh; width: 100%; overflow: hidden; }
.main   { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ════════════════════════════════════════════════════════════════
   SIDEBAR — Fluent 2 NavigationView
════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sb-w); min-width: var(--sb-w); flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--b1);  /* RTL: left side faces main content */
  display: flex; flex-direction: column; height: 100%;
  overflow: hidden;
  transition: width var(--e-enter), min-width var(--e-enter);
}
[data-theme="dark"]  .sidebar { background: #1c1c1c; }
[data-theme="light"] .sidebar { background: #f9f9f9; }

.sidebar.collapsed {
  width: var(--sb-min)   !important;
  min-width: var(--sb-min) !important;
}

/* ── Sidebar Head ── */
.sb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px;
  min-height: var(--top-h); flex-shrink: 0;
  border-bottom: 1px solid var(--b1);
  gap: 8px;
}
.sb-brand { display: flex; align-items: center; gap: 10px; overflow: hidden; flex: 1; min-width: 0; }
.sb-logo {
  width: 28px; height: 28px; border-radius: var(--r4); flex-shrink: 0;
  background: linear-gradient(145deg, var(--acc-l), var(--acc-d));
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--el-4);
}
.sb-name {
  font-size: .85rem; font-weight: 800; white-space: nowrap;
  overflow: hidden; color: var(--t1);
  transition: opacity var(--e-std), width var(--e-enter);
}
.sidebar.collapsed .sb-name { opacity: 0; width: 0; }

/* Fluent 2 Subtle button */
.sb-toggle {
  width: 26px; height: 26px; border-radius: var(--r2);
  border: 1px solid var(--b1); background: transparent;
  color: var(--t3); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast), border-color var(--e-fast), color var(--e-fast);
}
.sb-toggle svg { transition: transform var(--e-enter); }
.sidebar.collapsed .sb-toggle svg { transform: rotate(180deg); }
.sb-toggle:hover { background: var(--bg3); border-color: var(--b2); color: var(--t2); }

/* ── User Chip ── */
.sb-user-chip {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 8px 4px; padding: 8px 9px;
  border-radius: var(--r4); background: var(--bg3);
  border: 1px solid var(--b1);
  overflow: hidden; transition: background var(--e-fast); flex-shrink: 0;
}
.sb-user-chip:hover { background: var(--bg4); }
.sidebar.collapsed .sb-user-chip { justify-content: center; padding: 8px; }
.avatar {
  width: 26px; height: 26px; border-radius: var(--r2); flex-shrink: 0;
  background: linear-gradient(145deg, var(--acc-l), var(--pur));
  display: flex; align-items: center; justify-content: center;
  font-size: .6rem; font-weight: 900; color: #fff;
}
.sb-user-info { overflow: hidden; min-width: 0; }
.sidebar.collapsed .sb-user-info { display: none; }
.sb-user-name { font-size: .74rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--t1); }
.sb-user-role { font-size: .62rem; color: var(--acc2); font-weight: 600; margin-top: 1px; }

/* ── Nav ── */
.sb-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 4px 6px;
  scrollbar-width: thin; scrollbar-color: var(--b1) transparent;
}

.sb-section-label {
  font-size: .6rem; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--t4); padding: 10px 8px 3px;
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap; overflow: hidden; user-select: none; cursor: default;
}
.sidebar.collapsed .sb-section-label { display: none; }
.sb-section-collapsible { cursor: pointer; }
.sb-section-collapsible:hover { color: var(--t3); }
.sb-section-arrow { opacity: .5; flex-shrink: 0; transition: transform var(--e-std); }
.sb-section-body { overflow: hidden; max-height: 600px; transition: max-height var(--e-enter); }
.sb-section-body.closed { max-height: 0; }
.sidebar.collapsed .sb-section-body { display: none; }

.sb-section-add {
  width: 16px; height: 16px; border-radius: var(--r0);
  border: 1px solid var(--b1); background: transparent; color: var(--t4);
  font-size: .72rem; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  transition: background var(--e-fast), color var(--e-fast), border-color var(--e-fast);
}
.sb-section-add:hover { background: var(--abg); color: var(--acc2); border-color: var(--b2); }
.sidebar.collapsed .sb-section-add { display: none; }

/* ── NavigationViewItem ── */
.sb-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  border-radius: var(--r3); border: 1px solid transparent; background: transparent;
  color: var(--t2); font-size: .8rem; font-weight: 600;
  cursor: pointer; text-align: right; font-family: var(--font);
  transition: background var(--e-fast), color var(--e-fast), border-color var(--e-fast);
  position: relative; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden;
}
.sb-item svg { flex-shrink: 0; width: 16px; height: 16px; opacity: .55; transition: opacity var(--e-fast); }
.sb-item-label { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.sidebar.collapsed .sb-item { justify-content: center; padding: 9px 8px; gap: 0; }
.sidebar.collapsed .sb-item-label { display: none; }
.sb-item:hover { background: var(--bg3); color: var(--t1); }
.sb-item:hover svg { opacity: .85; }

/* Active — Fluent 2 indicator pill (RIGHT side in RTL layout) */
.sb-item.active {
  background: var(--abg);
  border-color: var(--b2);
  color: var(--acc);
  font-weight: 700;
}
.sb-item.active svg { opacity: 1; color: var(--acc); }
.sb-item.active::after {
  content: '';
  position: absolute; right: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 2px 0 0 2px;
  background: var(--acc);
}
.sidebar.collapsed .sb-item.active::after { display: none; }

/* ── Sidebar Bottom ── */
.sb-bottom {
  padding: 6px; border-top: 1px solid var(--b1);
  display: flex; flex-direction: column; gap: 2px; flex-shrink: 0;
}
.sb-bottom-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  border-radius: var(--r3); border: none; background: transparent;
  color: var(--t2); font-size: .78rem; font-weight: 600;
  cursor: pointer; text-align: right; font-family: var(--font);
  transition: background var(--e-fast), color var(--e-fast);
  white-space: nowrap; overflow: hidden;
}
.sb-bottom-btn svg { flex-shrink: 0; width: 15px; height: 15px; opacity: .6; }
.sidebar.collapsed .sb-bottom-btn { justify-content: center; padding: 9px 8px; gap: 0; }
.sidebar.collapsed .sb-bottom-btn .sb-item-label { display: none; }
.sb-bottom-btn:hover { background: var(--bg3); color: var(--t1); }
.sb-logout:hover { background: var(--rbg); color: var(--red); }

/* Sidebar overlay — mobile */
.sb-ov {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.42); backdrop-filter: blur(4px);
}
.sb-ov.on { display: block; }

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; right: 0; top: 0; bottom: 0; z-index: 100;
    width: var(--sb-w) !important; min-width: var(--sb-w) !important;
    transform: translateX(100%);
    box-shadow: var(--el-64);
    transition: transform var(--e-enter);
  }
  .sidebar.open { transform: translateX(0); }
}

/* ════════════════════════════════════════════════════════════════
   TOPBAR — Fluent 2 Title Bar
════════════════════════════════════════════════════════════════ */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: var(--top-h);
  background: var(--gl); border-bottom: 1px solid var(--b1);
  flex-shrink: 0; z-index: 20;
  backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
}
[data-theme="dark"]  .topbar { background: rgba(20,20,20,.84); }
[data-theme="light"] .topbar { background: rgba(249,249,249,.92); }

.menu-btn {
  display: none; width: 30px; height: 30px; border-radius: var(--r2);
  border: none; background: transparent; color: var(--t2);
  align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background var(--e-fast);
}
.menu-btn:hover { background: var(--bg3); }

.topbar-title {
  font-size: .88rem; font-weight: 800; flex-shrink: 0; color: var(--t1);
  white-space: nowrap;
}

/* ── Fluent 2 Expandable Search ── */
.f2-search-wrap {
  flex: 1; display: flex; align-items: center;
  justify-content: flex-end; position: relative; min-width: 0;
}

/* Collapsed: icon button only */
.f2-search-btn {
  width: 30px; height: 30px; border-radius: var(--r2);
  border: none; background: transparent; color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background var(--e-fast), opacity var(--e-fast);
}
.f2-search-btn:hover { background: var(--bg3); color: var(--t1); }
.f2-search-wrap.expanded .f2-search-btn { opacity: 0; pointer-events: none; }

/* Expanded: full-width field */
.f2-search-field {
  position: absolute; right: 0; left: 0; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1.5px solid var(--b2);
  border-radius: var(--r4); padding: 0 8px 0 10px; height: 32px;
  opacity: 0; pointer-events: none; width: 0; overflow: hidden;
  transition: width var(--e-enter), opacity var(--e-enter), border-color var(--e-std);
  z-index: 10;
}
.f2-search-field.expanded { opacity: 1; pointer-events: all; width: 100%; }
.f2-search-field.focused  { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc); }
.f2-search-icon  { color: var(--t3); flex-shrink: 0; }
.f2-search-input {
  flex: 1; border: none; background: transparent; color: var(--t1);
  font-size: .82rem; outline: none; font-family: var(--font); min-width: 0;
}
.f2-search-input::placeholder { color: var(--t3); }
.f2-search-clear {
  width: 22px; height: 22px; border-radius: var(--r1); border: none;
  background: transparent; color: var(--t3); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast), color var(--e-fast);
}
.f2-search-clear:hover { background: var(--bg4); color: var(--t1); }

/* Fluent 2 Icon buttons */
.topbar-icon-btn {
  width: 30px; height: 30px; border-radius: var(--r2); flex-shrink: 0;
  border: none; background: transparent; color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast), color var(--e-fast); cursor: pointer;
}
.topbar-icon-btn:hover { background: var(--bg3); color: var(--t1); }

/* Notification bell */
.notif-bell {
  width: 30px; height: 30px; border-radius: var(--r2); flex-shrink: 0;
  border: none; background: transparent; color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast), color var(--e-fast); cursor: pointer; position: relative;
}
.notif-bell:hover { background: var(--abg); color: var(--acc2); }
.notif-dot {
  position: absolute; top: 5px; right: 5px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red); border: 1.5px solid var(--bg2); display: none;
}
.notif-dot.on { display: block; }

/* ════════════════════════════════════════════════════════════════
   FILTER CHIPS — Fluent 2 FilterPill
════════════════════════════════════════════════════════════════ */
.topbar-filters {
  display: flex; align-items: center; gap: 5px; padding: 5px 12px;
  background: var(--gl); border-bottom: 1px solid var(--b1);
  overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap;
  scrollbar-width: none; flex-shrink: 0; min-height: 40px;
  -webkit-overflow-scrolling: touch;
}
[data-theme="dark"]  .topbar-filters { background: rgba(20,20,20,.76); }
[data-theme="light"] .topbar-filters { background: rgba(249,249,249,.86); }
.topbar-filters::-webkit-scrollbar { display: none; }
.topbar-filters > * { flex-shrink: 0; }

/* FilterPill component */
.tf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 12px; border-radius: 99px;
  border: 1px solid var(--b2); background: transparent;
  color: var(--t2); font-size: .72rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; font-family: var(--font);
  transition: background var(--e-fast), border-color var(--e-fast), color var(--e-fast);
}
.tf-chip:hover  { background: var(--bg3); border-color: var(--b3); color: var(--t1); }
.tf-chip.active {
  background: var(--acc); border-color: var(--acc); color: #fff;
  box-shadow: 0 1px 6px var(--glow);
}
.tf-sep { width: 1px; height: 14px; background: var(--b1); margin: 0 2px; }
.tf-clear {
  padding: 3px 10px; border-radius: 99px; border: none; background: transparent;
  color: var(--t3); font-size: .7rem; font-weight: 600; cursor: pointer;
  font-family: var(--font);
  transition: color var(--e-fast), background var(--e-fast);
}
.tf-clear:hover { color: var(--red); background: var(--rbg); }

/* Files filter bar (same style) */
.filter-bar {
  display: flex; align-items: center; gap: 5px; padding: 6px 12px;
  border-bottom: 1px solid var(--b1);
  overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; flex-shrink: 0;
  background: var(--bg2);
}
.filter-bar::-webkit-scrollbar { display: none; }
.flt-btn {
  padding: 4px 12px; border-radius: 99px; border: 1px solid var(--b2);
  background: transparent; color: var(--t2); font-size: .72rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0; font-family: var(--font);
  transition: background var(--e-fast), border-color var(--e-fast), color var(--e-fast);
}
.flt-btn:hover { background: var(--bg3); border-color: var(--b3); color: var(--t1); }
.flt-btn.on    { background: var(--acc); border-color: var(--acc); color: #fff; }

/* ════════════════════════════════════════════════════════════════
   VIEWS — show / hide
════════════════════════════════════════════════════════════════ */
#chat-view  { display: none; flex-direction: column; flex: 1; height: 100%; overflow: hidden; }
#files-view { display: none; flex-direction: column; flex: 1; height: 100%; overflow: hidden; }
#admin-view { display: none; flex-direction: column; flex: 1; height: 100%; overflow: hidden; width: 100%; min-width: 0; }
#files-view.on { display: flex; }
#admin-view.on { display: flex; width: 100%; }

/* Calendar view */
#calendar-view { display: none; flex-direction: column; overflow: hidden; }
#calendar-view.on { display: flex; }
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--b1); flex-shrink: 0;
}
.cal-title { font-size: .9rem; font-weight: 800; }
.cal-nav { display: flex; gap: 3px; }
.cal-nav-btn {
  width: 28px; height: 28px; border-radius: var(--r2);
  border: 1px solid var(--b1); background: transparent; color: var(--t2);
  cursor: pointer; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast), color var(--e-fast);
}
.cal-nav-btn:hover { background: var(--bg3); color: var(--t1); }
.cal-grid {
  flex: 1; overflow-y: auto; padding: 12px;
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.cal-day {
  aspect-ratio: 1; border-radius: var(--r2);
  background: var(--bg3); border: 1px solid var(--b1);
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
  transition: background var(--e-fast), border-color var(--e-fast);
}
.cal-day:hover    { background: var(--bg4); border-color: var(--b2); }
.cal-day.has-msgs { border-color: var(--acc); background: var(--abg); }
.cal-day.today    { border-color: var(--grn); }
.cal-day-num { font-size: .72rem; font-weight: 800; }
.cal-day-cnt { font-size: .56rem; color: var(--acc2); font-weight: 800; }

/* ════════════════════════════════════════════════════════════════
   PINNED STRIP
════════════════════════════════════════════════════════════════ */
.pinned-strip {
  position: sticky; top: 0; z-index: 40; flex-shrink: 0;
  background: var(--gl2); border-bottom: 1px solid rgba(252,176,64,.22);
  backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
  transition: opacity var(--e-std);
}
.pinned-strip-inner {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px; min-height: 36px;
}
.pinned-strip-icon { font-size: .82rem; flex-shrink: 0; opacity: .7; }
.pinned-strip-msgs { flex: 1; display: flex; align-items: center; gap: 8px; overflow: hidden; min-width: 0; }
.pinned-preview {
  font-size: .72rem; font-weight: 600; color: var(--t2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; padding: 2px 7px; border-radius: var(--r2);
  transition: background var(--e-fast);
}
.pinned-preview:hover { background: var(--bg3); color: var(--t1); }
.pinned-preview-count {
  font-size: .63rem; font-weight: 700; color: var(--org);
  background: var(--obg); padding: 1px 6px; border-radius: 99px; flex-shrink: 0;
}
.pinned-strip-toggle {
  width: 22px; height: 22px; border-radius: var(--r1);
  border: 1px solid var(--b1); background: transparent; color: var(--t3);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background var(--e-fast);
}
.pinned-strip-toggle:hover { background: var(--bg3); color: var(--t2); }
.pinned-strip-toggle svg { transition: transform var(--e-std); }
.pinned-strip.expanded .pinned-strip-toggle svg { transform: rotate(180deg); }
.pinned-strip-expanded {
  display: none; flex-direction: column;
  border-top: 1px solid var(--b1); max-height: 180px; overflow-y: auto;
}
.pinned-strip.expanded .pinned-strip-expanded { display: flex; }
.pinned-exp-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 7px 14px; border-bottom: 1px solid var(--b1);
  cursor: pointer; transition: background var(--e-fast);
}
.pinned-exp-item:last-child { border-bottom: none; }
.pinned-exp-item:hover { background: var(--bg3); }
.pinned-exp-text {
  flex: 1; font-size: .75rem; color: var(--t1); line-height: 1.5; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.pinned-exp-time { font-size: .62rem; color: var(--t3); flex-shrink: 0; margin-top: 2px; }

/* ════════════════════════════════════════════════════════════════
   MESSAGES
════════════════════════════════════════════════════════════════ */
.msgs-wrap {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 16px 8px;
  display: flex; flex-direction: column; gap: 4px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
[data-theme="dark"]  .msgs-wrap { background: #14141a; }
[data-theme="light"] .msgs-wrap { background: #f6f5f4; }

/* Date separator */
.date-sep { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.date-sep::before, .date-sep::after { content: ''; flex: 1; height: 1px; background: var(--b1); }
.date-sep > span {
  font-size: .6rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: var(--t3); padding: 2px 9px; background: var(--bg3);
  border: 1px solid var(--b1); border-radius: 99px; white-space: nowrap;
}

/* Message rows */
.msg-row {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 100%; min-width: 0;
}
/* In RTL layout: "own" messages align to the START (right side in RTL = our side) */
/* Other messages align to the END (left side in RTL = others side) */
.msg-row.own { justify-content: flex-end; }
.msg-row:not(.own):not(.sys) { justify-content: flex-start; }
.msg-row.chain .msg-av { visibility: hidden; }

.msg-av {
  width: 22px; height: 22px; border-radius: var(--r2); flex-shrink: 0;
  background: linear-gradient(145deg, var(--acc-l), var(--pur));
  display: flex; align-items: center; justify-content: center;
  font-size: .52rem; font-weight: 900; color: #fff; margin-bottom: 2px;
}

/* ── Fluent 2 Chat Bubble ── */
.bubble {
  position: relative;
  max-width: min(72%, 520px);
  min-width: 60px;
  padding: 8px 12px;
  border-radius: var(--r5) var(--r5) var(--r5) var(--r1);
  background: var(--bg3); border: 1px solid var(--b1);
  box-shadow: var(--el-2); word-break: break-word;
  transition: background var(--e-fast);
  direction: rtl;
  text-align: right;
}
[data-theme="light"] .bubble { background: #ffffff; border-color: rgba(0,0,0,.08); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.msg-row.own .bubble {
  background: var(--acc); border-color: transparent; color: #fff;
  border-radius: var(--r5) var(--r5) var(--r1) var(--r5);
  box-shadow: 0 2px 10px var(--glow);
  direction: rtl; text-align: right;
}
[data-theme="light"] .msg-row.own .bubble { background: #0066cc; }
.msg-row.sys .bubble {
  background: var(--obg); border-color: rgba(252,176,64,.25);
  border-radius: var(--r5); max-width: 90%; text-align: center;
  font-size: .74rem; color: var(--org); font-weight: 600; margin: 0 auto;
}
.bubble.touched     { background: var(--bg5); }
.msg-row.own .bubble.touched { background: var(--acc-d); }

.bubble-txt  { font-size: .82rem; line-height: 1.65; white-space: pre-wrap; }
.bubble-time { font-size: .58rem; color: var(--t3); margin-top: 4px; text-align: left; opacity: .75; }
.msg-row.own .bubble-time { color: rgba(255,255,255,.6); text-align: right; }

/* ── Bubble action bar ── */
.bub-bar {
  display: none; position: absolute; bottom: calc(100% + 4px); right: 0;
  background: var(--gl3); border: 1px solid var(--b2); border-radius: var(--r4);
  box-shadow: var(--el-8); backdrop-filter: blur(40px);
  padding: 2px; flex-direction: row; gap: 1px; z-index: 30;
  animation: f2Pop .12s var(--e-spring);
}
.msg-row.own .bub-bar { right: auto; left: 0; }
@keyframes f2Pop { from { opacity: 0; transform: scale(.88) translateY(5px); } to { opacity: 1; transform: none; } }
.bubble:hover .bub-bar, .bubble.touched .bub-bar { display: flex; }

.bb {
  padding: 5px 9px; border-radius: var(--r2); border: none; background: transparent;
  color: var(--t2); font-size: .64rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 3px; white-space: nowrap; font-family: var(--font);
  transition: background var(--e-fast), color var(--e-fast);
}
.bb svg { width: 10px; height: 10px; }
.bb:hover     { background: var(--bg3); color: var(--t1); }
.bb.del:hover { background: var(--rbg); color: var(--red); }
.bb.edt:hover { background: var(--abg); color: var(--acc2); }
.bb.shr:hover { background: var(--gbg); color: var(--grn); }
.bb.tr:hover  { background: var(--pbg); color: var(--pur); }

/* ── File / media bubbles ── */
.file-bub {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: var(--r4); min-width: 160px; cursor: pointer;
  text-decoration: none;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  transition: background var(--e-fast);
}
.file-bub:hover { background: rgba(255,255,255,.12); }
.msg-row:not(.own) .file-bub { background: var(--bg4); border-color: var(--b1); }
.msg-row:not(.own) .file-bub:hover { background: var(--bg5); }
.file-ic { font-size: 1.3rem; flex-shrink: 0; }
.file-nm { font-size: .74rem; font-weight: 700; color: var(--t1); margin-bottom: 2px; word-break: break-all; }
.file-sz { font-size: .6rem; color: var(--t3); font-weight: 600; }
.msg-row.own .file-nm { color: #fff; }
.msg-row.own .file-sz { color: rgba(255,255,255,.5); }
.img-thumb {
  max-width: 230px; max-height: 180px; border-radius: var(--r4);
  border: 1px solid var(--b1); object-fit: cover; cursor: pointer; display: block;
  transition: opacity var(--e-fast);
}
.img-thumb:hover  { opacity: .9; }
.img-caption { font-size: .62rem; color: var(--t3); margin-top: 3px; font-weight: 600; }
.audio-bub  { min-width: 180px; }
.draw-bub img { max-width: 240px; border-radius: var(--r4); cursor: pointer; display: block; }

/* ── Edit in-place ── */
.edit-wrap { display: flex; flex-direction: column; gap: 5px; min-width: 180px; }
.edit-ta {
  padding: 7px 10px; background: var(--bg4); border: 1.5px solid var(--acc);
  border-radius: var(--r3); color: var(--t1); font-family: var(--font);
  font-size: .8rem; resize: none; outline: none;
  box-shadow: 0 0 0 1px var(--acc); min-height: 52px;
}
.edit-actions { display: flex; gap: 5px; justify-content: flex-end; }
.ea-btn {
  padding: 5px 11px; border-radius: var(--r2); border: 1px solid var(--b2);
  font-family: var(--font); font-size: .7rem; font-weight: 700; cursor: pointer;
  transition: all var(--e-fast);
}
.ea-save   { background: var(--acc); border-color: var(--acc); color: #fff; }
.ea-save:hover { background: var(--acc-l); }
.ea-cancel { background: var(--bg3); color: var(--t2); }
.ea-cancel:hover { background: var(--bg4); color: var(--t1); }

/* ── Code blocks ── */
.code-block-wrap { margin: 4px 0; border-radius: var(--r3); overflow: hidden; border: 1px solid var(--b2); }
.code-block-lang {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px; background: var(--bg4); border-bottom: 1px solid var(--b2);
  font-size: .62rem; font-weight: 700; color: var(--t3);
}
.code-block-copy {
  padding: 2px 7px; border-radius: var(--r1); border: 1px solid var(--b1);
  background: transparent; color: var(--t3); font-size: .58rem; cursor: pointer;
  font-family: var(--font); transition: all var(--e-fast);
}
.code-block-copy:hover { background: var(--bg3); color: var(--t1); }
.code-block-pre  { padding: 9px; background: var(--bg3); margin: 0; overflow-x: auto; }
.code-block-pre code { font-family: var(--mono); font-size: .75rem; color: var(--t1); white-space: pre; }
.inline-code {
  font-family: var(--mono); font-size: .8em; padding: 1px 5px;
  background: var(--bg4); border: 1px solid var(--b2); border-radius: var(--r1); color: var(--acc2);
}
.transcript-lbl { font-size: .62rem; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: .4px; margin-top: 7px; margin-bottom: 2px; }
.transcript-txt { font-size: .76rem; color: var(--t1); line-height: 1.55; padding: 5px 7px; background: var(--bg3); border-radius: var(--r2); }

/* ── TODO bubble ── */
.todo-bub-wrap { min-width: 210px; max-width: 330px; }
.todo-bubble   { display: flex; flex-direction: column; gap: 1px; }
.todo-header   { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.todo-title    { font-size: .78rem; font-weight: 800; color: var(--t1); }
.msg-row.own .todo-title { color: #fff; }
.todo-progress {
  font-size: .65rem; font-weight: 700; color: var(--acc2);
  background: var(--abg); padding: 1px 7px; border-radius: 99px;
}
.msg-row.own .todo-progress { color: rgba(255,255,255,.8); background: rgba(255,255,255,.15); }
.todo-item {
  display: flex; align-items: center; gap: 7px; padding: 4px 5px;
  border-top: 1px solid var(--b1); cursor: pointer;
  border-radius: var(--r2); transition: background var(--e-fast);
}
.todo-item:first-of-type { border-top: none; }
.todo-item:hover { background: rgba(255,255,255,.06); }
.msg-row.own .todo-item { border-top-color: rgba(255,255,255,.1); }
.msg-row.own .todo-item:hover { background: rgba(255,255,255,.08); }
.todo-item.done .todo-text { text-decoration: line-through; opacity: .45; }
.todo-check {
  width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0;
  border: 1.5px solid var(--b3); background: transparent;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--e-std); color: transparent; font-size: .6rem;
}
.todo-item.done .todo-check { background: var(--grn); border-color: var(--grn); color: #fff; }
.todo-text { font-size: .77rem; font-weight: 600; flex: 1; line-height: 1.4; }
.todo-item-actions { display: flex; gap: 1px; flex-shrink: 0; }
.todo-move-btn {
  width: 16px; height: 16px; border-radius: 3px; border: 1px solid var(--b1);
  background: transparent; color: var(--t3); cursor: pointer; font-size: .54rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--e-fast);
}
.todo-move-btn:hover:not(:disabled) { background: var(--bg3); color: var(--t1); }
.todo-move-btn:disabled { opacity: .2; cursor: not-allowed; }
.todo-bar { height: 2px; border-radius: 99px; background: var(--b1); margin-top: 7px; overflow: hidden; }
.todo-bar-fill { height: 100%; border-radius: 99px; background: var(--grn); transition: width .4s var(--e-enter); }
.todo-add {
  display: flex; align-items: center; gap: 5px; padding: 4px 5px; margin-top: 3px;
  border-radius: var(--r2); cursor: pointer; color: var(--t3); font-size: .7rem; font-weight: 600;
  transition: all var(--e-fast);
}
.todo-add:hover { background: rgba(255,255,255,.05); color: var(--t2); }
.msg-row.own .todo-add       { color: rgba(255,255,255,.45); }
.msg-row.own .todo-add:hover { background: rgba(255,255,255,.08); }
.todo-add-ic {
  width: 14px; height: 14px; border-radius: 3px; border: 1.5px dashed currentColor;
  display: flex; align-items: center; justify-content: center; font-size: .7rem;
}

/* Empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 40px; color: var(--t3); text-align: center; height: 100%;
}
.empty-icon { font-size: 2.4rem; opacity: .4; }
.empty h3   { font-size: .88rem; font-weight: 700; color: var(--t2); }
.empty p    { font-size: .74rem; }

/* ════════════════════════════════════════════════════════════════
   INPUT BAR — Fluent 2 TextField + CommandBar
════════════════════════════════════════════════════════════════ */
.input-bar {
  padding: 8px 12px 10px; flex-shrink: 0;
  border-top: 1px solid var(--b1);
  background: var(--gl); backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
  display: flex; flex-direction: column; gap: 6px;
}
[data-theme="dark"]  .input-bar { background: rgba(20,20,20,.84); }
[data-theme="light"] .input-bar { background: rgba(249,249,249,.92); }

.input-main-row { display: flex; align-items: flex-end; gap: 8px; }

.msg-ta {
  flex: 1; padding: 9px 13px; resize: none; min-height: 40px; max-height: 150px;
  background: var(--bg3); border: 1.5px solid var(--b2);
  border-radius: var(--r5); color: var(--t1); font-size: .82rem;
  font-weight: 400; line-height: 1.6; outline: none; overflow-y: auto;
  font-family: var(--font);
  transition: border-color var(--e-std), background var(--e-std), box-shadow var(--e-std);
}
.msg-ta:hover { border-color: var(--b3); }
.msg-ta:focus { border-color: var(--acc); background: var(--bg4); box-shadow: 0 0 0 1px var(--acc); }
.msg-ta::placeholder { color: var(--t3); }

/* Fluent 2 Accent Button */
.send-btn {
  width: 36px; height: 36px; border-radius: var(--r4); border: none; flex-shrink: 0;
  background: var(--acc); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--el-4);
  transition: background var(--e-fast), transform var(--e-fast), box-shadow var(--e-fast);
}
.send-btn:hover  { background: var(--acc-l); box-shadow: var(--el-8); }
.send-btn:active { background: var(--acc-d); transform: scale(.96); box-shadow: none; }

/* Input action toolbar */
.input-actions-row { display: flex; align-items: center; gap: 3px; }

/* ib = Fluent 2 Subtle Icon Button */
.ib {
  width: 28px; height: 28px; border-radius: var(--r3); flex-shrink: 0;
  border: none; background: transparent; color: var(--t3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  transition: background var(--e-fast), color var(--e-fast);
}
.ib:hover { background: var(--bg3); color: var(--t2); }
.voice-ib:hover { color: var(--red); background: var(--rbg); }

.stt-ib { overflow: hidden; }
.stt-rings {
  position: absolute; inset: 0; border-radius: var(--r3);
  pointer-events: none; opacity: 0;
}
.stt-ib.listening { background: var(--rbg); color: var(--red); animation: sttPulse 1.2s ease infinite; }
.stt-ib.listening .stt-rings { opacity: 1; }
@keyframes sttPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(241,112,122,.38); }
  50%      { box-shadow: 0 0 0 6px rgba(241,112,122,0); }
}

/* Legacy aliases */
.ia-btn { width: 28px; height: 28px; border-radius: var(--r3); flex-shrink: 0; border: none; background: transparent; color: var(--t3); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background var(--e-fast); }
.ia-btn:hover { background: var(--bg3); color: var(--t2); }
.ia-sep { width: 1px; height: 14px; background: var(--b1); margin: 0 2px; }
.inp-hint { margin-right: auto; font-size: .58rem; color: var(--t4); font-weight: 600; }

/* ════════════════════════════════════════════════════════════════
   FILES VIEW
════════════════════════════════════════════════════════════════ */
.fh {
  padding: 12px; display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; flex-shrink: 0; border-bottom: 1px solid var(--b1);
  background: var(--bg2);
}
.fh h3     { font-size: .96rem; font-weight: 800; }
.files-cnt { font-size: .7rem; color: var(--t3); font-weight: 600; }
.sort-row  { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.sort-lbl  { font-size: .68rem; color: var(--t3); font-weight: 700; white-space: nowrap; }
.sort-btn {
  padding: 3px 10px; border-radius: 99px; border: 1px solid var(--b2);
  background: transparent; color: var(--t2); font-size: .68rem; font-weight: 600;
  cursor: pointer; font-family: var(--font); transition: all var(--e-fast);
}
.sort-btn.on    { background: var(--abg); border-color: var(--acc); color: var(--acc2); }
.sort-btn:hover { background: var(--bg3); color: var(--t1); }

.files-grid {
  flex: 1; overflow-y: auto; overflow-x: visible;
  padding: 12px; display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px; align-content: start;
  -webkit-overflow-scrolling: touch;
}
@media (max-width:1100px) { .files-grid { grid-template-columns: repeat(4,1fr); } }
@media (max-width:768px)  { .files-grid { grid-template-columns: repeat(3,1fr); gap: 6px; } }
@media (max-width:480px)  { .files-grid { grid-template-columns: repeat(2,1fr); gap: 5px; } }

/* Fluent 2 Card */
.fc {
  background: var(--bg3); border: 1px solid var(--b1); border-radius: var(--r5);
  padding: 10px 8px 8px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  cursor: pointer; aspect-ratio: 1/1.1;
  position: relative; z-index: 1; overflow: visible;
  transition: background var(--e-fast), border-color var(--e-fast),
              box-shadow var(--e-fast), transform var(--e-fast);
}
.fc:hover { background: var(--bg4); border-color: var(--b2); box-shadow: var(--el-4); transform: translateY(-2px); z-index: 50; }
.fc-ic {
  width: 44px; height: 44px; border-radius: var(--r4);
  background: var(--bg4); border: 1px solid var(--b1);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-bottom: 6px; flex-shrink: 0;
}
.fc-img { width: 44px; height: 44px; border-radius: var(--r4); object-fit: cover; margin-bottom: 6px; border: 1px solid var(--b1); flex-shrink: 0; }
.fc-nm  { font-size: .64rem; font-weight: 700; color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; margin-bottom: 2px; }
.fc-sz  { font-size: .6rem; color: var(--t3); font-weight: 600; }

/* File action overlay */
.fc-acts {
  display: none; position: absolute; inset: 0;
  border-radius: var(--r5); z-index: 200;
  background: rgba(14,14,14,.90); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 8px; pointer-events: none;
}
.fc:hover .fc-acts, .fc:focus-within .fc-acts, .fc.touched .fc-acts { display: flex; pointer-events: all; }
[data-theme="light"] .fc-acts { background: rgba(240,240,240,.94); }
.fca-btn {
  width: 90%; height: 28px; border-radius: var(--r2); border: none;
  font-size: .68rem; font-weight: 700; cursor: pointer; font-family: var(--font);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: filter var(--e-fast);
}
.fca-btn:hover { filter: brightness(1.1); }
.fca-open { background: var(--acc); color: #fff; }
.fca-draw { background: var(--pur); color: #fff; }
.fca-del  { background: var(--red); color: #fff; }

/* List view */
.files-grid.list-view { grid-template-columns: 1fr; gap: 3px; }
.files-grid.list-view .fc { flex-direction: row; aspect-ratio: unset; padding: 9px 12px; align-items: center; text-align: right; gap: 10px; }
.files-grid.list-view .fc-ic, .files-grid.list-view .fc-img { width: 34px; height: 34px; margin-bottom: 0; flex-shrink: 0; }
.files-grid.list-view .fc-nm  { text-align: right; white-space: nowrap; flex: 1; }
.files-grid.list-view .fc-sz  { flex-shrink: 0; margin: 0; }
.files-grid.list-view .fc-acts { flex-direction: row; padding: 0 8px; gap: 4px; }
.files-grid.list-view .fca-btn { width: auto; padding: 0 10px; height: 24px; }

/* ════════════════════════════════════════════════════════════════
   UPLOAD BAR / DROP OVERLAY
════════════════════════════════════════════════════════════════ */
.upbar {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  min-width: 240px; max-width: 320px;
  background: var(--gl2); border: 1px solid var(--b2); border-radius: var(--r5);
  padding: 12px 16px; box-shadow: var(--el-28); backdrop-filter: blur(40px);
  z-index: 500; display: none;
}
.upbar.on { display: block; animation: f2SlideIn .18s var(--e-enter); }
.upbar-track { height: 3px; background: var(--b1); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.upbar-fill  { height: 100%; border-radius: 99px; background: var(--acc); transition: width .12s; width: 0%; }

.drop-ov {
  position: fixed; inset: 0; z-index: 800; background: rgba(0,0,0,.72);
  backdrop-filter: blur(20px); display: none; align-items: center; justify-content: center;
}
.drop-ov.on { display: flex; animation: f2FadeIn .15s ease; }
@keyframes f2FadeIn { from { opacity: 0; } to { opacity: 1; } }
.drop-card {
  background: var(--gl2); border: 2px dashed var(--acc); border-radius: var(--r8);
  padding: 32px 40px; text-align: center; box-shadow: var(--el-64);
  animation: f2ScaleIn .24s var(--e-spring);
}
@keyframes f2ScaleIn { from { opacity: 0; transform: scale(.90); } to { opacity: 1; transform: none; } }
.drop-card h2 { font-size: 1rem; font-weight: 800; margin-top: 12px; }
.drop-card p  { font-size: .75rem; color: var(--t3); margin-top: 4px; }

/* ════════════════════════════════════════════════════════════════
   ADMIN VIEW
════════════════════════════════════════════════════════════════ */
.adm-hd {
  padding: 14px 16px; border-bottom: 1px solid var(--b2); flex-shrink: 0;
  background: var(--bg2);
}
.adm-hd-inner { display: flex; align-items: center; gap: 12px; }
.adm-hd-icon  {
  width: 36px; height: 36px; border-radius: var(--r5);
  background: linear-gradient(145deg, var(--acc-l), var(--acc-d));
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; box-shadow: var(--el-4); flex-shrink: 0;
}
.adm-hd-inner h2 { font-size: .96rem; font-weight: 900; }
.adm-hd-inner p  { font-size: .72rem; color: var(--t3); margin-top: 2px; }
.adm-body {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin; background: var(--bg);
  width: 100%; min-width: 0; box-sizing: border-box;
}

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width:900px)  { .stats-row { grid-template-columns: repeat(2,1fr); } }
@media (max-width:480px)  { .stats-row { grid-template-columns: 1fr 1fr; } }
.sc {
  background: var(--bg2); border: 1px solid var(--b2);
  border-radius: var(--r5); padding: 16px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  box-shadow: var(--el-4); transition: all var(--e-fast);
  min-width: 0; overflow: hidden;
}
.sc:hover { background: var(--bg3); box-shadow: var(--el-8); transform: translateY(-1px); }
.si { font-size: 1.4rem; margin-bottom: 8px; }
.sv { font-size: 1.6rem; font-weight: 900; color: var(--t1); letter-spacing: -.5px; }
.sl { font-size: .67rem; color: var(--t2); font-weight: 700; margin-top: 4px; }

/* Fluent 2 Card */
.adm-card {
  background: var(--bg2); border: 1px solid var(--b2);
  border-radius: var(--r5); overflow: hidden;
  box-shadow: var(--el-4);
}
.adm-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--b1);
  background: var(--bg3);
}
.adm-card-title { display: flex; align-items: center; gap: 8px; font-size: .86rem; font-weight: 800; }
.adm-card-icon  { width: 26px; height: 26px; border-radius: var(--r2); display: flex; align-items: center; justify-content: center; font-size: .86rem; }
.adm-card-body  { padding: 16px; }
.adm-ctrl-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width:600px) { .adm-ctrl-grid { grid-template-columns: 1fr; } }
.adm-ctrl       { display: flex; flex-direction: column; gap: 3px; }
.adm-ctrl-label { font-size: .7rem; font-weight: 700; color: var(--t2); }
.adm-ctrl-val   { font-size: 1.1rem; font-weight: 900; color: var(--acc2); }
.adm-ctrl-sub   { font-size: .63rem; color: var(--t3); }
.adm-range { width: 100%; accent-color: var(--acc); cursor: pointer; }

/* Fluent 2 Pivot / Tab */
.adm-tabs { display: flex; border-bottom: 1px solid var(--b1); }
.adm-tab {
  flex: 1; padding: 9px 16px; border: none; background: transparent;
  color: var(--t3); font-size: .76rem; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all var(--e-fast); font-family: var(--font);
}
.adm-tab:hover  { color: var(--t2); }
.adm-tab.active { color: var(--acc2); border-bottom-color: var(--acc); font-weight: 700; }
.adm-tab-body   { padding: 12px; }
.sec-l { font-size: .62rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--t3); margin-bottom: 8px; }

/* Data table */
.utbl-wrap { overflow-x: auto; }
.ut { width: 100%; border-collapse: collapse; font-size: .74rem; }
.ut th {
  padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--b2);
  font-size: .6rem; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--t3);
}
.ut td { padding: 9px 8px; border-bottom: 1px solid var(--b1); color: var(--t2); vertical-align: middle; }
.ut tr:last-child td { border-bottom: none; }
.ut tr:hover td { background: var(--bg4); }
.acts { display: flex; gap: 4px; flex-wrap: wrap; }

/* Small buttons */
.bsm {
  padding: 3px 9px; border-radius: var(--r2); border: 1px solid var(--b1);
  background: var(--bg4); color: var(--t2); font-size: .66rem; font-weight: 700;
  cursor: pointer; transition: all var(--e-fast); font-family: var(--font); white-space: nowrap;
}
.bsm:hover { border-color: var(--b2); color: var(--t1); background: var(--bg5); }
.bsm.o     { color: var(--org); }
.bsm.o:hover { background: var(--obg); }
.bsm.d     { color: var(--red); }
.bsm.d:hover { background: var(--rbg); }

/* Badges */
.badge { padding: 2px 7px; border-radius: 99px; font-size: .62rem; font-weight: 700; }
.ba   { background: var(--abg); color: var(--acc2); }
.bu   { background: var(--bg4); color: var(--t3); }
.bon  { background: var(--gbg); color: var(--grn); }
.boff { background: var(--rbg); color: var(--red); }

/* Broadcast */
.bc-opts { display: flex; gap: 5px; margin-bottom: 8px; }
.bc-opt {
  flex: 1; padding: 7px; border-radius: var(--r2); border: 1px solid var(--b2);
  background: transparent; color: var(--t2); font-size: .74rem; font-weight: 600;
  cursor: pointer; transition: all var(--e-fast); font-family: var(--font);
}
.bc-opt.on { background: var(--abg); border-color: var(--acc); color: var(--acc2); }
.bc-ta {
  width: 100%; padding: 8px 12px; background: var(--bg4);
  border: 1.5px solid var(--b2); border-radius: var(--r3);
  color: var(--t1); font-family: var(--font); font-size: .8rem; resize: none; outline: none;
  transition: border-color var(--e-std), box-shadow var(--e-std);
}
.bc-ta:focus { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc); }
.bc-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.bc-count  { font-size: .66rem; color: var(--t3); font-weight: 600; }
.bc-btn {
  padding: 6px 16px; border-radius: var(--r3); border: none;
  background: var(--acc); color: #fff; font-size: .76rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: background var(--e-fast);
}
.bc-btn:hover { background: var(--acc-l); }

/* ════════════════════════════════════════════════════════════════
   BOTTOM NAV — Mobile only
════════════════════════════════════════════════════════════════ */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--gl2); border-top: 1px solid var(--b1);
  backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
  padding: 4px 0 max(env(safe-area-inset-bottom), 6px);
  flex-direction: row; justify-content: stretch; align-items: stretch;
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 5px 4px; border: none; background: transparent;
  color: var(--t3); font-size: .58rem; font-weight: 700; cursor: pointer;
  font-family: var(--font); transition: color var(--e-fast); position: relative;
}
.bn-item svg { flex-shrink: 0; }
.bn-item.active { color: var(--acc2); }
.bn-dot {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 0 0 2px 2px;
  background: transparent; transition: background var(--e-std);
}
.bn-item.active .bn-dot { background: var(--acc); }
@media (min-width:769px) { .bottom-nav { display: none !important; } }
@media (max-width:768px) { .bottom-nav { display: flex; } }

/* ════════════════════════════════════════════════════════════════
   SETTINGS PANEL — Fluent 2 Side Panel
════════════════════════════════════════════════════════════════ */
.settings-modal {
  position: fixed; inset: 0; z-index: 700;
  background: rgba(0,0,0,.52); backdrop-filter: blur(12px);
  display: none; align-items: stretch; justify-content: flex-start;
}
.settings-modal.on { display: flex; }

.settings-box {
  background: var(--bg2);
  border-left: 1px solid var(--b1);
  width: min(400px, 100vw); height: 100vh; max-height: 100vh;
  display: flex; flex-direction: column;
  box-shadow: var(--el-64); overflow: hidden;
  transform: translateX(-100%);
  transition: transform var(--e-enter);
}
[data-theme="dark"]  .settings-box { background: #1c1c1c; }
[data-theme="light"] .settings-box { background: #f9f9f9; }
.settings-modal.on .settings-box { transform: translateX(0); }
@media (max-width:420px) { .settings-box { width: 100vw; border-left: none; } }

.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: var(--top-h); flex-shrink: 0;
  background: var(--gl2); border-bottom: 1px solid var(--b1);
}
.settings-head-left { display: flex; align-items: center; gap: 8px; }
.settings-head-icon {
  width: 26px; height: 26px; border-radius: var(--r3);
  background: linear-gradient(145deg, var(--acc-l), var(--acc-d));
  display: flex; align-items: center; justify-content: center;
  font-size: .84rem; box-shadow: var(--el-4);
}
.settings-head h3 { font-size: .88rem; font-weight: 900; }

.settings-close-btn {
  width: 28px; height: 28px; border-radius: var(--r2); border: none;
  background: transparent; color: var(--t3); font-size: .78rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--e-fast), color var(--e-fast);
}
.settings-close-btn:hover { background: var(--rbg); color: var(--red); }

/* Profile card */
.set-profile-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--b1);
  flex-shrink: 0; background: var(--bg3);
}
.set-profile-avatar {
  width: 42px; height: 42px; border-radius: var(--r5); flex-shrink: 0;
  background: linear-gradient(145deg, var(--acc-l), var(--pur));
  display: flex; align-items: center; justify-content: center;
  font-size: .88rem; font-weight: 900; color: #fff; box-shadow: var(--el-4);
}
.set-profile-info   { flex: 1; min-width: 0; }
.set-profile-name   { font-size: .86rem; font-weight: 800; color: var(--t1); }
.set-profile-role   { font-size: .66rem; color: var(--acc2); font-weight: 600; margin-top: 2px; }
.set-profile-logout {
  width: 30px; height: 30px; border-radius: var(--r3); border: none;
  background: transparent; color: var(--t3); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast), color var(--e-fast);
}
.set-profile-logout:hover { background: var(--rbg); color: var(--red); }

/* Settings Tabs — Fluent 2 Pivot */
.settings-tabs-row {
  display: flex; background: var(--bg3);
  border-bottom: 1px solid var(--b1); flex-shrink: 0;
}
.set-tab {
  flex: 1; min-width: 60px; padding: 10px 6px 9px;
  border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: transparent; color: var(--t3); font-size: .7rem; font-weight: 600;
  cursor: pointer; font-family: var(--font);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: color var(--e-fast), border-color var(--e-fast), background var(--e-fast);
}
.set-tab svg { opacity: .5; transition: opacity var(--e-fast); flex-shrink: 0; }
.set-tab:hover  { color: var(--t2); background: var(--bg4); }
.set-tab.active { color: var(--acc2); border-bottom-color: var(--acc); font-weight: 700; }
.set-tab.active svg { opacity: 1; }

/* Settings body */
.settings-body { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--b1) transparent; }
.set-panel             { display: none; flex-direction: column; gap: 0; padding: 0 0 16px; }
.set-panel.active      { display: flex; }

/* Settings group — Fluent 2 grouped settings list */
.set-group {
  margin: 12px 12px 0; border: 1px solid var(--b1);
  border-radius: var(--r5); background: var(--bg3); overflow: hidden;
}
.set-group:last-child { margin-bottom: 12px; }
.set-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--b1); background: var(--bg4);
}
.set-group-icon  { width: 28px; height: 28px; border-radius: var(--r2); display: flex; align-items: center; justify-content: center; font-size: .86rem; flex-shrink: 0; }
.set-group-title { font-size: .78rem; font-weight: 800; color: var(--t1); }
.set-group-sub   { font-size: .64rem; color: var(--t3); margin-top: 2px; line-height: 1.4; }

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 12px; gap: 12px; min-height: 48px;
  border-top: 1px solid var(--b1); transition: background var(--e-fast);
}
.setting-row:first-of-type { border-top: none; }
.setting-row:hover { background: var(--bg4); }
.setting-row.danger { background: rgba(241,112,122,.05); }
.setting-row.danger:hover { background: rgba(241,112,122,.10); }
[data-theme="light"] .setting-row.danger { background: rgba(196,43,28,.05); }
.setting-label-wrap { flex: 1; min-width: 0; }
.setting-label { font-size: .78rem; font-weight: 700; color: var(--t1); }
.setting-desc  { font-size: .66rem; color: var(--t2); margin-top: 2px; line-height: 1.4; }

/* Fluent 2 Toggle */
.tog {
  width: 40px; height: 22px; border-radius: 11px; flex-shrink: 0;
  border: 1.5px solid var(--b2); background: var(--bg5);
  cursor: pointer; position: relative;
  transition: background var(--e-std), border-color var(--e-std);
}
.tog.on { background: var(--acc); border-color: var(--acc); }
.tog::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: var(--el-2); transition: transform var(--e-spring);
}
.tog.on::after { transform: translateX(-18px); }

/* ════════════════════════════════════════════════════════════════
   MODALS — Fluent 2 Dialog
════════════════════════════════════════════════════════════════ */
.modal-bg {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,.52); backdrop-filter: blur(10px);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-bg.on { display: flex; animation: f2FadeIn .15s ease; }

/* Shared dialog buttons */
.btn-ok {
  padding: 9px 20px; border-radius: var(--r3); border: none;
  background: var(--acc); color: #fff; font-size: .82rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); box-shadow: var(--el-4);
  transition: background var(--e-fast), box-shadow var(--e-fast);
}
.btn-ok:hover  { background: var(--acc-l); box-shadow: var(--el-8); }
.btn-ok:active { background: var(--acc-d); }
.btn-can {
  padding: 9px 20px; border-radius: var(--r3);
  border: 1px solid var(--b2); background: transparent;
  color: var(--t2); font-size: .82rem; font-weight: 600; cursor: pointer;
  font-family: var(--font); transition: background var(--e-fast), color var(--e-fast);
}
.btn-can:hover { background: var(--bg3); color: var(--t1); }

/* Voice modal */
.voice-box {
  background: var(--bg2); border: 1px solid var(--b2); border-radius: var(--r8);
  padding: 24px 20px; text-align: center; width: min(320px, 96%);
  box-shadow: var(--el-64); animation: f2ScaleIn .2s var(--e-spring);
}
.v-title  { font-size: 1.05rem; font-weight: 900; margin-bottom: 4px; }
.v-sub    { font-size: .74rem; color: var(--t3); margin-bottom: 20px; }
.rec-btn {
  width: 70px; height: 70px; border-radius: 50%; border: none;
  background: linear-gradient(145deg, var(--acc-l), var(--acc-d));
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  margin: 0 auto 12px; box-shadow: 0 8px 24px var(--glow);
  font-size: 1.5rem; transition: all var(--e-std);
}
.rec-btn.on {
  background: linear-gradient(145deg, #f87171, var(--red));
  box-shadow: 0 8px 24px rgba(241,112,122,.45);
  animation: recPulse 1s ease infinite;
}
@keyframes recPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.rec-timer  { font-size: 1.4rem; font-weight: 900; font-family: var(--mono); margin-bottom: 4px; color: var(--acc2); }
.rec-status { font-size: .74rem; color: var(--t3); margin-bottom: 16px; }
.v-acts { display: flex; gap: 8px; justify-content: center; }

/* Drawing modal */
.draw-modal {
  position: fixed; inset: 0; z-index: 600; display: none;
  background: rgba(0,0,0,.74); backdrop-filter: blur(18px);
  align-items: center; justify-content: center;
}
.draw-modal.on { display: flex; }
.draw-box {
  background: var(--bg2); border: 1px solid var(--b2); border-radius: var(--r6);
  width: min(760px, 98vw); max-height: 96vh; display: flex; flex-direction: column;
  box-shadow: var(--el-64); overflow: hidden;
}
.dtb {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  border-bottom: 1px solid var(--b1); background: var(--bg3);
  overflow-x: auto; flex-wrap: nowrap; flex-shrink: 0; scrollbar-width: none;
}
.dtb::-webkit-scrollbar { display: none; }
.dtb-title { font-size: .8rem; font-weight: 800; white-space: nowrap; flex-shrink: 0; }
.tg { display: flex; gap: 3px; flex-shrink: 0; }
.tb {
  padding: 4px 8px; border-radius: var(--r2); border: 1px solid var(--b1);
  background: transparent; color: var(--t2); font-size: .68rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; font-family: var(--font);
  transition: all var(--e-fast);
}
.tb.on  { background: var(--acc); border-color: var(--acc); color: #fff; }
.tb.dng { color: var(--red); }
.tb.dng:hover { background: var(--rbg); border-color: var(--rbg); }
.tb:hover:not(.on):not(.dng) { background: var(--bg3); color: var(--t1); }
.csw {
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; flex-shrink: 0;
  transition: transform var(--e-fast), border-color var(--e-fast);
}
.csw.on { border-color: var(--acc); transform: scale(1.25); }
.cpick  { width: 22px; height: 22px; border-radius: 50%; border: none; cursor: pointer; padding: 0; flex-shrink: 0; }
.sz     { width: 68px; accent-color: var(--acc); cursor: pointer; }
.fnt-sz { width: 44px; padding: 3px 5px; border-radius: var(--r1); border: 1px solid var(--b2); background: var(--bg3); color: var(--t1); font-size: .68rem; text-align: center; outline: none; }
.canvas-wrap { flex: 1; overflow: auto; background: #fff; display: flex; align-items: center; justify-content: center; }
.canvas-wrap canvas { display: block; touch-action: none; cursor: crosshair; }
.dbb {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-top: 1px solid var(--b1);
  background: var(--bg3); flex-shrink: 0; gap: 8px;
}
.dbb-hint { font-size: .68rem; color: var(--t3); font-weight: 600; flex: 1; text-align: center; }

/* Custom dialog */
.dlg-bg {
  position: fixed; inset: 0; z-index: 900; display: none;
  background: rgba(0,0,0,.56); backdrop-filter: blur(12px);
  align-items: center; justify-content: center; padding: 16px;
}
.dlg-bg.on { display: flex; }
.dlg-box {
  background: var(--bg2); border: 1px solid var(--b2); border-radius: var(--r6);
  padding: 20px; text-align: center; width: min(312px, 96%);
  box-shadow: var(--el-64); animation: f2ScaleIn .16s var(--e-spring);
}
.dlg-icon  { font-size: 1.8rem; margin-bottom: 8px; }
.dlg-title { font-size: .92rem; font-weight: 900; margin-bottom: 4px; }
.dlg-msg   { font-size: .76rem; color: var(--t2); margin-bottom: 16px; line-height: 1.55; }
.dlg-acts  { display: flex; gap: 8px; justify-content: center; }
.dlg-btn {
  flex: 1; padding: 8px 12px; border-radius: var(--r3);
  border: 1px solid var(--b2); background: var(--bg3);
  color: var(--t2); font-size: .78rem; font-weight: 700; cursor: pointer;
  font-family: var(--font); transition: all var(--e-fast);
}
.dlg-ok { background: var(--acc); border-color: var(--acc); color: #fff; }
.dlg-ok.danger { background: var(--red); border-color: var(--red); }
.dlg-can:hover { background: var(--bg4); color: var(--t1); }
.dlg-btn:not(.dlg-can):hover { filter: brightness(1.1); }

/* Lightbox */
.lb {
  position: fixed; inset: 0; z-index: 800; display: none;
  background: rgba(0,0,0,.94); backdrop-filter: blur(24px);
  flex-direction: column; align-items: center; justify-content: center;
}
.lb.on { display: flex; animation: f2FadeIn .15s ease; }
.lb-topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 46px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: rgba(14,14,14,.65); backdrop-filter: blur(16px);
}
.lb-title { font-size: .78rem; font-weight: 700; color: var(--t2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-close {
  width: 28px; height: 28px; border-radius: var(--r2); border: none;
  background: transparent; color: var(--t3); cursor: pointer; font-size: .78rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast), color var(--e-fast);
}
.lb-close:hover { background: var(--rbg); color: var(--red); }
.lb-inner { max-width: 92vw; max-height: 76vh; display: flex; align-items: center; justify-content: center; }
.lb-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; height: 50px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(14,14,14,.65); backdrop-filter: blur(16px);
  padding: 0 16px; flex-wrap: wrap;
}
.lb-dl {
  padding: 6px 13px; border-radius: var(--r3); background: var(--bg3);
  border: 1px solid var(--b2); color: var(--t2); font-size: .76rem; font-weight: 700;
  text-decoration: none; transition: all var(--e-fast);
}
.lb-dl:hover { color: var(--t1); background: var(--bg4); }
.lb-audio-player { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; }
.lb-audio-icon  { font-size: 2.8rem; }
.lb-audio-title { font-size: .88rem; font-weight: 700; color: var(--t1); text-align: center; }
.lb-audio-player audio { width: 270px; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(6px);
  background: var(--gl3); border: 1px solid var(--b2); border-radius: var(--r5);
  padding: 8px 16px; font-size: .76rem; font-weight: 700;
  box-shadow: var(--el-28); backdrop-filter: blur(40px); z-index: 999;
  display: flex; align-items: center; gap: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--e-std), transform var(--e-std);
}
.toast.on { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(241,112,122,.35); color: var(--red); }
.t-ic { font-size: .88rem; }

/* Share popup */
.share-bg { position: fixed; inset: 0; z-index: 700; display: none; background: rgba(0,0,0,.42); backdrop-filter: blur(8px); }
.share-bg.on { display: block; }
.share-popup {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 710;
  background: var(--bg2); border: 1px solid var(--b2); border-radius: var(--r6);
  padding: 20px; width: min(356px, 96%); box-shadow: var(--el-64);
  text-align: center; display: none;
}
.share-popup.on { display: block; animation: f2ScaleIn .16s var(--e-spring); }
.share-url {
  display: flex; gap: 8px; align-items: center;
  background: var(--bg3); border: 1px solid var(--b1); border-radius: var(--r3);
  padding: 8px 12px; margin: 12px 0;
}
.share-url span { flex: 1; font-size: .73rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); color: var(--t2); }
.sp-copy {
  padding: 4px 11px; border-radius: var(--r2); border: none;
  background: var(--acc); color: #fff; font-size: .7rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: background var(--e-fast); flex-shrink: 0;
}
.sp-copy:hover { background: var(--acc-l); }
.sp-close {
  padding: 7px 18px; border-radius: var(--r3); border: 1px solid var(--b2);
  background: transparent; color: var(--t2); font-size: .76rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: all var(--e-fast);
}
.sp-close:hover { background: var(--bg3); color: var(--t1); }

/* Tags / Folders / Encryption Modals */
.tags-modal, .folder-modal, .enc-modal {
  position: fixed; inset: 0; z-index: 700; display: none;
  background: rgba(0,0,0,.52); backdrop-filter: blur(10px);
  align-items: center; justify-content: center; padding: 16px;
}
.tags-modal.on, .folder-modal.on, .enc-modal.on { display: flex; }
.tags-box, .folder-box, .enc-box {
  background: var(--bg2); border: 1px solid var(--b2); border-radius: var(--r6);
  width: min(376px, 96%); max-height: 88vh; overflow: hidden;
  box-shadow: var(--el-64); animation: f2ScaleIn .16s var(--e-spring);
  display: flex; flex-direction: column;
}
.tags-head, .folder-box-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--b1);
  background: var(--bg3); flex-shrink: 0;
}
.tags-head h3 { font-size: .9rem; font-weight: 900; }
.tags-body, .folder-box-body {
  flex: 1; padding: 12px 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.tag-colors-row  { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-color-swatch {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform var(--e-fast), border-color var(--e-fast);
}
.tag-color-swatch.sel { border-color: var(--t1); transform: scale(1.25); }
.tag-create-row { display: flex; gap: 8px; align-items: center; }
.tag-inp {
  flex: 1; padding: 8px 11px; background: var(--bg3); border: 1.5px solid var(--b2);
  border-radius: var(--r3); color: var(--t1); font-family: var(--font); font-size: .8rem; outline: none;
  transition: border-color var(--e-std), box-shadow var(--e-std);
}
.tag-inp:focus { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc); }
.tag-add-btn {
  padding: 8px 13px; border-radius: var(--r3); border: none;
  background: var(--acc); color: #fff; font-size: .74rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: background var(--e-fast); white-space: nowrap;
}
.tag-add-btn:hover { background: var(--acc-l); }
.tag-list { display: flex; flex-direction: column; gap: 4px; }
.tag-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px;
  border-radius: var(--r3); background: var(--bg3); border: 1px solid var(--b1);
  transition: background var(--e-fast);
}
.tag-item:hover { background: var(--bg4); }
.tag-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tag-nm  { flex: 1; font-size: .76rem; font-weight: 700; }
.tag-del {
  padding: 2px 7px; border-radius: var(--r1); border: none;
  background: var(--rbg); color: var(--red); font-size: .62rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: all var(--e-fast);
}
.tag-del:hover { background: var(--red); color: #fff; }

/* Encryption */
.enc-box { align-items: center; gap: 12px; padding: 24px 20px; text-align: center; max-width: 290px; }
.enc-icon  { font-size: 2rem; }
.enc-title { font-size: .94rem; font-weight: 900; }
.enc-sub   { font-size: .74rem; color: var(--t3); }
.enc-inp {
  width: 100%; padding: 9px 12px; background: var(--bg3); border: 1.5px solid var(--b2);
  border-radius: var(--r3); color: var(--t1); font-family: var(--font); font-size: .86rem;
  outline: none; text-align: center;
  transition: border-color var(--e-std), box-shadow var(--e-std);
}
.enc-inp:focus { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc); }
.enc-acts   { display: flex; gap: 8px; justify-content: center; }
.enc-cancel {
  padding: 8px 18px; border-radius: var(--r3);
  border: 1px solid var(--b2); background: transparent; color: var(--t2);
  font-size: .78rem; font-weight: 700; cursor: pointer; font-family: var(--font);
  transition: all var(--e-fast);
}
.enc-cancel:hover { background: var(--bg3); }
.enc-ok {
  padding: 8px 18px; border-radius: var(--r3); border: none;
  background: var(--acc); color: #fff; font-size: .78rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); box-shadow: var(--el-4);
  transition: background var(--e-fast);
}
.enc-ok:hover { background: var(--acc-l); }

/* Admin user viewer */
.uv-modal {
  position: fixed; inset: 0; z-index: 750; display: none;
  background: rgba(0,0,0,.56); backdrop-filter: blur(12px);
  align-items: center; justify-content: center; padding: 12px;
}
.uv-modal.on { display: flex; }
.uv-box {
  background: var(--bg2); border: 1px solid var(--b2); border-radius: var(--r6);
  width: min(700px, 98%); max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: var(--el-64); overflow: hidden; animation: f2ScaleIn .18s var(--e-spring);
}
.uv-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--b1);
  background: var(--bg3); flex-shrink: 0;
}
.uv-avatar {
  width: 40px; height: 40px; border-radius: var(--r5); flex-shrink: 0;
  background: linear-gradient(145deg, var(--acc-l), var(--pur));
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 900; color: #fff;
}
.uv-info   { flex: 1; }
.uv-name   { font-size: .9rem; font-weight: 800; }
.uv-meta   { font-size: .68rem; color: var(--t3); margin-top: 2px; }
.uv-close  {
  width: 28px; height: 28px; border-radius: var(--r2); border: none;
  background: transparent; color: var(--t3); margin-right: auto;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background var(--e-fast), color var(--e-fast); font-size: .78rem;
}
.uv-close:hover { background: var(--rbg); color: var(--red); }
.uv-tabs { display: flex; border-bottom: 1px solid var(--b1); flex-shrink: 0; }
.uv-tab {
  flex: 1; padding: 9px; border: none; background: transparent;
  color: var(--t3); font-size: .76rem; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all var(--e-fast); font-family: var(--font);
}
.uv-tab.active { color: var(--acc2); border-bottom-color: var(--acc); font-weight: 700; }
.uv-body { flex: 1; overflow-y: auto; padding: 12px; scrollbar-width: thin; }
.uv-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px; color: var(--t3); text-align: center; }
.uv-empty .icon { font-size: 1.8rem; }
.uv-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.uv-stat { background: var(--bg3); border: 1px solid var(--b1); border-radius: var(--r3); padding: 4px 12px; font-size: .68rem; font-weight: 600; color: var(--t2); }
.uv-stat span { font-weight: 800; color: var(--acc2); }
.uv-search-wrap { position: relative; margin-bottom: 8px; }
.uv-search-ic { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--t3); pointer-events: none; }
.uv-search {
  width: 100%; padding: 7px 30px 7px 11px; background: var(--bg3);
  border: 1.5px solid var(--b2); border-radius: var(--r3);
  color: var(--t1); font-family: var(--font); font-size: .76rem; outline: none;
  transition: border-color var(--e-std);
}
.uv-search:focus { border-color: var(--acc); }
.uv-msg-list { display: flex; flex-direction: column; gap: 4px; }
.uv-msg { background: var(--bg3); border: 1px solid var(--b1); border-radius: var(--r3); padding: 8px 12px; }
.uv-msg.sys { border-color: var(--obg); background: var(--obg); }
.uv-msg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.uv-type-badge { padding: 2px 7px; border-radius: 99px; font-size: .6rem; font-weight: 700; }
.uvt-text    { background: var(--abg); color: var(--acc2); }
.uvt-audio   { background: var(--gbg); color: var(--grn); }
.uvt-file    { background: var(--pbg); color: var(--pur); }
.uvt-drawing { background: var(--obg); color: var(--org); }
.uvt-sys     { background: var(--obg); color: var(--org); }
.uv-time { font-size: .63rem; color: var(--t3); font-weight: 600; }
.uv-msg-text { font-size: .76rem; color: var(--t1); line-height: 1.55; white-space: pre-wrap; }
.uv-msg-audio audio { width: 100%; margin-top: 4px; }
.uv-msg-img { max-width: 180px; border-radius: var(--r3); border: 1px solid var(--b1); cursor: pointer; }
.uv-file-row { display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: var(--r2); text-decoration: none; color: var(--t1); transition: background var(--e-fast); }
.uv-file-row:hover { background: var(--bg4); }
.uv-file-ic { font-size: 1rem; flex-shrink: 0; }
.uv-file-nm { font-size: .73rem; font-weight: 700; }
.uv-file-sz { font-size: .6rem; color: var(--t3); }
.uv-files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px,1fr)); gap: 8px; }
.uv-fc { background: var(--bg3); border: 1px solid var(--b1); border-radius: var(--r3); padding: 8px; text-align: center; text-decoration: none; color: var(--t1); transition: all var(--e-fast); display: flex; flex-direction: column; align-items: center; gap: 3px; }
.uv-fc:hover { background: var(--bg4); border-color: var(--b2); }
.uv-fc-img { width: 56px; height: 56px; border-radius: var(--r2); object-fit: cover; }
.uv-fc-ic  { font-size: 1.5rem; }
.uv-fc-nm  { font-size: .6rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.uv-fc-sz  { font-size: .56rem; color: var(--t3); }

/* Conn badge */
.conn-badge {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--rbg); border: 1px solid var(--red); border-radius: 99px;
  padding: 3px 14px; font-size: .7rem; font-weight: 700; color: var(--red); z-index: 100;
}
.float-controls { position: fixed; bottom: 16px; right: 16px; z-index: 80; }

/* ── Hidden file inputs ── */
#file-input, #img-input { display: none !important; }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --top-h: 46px; }
  .topbar { padding: 0 8px; gap: 4px; }
  .menu-btn { display: flex; }
  .topbar-title { display: none; }
  .stats-row { grid-template-columns: repeat(2,1fr); }
  .files-grid { grid-template-columns: repeat(3,1fr); }
  #files-view.on, #admin-view.on { padding-bottom: 56px; }
}
@media (max-width: 480px) {
  .files-grid { grid-template-columns: repeat(2,1fr); gap: 5px; }
  .auth-card  { padding: 16px; }
}

/* ── FILTER DROPDOWN (replaces chips bar) ── */
/* ════════════════════════════════════════════════════════════════
   FILTER DROPDOWNS — Fluent 2 ComboBox
════════════════════════════════════════════════════════════════ */
.filter-dropdown-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  flex-shrink: 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--b1);
  direction: rtl;
  position: relative;
  z-index: 100;
  min-height: 44px;
  overflow: visible;
}
[data-theme="light"] .filter-dropdown-bar { background: #f5f5f3; }
/* Group wrapper — must be relative so menu positions correctly */
.fdd-group {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* The trigger button */
.fdd-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 12px;
  background: var(--bg3);
  border: 1.5px solid var(--b2);
  border-radius: var(--r3);
  color: var(--t1);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  min-width: 110px;
  transition: background var(--e-fast), border-color var(--e-fast), color var(--e-fast);
  user-select: none;
}
.fdd-btn:hover { background: var(--bg4); border-color: var(--b3); }
.fdd-btn.has-value {
  border-color: var(--acc);
  background: var(--abg);
  color: var(--acc2);
}
[data-theme="light"] .fdd-btn           { background: #ffffff; border-color: rgba(0,0,0,.18); }
[data-theme="light"] .fdd-btn:hover     { background: #f0f0ee; }
[data-theme="light"] .fdd-btn.has-value { background: rgba(0,102,204,.08); border-color: var(--acc); }

.fdd-btn-label {
  flex: 1;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fdd-btn-arrow {
  flex-shrink: 0;
  color: var(--t3);
  transition: transform var(--e-std);
}
.fdd-group.open .fdd-btn-arrow { transform: rotate(180deg); }
.fdd-group.open .fdd-btn {
  border-color: var(--acc);
  box-shadow: 0 0 0 1px var(--acc);
}

/* Dropdown panel — hidden by default, shown via .open class */
.fdd-menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  min-width: 180px;
  max-height: 340px;
  overflow-y: auto;

  /* Critical: hidden by default */
  display: none;
  opacity: 0;
  transform: translateY(-6px);

  background: var(--bg2);
  border: 1.5px solid var(--b2);
  border-radius: var(--r4);
  box-shadow:
    0 4px 6px rgba(0,0,0,.07),
    0 10px 24px rgba(0,0,0,.22),
    0 20px 48px rgba(0,0,0,.18);
  z-index: 9999;
  direction: rtl;
  scrollbar-width: thin;
  scrollbar-color: var(--b2) transparent;
}
[data-theme="light"] .fdd-menu {
  background: #ffffff;
  border-color: rgba(0,0,0,.14);
  box-shadow: 0 4px 6px rgba(0,0,0,.04), 0 10px 24px rgba(0,0,0,.12), 0 20px 48px rgba(0,0,0,.08);
}

/* Show state */
.fdd-group.open .fdd-menu {
  display: block;
  opacity: 1;
  transform: translateY(0);
  animation: fddOpen .14s cubic-bezier(0,0,0,1);
}
@keyframes fddOpen {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Menu items */
.fdd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--t1);
  transition: background var(--e-fast);
  position: relative;
}
.fdd-item:hover { background: var(--bg3); }
[data-theme="light"] .fdd-item:hover { background: #f0f0ee; }

.fdd-item.selected {
  color: var(--acc2);
  background: var(--abg);
  font-weight: 700;
}
[data-theme="light"] .fdd-item.selected { background: rgba(0,102,204,.08); }

/* Icon on RIGHT side (RTL) */
.fdd-item-icon {
  font-size: .9rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  order: 1; /* icon on the right in RTL flex */
}

.fdd-item-text {
  flex: 1;
  text-align: right;
}

/* Checkmark on LEFT side (RTL = logical end) */
.fdd-check {
  width: 16px;
  height: 16px;
  border-radius: var(--r1);
  border: 1.5px solid var(--b2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 900;
  flex-shrink: 0;
  color: transparent;
  background: transparent;
  transition: all var(--e-fast);
  order: 2; /* leftmost in RTL */
}
.fdd-item.selected .fdd-check {
  background: var(--acc);
  border-color: var(--acc);
  color: #fff;
}

/* Divider */
.fdd-divider {
  height: 1px;
  background: var(--b1);
  margin: 3px 0;
}
[data-theme="light"] .fdd-divider { background: rgba(0,0,0,.08); }

/* Section header inside menu */
.fdd-section-label {
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--t3);
  padding: 9px 14px 4px;
  pointer-events: none;
}

/* Clear button */
.fdd-clear-btn {
  display: none; /* shown via JS when filters active */
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: var(--r3);
  border: 1px solid transparent;
  background: transparent;
  color: var(--t3);
  font-size: .74rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  transition: color var(--e-fast), background var(--e-fast), border-color var(--e-fast);
}
.fdd-clear-btn:hover {
  color: var(--red);
  background: var(--rbg);
  border-color: rgba(255,107,107,.25);
}

/* Active count badge */
.fdd-active-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--acc);
  color: #fff;
  font-size: .58rem;
  font-weight: 900;
  flex-shrink: 0;
}

/* ── Hide filter bar when not in chat view ── */
#admin-view.on ~ * .filter-dropdown-bar,
body.view-admin .filter-dropdown-bar { display: none; }

/* ── Bento / Admin stats extra fixes ── */
.adm-body { min-width: 0; }
.adm-card-body { min-width: 0; }
.adm-ctrl-grid { min-width: 0; }

/* ── Chat bubble avatar fix ── */
.msg-av { align-self: flex-end; flex-shrink: 0; }

/* ── Bubble txt inherits direction ── */
.bubble-txt { text-align: right; direction: rtl; }
.msg-row.own .bubble-txt { text-align: right; }

/* ════════════════════════════════════════════════════════════════
   BENTO DASHBOARD — Admin stats grid injected by JS
════════════════════════════════════════════════════════════════ */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  width: 100%;
  margin-bottom: 4px;
}
@media (max-width: 1000px) { .bento-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width:  480px) { .bento-grid { grid-template-columns: 1fr 1fr; } }

.bento-card {
  background: var(--bg2);
  border: 1px solid var(--b2);
  border-radius: var(--r5);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--el-4);
  transition: all var(--e-fast);
  min-width: 0;
  overflow: hidden;
  direction: rtl;
}
.bento-card:hover { background: var(--bg3); box-shadow: var(--el-8); transform: translateY(-1px); }
.bento-card.span2 { grid-column: span 2; }

/* Card icon */
.bc-icon {
  width: 32px; height: 32px; border-radius: var(--r3);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px; flex-shrink: 0;
}
.bc-icon.blue   { background: var(--abg);  color: var(--acc2); }
.bc-icon.green  { background: var(--gbg);  color: var(--grn); }
.bc-icon.purple { background: var(--pbg);  color: var(--pur); }
.bc-icon.orange { background: var(--obg);  color: var(--org); }

/* Card label */
.bc-label {
  font-size: .62rem; font-weight: 800; letter-spacing: .6px;
  text-transform: uppercase; color: var(--t3); margin-bottom: 2px;
}

/* Card value */
.bc-val {
  font-size: 1.7rem; font-weight: 900; color: var(--t1);
  letter-spacing: -.5px; line-height: 1;
}

/* Sub text */
.bc-sub { font-size: .68rem; color: var(--t3); margin-top: 2px; }

/* Trend badge */
.bc-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .65rem; font-weight: 800;
  padding: 2px 8px; border-radius: 99px; margin-top: 4px; align-self: flex-start;
}
.bc-trend.up   { background: var(--gbg); color: var(--grn); }
.bc-trend.down { background: var(--rbg); color: var(--red); }

/* Mini bar chart */
.bento-mini-chart {
  display: flex; align-items: flex-end; gap: 3px;
  height: 40px; margin-top: 8px;
}
.bento-bar {
  flex: 1; border-radius: 3px 3px 0 0;
  background: var(--bg4); border: 1px solid var(--b1);
  min-height: 4px; transition: height var(--e-std);
}
.bento-bar.active { background: var(--acc); border-color: var(--acc); }

/* Storage bar */
.bento-storage-bar {
  height: 6px; border-radius: 99px; background: var(--bg4);
  overflow: hidden; margin: 6px 0;
}
.bento-storage-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--acc-d), var(--acc-l));
  transition: width .6s var(--e-enter);
}

/* ════════════════════════════════════════════════════════════════
   CALENDAR VIEW — Full fix
════════════════════════════════════════════════════════════════ */
#calendar-view {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--bg2);
  border-bottom: 1px solid var(--b1);
}
#calendar-view.on { display: flex; }

.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--b1);
  flex-shrink: 0; background: var(--bg3);
  direction: rtl;
}
.cal-title { font-size: .88rem; font-weight: 800; color: var(--t1); }

.cal-nav { display: flex; gap: 4px; }
.cal-nav-btn {
  width: 28px; height: 28px; border-radius: var(--r2);
  border: 1px solid var(--b2); background: var(--bg3);
  color: var(--t2); cursor: pointer; font-size: .88rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast), color var(--e-fast);
}
.cal-nav-btn:hover { background: var(--bg4); color: var(--t1); }

/* Day labels row */
.cal-day-labels {
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding: 6px 8px 0; direction: rtl;
}
.cal-day-label {
  text-align: center; font-size: .6rem; font-weight: 800;
  letter-spacing: .3px; color: var(--t3); padding: 4px;
  text-transform: uppercase;
}

/* Calendar grid */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px; padding: 6px 8px 10px; direction: rtl;
  overflow-y: auto;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: var(--r2);
  background: var(--bg3); border: 1px solid var(--b1);
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
  transition: all var(--e-fast);
}
.cal-day:hover { background: var(--bg4); border-color: var(--b2); }
.cal-day.has-msgs {
  background: var(--abg); border-color: var(--acc);
}
.cal-day.today { border-color: var(--grn); border-width: 2px; }
.cal-day.other-month { opacity: .35; }
.cal-day-num { font-size: .72rem; font-weight: 800; color: var(--t1); }
.cal-day-cnt { font-size: .56rem; font-weight: 800; color: var(--acc2); }
.cal-day.has-msgs .cal-day-num { color: var(--acc2); }
[data-theme="light"] .cal-day.has-msgs { background: rgba(0,102,204,.08); }
[data-theme="light"] .cal-day.today { border-color: var(--grn); }

/* ════════════════════════════════════════════════════════════════
   JS-INJECTED CLASSES — rendered via innerHTML in app.js
════════════════════════════════════════════════════════════════ */

/* Connection state */
.connected    { color: var(--grn) !important; background: var(--gbg) !important; }
.disconnected { color: var(--red) !important; background: var(--rbg) !important; }
.mine { opacity: .6; font-style: italic; }

/* Tag pill — shown on bubbles */
.tag-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; border-radius: 99px; font-size: .6rem; font-weight: 700;
  margin: 2px 2px 0 0; cursor: pointer; border: 1px solid transparent;
}
.bubble-tags { display: flex; flex-wrap: wrap; margin-top: 4px; }

/* Pin badge on bubble */
.pin-badge {
  position: absolute; bottom: 4px; left: 6px;
  font-size: .7rem; opacity: .7;
}
.msg-row.own .pin-badge { left: auto; right: 6px; }

/* Lock badge on bubble */
.locked-bubble {
  display: flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--t2); cursor: pointer; padding: 4px 0;
}
.enc-lock-btn {
  padding: 3px 9px; border-radius: var(--r2); border: 1px solid var(--b2);
  background: var(--bg3); color: var(--t2); font-size: .68rem; font-weight: 700;
  cursor: pointer; transition: all var(--e-fast); font-family: var(--font);
}
.enc-lock-btn:hover { background: var(--bg4); color: var(--t1); }

/* Reaction bar */
.reaction-bar {
  display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px;
}
.reaction-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 99px;
  background: var(--bg3); border: 1px solid var(--b1);
  font-size: .72rem; font-weight: 700; cursor: pointer;
  transition: all var(--e-fast);
}
.reaction-chip:hover { background: var(--bg4); border-color: var(--b2); }
.reaction-chip.mine  { background: var(--abg); border-color: var(--acc); color: var(--acc2); }

/* Emoji picker */
.emoji-picker-wrap {
  position: absolute; bottom: calc(100% + 6px); right: 0;
  background: var(--bg2); border: 1px solid var(--b2);
  border-radius: var(--r5); box-shadow: var(--el-28);
  z-index: 300; overflow: hidden; width: 260px;
  animation: f2ScaleIn .14s var(--e-spring);
}
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 8px;
}
.emoji-btn {
  width: 28px; height: 28px; border-radius: var(--r1);
  border: none; background: transparent; font-size: 1rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast);
}
.emoji-btn:hover { background: var(--bg3); }

/* Tag picker (message context menu) */
.tag-picker {
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  max-height: 200px; overflow-y: auto;
}
.tag-picker-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px;
  border-radius: var(--r2); cursor: pointer; font-size: .76rem; font-weight: 600;
  transition: background var(--e-fast);
}
.tag-picker-item:hover { background: var(--bg3); }

/* Folder picker */
.folder-picker { display: flex; flex-direction: column; gap: 2px; padding: 6px; }
.folder-picker-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px;
  border-radius: var(--r2); cursor: pointer; font-size: .76rem;
  transition: background var(--e-fast);
}
.folder-picker-item:hover { background: var(--bg3); }

/* Folder sidebar item (injected by renderFolders) */
.folder-sb-item { /* inherits from .sb-item */ }

/* PDF export button */
.pdf-export-btn {
  padding: 5px 12px; border-radius: var(--r2); border: 1px solid var(--b2);
  background: var(--bg3); color: var(--t2); font-size: .7rem; font-weight: 700;
  cursor: pointer; transition: all var(--e-fast); font-family: var(--font);
}
.pdf-export-btn:hover { background: var(--bg4); color: var(--t1); }

/* OCR result */
.ocr-result-wrap {
  background: var(--bg3); border: 1px solid var(--b1);
  border-radius: var(--r3); padding: 8px 10px; margin-top: 6px;
  font-size: .78rem; line-height: 1.55;
}

/* Storage item */
.st-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r3);
  background: var(--bg3); border: 1px solid var(--b1);
  margin-bottom: 5px; transition: background var(--e-fast);
}
.st-item:hover { background: var(--bg4); }

/* Draw bubble */
.draw-bub { display: block; }
.draw-bub img { max-width: 240px; border-radius: var(--r4); cursor: pointer; display: block; border: 1px solid var(--b1); }

/* Audio message in UV */
.uv-msg-audio audio { width: 100%; margin-top: 4px; border-radius: var(--r2); }

/* Search close button */
.srch-close {
  width: 22px; height: 22px; border-radius: var(--r1); border: none;
  background: transparent; color: var(--t3); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--e-fast), color var(--e-fast);
}
.srch-close:hover { background: var(--bg4); color: var(--t1); }

/* Admin user checkbox */
.bc-user-chk {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--acc);
}

/* Logout button alias */
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--r3);
  border: 1px solid var(--b2); background: transparent;
  color: var(--t2); font-size: .78rem; font-weight: 700;
  cursor: pointer; font-family: var(--font);
  transition: all var(--e-fast);
}
.btn-logout:hover { background: var(--rbg); color: var(--red); border-color: rgba(255,107,107,.25); }

/* Markdown rendered elements */
.md-h1, .md-h2, .md-h3 { font-weight: 800; line-height: 1.3; margin: 4px 0 2px; color: var(--t1); }
.md-h1 { font-size: 1.1rem; }
.md-h2 { font-size: .95rem; }
.md-h3 { font-size: .86rem; }
.md-bold   { font-weight: 800; }
.md-italic { font-style: italic; }
.md-strike { text-decoration: line-through; opacity: .7; }
.md-link   { color: var(--acc2); text-decoration: underline; cursor: pointer; }
.md-bq {
  border-right: 3px solid var(--acc); padding: 4px 8px 4px 0;
  margin: 4px 0; color: var(--t2); font-style: italic;
}
.md-ul, .md-ol { padding-right: 16px; margin: 4px 0; }
.md-li         { margin: 2px 0; font-size: .82rem; }
.md-hr         { border: none; border-top: 1px solid var(--b2); margin: 6px 0; }

/* Calendar additional */
.cal-date-num { font-size: .72rem; font-weight: 800; color: var(--t1); }
.cal-note-chip {
  font-size: .52rem; font-weight: 700; color: var(--acc2);
  background: var(--abg); padding: 1px 4px; border-radius: 3px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-cell {
  aspect-ratio: 1; border-radius: var(--r2);
  background: var(--bg3); border: 1px solid var(--b1);
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; padding: 3px;
  transition: all var(--e-fast); overflow: hidden;
}
.cal-cell:hover    { background: var(--bg4); border-color: var(--b2); }
.cal-cell.has-msgs { background: var(--abg); border-color: var(--acc); }
.cal-cell.today    { border-color: var(--grn); border-width: 2px; }

/* ════════════════════════════════════════════════════════════════
   STT MODAL + Section Header + Drawing extras
════════════════════════════════════════════════════════════════ */

/* Section header above msgs */
.msgs-section-header {
  display:flex; align-items:center; gap:10px;
  padding:8px 14px 7px; flex-shrink:0;
  border-bottom:1px solid var(--b1); background:var(--bg2); direction:rtl;
}
[data-theme="light"] .msgs-section-header { background:#f2f2f5; }
.msgs-section-icon {
  width:28px; height:28px; border-radius:var(--r3);
  background:linear-gradient(145deg,var(--acc-l),var(--acc-d));
  display:flex; align-items:center; justify-content:center;
  font-size:.82rem; box-shadow:0 3px 10px var(--glow); flex-shrink:0;
}
.msgs-section-title { font-size:.82rem; font-weight:800; color:var(--t1); }
.msgs-section-count {
  font-size:.68rem; font-weight:700; color:var(--acc2);
  background:var(--abg); padding:2px 9px; border-radius:99px; margin-right:auto;
}

/* Drawing extras */
.dtb-sep { width:1px; height:24px; background:var(--b2); flex-shrink:0; margin:0 2px; }
.dbb-size-indicator {
  font-size:.62rem; color:var(--t4); font-weight:700; font-family:var(--mono);
  background:var(--bg4); padding:2px 7px; border-radius:var(--r1); flex-shrink:0;
}

/* STT Modal */
.stt-modal {
  position:fixed; inset:0; z-index:800; display:none;
  background:rgba(0,0,0,.65); backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px);
  align-items:center; justify-content:center; padding:16px;
}
.stt-modal.on { display:flex; animation:f2FadeIn .18s ease; }
.stt-box {
  background:var(--bg2); border:1px solid var(--b2); border-radius:var(--r8);
  width:min(460px,96%); max-height:80vh; display:flex; flex-direction:column;
  box-shadow:var(--el-64); overflow:hidden; direction:rtl;
  animation:f2ScaleIn .22s var(--e-spring);
}
.stt-header {
  display:flex; align-items:center; gap:12px; padding:16px 20px;
  border-bottom:1px solid var(--b1); background:var(--bg3); flex-shrink:0;
}
.stt-header-icon {
  width:40px; height:40px; border-radius:var(--r6);
  background:linear-gradient(145deg,var(--acc-l),var(--acc-d));
  display:flex; align-items:center; justify-content:center;
  font-size:1.1rem; box-shadow:0 4px 16px var(--glow); flex-shrink:0;
}
.stt-header-info { flex:1; }
.stt-header-title { font-size:.96rem; font-weight:900; color:var(--t1); }
.stt-header-sub   { font-size:.7rem; color:var(--t3); margin-top:2px; }
.stt-lang-row {
  display:flex; gap:5px; padding:10px 20px 0; flex-shrink:0; direction:rtl;
}
.stt-lang-btn {
  flex:1; padding:6px 4px; border-radius:var(--r3); border:1.5px solid var(--b2);
  background:transparent; color:var(--t2); font-size:.72rem; font-weight:700;
  cursor:pointer; font-family:var(--font); transition:all var(--e-fast); text-align:center;
}
.stt-lang-btn:hover { background:var(--bg3); color:var(--t1); border-color:var(--b3); }
.stt-lang-btn.active { background:var(--abg); border-color:var(--acc); color:var(--acc2); }
.stt-visual {
  display:flex; align-items:center; justify-content:center; gap:3px;
  height:56px; padding:0 20px; flex-shrink:0;
}
.stt-bar {
  width:4px; border-radius:99px; background:var(--b2);
  transition:height .1s ease, background .2s;
}
.stt-modal.on:not(.stt-listening-off) .stt-bar { background:var(--acc); animation:sttWave 1.2s ease-in-out infinite; }
.stt-modal.on:not(.stt-listening-off) .stt-bar:nth-child(1){animation-delay:.0s}
.stt-modal.on:not(.stt-listening-off) .stt-bar:nth-child(2){animation-delay:.1s}
.stt-modal.on:not(.stt-listening-off) .stt-bar:nth-child(3){animation-delay:.2s}
.stt-modal.on:not(.stt-listening-off) .stt-bar:nth-child(4){animation-delay:.3s}
.stt-modal.on:not(.stt-listening-off) .stt-bar:nth-child(5){animation-delay:.2s}
.stt-modal.on:not(.stt-listening-off) .stt-bar:nth-child(6){animation-delay:.1s}
.stt-modal.on:not(.stt-listening-off) .stt-bar:nth-child(7){animation-delay:.0s}
@keyframes sttWave { 0%,100%{height:6px} 50%{height:32px} }
.stt-status-row {
  display:flex; align-items:center; gap:8px; padding:8px 20px 0; flex-shrink:0; direction:rtl;
}
.stt-status-dot {
  width:8px; height:8px; border-radius:50%; background:var(--b3); flex-shrink:0;
  transition:all var(--e-std);
}
.stt-status-dot.active { background:var(--red); animation:recDot 1s ease infinite; box-shadow:0 0 8px var(--red); }
@keyframes recDot { 0%,100%{opacity:1} 50%{opacity:.3} }
.stt-status-text { font-size:.72rem; font-weight:700; color:var(--t3); }
.stt-timer { font-size:.72rem; font-weight:800; color:var(--acc2); font-family:var(--mono); margin-right:auto; }
.stt-transcript-wrap {
  flex:1; overflow-y:auto; padding:12px 20px; min-height:100px;
  direction:rtl; scrollbar-width:thin;
}
.stt-placeholder { font-size:.82rem; color:var(--t3); text-align:center; padding:12px 0; }
.stt-transcript-live  { font-size:.86rem; line-height:1.7; color:var(--t3); font-style:italic; min-height:24px; }
.stt-transcript-final { font-size:.88rem; line-height:1.7; color:var(--t1); font-weight:500; white-space:pre-wrap; }
.stt-edit-ta {
  width:100%; padding:10px 13px; resize:none; display:none;
  background:var(--bg3); border:1.5px solid var(--b2); border-radius:var(--r4);
  color:var(--t1); font-size:.86rem; font-family:var(--font); outline:none; line-height:1.65;
  transition:border-color var(--e-std), box-shadow var(--e-std);
}
.stt-edit-ta.visible { display:block; }
.stt-edit-ta:focus { border-color:var(--acc); box-shadow:0 0 0 3px var(--abg2); }
.stt-actions {
  display:flex; gap:8px; padding:14px 20px 16px; flex-shrink:0;
  border-top:1px solid var(--b1); background:var(--bg3); direction:rtl;
}
.stt-mic-btn {
  width:44px; height:44px; border-radius:50%; border:none; flex-shrink:0;
  background:linear-gradient(145deg,var(--acc-l),var(--acc-d)); color:#fff;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 16px var(--glow); font-size:1.1rem;
  transition:filter var(--e-fast), transform var(--e-fast);
}
.stt-mic-btn.recording {
  background:linear-gradient(145deg,#f87171,var(--red));
  box-shadow:0 4px 20px rgba(255,107,107,.5);
  animation:micPulse 1s ease infinite;
}
@keyframes micPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }
.stt-mic-btn:hover { filter:brightness(1.12); }
.stt-send-btn {
  flex:1; padding:11px; border-radius:var(--r4); border:none;
  background:linear-gradient(135deg,var(--acc-l),var(--acc-d)); color:#fff;
  font-size:.84rem; font-weight:800; cursor:pointer; font-family:var(--font);
  box-shadow:0 4px 16px var(--glow); transition:filter var(--e-fast);
}
.stt-send-btn:hover { filter:brightness(1.1); }
.stt-send-btn:disabled { opacity:.4; cursor:not-allowed; filter:none; box-shadow:none; }
.stt-cancel-btn {
  padding:11px 16px; border-radius:var(--r4); border:1.5px solid var(--b2);
  background:transparent; color:var(--t2); font-size:.82rem; font-weight:700;
  cursor:pointer; font-family:var(--font); transition:all var(--e-fast); white-space:nowrap;
}
.stt-cancel-btn:hover { background:var(--bg3); color:var(--t1); border-color:var(--b3); }

/* Sidebar folder "all" item */
.sb-folder-all {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border-radius: var(--r3); border: 1px solid transparent;
  background: transparent; color: var(--t2); font-size: .78rem; font-weight: 600;
  cursor: pointer; text-align: right; font-family: var(--font);
  transition: background var(--e-fast), color var(--e-fast);
  position: relative; margin-bottom: 2px; white-space: nowrap; overflow: hidden;
}
.sb-folder-all:hover { background: var(--bg3); color: var(--t1); }
.sb-folder-all.active { background: var(--abg); color: var(--acc2); font-weight: 700; border-color: var(--b2); }
.sb-folder-all .sb-item-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--abg); color: var(--acc2);
  font-size: .6rem; font-weight: 800; margin-right: auto; flex-shrink: 0;
}

/* ── Drawing toolbar 2-row layout ── */
.dtb-row {
  display: flex; align-items: center; gap: 5px;
  flex-wrap: wrap; min-height: 32px;
}
.dtb-row + .dtb-row {
  padding-top: 4px;
  border-top: 1px solid var(--b1);
}
.dtb-title { font-size: .88rem; flex-shrink: 0; }

/* ════════════════════════════════════════════════════════════════
   ADMIN ACCORDION — v8
════════════════════════════════════════════════════════════════ */

/* Stats strip */
.adm-stats-strip {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.adm-stats-strip::-webkit-scrollbar { display: none; }

.adm-stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 12px;
  padding: 10px 16px;
  min-width: 72px;
  flex-shrink: 0;
  transition: all var(--e-fast);
}
.adm-stat-chip:hover {
  border-color: var(--b2);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
}
.adm-stat-num {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--t1);
  font-family: var(--mono), monospace;
  line-height: 1;
}
.adm-stat-lbl {
  font-size: .6rem;
  font-weight: 700;
  color: var(--t3);
  text-align: center;
}

/* Accordion wrapper */
.adm-accordion {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px 80px;
}

/* Accordion section */
.acc-section {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow var(--e-fast), border-color var(--e-fast);
}
.acc-section:hover {
  border-color: var(--b2);
}
.acc-section.open {
  border-color: var(--b2);
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
[data-theme="dark"] .acc-section.open {
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
}

/* Accordion header */
.acc-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-align: right;
  transition: background var(--e-fast);
}
.acc-head:hover { background: var(--bg3); }
.acc-section.open .acc-head { background: var(--bg3); }

.acc-head-left {
  display: flex;
  align-items: center;
  gap: 11px;
}

.acc-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.acc-title {
  font-size: .88rem;
  font-weight: 800;
  color: var(--t1);
  line-height: 1.3;
}
.acc-sub {
  font-size: .65rem;
  color: var(--t3);
  margin-top: 2px;
  font-weight: 600;
}

.acc-arrow {
  flex-shrink: 0;
  color: var(--t3);
  transform: rotate(0deg);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.acc-section.open .acc-arrow {
  transform: rotate(180deg);
}

/* Accordion body */
.acc-body {
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid var(--b1);
  animation: accSlideIn .18s ease;
}
.acc-section.open .acc-body {
  display: flex;
}
@keyframes accSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* Sub-tabs inside accordion */
.acc-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 10px;
  padding: 3px;
}
.acc-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--t2);
  font-size: .74rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--e-fast);
}
.acc-tab.active {
  background: var(--bg2);
  color: var(--acc2);
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
  border: 1px solid var(--b1);
}

.acc-panel { width: 100%; }

/* Field groups inside acc-body */
.acc-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.acc-field-label {
  font-size: .72rem;
  font-weight: 800;
  color: var(--t2);
  letter-spacing: .3px;
}
.acc-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.acc-slider-val {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--acc2);
  font-family: var(--mono), monospace;
}
.acc-slider-minmax {
  display: flex;
  justify-content: space-between;
  font-size: .6rem;
  color: var(--t3);
  margin-top: 2px;
}

/* Scope buttons */
.acc-scope-btn {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: 1.5px solid var(--b2);
  background: var(--bg3);
  color: var(--t2);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all .15s;
}
.acc-scope-btn.active {
  border-color: var(--acc);
  background: var(--abg);
  color: var(--acc2);
}
.acc-scope-btn:hover:not(.active) { background: var(--bg4); }

/* Toggle rows */
.acc-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--bg3);
  border-radius: 10px;
  border: 1px solid var(--b1);
  gap: 12px;
}
.acc-toggle-info { flex: 1; min-width: 0; }
.acc-toggle-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--t1);
}
.acc-toggle-desc {
  font-size: .63rem;
  color: var(--t3);
  margin-top: 2px;
  line-height: 1.4;
}

/* Compression card */
.acc-compress-card {
  background: var(--bg3);
  border-radius: 12px;
  border: 1px solid var(--b1);
  padding: 12px 14px;
}

/* Save button */
.acc-save-btn {
  width: 100%;
  padding: 11px;
  border-radius: 11px;
  border: none;
  background: linear-gradient(135deg, var(--acc-l), var(--acc-d));
  color: #fff;
  font-size: .84rem;
  font-weight: 800;
  cursor: pointer;
  font-family: var(--font);
  box-shadow: 0 4px 14px var(--glow);
  transition: filter .15s;
  margin-top: 2px;
}
.acc-save-btn:active { transform: scale(.98); }

/* Separator between field groups */
.acc-body .acc-field-group + .acc-field-group {
  padding-top: 12px;
  border-top: 1px solid var(--b1);
  margin-top: 2px;
}

/* Mobile: full width stats */
@media (max-width: 480px) {
  .adm-stats-strip { padding: 10px 10px; gap: 6px; }
  .adm-stat-chip   { padding: 8px 10px; min-width: 62px; }
  .adm-stat-num    { font-size: 1.1rem; }
  .adm-accordion   { padding: 0 8px 80px; gap: 5px; }
  .acc-head        { padding: 12px 12px; }
  .acc-body        { padding: 12px; gap: 12px; }
  .acc-title       { font-size: .82rem; }
}

/* Remove old stats-row / sc / sv / sl styles used only by old admin */

/* ═══════════════════════════════════════════════════════════════
   ADMIN ACCORDION — FULL REDESIGN
   + FOLDERS & HASHTAGS SIDEBAR STYLE
   + IMAGE COMPRESSION SLIDER
═══════════════════════════════════════════════════════════════ */

/* ── RESET old admin stats-row (replaced by strip) ─────── */
#admin-view .stats-row { display: none !important; }

/* ── ADM-HD header ──────────────────────────────────────── */
.adm-hd {
  background: linear-gradient(135deg, var(--bg2) 0%, var(--bg3) 100%);
  border-bottom: 1px solid var(--b1);
  padding: 16px 18px 14px;
  flex-shrink: 0;
}
.adm-hd-inner { display: flex; align-items: center; gap: 12px; }
.adm-hd-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--acc-l), var(--acc-d));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 16px var(--glow);
  flex-shrink: 0;
}
.adm-hd-inner h2 { font-size: 1rem; font-weight: 900; letter-spacing: -.3px; }
.adm-hd-inner p  { font-size: .68rem; color: var(--t3); margin-top: 2px; }

/* ── ADM-BODY ───────────────────────────────────────────── */
.adm-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  -webkit-overflow-scrolling: touch;
}

/* ── STATS STRIP ────────────────────────────────────────── */
.adm-stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px 14px 10px;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .adm-stats-strip { grid-template-columns: repeat(2, 1fr); }
}
.adm-stat-chip {
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all var(--e-fast);
  position: relative;
  overflow: hidden;
}
.adm-stat-chip::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--e-fast);
  background: var(--shimmer, linear-gradient(105deg,transparent 40%,rgba(255,255,255,.04) 50%,transparent 60%));
}
.adm-stat-chip:hover { border-color: var(--b2); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.10); }
.adm-stat-chip:hover::before { opacity: 1; }
.adm-stat-chip svg { opacity: .7; }
.adm-stat-num {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--t1);
  font-family: var(--mono), 'JetBrains Mono', monospace;
  line-height: 1;
  letter-spacing: -.5px;
}
.adm-stat-lbl {
  font-size: .62rem;
  font-weight: 700;
  color: var(--t3);
  letter-spacing: .3px;
}

/* ── ACCORDION WRAPPER ──────────────────────────────────── */
.adm-accordion {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 12px 90px;
}

/* ── ACCORDION SECTION ──────────────────────────────────── */
.acc-section {
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--b1);
  background: transparent;
  overflow: visible;
  transition: background var(--e-fast);
}
.acc-section:first-child { border-radius: 14px 14px 0 0; border-top: 1px solid var(--b1); }
.acc-section:last-child  { border-radius: 0 0 14px 14px; border-bottom: 1px solid var(--b1); }
.acc-section:only-child  { border-radius: 14px; }

/* Group sections with outer border */
.adm-accordion {
  border-radius: 14px;
  border: 1px solid var(--b1);
  background: var(--bg2);
  overflow: hidden;
  padding: 0 0 80px;
  gap: 0;
}

/* ── ACCORDION HEADER ───────────────────────────────────── */
.acc-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-align: right;
  transition: background var(--e-fast);
}
.acc-head:hover     { background: var(--bg3); }
.acc-section.open > .acc-head  { background: var(--bg3); }

.acc-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.acc-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .9rem;
}

.acc-title {
  font-size: .88rem;
  font-weight: 800;
  color: var(--t1);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acc-sub {
  font-size: .63rem;
  color: var(--t3);
  margin-top: 2px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-arrow {
  flex-shrink: 0;
  color: var(--t4);
  transform: rotate(0deg);
  transition: transform .22s cubic-bezier(.4,0,.2,1), color .15s;
}
.acc-section.open > .acc-head .acc-arrow {
  transform: rotate(180deg);
  color: var(--acc2);
}

/* ── ACCORDION BODY ─────────────────────────────────────── */
.acc-body {
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: var(--bg2);
  border-top: 1px solid var(--b1);
}
.acc-section.open > .acc-body {
  display: flex;
  animation: accOpen .2s cubic-bezier(.4,0,.2,1);
}
@keyframes accOpen {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── ACC SUB-TABS ───────────────────────────────────────── */
.acc-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 11px;
  padding: 3px;
  flex-shrink: 0;
}
.acc-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--t3);
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--e-fast);
}
.acc-tab.active {
  background: var(--acc);
  color: #fff;
  box-shadow: 0 2px 10px var(--glow);
}
.acc-tab:hover:not(.active) { background: var(--bg4); color: var(--t1); }
.acc-panel { width: 100%; }

/* ── FIELD GROUPS ───────────────────────────────────────── */
.acc-field-group {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.acc-field-label {
  font-size: .72rem;
  font-weight: 800;
  color: var(--t2);
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── SCOPE BUTTONS ──────────────────────────────────────── */
.acc-scope-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1.5px solid var(--b2);
  background: var(--bg3);
  color: var(--t2);
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all .15s;
  line-height: 1.3;
}
.acc-scope-btn.active {
  border-color: var(--acc);
  background: var(--abg);
  color: var(--acc2);
  box-shadow: 0 0 0 1px var(--acc) inset;
}
.acc-scope-btn:hover:not(.active) { background: var(--bg4); border-color: var(--b3); }

/* ── TOGGLE ROWS ────────────────────────────────────────── */
.acc-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg3);
  border-radius: 11px;
  border: 1px solid var(--b1);
  transition: border-color var(--e-fast);
}
.acc-toggle-row:hover { border-color: var(--b2); }
.acc-toggle-info { flex: 1; min-width: 0; }
.acc-toggle-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--t1);
}
.acc-toggle-desc {
  font-size: .63rem;
  color: var(--t3);
  margin-top: 2px;
  line-height: 1.4;
}

/* ── SLIDER FIELDS ──────────────────────────────────────── */
.acc-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.acc-slider-val {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--acc2);
  font-family: var(--mono), monospace;
  letter-spacing: -.5px;
  min-width: 52px;
  text-align: left;
}
[dir="rtl"] .acc-slider-val { text-align: right; }
.acc-slider-minmax {
  display: flex;
  justify-content: space-between;
  font-size: .6rem;
  color: var(--t4);
  margin-top: 4px;
}
.adm-range {
  width: 100%;
  accent-color: var(--acc);
  cursor: pointer;
  height: 4px;
  border-radius: 99px;
}
.adm-range::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 2px 8px var(--glow);
  cursor: pointer;
}

/* ── COMPRESSION CARD ───────────────────────────────────── */
.acc-compress-card {
  background: var(--bg3);
  border-radius: 12px;
  border: 1px solid var(--b1);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: border-color var(--e-fast);
}
.acc-compress-card:hover { border-color: var(--b2); }
.acc-compress-card .acc-toggle-row {
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0;
}
.acc-compress-card .acc-toggle-row:hover { border-color: transparent; }

/* Quality row inside compress card */
#pc-q-row {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--b1);
}

/* ── SAVE BUTTON ────────────────────────────────────────── */
.acc-save-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--acc-l), var(--acc-d));
  color: #fff;
  font-size: .86rem;
  font-weight: 900;
  cursor: pointer;
  font-family: var(--font);
  box-shadow: 0 4px 18px var(--glow);
  transition: filter .15s, transform .1s;
  letter-spacing: -.2px;
}
.acc-save-btn:hover   { filter: brightness(1.1); }
.acc-save-btn:active  { transform: scale(.98); }

/* ── DIVIDER between field-groups ──────────────────────── */
.acc-body > .acc-field-group + .acc-field-group {
  padding-top: 14px;
  border-top: 1px solid var(--b1);
}

/* ════════════════════════════════════════════════════════
   SIDEBAR: FOLDERS & HASHTAGS / TAGS — FULL REDESIGN
════════════════════════════════════════════════════════ */

/* Section labels */
.sb-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 4px;
  font-size: .62rem;
  font-weight: 800;
  color: var(--t4);
  letter-spacing: .8px;
  text-transform: uppercase;
  cursor: default;
  user-select: none;
}
.sb-section-collapsible { cursor: pointer; }
.sb-section-collapsible:hover { color: var(--t2); }
.sb-section-label > span:first-child { flex: 1; }
.sb-section-arrow {
  opacity: .45;
  flex-shrink: 0;
  transition: transform var(--e-std);
}
.sb-section-body { overflow: hidden; max-height: 600px; transition: max-height .3s ease; }
.sb-section-body.closed { max-height: 0; }

.sb-section-add {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1px solid var(--b2);
  background: transparent;
  color: var(--t3);
  font-size: .72rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--e-fast);
  font-family: var(--font);
}
.sb-section-add:hover { background: var(--abg); color: var(--acc2); border-color: var(--acc); }

/* ── FOLDER ITEMS in sidebar ──────────────────────────── */
.folder-sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 14px 7px 10px;
  border: none;
  background: transparent;
  color: var(--t2);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  text-align: right;
  direction: rtl;
  border-radius: 0;
  border-right: 3px solid transparent;
  transition: all var(--e-fast);
  position: relative;
}
.folder-sb-item:hover {
  background: var(--bg3);
  color: var(--t1);
}
.folder-sb-item.active {
  background: var(--abg);
  color: var(--acc2);
  font-weight: 700;
  border-right-color: var(--acc);
}
.folder-sb-item .folder-sb-cnt {
  font-size: .62rem;
  font-weight: 800;
  color: var(--t4);
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 99px;
  padding: 1px 7px;
  margin-right: auto;
  transition: all var(--e-fast);
  font-family: var(--mono), monospace;
}
.folder-sb-item.active .folder-sb-cnt {
  background: var(--acc);
  color: #fff;
  border-color: transparent;
}
.folder-sb-item:hover .folder-sb-cnt { color: var(--t2); }

/* Folder icon badge */
.folder-sb-item > span:first-child {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--b1);
  transition: all var(--e-fast);
}
.folder-sb-item.active > span:first-child {
  background: var(--abg);
  border-color: var(--acc);
}

/* ── TAG ITEMS in sidebar ─────────────────────────────── */
.folder-sb-item .tag-dot-sb {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.12);
}

/* ── FOLDER MODAL LIST ────────────────────────────────── */
.tags-box, .folder-box {
  background: var(--bg2);
  border: 1.5px solid var(--b2);
  border-radius: 20px;
  width: min(420px, 96%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.32);
  overflow: hidden;
  animation: f2ScaleIn .18s var(--e-spring);
}
.tags-head, .folder-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--b1);
  background: var(--bg3);
  flex-shrink: 0;
  font-size: .9rem;
  font-weight: 900;
}
.tags-body, .folder-box-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Tag color swatches */
.tag-colors-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.tag-color-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--e-fast);
  box-shadow: 0 2px 6px rgba(0,0,0,.14);
}
.tag-color-swatch:hover { transform: scale(1.2); }
.tag-color-swatch.sel   { border-color: var(--t1); transform: scale(1.28); box-shadow: 0 3px 10px rgba(0,0,0,.22); }

/* Tag create row */
.tag-create-row {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg3);
  border: 1.5px solid var(--b1);
  border-radius: 11px;
  padding: 8px 10px;
  transition: border-color var(--e-fast);
}
.tag-create-row:focus-within { border-color: var(--acc); }
.tag-inp {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--t1);
  font-family: var(--font);
  font-size: .84rem;
  font-weight: 600;
  outline: none;
}
.tag-inp::placeholder { color: var(--t4); }
.tag-add-btn {
  padding: 5px 12px;
  border-radius: 8px;
  border: none;
  background: var(--acc);
  color: #fff;
  font-size: .74rem;
  font-weight: 800;
  cursor: pointer;
  font-family: var(--font);
  transition: filter var(--e-fast), transform var(--e-fast);
  flex-shrink: 0;
}
.tag-add-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.tag-add-btn:active { transform: scale(.96); }

/* Tag list */
.tag-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tag-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 11px;
  transition: all var(--e-fast);
}
.tag-item:hover { border-color: var(--b2); background: var(--bg4); }
.tag-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,0,0,.16); }
.tag-nm, .tag-item-name  { flex: 1; font-size: .78rem; font-weight: 700; color: var(--t1); }
.tag-del, .tag-item-del {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--t3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .68rem;
  transition: all var(--e-fast);
  flex-shrink: 0;
}
.tag-del:hover, .tag-item-del:hover { background: var(--rbg); color: var(--red); }
.tag-item-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,0,0,.16); }

/* Tag pills on messages */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .6rem;
  font-weight: 700;
  border: 1px solid transparent;
  opacity: .85;
  transition: opacity var(--e-fast), transform var(--e-fast);
}
.tag-pill:hover { opacity: 1; transform: scale(1.05); }
.tag-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  flex-shrink: 0;
}

/* Folder items in modal list */
#folder-list .folder-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 11px;
  transition: all var(--e-fast);
}
#folder-list .folder-modal-item:hover { border-color: var(--b2); }

/* Tag picker dropdown */
.tag-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  z-index: 800;
  background: var(--bg2);
  border: 1.5px solid var(--b2);
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  min-width: 170px;
  display: none;
  flex-direction: column;
}
.tag-picker.on { display: flex; animation: fddOpen .14s ease; }
.tag-picker-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--t1);
  font-family: var(--font);
  transition: background var(--e-fast);
}
.tag-picker-item:hover  { background: var(--bg3); }
.tag-picker-item.checked { background: var(--abg); color: var(--acc2); font-weight: 700; }

/* Folder picker dropdown */
.folder-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  z-index: 800;
  background: var(--bg2);
  border: 1.5px solid var(--b2);
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  min-width: 170px;
  display: none;
  flex-direction: column;
  padding: 4px;
  gap: 2px;
}
.folder-picker.on { display: flex; animation: fddOpen .14s ease; }
.folder-picker-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--t1);
  font-family: var(--font);
  transition: background var(--e-fast);
}
.folder-picker-item:hover  { background: var(--bg3); }
.folder-picker-item.checked { background: var(--abg); color: var(--acc2); font-weight: 700; }

/* ════════════════════════════════════════════════════════
   IMAGE COMPRESSION SLIDER — enhanced
════════════════════════════════════════════════════════ */

/* Quality slider track */
.compress-quality-track {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--org) 0%, var(--grn) 100%);
  margin: 6px 0;
}
.compress-quality-track input[type=range] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

/* Custom range: quality with color gradient feedback */
input[type="range"].quality-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 99px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(to right,
    var(--red)  0%,
    var(--org)  35%,
    var(--grn)  75%,
    #22c55e     100%
  );
}
input[type="range"].quality-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg2);
  border: 3px solid var(--acc);
  box-shadow: 0 2px 8px var(--glow), 0 0 0 1px rgba(255,255,255,.1);
  cursor: pointer;
  transition: transform var(--e-fast), box-shadow var(--e-fast);
}
input[type="range"].quality-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 14px var(--glow);
}
input[type="range"].quality-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg2);
  border: 3px solid var(--acc);
  cursor: pointer;
}

/* Quality label badge */
.quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .76rem;
  font-weight: 900;
  font-family: var(--mono), monospace;
  background: var(--bg3);
  border: 1.5px solid var(--b2);
  color: var(--t1);
  min-width: 54px;
  justify-content: center;
  transition: all var(--e-fast);
}

/* ════════════════════════════════════════════════════════
   MOBILE ADJUSTMENTS
════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .adm-stats-strip   { padding: 10px; gap: 6px; }
  .adm-stat-chip     { padding: 10px 10px; border-radius: 12px; }
  .adm-stat-num      { font-size: 1.25rem; }
  .adm-accordion     { border-radius: 12px; margin: 0 6px; }
  .acc-head          { padding: 13px 12px; }
  .acc-body          { padding: 13px; gap: 12px; }
  .acc-title         { font-size: .84rem; }
  .acc-sub           { font-size: .6rem; }
  .acc-icon          { width: 32px; height: 32px; border-radius: 9px; }
  .acc-scope-btn     { padding: 8px 6px; font-size: .7rem; }
  .acc-toggle-row    { padding: 10px 12px; }
  .acc-toggle-title  { font-size: .76rem; }
  .acc-save-btn      { padding: 11px; font-size: .82rem; }
  .folder-sb-item    { font-size: .75rem; padding: 7px 12px 7px 8px; }
  .tag-item          { padding: 9px 10px; }
}

/* ════════════════════════════════════════════════════════
   BENTO NEUTRALIZER — prevent injected bento from breaking layout
════════════════════════════════════════════════════════ */

/* If any old bento grid sneaks in, hide it */
.bento-grid,
#v31-bento {
  display: none !important;
}

/* ── ADMIN stats strip — final overrides ── */
.adm-stats-strip {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 8px !important;
  padding: 14px !important;
  flex-shrink: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
@media (max-width: 600px) {
  .adm-stats-strip { grid-template-columns: repeat(2, 1fr) !important; }
}

.adm-stat-chip {
  background: var(--bg3) !important;
  border: 1px solid var(--b1) !important;
  border-radius: 14px !important;
  padding: 12px 10px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 4px !important;
  text-align: center !important;
  min-width: 0 !important;
  overflow: hidden !important;
  transition: all var(--e-fast) !important;
}
.adm-stat-chip:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 20px rgba(0,0,0,.10) !important;
  border-color: var(--b2) !important;
}
.adm-stat-num {
  font-size: 1.6rem !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  letter-spacing: -.5px !important;
  font-family: var(--mono), 'JetBrains Mono', monospace !important;
}
.adm-stat-lbl {
  font-size: .6rem !important;
  font-weight: 700 !important;
  color: var(--t4) !important;
  letter-spacing: .3px !important;
  white-space: nowrap !important;
}

/* ── ADM-BODY layout fix ── */
.adm-body {
  flex: 1 !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
  -webkit-overflow-scrolling: touch !important;
}

/* Accordion wrapper inside adm-body */
.adm-accordion {
  flex: 1 !important;
  margin: 0 12px !important;
  margin-bottom: 80px !important;
  border-radius: 14px !important;
  border: 1px solid var(--b1) !important;
  background: var(--bg2) !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  padding: 0 !important;
}
@media (max-width: 480px) {
  .adm-accordion { margin: 0 6px; margin-bottom: 80px; }
}

/* Each section fills width, no overflow */
.acc-section {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Ensure utbl scrolls horizontally on small screens */
.utbl-wrap {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

/* ═══════════════════════════════════════════════════════════════
   STATS VIEW — Standalone Statistics Page
═══════════════════════════════════════════════════════════════ */

/* View container */
#stats-view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  height: 100%;
}
#stats-view.on {
  display: flex;
}

/* Header */
.stats-page-hd {
  background: linear-gradient(135deg, var(--bg2) 0%, var(--bg3) 100%);
  border-bottom: 1px solid var(--b1);
  padding: 15px 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stats-page-hd-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stats-page-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--acc-l), var(--acc-d));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 16px var(--glow);
  flex-shrink: 0;
}
.stats-page-hd h2 { font-size: 1rem; font-weight: 900; letter-spacing: -.3px; }
.stats-page-hd p  { font-size: .68rem; color: var(--t3); margin-top: 2px; }
.stats-refresh-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--b2);
  background: var(--bg3);
  color: var(--t2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--e-fast);
  flex-shrink: 0;
}
.stats-refresh-btn:hover {
  background: var(--abg);
  color: var(--acc2);
  border-color: var(--acc);
  transform: rotate(45deg);
}

/* Body */
.stats-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 80px;
  -webkit-overflow-scrolling: touch;
}

/* ── Stat cards grid ── */
.stats-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 680px) {
  .stats-cards-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  border-radius: 16px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
  transition: transform var(--e-fast), box-shadow var(--e-fast);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 70px; height: 70px;
  border-radius: 50%;
  opacity: .08;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.13); }

.stat-card.accent { background: linear-gradient(135deg, rgba(124,77,255,.14), rgba(124,77,255,.06)); border-color: rgba(124,77,255,.22); }
.stat-card.accent::after { background: var(--acc); }
.stat-card.accent .stat-card-icon { background: rgba(124,77,255,.18); color: var(--acc2); }
.stat-card.accent .stat-card-val  { color: var(--acc2); }

.stat-card.green { background: linear-gradient(135deg, rgba(52,211,153,.14), rgba(52,211,153,.06)); border-color: rgba(52,211,153,.22); }
.stat-card.green::after { background: var(--grn); }
.stat-card.green .stat-card-icon { background: rgba(52,211,153,.18); color: var(--grn); }
.stat-card.green .stat-card-val  { color: var(--grn); }

.stat-card.purple { background: linear-gradient(135deg, rgba(192,132,252,.14), rgba(192,132,252,.06)); border-color: rgba(192,132,252,.22); }
.stat-card.purple::after { background: var(--pur); }
.stat-card.purple .stat-card-icon { background: rgba(192,132,252,.18); color: var(--pur); }
.stat-card.purple .stat-card-val  { color: var(--pur); }

.stat-card.orange { background: linear-gradient(135deg, rgba(251,191,36,.14), rgba(251,191,36,.06)); border-color: rgba(251,191,36,.22); }
.stat-card.orange::after { background: var(--org); }
.stat-card.orange .stat-card-icon { background: rgba(251,191,36,.18); color: var(--org); }
.stat-card.orange .stat-card-val  { color: var(--org); }

.stat-card-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card-info { flex: 1; min-width: 0; }
.stat-card-val {
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: -.5px;
  font-family: var(--mono), 'JetBrains Mono', monospace;
  line-height: 1;
}
.stat-card-lbl {
  font-size: .66rem;
  font-weight: 700;
  color: var(--t2);
  margin-top: 4px;
}
.stat-card-trend {
  font-size: .6rem;
  color: var(--t3);
  font-weight: 700;
  white-space: nowrap;
  margin-top: 2px;
}

/* ── Section cards ── */
.stats-section-card {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color var(--e-fast);
}
.stats-section-card:hover { border-color: var(--b2); }
.stats-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .76rem;
  font-weight: 800;
  color: var(--t2);
  letter-spacing: .2px;
}
.stats-section-title svg { color: var(--t3); flex-shrink: 0; }

/* ── Storage bar ── */
.stats-storage-wrap { display: flex; flex-direction: column; gap: 8px; }
.stats-storage-bar-track {
  width: 100%;
  height: 10px;
  border-radius: 99px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  overflow: hidden;
}
.stats-storage-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1), background .3s;
  background: var(--grn);
}
.stats-storage-labels {
  display: flex;
  justify-content: space-between;
  font-size: .66rem;
  color: var(--t3);
  font-weight: 700;
}

/* ── Activity bar chart ── */
.stats-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
}
.stats-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.stats-bar-val {
  font-size: .56rem;
  font-weight: 800;
  color: var(--t3);
  font-family: var(--mono), monospace;
  min-height: 12px;
}
.stats-bar-track {
  flex: 1;
  width: 100%;
  border-radius: 5px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.stats-bar-fill {
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--b2);
  transition: height .5s cubic-bezier(.4,0,.2,1);
  min-height: 4px;
}
.stats-bar-fill.today {
  background: linear-gradient(180deg, var(--acc-l), var(--acc-d));
  box-shadow: 0 -2px 8px var(--glow);
}
.stats-bar-day {
  font-size: .56rem;
  font-weight: 700;
  color: var(--t4);
  white-space: nowrap;
}

/* ── Note types grid ── */
.stats-types-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stats-type-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.stats-type-icon { font-size: .9rem; flex-shrink: 0; width: 20px; text-align: center; }
.stats-type-lbl  { font-size: .74rem; font-weight: 700; color: var(--t2); width: 52px; flex-shrink: 0; text-align: right; }
.stats-type-bar-wrap {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: var(--bg3);
  overflow: hidden;
  border: 1px solid var(--b1);
}
.stats-type-bar {
  height: 100%;
  border-radius: 99px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
  min-width: 4px;
}
.stats-type-count {
  font-size: .7rem;
  font-weight: 800;
  color: var(--t3);
  font-family: var(--mono), monospace;
  width: 28px;
  text-align: left;
  flex-shrink: 0;
}

/* ── Top users list ── */
.stats-users-list { display: flex; flex-direction: column; gap: 8px; }
.stats-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--b1);
}
.stats-user-row:last-child { border-bottom: none; }
.stats-user-rank {
  font-size: .7rem;
  font-weight: 900;
  color: var(--t4);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-family: var(--mono), monospace;
}
.stats-user-rank:first-child { color: #f59e0b; }
.stats-user-av {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--acc-l), var(--pur));
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stats-user-info { flex: 1; min-width: 0; }
.stats-user-name { font-size: .8rem; font-weight: 700; color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-user-meta { font-size: .62rem; color: var(--t3); margin-top: 1px; }
.stats-user-bar-wrap {
  width: 60px;
  height: 5px;
  border-radius: 99px;
  background: var(--bg3);
  overflow: hidden;
  flex-shrink: 0;
}
.stats-user-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--acc-l), var(--acc-d));
  transition: width .5s ease;
}

/* Mobile stats adjustments */
@media (max-width: 480px) {
  .stats-body { padding: 10px; gap: 10px; }
  .stats-cards-grid { gap: 8px; }
  .stat-card { padding: 12px 10px; border-radius: 14px; }
  .stat-card-val { font-size: 1.4rem; }
  .stats-section-card { padding: 12px; gap: 10px; }
  .stats-bars { height: 80px; gap: 4px; }
  .stats-type-lbl { width: 44px; font-size: .68rem; }
}

/* ═══════════════════════════════════════════════════════════════
   ADMIN v2 — New Elements CSS
═══════════════════════════════════════════════════════════════ */

/* ── Admin scope badge ── */
.admin-scope-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .64rem;
  font-weight: 700;
  color: var(--t3);
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 99px;
  padding: 3px 10px;
  margin-top: 6px;
}

.admin-scope-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: .72rem;
  color: var(--org);
  background: rgba(251,191,36,.08);
  border: 1px solid rgba(251,191,36,.22);
  border-radius: 10px;
  padding: 9px 12px;
  margin-top: 4px;
  line-height: 1.5;
}
.admin-scope-note svg { flex-shrink:0; margin-top:1px; color:var(--org); }

/* ── File types grid ── */
.file-types-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
@media (max-width: 480px) {
  .file-types-grid { grid-template-columns: repeat(2, 1fr); }
}
.file-type-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg3);
  border: 1.5px solid var(--b1);
  border-radius: 9px;
  cursor: pointer;
  font-size: .76rem;
  font-weight: 700;
  color: var(--t2);
  transition: all var(--e-fast);
  user-select: none;
}
.file-type-chip:hover { border-color: var(--b2); background: var(--bg4); }
.file-type-chip input[type=checkbox] { display: none; }
.file-type-chip:has(input:checked) {
  border-color: var(--acc);
  background: var(--abg);
  color: var(--acc2);
}
.file-type-chip span { font-size: .75rem; }

/* ── Users filter row ── */
.users-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

/* ── Storage filter row ── */
.storage-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* ── Danger section ── */
.acc-danger-warning {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  background: rgba(248,113,113,.08);
  border: 1px solid rgba(248,113,113,.22);
  border-radius: 11px;
  color: var(--red);
  font-size: .76rem;
  font-weight: 700;
  line-height: 1.5;
}
.acc-danger-warning svg { flex-shrink:0; margin-top:1px; }

.acc-danger-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.acc-danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(248,113,113,.05);
  border: 1px solid rgba(248,113,113,.14);
  border-radius: 11px;
  transition: border-color var(--e-fast), background var(--e-fast);
}
.acc-danger-row:hover {
  background: rgba(248,113,113,.10);
  border-color: rgba(248,113,113,.28);
}
.acc-danger-row .acc-toggle-info { flex:1; }
.acc-danger-row .acc-toggle-title { font-size:.8rem; }
.acc-danger-row .acc-toggle-desc  { font-size:.63rem; }

/* ── adm-hd refresh button ── */
.adm-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ── Tablet+ stats strip is still visible ── */
@media (max-width: 540px) {
  .file-types-grid { grid-template-columns: repeat(2,1fr); gap:5px; }
  .file-type-chip  { padding:7px 8px; font-size:.72rem; }
  .users-filter-row { gap:5px; }
  .acc-danger-row  { flex-direction:column; align-items:flex-start; }
  .acc-danger-row .bsm { align-self:flex-end; }
}

/* ═══════════════════════════════════════════════════════════════
   ACCORDION INNER SCROLL FIX + POLISH
═══════════════════════════════════════════════════════════════ */

/* Inner scroll — custom scrollbar for acc-body */
.acc-body {
  scrollbar-width: thin;
  scrollbar-color: var(--b2) transparent;
}
.acc-body::-webkit-scrollbar {
  width: 4px;
}
.acc-body::-webkit-scrollbar-track {
  background: transparent;
}
.acc-body::-webkit-scrollbar-thumb {
  background: var(--b2);
  border-radius: 99px;
}
.acc-body::-webkit-scrollbar-thumb:hover {
  background: var(--acc);
}

/* Ensure acc-body content doesn't cause horizontal overflow */
.acc-body > * {
  min-width: 0;
}

/* Fade indicator at bottom of scrollable body */
.acc-section.open > .acc-body {
  position: relative;
}

/* Mobile: reduce max-heights */
@media (max-width: 540px) {
  .acc-body[style*="max-height:420px"] { max-height: 340px !important; }
  .acc-body[style*="max-height:480px"] { max-height: 380px !important; }
  .acc-body[style*="max-height:300px"] { max-height: 240px !important; }
  .acc-body[style*="max-height:340px"] { max-height: 280px !important; }
}

/* Fix: adm-accordion itself shouldn't overflow-hidden (breaks inner scroll) */
.adm-accordion {
  overflow: visible !important;
}

/* Fix: each acc-section clips its content */
.acc-section {
  overflow: hidden;
  border-radius: 0;
}
.acc-section:first-child { border-radius: 14px 14px 0 0; }
.acc-section:last-child  { border-radius: 0 0 14px 14px; }

/* Users table: inner scroll on the table wrap itself */
.utbl-wrap {
  max-height: 300px;
  overflow-y: auto;
  overflow-x: auto;
  border-radius: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--b2) transparent;
}
.utbl-wrap::-webkit-scrollbar { width: 4px; height: 4px; }
.utbl-wrap::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 99px; }

/* Storage list: inner scroll */
#storage-list {
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--b2) transparent;
}
#storage-list::-webkit-scrollbar { width: 4px; }
#storage-list::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 99px; }

/* Sticky table header inside utbl-wrap */
.ut thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg3);
  box-shadow: 0 1px 0 var(--b1);
}

/* Sticky save button inside scrollable acc-body */
#pc-save, .acc-save-btn {
  position: sticky;
  bottom: 0;
  z-index: 5;
  backdrop-filter: blur(20px);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   TYPE FILTER CHIPS — pill row above textarea (all screens)
═══════════════════════════════════════════════════════════ */
.type-chips-row {
  display: flex; align-items: center; gap: 4px;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; flex-shrink: 0;
  padding: 2px 0 4px;
}
.type-chips-row::-webkit-scrollbar { display: none; }
.type-chips-row > * { flex-shrink: 0; }

.tc {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: 99px;
  border: 1.5px solid var(--b2); background: var(--bg3);
  color: var(--t2); font-size: .7rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; user-select: none;
  font-family: var(--font); line-height: 1;
  transition: all .14s cubic-bezier(.22,1,.36,1);
}
.tc-ic { font-size: .78rem; line-height: 1; transition: transform .14s; }
.tc-lbl { font-size: .68rem; font-weight: 700; }
.tc:hover:not(:disabled):not(.tc-off) { border-color: var(--b3); color: var(--t1); background: var(--bg4); transform: translateY(-1px); }
.tc.active { background: var(--acc); border-color: var(--acc); color: #fff; box-shadow: 0 3px 10px rgba(0,102,255,.26); }
.tc.active .tc-ic { transform: scale(1.12); }
.tc.active:hover { background: var(--acc-l, var(--acc)); box-shadow: 0 4px 14px rgba(0,102,255,.34); }

/* DISABLED — type not available */
.tc.tc-off {
  opacity: .3; cursor: not-allowed; pointer-events: none;
  filter: grayscale(.8); transform: none !important; box-shadow: none !important;
}
.tc-sep { width: 1px; height: 14px; background: var(--b1); flex-shrink: 0; margin: 0 2px; }

/* Hide old filter-dropdown-bar on mobile (chips handle filtering) */
@media (max-width: 768px) {
  .filter-dropdown-bar { display: none !important; }
  #admin-view.on { padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important; }
}

/* ═══════════════════════════════════════════════════════════
   STT WAVEFORM — animated real-time wave
═══════════════════════════════════════════════════════════ */
.stt-visual {
  display: flex; align-items: center; justify-content: center;
  gap: 0; height: 80px; padding: 0 20px; flex-shrink: 0; position: relative;
}
.stt-wave-wrap {
  display: flex; align-items: center; gap: 3px; height: 64px;
}
.stt-bar {
  width: 3px; border-radius: 99px; background: var(--b2);
  height: var(--b, 6px); transition: background .2s;
}
/* Animate when listening (stt-visual no longer has stt-listening-off) */
.stt-visual:not(.stt-listening-off) .stt-bar {
  background: var(--acc);
  animation: sttWave 1.3s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
@keyframes sttWave {
  0%   { height: var(--b, 6px); }
  35%  { height: var(--p, 30px); }
  65%  { height: calc(var(--b, 6px) * .6); }
  85%  { height: var(--p, 30px); opacity: .75; }
  100% { height: var(--b, 6px); }
}
.stt-listening-off .stt-bar { height: var(--b, 6px) !important; background: var(--b2) !important; animation: none !important; }

/* Mic orb in centre */
.stt-mic-orb {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--gl2); border: 1.5px solid var(--b2);
  display: flex; align-items: center; justify-content: center;
  color: var(--t3); z-index: 2; backdrop-filter: blur(8px);
  transition: all .25s;
}
.stt-visual:not(.stt-listening-off) .stt-mic-orb {
  background: rgba(0,102,255,.1); border-color: var(--acc); color: var(--acc2);
  animation: micOrb 1.8s ease-out infinite;
}
@keyframes micOrb {
  0%   { box-shadow: 0 0 0 0 rgba(0,102,255,.4); }
  60%  { box-shadow: 0 0 0 10px rgba(0,102,255,.05); }
  100% { box-shadow: 0 0 0 16px rgba(0,102,255,0); }
}

/* ═══════════════════════════════════════════════════════════
   ADMIN CODE REGISTRATION FIELD
═══════════════════════════════════════════════════════════ */
.admin-invite-box {
  background: linear-gradient(135deg, rgba(124,77,255,.07), rgba(0,120,255,.04));
  border: 1.5px dashed rgba(124,77,255,.3);
  border-radius: 11px; padding: 12px 14px; transition: border-color .2s;
}
.admin-invite-box:focus-within { border-color: var(--acc); border-style: solid; }
.admin-invite-hdr {
  display: flex; align-items: center; gap: 6px;
  font-size: .74rem; font-weight: 800; color: var(--acc2); margin-bottom: 2px;
}

/* ═══════════════════════════════════════════════════════════
   SETTINGS APP TAB PANEL
═══════════════════════════════════════════════════════════ */
#spanel-app { display: none; }
#spanel-app.active { display: block; }
.settings-tabs-row { overflow-x: auto; scrollbar-width: none; }
.settings-tabs-row::-webkit-scrollbar { display: none; }
.set-tab { font-size: .66rem; padding: 7px 10px; flex-shrink: 0; min-width: 52px; }

/* ═══════════════════════════════════════════════════════════
   AUTO-SAVE BADGE
═══════════════════════════════════════════════════════════ */
.autosave-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 99px;
  background: var(--gbg); border: 1px solid rgba(0,200,130,.2);
  color: var(--grn, #00e5a0); font-size: .68rem; font-weight: 700;
  margin-top: 12px;
}

/* Admin save indicator flash */
.admin-saved-flash {
  position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%);
  z-index: 9999; pointer-events: none; white-space: nowrap;
}
.admin-saved-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 14px; border-radius: 99px;
  background: var(--gbg); border: 1px solid var(--grn);
  color: var(--grn); font-size: .7rem; font-weight: 800;
  font-family: var(--font); backdrop-filter: blur(10px);
  animation: savedFade 2s ease forwards;
}
@keyframes savedFade { 0%{opacity:0;transform:scale(.9)} 12%{opacity:1;transform:scale(1)} 70%{opacity:1} 100%{opacity:0} }
.tog.tog-saving { animation: togPulse .35s ease; }
@keyframes togPulse { 0%,100%{box-shadow:none} 50%{box-shadow:0 0 0 6px rgba(0,200,130,.25)} }

/* ═══════════════════════════════════════════════════════════
   NOTE SHARING UI
═══════════════════════════════════════════════════════════ */
.share-ulist {
  position: absolute; top: calc(100% + 4px); right: 0; left: 0; z-index: 9999;
  background: var(--bg2); border: 1.5px solid var(--b2); border-radius: 11px;
  box-shadow: 0 8px 32px rgba(0,0,0,.24); max-height: 200px; overflow-y: auto;
  display: none;
}
.share-ulist.open { display: block; }
.share-uitem {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; font-size: .8rem; font-weight: 600; color: var(--t1);
  transition: background var(--e-fast);
}
.share-uitem:hover { background: var(--bg3); }
.share-uavatar {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--acc-d, #2d5cd4), var(--acc));
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 900; color: #fff;
}

/* Share live notification */
.share-live-notif {
  position: fixed; bottom: 76px; right: 14px; z-index: 8800;
  max-width: 320px; background: var(--bg2); border: 1.5px solid var(--acc);
  border-radius: 16px; padding: 14px 16px; box-shadow: 0 8px 32px rgba(0,0,0,.3);
  backdrop-filter: blur(20px); display: none;
  animation: shareNotifIn .35s cubic-bezier(.22,1,.36,1);
}
@keyframes shareNotifIn { from{transform:translateY(16px);opacity:0} to{transform:translateY(0);opacity:1} }
.sln-from { font-size: .78rem; font-weight: 900; color: var(--t1); }
.sln-preview { font-size: .74rem; color: var(--t2); padding: 6px 10px; background: var(--bg3); border-radius: 8px; margin: 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sln-acts { display: flex; gap: 6px; }
.sln-accept { flex:1; padding:7px; border-radius:9px; border:none; background:var(--acc); color:#fff; font-family:var(--font); font-size:.76rem; font-weight:800; cursor:pointer; }
.sln-decline { padding:7px 12px; border-radius:9px; border:1.5px solid var(--b2); background:transparent; color:var(--t2); font-family:var(--font); font-size:.76rem; font-weight:700; cursor:pointer; }

/* Inbox badge */
.inbox-badge {
  position: absolute; top: 2px; right: -2px;
  min-width: 16px; height: 16px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: .5rem; font-weight: 900;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 3px; line-height: 1;
}

/* Inbox note item */
.inbox-item { background: var(--bg3); border: 1px solid var(--b1); border-radius: 11px; padding: 12px 14px; }
.inbox-from { display:inline-flex;align-items:center;gap:4px;padding:2px 8px;background:var(--abg);border:1px solid var(--b2);border-radius:99px;font-size:.64rem;font-weight:800;color:var(--acc2); }
.inbox-preview { font-size:.76rem;color:var(--t2);padding:6px 9px;background:var(--bg4);border-radius:8px;margin:6px 0;max-height:60px;overflow:hidden;text-overflow:ellipsis;white-space:pre-wrap; }
.inbox-acts { display:flex;gap:6px;margin-top:8px; }

/* Shared note bubble tag */
.shared-from-tag { display:inline-flex;align-items:center;gap:4px;font-size:.58rem;font-weight:800;color:var(--acc2);background:var(--abg);border:1px solid var(--b2);border-radius:99px;padding:1px 6px;margin-bottom:4px; }

/* Invite code card in admin panel */
.invite-code-card { display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 14px;background:var(--bg3);border:1.5px solid var(--b2);border-radius:10px;flex-wrap:wrap; }
.invite-code-val { font-family:var(--mono);font-size:.92rem;font-weight:900;color:var(--acc2);letter-spacing:.06em;word-break:break-all; }

/* Pending user row */
.pending-row { display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--bg3);border:1px solid var(--b1);border-radius:9px;font-size:.76rem; }
.pending-row .pr-info { flex:1;min-width:0; }
.pending-row .pr-name { font-weight:800;color:var(--t1); }
.pending-row .pr-email { color:var(--t3);font-size:.66rem; }
