/* =====================================================================
   GNEX HUB — DESIGN SYSTEM
   ---------------------------------------------------------------------
   HOW THIS FILE IS ORGANISED, in plain language:

   1. STRUCTURE TOKENS — things that never change between themes:
      corner rounding, spacing, type sizes, shadows, motion timing.
   2. THE GLASS FORMULA — one number (--glass, 0..100) the user drags on
      a slider. It drives BOTH how see-through a panel is and how frosted
      it is, together, the way real glass behaves.
   3. THEME TOKENS — eight colour sets. A theme only redefines colours,
      never layout.

      *** ORDER MATTERS HERE. ***
      The :root defaults must come BEFORE every [data-gnex-theme] block.
      ":root" and "[data-gnex-theme=x]" have the SAME specificity, so
      whichever is written last wins. When the defaults were written last
      they silently overrode every other theme — the whole site stayed on
      the default colour no matter what was picked. Keep :root first.

   4. COMPONENTS — built only from the tokens above, so a new theme costs
      about ten lines and zero new component CSS.

   To change the look, edit tokens. Do not edit components.
   ===================================================================== */


/* =====================================================================
   1. STRUCTURE TOKENS  (identical in every theme)
   ===================================================================== */
:root {
  --r-card:   20px;
  --r-tile:   14px;
  --r-input:  14px;
  --r-pill:   999px;

  --sp-1: .5rem;
  --sp-2: .85rem;
  --sp-3: 1.4rem;
  --sp-4: 2.2rem;
  --sp-5: 3.2rem;

  --font-ui:   'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;   /* Persian UI  */
  --font-lat:  'Plus Jakarta Sans', 'Vazirmatn', sans-serif;   /* Latin words */
  --font-num:  'JetBrains Mono', ui-monospace, monospace;      /* readouts    */

  --t-label: .72rem;
  --t-body:  .95rem;
  --t-value: 1.35rem;
  --t-h2:    1.5rem;
  --t-h1:    clamp(1.5rem, 2.6vw, 2.1rem);

  --shadow-card: 0 20px 40px rgba(0, 0, 0, .38);
  --shadow-tile: 0 6px 18px rgba(0, 0, 0, .35);
  --rim: inset 0 1px 0 rgba(255, 255, 255, .07);

  --ease:   cubic-bezier(.4, 0, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);   /* overshoots slightly */
  --fast: .18s;
  --slow: .4s;

  /* --- 2. THE GLASS FORMULA --------------------------------------- */
  --glass: 62;
  --glass-blur:  calc(4px + (var(--glass) * 1.16px));   /*   4px .. 120px */
  --glass-alpha: calc(.10 + (var(--glass) * .0082));    /*  0.10 .. 0.92  */


  /* --- 3a. DEFAULT COLOURS = BLOOD MOON ---------------------------
     These sit on :root so a page renders in the brand colour before it
     has read the user's saved theme. MUST stay above the blocks below. */
  --ink-1: #08060A;  --ink-2: #17090C;
  --card-rgb: 30, 15, 19;
  --line: rgba(255, 205, 205, .11);
  --text: #FFFFFF;   --muted: #AE9BA0;
  --a1: #FF2D2D;     --a2: #C1121F;
  --glow-1: #7A0F16; --glow-2: #FF2D2D;
  --glow-strength: .9;
  --nav-active: #2B1014;
  --ok: #01B574;  --warn: #FFB547;  --bad: #E31A1A;
}


/* =====================================================================
   3b. THEME TOKENS — every one of these overrides the defaults above
   ===================================================================== */

/* --- Blood Moon — THE DEFAULT. True red, not orange. ------------------ */
[data-gnex-theme="bloodmoon"] {
  --ink-1: #08060A;  --ink-2: #17090C;
  --card-rgb: 30, 15, 19;
  --line: rgba(255, 205, 205, .11);
  --text: #FFFFFF;   --muted: #AE9BA0;
  --a1: #FF2D2D;     --a2: #C1121F;
  --glow-1: #7A0F16; --glow-2: #FF2D2D;
  --glow-strength: .9;
  --nav-active: #2B1014;
  --ok: #01B574;  --warn: #FFB547;  --bad: #E31A1A;
}

/* --- Vision — sampled from the reference dashboard UI ----------------- */
[data-gnex-theme="vision"] {
  --ink-1: #070C2A;  --ink-2: #0B0E31;
  --card-rgb: 15, 21, 53;
  --line: rgba(226, 232, 255, .10);
  --text: #FFFFFF;   --muted: #A0AEC0;
  --a1: #0075FF;     --a2: #21D4FD;
  --glow-1: #3546B0; --glow-2: #3993FE;
  --glow-strength: 1;
  --nav-active: #1A1F37;
  --ok: #01B574;  --warn: #FFB547;  --bad: #E31A1A;
}

/* --- Abyss — AMOLED black, monochrome, minimal glow ------------------- */
[data-gnex-theme="abyss"] {
  --ink-1: #000000;  --ink-2: #030305;
  --card-rgb: 14, 14, 18;
  --line: rgba(255, 255, 255, .09);
  --text: #FFFFFF;   --muted: #8A8A94;
  --a1: #E8E8EC;     --a2: #9A9AA6;
  --glow-1: #1C1C22; --glow-2: #2A2A32;
  --glow-strength: .22;
  --nav-active: #141418;
  --ok: #01B574;  --warn: #FFB547;  --bad: #E31A1A;
}

/* --- Moonshine — the one LIGHT theme, its own palette ----------------- */
[data-gnex-theme="moonshine"] {
  --ink-1: #EEF1F9;  --ink-2: #E2E8F5;
  --card-rgb: 255, 255, 255;
  --line: rgba(16, 26, 60, .13);
  --text: #0B1020;   --muted: #59637E;
  --a1: #2F5BEA;     --a2: #12A5E8;
  --glow-1: #B9CBEF; --glow-2: #93B4E8;
  --glow-strength: .8;
  --nav-active: #DDE5F6;
  --ok: #068A5B;  --warn: #B47510;  --bad: #C4161C;
}

