/* =========================================================
   IRAQ CYBER ELITE — visual identity "Wedge & Trace"
   Layers keep specificity predictable.
   ========================================================= */
@layer reset, tokens, base, layout, components, pages, motion, utilities;

/* ---------- Fonts (self-hosted, subset per script) ---------- */
@font-face { font-family: "Reem Kufi"; src: url("../fonts/reemkufi-latin.woff2") format("woff2"); font-weight: 400 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215, U+FEFF; }
@font-face { font-family: "Reem Kufi"; src: url("../fonts/reemkufi-arabic.woff2") format("woff2"); font-weight: 400 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-Regular-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215, U+FEFF; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-Regular-arabic.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-SemiBold-latin.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215, U+FEFF; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-SemiBold-arabic.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "JB Mono"; src: url("../fonts/jbmono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

@property --grow { syntax: "<length>"; inherits: false; initial-value: 0px; }

/* ---------- Reset ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, svg, video, canvas { display: block; max-width: 100%; }
  img { height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
  a { color: inherit; }
  ul[class], ol[class], nav ul { list-style: none; padding: 0; }
  [hidden] { display: none !important; }
}

/* ---------- Tokens ---------- */
@layer tokens {
  :root {
    --font-display: "Reem Kufi", "Plex Arabic", system-ui, sans-serif;
    --font-body: "Plex Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
    --font-mono: "JB Mono", "Plex Arabic", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;

    --fs-xs: 0.78rem;
    --fs-sm: 0.875rem;
    --fs-base: 1.0625rem;
    --fs-md: 1.3125rem;
    --fs-lg: 1.5rem;
    --fs-xl: clamp(1.75rem, 1.3rem + 1.6vw, 2.25rem);
    --fs-2xl: clamp(2rem, 1.3rem + 2.8vw, 3rem);
    --fs-3xl: clamp(2.1rem, 0.9rem + 6.4vw, 5.4rem);

    --gutter: clamp(1rem, 4vw, 2.5rem);
    --wrap: 1180px;
    --header-h: 64px;
    --em: clamp(176px, min(34vh, 44vw), 340px);
    --em: clamp(176px, min(34svh, 44vw), 340px);
    --hero-top: calc(var(--header-h) + clamp(0.75rem, 5vh, 3.25rem));
    --wm-scale: 2.2;
    --n: 18px; /* tablet notch */
    --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --radius-s: 3px;
    --radius-m: 8px;
  }

  /* Sovereign (from the emblem) */
  [data-theme="sovereign"][data-mode="dark"] {
    --bg: #030812; --bg-2: #06101f; --surface: #0a1628; --surface-2: #0f1e36;
    --ink: #f3ead6; --ink-2: #b9b19d; --ink-3: #8a8677;
    --line: rgba(229, 176, 72, 0.16); --line-2: rgba(229, 176, 72, 0.34);
    --accent: #e5b048; --accent-hi: #f9df71; --accent-ink: #1a1204; --accent-2: #5b8ff0;
    --glow: rgba(229, 176, 72, 0.32);
    --trace-rgb: 229 176 72; --trace-a: 0.11; --pulse-rgb: 249 223 113; --pulse2-rgb: 91 143 240;
    --wm: 0.075; --texture: none;
    color-scheme: dark;
  }
  [data-theme="sovereign"][data-mode="light"] {
    --bg: #eef1f7; --bg-2: #e5e9f2; --surface: #ffffff; --surface-2: #f6f8fb;
    --ink: #0a1530; --ink-2: #444e69; --ink-3: #5d6479;
    --line: rgba(10, 21, 48, 0.12); --line-2: rgba(10, 21, 48, 0.24);
    --accent: #85590a; --accent-hi: #c8952a; --accent-ink: #ffffff; --accent-2: #1c4fb0;
    --glow: rgba(200, 149, 42, 0.26);
    --trace-rgb: 133 89 10; --trace-a: 0.12; --pulse-rgb: 200 149 42; --pulse2-rgb: 28 79 176;
    --wm: 0.065; --texture: none;
    color-scheme: light;
  }

  /* Nebula (blue to violet, calm neon) */
  [data-theme="nebula"][data-mode="light"] {
    --bg: #eef0ff; --bg-2: #e6e7fd; --surface: #fbfbff; --surface-2: #f3f2ff;
    --ink: #1b1747; --ink-2: #4a4782; --ink-3: #5f5b93;
    --line: rgba(91, 76, 214, 0.15); --line-2: rgba(91, 76, 214, 0.3);
    --accent: #5f33e6; --accent-hi: #00c8f0; --accent-ink: #ffffff; --accent-2: #006f94;
    --glow: rgba(0, 200, 240, 0.35);
    --trace-rgb: 95 51 230; --trace-a: 0.1; --pulse-rgb: 0 200 240; --pulse2-rgb: 255 63 210;
    --wm: 0.065;
    --texture: radial-gradient(70vmax 55vmax at 0% 0%, rgba(90, 150, 255, 0.28), transparent 62%), radial-gradient(70vmax 60vmax at 100% 35%, rgba(170, 100, 255, 0.24), transparent 62%), radial-gradient(60vmax 40vmax at 30% 100%, rgba(0, 210, 255, 0.14), transparent 60%);
    color-scheme: light;
  }
  [data-theme="nebula"][data-mode="dark"] {
    --bg: #0b0a22; --bg-2: #110f30; --surface: #16143d; --surface-2: #1d1a4d;
    --ink: #eceaff; --ink-2: #aba7dd; --ink-3: #8682b8;
    --line: rgba(140, 120, 255, 0.18); --line-2: rgba(140, 120, 255, 0.36);
    --accent: #3ef0ff; --accent-hi: #b8faff; --accent-ink: #06061a; --accent-2: #b98aff;
    --glow: rgba(62, 240, 255, 0.36);
    --trace-rgb: 150 130 255; --trace-a: 0.13; --pulse-rgb: 62 240 255; --pulse2-rgb: 255 79 216;
    --wm: 0.08;
    --texture: radial-gradient(70vmax 55vmax at 0% 0%, rgba(60, 90, 255, 0.22), transparent 62%), radial-gradient(70vmax 60vmax at 100% 30%, rgba(160, 60, 255, 0.2), transparent 62%);
    color-scheme: dark;
  }

  /* Ishtar (lapis and glazed brick) */
  [data-theme="ishtar"][data-mode="dark"] {
    --bg: #061334; --bg-2: #0a1b45; --surface: #0d2255; --surface-2: #122a66;
    --ink: #f4ead2; --ink-2: #b1bedc; --ink-3: #8593b5;
    --line: rgba(242, 184, 75, 0.17); --line-2: rgba(242, 184, 75, 0.34);
    --accent: #f2b84b; --accent-hi: #ffd98a; --accent-ink: #1d1200; --accent-2: #45d0cb;
    --glow: rgba(69, 208, 203, 0.3);
    --trace-rgb: 69 208 203; --trace-a: 0.1; --pulse-rgb: 255 217 138; --pulse2-rgb: 69 208 203;
    --wm: 0.08;
    --texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='32'%3E%3Cpath d='M0 .5h64M0 16.5h64M.5 0v16M32.5 16v16' stroke='%23ffffff' stroke-opacity='.045' fill='none'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
  [data-theme="ishtar"][data-mode="light"] {
    --bg: #e7f0f0; --bg-2: #dce8e9; --surface: #fbfdfd; --surface-2: #f0f6f6;
    --ink: #0b1e52; --ink-2: #3a4b78; --ink-3: #536289;
    --line: rgba(11, 30, 82, 0.13); --line-2: rgba(11, 30, 82, 0.26);
    --accent: #8a5300; --accent-hi: #d08b1c; --accent-ink: #ffffff; --accent-2: #1747c4;
    --glow: rgba(23, 71, 196, 0.22);
    --trace-rgb: 23 71 196; --trace-a: 0.11; --pulse-rgb: 208 139 28; --pulse2-rgb: 23 71 196;
    --wm: 0.065;
    --texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='32'%3E%3Cpath d='M0 .5h64M0 16.5h64M.5 0v16M32.5 16v16' stroke='%230b1e52' stroke-opacity='.06' fill='none'/%3E%3C/svg%3E");
    color-scheme: light;
  }

  /* Ahwar (southern marshes: water and reed at dusk) */
  [data-theme="ahwar"][data-mode="dark"] {
    --bg: #04161a; --bg-2: #071d22; --surface: #0a262c; --surface-2: #0e3036;
    --ink: #e6f2ea; --ink-2: #9dbdb2; --ink-3: #739388;
    --line: rgba(155, 224, 122, 0.15); --line-2: rgba(155, 224, 122, 0.3);
    --accent: #9be07a; --accent-hi: #d3f7ba; --accent-ink: #06180c; --accent-2: #74d6e2;
    --glow: rgba(116, 214, 226, 0.28);
    --trace-rgb: 116 214 226; --trace-a: 0.1; --pulse-rgb: 211 247 186; --pulse2-rgb: 116 214 226;
    --wm: 0.075;
    --texture: repeating-linear-gradient(90deg, transparent 0 21px, rgba(155, 224, 122, 0.05) 21px 22px, transparent 22px 37px, rgba(116, 214, 226, 0.035) 37px 38px, transparent 38px 53px);
    color-scheme: dark;
  }
  [data-theme="ahwar"][data-mode="light"] {
    --bg: #eef5ef; --bg-2: #e3eee5; --surface: #fcfefc; --surface-2: #f1f7f2;
    --ink: #0b2a24; --ink-2: #3d5c53; --ink-3: #526d65;
    --line: rgba(11, 42, 36, 0.13); --line-2: rgba(11, 42, 36, 0.26);
    --accent: #2b6a1a; --accent-hi: #5aa83a; --accent-ink: #ffffff; --accent-2: #0b6a77;
    --glow: rgba(11, 106, 119, 0.2);
    --trace-rgb: 11 106 119; --trace-a: 0.11; --pulse-rgb: 90 168 58; --pulse2-rgb: 11 106 119;
    --wm: 0.065;
    --texture: repeating-linear-gradient(90deg, transparent 0 21px, rgba(43, 106, 26, 0.06) 21px 22px, transparent 22px 37px, rgba(11, 106, 119, 0.045) 37px 38px, transparent 38px 53px);
    color-scheme: light;
  }
}

/* ---------- Base ---------- */
@layer base {
  html {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 100%;
    line-height: 1.65;
    scroll-padding-top: calc(var(--header-h) + 1rem);
    -webkit-tap-highlight-color: transparent;
  }
  html:lang(ar) { line-height: 1.85; }
  html::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -3;
    background-image: var(--texture);
    pointer-events: none;
  }
  [data-theme="ahwar"]::before { -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 55%); mask-image: linear-gradient(to top, #000 0%, transparent 55%); }
  body {
    min-height: 100vh;
    min-height: 100svh;
    font-size: var(--fs-base);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
  }
  html:lang(ar) body { font-size: 1.125rem; }
  ::selection { background: var(--accent); color: var(--accent-ink); }
  h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    text-wrap: balance;
    letter-spacing: -0.005em;
  }
  html:lang(ar) h1, html:lang(ar) h2, html:lang(ar) h3 { line-height: 1.4; letter-spacing: 0; font-weight: 600; }
  h1 { font-size: var(--fs-2xl); }
  h2 { font-size: var(--fs-xl); }
  h3 { font-size: var(--fs-md); }
  p { text-wrap: pretty; }
  a { text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 0.22em; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
  code, kbd, pre { font-family: var(--font-mono); }
  kbd {
    display: inline-grid;
    place-items: center;
    min-width: 1.6em;
    padding: 0 0.35em;
    font-size: 0.8em;
    line-height: 1.6;
    border: 1px solid var(--line-2);
    border-bottom-width: 2px;
    border-radius: var(--radius-s);
    color: var(--accent);
    background: var(--surface);
  }
  .sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
}

/* ---------- Layout ---------- */
@layer layout {
  .wrap { width: min(var(--wrap), 100% - 2 * var(--gutter)); margin-inline: auto; }
  main { display: block; position: relative; }
  .section { padding-block: clamp(3.5rem, 9vw, 7rem); }
  .section-head { display: grid; gap: 0.5rem; margin-block-end: clamp(1.75rem, 4vw, 2.75rem); max-width: 62ch; }
  .section-head p { color: var(--ink-2); }
  .section-head.row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; max-width: none; flex-wrap: wrap; }

  /* Background layers (canvas + emblem stage) */
  .bg-layer { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100lvh; pointer-events: none; z-index: -2; contain: strict; }
  .emblem-stage { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
  .emblem-wrap {
    position: absolute;
    width: var(--em);
    aspect-ratio: 1;
    left: 50%;
    top: var(--hero-top);
    margin-left: calc(var(--em) / -2);
    view-transition-name: emblem;
    will-change: translate, scale, opacity;
  }
  .emblem-wrap.is-static { translate: 0 calc(50vh - var(--em) / 2 - var(--hero-top)); translate: 0 calc(50svh - var(--em) / 2 - var(--hero-top)); scale: var(--wm-scale); opacity: var(--wm); }
  .emblem-wrap.is-static .emblem-ring, .emblem-wrap.is-static .emblem-sheen { display: none; }
  .em-off .ring-ticks, .em-off .ring-arc, .em-off .emblem-sheen::before { animation-play-state: paused; }
  .emblem { width: 100%; height: 100%; border-radius: 50%; transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 0.5s var(--ease); }
  .emblem-sheen { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; pointer-events: none; }
  .emblem-sheen::before {
    content: "";
    position: absolute;
    inset: -10%;
    background: linear-gradient(115deg, transparent 42%, rgba(255, 244, 210, 0.28) 50%, transparent 58%);
    translate: -120% 0;
  }
  .emblem-ring { position: absolute; left: -16%; top: -16%; width: 132%; height: 132%; color: var(--accent); pointer-events: none; }
  .emblem-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; overflow: visible; }
  .ring-ticks { animation: spin 140s linear infinite; will-change: rotate; }
  .ring-arc { animation: spin 46s linear infinite reverse; will-change: rotate; }
}

/* ---------- Components ---------- */
@layer components {
  /* Skip link */
  .skip { position: absolute; inset-inline-start: 1rem; top: -100px; z-index: 100; padding: 0.6rem 1rem; background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: var(--radius-s); text-decoration: none; }
  .skip:focus { top: 0.75rem; }

  /* Header */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-h);
    view-transition-name: header;
    transition: background-color 0.3s, border-color 0.3s;
    border-bottom: 1px solid transparent;
  }
  .site-header.scrolled, .site-header:not(.on-hero) {
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    backdrop-filter: blur(14px) saturate(1.2);
    border-bottom-color: var(--line);
  }
  .header-inner { height: 100%; display: flex; align-items: center; gap: 1rem; }
  .brand { display: inline-flex; align-items: center; gap: 0.65rem; text-decoration: none; flex-shrink: 0; }
  .brand img { width: 36px; height: 36px; border-radius: 50%; }
  .brand-name { font-family: var(--font-display); font-weight: 700; font-size: 0.98rem; letter-spacing: 0.08em; white-space: nowrap; direction: ltr; }
  .nav { margin-inline-start: auto; }
  .nav ul { display: flex; gap: 0.25rem; }
  .nav a {
    position: relative;
    display: block;
    padding: 0.45rem 0.8rem;
    font-weight: 600;
    font-size: 0.94rem;
    text-decoration: none;
    color: var(--ink-2);
    border-radius: var(--radius-s);
    transition: color 0.2s;
  }
  .nav a:hover { color: var(--ink); }
  .nav a[aria-current="page"] { color: var(--accent); }
  .nav a[aria-current="page"]::after {
    content: "";
    position: absolute;
    inset-inline: 0.8rem;
    bottom: 0.1rem;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
  }
  [dir="rtl"] .nav a[aria-current="page"]::after { background: linear-gradient(-90deg, var(--accent), transparent); }
  .controls { display: flex; align-items: center; gap: 0.25rem; margin-inline-start: 0.5rem; }
  .ctl {
    display: inline-grid;
    place-items: center;
    min-width: 40px;
    height: 40px;
    padding-inline: 0.5rem;
    color: var(--ink-2);
    border-radius: var(--radius-m);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    transition: color 0.2s, background-color 0.2s;
  }
  .ctl:hover { color: var(--ink); background: var(--line); }
  .ctl .i { width: 20px; height: 20px; }
  .ctl.lang { font-family: var(--font-body); }
  .menu-btn { display: none; }
  @media (max-width: 920px) {
    .nav { display: none; }
    .menu-btn { display: inline-grid; }
    .controls { margin-inline-start: auto; }
  }
  @media (max-width: 520px) {
    .brand-name { display: none; }
    .controls { gap: 0; }
  }
  .i { width: 1.15em; height: 1.15em; flex-shrink: 0; }
  [data-mode="dark"] .only-light, [data-mode="light"] .only-dark { display: none; }

  /* Popovers (theme + mobile menu) */
  .pop { display: none; }
  .pop.is-open { display: block; }
  .pop:popover-open { display: block; }
  .pop {
    position: fixed;
    inset: auto;
    top: calc(var(--header-h) + 0.5rem);
    inset-inline-end: max(var(--gutter), calc((100vw - var(--wrap)) / 2));
    margin: 0;
    width: min(340px, calc(100vw - 2rem));
    padding: 1rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-m);
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.45);
    z-index: 60;
  }
  .pop-title { font-family: var(--font-display); font-weight: 600; margin-block-end: 0.75rem; }
  .theme-list { display: grid; gap: 0.4rem; }
  .theme-opt {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    padding: 0.55rem 0.6rem;
    text-align: start;
    border-radius: var(--radius-m);
    border: 1px solid transparent;
    transition: background-color 0.2s, border-color 0.2s;
  }
  .theme-opt:hover { background: var(--surface-2); }
  .theme-opt[aria-pressed="true"] { border-color: var(--line-2); background: var(--surface-2); }
  .theme-txt { display: grid; line-height: 1.35; }
  .theme-txt small { color: var(--ink-2); font-size: var(--fs-xs); }
  .swatch { position: relative; width: 44px; height: 44px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line-2); overflow: hidden; flex-shrink: 0; }
  .swatch i { position: absolute; border-radius: 50%; }
  .swatch i:nth-child(1) { width: 18px; height: 18px; top: 7px; inset-inline-start: 7px; background: var(--accent); }
  .swatch i:nth-child(2) { width: 12px; height: 12px; bottom: 8px; inset-inline-end: 8px; background: var(--accent-2); }
  .swatch i:nth-child(3) { width: 7px; height: 7px; bottom: 9px; inset-inline-start: 12px; background: var(--ink); opacity: 0.8; }
  .mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-block-start: 0.75rem; padding-block-start: 0.75rem; border-top: 1px solid var(--line); }
  .mode-opt { display: flex; align-items: center; justify-content: center; gap: 0.45rem; padding: 0.55rem; border-radius: var(--radius-m); border: 1px solid var(--line); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
  .mode-opt[aria-pressed="true"] { color: var(--accent); border-color: var(--line-2); background: var(--surface-2); }
  .menu-pop { padding: 0.5rem; }
  .menu-pop ul { display: grid; }
  .menu-pop a { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 0.9rem; font-family: var(--font-display); font-size: var(--fs-md); text-decoration: none; border-radius: var(--radius-m); }
  .menu-pop a:hover { background: var(--surface-2); }
  .menu-pop a[aria-current="page"] { color: var(--accent); }
  .menu-pop .wedge { width: 14px; height: 14px; color: var(--accent); opacity: 0; }
  .menu-pop a[aria-current="page"] .wedge { opacity: 1; }

  /* Buttons */
  .btn {
    --bn: 10px;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 48px;
    padding: 0.7rem 1.5rem;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
    text-decoration: none;
    border-radius: var(--radius-s);
    transition: background-color 0.2s, color 0.2s, box-shadow 0.25s, translate 0.2s var(--ease);
  }
  .btn .i { width: 1.15rem; height: 1.15rem; }
  .btn.primary {
    color: var(--accent-ink);
    background: var(--accent);
    clip-path: polygon(0 0, calc(100% - var(--bn)) 0, 100% var(--bn), 100% 100%, 0 100%);
    border-radius: 0;
  }
  [dir="rtl"] .btn.primary { clip-path: polygon(var(--bn) 0, 100% 0, 100% 100%, 0 100%, 0 var(--bn)); }
  .btn.primary:hover { background: var(--accent-hi); translate: 0 -1px; }
  .btn.ghost { color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
  .btn.ghost:hover { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
  .text-link { color: var(--accent); font-weight: 600; text-decoration: none; font-size: var(--fs-sm); }
  .text-link:hover { text-decoration: underline; }

  /* Chips & tags */
  .chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 38px;
    padding: 0.35rem 0.95rem;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--ink-2);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
  }
  .chip:hover { color: var(--ink); border-color: var(--accent); }
  .chip[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
  .chip .count { font-size: var(--fs-xs); opacity: 0.75; }
  .tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
  .tags li { font-size: var(--fs-xs); line-height: 1.5; padding: 0.12rem 0.5rem; color: var(--ink-2); border: 1px solid var(--line); border-radius: 2px; }

  /* Tablet: cards cut at one corner like a broken clay tablet */
  .tablet {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line-2);
    clip-path: polygon(0 0, calc(100% - var(--n)) 0, 100% var(--n), 100% 100%, 0 100%);
  }
  [dir="rtl"] .tablet { clip-path: polygon(var(--n) 0, 100% 0, 100% 100%, 0 100%, 0 var(--n)); }
  .tablet::after {
    content: "";
    position: absolute;
    top: calc(var(--n) / 2 - 1px);
    right: calc(var(--n) / 2 - 1px);
    width: calc(var(--n) * 1.4142);
    height: 1px;
    background: var(--line-2);
    translate: 50% -50%;
    rotate: 45deg;
    pointer-events: none;
  }
  [dir="rtl"] .tablet::after { right: auto; left: calc(var(--n) / 2 - 1px); translate: -50% -50%; rotate: -45deg; }
  [data-spot] { background-image: radial-gradient(420px circle at var(--mx, -999px) var(--my, -999px), color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%); }

  /* Wedge glyph & lists */
  .wedge { width: 1em; height: 1em; color: var(--accent); flex-shrink: 0; }
  .wedge-list { display: grid; gap: 0.85rem; }
  .wedge-list li { display: flex; gap: 0.8rem; align-items: baseline; }
  .wedge-list .wedge { translate: 0 0.18em; width: 0.95em; height: 0.95em; }

  /* Post list (rows, not cards) */
  .post-list { display: grid; }
  .post-row { border-bottom: 1px solid var(--line); }
  .post-row:first-child { border-top: 1px solid var(--line); }
  .post-link {
    display: grid;
    grid-template-columns: 9.5rem 1fr;
    gap: 0.35rem 1.5rem;
    padding: 1.35rem 0.25rem;
    text-decoration: none;
    transition: background-color 0.25s;
  }
  .post-link:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
  .post-link time { grid-row: span 3; color: var(--ink-3); font-size: var(--fs-sm); padding-top: 0.25rem; }
  .post-link h3 { font-family: var(--font-body); font-weight: 600; font-size: var(--fs-md); line-height: 1.4; transition: color 0.2s; }
  .post-link:hover h3 { color: var(--accent); }
  .post-link p { color: var(--ink-2); font-size: 0.98em; }
  .post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.9rem; color: var(--ink-3); font-size: var(--fs-sm); }
  .post-meta .tags li { color: var(--ink-3); }
  @media (max-width: 640px) {
    .post-link { grid-template-columns: 1fr; }
    .post-link time { grid-row: auto; padding: 0; }
  }

  /* Project cards */
  .project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1.25rem; }
  .project { display: flex; flex-direction: column; gap: 0.8rem; padding: 1.5rem 1.5rem 1.25rem; min-height: 100%; }
  .p-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: var(--fs-sm); }
  .p-type { color: var(--ink-2); font-weight: 600; }
  .status { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--ink-2); padding-inline-end: calc(var(--n) - 0.5rem); }
  .status i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
  .s-live i { background: #3ccf7a; box-shadow: 0 0 0 3px rgba(60, 207, 122, 0.18); }
  .s-beta i { background: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 22%, transparent); }
  .s-dev i { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); animation: blink 2.4s ease-in-out infinite; }
  .p-name { font-size: var(--fs-lg); direction: ltr; text-align: start; }
  [dir="rtl"] .p-name { text-align: right; }
  .p-sum { color: var(--ink-2); flex-grow: 1; }
  .p-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--ink-3); min-height: 3.2rem; }
  .p-links { display: flex; gap: 0.25rem; margin-inline-start: auto; }
  .p-links a { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.6rem; color: var(--ink); text-decoration: none; font-weight: 600; border-radius: var(--radius-s); }
  .p-links a:hover { color: var(--accent); background: var(--line); }

  /* Page head */
  .page-head { padding-block: clamp(3rem, 8vw, 6rem) clamp(1.5rem, 4vw, 2.5rem); display: grid; gap: 0.9rem; }
  .page-head h1 { font-size: var(--fs-3xl); line-height: 1.1; }
  html:lang(ar) .page-head h1 { line-height: 1.3; }
  .page-head .lead { font-size: var(--fs-md); color: var(--ink-2); max-width: 46ch; }
  .empty { padding: 2rem 0; color: var(--ink-2); }

  /* Footer */
  .site-footer { margin-block-start: clamp(4rem, 10vw, 7rem); border-top: 1px solid var(--line); background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent); }
  .foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 2.5rem; padding-block: 3.5rem 2.5rem; }
  .foot-brand { display: grid; gap: 0.9rem; align-content: start; max-width: 34ch; }
  .foot-brand img { width: 64px; height: 64px; border-radius: 50%; }
  .foot-brand .wordmark-sm { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.1em; direction: ltr; text-align: start; }
  [dir="rtl"] .foot-brand .wordmark-sm { text-align: right; }
  .foot-brand p { color: var(--ink-2); }
  .site-footer h2 { font-size: var(--fs-base); margin-block-end: 0.9rem; color: var(--ink); }
  .foot-links { display: grid; gap: 0.55rem; }
  .foot-links a { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--ink-2); text-decoration: none; }
  .foot-links a:hover { color: var(--accent); }
  .foot-base { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem 2rem; padding-block: 1.25rem 2rem; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--ink-3); }
  @media (max-width: 760px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-brand { grid-column: 1 / -1; } }
  @media (hover: none) { .kbd-only { display: none !important; } }
  @media (hover: hover) { .touch-only { display: none !important; } }

  /* Terminal */
  .term {
    --t-bg: #050a12;
    --t-ink: #d9e2ec;
    --t-dim: #8b98a8;
    --t-ok: #6ee7a8;
    --t-err: #ff7a7a;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 360px;
    max-height: min(70vh, 560px);
    color: var(--t-ink);
    background: var(--t-bg);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-m);
    font-family: var(--font-mono), "Plex Arabic";
    font-size: 0.9rem;
    line-height: 1.6;
    direction: ltr;
    text-align: left;
    overflow: hidden;
    box-shadow: 0 30px 80px -40px var(--glow);
  }
  [data-mode="light"] .term { --t-bg: #0b1222; }
  .term-bar { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.85rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); background: rgba(255, 255, 255, 0.03); }
  .term-dots { display: flex; gap: 6px; }
  .term-dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }
  .term-dots i:first-child { background: var(--accent); }
  .term-title { color: var(--t-dim); font-size: 0.8rem; flex-grow: 1; }
  .term-x { display: inline-grid; place-items: center; width: 32px; height: 32px; color: var(--t-dim); border-radius: 6px; }
  .term-x:hover { color: var(--t-ink); background: rgba(255, 255, 255, 0.08); }
  .term-body { flex-grow: 1; overflow-y: auto; padding: 0.9rem 1rem 0.25rem; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
  .term-line { white-space: pre-wrap; word-break: break-word; min-height: 1.6em; }
  .term-line[dir="rtl"] { text-align: right; font-family: "Plex Arabic", var(--font-mono); }
  .term-line .p { color: var(--accent); }
  .term-line .dim { color: var(--t-dim); }
  .term-line .ok { color: var(--t-ok); }
  .term-line .err { color: var(--t-err); }
  .term-line .acc { color: var(--accent); }
  .term-line .acc2 { color: var(--accent-2); }
  .term-line a { color: var(--accent-2); text-underline-offset: 0.2em; }
  .term-line a.acc { color: var(--accent); text-decoration: none; }
  .term-line a.acc:hover { text-decoration: underline; }
  .term-form { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 1rem 0.9rem; }
  .term-prompt { color: var(--accent); white-space: nowrap; }
  .term-input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--t-ink); caret-color: var(--accent); font-family: inherit; font-size: inherit; padding: 0.2rem 0; }
  .term-input:focus-visible { outline: none; }
  .term:focus-within { border-color: var(--accent); }
  .term-dialog { width: min(860px, calc(100vw - 1.5rem)); max-height: none; padding: 0; border: 0; background: transparent; color: inherit; margin: auto; overflow: visible; }
  .term-dialog::backdrop { background: rgba(2, 4, 10, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
  .term-dialog .term { min-height: min(520px, 72vh); }
  .term-dialog[open] .term { animation: term-in 0.32s var(--ease) both; }
}

/* ---------- Pages ---------- */
@layer pages {
  /* Hero */
  .hero {
    min-height: calc(100vh - var(--header-h));
    min-height: calc(100svh - var(--header-h));
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-block: calc(var(--hero-top) - var(--header-h)) 3rem;
    padding-inline: var(--gutter);
  }
  .hero-slot { width: var(--em); height: var(--em); flex-shrink: 0; margin-block-end: clamp(1.25rem, 3.5vh, 2.25rem); }
  .wordmark {
    font-size: var(--fs-3xl);
    line-height: 1.05;
    letter-spacing: 0.07em;
    direction: ltr;
    max-width: 14ch;
    background: linear-gradient(180deg, var(--accent-hi) 0%, var(--accent) 70%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  @media (min-width: 900px) { .wordmark { max-width: none; } }
  html:lang(ar) .wordmark { line-height: 1.1; letter-spacing: 0.07em; }
  [data-theme="nebula"][data-mode="dark"] .wordmark { filter: drop-shadow(0 0 18px rgba(62, 240, 255, 0.35)); }
  .wordmark span { display: inline-block; }
  .hero-line { margin-block-start: 0.9rem; font-family: var(--font-display); font-size: var(--fs-md); color: var(--ink); word-spacing: 0.14em; }
  html:lang(en) h1, html:lang(en) h2, html:lang(en) h3, html:lang(en) .statement { word-spacing: 0.1em; }
  .tagline { margin-block-start: 0.4rem; color: var(--ink-2); max-width: 44ch; font-size: 1.05em; }
  .hero-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-block-start: 1.75rem; }
  .hero-hint { margin-block-start: 1.5rem; font-size: var(--fs-sm); color: var(--ink-3); display: flex; align-items: center; gap: 0.5rem; }
  .hero-hint button { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; padding-inline: 0.75rem; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 0.25em; }

  /* Intro */
  .intro { display: grid; grid-template-columns: 1.15fr 1fr; gap: clamp(1.5rem, 5vw, 5rem); align-items: end; padding-block: clamp(4rem, 10vw, 8rem) clamp(2rem, 5vw, 4rem); }
  .statement { font-family: var(--font-display); font-size: var(--fs-2xl); line-height: 1.25; font-weight: 600; }
  html:lang(ar) .statement { font-family: var(--font-body); line-height: 1.6; font-size: var(--fs-xl); }
  .intro-body { color: var(--ink-2); font-size: 1.05em; max-width: 52ch; }
  @media (max-width: 800px) { .intro { grid-template-columns: 1fr; } }

  /* Focus: a circuit trace that links the four tracks */
  .circuit { position: relative; padding-inline-start: 2.75rem; view-timeline: --circuit block; }
  .circuit::before {
    content: "";
    position: absolute;
    top: 2.35rem;
    bottom: 2.6rem;
    inset-inline-start: 0.6rem;
    width: 2px;
    background: linear-gradient(to bottom, var(--accent), var(--accent-2));
    transform-origin: top;
    border-radius: 2px;
  }
  .node {
    position: relative;
    display: grid;
    grid-template-columns: minmax(13rem, 0.9fr) 1.6fr;
    gap: 0.6rem 3rem;
    padding-block: 1.9rem;
    border-bottom: 1px solid var(--line);
  }
  .node:last-child { border-bottom: 0; }
  .node-head { display: grid; gap: 0.15rem; align-content: start; }
  .node-head h3 { font-size: var(--fs-lg); }
  .node-alt { font-size: var(--fs-sm); color: var(--ink-3); }
  .node-body { display: grid; gap: 0.9rem; }
  .node-body p { color: var(--ink-2); max-width: 56ch; }
  .pad {
    position: absolute;
    top: 2.35rem;
    inset-inline-start: calc(-2.75rem + 0.6rem + 1px - 8px);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: var(--bg);
    box-shadow: 0 0 0 5px var(--bg);
    transition: background-color 0.3s, box-shadow 0.3s;
  }
  .pad::after { content: ""; position: absolute; top: 50%; inset-inline-start: 100%; width: 0.85rem; height: 2px; background: var(--accent); translate: 0 -50%; margin-inline-start: 4px; opacity: 0.7; }
  .node:hover .pad { background: var(--accent); box-shadow: 0 0 0 5px var(--bg), 0 0 22px var(--glow); }
  @media (max-width: 760px) { .node { grid-template-columns: 1fr; } }

  /* Terminal section */
  .term-section { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: clamp(1.5rem, 5vw, 4rem); align-items: center; }
  .term-copy { display: grid; gap: 1rem; }
  .term-copy p { color: var(--ink-2); max-width: 46ch; }
  .cmd-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
  .cmd-chips button { font-family: var(--font-mono); font-size: 0.82rem; padding: 0.4rem 0.75rem; color: var(--accent); border: 1px dashed var(--line-2); border-radius: var(--radius-s); direction: ltr; }
  .cmd-chips button:hover { border-style: solid; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
  .term-inline { height: 420px; max-height: none; }
  @media (max-width: 860px) { .term-section { grid-template-columns: 1fr; } .term-inline { height: 380px; } }

  /* Latest */
  .latest { display: grid; grid-template-columns: 1.25fr 1fr; gap: clamp(2rem, 5vw, 4.5rem); align-items: start; }
  .latest > :only-child { grid-column: 1 / -1; }
  .project-grid.compact { grid-template-columns: 1fr; }
  @media (max-width: 920px) { .latest { grid-template-columns: 1fr; } }

  /* Join */
  .join { display: grid; justify-items: start; gap: 1rem; padding-block: clamp(3rem, 8vw, 5rem); border-top: 1px solid var(--line); }
  .join h2 { font-size: var(--fs-2xl); max-width: 22ch; }
  .join p { color: var(--ink-2); max-width: 52ch; }
  .join .btn { margin-block-start: 0.5rem; }

  /* About */
  .story { display: grid; gap: 1.5rem; max-width: 68ch; padding-block-end: clamp(2rem, 6vw, 4rem); }
  .story p { font-size: var(--fs-md); line-height: 1.7; color: var(--ink-2); }
  html:lang(ar) .story p { line-height: 1.95; }
  .story p:first-child { color: var(--ink); font-family: var(--font-display); font-size: var(--fs-xl); line-height: 1.45; }
  html:lang(ar) .story p:first-child { line-height: 1.85; font-family: var(--font-body); font-weight: 600; font-size: var(--fs-lg); }
  .tl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-block-start: 2rem; position: relative; }
  .tl li { position: relative; padding: 1.5rem 1.25rem 0 0; padding-inline: 0 1.5rem; border-top: 1px solid var(--line-2); }
  .tl li::before { content: ""; position: absolute; top: -5px; inset-inline-start: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--bg); }
  .tl-num { display: flex; align-items: center; gap: 0.6rem; height: 30px; color: var(--accent); margin-block-end: 0.85rem; }
  .tl-num .babylon { height: 22px; width: auto; }
  .tl-digit { font-size: var(--fs-sm); color: var(--ink-3); font-weight: 600; }
  .tl h3 { font-size: var(--fs-md); margin-block-end: 0.35rem; }
  .tl p { color: var(--ink-2); font-size: 0.97em; }
  @media (max-width: 860px) {
    .tl { grid-template-columns: 1fr; gap: 0; padding-inline-start: 1.5rem; }
    .tl::before { content: ""; position: absolute; inset-block: 0.5rem; inset-inline-start: 4px; width: 1px; background: var(--line-2); }
    .tl li { border-top: 0; padding: 0 0 2rem; }
    .tl li::before { top: 0.6rem; inset-inline-start: calc(-1.5rem); }
  }
  .vm { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
  .vm-item { padding: clamp(1.5rem, 4vw, 2.5rem); }
  .vm-item h2 { font-size: var(--fs-lg); color: var(--accent); margin-block-end: 0.75rem; }
  .vm-item p { font-size: var(--fs-md); line-height: 1.6; }
  html:lang(ar) .vm-item p { line-height: 1.85; }
  @media (max-width: 760px) { .vm { grid-template-columns: 1fr; } }
  .split { display: grid; grid-template-columns: 1fr 1.4fr; gap: clamp(1.5rem, 5vw, 4rem); align-items: start; }
  @media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
  .values-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 1px solid var(--line); }
  .value { padding: 1.5rem 0; padding-inline-end: 1.5rem; border-bottom: 1px solid var(--line); }
  .value h3 { font-size: var(--fs-md); display: flex; gap: 0.6rem; align-items: center; margin-block-end: 0.35rem; }
  .value p { color: var(--ink-2); }
  @media (max-width: 640px) { .values-grid { grid-template-columns: 1fr; } }

  /* Team */
  .role-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-block-end: 2rem; padding-block-end: 1.25rem; border-bottom: 1px solid var(--line); }
  .team-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.5rem; }
  .member { flex: 0 1 calc((100% - 3rem) / 3); min-width: 0; perspective: 1400px; }
  @media (max-width: 1020px) { .member { flex-basis: calc((100% - 1.5rem) / 2); } }
  @media (max-width: 640px) { .member { flex-basis: 100%; } }
  .member.flipped { --flip: 180deg; }
  .member-inner {
    position: relative; display: grid; height: 100%; min-height: 540px; transform-style: preserve-3d;
    transform: rotateX(var(--rx, 0deg)) rotateY(calc(var(--ry, 0deg) + var(--flip, 0deg)));
    transition: transform 0.75s var(--ease);
  }
  .member.tilting:not(.flipping) .member-inner { transition-duration: 0.25s; }
  .face {
    grid-area: 1 / 1; position: relative; display: flex; flex-direction: column; padding: 1.25rem 1.35rem 1rem; overflow: hidden;
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
    background:
      radial-gradient(420px circle at var(--mx, -999px) var(--my, -999px), color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
      linear-gradient(180deg, color-mix(in srgb, var(--accent) 7%, var(--surface)), var(--surface) 38%);
    transition: border-color 0.4s;
  }
  .member:hover .face { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
  .face.front { align-items: center; text-align: center; gap: 0.45rem; cursor: pointer; }
  .face.back { transform: rotateY(180deg); gap: 0.8rem; }

  /* front: number, sigil, name, inscription, skill tablets */
  .m-top { align-self: stretch; display: flex; min-height: 16px; }
  .m-no { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--accent); font: 600 var(--fs-xs)/1 var(--font-mono); }
  .m-no .babylon { height: 13px; width: auto; }
  .m-no-d { color: var(--ink-3); letter-spacing: 0.12em; }
  .fan { position: absolute; bottom: 9px; width: 24px; height: 24px; color: var(--accent); opacity: 0.32; pointer-events: none; transition: opacity 0.5s; }
  .fan-s { left: 9px; transform: scaleY(-1); }
  .fan-e { right: 9px; transform: scale(-1, -1); }
  .member:hover .fan { opacity: 0.8; }
  .avatar { width: 140px; height: 140px; margin-block: auto 0.5rem; color: var(--accent); position: relative; }
  .avatar::before { content: ""; position: absolute; inset: -14px; border-radius: 50%; background: radial-gradient(closest-side, var(--glow), transparent); opacity: 0; transition: opacity 0.6s; }
  .member:hover .avatar::before { opacity: 0.55; }
  .avatar img { position: relative; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--line-2); }
  .sigil { position: relative; width: 100%; height: 100%; }
  .sigil-text { font-family: var(--font-display); font-weight: 700; font-size: 22px; fill: var(--ink); letter-spacing: 0.06em; }
  .member:hover .sigil-marks { animation: spin 18s linear infinite; transform-origin: 50px 50px; }
  .m-name { font-size: var(--fs-md); font-family: var(--font-display); line-height: 1.3; }
  .face.front .m-name { font-size: var(--fs-lg); }
  .inscr { height: 12px; width: auto; color: var(--accent); opacity: 0.5; margin-block-end: 0.55rem; overflow: visible; transition: opacity 0.4s; }
  .inscr g > * { transform-box: fill-box; transform-origin: center; }
  .member:hover .inscr { opacity: 1; }

  .doms { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; width: 100%; }
  .dom {
    --n: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; min-height: 112px; padding: 0.7rem 0.75rem 0.7rem; text-align: start;
    background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 10%, var(--surface-2)), var(--surface-2) 72%);
    isolation: isolate; overflow: hidden; cursor: default;
    transition: transform 0.35s var(--ease), border-color 0.3s;
  }
  .dom:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .doms:has(> :nth-child(5)) .dom { min-height: 96px; }
  .dom::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; transform: translateX(-130%);
    background: linear-gradient(105deg, transparent 30%, color-mix(in srgb, var(--accent-hi) 20%, transparent) 50%, transparent 70%); }
  .dom:hover { transform: translateY(-3px); border-color: var(--accent); }
  .dom:hover::before { transform: translateX(130%); transition: transform 0.9s var(--ease); }
  .dom-ic { display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0; color: var(--accent); border: 1px solid var(--line-2); border-radius: 50%; background: color-mix(in srgb, var(--accent) 8%, transparent); transition: background-color 0.3s, color 0.3s, border-color 0.3s; }
  .dom-ic .i, .dom-ic .wedge { width: 16px; height: 16px; }
  .dom:hover .dom-ic { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  .dom-no { position: absolute; top: 0.95rem; inset-inline-end: 0.95rem; color: var(--ink-3); opacity: 0.7; transition: color 0.3s, opacity 0.3s; }
  .dom-no .babylon { height: 10px; width: auto; }
  .dom:hover .dom-no { color: var(--accent); opacity: 1; }
  .dom-en { display: block; margin-block-start: 0.4rem; font-weight: 600; font-size: 0.84rem; line-height: 1.3; color: var(--ink); }
  .dom-ar { font-size: 0.72rem; line-height: 1.4; color: var(--ink-3); }

  /* cuneiform band: wedge, corner wedge, node — repeated, lit by a sweep on hover */
  .frieze {
    align-self: stretch; flex-shrink: 0; height: 10px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 34%, transparent) 0 40%, var(--accent-hi) 50%, color-mix(in srgb, var(--accent) 34%, transparent) 60% 100%) 100% 0 / 300% 100%;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='10'%3E%3Cpath d='M1 1h5l-2 2.4v5.6h-1V3.4z'/%3E%3Cpath d='M15 1 9 5l6 4-1.4-4z'/%3E%3Ccircle cx='20' cy='5' r='1.9' fill='none' stroke='black' stroke-width='1.2'/%3E%3C/svg%3E") center / 24px 10px repeat-x;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='10'%3E%3Cpath d='M1 1h5l-2 2.4v5.6h-1V3.4z'/%3E%3Cpath d='M15 1 9 5l6 4-1.4-4z'/%3E%3Ccircle cx='20' cy='5' r='1.9' fill='none' stroke='black' stroke-width='1.2'/%3E%3C/svg%3E") center / 24px 10px repeat-x;
  }
  .face.front .frieze { margin-block: auto 0.15rem; }
  .face.front .frieze.top { margin-block: 0.55rem 0; opacity: 0.6; }

  .flip-btn { position: relative; display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.55rem 0.9rem; font-size: var(--fs-sm); font-weight: 600; color: var(--accent); border-radius: var(--radius-s); transition: background-color 0.2s; }
  .flip-btn:hover { background: var(--line); }
  .flip-btn .i { width: 1.05rem; height: 1.05rem; transition: rotate 0.6s var(--ease); }
  .flip-btn:hover .i, .face.front:hover .flip-btn .i { rotate: 180deg; }
  .face.back .flip-btn { align-self: flex-start; padding-inline: 0.6rem; margin-block-start: auto; }

  /* back: bio and details */
  .face.back { isolation: isolate; }
  .back-wm { position: absolute; z-index: -1; inset-block-end: 16px; inset-inline-end: 18px; color: var(--accent); opacity: 0.06; pointer-events: none; }
  .back-wm .babylon { height: 84px; width: auto; }
  .m-head { display: grid; gap: 0.15rem; padding-inline-end: var(--n); }
  .m-title { color: var(--accent); font-size: var(--fs-sm); font-weight: 600; }
  .m-bio { color: var(--ink); font-size: var(--fs-sm); line-height: 1.8; }
  .m-sec { display: grid; gap: 0.4rem; }
  .m-label { display: flex; align-items: center; gap: 0.4rem; font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; }
  .m-label .wedge { width: 0.85em; height: 0.85em; }
  .m-projects { display: grid; gap: 0.55rem; }
  .m-projects li { display: grid; gap: 0.1rem; padding-inline-start: 0.7rem; border-inline-start: 1px solid var(--line-2); transition: border-color 0.3s; }
  .m-projects li:hover { border-color: var(--accent); }
  .m-projects a, .p-name { display: inline-flex; align-items: center; gap: 0.35rem; width: fit-content; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); text-decoration: none; transition: color 0.2s; }
  .m-projects a:hover { color: var(--accent); }
  .m-projects .i { width: 13px; height: 13px; opacity: 0.6; }
  .p-desc { font-size: var(--fs-xs); line-height: 1.65; color: var(--ink-2); }
  .m-links { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-block-start: 0.25rem; }
  .m-links a { display: inline-grid; place-items: center; width: 42px; height: 42px; color: var(--ink-2); border: 1px solid var(--line-2); border-radius: var(--radius-m); --icon-cut: var(--surface); transition: color 0.2s, border-color 0.2s; }
  .m-links a:hover { color: var(--accent); border-color: var(--accent); }
  .m-links .i { width: 19px; height: 19px; }

  @media (prefers-reduced-motion: no-preference) {
    .dom { animation: dom-rise 0.7s var(--ease) backwards; animation-delay: calc(var(--j) * 80ms + 150ms); }
    .member:hover .inscr g > * { animation: ins-impress 0.7s var(--ease) both; animation-delay: calc(var(--k) * 32ms); }
    .member:hover .face.front .frieze { animation: frieze-sweep 1.8s var(--ease) both; }
    .dom:hover .dom-ic { animation: dom-stamp 0.45s var(--ease); }
  }
  @keyframes dom-rise { from { opacity: 0; transform: translateY(10px); } }
  @keyframes ins-impress { 0% { opacity: 0.2; transform: translateY(-3px) scale(0.8); } 55% { opacity: 1; color: var(--accent-hi); transform: none; } 100% { opacity: 1; transform: none; } }
  @keyframes frieze-sweep { to { background-position: 0 0; } }
  @keyframes dom-stamp { 40% { transform: scale(0.82) rotate(-10deg); } }

  @media (max-width: 560px) {
    .member-inner { min-height: 0; }
    .face { padding: 1.1rem 1.1rem 0.9rem; }
    .avatar { width: 92px; height: 92px; }
    .sigil-text { font-size: 24px; }
    .dom { min-height: 84px; padding: 0.6rem 0.65rem; }
  }

  /* Blog */
  .blog-tools { display: grid; gap: 1rem; margin-block-end: 1.75rem; }
  .search { position: relative; display: flex; align-items: center; max-width: 520px; }
  .search .i { position: absolute; inset-inline-start: 0.9rem; color: var(--ink-3); width: 1.1rem; height: 1.1rem; pointer-events: none; }
  .search input { width: 100%; min-height: 50px; padding: 0.6rem 1rem; padding-inline-start: 2.6rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-m); }
  .search input::placeholder { color: var(--ink-3); }
  .search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }

  /* Post */
  .read-progress { position: fixed; top: 0; inset-inline: 0; height: 2px; z-index: 70; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transform-origin: left; scale: var(--read, 0) 1; }
  [dir="rtl"] .read-progress { transform-origin: right; background: linear-gradient(-90deg, var(--accent-2), var(--accent)); }
  .post-head { display: grid; gap: 1rem; padding-block: clamp(2.5rem, 7vw, 5rem) 2rem; max-width: 46rem; }
  .crumbs a { color: var(--accent); font-weight: 600; text-decoration: none; font-size: var(--fs-sm); }
  .post-head h1 { font-size: var(--fs-2xl); }
  .post-sub { font-size: var(--fs-md); color: var(--ink-2); }
  .post-layout { display: grid; grid-template-columns: minmax(0, 46rem) 1fr; gap: 4rem; align-items: start; padding-block-start: 2rem; border-top: 1px solid var(--line); }
  .toc { position: sticky; top: calc(var(--header-h) + 1.5rem); order: 2; font-size: var(--fs-sm); padding-inline-start: 1.25rem; border-inline-start: 1px solid var(--line); }
  .toc-title { font-weight: 600; margin-block-end: 0.75rem; color: var(--ink); }
  .toc ol { display: grid; gap: 0.5rem; list-style: none; padding: 0; }
  .toc a { color: var(--ink-2); text-decoration: none; }
  .toc a:hover, .toc a.active { color: var(--accent); }
  .toc .lvl-3 { padding-inline-start: 0.9rem; }
  @media (max-width: 1000px) { .post-layout { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }
  .prose { min-width: 0; }
  .prose > * + * { margin-block-start: 1.15em; }
  .prose h2 { font-size: var(--fs-xl); margin-block-start: 2.2em; }
  .prose h3 { font-size: var(--fs-lg); margin-block-start: 1.8em; }
  .prose p, .prose li { color: var(--ink); max-width: 70ch; }
  .prose ul, .prose ol { padding-inline-start: 1.4em; display: grid; gap: 0.5em; }
  .prose li::marker { color: var(--accent); }
  .prose a { color: var(--accent); }
  .prose strong { color: var(--ink); font-weight: 600; }
  .prose :not(pre) > code { font-size: 0.86em; padding: 0.1em 0.4em; border-radius: var(--radius-s); background: var(--surface-2); border: 1px solid var(--line); color: var(--accent); unicode-bidi: isolate; }
  .prose blockquote { padding: 1.1rem 1.4rem; border-inline-start: 3px solid var(--accent); background: var(--surface); font-family: var(--font-display); font-size: var(--fs-md); }
  .prose hr { border: 0; height: 1px; background: var(--line-2); margin-block: 2.5rem; }
  .prose img { border-radius: var(--radius-m); border: 1px solid var(--line); }
  .table-wrap { overflow-x: auto; }
  .prose table { border-collapse: collapse; width: 100%; font-size: 0.95em; }
  .prose th, .prose td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); text-align: start; }
  .code-block { border: 1px solid var(--line-2); border-radius: var(--radius-m); overflow: hidden; background: #050a12; }
  [data-mode="light"] .code-block { background: #0b1222; }
  .code-block figcaption { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0.6rem 0.4rem 0.9rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-size: var(--fs-xs); color: #8b98a8; direction: ltr; }
  .copy-btn { padding: 0.3rem 0.6rem; border-radius: var(--radius-s); color: #c9d3df; font-size: var(--fs-xs); font-weight: 600; }
  .copy-btn:hover { background: rgba(255, 255, 255, 0.08); }
  .code-block pre { padding: 1rem 1.1rem; overflow-x: auto; font-size: 0.86rem; line-height: 1.65; color: #d9e2ec; tab-size: 2; text-align: left; }
  .t-kw { color: var(--accent); }
  .t-str { color: #8fd6a8; }
  .t-num { color: #f5a97f; }
  .t-com { color: #7f8b9b; font-style: italic; }
  .t-fn { color: #9cc4ff; }
  .t-attr { color: var(--accent-2); }
  [data-mode="light"] .t-kw { color: #f2c66d; }
  [data-mode="light"] .t-attr { color: #7fb4ff; }
  .post-foot { display: grid; gap: 2rem; margin-block-start: 3.5rem; padding-block-start: 2rem; border-top: 1px solid var(--line); max-width: 46rem; }
  .share { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
  .share-label { font-weight: 600; margin-inline-end: 0.5rem; }
  .share a, .share button { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 40px; padding: 0.4rem 0.8rem; border: 1px solid var(--line-2); border-radius: var(--radius-m); color: var(--ink-2); text-decoration: none; font-size: var(--fs-sm); font-weight: 600; --icon-cut: var(--bg); }
  .share a:hover, .share button:hover { color: var(--accent); border-color: var(--accent); }
  .post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
  .post-nav a { display: grid; gap: 0.2rem; padding: 1rem 1.1rem; text-decoration: none; }
  .post-nav a small { color: var(--ink-3); font-size: var(--fs-xs); }
  .post-nav a span { font-weight: 600; }
  .post-nav .next { grid-column: 2; text-align: end; }
  @media (max-width: 600px) { .post-nav { grid-template-columns: 1fr; } .post-nav .next { grid-column: auto; } }

  /* Brand */
  .brand-section { padding-block: clamp(2.5rem, 6vw, 4.5rem); border-top: 1px solid var(--line); }
  .brand-section > h2 { margin-block-end: 0.5rem; }
  .brand-section > p { color: var(--ink-2); max-width: 60ch; margin-block-end: 2rem; }
  .emblem-demo { display: grid; grid-template-columns: auto 1fr; gap: clamp(1.5rem, 5vw, 4rem); align-items: center; }
  .clearspace { position: relative; width: clamp(180px, 30vw, 260px); aspect-ratio: 1; padding: 12.5%; border: 1px dashed var(--line-2); background: repeating-linear-gradient(45deg, transparent 0 7px, var(--line) 7px 8px); }
  .clearspace img { width: 100%; border-radius: 50%; }
  .rules { display: grid; gap: 0.6rem; }
  @media (max-width: 640px) { .emblem-demo { grid-template-columns: 1fr; } }
  .palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 1rem; }
  .palette { color: var(--ink); background: var(--bg); background-image: var(--texture); padding: 1.1rem; display: grid; gap: 0.75rem; }
  .palette h3 { font-size: var(--fs-base); display: flex; justify-content: space-between; gap: 0.5rem; }
  .palette h3 small { font-family: var(--font-body); font-weight: 400; color: var(--ink-2); font-size: var(--fs-xs); }
  .chipset { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .chipset span { aspect-ratio: 1; border-radius: 3px; border: 1px solid var(--line); }
  .palette code { font-size: 0.7rem; color: var(--ink-2); direction: ltr; text-align: start; }
  .type-specimen { display: grid; gap: 1.5rem; }
  .spec { display: grid; grid-template-columns: 12rem 1fr; gap: 1rem 2rem; padding-block: 1.25rem; border-bottom: 1px solid var(--line); align-items: baseline; }
  .spec small { color: var(--ink-3); }
  .spec .s-display { font-family: var(--font-display); font-size: var(--fs-2xl); line-height: 1.3; }
  .spec .s-body { font-size: var(--fs-md); }
  .spec .s-mono { font-family: var(--font-mono); font-size: var(--fs-md); direction: ltr; text-align: start; }
  @media (max-width: 700px) { .spec { grid-template-columns: 1fr; } }
  .motifs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 1.25rem; }
  .motif { padding: 1.5rem; display: grid; gap: 0.75rem; align-content: start; }
  .motif-art { height: 120px; display: grid; place-items: center; color: var(--accent); border-bottom: 1px solid var(--line); padding-block-end: 1rem; }
  .motif-art .wedge { width: 64px; height: 64px; }
  .motif-art .trace-art { width: 100%; height: 100%; }
  .motif-art .mini-tablet { width: 120px; height: 84px; --n: 22px; }
  .numerals { display: flex; flex-wrap: wrap; gap: 0.9rem 1.2rem; align-items: flex-end; }
  .numerals span { display: grid; justify-items: center; gap: 0.25rem; color: var(--ink-3); font-size: var(--fs-xs); }
  .numerals .babylon { height: 26px; width: auto; color: var(--accent); }

  /* 404 */
  .nf { display: grid; justify-items: start; gap: 1.25rem; padding-block: clamp(4rem, 12vw, 9rem); }
  .nf-term { font-family: var(--font-mono); font-size: 0.95rem; padding: 1rem 1.25rem; background: #050a12; color: #d9e2ec; border-radius: var(--radius-m); border: 1px solid var(--line-2); width: min(100%, 560px); text-align: left; }
  .nf-term .p { color: var(--accent); }
  .nf-term .err { color: #ff7a7a; }
  .nf h1 { font-size: var(--fs-3xl); }
  .nf p { color: var(--ink-2); max-width: 50ch; }
}

/* ---------- Motion ---------- */
@layer motion {
  @keyframes spin { to { rotate: 360deg; } }
  @keyframes blink { 50% { opacity: 0.35; } }
  @keyframes term-in { from { opacity: 0; translate: 0 14px; scale: 0.98; } }
  @keyframes rise { from { opacity: 0; translate: 0 14px; } }
  @keyframes emblem-in { from { opacity: 0; scale: 0.86; filter: brightness(1.7) saturate(0.6); } }
  @keyframes ring-draw { from { stroke-dashoffset: 620; } to { stroke-dashoffset: 0; } }
  @keyframes sheen { 0%, 70% { translate: -120% 0; } 100% { translate: 120% 0; } }
  @keyframes grow { from { --grow: 0px; } to { --grow: 2400px; } }
  @keyframes em-travel {
    30% { opacity: 0.16; }
    to { translate: 0 calc(50svh - var(--em) / 2 - var(--hero-top)); scale: var(--wm-scale); opacity: var(--wm); }
  }
  @keyframes fade-out { to { opacity: 0; } }
  @keyframes header-solid { to { background-color: color-mix(in srgb, var(--bg) 80%, transparent); border-bottom-color: var(--line); } }
  @keyframes draw { from { scale: 1 0; } to { scale: 1 1; } }
  @keyframes pad-on { to { background-color: var(--accent); } }
  @keyframes scan-ltr { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
  @keyframes scan-rtl { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
  @keyframes vt-reveal { from { clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 0)); } to { clip-path: circle(150vmax at var(--vt-x, 50%) var(--vt-y, 0)); } }

  @media (prefers-reduced-motion: no-preference) {
    /* One orchestrated load moment on the home page */
    .is-home .emblem { animation: emblem-in 1.1s var(--ease) both; }
    .is-home .emblem-ring .ring-trace { stroke-dasharray: 620; animation: ring-draw 1.6s var(--ease) 0.25s both; }
    .is-home .emblem-sheen::before { animation: sheen 7s var(--ease-in-out) 1.4s infinite; }
    .is-home .hero > :not(.hero-slot) { animation: rise 0.8s var(--ease) both; animation-delay: calc(var(--d, 0) * 1ms); }
    .is-home .bg-traces {
      -webkit-mask-image: radial-gradient(circle at 50% 38%, #000 var(--grow), transparent calc(var(--grow) + 22vmax));
      mask-image: radial-gradient(circle at 50% 38%, #000 var(--grow), transparent calc(var(--grow) + 22vmax));
      animation: grow 2.6s var(--ease) 0.2s both;
    }

    @supports (animation-timeline: scroll()) {
      .is-home .emblem-wrap { animation: em-travel linear both; animation-timeline: scroll(root); animation-range: 0 80vh; }
      .is-home .emblem-ring, .is-home .emblem-sheen { animation: fade-out linear both; animation-timeline: scroll(root); animation-range: 0 40vh; }
      .circuit::before { animation: draw linear both; animation-timeline: --circuit; animation-range: entry 20% cover 55%; }
      .node .pad { animation: pad-on linear both; animation-timeline: view(); animation-range: cover 30% cover 45%; }
      .scan { animation: scan-ltr linear both; animation-timeline: view(); animation-range: entry 0% entry 90%; }
      [dir="rtl"] .scan { animation-name: scan-rtl; }
      .read-progress { animation: draw-x linear both; animation-timeline: scroll(root); }
    }
    .vt-theme::view-transition-old(root) { animation: none; }
    .vt-theme::view-transition-new(root) { animation: vt-reveal 0.7s var(--ease) both; }
    .vt-theme::view-transition-group(*) { animation-duration: 0s; }
    .vt-theme::view-transition-group(root) { animation-duration: 0.7s; }
    ::view-transition-group(emblem) { animation-duration: 0.55s; animation-timing-function: var(--ease); }
    ::view-transition-group(*) { animation-duration: 0.35s; }
  }
  @keyframes draw-x { from { scale: 0 1; } to { scale: 1 1; } }

  @media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }
  }

  @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; }
    .member-inner { transition: none; }
  }
}

/* ---------- Utilities ---------- */
@layer utilities {
  .muted { color: var(--ink-2); }
  .ltr { direction: ltr; unicode-bidi: isolate; }
  .mt-0 { margin-top: 0; }
}

.tilt { transform-style: preserve-3d; will-change: transform; }
.tilt::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: var(--hl, 0); transition: opacity .35s var(--ease);
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 16%, transparent), transparent 65%); }
@media (prefers-reduced-motion: reduce) { .tilt::after { transition: none; } }

/* ---------- Palette, scroll progress, roster ---------- */
.scroll-progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 200; background: var(--accent); transform-origin: left; transform: scaleX(var(--sp, 0)); pointer-events: none; }
[dir="rtl"] .scroll-progress { transform-origin: right; }
.cmdk { width: min(620px, 92vw); margin: 12vh auto auto; padding: 0; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: 0 30px 80px rgba(0, 0, 0, .55); }
.cmdk::backdrop { background: rgba(2, 5, 12, .62); backdrop-filter: blur(4px); }
.cmdk input { display: block; width: 100%; box-sizing: border-box; padding: 1rem 1.1rem; background: transparent; border: 0; border-bottom: 1px solid var(--line); color: inherit; font: inherit; font-size: var(--fs-md); outline: none; }
.cmdk ul { list-style: none; margin: 0; padding: 6px; max-height: min(52vh, 420px); overflow: auto; }
.cmdk li[role="option"] { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem .8rem; border-radius: var(--radius-s); cursor: pointer; }
.cmdk li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.cmdk small { opacity: .6; }
.p-group { padding: .7rem .8rem .25rem; font: 500 var(--fs-xs)/1 var(--font-mono); letter-spacing: .12em; opacity: .55; }
.p-empty { padding: 1rem; opacity: .7; }
.p-foot { padding: .5rem .9rem; border-top: 1px solid var(--line); font-size: var(--fs-xs); opacity: .65; display: flex; gap: .4rem; }
.team-tools { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.view-toggle button { background: none; border: 0; color: var(--ink); padding: .5rem .95rem; font: inherit; font-size: var(--fs-sm); cursor: pointer; opacity: .7; }
.view-toggle button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); opacity: 1; }
[data-views][data-view="cards"] .roster-wrap, [data-views][data-view="roster"] .team-grid { display: none; }
.roster { width: 100%; margin-top: 18px; border-collapse: collapse; font-size: var(--fs-sm); }
.roster th, .roster td { text-align: start; padding: 1rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.roster thead th { font: 500 var(--fs-xs)/1 var(--font-mono); letter-spacing: .1em; opacity: .65; }
.roster-row[hidden] { display: none; }
.r-name { display: block; font-family: var(--font-display); font-size: var(--fs-md); }
.r-title { opacity: .7; }
.roster ul { margin: 0; padding: 0; list-style: none; display: grid; gap: .3rem; }
.r-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.r-links a, .m-links a.lbl { display: inline-flex; align-items: center; gap: .4rem; width: auto; height: auto; padding: .4rem .65rem; border: 1px solid var(--line); border-radius: var(--radius-s); color: inherit; text-decoration: none; font-size: var(--fs-xs); transition: color .2s, border-color .2s; }
.r-links a:hover, .m-links a.lbl:hover { color: var(--accent); border-color: var(--accent); }
.roster .i, .m-links a.lbl .i { width: 16px; height: 16px; }
.m-spec { margin: 0; font-size: var(--fs-sm); }
.m-quals { margin: 0; padding: 0; list-style: none; display: grid; gap: .25rem; font-size: var(--fs-sm); }
@media (max-width: 720px) {
  .roster thead { display: none; }
  .roster, .roster tbody, .roster tr, .roster td, .roster th { display: block; }
  .roster tr { padding: .9rem 0; border-bottom: 1px solid var(--line); }
  .roster th, .roster td { border: 0; padding: .35rem 0; }
  .roster td[data-label]::before { content: attr(data-label); display: block; font: 500 var(--fs-xs)/1.6 var(--font-mono); opacity: .55; }
}

/* ---------- Navigation aids: breadcrumbs, in-page bar, pager, back to top ---------- */
@layer components {
  .crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.5rem; list-style: none; margin: 0; padding: 0; font-size: var(--fs-sm); }
  .crumbs li { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink-3); }
  .crumbs li + li::before { content: "/"; color: var(--line-2); font-family: var(--font-mono); }
  .crumbs a:hover { text-decoration: underline; }
  .crumbs [aria-current="page"] { color: var(--ink-2); font-weight: 600; }

  .jump-nav {
    position: sticky;
    top: var(--header-h);
    z-index: 45;
    margin-block-end: clamp(1.5rem, 4vw, 2.5rem);
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    backdrop-filter: blur(14px) saturate(1.2);
    border-block: 1px solid var(--line);
  }
  .jump-inner { display: flex; align-items: center; gap: 1rem; min-height: 52px; }
  .jump-label { flex-shrink: 0; font: 500 var(--fs-xs)/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
  .jump-nav ul { display: flex; gap: 0.25rem; margin: 0; padding: 0.45rem 0; list-style: none; overflow-x: auto; scrollbar-width: none; }
  .jump-nav ul::-webkit-scrollbar { display: none; }
  .jump-nav a { display: block; white-space: nowrap; padding: 0.35rem 0.85rem; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); text-decoration: none; border: 1px solid transparent; border-radius: 999px; transition: color 0.2s, border-color 0.2s, background-color 0.2s; }
  .jump-nav a:hover { color: var(--ink); }
  .jump-nav a[aria-current] { color: var(--accent); border-color: var(--line-2); background: var(--surface); }
  html:lang(ar) .jump-label { font-family: var(--font-body); letter-spacing: 0; }
  @media (max-width: 640px) { .jump-label { display: none; } }
  html:has(.jump-nav) { scroll-padding-top: calc(var(--header-h) + 4.5rem); scroll-behavior: smooth; }

  .page-pager { margin-block-start: clamp(3rem, 7vw, 5rem); }
  .page-pager a span { transition: color 0.2s; }
  .page-pager a:hover span { color: var(--accent); }

  .to-top {
    position: fixed;
    inset-block-end: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    inset-inline-end: 1.25rem;
    z-index: 60;
    width: 44px;
    height: 44px;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--line-2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    translate: 0 10px;
    transition: opacity 0.25s var(--ease), translate 0.25s var(--ease), visibility 0s linear 0.25s, color 0.2s, background-color 0.2s;
  }
  .to-top.show { opacity: 1; visibility: visible; translate: 0 0; transition: opacity 0.25s var(--ease), translate 0.25s var(--ease), visibility 0s, color 0.2s, background-color 0.2s; }
  .to-top:hover { color: var(--accent); background: var(--surface-2); }

  .member:target .face, .project:target { animation: target-ring 2.6s var(--ease) 0.3s backwards; }
  @keyframes target-ring { 0%, 55% { box-shadow: inset 0 0 0 2px var(--accent); } 100% { box-shadow: inset 0 0 0 0 transparent; } }
}
