/* ═══════════ YARAAV PREMIUM — layered 3D glassmorphism design system v7 ═══════════
   Visual language adopted from the official YARAAV design reference:
   deep near-black brown base · bronze/copper metallics · translucent layered glass
   · edge illumination · aurora + light beams + horizon glow · fine grain.
   One system, two fully independent themes (data-theme on <html>).
   v7: instant theme switching (zero white flash) · GPU-cheap background
   (no giant blur filters — softness baked into gradients) · self-hosted
   Vazirmatn · new official emblems · perf-first animation layers.   */

/* ── 0. Self-hosted Vazirmatn (Persian UI) — no third-party CDN,
        font-display swap so text never waits on the font ── */
@font-face {
  font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-ExtraBold.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}

/* ── 1. Core tokens ── */
:root {
  --radius-s: 10px; --radius-m: 16px; --radius-l: 24px; --radius-pill: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px; --sp-16: 64px;
  --ease: cubic-bezier(.22,1,.36,1);
  --dur: 180ms;
  --font-fa: Vazirmatn, Tahoma, "Segoe UI", sans-serif;
  --focus-ring: 0 0 0 2px rgba(240, 166, 92, .40);
}
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  :root { --focus-ring: 0 0 0 2px color-mix(in srgb, var(--copper) 40%, transparent); }
}

/* ── 2. DARK theme — near-black brown + bronze/copper ambient light ── */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0806; --bg-2: #120C08;
  --surface: rgba(48, 30, 18, 0.48);          /* standard glass */
  --surface-raised: rgba(56, 36, 20, 0.62);   /* elevated glass */
  --surface-frost: rgba(40, 26, 14, 0.55);    /* frosted glass */
  --surface-hover: rgba(64, 42, 24, 0.58);
  --surface-solid: #1A110B;
  --border: rgba(205, 139, 75, 0.16);
  --border-strong: rgba(205, 139, 75, 0.28);
  --border-metal: rgba(240, 166, 92, 0.35);
  --text: #F7F0E8;
  --muted-c: #B8A494;
  --bronze: #B8753D; --bronze-metal: #CD8B4B;
  --copper: #F0A65C; --bright: #FFD09A;
  --accent: #B8753D; --accent-hi: #F5B66B;
  --accent-soft: rgba(240, 166, 92, 0.12);
  --grad-a: #E29A55; --grad-b: #B8753D; --grad-c: #8A5426; --grad-ink: #1A0E06;
  --grad-bronze: linear-gradient(135deg, #E29A55 0%, #B8753D 55%, #8A5426 100%);
  --grad-metal: linear-gradient(160deg, #FFD09A 0%, #F0A65C 30%, #B8753D 62%, #7A4A22 100%);
  --edge-glow: rgba(240, 166, 92, 0.55);
  --inner-hi: inset 0 1px 0 rgba(255, 220, 170, 0.10);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55), 0 4px 14px rgba(0, 0, 0, 0.40), inset 0 1px 0 rgba(255, 208, 154, 0.08);
  --shadow-btn: 0 6px 18px rgba(184, 117, 61, 0.35), inset 0 1px 0 rgba(255, 220, 170, 0.45);
  --glow-field: 0 0 0 1px var(--border-metal), 0 8px 40px rgba(240, 166, 92, 0.14), 0 20px 60px rgba(0, 0, 0, .5);
  --glow-1: rgba(240, 166, 92, 0.16);
  --glow-2: rgba(184, 117, 61, 0.14);
  --glow-3: rgba(255, 208, 154, 0.10);
  --aurora-1: rgba(184, 117, 61, 0.20);
  --aurora-2: rgba(240, 166, 92, 0.12);
  --beam-opacity: .07;
  --horizon: rgba(240, 166, 92, 0.20);
  --vignette: rgba(4, 2, 1, 0.55);
  --grain-opacity: .05;
  --streak-opacity: .10;
  --logo: url("../logo/emblem-dark.webp?v=8");
  --skeleton: rgba(240, 166, 92, .10);
  --scrim: rgba(6, 4, 2, 0.60);
}

