/* ============================================================
   xVh Bot — premium anime cyber lounge
   ============================================================ */
:root {
  --bg-0:   #07060B;
  --bg-1:   #0D0B16;
  --bg-2:   #14111F;
  --bg-3:   #1B1729;
  --bg-4:   #221C33;

  --accent:    #B19CFF;
  --accent-2:  #8B6FE8;
  --accent-3:  #6B4FD8;
  --accent-ink:#2E1F66;
  --glow:      rgba(177,156,255,0.35);

  --success: #6EE7B7;
  --warning: #FBBF24;
  --danger:  #F87171;
  --info:    #7DD3FC;

  --text-1: #F4F1FF;
  --text-2: #C9C3E0;
  --text-3: #8B85A8;
  --text-4: #867FA0;   /* AA-normal: 4.9:1 on bg-2 / 4.6:1 on bg-3 (was #7C769E = 4.1:1 on bg-3, failed AA-normal per Gate-6). Stays distinct from --text-3. */
  --text-4b: #4A465E;  /* legacy value — decorative use ONLY, never readable copy */

  --border:   rgba(177,156,255,0.12);
  --border-2: rgba(177,156,255,0.22);
  --border-3: rgba(177,156,255,0.35);
  --hairline: rgba(255,255,255,0.04);  /* neutral in-surface divider */

  --grad-1: linear-gradient(135deg, #B19CFF 0%, #6B4FD8 50%, #2E1F66 100%);
  --grad-soft: linear-gradient(180deg, rgba(177,156,255,0.10) 0%, rgba(177,156,255,0.02) 100%);

  --radius: 14px;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --shadow-glow: 0 10px 40px -10px rgba(107, 79, 216, 0.45);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.03) inset, 0 20px 50px -30px rgba(0,0,0,0.6);

  --font-latin: 'Inter', system-ui, sans-serif;
  --font-arabic: 'Tajawal', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --topbar-h: 64px;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --right-rail-w: 280px;

  /* Type scale tokens (Phase 1 / D-05 — refreshed v1.2 modular ratio 1.25) */
  --text-display:  3.5rem;
  --text-h1:       2.25rem;
  --text-h2:       1.75rem;
  --text-h3:       1.375rem;
  --text-body-lg:  1.125rem;
  --text-body:     1.00rem;
  --text-caption:  0.875rem;
  --text-sm:       0.875rem;
  --text-xs:       0.75rem;
  --text-micro:    0.75rem;

  /* v1.2 — 8pt spacing scale */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* v1.2 — motion tokens (consistent across all interactions) */
  --motion-instant: 80ms;
  --motion-fast:    160ms;
  --motion-base:    240ms;
  --motion-slow:    380ms;
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:     cubic-bezier(0.7, 0, 0.84, 0);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-soft:   cubic-bezier(0.4, 0, 0.2, 1);

  /* v1.2 — elevation scale (purple-tinted shadows align with palette) */
  --elev-1:    0 1px 2px rgba(177,156,255,0.04), 0 1px 3px rgba(7,6,11,0.4);
  --elev-2:    0 4px 8px rgba(177,156,255,0.06), 0 2px 4px rgba(7,6,11,0.5);
  --elev-3:    0 8px 24px rgba(177,156,255,0.10), 0 4px 8px rgba(7,6,11,0.6);
  --elev-modal:0 24px 64px rgba(7,6,11,0.7), 0 0 0 1px rgba(177,156,255,0.12);
  --elev-glow: 0 0 32px rgba(177,156,255,0.15);

  /* ==========================================================
     v2.0 MATERIALITY — the luxury layer (Shion / Gate 2).
     A raised surface = (a) lit top edge, (b) layered soft shadow,
     (c) faint top-down sheen painted into the fill. Additive; the
     legacy --elev-* above are kept for anything already using them.
     ========================================================== */
  --lit-edge:        inset 0 1px 0 rgba(255,255,255,0.06);
  --lit-edge-strong: inset 0 1px 0 rgba(255,255,255,0.09);
  /* cooler, layered shadows (contact + ambient + faint bloom) */
  --elev-2m: 0 2px 4px rgba(7,6,11,0.45), 0 8px 16px -8px rgba(7,6,11,0.55);
  --elev-3m: 0 4px 8px rgba(7,6,11,0.50), 0 16px 40px -16px rgba(7,6,11,0.65), 0 0 40px -20px var(--glow);
  /* composed recipes — apply these on surfaces */
  --surface-raised-bg: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0)), var(--bg-2);
  --surface-raised-shadow: var(--lit-edge), var(--elev-2m);
  --surface-hover-shadow:  var(--lit-edge-strong), var(--elev-3m);
  --accent-tint: rgba(177,156,255,0.10);
  --success-tint: rgba(110,231,183,0.12);
  --warning-tint: rgba(251,191,36,0.12);
  --danger-tint:  rgba(248,113,113,0.12);
  --info-tint:    rgba(125,211,252,0.12);
  /* restrained glass — topbar / floating only, never content cards */
  --glass-bg: rgba(12,10,20,0.72);
  --glass-blur: saturate(140%) blur(18px);
  /* filmic grain (self-contained data-URI) + canvas atmosphere */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  --grain-opacity: 0.03;
  --canvas-atmosphere:
     radial-gradient(120% 80% at 15% -10%, rgba(107,79,216,0.14) 0%, rgba(107,79,216,0) 55%),
     radial-gradient(90% 60% at 100% 0%,  rgba(139,111,232,0.06) 0%, rgba(139,111,232,0) 50%),
     var(--bg-1);

  /* ==========================================================
     v2.0 SOUL — accent story, hero, data-viz treatment
     ========================================================== */
  --hero-band-bg:
     radial-gradient(120% 140% at 100% 0%, rgba(107,79,216,0.16), rgba(107,79,216,0) 60%),
     linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0)), var(--bg-2);
  --hero-line: var(--accent);
  --viz-line: var(--accent);
  --viz-fill: linear-gradient(180deg, rgba(177,156,255,0.18) 0%, rgba(177,156,255,0) 82%);
  --viz-track: rgba(177,156,255,0.08);
  --focus-ring: 0 0 0 2px var(--bg-1), 0 0 0 4px var(--accent);
}

/* ============================================================
   v1.3 — Light theme overrides
   Activated by [data-theme="light"] on <html> (set via CurtainThemeToggle).
   Two-state only: dark (default) ↔ light. Auto mode removed in v1.3 stack-fix.
   ============================================================ */