/* --- Cyberpunk — from Kiyan's reference palette: a teal-and-yellow
   night city, not a black one. The ground is deep teal (05262D), the
   signage is bright yellow (FFE44B), and the cool light is pale cyan
   (A1E3D8). Gold 968445 is the dimmed/secondary tone. ------------------ */
[data-gnex-theme="cyberpunk"] {
  --ink-1: #041A20;  --ink-2: #05262D;
  --card-rgb: 8, 45, 53;
  --line: rgba(161, 227, 216, .18);
  --text: #F6F09C;   --muted: #7FAEB0;
  --a1: #FFE44B;     --a2: #A1E3D8;
  --glow-1: #0B5868; --glow-2: #968445;
  --glow-strength: 1;
  --nav-active: #0A3B46;
  --ok: #7FD6A8;  --warn: #FFE44B;  --bad: #FF6B5B;
}

/* --- Vergil — cold navy, steel blue and silver, restrained ------------ */
[data-gnex-theme="vergil"] {
  --ink-1: #05070F;  --ink-2: #0A101F;
  --card-rgb: 13, 19, 36;
  --line: rgba(199, 212, 228, .11);
  --text: #FFFFFF;   --muted: #93A0B5;
  --a1: #4A7BC8;     --a2: #C7D4E4;
  --glow-1: #22406B; --glow-2: #5C7DA8;
  --glow-strength: .5;
  --nav-active: #121A2E;
  --ok: #01B574;  --warn: #FFB547;  --bad: #E31A1A;
}

/* --- Matrix Green — black + neon green, gets the falling code --------- */
[data-gnex-theme="matrix"] {
  --ink-1: #000000;  --ink-2: #020A05;
  --card-rgb: 7, 20, 11;
  --line: rgba(0, 255, 65, .16);
  --text: #E8FFEE;   --muted: #7FA98B;
  --a1: #00FF41;     --a2: #00A82D;
  --glow-1: #04421A; --glow-2: #007A25;
  --glow-strength: .7;
  --nav-active: #081B0D;
  --ok: #01B574;  --warn: #FFB547;  --bad: #E31A1A;
}

/* --- Nightreign — navy to violet, gets the star field ----------------- */
[data-gnex-theme="nightreign"] {
  --ink-1: #0A0620;  --ink-2: #170C36;
  --card-rgb: 22, 14, 52;
  --line: rgba(198, 180, 255, .13);
  --text: #FFFFFF;   --muted: #A79BC8;
  --a1: #7B4DFF;     --a2: #4DC9FF;
  --glow-1: #4C2A9E; --glow-2: #7B4DFF;
  --glow-strength: 1;
  --nav-active: #1E1442;
  --ok: #01B574;  --warn: #FFB547;  --bad: #E31A1A;
}


/* =====================================================================
   4. BASE
   ===================================================================== */
* { box-sizing: border-box; }

html, body {
  margin: 0; min-height: 100%;
  background: var(--ink-1);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative; overflow-x: hidden;
  background:
    radial-gradient(90rem 50rem at 78% -10%, color-mix(in srgb, var(--glow-1) 55%, transparent), transparent 60%),
    radial-gradient(70rem 45rem at 10% 110%, color-mix(in srgb, var(--glow-2) 30%, transparent), transparent 62%),
    linear-gradient(180deg, var(--ink-1), var(--ink-2));
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

:focus-visible { outline: 2px solid var(--a1); outline-offset: 2px; border-radius: 6px; }

/* The interactive ambient field (assets/hub-field.js) — recolours itself
   from the active theme and is dimmed by --glow-strength. */
#hub-field { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }

.lat { font-family: var(--font-lat); direction: ltr; unicode-bidi: isolate; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }


/* =====================================================================
   5. SURFACES — the glass card, and the HUD treatment
   ===================================================================== */
.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--sp-3);
  background: linear-gradient(160deg,
    rgba(var(--card-rgb), var(--glass-alpha)),
    rgba(var(--card-rgb), calc(var(--glass-alpha) * .78)));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-card), var(--rim);
}

/* HUD corner brackets. Spend these on panels that matter — putting them
   on every card flattens the hierarchy and stops reading as a HUD. */
.hud::before, .hud::after {
  content: ''; position: absolute; width: 15px; height: 15px;
  border: 0 solid color-mix(in srgb, var(--a1) 75%, transparent);
  pointer-events: none;
}
.hud::before { top: 9px; inset-inline-start: 9px; border-top-width: 2px; border-inline-start-width: 2px; border-start-start-radius: 7px; }
.hud::after  { bottom: 9px; inset-inline-end: 9px; border-bottom-width: 2px; border-inline-end-width: 2px; border-end-end-radius: 7px; }

/* A thin monospace readout line, the "instrument label" of the system */
.readout {
  font-family: var(--font-num); font-size: .64rem; letter-spacing: .08em;
  color: color-mix(in srgb, var(--a1) 80%, var(--muted));
  direction: ltr; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: .35rem;
}
.readout::before { content: ''; width: 5px; height: 5px; background: currentColor; transform: rotate(45deg); }

.clickable { cursor: pointer; transition: transform var(--fast) var(--spring), border-color var(--fast) var(--ease); }
.clickable:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--a1) 45%, var(--line)); }
.clickable:active { transform: translateY(-1px) scale(.99); }

/* a scanline wash that only shows on hover — atmosphere, cheap to run */
.scan { position: relative; overflow: hidden; }
.scan::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0 1px, transparent 1px 3px);
  transition: opacity var(--fast) var(--ease);
}
.scan:hover::after { opacity: 1; }


/* =====================================================================
   6. LAYOUT — RTL, so grid column 1 draws on the RIGHT
   ===================================================================== */
.shell {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 258px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: var(--sp-3) var(--sp-2);
  display: flex; flex-direction: column; gap: .15rem;
  border-inline-start: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: .6rem;
  padding: .3rem .6rem var(--sp-3);
  font-weight: 700; font-size: 1.05rem;
}
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--a1), var(--a2));
  color: #fff; font-family: var(--font-lat); font-weight: 800;
  box-shadow: var(--shadow-tile);
}