/* ── 2b. LIGHT theme — warm ivory + cream depth (own palette, not recolored dark) ── */
[data-theme="light"] {
  color-scheme: light;
  --bg: #FCF8F2; --bg-2: #F5EDE2;
  --surface: rgba(255, 252, 247, 0.68);
  --surface-raised: rgba(255, 252, 247, 0.85);
  --surface-frost: rgba(255, 250, 242, 0.78);
  --surface-hover: rgba(255, 253, 250, 0.90);
  --surface-solid: #FFFCF8;
  --border: rgba(152, 96, 57, 0.16);
  --border-strong: rgba(152, 96, 57, 0.26);
  --border-metal: rgba(190, 139, 89, 0.40);
  --text: #34241A;
  --muted-c: #796656;
  --bronze: #986039; --bronze-metal: #BE8B59;
  --copper: #B4763F; --bright: #F5D6A8;
  --accent: #A96B3C; --accent-hi: #8B4F2B;
  --accent-soft: rgba(190, 139, 89, 0.12);
  --grad-a: #E8B57C; --grad-b: #BE8B59; --grad-c: #986039; --grad-ink: #241407;
  --grad-bronze: linear-gradient(135deg, #E8B57C 0%, #BE8B59 55%, #986039 100%);
  --grad-metal: linear-gradient(160deg, #FBE3B8 0%, #E5B06E 30%, #BE8B59 62%, #986039 100%);
  --edge-glow: rgba(229, 176, 110, 0.60);
  --inner-hi: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --shadow: 0 8px 28px rgba(152, 96, 57, 0.14), 0 2px 8px rgba(120, 80, 45, 0.08);
  --shadow-lg: 0 18px 45px rgba(152, 96, 57, 0.20), 0 4px 14px rgba(120, 80, 45, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  --shadow-btn: 0 6px 16px rgba(152, 96, 57, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  --glow-field: 0 0 0 1px var(--border-metal), 0 8px 34px rgba(229, 176, 110, 0.28), 0 18px 50px rgba(152, 96, 57, 0.12);
  --glow-1: rgba(245, 214, 168, 0.60);
  --glow-2: rgba(229, 176, 110, 0.34);
  --glow-3: rgba(255, 250, 240, 0.65);
  --aurora-1: rgba(229, 176, 110, 0.30);
  --aurora-2: rgba(245, 214, 168, 0.38);
  --beam-opacity: .16;
  --horizon: rgba(229, 176, 110, 0.35);
  --vignette: rgba(120, 80, 45, 0.16);
  --grain-opacity: .03;
  --streak-opacity: .35;
  --logo: url("../logo/emblem-light.webp?v=8");
  --skeleton: rgba(138, 90, 43, .12);
  --scrim: rgba(84, 56, 30, 0.28);
}

/* ── 3. Base ── */
* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Vazirmatn, Tahoma, sans-serif;
  font-size: 16px; line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh; overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
/* Theme flips must be INSTANT — a cross-fade passes through light
   intermediate colors and reads as a white flash on the dark theme. */
html.theme-switching, html.theme-switching *,
html.theme-switching *::before, html.theme-switching *::after {
  transition: none !important;
}
::selection { background: rgba(240, 166, 92, .35); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-raised); border-radius: var(--radius-s); }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; border-radius: var(--radius-s); }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
[lang="fa"], [dir="rtl"] { font-family: var(--font-fa); }

/* ── 4. Ambient background — cinematic layered depth ──
   Gradient mesh + two slow-rotating aurora fields + three drifting orbs
   + diagonal light beams + horizon glow + fine grain + vignette.
   All layers: fixed, pointer-events none, transform/opacity motion only.
   v7 perf: every layer's softness is baked into its own gradients and
   masks — no filter:blur() on oversized elements. This keeps raster
   cheap, page load fast and theme repaints instant. */
.bg-ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(1100px 700px at 50% -10%, var(--glow-1), transparent 65%),
    radial-gradient(900px 600px at 85% 110%, var(--glow-2), transparent 60%),
    radial-gradient(700px 500px at 8% 95%, var(--glow-3), transparent 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 45%);
}
/* aurora — huge conic light fields, barely there, slowly turning.
   Wide transparent fade bands + radial mask give the softness that
   previously required a 70px blur. */
.aurora {
  position: absolute; width: 130vmax; height: 130vmax;
  border-radius: 50%; opacity: .8;
  will-change: transform;
}
.aurora-1 {
  top: -65vmax; left: -25vmax;
  background: conic-gradient(from 120deg at 50% 50%,
    transparent 0deg, transparent 25deg, var(--aurora-1) 75deg,
    transparent 145deg, transparent 175deg, var(--aurora-2) 215deg,
    transparent 285deg, transparent 360deg);
  mask-image: radial-gradient(closest-side, #000 8%, rgba(0,0,0,.55) 32%, transparent 62%);
  -webkit-mask-image: radial-gradient(closest-side, #000 8%, rgba(0,0,0,.55) 32%, transparent 62%);
  animation: aurora-spin 90s linear infinite;
}
.aurora-2 {
  bottom: -82vmax; right: -32vmax;
  background: conic-gradient(from 300deg at 50% 50%,
    transparent 0deg, transparent 20deg, var(--aurora-2) 65deg,
    transparent 135deg, transparent 165deg, var(--aurora-1) 205deg,
    transparent 275deg, transparent 360deg);
  mask-image: radial-gradient(closest-side, #000 8%, rgba(0,0,0,.55) 30%, transparent 58%);
  -webkit-mask-image: radial-gradient(closest-side, #000 8%, rgba(0,0,0,.55) 30%, transparent 58%);
  animation: aurora-spin 120s linear infinite reverse;
}
@keyframes aurora-spin { to { transform: rotate(360deg); } }
/* orbs — radial gradients fade to transparent by design, so the 90px
   blur they used to carry is dropped entirely; stops spread wider to
   keep the same misty edge. */
.orb {
  position: absolute; border-radius: 50%; opacity: .6;
  will-change: transform;
}
.orb-1 {
  width: 560px; height: 560px; top: -180px; left: 50%; margin-left: -280px;
  background: radial-gradient(circle, var(--glow-1) 0%, transparent 62%);
  animation: orb-drift 30s ease-in-out infinite alternate;
}
.orb-2 {
  width: 480px; height: 480px; bottom: -220px; right: -120px;
  background: radial-gradient(circle, var(--glow-2) 0%, transparent 62%);
  animation: orb-drift 38s ease-in-out infinite alternate-reverse;
}
.orb-3 {
  width: 420px; height: 420px; bottom: -140px; left: -140px;
  background: radial-gradient(circle, var(--glow-3) 0%, transparent 62%);
  animation: orb-drift 46s ease-in-out infinite alternate;
}
@keyframes orb-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(40px, 26px, 0) scale(1.08); }
}
/* diagonal light beams — cathedral shafts of warm light.
   Horizontal softness comes from a mirrored mask instead of blur. */
.beam {
  position: absolute; top: -20%; width: 26vw; height: 150%;
  background: linear-gradient(180deg, var(--edge-glow), transparent 70%);
  opacity: var(--beam-opacity);
  transform: rotate(24deg);
  mask-image:
    linear-gradient(90deg, transparent 0%, #000 32%, #000 68%, transparent 100%),
    linear-gradient(180deg, #000, transparent 85%);
  mask-composite: intersect;
  -webkit-mask-image:
    linear-gradient(90deg, transparent 0%, #000 32%, #000 68%, transparent 100%),
    linear-gradient(180deg, #000, transparent 85%);
  -webkit-mask-composite: source-in;
  will-change: transform, opacity;
}
.beam-1 { left: 12vw; animation: beam-sway 26s ease-in-out infinite alternate; }
.beam-2 { right: 8vw; transform: rotate(-18deg); animation: beam-sway 34s ease-in-out infinite alternate-reverse; }
@keyframes beam-sway {
  from { opacity: calc(var(--beam-opacity) * .5); transform: rotate(24deg) translateX(-4vw); }
  to   { opacity: var(--beam-opacity); transform: rotate(24deg) translateX(4vw); }
}
.beam-2 { animation-name: beam-sway-2; }
@keyframes beam-sway-2 {
  from { opacity: var(--beam-opacity); transform: rotate(-18deg) translateX(3vw); }
  to   { opacity: calc(var(--beam-opacity) * .5); transform: rotate(-18deg) translateX(-3vw); }
}
/* warm horizon glow — a copper sunrise line at the bottom edge */
.horizon {
  position: absolute; left: 50%; bottom: -260px; width: 130vw; height: 320px;
  transform: translateX(-50%);
  background: radial-gradient(48% 100% at 50% 100%, var(--horizon) 0%, transparent 62%);
}
/* fine film grain */
.bg-grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}
/* cinematic vignette pulls focus to the center */
.bg-vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 40%, transparent 55%, var(--vignette) 100%);
}
@media (max-width: 640px) {
  .orb-3 { display: none; }
  .beam { width: 34vw; }
}

/* ── 5. Utility classes (layout contract with PHP templates) ── */
.muted { color: var(--muted-c); }
.min-h-screen { min-height: 100vh; }
.page-root { position: relative; z-index: 10; }
.flex { display: flex; } .flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.px-5 { padding-left: 20px; padding-right: 20px; }
.py-4 { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
.p-5 { padding: 20px; }
.mb-10 { margin-bottom: var(--sp-12); }
.mt-10 { margin-top: var(--sp-12); }
.w-full { width: 100%; }
.max-w-2xl { max-width: 672px; }
.shrink-0 { flex-shrink: 0; }
.text-center { text-align: center; }
.gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.hidden { display: none; }

/* ── 6. Icons ── */
.icon { width: 24px; height: 24px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 12px; height: 12px; }
.icon-lg { width: 40px; height: 40px; }
.muted-icon { color: var(--muted-c); display: inline-flex; }

/* ── 7. Official emblem — transparent cutouts of the bronze/black-gold Y ── */
.logo-mark {
  display: inline-block; position: relative;
  width: 96px; height: 96px;
  background: var(--logo) center / contain no-repeat;
  filter: drop-shadow(0 14px 28px rgba(184, 117, 61, .30)) drop-shadow(0 3px 8px rgba(0, 0, 0, .35));
}
.logo-mark::before { /* warm copper halo behind the emblem */
  content: ''; position: absolute; inset: -16%; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow-1), transparent 72%);
}
.logo-lg .logo-mark { width: 132px; height: 132px; }
.mark-sm.logo-mark, .logo-sm .logo-mark { width: 30px; height: 30px; }
.logo-sm .logo-mark::before { inset: -30%; opacity: .8; }

/* ── 8. Wordmark ── */
.logo { display: flex; align-items: center; gap: var(--sp-3); user-select: none; }
.logo-text.wordmark {
  font-weight: 800; letter-spacing: .30em; font-size: 20px;
  background: var(--grad-metal);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo-lg { flex-direction: column; gap: var(--sp-4); }
.logo-lg .logo-text { font-size: clamp(38px, 8vw, 60px); letter-spacing: .32em; text-indent: .32em; }

/* ── 9. Glass material system ── */
.glass {
  background: var(--surface);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow), var(--inner-hi);
}
@supports not (backdrop-filter: blur(1px)) { .glass { background: var(--surface-raised); } }
.glass-strong {
  background: var(--surface);
  -webkit-backdrop-filter: blur(24px) saturate(1.25);
  backdrop-filter: blur(24px) saturate(1.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-lg), var(--inner-hi);
}
@supports not (backdrop-filter: blur(1px)) { .glass-strong { background: var(--surface-raised); } }

/* bronze edge illumination — 1px gradient border via mask compositing */
.edge-bronze { position: relative; }
.edge-bronze::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  padding: 1px;
  background: linear-gradient(140deg, var(--edge-glow), transparent 35%, transparent 65%, rgba(240, 166, 92, .25));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: .8;
}
/* reflected light streak along the top edge */
.streak { position: relative; }
.streak::after {
  content: ""; position: absolute; top: 0; left: 8%; width: 55%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 208, 154, .8), transparent);
  opacity: var(--streak-opacity); pointer-events: none; border-radius: 1px;
}