html[data-theme="light"] {
  --bg-0:   #f7f4ee;
  --bg-1:   #ffffff;
  --bg-2:   #f0eadd;
  --bg-3:   #e6dfce;
  --bg-4:   #d9d2bf;

  --accent:    #6B4FD8;
  --accent-2:  #8B6FE8;
  --accent-3:  #B19CFF;
  --accent-ink:#F4F1FF;
  --glow:      rgba(107,79,216,0.30);

  --text-1: #1a1729;
  --text-2: #3b3552;
  --text-3: #6b6585;
  --text-4: #a09baa;

  --border:   rgba(107,79,216,0.18);
  --border-2: rgba(107,79,216,0.32);
  --border-3: rgba(107,79,216,0.50);

  --grad-soft: linear-gradient(180deg, rgba(107,79,216,0.06) 0%, rgba(107,79,216,0.01) 100%);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.6) inset, 0 6px 16px -8px rgba(30,20,80,0.18);

  --elev-1:    0 1px 2px rgba(60,45,140,0.04), 0 1px 3px rgba(60,45,140,0.08);
  --elev-2:    0 4px 8px rgba(60,45,140,0.06), 0 2px 4px rgba(60,45,140,0.10);
  --elev-3:    0 8px 24px rgba(60,45,140,0.10), 0 4px 8px rgba(60,45,140,0.14);
  --elev-modal:0 24px 64px rgba(30,20,80,0.20), 0 0 0 1px rgba(107,79,216,0.18);
  --elev-glow: 0 0 32px rgba(107,79,216,0.22);

  /* v2.0 materiality — light-theme overrides (lit edge from white, softer shadows) */
  --hairline: rgba(30,20,80,0.06);
  --lit-edge:        inset 0 1px 0 rgba(255,255,255,0.8);
  --lit-edge-strong: inset 0 1px 0 rgba(255,255,255,0.95);
  --elev-2m: 0 2px 4px rgba(30,20,80,0.08), 0 8px 16px -8px rgba(30,20,80,0.14);
  --elev-3m: 0 4px 8px rgba(30,20,80,0.10), 0 16px 40px -16px rgba(30,20,80,0.18), 0 0 40px -20px var(--glow);
  --surface-raised-bg: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0)), var(--bg-1);
  --surface-raised-shadow: var(--lit-edge), var(--elev-2m);
  --surface-hover-shadow:  var(--lit-edge-strong), var(--elev-3m);
  --accent-tint: rgba(107,79,216,0.08);
  --glass-bg: rgba(255,255,255,0.72);
  --grain-opacity: 0.015;
  --canvas-atmosphere:
     radial-gradient(120% 80% at 15% -10%, rgba(107,79,216,0.06) 0%, rgba(107,79,216,0) 55%), var(--bg-1);
  --hero-band-bg:
     radial-gradient(120% 140% at 100% 0%, rgba(107,79,216,0.08), rgba(107,79,216,0) 60%),
     linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0)), var(--bg-1);
}
/* v1.3 stack-fix — auto-mode media query removed.
   Theme is now strictly two-state and stored in localStorage('xvh-theme').
   Default applied in index.html before React mounts to avoid FOUC. */
html, body { transition: background-color 300ms ease, color 300ms ease; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg-0); color: var(--text-1); }

body {
  font-family: var(--font-latin);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 1200px 600px at 80% -10%, rgba(139,111,232,0.10), transparent 60%),
    radial-gradient(ellipse 900px 500px at 0% 30%, rgba(107,79,216,0.07), transparent 60%),
    var(--bg-0);
  background-attachment: fixed;
}

[dir="rtl"] body, [dir="rtl"] {
  font-family: var(--font-arabic);
}

/* v2.0 — filmic grain over the whole canvas (once), kills flat digital black */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background-image: var(--grain); opacity: var(--grain-opacity); mix-blend-mode: overlay;
}

/* v2.0 — global reduced-motion. Layout never depends on motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* v2.0 — micro-interaction catalogue. transform/opacity only, ease-out, brief. */
@keyframes mi-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes mi-value-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.mi-enter { animation: mi-enter var(--motion-slow) var(--ease-out) both; }
.mi-value-in { animation: mi-value-in var(--motion-base) var(--ease-out) both; }
/* universal press feedback for interactive surfaces (opt-in via existing classes below) */
.card:active, .metric:active, .server-card:active, .btn:active,
.nav-item:active, .status-pill:active {
  transform: translateY(0) scale(0.99);
  transition-duration: var(--motion-instant);
  transition-timing-function: var(--ease-in);
}
:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* selection & focus */
::selection { background: rgba(177,156,255,0.35); color: var(--text-1); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ============================================================
   Phase 2 — Per-component :focus-visible shape overrides (D-23, UI-SPEC §8)
   Global rule above sets the COLOR + OFFSET; overrides match each component's border-radius.
   DO NOT remove or modify the global :focus-visible rule.
   ============================================================ */
.nav-item:focus-visible { outline-offset: -2px; border-radius: 10px; }
.btn:focus-visible { outline-offset: 2px; border-radius: 10px; }
.icon-btn:focus-visible { outline-offset: 2px; border-radius: 10px; }
.search-pill:focus-visible { outline-offset: 2px; border-radius: 10px; }
.user-chip:focus-visible { outline-offset: 2px; border-radius: 999px; }
.lang-toggle button:focus-visible { outline-offset: 2px; border-radius: 7px; }
/* .user-menu .menu-item:focus-visible already at styles.css:239 — do NOT duplicate */

/* Hamburger button base — hidden by default; revealed by mobile @media block above */
.hamburger-btn { display: none; }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--bg-4); background-clip: padding-box; border: 2px solid transparent; }

/* type */
h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; color: var(--text-1); }
h1 { font-size: var(--text-h1);      line-height: 1.15; }
h2 { font-size: var(--text-h2);      line-height: 1.25; }
h3 { font-size: var(--text-h3);      line-height: 1.30; }
h4 { font-size: var(--text-body-lg); line-height: 1.4;  }

/* ----- Type-scale utility classes (D-05) ----- */
.text-display { font-size: var(--text-display); line-height: 1.05; font-weight: 800; }
.text-h1      { font-size: var(--text-h1);      line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
.text-h2      { font-size: var(--text-h2);      line-height: 1.25; font-weight: 700; }
.text-h3      { font-size: var(--text-h3);      line-height: 1.30; font-weight: 600; }
.text-body-lg { font-size: var(--text-body-lg); line-height: 1.6;  font-weight: 400; }
.text-body    { font-size: var(--text-body);    line-height: 1.6;  font-weight: 400; }
.text-caption { font-size: var(--text-caption); line-height: 1.4;  font-weight: 500; }
.text-micro   { font-size: var(--text-micro);   line-height: 1.3;  font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; }

/* ----- RTL line-height boost (D-06) — single override block, no parallel var set ----- */
[dir="rtl"] body          { line-height: 1.60; }
[dir="rtl"] .text-display { line-height: 1.10; }
[dir="rtl"] .text-h1      { line-height: 1.20; }
[dir="rtl"] .text-h2      { line-height: 1.30; }
[dir="rtl"] .text-h3      { line-height: 1.35; }
[dir="rtl"] .text-body-lg,
[dir="rtl"] .text-body    { line-height: 1.65; }
[dir="rtl"] .text-caption { line-height: 1.45; }
[dir="rtl"] .text-micro   { line-height: 1.35; }
p { margin: 0; color: var(--text-2); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
.mono { font-family: var(--font-mono); }
/* v2.0 — LTR-run isolation helpers (numbers, IDs, latin tokens inside Arabic) */
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { direction: ltr; unicode-bidi: isolate; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ============================================================
   Phase 2 — a11y utilities (D-24 skip-link, D-26 sr-only)
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-block-start: -40px;
  inset-inline-start: 8px;
  z-index: 9999;
  background: var(--accent);
  color: var(--bg-0);
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: var(--text-body);
  transition: inset-block-start 150ms;
  text-decoration: none;
}
.skip-link:focus {
  inset-block-start: 8px;
  outline: 2px solid var(--bg-0);
  outline-offset: 2px;
}

.micro { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }

/* ============== layout shell ============== */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
}
.topbar { grid-area: topbar; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; min-width: 0; overflow-x: hidden; }

/* ============================================================
   Phase 2 — Shell breakpoints (D-04, RESEARCH §A.1)
   Mobile <640 / Tablet 640-1024 / Desktop 1024-1440 (default) / Wide >1440
   ============================================================ */

/* Wide >1440px — right-rail column added */
@media (min-width: 1440px) {
  .app {
    grid-template-columns: var(--sidebar-w) 1fr var(--right-rail-w);
    grid-template-areas:
      "topbar topbar topbar"
      "sidebar main right-rail";
  }
  .right-rail { display: block; }
}

/* Tablet 640-1024px — icon rail (sidebar collapsed) */
@media (max-width: 1024px) {
  .app { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .sidebar { width: var(--sidebar-w-collapsed); overflow: visible; }
  .right-rail { display: none; }
}

/* Mobile <640px — single column, sidebar hidden (replaced by MobileNavSheet) */
@media (max-width: 640px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar { display: none; }
  .right-rail { display: none; }
  .main { padding: 20px 16px 80px; }
  .hamburger-btn { display: inline-flex; }
  .topbar .brand .name,
  .topbar .brand .badge { display: none; }
}

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding-inline: 18px;
  background: rgba(7, 6, 11, 0.65);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  width: calc(var(--sidebar-w) - 18px);
  flex-shrink: 0;
}
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px; object-fit: cover;
  box-shadow: 0 0 0 1px var(--border-2), 0 8px 24px -10px var(--glow);
}
.brand .name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand .badge { font-size: 10px; color: var(--accent); background: rgba(177,156,255,0.12); padding: 2px 6px; border-radius: 6px; margin-inline-start: 6px; font-weight: 700; letter-spacing: 0.05em; }