.nav-label { font-size: .72rem; font-weight: 600; color: var(--muted); padding: var(--sp-2) .7rem .3rem; }

.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .7rem; border-radius: var(--r-input);
  color: var(--muted); font-size: var(--t-body);
  background: none; border: 0; width: 100%; text-align: start; cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav-item:hover { color: var(--text); background: rgba(var(--card-rgb), .5); }
.nav-item .ic {
  width: 30px; height: 30px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(var(--card-rgb), .85); border: 1px solid var(--line);
}
.nav-item.is-active { background: var(--nav-active); color: var(--text); font-weight: 600; }
.nav-item.is-active .ic {
  background: linear-gradient(135deg, var(--a1), var(--a2));
  border-color: transparent; box-shadow: var(--shadow-tile);
}
.nav-item .badge {
  margin-inline-start: auto; font-family: var(--font-num); font-size: .7rem;
  padding: .05rem .4rem; border-radius: var(--r-pill);
  background: var(--bad); color: #fff;
}

/* nested sub-navigation (Profile's own pages) */
.subnav { display: flex; flex-direction: column; gap: .1rem; padding-inline-start: 1.6rem; margin: .1rem 0 .3rem; }
.subnav button {
  background: none; border: 0; cursor: pointer; text-align: start;
  color: var(--muted); font-family: inherit; font-size: .85rem;
  padding: .3rem .6rem; border-radius: 9px;
  border-inline-start: 2px solid var(--line);
}
.subnav button:hover { color: var(--text); }
.subnav button.is-active { color: var(--text); border-inline-start-color: var(--a1); background: rgba(var(--card-rgb), .55); }

.main { padding: var(--sp-3) var(--sp-4) 7rem; min-width: 0; }

/* ---- top bar: search sits on the RIGHT (the start side in RTL) ---- */
.topbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.search {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .95rem; min-width: 17rem;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: rgba(var(--card-rgb), calc(var(--glass-alpha) * .9));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  color: var(--muted);
}
.search input { border: 0; background: none; outline: none; color: var(--text); font-family: var(--font-ui); font-size: .9rem; width: 100%; }
.search input::placeholder { color: var(--muted); }
.topbar .spacer { flex: 1; }
.crumbs { font-size: .8rem; color: var(--muted); }
.crumbs b { color: var(--text); font-weight: 600; }

.icon-btn {
  position: relative;
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--r-input); border: 1px solid var(--line);
  background: rgba(var(--card-rgb), .6); color: var(--muted); cursor: pointer;
  transition: color var(--fast) var(--ease);
}
.icon-btn:hover { color: var(--text); }
.icon-btn .dot { position: absolute; top: 6px; inset-inline-end: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }


/* =====================================================================
   7. COMPONENTS
   ===================================================================== */
.page-h1 { font-size: var(--t-h1); font-weight: 800; line-height: 1.25; margin: 0 0 var(--sp-1); text-wrap: balance; }
.page-sub { color: var(--muted); margin: 0 0 var(--sp-3); max-width: 48ch; }
.section-h { font-size: var(--t-h2); font-weight: 800; margin: 0 0 var(--sp-2); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.stack { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ---- gradient icon tile ---- */
.tile {
  width: 44px; height: 44px; flex: none; border-radius: var(--r-tile);
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--a1), var(--a2));
  color: #fff; box-shadow: var(--shadow-tile);
}
[data-gnex-theme="matrix"] .tile,
[data-gnex-theme="cyberpunk"] .tile,
[data-gnex-theme="abyss"] .tile { color: #05262D; }

/* ---- stat card ---- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); gap: var(--sp-2); }
.stat { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); }
.stat .k { font-size: var(--t-label); color: var(--muted); display: block; }
.stat .v { font-size: var(--t-value); font-weight: 700; }
.delta { font-size: .82rem; font-weight: 700; margin-inline-start: .35rem; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.05rem; border: 0; border-radius: var(--r-input);
  background: linear-gradient(135deg, var(--a1), var(--a2));
  color: #fff; font-weight: 700; font-size: .88rem; cursor: pointer;
  box-shadow: inset 0 -2px 6px rgba(0,0,0,.22), var(--shadow-tile);
  transition: transform var(--fast) var(--spring), filter var(--fast) var(--ease);
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn.sm { padding: .32rem .75rem; font-size: .78rem; border-radius: 10px; }
.btn.ghost { background: rgba(var(--card-rgb), .7); border: 1px solid var(--line); color: var(--text); box-shadow: none; }
.btn.ok { background: linear-gradient(135deg, #01B574, #00D68F); color: #04241A; }
[data-gnex-theme="matrix"] .btn:not(.ghost):not(.ok),
[data-gnex-theme="cyberpunk"] .btn:not(.ghost):not(.ok),
[data-gnex-theme="abyss"] .btn:not(.ghost):not(.ok) { color: #05262D; }

/* ---- chips ---- */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .16rem .55rem; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .55);
  font-size: .74rem; color: var(--muted);
}
.chip.match { border-color: color-mix(in srgb, var(--a1) 55%, transparent); color: var(--text); background: color-mix(in srgb, var(--a1) 18%, transparent); }
.chip.rank { font-family: var(--font-num); font-size: .7rem; }