/* ── 10. Buttons — tactile, three-dimensional ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-radius: var(--radius-s); padding: 0 var(--sp-3); height: 40px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow), var(--inner-hi);
  transition: border-color var(--dur) ease, background var(--dur) ease,
              transform var(--dur) var(--ease), box-shadow var(--dur) ease;
}
@supports not (backdrop-filter: blur(1px)) { .btn { background: var(--surface-raised); } }
.btn:hover { border-color: var(--border-metal); background: var(--surface-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.97); box-shadow: var(--inner-hi); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.lang-btn {
  min-width: 40px; height: 40px; padding: 0 var(--sp-3); border-radius: var(--radius-s);
  font-weight: 700; font-size: 14px; letter-spacing: .04em;
}
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: var(--radius-s); }
.icon-btn-sm { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-s); }
.go-btn {
  width: 42px; height: 42px; border: 1px solid rgba(255, 208, 154, .40); border-radius: 50%; flex-shrink: 0;
  background: var(--grad-bronze); color: var(--grad-ink); display: grid; place-items: center;
  box-shadow: var(--shadow-btn);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) ease, filter var(--dur) ease;
}
[data-theme="light"] .go-btn { border-color: rgba(255, 255, 255, .45); }
.go-btn:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 24px rgba(184, 117, 61, .45), inset 0 1px 0 rgba(255, 220, 170, .5); }
.go-btn:active { transform: scale(.94); }
.go-btn-sm { width: 34px; height: 34px; }
.go-btn-wide {
  height: 42px; padding: 0 var(--sp-6); border: 1px solid rgba(255, 208, 154, .35); border-radius: var(--radius-pill);
  background: var(--grad-bronze); color: var(--grad-ink); font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-btn);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) ease;
}
.go-btn-wide:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(184, 117, 61, .42), inset 0 1px 0 rgba(255, 220, 170, .5); }
.go-btn-wide:active { transform: scale(.97); }
.retry-btn {
  padding: var(--sp-2) var(--sp-6); border-radius: var(--radius-pill);
  border: 1px solid var(--border-metal); font-weight: 600; font-size: 14px;
  color: var(--copper); background: var(--surface);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: var(--shadow), var(--inner-hi);
  transition: border-color var(--dur) ease, background var(--dur) ease, transform var(--dur) var(--ease);
}
.retry-btn:hover { border-color: var(--edge-glow); background: var(--surface-hover); transform: translateY(-1px); }
.retry-btn:active { transform: scale(.97); }
.retry-btn.ghost { color: var(--muted-c); border-color: var(--border); }
.state-actions { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; }

/* ── 11. Search surfaces ── */
.search-wrap { position: relative; }
.search-shell {
  background: var(--surface);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  backdrop-filter: blur(22px) saturate(1.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-lg), var(--inner-hi);
  transition: box-shadow var(--dur) ease, border-color var(--dur) ease, background var(--dur) ease;
}
@supports not (backdrop-filter: blur(1px)) { .search-shell { background: var(--surface-raised); } }
.search-shell:focus-within {
  border-color: var(--border-metal);
  box-shadow: var(--glow-field), var(--inner-hi);
}
.search-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 17px; min-width: 0;
}
.search-input::placeholder { color: var(--muted-c); }
.search-compact {
  flex: 1; max-width: 672px; position: relative;
  padding: 6px 12px; border-radius: var(--radius-pill); display: flex; align-items: center; gap: var(--sp-2);
  background: var(--surface);
  -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), var(--inner-hi);
  transition: border-color var(--dur) ease, box-shadow var(--dur) ease;
}
@supports not (backdrop-filter: blur(1px)) { .search-compact { background: var(--surface-raised); } }
.search-compact:focus-within { border-color: var(--border-metal); box-shadow: var(--glow-field), var(--inner-hi); }
.search-compact .search-input { font-size: 15px; }
.js-clear-btn { color: var(--muted-c); }
.js-clear-btn:hover { color: var(--text); }