.server-picker {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 150ms;
}
.server-picker:hover { border-color: var(--border-2); }
.server-picker .srv-icon { width: 28px; height: 28px; border-radius: 8px; background: var(--grad-1); display: grid; place-items: center; font-weight: 700; font-size: 12px; color: white; }
.server-picker .srv-name { font-size: 13px; font-weight: 600; }
.server-picker .srv-meta { font-size: 11px; color: var(--text-3); }

.topbar-spacer { flex: 1; }

.search-pill {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--text-3);
  font-size: 13px;
  min-width: 280px;
  cursor: text;
}
.search-pill:hover { border-color: var(--border-2); color: var(--text-2); }
.search-pill kbd {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-3);
}

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 150ms, border-color 150ms, color 150ms;
}
.icon-btn:hover { background: var(--bg-2); border-color: var(--border); color: var(--text-1); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.user-chip:hover { border-color: var(--border-2); }
.user-chip .avatar { width: 28px; height: 28px; border-radius: 999px; object-fit: cover; }
.user-chip .uname { font-size: 12px; font-weight: 600; }

/* User dropdown menu */
.user-menu .menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: start;
  font-family: inherit;
  transition: background .12s, color .12s;
}
.user-menu .menu-item:hover { background: var(--bg-3); color: var(--text-1); }
.user-menu .menu-item.danger { color: var(--danger); }
.user-menu .menu-item.danger:hover { background: rgba(248,113,113,0.10); }
.user-menu .menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ============== sidebar ============== */
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  background: rgba(13, 11, 22, 0.6);
  border-inline-end: 1px solid var(--border);
  padding: 16px 14px 12px;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar .section-title {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-4);
  padding: 16px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: background 120ms, color 120ms;
}
.nav-item:hover { background: var(--bg-2); color: var(--text-1); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(177,156,255,0.12), rgba(177,156,255,0.02));
  color: var(--text-1);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-start: -14px;
  top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--glow);
}
[dir="rtl"] .nav-item.active::before {
  border-radius: 3px 0 0 3px;
}

/* ============================================================
   Phase 2 — Sidebar collapsed mode (D-07, RESEARCH §A.3)
   .sidebar.collapsed is class-toggled by shell.jsx (Plan 05) based on viewport.
   ============================================================ */
.sidebar.collapsed .section-title { display: none; }
.sidebar.collapsed .nav-item span[aria-hidden="true"] { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; height: 48px; position: relative; }
.sidebar.collapsed .nav-ico { width: 20px; height: 20px; }
.sidebar.collapsed .section-first { border-block-start: 1px solid var(--border); }

/* Footer pill collapses to status dot + invite icon-btn only */
.sidebar.collapsed .status-pill .lat,
.sidebar.collapsed .status-pill .label,
.sidebar.collapsed .invite-bot-text { display: none; }

/* Nav-tooltip — inline-end of icon in collapsed mode (logical CSS auto-mirrors for RTL) */
.sidebar.collapsed .nav-item .nav-tooltip {
  position: absolute;
  inset-inline-start: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  font-size: var(--text-caption);
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 10px;
  white-space: nowrap;
  max-width: 160px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms;
  z-index: 100;
}
.sidebar.collapsed .nav-item:hover .nav-tooltip,
.sidebar.collapsed .nav-item:focus-visible .nav-tooltip { opacity: 1; }
/* Hide tooltip in non-collapsed mode (always in DOM but invisible) */
.sidebar:not(.collapsed) .nav-tooltip { display: none; }

.nav-item .nav-ico { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; }
.nav-item.active .nav-ico { color: var(--accent); }
.nav-item .nav-meta { margin-inline-start: auto; font-size: 10px; color: var(--text-3); }
.nav-item .badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--glow); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.status-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  box-shadow: var(--lit-edge);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
.status-pill .lat { margin-inline-start: auto; color: var(--text-3); font-family: var(--font-mono); font-size: 11px; }

/* ============== main ============== */
.main { padding: 28px 32px 80px; }
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px; gap: 24px;
}
.page-title { font-size: var(--text-h2); line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-3); margin-top: 4px; font-size: 14px; }
.breadcrumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-3); margin-bottom: 6px;
}
.breadcrumbs .crumb { color: var(--text-3); transition: color 150ms ease; }
.breadcrumbs .crumb:not(.active) { cursor: pointer; }
.breadcrumbs .crumb:not(.active):hover { color: var(--accent); text-decoration: underline; }
.breadcrumbs .crumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.breadcrumbs .crumb.active { color: var(--accent); }
.breadcrumbs .sep { opacity: 0.5; }

/* ============== components ============== */
.card {
  background: var(--surface-raised-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  position: relative;
  box-shadow: var(--surface-raised-shadow);
  transition: transform var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
}
.card.interactive { cursor: pointer; }
.card.interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--elev-3);
  border-color: var(--border-2);
}
.card.glass {
  background: rgba(20, 17, 31, 0.55);
  backdrop-filter: blur(16px);
}
.card.premium {
  background: var(--bg-1);
  background-image:
    linear-gradient(var(--bg-1), var(--bg-1)),
    linear-gradient(135deg, var(--accent), transparent 60%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  border: 1px solid transparent;
}
.card .card-title {
  font-size: 13px; font-weight: 700;
  color: var(--text-1); margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.card .card-sub { font-size: 12px; color: var(--text-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 38px;
  padding: 0 var(--space-4);
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); transition-duration: var(--motion-instant); transition-timing-function: var(--ease-spring); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: white;
  box-shadow: var(--elev-2), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover {
  box-shadow: var(--elev-3), var(--elev-glow), inset 0 1px 0 rgba(255,255,255,0.25);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg-2);
  border-color: var(--border-2);
  color: var(--text-1);
}
.btn-secondary:hover { background: var(--bg-3); border-color: var(--border-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text-1); }
.btn-danger {
  background: linear-gradient(135deg, #f87171, #c43e3e);
  color: white;
  box-shadow: 0 6px 20px -8px rgba(248,113,113,0.4);
}
.btn-danger:hover { transform: translateY(-1px); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 15px; border-radius: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.badge-purple { background: rgba(177,156,255,0.12); color: var(--accent); border-color: rgba(177,156,255,0.2); }
.badge-success { background: rgba(110,231,183,0.10); color: var(--success); border-color: rgba(110,231,183,0.2); }
.badge-warn { background: rgba(251,191,36,0.10); color: var(--warning); border-color: rgba(251,191,36,0.2); }
.badge-danger { background: rgba(248,113,113,0.10); color: var(--danger); border-color: rgba(248,113,113,0.2); }
.badge-info { background: rgba(125,211,252,0.10); color: var(--info); border-color: rgba(125,211,252,0.2); }
.badge-neutral { background: var(--bg-3); color: var(--text-3); }

.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
}
.dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot.idle { background: var(--warning); }
.dot.dnd { background: var(--danger); }

/* toggle */
.toggle {
  position: relative;
  width: 40px; height: 22px;
  background: var(--bg-3);
  border-radius: 999px;
  cursor: pointer;
  transition: background 200ms;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 16px; height: 16px;
  background: var(--text-3);
  border-radius: 50%;
  transition: transform 200ms, background 200ms;
}
.toggle.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; box-shadow: 0 0 10px var(--glow); }
.toggle.on::after { transform: translateX(18px); background: white; }
[dir="rtl"] .toggle.on::after { transform: translateX(-18px); }

/* Task 7 — honest save states. Animations live on the .toggle element (never
   ::after) so the knob's on/off transform stays intact.
   .pending = write in flight (opacity breathe, cursor progress);
   .saved   = one-shot green ring the moment the server persists. */
.toggle.pending { cursor: progress; animation: toggle-pending 900ms ease-in-out infinite; }
.toggle.saved   { animation: toggle-saved 1000ms ease-out; }
@keyframes toggle-pending { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.9; } }
@keyframes toggle-saved { 0% { box-shadow: 0 0 0 0 var(--success); } 100% { box-shadow: 0 0 0 7px transparent; } }

/* inputs */
.input, .textarea, .select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-1);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color 120ms, box-shadow 120ms;
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-2); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(177,156,255,0.15); }
.textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%238B85A8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-inline-end: 36px; cursor: pointer; }
[dir="rtl"] .select { background-position: left 12px center; padding-inline-end: 14px; padding-inline-start: 36px; }