/* rank medal — competitive identity, coloured by tier not by theme */
.medal {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .2rem .55rem .2rem .3rem; border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--tier, #8892a6) 45%, transparent);
  background: color-mix(in srgb, var(--tier, #8892a6) 15%, transparent);
  font-family: var(--font-num); font-size: .7rem; color: var(--text); direction: ltr;
}
.medal::before {
  content: ''; width: 14px; height: 14px; flex: none;
  background: linear-gradient(135deg, var(--tier, #8892a6), color-mix(in srgb, var(--tier, #8892a6) 40%, #fff));
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

/* ---- presence ---- */
.live { display: inline-flex; align-items: center; gap: .35rem; font-size: .74rem; color: var(--ok); }
.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

.avatar {
  border-radius: 15px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--a1), var(--a2));
  color: #fff; font-weight: 700; font-family: var(--font-lat);
  width: 46px; height: 46px; font-size: 1rem; position: relative;
}
.avatar.sm { width: 32px; height: 32px; font-size: .78rem; border-radius: 11px; }
.avatar.lg { width: 88px; height: 88px; font-size: 1.9rem; border-radius: 24px; }
/* the pulsing ring means "in a match right now" */
.avatar.playing::after {
  content: ''; position: absolute; inset: -4px; border-radius: inherit;
  border: 2px solid var(--ok); animation: ring 2.2s var(--ease) infinite;
}
@keyframes ring { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(1.07); } }

/* ---- compact player card: name, game, follow. Nothing else. ---- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.75rem, 1fr)); gap: .6rem; }
.pcard {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .7rem; border-radius: var(--r-input);
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .5);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * .5));
  backdrop-filter: blur(calc(var(--glass-blur) * .5));
  min-width: 0;
}
/* name over game, each on its own line — these are spans, so they need
   display:block or they sit side by side and read as one run of text. */
.pcard .nm, .pcard .gm { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .nm { font-size: .88rem; font-weight: 600; line-height: 1.35; }
.pcard .gm { font-size: .72rem; line-height: 1.3; color: var(--muted); font-family: var(--font-lat); direction: rtl; text-align: start; }
.pcard .who { min-width: 0; flex: 1; }
.pcard .btn.sm { flex: none; }

/* ---- Twitter-style cover + avatar (profile drawer and profile page) ---- */
.cover {
  position: relative; height: 132px; border-radius: var(--r-card) var(--r-card) 0 0;
  background: linear-gradient(120deg, var(--a1), var(--a2));
  background-size: cover; background-position: center; overflow: hidden;
}
.cover .edit {
  position: absolute; inset-block-end: .6rem; inset-inline-end: .6rem;
  font-size: .7rem; padding: .25rem .6rem; border-radius: var(--r-pill);
  background: rgba(0,0,0,.45); color: #fff; border: 1px solid rgba(255,255,255,.25); cursor: pointer;
}
.cover-avatar { margin-top: -46px; padding-inline: var(--sp-3); position: relative; }
.cover-avatar .avatar.lg { border: 4px solid rgba(var(--card-rgb), .96); }

/* ---- room / game tiles ---- */
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: var(--sp-2); }
.room {
  position: relative; overflow: hidden; padding: 0;
  border-radius: var(--r-card); border: 1px solid var(--line);
  background: rgba(var(--card-rgb), .55); cursor: pointer;
}
.room .art { height: 78px; background: linear-gradient(135deg, var(--a1), var(--a2)); position: relative; }
.room .art::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.35), transparent 55%),
              repeating-linear-gradient(115deg, rgba(0,0,0,.18) 0 6px, transparent 6px 14px);
}
.room .rb { padding: .6rem .8rem .8rem; }
.room .rn { font-family: var(--font-lat); font-weight: 700; font-size: .95rem; direction: ltr; }

/* ---- chat ---- */
.msg { display: flex; gap: .7rem; padding: .45rem 0; }
.msg .who { font-size: .82rem; font-weight: 700; }
.msg .when { font-size: .68rem; color: var(--muted); margin-inline-start: .4rem; font-family: var(--font-num); }
.msg p { margin: .1rem 0 0; font-size: .92rem; }

.composer {
  display: flex; align-items: center; gap: .5rem; margin-top: var(--sp-2);
  padding: .4rem .4rem .4rem .9rem;
  border: 1px solid var(--line); border-radius: var(--r-pill); background: rgba(var(--card-rgb), .5);
}
.composer input { flex: 1; border: 0; background: none; outline: none; color: var(--text); font-family: var(--font-ui); font-size: .9rem; }
.composer input::placeholder { color: var(--muted); }
.composer button { width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%; background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; display: grid; place-items: center; cursor: pointer; }

/* ---- matchmaking party rows ---- */
.party { display: flex; align-items: center; gap: var(--sp-2); padding: .65rem var(--sp-2); border-radius: var(--r-input); border: 1px solid var(--line); background: rgba(var(--card-rgb), .45); cursor: pointer; }
.party:hover { border-color: color-mix(in srgb, var(--a1) 45%, var(--line)); }
.slots { display: flex; gap: .35rem; }
.slot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--muted) 55%, transparent); background: transparent; }
.slot.waiting { background: var(--warn); border-color: var(--warn); box-shadow: 0 0 10px color-mix(in srgb, var(--warn) 60%, transparent); }
.slot.ready { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 10px color-mix(in srgb, var(--ok) 60%, transparent); }
.party .meta { color: var(--muted); font-size: .78rem; margin-inline-start: auto; }

/* ---- the always-present matchmaking button ---- */
.fab {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); z-index: 40;
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .78rem 1.6rem; border: 0; border-radius: var(--r-pill);
  background: linear-gradient(135deg, #01B574, #00D68F);
  color: #04241A; font-weight: 800; font-size: .95rem; cursor: pointer;
  box-shadow: 0 12px 34px rgba(1,181,116,.42), inset 0 -2px 6px rgba(0,0,0,.18);
  transition: transform var(--fast) var(--spring);
}
.fab:hover { transform: translateX(-50%) translateY(-2px); }

/* =====================================================================
   THE PARTY DOCK — bottom-left, collapsed to a square, expands on hover
   ===================================================================== */
.dock {
  position: fixed; bottom: 1.4rem; inset-inline-end: 1.4rem; z-index: 45;
  border-radius: var(--r-input); border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(var(--card-rgb), .95), rgba(var(--card-rgb), .8));
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  overflow: hidden; cursor: pointer;
  width: 5.4rem; transition: width var(--slow) var(--spring);
}
.dock:hover, .dock:focus-within { width: 15rem; }
.dock .head { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; }
.dock .head .lbl { font-size: .72rem; font-weight: 700; white-space: nowrap; }
.dock .head .slots { flex: none; }
.dock .head .slot { width: 9px; height: 9px; border-width: 1.5px; }
.dock .members { display: none; padding: 0 .7rem .6rem; }
.dock:hover .members, .dock:focus-within .members { display: block; }
.dock .mem { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; font-size: .8rem; white-space: nowrap; }
.dock .mem .st { margin-inline-start: auto; font-size: .66rem; color: var(--muted); font-family: var(--font-num); }
.dock .empty { font-size: .74rem; color: var(--muted); padding-bottom: .3rem; }