/* ── 12. Suggestions ── */
.suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  padding: var(--sp-2) 0; z-index: 50; list-style: none;
  max-height: 320px; overflow-y: auto; border-radius: var(--radius-m);
  background: var(--surface-frost);
  -webkit-backdrop-filter: blur(30px) saturate(1.35); backdrop-filter: blur(30px) saturate(1.35);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg), var(--inner-hi);
}
@supports not (backdrop-filter: blur(1px)) { .suggestions { background: var(--surface-raised); } }
.suggestions li button {
  width: 100%; text-align: start; padding: var(--sp-2) var(--sp-4); border: none; background: transparent;
  color: var(--text); font-size: 14px;
}
.suggestions li button:hover, .suggestions li button.hl { background: var(--accent-soft); }
[dir="rtl"] .suggestions li button { text-align: right; }

/* ── 13. Chips / pills ── */
.chip {
  padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-pill); font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: var(--inner-hi);
  transition: border-color var(--dur) ease, background var(--dur) ease, transform var(--dur) var(--ease), box-shadow var(--dur) ease;
}
@supports not (backdrop-filter: blur(1px)) { .chip { background: var(--surface-raised); } }
.chip:hover { border-color: var(--border-metal); background: var(--surface-hover); transform: translateY(-1px); }
.chip-ghost {
  background: transparent; box-shadow: none; border-style: dashed;
  border-color: var(--border-metal); color: var(--copper); font-size: 13px;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.chip-ghost:hover { background: var(--accent-soft); }

/* ── 14. Welcome message ── */
.animate-fade-up { animation: fadeUp .7s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.welcome { margin-top: var(--sp-4); font-size: 15px; min-height: 24px; color: var(--muted-c); animation: fadeIn .5s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── 15. Footer / hero ── */
.footer { padding-bottom: var(--sp-6); font-size: 12px; margin-top: auto; letter-spacing: .05em; }
.home { min-height: 100vh; }

/* ── 16. Results header ── */
.results-header {
  position: sticky; top: 0; z-index: 40; border-radius: 0;
  border-left: none; border-right: none; border-top: none;
  padding: var(--sp-3) clamp(16px, 4vw, 32px);
  background: var(--surface-frost);
  -webkit-backdrop-filter: blur(26px) saturate(1.3); backdrop-filter: blur(26px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
@supports not (backdrop-filter: blur(1px)) { .results-header { background: var(--surface-raised); } }
[data-theme="light"] .results-header { box-shadow: 0 12px 34px rgba(152, 96, 57, 0.12); }
.results-header-inner { max-width: 1152px; margin: 0 auto; display: flex; align-items: center; gap: var(--sp-3); }
.results-toolbar {
  max-width: 1152px; margin: var(--sp-3) auto 0; display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: var(--sp-3);
}
.mobile-only { display: none; margin-top: var(--sp-2); }
@media (max-width: 640px) {
  .hidden-mobile { display: none !important; }
  .mobile-only { display: flex; }
  .results-toolbar { justify-content: center; }
  .card-url { display: none; }
}
.results-stats { font-size: 12px; }

/* ── 17. Tabs ── */
.tabs {
  display: inline-flex; gap: var(--sp-1); padding: var(--sp-1); border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: var(--shadow), var(--inner-hi); flex-wrap: wrap;
}
@supports not (backdrop-filter: blur(1px)) { .tabs { background: var(--surface-raised); } }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-pill);
  color: var(--muted-c); font-size: 14px; font-weight: 600;
  transition: color var(--dur) ease, background var(--dur) ease, box-shadow var(--dur) ease;
}
.tab:hover { color: var(--text); background: var(--accent-soft); }
.tab.active {
  color: var(--grad-ink);
  background: var(--grad-bronze);
  box-shadow: var(--shadow-btn);
}

/* ── 18. Domain indicator ── */
.domain-indicator {
  max-width: 1152px; margin: var(--sp-2) auto 0; display: flex; align-items: center; gap: var(--sp-2);
  font-size: 13px;
}
.domain-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px var(--sp-3); border-radius: var(--radius-pill);
  background: var(--accent-soft); border: 1px solid var(--border-metal); color: var(--text); font-weight: 500;
}
.chip-x { display: inline-flex; color: var(--muted-c); }
.chip-x:hover { color: var(--copper); }

/* ── 19. Advanced search — CENTERED modal dialog (elevated frosted glass) ── */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60; background: var(--scrim);
  border: none; padding: 0;
  -webkit-backdrop-filter: blur(6px) saturate(1.1); backdrop-filter: blur(6px) saturate(1.1);
  animation: fadeIn .2s ease both;
}
.drawer {
  position: fixed; z-index: 61;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: var(--sp-6);
  background: var(--surface-frost);
  -webkit-backdrop-filter: blur(32px) saturate(1.4); backdrop-filter: blur(32px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-lg), var(--inner-hi), 0 0 80px rgba(240, 166, 92, 0.10);
  animation: modalIn .28s var(--ease) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.94) translateY(-8px); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1) translateY(0); }
}
@supports not (backdrop-filter: blur(1px)) { .drawer { background: var(--surface-raised); } }
.drawer.edge-bronze::before { border-radius: inherit; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.drawer-title { font-size: 16px; font-weight: 700; letter-spacing: .02em; }
.drawer-note { font-size: 12px; line-height: 1.6; margin-bottom: var(--sp-4); }
.drawer-error {
  margin-top: var(--sp-3); font-size: 13px; line-height: 1.55;
  color: var(--copper); background: var(--accent-soft);
  border: 1px solid var(--border-metal); border-radius: var(--radius-s);
  padding: var(--sp-2) var(--sp-3);
}
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted-c); margin-bottom: var(--sp-1); }
.text-input {
  width: 100%; height: 42px; padding: 0 var(--sp-3);
  background: var(--surface); color: var(--text);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong); border-radius: var(--radius-s); font-size: 15px;
  box-shadow: var(--inner-hi);
  transition: border-color var(--dur) ease, box-shadow var(--dur) ease;
}
@supports not (backdrop-filter: blur(1px)) { .text-input { background: var(--surface-raised); } }
.text-input::placeholder { color: var(--muted-c); }
.text-input:focus { outline: none; border-color: var(--border-metal); box-shadow: 0 0 0 3px rgba(240, 166, 92, .14), var(--inner-hi); }
.hint { font-size: 11px; margin-top: var(--sp-1); }
.domain-suggestions { margin-top: var(--sp-3); display: flex; flex-wrap: wrap; gap: var(--sp-2); max-height: 180px; overflow-y: auto; }
.domain-suggestions:empty { display: none; }
.domain-sug-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px var(--sp-3); border-radius: var(--radius-pill); font-size: 13px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: border-color var(--dur) ease, background var(--dur) ease;
}
.domain-sug-chip:hover { border-color: var(--border-metal); background: var(--surface-hover); }
.drawer-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-6); }