.label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.helptext { font-size: 11.5px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }

/* table */
.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-raised-bg); box-shadow: var(--surface-raised-shadow); }
table.dt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dt thead th {
  text-align: start;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
table.dt tbody td { padding: 12px 14px; border-bottom: 1px solid var(--hairline); color: var(--text-2); vertical-align: middle; }
table.dt tbody tr { transition: background var(--motion-fast) var(--ease-out); }
table.dt tbody tr:hover { background: var(--bg-2); }
table.dt tbody tr:last-child td { border-bottom: none; }
table.dt tbody tr:last-child td { border-bottom: none; }
table.dt tbody tr:hover { background: rgba(177,156,255,0.03); }
table.dt tbody tr.zebra { background: rgba(177,156,255,0.02); }

/* metric tile */
.metric {
  background: var(--surface-raised-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--surface-raised-shadow);
  transition: transform var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
}
.metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--surface-hover-shadow);
  border-color: var(--border-2);
}
.metric::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at top right, rgba(177,156,255,0.06), transparent 60%);
  pointer-events: none;
}
.metric .m-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
.metric .m-value { font-size: var(--text-h2); font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; }
.metric .m-delta { font-size: 11.5px; color: var(--success); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.metric .m-delta.down { color: var(--danger); }
.metric .m-ico { position: absolute; top: 18px; inset-inline-end: 18px; width: 28px; height: 28px; border-radius: 8px; background: rgba(177,156,255,0.1); color: var(--accent); display: grid; place-items: center; }

/* ============= login ============= */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
  overflow: hidden;
}
@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-left { display: none; }
}
.login-left {
  position: relative;
  display: grid; place-items: center;
  padding: 40px;
  background:
    radial-gradient(ellipse 600px 600px at 50% 40%, rgba(139, 111, 232, 0.30), transparent 65%),
    radial-gradient(ellipse 400px 400px at 60% 70%, rgba(177, 156, 255, 0.18), transparent 70%),
    var(--bg-0);
  border-inline-end: 1px solid var(--border);
}
.login-portrait {
  position: relative;
  width: min(360px, 80%);
  aspect-ratio: 1;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 80px -20px var(--glow), 0 0 0 1px var(--border-2);
}
.login-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.login-glass {
  position: absolute;
  bottom: 60px; inset-inline-start: 60px;
  background: rgba(13,11,22,0.7);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 16px 20px;
  max-width: 320px;
}
.login-right { display: grid; place-items: center; padding: 40px; }
.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(13,11,22,0.7);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 36px;
  box-shadow: var(--shadow-card);
}

/* particles */
.particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.particles span {
  position: absolute;
  width: 3px; height: 3px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.4;
  box-shadow: 0 0 6px var(--glow);
  animation: float 12s ease-in-out infinite;
}
@keyframes float {
  0%,100% { transform: translateY(0) translateX(0); opacity: 0.4; }
  50% { transform: translateY(-30px) translateX(10px); opacity: 0.8; }
}

/* grids */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1180px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* server-card */
.server-card {
  background: var(--surface-raised-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  transition: transform var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-fast) var(--ease-out);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: var(--surface-raised-shadow);
}
.server-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-2);
  box-shadow: var(--surface-hover-shadow);
}
.server-card .sc-banner {
  height: 60px;
  margin: -18px -18px 0;
  background: var(--grad-1);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.server-card .sc-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 3px solid var(--bg-1);
  position: absolute;
  bottom: -16px; inset-inline-start: 14px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px;
  color: var(--text-1);
}
.server-card .sc-body { margin-top: 18px; }

/* ============================================================
   v2.0 DashboardHome — Pulse hero band, weighted primary tile,
   data-viz sparklines. Additive; scoped to dashboard classes.
   ============================================================ */