/* =====================================================================
   OVERLAYS — profile drawer, messages, matchmaking sheet
   ===================================================================== */
.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity var(--fast) var(--ease);
}
.scrim.open { opacity: 1; pointer-events: auto; }

/* profile drawer: slides in from the start edge (right, in RTL) */
.drawer {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 70;
  width: min(26rem, 100%);
  background: linear-gradient(200deg, rgba(var(--card-rgb), .98), rgba(var(--card-rgb), .92));
  -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px);
  border-inline-end: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  /* Closed state. inset-inline-start already resolves to the right edge in
     RTL, so only the transform's SIGN flips — overriding the inset too
     parked the closed drawer in the middle of the screen, where it
     silently swallowed clicks meant for the page. visibility is the
     belt-and-braces: a closed drawer can never intercept a pointer. */
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform var(--slow) var(--ease), visibility 0s linear var(--slow);
  overflow-y: auto;
}
[dir="rtl"] .drawer { transform: translateX(100%); }
.drawer.open { transform: translateX(0); visibility: visible; transition-delay: 0s; }

.drawer .close, .sheet .close, .msgs .close {
  position: absolute; top: .8rem; inset-inline-start: .8rem; z-index: 5;
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(0,0,0,.5); color: #fff; cursor: pointer; display: grid; place-items: center;
}

/* The messages panel's own sidebar sits on the inline-start edge, so its
   close button goes to the opposite corner or it lands on the header. */
.msgs .close { inset-inline-start: auto; inset-inline-end: .8rem; }

.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.kv > div { border: 1px solid var(--line); border-radius: var(--r-input); padding: .5rem .6rem; background: rgba(var(--card-rgb), .5); }
.kv .k { font-size: .66rem; color: var(--muted); display: block; }
.kv .v { font-size: .95rem; font-weight: 700; font-family: var(--font-num); }

/* messages: a full platform, not a page. 95% of the viewport. */
.msgs {
  position: fixed; inset: 2.5vh 2.5vw; z-index: 70;
  display: none; grid-template-columns: 16rem 1fr 13rem;
  border-radius: var(--r-card); overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(var(--card-rgb), .97), rgba(var(--card-rgb), .9));
  -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px);
  box-shadow: 0 40px 90px rgba(0,0,0,.55);
}
.msgs.open { display: grid; }
.msgs .col { min-width: 0; display: flex; flex-direction: column; }
.msgs .col + .col { border-inline-start: 1px solid var(--line); }
.msgs .col-h { padding: .8rem var(--sp-2); border-bottom: 1px solid var(--line); font-weight: 700; font-size: .9rem; flex: none; }
.msgs .col-b { overflow-y: auto; padding: .6rem var(--sp-2); flex: 1; }
.msgs .conv {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  padding: .45rem .55rem; border-radius: 11px; border: 0; background: none;
  color: var(--muted); cursor: pointer; text-align: start; font-family: inherit; font-size: .85rem;
}
.msgs .conv:hover { background: rgba(var(--card-rgb), .8); color: var(--text); }
.msgs .conv.is-active { background: var(--nav-active); color: var(--text); font-weight: 600; }
.msgs .conv .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msgs .grp { font-size: .68rem; color: var(--muted); padding: .6rem .55rem .25rem; font-weight: 600; }

/* matchmaking bottom sheet: 95% tall, slides up */
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 70; height: 95vh;
  border-radius: var(--r-card) var(--r-card) 0 0;
  border: 1px solid var(--line); border-bottom: 0;
  background: linear-gradient(180deg, rgba(var(--card-rgb), .97), rgba(var(--card-rgb), .93));
  -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px);
  transform: translateY(100%); visibility: hidden;
  transition: transform var(--slow) var(--ease), visibility 0s linear var(--slow);
  overflow-y: auto; padding: var(--sp-4) var(--sp-4) var(--sp-5);
}
.sheet.open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
.sheet .grip { width: 44px; height: 4px; border-radius: 3px; background: var(--line); margin: 0 auto var(--sp-3); }

/* ---- live activity ticker ---- */
.ticker { overflow: hidden; border-radius: var(--r-pill); border: 1px solid var(--line); background: rgba(var(--card-rgb), .5); padding: .35rem 0; }
.ticker .track { display: flex; gap: var(--sp-4); width: max-content; animation: slide 38s linear infinite; }
.ticker .it { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.ticker .it b { color: var(--text); font-weight: 600; }
@keyframes slide { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---- form fields ---- */
.field { margin-bottom: var(--sp-2); }
.field label { display: block; font-size: var(--t-label); color: var(--muted); margin-bottom: .3rem; }
.field input, .field textarea, .field select {
  width: 100%; padding: .65rem .9rem; border-radius: var(--r-input);
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .6);
  color: var(--text); font-family: var(--font-ui); font-size: .92rem;
}
.field .hint { font-size: .74rem; color: var(--muted); margin: .3rem 0 0; }


/* =====================================================================
   8. NEW COMPONENTS
   ===================================================================== */

/* ---- notifications dropdown (the bell) ---- */
/* The bell sits at the far inline-end of the top bar, so a panel anchored
   to its inline-START opens off the edge of the screen and gets clipped.
   Anchoring to the END makes it open inward, and the max-width keeps it
   inside the viewport at any size. */
.pop {
  position: absolute; top: calc(100% + .5rem); inset-inline-end: 0; z-index: 80;
  width: 20rem; max-width: calc(100vw - 1.5rem);
  max-height: 24rem; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--r-card);
  background: linear-gradient(160deg, rgba(var(--card-rgb), .98), rgba(var(--card-rgb), .93));
  -webkit-backdrop-filter: blur(28px); backdrop-filter: blur(28px);
  box-shadow: var(--shadow-card); padding: .5rem;
  display: none;
}
.pop.open { display: block; }
.pop .ph { font-size: .78rem; font-weight: 700; padding: .3rem .5rem .5rem; color: var(--muted); }
.note-item { display: flex; gap: .6rem; padding: .55rem; border-radius: 11px; cursor: pointer; }
.note-item:hover { background: rgba(var(--card-rgb), .9); }
.note-item .nt { font-size: .84rem; font-weight: 600; }
.note-item .nd { font-size: .76rem; color: var(--muted); }
.note-item .nw { font-size: .66rem; color: var(--muted); font-family: var(--font-num); margin-inline-start: auto; }
.note-item.unread { border-inline-start: 2px solid var(--a1); }