/* ── 20. Results body / cards ── */
.results-body { max-width: 768px; margin: var(--sp-8) auto 0; padding: 0 clamp(16px, 4vw, 32px) var(--sp-6); }
.results-body.images-mode { max-width: 1100px; }
.result-grid { display: grid; gap: var(--sp-4); }
.result-grid.images { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .result-grid.images { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: block; padding: var(--sp-4);
  background: var(--surface);
  -webkit-backdrop-filter: blur(16px) saturate(1.15); backdrop-filter: blur(16px) saturate(1.15);
  border: 1px solid var(--border); border-radius: var(--radius-m);
  box-shadow: var(--shadow), var(--inner-hi);
  transition: transform var(--dur) var(--ease), border-color var(--dur) ease,
              box-shadow var(--dur) ease, background var(--dur) ease;
  animation: cardIn .35s ease both; overflow-wrap: anywhere;
}
@supports not (backdrop-filter: blur(1px)) { .card { background: var(--surface-raised); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card:hover {
  transform: translateY(-3px); border-color: var(--border-metal);
  background: var(--surface-hover);
  box-shadow: var(--shadow-lg), var(--inner-hi);
}
.card .card-meta { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); font-size: 12px; color: var(--muted-c); min-width: 0; }
.card .card-meta img { width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0; }
.card h3 { font-size: 17px; font-weight: 600; line-height: 1.35; margin-bottom: 4px; color: var(--copper); }
.card .card-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card .card-snippet { font-size: 14px; color: var(--muted-c); line-height: 1.65; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card.news-card h3 { color: var(--text); }
.news-src { color: var(--copper); }
.card.image-card { padding: 0; overflow: hidden; }
.card.image-card img.thumb {
  width: 100%; height: 176px; object-fit: cover; display: block;
  background: var(--surface-raised); /* reserved space — reduces CLS while loading */
  transition: transform .3s var(--ease);
}
.card.image-card:hover img.thumb { transform: scale(1.04); }
.card.image-card .card-body { padding: var(--sp-3); }
.card.image-card .card-title { font-size: 14px; font-weight: 500; color: var(--text); }
[dir="rtl"] .card .card-meta { flex-direction: row-reverse; justify-content: flex-end; }
[dir="rtl"] .card .card-url { direction: ltr; text-align: left; unicode-bidi: embed; }
[dir="rtl"] .card h3, [dir="rtl"] .card .card-snippet { text-align: right; }

/* ── 21. Skeletons ── */
.skeleton { background: var(--skeleton); border-radius: var(--radius-s); position: relative; overflow: hidden; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07), transparent);
  background-size: 500px 100%; animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { 0% { background-position: -500px 0; } 100% { background-position: 500px 0; } }
.sk-card { padding: var(--sp-4); display: grid; gap: var(--sp-3); border-radius: var(--radius-m); }
.sk-card .s1 { height: 14px; width: 192px; } .sk-card .s2 { height: 22px; width: 75%; }
.sk-card .s3 { height: 14px; width: 100%; } .sk-card .s4 { height: 14px; width: 83%; }
.sk-img .s1 { height: 176px; border-radius: 0; }

/* ── 22. States ── */
.state-box { padding: var(--sp-12) var(--sp-6); text-align: center; }
.state-box .emoji-icon { color: var(--muted-c); margin-bottom: var(--sp-3); }
.state-box .emoji-icon .icon-lg { width: 44px; height: 44px; }
.state-box .title { font-weight: 600; margin-bottom: var(--sp-2); }
.state-box .msg { font-size: 14px; color: var(--muted-c); margin-bottom: var(--sp-4); line-height: 1.7; }

/* ── 23. Pagination ── */
.pagination {
  max-width: 768px; margin: var(--sp-8) auto var(--sp-16);
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--sp-2);
  padding: 0 clamp(16px, 4vw, 32px);
}
.page-btn {
  min-width: 36px; height: 36px; padding: 0 var(--sp-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border-radius: var(--radius-s); font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: var(--inner-hi);
  transition: border-color var(--dur) ease, background var(--dur) ease, transform var(--dur) var(--ease), box-shadow var(--dur) ease;
}
@supports not (backdrop-filter: blur(1px)) { .page-btn { background: var(--surface-raised); } }
a.page-btn:hover { border-color: var(--border-metal); background: var(--surface-hover); transform: translateY(-1px); }
a.page-btn:active { transform: scale(.95); }
.page-btn.current { background: var(--grad-bronze); color: var(--grad-ink); border-color: rgba(255, 208, 154, .4); box-shadow: var(--shadow-btn); }
.page-btn.disabled { opacity: .38; pointer-events: none; box-shadow: none; }
.pagination.is-loading .page-btn { opacity: .55; pointer-events: none; }
.page-btn.loading { opacity: .6; pointer-events: none; }

/* ── 24. RTL chrome polish (Persian UI) ──
   Flex layouts mirror automatically via dir=rtl; only directional details
   need explicit help. */
[dir="rtl"] .search-wrap, [dir="rtl"] .search-compact { direction: rtl; }
[dir="rtl"] input[type="text"],
[dir="rtl"] .text-input { text-align: right; }
[dir="rtl"] input[dir="auto"] { text-align: start; }
[dir="rtl"] .page-btn .icon-sm:first-child { transform: scaleX(-1); }
[dir="rtl"] a.page-btn:last-child .icon-sm, [dir="rtl"] a.page-btn[rel="prev"] .icon-sm { transform: scaleX(-1); }
[dir="rtl"] .drawer-note, [dir="rtl"] .hint, [dir="rtl"] .drawer-error { text-align: right; }
[dir="rtl"] .drawer-head { direction: rtl; }
[dir="rtl"] .results-header-inner { direction: rtl; }
[dir="rtl"] .tabs { direction: rtl; }
[dir="rtl"] .drawer-actions { direction: rtl; }

/* ── 25. Motion preferences ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
  .orb, .aurora, .beam { animation: none !important; }
}