.dash-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 20px 24px; border-radius: var(--radius-lg); margin-bottom: 24px;
  background: var(--hero-band-bg);
  border: 1px solid var(--border);
  box-shadow: var(--lit-edge), var(--elev-2m);
  position: relative; overflow: hidden;
}
.dash-hero-left { display: flex; align-items: center; gap: 16px; position: relative; z-index: 2; }
.dash-hero-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; position: relative; z-index: 2; }
.dash-hero-title { font-size: var(--text-h1); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.dash-hero-sub { font-size: 13.5px; color: var(--text-3); margin-top: 3px; display: flex; align-items: center; gap: 7px; }
.dash-hero-sub .hl { color: var(--text-1); font-weight: 700; }
.pulse-label { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.pulse-label .live { width: 6px; height: 6px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 8px rgba(110,231,183,0.7); animation: dash-live-blink 2.4s var(--ease-soft) infinite; }
@keyframes dash-live-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.pulse { position: relative; overflow: hidden; width: 230px; height: 52px; border-radius: 10px; }
.pulse svg { display: block; }
.pulse .pulse-line { stroke: var(--hero-line); stroke-width: 1.5; fill: none;
  filter: drop-shadow(0 0 6px rgba(177,156,255,0.5)); }
.pulse .pulse-fill { fill: url(#dashPulseGrad); opacity: 0.6; }
.pulse .pulse-sweep { position: absolute; inset-block: 0; inline-size: 38%; inset-inline-start: -38%;
  background: linear-gradient(90deg, transparent, rgba(177,156,255,0.22), transparent);
  animation: dash-sweep 3.2s var(--ease-soft) infinite; pointer-events: none; }
@keyframes dash-sweep { 0% { transform: translateX(0); } 100% { transform: translateX(360%); } }
[dir="rtl"] .pulse .pulse-sweep { animation-name: dash-sweep-rtl; }
@keyframes dash-sweep-rtl { 0% { transform: translateX(0); } 100% { transform: translateX(-360%); } }
@media (prefers-reduced-motion: reduce) { .pulse .pulse-sweep { display: none; } }

/* weighted primary metric tile */
.metric.primary { background: var(--hero-band-bg); }
.metric.primary .m-value { font-size: 2.4rem; }
.m-context { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.m-context .m-trend { margin-top: 0; }
.dot-live { width: 6px; height: 6px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 7px rgba(110,231,183,0.7); animation: dash-live-blink 2.4s var(--ease-soft) infinite; flex-shrink: 0; }
.m-spark { opacity: 0.85; flex-shrink: 0; }
.m-trend { font-size: 11.5px; display: inline-flex; align-items: center; gap: 5px;
  color: var(--success); background: var(--success-tint); border-radius: 999px; padding: 2px 8px; }
.m-trend.flat { color: var(--text-2); background: var(--bg-3); }

/* dashboard section headers (Arabic, uppercase-tracked for latin only) */
.dash-sec-title { font-size: 12.5px; font-weight: 700; color: var(--text-3); margin: 4px 0 14px; }

@media (max-width: 640px) {
  .dash-hero { flex-direction: column; align-items: stretch; }
  .dash-hero-right { align-items: stretch; }
  .pulse { width: 100%; }
}

/* admin specific */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; gap: 24px; min-height: 70vh; }
@media (max-width: 980px) { .admin-shell { grid-template-columns: 1fr; } }
.admin-tabs {
  background: var(--surface-raised-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: calc(var(--topbar-h) + 24px);
  align-self: start;
  box-shadow: var(--surface-raised-shadow);
}
.admin-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  font-weight: 500;
  transition: background 120ms, color 120ms;
  position: relative;
}
.admin-tab:hover { background: var(--bg-2); color: var(--text-1); }
.admin-tab.active {
  background: var(--accent-tint);
  color: var(--text-1);
}
.admin-tab.active::before {
  content: ''; position: absolute; inset-inline-start: 0; inset-block: 8px;
  inline-size: 2px; border-radius: 2px; background: var(--accent);
}
.admin-tab.active .at-ico { color: var(--accent); }
.admin-tab .at-ico { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.admin-tab .at-num { margin-inline-end: 8px; font-family: var(--font-mono); font-size: 10px; color: var(--text-4); width: 14px; }
.admin-tab.active .at-num { color: var(--accent); }
.admin-tab.locked { opacity: 0.45; cursor: not-allowed; }
.admin-tab.locked:hover { background: transparent; }
.admin-tab.owner-only { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 14px; }

.admin-content {
  background: var(--surface-raised-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  min-width: 0;
  box-shadow: var(--surface-raised-shadow);
}

/* command palette / search */
.kbd { font-family: var(--font-mono); font-size: 10.5px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; color: var(--text-3); }

/* save bar */
.save-bar {
  position: sticky; bottom: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 24px;
  padding: 12px 16px;
  background: rgba(20, 17, 31, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: 0 20px 50px -20px rgba(0,0,0,0.6), 0 0 0 1px var(--border);
  z-index: 30;
}
.save-bar .save-msg { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.save-bar .save-msg .pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }

/* log stream */
.log-stream {
  background: #050409;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  height: 460px;
  overflow-y: auto;
  position: relative;
}
.log-stream::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(
    180deg,
    rgba(177,156,255,0.012) 0px,
    rgba(177,156,255,0.012) 1px,
    transparent 1px,
    transparent 3px);
  pointer-events: none;
  border-radius: 12px;
}
.log-line { display: grid; grid-template-columns: 80px 60px 1fr; gap: 10px; padding: 1px 0; }
.log-line .log-time { color: var(--text-4); }
.log-line .log-level { font-weight: 700; }
.log-line .log-msg { color: var(--text-2); word-break: break-word; }
.log-line.info .log-level { color: var(--accent); }
.log-line.warn .log-level { color: var(--warning); }
.log-line.error .log-level { color: var(--danger); }
.log-line.debug .log-level { color: var(--text-4); }
.log-line.error .log-msg { color: var(--danger); }

/* json tree */
.json-tree {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
}
.jt-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 100ms;
}
.jt-row:hover { background: var(--bg-2); }
.jt-key { color: var(--accent); font-weight: 500; }
.jt-colon { color: var(--text-4); }
.jt-string { color: var(--success); }
.jt-number { color: var(--info); }
.jt-bool { color: var(--warning); font-weight: 600; }
.jt-bracket { color: var(--text-3); }
.jt-indent { padding-inline-start: 20px; border-inline-start: 1px dashed var(--border); margin-inline-start: 10px; }
.jt-mini-input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 12px;
  width: 200px;
}
.jt-mini-input:focus { outline: none; border-color: var(--accent); }
.jt-mini-input.num { color: var(--info); }
.jt-mini-input.str { color: var(--success); }

/* file tree */
.file-tree { font-family: var(--font-mono); font-size: 12.5px; }
.ft-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-2);
}
.ft-row:hover { background: var(--bg-2); }
.ft-row.active { background: rgba(177,156,255,0.12); color: var(--accent); }
.ft-row .ft-icon { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.ft-row.active .ft-icon { color: var(--accent); }

/* discord preview */
.discord-preview {
  background: #313338;
  border-radius: 10px;
  padding: 16px;
  font-family: 'gg sans', 'Inter', sans-serif;
  color: #dbdee1;
}
.discord-msg { display: flex; gap: 12px; padding: 8px 0; }
.discord-msg .d-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--grad-1); flex-shrink: 0; display: grid; place-items: center; color: white; font-weight: 700; font-size: 14px; overflow: hidden; }
.discord-msg .d-avatar img { width: 100%; height: 100%; object-fit: cover; }
.discord-msg .d-content { flex: 1; }
.discord-msg .d-meta { display: flex; align-items: baseline; gap: 8px; }
.discord-msg .d-name { color: #fff; font-weight: 600; font-size: 14px; }
.discord-msg .d-time { font-size: 11px; color: #949ba4; }
.discord-msg .d-text { font-size: 14px; color: #dbdee1; margin-top: 2px; }
.discord-embed {
  margin-top: 6px;
  background: #2b2d31;
  border-inline-start: 4px solid var(--accent);
  border-radius: 4px;
  padding: 12px 14px;
  max-width: 480px;
}
.discord-embed .e-title { color: #fff; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.discord-embed .e-desc { font-size: 13px; color: #b5bac1; line-height: 1.45; }
.discord-card-image {
  margin-top: 10px;
  width: 100%;
  height: 200px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(7,6,11,0.85), rgba(46,31,102,0.85)),
    radial-gradient(circle at 30% 50%, rgba(177,156,255,0.3), transparent 60%);
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; padding: 0 24px; gap: 18px;
}
.discord-card-image .dc-avatar { width: 90px; height: 90px; border-radius: 50%; border: 3px solid var(--accent); overflow: hidden; flex-shrink: 0; }
.discord-card-image .dc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.discord-card-image .dc-text-1 { font-size: 14px; color: var(--accent); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.discord-card-image .dc-text-2 { font-size: 24px; color: #fff; font-weight: 700; margin-top: 4px; }
.discord-card-image .dc-text-3 { font-size: 12px; color: #c9c3e0; margin-top: 8px; }

/* tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  padding: 0 4px;
}
.tab {
  padding: 12px 22px;
  color: var(--text-3);
  background: transparent;
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
  border-radius: 8px 8px 0 0;
  position: relative;
}
.tab:hover {
  color: var(--text-1);
  background: rgba(177, 156, 255, 0.06);
}
.tab.active {
  color: var(--accent);
  background: rgba(177, 156, 255, 0.10);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 12px rgba(177, 156, 255, 0.3);
}
.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* toast */
.toast-stack { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: rgba(20, 17, 31, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow: var(--elev-3);
  min-width: 280px;
  animation: toastEnter var(--motion-base) var(--ease-out);
}
@keyframes toastEnter {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.toast .t-ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.toast.success .t-ico { background: rgba(110,231,183,0.15); color: var(--success); }
.toast.error .t-ico { background: rgba(248,113,113,0.15); color: var(--danger); }
.toast.info .t-ico { background: rgba(177,156,255,0.15); color: var(--accent); }
.toast .t-msg { font-size: 13px; color: var(--text-1); font-weight: 500; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(7,6,11,0.7);
  backdrop-filter: blur(8px);
  z-index: 150;
  display: grid; place-items: center;
  padding: 24px;
  animation: backdropFade var(--motion-fast) var(--ease-out);
}
@keyframes backdropFade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: 18px;
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--elev-modal);
  animation: modalEnter var(--motion-base) var(--ease-out);
}
@keyframes modalEnter {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

/* tooltip */
.tooltip-host { position: relative; display: inline-flex; }
.tooltip-host .tooltip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 150ms;
  z-index: 100;
}
.tooltip-host:hover .tooltip { opacity: 1; }

/* spark/chart placeholders */
.spark { width: 100%; height: 60px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 80px;
  padding-block-start: 4px; border-radius: 6px; }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--accent), rgba(107,79,216,0.35)); border-radius: 4px 4px 2px 2px; min-height: 4px;
  transition: opacity var(--motion-fast) var(--ease-out); }
.bars:hover .bar { opacity: 0.55; }
.bars .bar:hover { opacity: 1; box-shadow: 0 0 10px -2px var(--glow); }

/* divider */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* row helpers */
.row { display: flex; align-items: center; gap: 12px; }
.row.gap-sm { gap: 6px; }
.row.gap-lg { gap: 18px; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 12px; }
.col.gap-sm { gap: 6px; }
.col.gap-lg { gap: 20px; }

/* lang toggle */
.lang-toggle {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 0;
}
.lang-toggle button {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
}
.lang-toggle button.active {
  background: var(--bg-3);
  color: var(--text-1);
}

/* danger zone */
.danger-zone {
  margin-top: 20px;
  border: 1px solid rgba(248,113,113,0.3);
  background: rgba(248,113,113,0.04);
  border-radius: 14px;
  padding: 18px;
}
.danger-zone .dz-title { color: var(--danger); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }

/* RTL nav-meta align */
[dir="rtl"] .nav-item .nav-meta { margin-inline-start: auto; }

/* small util */
.muted { color: var(--text-3); }
.dim { color: var(--text-4); }
.right { margin-inline-start: auto; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* avatar */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--grad-1);
  display: grid; place-items: center;
  color: white;
  font-weight: 700;
  font-size: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.ring { box-shadow: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--accent); }

/* v2.0 — decorate preset picker cards (premium, transform/opacity motion only) */
.preset-card {
  background: var(--surface-raised-bg); color: var(--text-1);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  cursor: pointer; font-size: 13px; text-align: start;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--lit-edge);
  transition: transform var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out);
}
.preset-card:hover { transform: translateY(-2px); box-shadow: var(--surface-hover-shadow); border-color: var(--border-2); }
.preset-card:active { transform: translateY(0) scale(0.99); transition-duration: var(--motion-instant); }
.preset-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.preset-card.active { border-color: var(--accent); background: var(--accent-tint); box-shadow: var(--lit-edge), var(--elev-glow); }
.preset-card .pc-label { font-size: 11px; color: var(--text-3); font-weight: 500; }
.preset-card .pc-preview { font-size: 14px; font-weight: 600; font-family: var(--font-mono); color: var(--text-1); }
.preset-card.active .pc-preview { color: var(--accent); }

/* v2.0 — analytics range segmented control (matches segmented tabs elsewhere) */
.seg-range { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--lit-edge); }
.seg-range-btn { background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--text-3);
  padding: 6px 13px; border-radius: 8px;
  transition: color var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out); }