/* ---- status toggle: bottom-right, the user sets it themselves ---- */
.status-dock { position: fixed; bottom: 1.4rem; inset-inline-start: 1.4rem; z-index: 45; }
.status-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .85rem; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: linear-gradient(160deg, rgba(var(--card-rgb), .95), rgba(var(--card-rgb), .8));
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card); color: var(--text); font-size: .8rem; font-weight: 600;
}
.st-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.st-online  { background: var(--ok);   box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.st-away    { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }
.st-offline { background: #7C7C86; }
.status-menu {
  position: absolute; bottom: calc(100% + .5rem); inset-inline-start: 0;
  width: 11rem; padding: .35rem; display: none;
  border: 1px solid var(--line); border-radius: var(--r-input);
  background: linear-gradient(160deg, rgba(var(--card-rgb), .98), rgba(var(--card-rgb), .92));
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  box-shadow: var(--shadow-card);
}
.status-menu.open { display: block; }
.status-menu button {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .45rem .6rem; border: 0; border-radius: 9px; cursor: pointer;
  background: none; color: var(--muted); font-family: inherit; font-size: .82rem; text-align: start;
}
.status-menu button:hover { background: rgba(var(--card-rgb), .9); color: var(--text); }

/* ---- party dock gets a leave button on hover ---- */
.dock .leave {
  display: none; width: 100%; margin-top: .4rem;
  padding: .35rem; border-radius: 9px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  color: color-mix(in srgb, var(--bad) 25%, var(--text));
  font-family: inherit; font-size: .74rem; font-weight: 600;
}
.dock:hover .leave, .dock:focus-within .leave { display: block; }

/* ---- generated room art. --h is a per-room hue so every game reads as
   a different place. Admins replace these with real uploaded art. ---- */
.room .art {
  height: 88px; position: relative;
  background:
    radial-gradient(circle at 25% 15%, hsl(calc(var(--h) + 30) 85% 60% / .55), transparent 55%),
    linear-gradient(135deg, hsl(var(--h) 55% 22%), hsl(calc(var(--h) + 45) 60% 38%));
}
.room .art::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg, rgba(0,0,0,.22) 0 7px, transparent 7px 17px);
  mix-blend-mode: overlay;
}
.room .art .tag {
  position: absolute; inset-block-end: .4rem; inset-inline-start: .5rem;
  font-family: var(--font-num); font-size: .6rem; letter-spacing: .06em;
  padding: .1rem .4rem; border-radius: 5px; background: rgba(0,0,0,.55); color: #fff;
}

/* ---- Tinder-style discovery card ---- */
.swipe-wrap { display: grid; place-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; }
.swipe {
  width: min(27rem, 100%); border-radius: 26px; overflow: hidden; padding: 0;
  border: 1px solid var(--line);
  background: linear-gradient(170deg, rgba(var(--card-rgb), var(--glass-alpha)), rgba(var(--card-rgb), calc(var(--glass-alpha) * .8)));
  -webkit-backdrop-filter: blur(var(--glass-blur)); backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-card), var(--rim);
  animation: dealIn .32s var(--spring);
}
@keyframes dealIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.swipe .cover { height: 150px; border-radius: 0; }
.swipe .body { padding: 0 var(--sp-3) var(--sp-3); }
.swipe h2 { margin: .4rem 0 .1rem; font-size: 1.5rem; }
.swipe .sub { color: var(--muted); font-size: .85rem; margin: 0 0 var(--sp-2); }
.swipe-actions { display: flex; gap: .6rem; justify-content: center; }
.round {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .8); color: var(--muted);
  cursor: pointer; transition: transform var(--fast) var(--spring), color var(--fast) var(--ease);
}
.round:hover { transform: scale(1.08); color: var(--text); }
.round.big { width: 62px; height: 62px; border: 0; background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; box-shadow: var(--shadow-tile); }
.chip.tappable { cursor: pointer; }
.chip.tappable:hover { border-color: color-mix(in srgb, var(--a1) 55%, transparent); color: var(--text); }

/* ---- chat extras: pins, reactions, embeds, typing ---- */
.pinned {
  display: flex; align-items: center; gap: .5rem; font-size: .78rem;
  padding: .45rem .7rem; margin-bottom: .5rem;
  border-radius: var(--r-input); border: 1px dashed color-mix(in srgb, var(--a1) 45%, transparent);
  background: color-mix(in srgb, var(--a1) 10%, transparent); color: var(--muted);
}
.pinned b { color: var(--text); font-weight: 600; }
.msg { position: relative; }
.msg .acts { display: none; gap: .2rem; position: absolute; top: 0; inset-inline-end: 0; }
.msg:hover .acts { display: flex; }
.msg .acts button {
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .95);
  color: var(--muted); display: grid; place-items: center; font-size: .72rem;
}
.msg .acts button:hover { color: var(--text); }
.reacts { display: flex; gap: .25rem; margin-top: .3rem; }
.react {
  display: inline-flex; align-items: center; gap: .2rem; cursor: pointer;
  padding: .05rem .4rem; border-radius: var(--r-pill); font-size: .72rem;
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .7); color: var(--muted);
}
.react.mine { border-color: color-mix(in srgb, var(--a1) 55%, transparent); color: var(--text); background: color-mix(in srgb, var(--a1) 15%, transparent); }
.reply-to {
  font-size: .72rem; color: var(--muted); border-inline-start: 2px solid var(--line);
  padding-inline-start: .5rem; margin-bottom: .15rem;
}
.embed {
  display: flex; gap: .6rem; align-items: center; margin-top: .4rem; max-width: 22rem;
  padding: .5rem; border-radius: var(--r-input);
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .75);
}
.embed .thumb { width: 46px; height: 46px; border-radius: 9px; flex: none; display: grid; place-items: center; color: #fff; }
.embed .et { font-size: .82rem; font-weight: 600; }
.embed .es { font-size: .72rem; color: var(--muted); }
.typing { font-size: .74rem; color: var(--muted); padding: .2rem .3rem; }

/* member list grouped by what people are playing */
.mgroup { font-size: .68rem; color: var(--muted); font-weight: 600; padding: .7rem .55rem .25rem; display: flex; gap: .35rem; align-items: center; }
.mgroup .n { font-family: var(--font-num); opacity: .8; }
.conv .st2 { font-size: .66rem; color: var(--muted); display: block; }
.icon-mini {
  width: 22px; height: 22px; border-radius: 7px; cursor: pointer; flex: none;
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .8);
  color: var(--muted); display: grid; place-items: center; margin-inline-start: auto;
}
.icon-mini:hover { color: var(--text); border-color: color-mix(in srgb, var(--a1) 50%, transparent); }

/* ---- blog ---- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--sp-2); }
.post { padding: 0; overflow: hidden; cursor: pointer; }
.post .art { height: 110px; }
.post .pb { padding: .7rem var(--sp-2) var(--sp-2); }
.post h3 { margin: 0 0 .2rem; font-size: .98rem; line-height: 1.45; }
.post .meta { font-size: .72rem; color: var(--muted); font-family: var(--font-num); }
.feature { display: grid; grid-template-columns: 1.1fr .9fr; gap: 0; padding: 0; overflow: hidden; }
@media (max-width: 900px) { .feature { grid-template-columns: 1fr; } }
.feature .art { min-height: 210px; }
.feature .fb { padding: var(--sp-3); }
.social { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
.social .sq { position: relative; aspect-ratio: 1; border-radius: var(--r-input); overflow: hidden; cursor: pointer; border: 1px solid var(--line); }
.social .sq .pin { position: absolute; top: .35rem; inset-inline-start: .35rem; font-size: .6rem; padding: .1rem .35rem; border-radius: 5px; background: rgba(0,0,0,.6); color: #fff; font-family: var(--font-num); }
.social .sq .plat { position: absolute; bottom: .35rem; inset-inline-end: .35rem; font-size: .62rem; color: #fff; background: rgba(0,0,0,.55); padding: .1rem .35rem; border-radius: 5px; }

/* block editor (admin) */
.blocks { display: flex; flex-direction: column; gap: .45rem; }
.blk { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--r-input); background: rgba(var(--card-rgb), .55); cursor: grab; }
.blk .bt { font-family: var(--font-num); font-size: .64rem; color: var(--a1); border: 1px solid var(--line); border-radius: 5px; padding: .05rem .35rem; }
.blk .bx { flex: 1; font-size: .84rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk .bo { display: flex; gap: .25rem; }

/* admin tiles */
.adm { display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: var(--sp-2); }
.adm .card { cursor: pointer; }
.adm h3 { margin: .5rem 0 .15rem; font-size: .98rem; }
.adm p { margin: 0; font-size: .78rem; color: var(--muted); }
.role-pill { font-family: var(--font-num); font-size: .62rem; padding: .1rem .4rem; border-radius: 5px; border: 1px solid color-mix(in srgb, var(--a1) 50%, transparent); color: var(--a1); }

/* ---- mobile top bar (hidden on desktop) ---- */
.mobile-bar { display: none; }

/* The menu's own scrim. It has to live INSIDE .shell: .shell sets
   z-index:1, which creates a stacking context, so the sidebar's z-index
   can never beat a scrim that sits outside .shell — the page-level scrim
   was painting ON TOP of the open menu and blurring it. This one is a
   sibling of the sidebar, so 77 < 78 and the menu stays sharp. */
.menu-scrim { display: none; }

/* the floating controls would otherwise stay sharp above the blur */
.wrap.menu-open .fab,
.wrap.menu-open .dock,
.wrap.menu-open .status-dock { opacity: 0; pointer-events: none; transition: opacity var(--fast) var(--ease); }

/* =====================================================================
   9. RESPONSIVE — the sidebar becomes an overlay menu, it never stacks
   ===================================================================== */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }

  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
    position: sticky; top: 0; z-index: 50;
    padding: .6rem var(--sp-2); margin: calc(var(--sp-3) * -1) calc(var(--sp-2) * -1) var(--sp-2);
    border-bottom: 1px solid var(--line);
    background: rgba(var(--card-rgb), .9);
    -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  }

  .menu-scrim {
    display: block; position: fixed; inset: 0; z-index: 77;
    background: rgba(0, 0, 0, .58);
    -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px);
    opacity: 0; pointer-events: none; transition: opacity var(--fast) var(--ease);
  }
  .menu-scrim.open { opacity: 1; pointer-events: auto; }

  /* the menu slides in over the page instead of pushing it down */
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 78;
    width: min(17.5rem, 84%); border-inline-start: 1px solid var(--line);
    background: linear-gradient(200deg, rgba(var(--card-rgb), .98), rgba(var(--card-rgb), .93));
    -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px);
    box-shadow: var(--shadow-card);
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--slow) var(--ease), visibility 0s linear var(--slow);
    overflow-y: auto;
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); visibility: visible; transition-delay: 0s; }

  .main { padding: var(--sp-3) var(--sp-2) 7rem; }
  .topbar .crumbs { display: none; }
  .search { min-width: 0; flex: 1; }
  .msgs { inset: 0; border-radius: 0; grid-template-columns: 1fr; }
  .msgs .col.side, .msgs .col.members { display: none; }
  .drawer { width: 100%; }
  .status-dock, .dock { bottom: 5.2rem; }
}