.seg-range-btn:hover { color: var(--text-2); }
.seg-range-btn.active { color: var(--text-1); background: var(--bg-4); box-shadow: var(--lit-edge); }
.seg-range-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* progress */
.progress { height: 6px; background: var(--viz-track, var(--bg-3)); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 3px;
  box-shadow: 0 0 8px -1px var(--glow); }

/* heatmap cells */
.heatmap { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; }
.heatmap .hm { aspect-ratio: 1; border-radius: 3px; background: var(--bg-3); }

/* sparkline area */
.sparkline { width: 100%; height: 60px; }

/* admin only banner */
.ops-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  background: linear-gradient(90deg, rgba(177,156,255,0.10), transparent);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  margin-bottom: 20px;
}
.ops-banner .ob-ico { width: 36px; height: 36px; border-radius: 10px; background: rgba(177,156,255,0.15); color: var(--accent); display: grid; place-items: center; }
.ops-banner .ob-title { font-size: 13px; font-weight: 700; color: var(--text-1); display: flex; align-items: center; gap: 8px; }
.ops-banner .ob-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* footer watermark */
.footer-mark {
  position: fixed;
  bottom: 14px; inset-inline-end: 14px;
  width: 38px; height: 38px;
  border-radius: 10px;
  overflow: hidden;
  opacity: 0.2;
  filter: grayscale(0.3);
  pointer-events: none;
  z-index: 1;
}
.footer-mark img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================
   Phase 1 — New primitive CSS (Plans 04 + 05)
   ============================================================ */

/* ----- Field wrapper (D-09 #7) ----- */
.field { margin-bottom: 14px; }
.field .label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.error-text { font-size: 11.5px; color: var(--danger); margin-top: 6px; line-height: 1.5; }
.input.error, .textarea.error, .select.error { border-color: var(--danger); }
.input.error:focus, .textarea.error:focus, .select.error:focus {
  outline: none;
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(248,113,113,0.15);
}

/* ----- Slider (D-09 #1, RESEARCH §"Cross-Browser <input type=range> Styling") ----- */
.slider-wrap { display: flex; align-items: center; gap: 12px; width: 100%; }
.slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--slider-pct, 0%),
    var(--bg-3) var(--slider-pct, 0%),
    var(--bg-3) 100%
  );
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--bg-0);
  transition: transform 120ms;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.1); }
.slider:focus::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--accent); }
.slider::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}
.slider::-moz-range-progress { background: var(--accent); height: 6px; border-radius: 3px; }
.slider:disabled { opacity: 0.55; cursor: not-allowed; }
.slider-value {
  min-width: 36px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  font-family: var(--font-mono);
}
[dir="rtl"] .slider {
  background: linear-gradient(
    to left,
    var(--accent) 0%,
    var(--accent) var(--slider-pct, 0%),
    var(--bg-3) var(--slider-pct, 0%),
    var(--bg-3) 100%
  );
  direction: rtl;
}

/* ----- ColorPicker (D-09 #2, RESEARCH §"ColorPicker — Native vs Custom") ----- */
.color-picker-wrap { position: relative; display: inline-block; }
.color-picker-trigger {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  transition: border-color 120ms, box-shadow 120ms;
}
.color-picker-trigger:hover { border-color: var(--border-2); }
.color-picker-trigger[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(177,156,255,0.15); }
.color-popover {
  position: absolute;
  inset-block-start: calc(100% + 8px);
  inset-inline-start: 0;
  z-index: 100;
  min-width: 220px;
  padding: 12px;
  background: var(--bg-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px -16px rgba(0,0,0,0.6);
}
.color-hex-input { font-family: var(--font-mono); }
.color-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-block-start: 10px;
}
.color-swatch {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms, border-color 120ms;
}
.color-swatch:hover { transform: scale(1.05); border-color: var(--border-2); }
.color-swatch.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* ----- Skeleton (D-09 #4, D-10, RESEARCH §"Skeleton Shimmer") ----- */
.skel {
  position: relative;
  background: var(--bg-2);
  border-radius: 6px;
  overflow: hidden;
}
.skel::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent 0%, rgba(177,156,255,0.08) 50%, transparent 100%);
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel.skel-circle { border-radius: 50%; }
[dir="rtl"] .skel::after { animation: shimmer-rtl 1.6s linear infinite; }
@keyframes shimmer-rtl {
  0%   { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}
.skel-card { display: flex; flex-direction: column; gap: 12px; }
.skel-row { display: flex; align-items: center; gap: 12px; }
.skel-row > .skel { height: 12px; }
.skel-metric { display: flex; flex-direction: column; gap: 8px; }
.skel-table { display: flex; flex-direction: column; gap: 8px; }
.skel-table .skel-table-row {
  display: grid;
  grid-template-columns: repeat(var(--skel-cols, 4), 1fr);
  gap: 8px;
}

/* ============================================================
   Phase 1 — Plan 05 composite primitives (D-09 #3/#5/#6/#8)
   FileUpload (UI-only per D-11) + ImagePicker + ConfirmModal + EmptyState
   ============================================================ */

/* ----- FileUpload (D-09 #3, UI-only per D-11) ----- */
.file-upload-wrap { display: flex; flex-direction: column; gap: 8px; }
.file-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  background: var(--bg-2);
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius);
  color: var(--text-3);
  cursor: pointer;
  text-align: center;
  transition: border-color 120ms, background 120ms, transform 120ms;
}
.file-upload-zone:hover { border-color: var(--accent); background: rgba(177,156,255,0.04); }
.file-upload-zone.dragging { border-color: var(--accent); background: rgba(177,156,255,0.08); transform: scale(1.01); }
.file-upload-zone.error { border-color: var(--danger); }
.file-preview-img { max-width: 240px; max-height: 200px; border-radius: var(--radius-sm); object-fit: cover; }
.file-error { font-size: 11.5px; color: var(--danger); padding-inline: 4px; line-height: 1.5; }
.file-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  padding-inline: 4px;
}
.file-meta .muted { color: var(--text-4); }