@media (max-width: 640px) {
  .pop { position: fixed; top: 4.6rem; inset-inline: .75rem; width: auto; max-width: none; }
}

/* =====================================================================
   9. REDUCED MOTION
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* =====================================================================
   10. PUBLIC / AUTH CHROME — the prototype only covers the logged-in
   dashboard shell (sidebar + topbar). Pages that exist before that shell
   is relevant (sign-in, sign-up, plain error pages) need their own small,
   token-built vocabulary. Same rule as everywhere else: built only from
   the tokens in section 1-3, no new colours invented here.
   ===================================================================== */

/* A simple top bar for pages that aren't inside the dashboard shell yet. */
.pub-topbar {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); padding: var(--sp-2) var(--sp-4);
}
.pub-topbar .brand { padding: 0; }
.pub-topbar nav { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); font-size: .88rem; color: var(--muted); }
.pub-topbar nav a, .pub-topbar nav span { white-space: nowrap; }
.pub-topbar nav a { color: var(--text); font-weight: 600; }
.pub-topbar nav a:hover { color: var(--a1); }

/* Narrow phones: the full brand name + nav links don't fit on one row —
   let the nav drop to its own row under the brand instead of squeezing
   a two-word link like "ساخت حساب" into wrapping mid-phrase. */
@media (max-width: 420px) {
  .pub-topbar { justify-content: center; text-align: center; }
  .pub-topbar nav { width: 100%; justify-content: center; }
}

/* Centres a single card vertically for sign-in / sign-up / error pages. */
.auth-wrap {
  position: relative; z-index: 1;
  min-height: calc(100vh - 4.5rem);
  display: grid; place-items: center;
  padding: var(--sp-3) var(--sp-2) var(--sp-5);
}
.auth-card { width: min(24rem, 100%); }
.auth-card h1 { margin: 0 0 .3rem; font-size: var(--t-h1); font-weight: 800; line-height: 1.25; }
.auth-card .sub { color: var(--muted); margin: 0 0 var(--sp-3); font-size: .9rem; }
.auth-card .switch { margin: var(--sp-3) 0 0; text-align: center; font-size: .86rem; color: var(--muted); }
.auth-card .switch a { color: var(--a1); font-weight: 600; }

/* Inline error/notice banner — forms, admin actions, anywhere a plain-
   language result needs to sit above or below a form. */
.alert {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .65rem .85rem; margin-bottom: var(--sp-2);
  border-radius: var(--r-input); font-size: .86rem; line-height: 1.6;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--text);
}
.alert.ok {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}

/* ---- CSS-only tabs (radio + label trick) — no JS, so no CSP exception
   needed. Used by the owner's builder panel; reusable anywhere else a
   simple two/three-way tab switch is needed. ---- */
.tab-radio { position: absolute; opacity: 0; pointer-events: none; }
.tab-bar { display: flex; gap: .5rem; margin-bottom: var(--sp-3); flex-wrap: wrap; }
.tab-btn {
  padding: .5rem 1.1rem; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .6);
  color: var(--muted); cursor: pointer; font-size: .85rem; font-weight: 600;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.tab-panel { display: none; }
#tab-theme:checked ~ .tab-panel#panel-theme,
#tab-strings:checked ~ .tab-panel#panel-strings { display: block; }
#tab-theme:checked ~ .tab-bar label[for="tab-theme"],
#tab-strings:checked ~ .tab-bar label[for="tab-strings"] {
  background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; border-color: transparent;
}

/* ---- theme swatch radio cards (builder panel) ---- */
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .6rem; margin-bottom: var(--sp-3); }
.swatch-radio { position: absolute; opacity: 0; pointer-events: none; }
.swatch-card {
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  padding: .55rem .7rem; border-radius: var(--r-input); border: 1px solid var(--line);
  background: rgba(var(--card-rgb), .5); font-size: .82rem; color: var(--muted);
}
.swatch-dot { width: 22px; height: 22px; border-radius: 8px; flex: none; box-shadow: var(--shadow-tile); }
.swatch-radio:checked + .swatch-card { border-color: color-mix(in srgb, var(--a1) 55%, transparent); color: var(--text); background: color-mix(in srgb, var(--a1) 14%, transparent); }

/* ---- builder content-editor rows ---- */
.builder-group { margin-bottom: var(--sp-4); }
.builder-group h3 { font-size: 1rem; margin: 0 0 var(--sp-2); }
.builder-row { display: grid; grid-template-columns: 14rem 1fr; gap: var(--sp-2); align-items: start; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.builder-row label { font-size: .8rem; color: var(--muted); padding-top: .55rem; }
.builder-row input[type="text"], .builder-row textarea {
  width: 100%; padding: .55rem .8rem; border-radius: var(--r-input);
  border: 1px solid var(--line); background: rgba(var(--card-rgb), .6);
  color: var(--text); font-family: var(--font-ui); font-size: .88rem;
}
.builder-row textarea { min-height: 4.2rem; resize: vertical; }
@media (max-width: 700px) { .builder-row { grid-template-columns: 1fr; } .builder-row label { padding-top: 0; } }

.color-row { display: flex; align-items: center; gap: var(--sp-2); padding: .5rem 0; border-bottom: 1px solid var(--line); }
.color-row label { flex: 1; font-size: .85rem; color: var(--muted); }
.color-row input[type="color"] { width: 44px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: none; cursor: pointer; padding: 0; }
.color-row .clear-note { font-size: .7rem; color: var(--muted); }

/* Plain centred page for 404 / 500 — no card, just a readout and a way home. */
.plain-page {
  position: relative; z-index: 1;
  min-height: calc(100vh - 4.5rem);
  display: grid; place-items: center; text-align: center;
  padding: var(--sp-3); gap: var(--sp-2);
}
.plain-page .code { font-family: var(--font-num); font-size: 4rem; font-weight: 700; color: var(--a1); line-height: 1; }
.plain-page p { color: var(--muted); max-width: 32ch; }