/* ----- ImagePicker (D-09 #8, dual-mode URL + Upload) ----- */
.image-picker { display: flex; flex-direction: column; gap: 10px; }
.ip-tabs {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  width: max-content;
}
.ip-tabs .tab {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  transition: color 120ms, background 120ms;
}
.ip-tabs .tab.active { background: var(--bg-3); color: var(--text-1); }
.ip-preview { display: block; margin-block-start: 10px; border: 1px solid var(--border); }
.ip-preview.square { width: 160px; height: 160px; border-radius: var(--radius); object-fit: cover; }
.ip-preview.banner { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); object-fit: cover; }

/* ----- ConfirmModal (D-09 #5, type-to-confirm; extends .modal chassis) ----- */
.confirm-modal { /* extends .modal — no positional override needed; .modal already sets max-width 480px */ }
.confirm-modal .confirm-helper {
  font-size: 11.5px;
  color: var(--text-3);
  margin-block-start: 6px;
  margin-block-end: 10px;
  line-height: 1.5;
}
.confirm-modal .confirm-input.matched { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(177,156,255,0.15); }

/* ----- EmptyState (D-09 #6, 6th mascot placement — REQ-brand-mascot) ----- */
.empty-state {
  display: grid;
  place-items: center;
  min-height: 480px;
  padding: 48px 24px;
  background:
    radial-gradient(ellipse 600px 400px at 50% 45%, rgba(177,156,255,0.20), transparent 60%),
    radial-gradient(ellipse 400px 300px at 50% 65%, rgba(107,79,216,0.12), transparent 70%);
  text-align: center;
}
.empty-state .mascot {
  width: min(240px, 50%);
  aspect-ratio: 1;
  opacity: 0.6;
  border-radius: 24px;
  margin-block-end: 24px;
}
.empty-state .es-ar { font-size: var(--text-h2);      font-weight: 700; margin-block-end: 6px; }
.empty-state .es-en { font-size: var(--text-body-lg); color: var(--text-3); margin-block-end: 16px; }
.empty-state .es-helper { font-size: var(--text-body); color: var(--text-3); margin-block-end: 28px; max-width: 420px; }
.empty-state.inline { min-height: 200px; padding: 28px 16px; background: none; }
.empty-state.inline .mascot { width: 120px; margin-block-end: 16px; }

/* ============================================================
   Phase 1 — Design System Showcase chrome (Plan 07)
   Logical CSS properties only — RTL-safe.
   ============================================================ */
.ds-root { padding-block: 24px; padding-inline: 32px; max-width: 1280px; margin-inline: auto; }
.ds-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-block-end: 24px;
  flex-wrap: wrap;
}
.ds-hero .page-title { font-size: var(--text-h1); margin-inline-end: auto; }
.ds-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ds-controls .dir-toggle,
.ds-controls .lang-toggle,
.ds-controls .live-toggle {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.ds-controls button {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  transition: color 120ms, background 120ms;
}
.ds-controls button.active { background: var(--bg-3); color: var(--text-1); }

.ds-toc {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-block-end: 24px;
  padding-block: 12px;
  border-block: 1px solid var(--border);
}
.ds-toc a {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}
.ds-toc a:hover { color: var(--accent); }

.ds-section {
  margin-block-end: 48px;
  scroll-margin-block-start: 24px;
}
.ds-section h2 {
  font-size: var(--text-h2);
  margin-block-end: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ds-primitive-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-block-end: 16px;
}
.ds-primitive-card h3 {
  font-size: var(--text-h3);
  margin-block-end: 4px;
}
.ds-primitive-card .ds-prim-meta {
  font-size: 11.5px;
  color: var(--text-3);
  margin-block-end: 16px;
}
.ds-state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-items: start;
}
.ds-state-grid .ds-cell {
  background: var(--bg-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.ds-state-grid .ds-cell .ds-cell-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-block-end: 10px;
}
.ds-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.ds-swatch-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
}
.ds-swatch-card .ds-swatch-chip {
  height: 48px;
  border-radius: var(--radius-sm);
  margin-block-end: 10px;
}
.ds-swatch-card .ds-swatch-name { font-size: 12px; font-weight: 600; }
.ds-swatch-card .ds-swatch-hex {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}
.ds-type-row {
  display: grid;
  grid-template-columns: 110px 1fr 1fr;
  gap: 16px;
  padding-block: 8px;
  border-block-end: 1px dashed var(--border);
}
.ds-type-row:last-child { border-block-end: none; }
.ds-type-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.ds-spacing-ruler { display: flex; align-items: flex-end; gap: 4px; height: 80px; }
.ds-spacing-ruler .ds-ruler-bar {
  background: var(--accent);
  width: 24px;
  border-radius: var(--radius-sm);
  position: relative;
}
.ds-spacing-ruler .ds-ruler-bar::after {
  content: attr(data-px);
  position: absolute;
  inset-block-start: 100%;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  margin-block-start: 4px;
  white-space: nowrap;
}
.ds-shadow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.ds-shadow-card { aspect-ratio: 4 / 3; background: var(--bg-1); border-radius: var(--radius); }
.ds-radius-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.ds-radius-card { width: 100px; height: 100px; background: var(--bg-2); display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }


/* ============================================================
   Phase 2 — Mobile bottom-sheet (D-06, UI-SPEC §3)
   ============================================================ */
.mobile-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.55);
  animation: fadeIn 200ms ease-out;
}

.mobile-sheet {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 91;
  width: 100vw;
  max-height: min(80vh, 80dvh);
  background: rgba(13, 11, 22, 0.97);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-radius: 18px 18px 0 0;
  border-block-start: 1px solid var(--border-2);
  box-shadow: 0 -20px 60px -10px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  transform: translateY(0);
  transition: transform 200ms ease-out;
}
.mobile-sheet.entering { transform: translateY(100%); }
.mobile-sheet .drag-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(177, 156, 255, 0.25);
  margin: 12px auto 8px;
}
.mobile-sheet-content {
  overflow-y: auto;
  padding-block-end: 16px;
}

/* ============================================================
   Phase 2 — Right rail (D-08, UI-SPEC §5)
   Hidden by default; revealed only at >1440px via the wide @media block in Zone 2.
   ============================================================ */
.right-rail {
  display: none;
  grid-area: right-rail;
  position: sticky;
  inset-block-start: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  background: rgba(13, 11, 22, 0.6);
  border-inline-start: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
}
.right-rail h4 {
  font-size: var(--text-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  margin: 0 0 16px;
  padding-block-end: 12px;
  border-block-end: 1px solid var(--border);
}

/* ============================================================
   Phase 2 — Cmd+K command palette (D-10..D-15, UI-SPEC §6)
   ============================================================ */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.60);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-block-start: 12vh;
  animation: fadeIn 150ms ease-out;
}
.cmdk-modal {
  width: min(640px, 90vw);
  max-height: 72vh;
  background: rgba(20, 17, 31, 0.98);
  border: 1px solid var(--border-2);
  border-radius: 18px;
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(177, 156, 255, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: popIn 150ms ease-out;
}
.cmdk-input-row {
  height: 60px;
  padding: 0 16px;
  border-block-end: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cmdk-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: var(--text-body-lg);
  font-weight: 400;
  color: var(--text-1);
  font-family: inherit;
}
.cmdk-input::placeholder { color: var(--text-4); }
.cmdk-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.cmdk-section-label {
  font-size: var(--text-micro);
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 10px 12px 4px;
  font-weight: 600;
}
.cmdk-section + .cmdk-section .cmdk-section-label {
  border-block-start: 1px solid var(--border);
  margin-block-start: 4px;
}
.cmdk-result-row {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: default;
  transition: background 80ms;
}
.cmdk-result-row.selected,
.cmdk-result-row:hover { background: rgba(177, 156, 255, 0.10); }
.cmdk-result-row:focus-visible { outline: none; background: rgba(177, 156, 255, 0.18); }
.cmdk-result-icon { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; }
.cmdk-cat-badge {
  font-size: var(--text-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 4px 8px;
  flex-shrink: 0;
}
.cmdk-cat-badge.nav { background: rgba(177, 156, 255, 0.12); color: var(--accent); }
.cmdk-cat-badge.action { background: rgba(107, 79, 216, 0.18); color: var(--accent-2); }
.cmdk-cat-badge.cmd { background: rgba(110, 231, 183, 0.12); color: var(--success); }
.cmdk-result-label {
  flex: 1;
  font-size: var(--text-body);
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmdk-mark {
  background: rgba(177, 156, 255, 0.25);
  color: var(--text-1);
  border-radius: 3px;
  padding: 0 2px;
}
.cmdk-kbd-hint { margin-inline-start: auto; }
.cmdk-footer {
  height: 44px;
  padding: 0 16px;
  background: var(--bg-3);
  border-block-start: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: var(--text-caption);
  color: var(--text-4);
  flex-shrink: 0;
}
.cmdk-empty {
  padding: 32px 0;
  text-align: center;
}

/* ============================================================
   Phase 2 — Toast assertive stack (D-25, UI-SPEC §9)
   Polite stack reuses Phase 1's .toast-stack; assertive stack is the new variant.
   ============================================================ */
.toast-stack-assertive {
  position: fixed;
  inset-block-end: 80px;
  inset-inline-end: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-stack-assertive > .toast { pointer-events: auto; }

/* ============================================================
   Phase 2 — Optimistic-revert inline ring (D-17, UI-SPEC §11)
   Applied by useOptimistic via a `.is-reverting` class on the failing control.
   ============================================================ */
.is-reverting {
  box-shadow: 0 0 0 1px var(--danger);
  transition: box-shadow 200ms ease-out;
}

/* ============================================================
   Phase 2 — Reduced-motion overrides (D-22, UI-SPEC §11, RESEARCH §D.1)
   SINGLE consolidated block — must be the LAST block in this file.
   Do NOT add scattered overrides anywhere else; consolidation is the contract.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  /* STOP entirely — no animation */
  .status-pill .dot { animation: none; }
  .skel::after,
  [dir="rtl"] .skel::after { animation: none; }
  .particles span { animation: none; }
  .btn-primary:hover,
  .btn-danger:hover { transform: none; }
  .server-card:hover { transform: none; box-shadow: var(--shadow-card); }
  .sidebar { transition: none; }
  .toggle::after { transition: background 200ms; }
  /* Task 7 — keep the honest-save cue but drop motion: static dim for pending, no pulse */
  .toggle.pending { animation: none; opacity: 0.6; }
  .toggle.saved { animation: none; }

  /* REPLACE motion with opacity-only fade (150ms or less) */
  .toast,
  [dir="rtl"] .toast { animation: fadeIn 150ms ease-out; }
  .modal { animation: fadeIn 150ms ease-out; }
  .mobile-sheet { animation: fadeIn 150ms ease-out; transform: none; transition: opacity 150ms ease-out; }
  .mobile-sheet-backdrop { animation: fadeIn 150ms ease-out; }
  .cmdk-modal { animation: fadeIn 100ms ease-out; transform: none; }
  .cmdk-overlay { animation: fadeIn 100ms ease-out; }
  .is-reverting { transition: none; }
  .skip-link { transition: none; }

  /* KEEP: color/border transitions are state feedback per WCAG 2.3.3 (not animation) */

  /* Phase 5 — ModuleDetailShell reduced-motion overrides */
  .mds-tab { transition: none; }
  .mds-save-bar { animation: none; }
}

/* ============= Phase 5 — ModuleDetailShell ============= */
/* v2.0 — a "primary" surface variant for weighted cards (overview hero card) */
.card.primary, .metric.primary { background: var(--hero-band-bg); }
.card.primary .card-title { color: var(--text-1); }

/* v2.0 — module card hover lift (within motion tokens) + category section rhythm */
.module-card { transition: transform var(--motion-fast) var(--ease-out),
  box-shadow var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out); }
.module-card:hover { transform: translateY(-2px); box-shadow: var(--surface-hover-shadow); border-color: var(--border-2); }
.cat-head {
  display: flex; align-items: center; gap: 10px;
  margin-block-end: 14px; padding-block-end: 10px;
  border-block-end: 1px solid var(--hairline);
}
.cat-head .cat-glyph { font-size: 15px; line-height: 1; }
.cat-head .cat-name { font-size: 13.5px; font-weight: 700; color: var(--text-2); }
.cat-head .cat-count {
  margin-inline-start: auto; font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--text-3); background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 9px;
}

.mds-shell { position: relative; padding-block-end: 96px; }

/* v2.0 — configurator settings header (module identity). Recompose only, no new data. */
.mds-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; margin-block-end: 20px;
  border-radius: var(--radius-lg);
  background: var(--hero-band-bg);
  border: 1px solid var(--border);
  box-shadow: var(--lit-edge), var(--elev-2m);
}
.mds-h-ico {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; color: var(--accent);
  background: var(--accent-tint); border: 1px solid var(--border);
  box-shadow: var(--lit-edge);
}
.mds-h-title { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.mds-h-sub { font-size: 12.5px; color: var(--text-3); margin-block-start: 3px; }
.mds-h-id {
  margin-inline-start: auto; align-self: flex-start;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-4);
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px;
}

/* v2.0 — segmented-pill tabs (was underline). Knob = a lit pill on the active tab. */
.mds-tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--lit-edge);
  margin-block-end: 24px;
}
.mds-tab {
  background: transparent; border: none;
  padding: 8px 18px;
  color: var(--text-3); cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: 8px;
  transition: color var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out);
}
.mds-tab:hover { color: var(--text-2); }
.mds-tab.active { color: var(--text-1); background: var(--bg-4); box-shadow: var(--lit-edge); }
.mds-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.mds-tab-content { min-height: 400px; }

/* v2.0 — premium sticky save bar (elevated glass + lit edge) */
.mds-save-bar {
  position: sticky; inset-block-end: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-block-start: 24px;
  padding: 14px 20px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: var(--lit-edge-strong), var(--elev-3m);
  z-index: 30;
  animation: slideInUp var(--motion-base) var(--ease-out);
}
.mds-save-msg { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 10px; }
.mds-save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning);
  box-shadow: 0 0 8px rgba(251,191,36,0.6); animation: dash-live-blink 2.4s var(--ease-soft) infinite; }
.mds-save-actions { display: flex; gap: 8px; }
@keyframes slideInUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================================================
   v1.2 — disabled state (Btn / form controls) — visible affordance
   ============================================================ */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  filter: saturate(0.6);
  box-shadow: none;
  transform: none;
}
.btn:disabled:hover,
.btn[aria-disabled="true"]:hover {
  transform: none;
  box-shadow: none;
}
.input:disabled, .textarea:disabled, .select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--bg-2);
}

/* ============================================================
   v1.2 — ConfirmModal close X (top-right corner)
   ============================================================ */
.confirm-modal { position: relative; }
.confirm-modal-close {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
}
.confirm-modal-close:hover {
  background: var(--bg-3);
  color: var(--text-1);
  border-color: var(--border-2);
}
.confirm-modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
