/* =========================================================================
   شاهر إسماعيل | TECH — CINEMATIC PORTAL THEME
   Philosophy: Break flat digital → tangible, warm, cinematic studio feel
   ========================================================================= */

/* ── Google Fonts (loaded via HTML <link>) ────────────────────────────────
   Changa: ExtraBold headlines
   Cairo:  Arabic body
   Inter:  English body / UI
   JetBrains Mono: code / mono
   ──────────────────────────────────────────────────────────────────────── */

:root {
  /* ─── Core Palette ─── */
  --bg:              #0a0b0b;
  --bg-soft:         #100e0b;
  --bg-studio:       #14110c;
  --card:            #17140f;
  --card-hover:      #211c14;
  --border:          #32291c;
  --border-warm:     #3a3225;

  /* ─── Brand Colors ─── */
  --teal:            #c8952e;
  --teal-dark:       #8a651e;
  --teal-deep:       #1a1409;
  --teal-glow:       rgba(200, 149, 46, 0.25);
  --teal-light:      #6b5626;
  --olive:           #4a4a30;
  --olive-dark:      #333322;
  --matte-black:     #111111;

  /* ─── Warm Tones ─── */
  --beige:           #d4c5a9;
  --beige-soft:      #b8a88e;
  --beige-muted:     #8a7d68;

  /* ─── Accent: Warm Gold / Amber ─── */
  --gold:            #c8952e;
  --gold-bright:     #e6b84d;
  --gold-dim:        #a07824;
  --amber:           #d4a234;
  --amber-glow:      rgba(212, 162, 52, 0.15);
  --amber-glow-strong: rgba(212, 162, 52, 0.30);

  /* ─── Semantic ─── */
  --success:         #6db87a;
  --error:           #c75a5a;

  /* ─── Surfaces ─── */
  --radius:          12px;
  --radius-sm:       8px;
  --radius-xs:       5px;
  --shadow-warm:     0 8px 32px rgba(0, 0, 0, .55), 0 2px 8px rgba(200, 149, 46, .06);
  --shadow-card:     0 4px 20px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(212, 197, 169, .04);
  --shadow-glow:     0 0 30px rgba(200, 149, 46, .12), 0 0 60px rgba(200, 149, 46, .05);

  /* ─── Typography ─── */
  --font-ar:         "WahbaSans", "Cairo", "Changa", "Tajawal", sans-serif;
  --font-headline:   "WahbaSans", "Changa", "Cairo", sans-serif;
  --font-en:         "WahbaSans", "Inter", "Segoe UI", system-ui, sans-serif;
  --font:            var(--font-ar);
  --mono:            "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  /* ─── Film Grain ─── */
  --grain-opacity:   0.03;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* ─────────────────────────────────────────────────────────────────────────
   BODY — Dark studio environment with warm tungsten wash
   ───────────────────────────────────────────────────────────────────────── */
body {
  margin: 0;
  background: var(--bg);
  color: var(--beige);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ── Warm tungsten ambient light (top-left key light) ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 15% 10%, rgba(200, 149, 46, .07) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 85% 80%, rgba(200, 149, 46, .08) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(74, 74, 48, .04) 0%, transparent 60%);
}

/* ── Film grain overlay ── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  mix-blend-mode: overlay;
}

/* ─────────────────────────────────────────────────────────────────────────
   GOLDEN BORDER FRAME — Geometric thin frame around the entire viewport
   ───────────────────────────────────────────────────────────────────────── */
.golden-frame {
  position: fixed;
  inset: 6px;
  border: 1px solid rgba(200, 149, 46, .18);
  border-radius: 4px;
  pointer-events: none;
  z-index: 9998;
}
.golden-frame::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(200, 149, 46, .08);
  border-radius: 3px;
}

/* ─────────────────────────────────────────────────────────────────────────
   DUST PARTICLES — Micro particles floating in the tungsten light path
   ───────────────────────────────────────────────────────────────────────── */
.dust-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.dust {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(212, 197, 169, .25);
  border-radius: 50%;
  animation: dustFloat linear infinite;
}

.dust:nth-child(1)  { left: 8%;  top: -5%;  width: 2px;   height: 2px;   animation-duration: 18s; animation-delay: 0s;   opacity: .3; }
.dust:nth-child(2)  { left: 22%; top: -8%;  width: 1.5px; height: 1.5px; animation-duration: 22s; animation-delay: 3s;   opacity: .2; }
.dust:nth-child(3)  { left: 45%; top: -3%;  width: 2.5px; height: 2.5px; animation-duration: 16s; animation-delay: 1s;   opacity: .35; }
.dust:nth-child(4)  { left: 60%; top: -6%;  width: 1px;   height: 1px;   animation-duration: 25s; animation-delay: 5s;   opacity: .2; }
.dust:nth-child(5)  { left: 75%; top: -4%;  width: 2px;   height: 2px;   animation-duration: 20s; animation-delay: 2s;   opacity: .25; }
.dust:nth-child(6)  { left: 35%; top: -7%;  width: 1.5px; height: 1.5px; animation-duration: 28s; animation-delay: 7s;   opacity: .18; }
.dust:nth-child(7)  { left: 88%; top: -2%;  width: 2px;   height: 2px;   animation-duration: 19s; animation-delay: 4s;   opacity: .22; }
.dust:nth-child(8)  { left: 52%; top: -9%;  width: 1px;   height: 1px;   animation-duration: 24s; animation-delay: 6s;   opacity: .15; }
.dust:nth-child(9)  { left: 15%; top: -5%;  width: 3px;   height: 3px;   animation-duration: 30s; animation-delay: 8s;   opacity: .12; }
.dust:nth-child(10) { left: 70%; top: -3%;  width: 1.5px; height: 1.5px; animation-duration: 21s; animation-delay: 1.5s; opacity: .28; }

@keyframes dustFloat {
  0%   { transform: translateY(0)    translateX(0)     rotate(0deg);   opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(110vh) translateX(40px) rotate(360deg); opacity: 0; }
}

/* ─────────────────────────────────────────────────────────────────────────
   BOKEH CIRCLES — Soft out-of-focus light orbs in the background
   ───────────────────────────────────────────────────────────────────────── */
.bokeh-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bokeh {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  animation: bokehPulse ease-in-out infinite alternate;
}

.bokeh:nth-child(1) {
  width: 200px; height: 200px;
  background: rgba(200, 149, 46, .04);
  top: 20%; left: 5%;
  animation-duration: 8s;
}
.bokeh:nth-child(2) {
  width: 300px; height: 300px;
  background: rgba(200, 149, 46, .05);
  top: 60%; right: 10%;
  animation-duration: 10s;
  animation-delay: 2s;
}
.bokeh:nth-child(3) {
  width: 150px; height: 150px;
  background: rgba(74, 74, 48, .04);
  top: 40%; left: 50%;
  animation-duration: 12s;
  animation-delay: 4s;
}
.bokeh:nth-child(4) {
  width: 250px; height: 250px;
  background: rgba(200, 149, 46, .03);
  bottom: 10%; left: 30%;
  animation-duration: 9s;
  animation-delay: 1s;
}

@keyframes bokehPulse {
  0%   { transform: scale(1)   translate(0, 0);      opacity: .5; }
  100% { transform: scale(1.2) translate(10px, -8px); opacity: 1; }
}

/* ─────────────────────────────────────────────────────────────────────────
   HEADER — Cinematic studio header with Arabic branding
   ───────────────────────────────────────────────────────────────────────── */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 11, 11, .92);
  backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, .4);
}

.header-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 16px 20px 8px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Brand ── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--beige);
  transition: transform .2s ease;
}
.brand:hover { transform: translateY(-1px); }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: var(--gold-bright);
  font-size: 20px;
  font-weight: 800;
  box-shadow:
    0 2px 12px rgba(200, 149, 46, .4),
    inset 0 1px 0 rgba(255, 255, 255, .08);
  border: 1px solid rgba(200, 149, 46, .5);
  position: relative;
  overflow: hidden;
}

/* Embossed light catch on brand mark */
.brand-mark::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.08) 0%, transparent 100%);
  border-radius: 10px 10px 0 0;
}

.brand-name {
  font-family: var(--font-headline);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: .3px;
  white-space: nowrap;
  color: var(--beige);
}

.brand-accent {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(200, 149, 46, .3);
}

.brand-separator {
  color: var(--beige-muted);
  font-weight: 300;
  margin: 0 2px;
  opacity: .5;
}

.brand-ar {
  font-family: var(--font-headline);
  font-weight: 800;
  font-size: 15px;
  color: var(--beige-soft);
  letter-spacing: 0;
}

/* ── Sub-Ribbon ── */
.sub-ribbon {
  display: block;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}
.sub-ribbon-inner {
  background: linear-gradient(90deg, var(--teal-dark) 0%, var(--teal) 50%, var(--teal-dark) 100%);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 5px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: rgba(212, 197, 169, .7);
  letter-spacing: .5px;
  border: 1px solid rgba(200, 149, 46, .3);
  border-top: none;
}
.sub-ribbon-label {
  font-family: var(--font-en);
  text-transform: uppercase;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--gold-dim);
}

/* ── Search ── */
.search-wrap {
  flex: 1 1 240px;
  min-width: 200px;
}

/* ── Category Chips ── */
.category-chips {
  max-width: 1140px;
  margin: 0 auto;
  padding: 6px 20px 14px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--beige-muted);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 12.5px;
  font-family: var(--font);
  cursor: pointer;
  transition: all .25s ease;
  position: relative;
  overflow: hidden;
}

.chip::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(200, 149, 46, .08) 0%, transparent 60%);
  opacity: 0;
  transition: opacity .25s ease;
}

.chip:hover {
  color: var(--beige);
  border-color: var(--gold-dim);
  box-shadow: 0 0 12px rgba(200, 149, 46, .08);
}
.chip:hover::before { opacity: 1; }

.chip-active {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  border-color: var(--teal);
  color: var(--beige);
  box-shadow: 0 2px 12px rgba(200, 149, 46, .3);
}
.chip-active::before { display: none; }

/* ─────────────────────────────────────────────────────────────────────────
   MAIN GRID — Tools displayed on dark walnut desk surface
   ───────────────────────────────────────────────────────────────────────── */
.portal-main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 20px 70px;
  position: relative;
  z-index: 2;
}

.tools-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}

/* ── Tool Card — Tangible, embossed, with warm lighting interaction ── */
.tool-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  background: var(--card);
  color: var(--beige);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  font-family: var(--font);
  position: relative;
  overflow: hidden;
  transition: all .3s cubic-bezier(.22, .61, .36, 1);

  /* Subtle wood-desk shadow beneath */
  box-shadow:
    0 2px 8px rgba(0, 0, 0, .3),
    inset 0 1px 0 rgba(255, 255, 255, .03);
}

/* Tungsten light reflection on card surface */
.tool-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 20%, rgba(200, 149, 46, .04) 0%, transparent 50%);
  pointer-events: none;
  transition: opacity .3s ease;
}

/* Warm rim light on bottom edge */
.tool-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 149, 46, .15), transparent);
  transition: all .3s ease;
}

.tool-card:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: rgba(200, 149, 46, .25);
  background: var(--card-hover);
  box-shadow:
    var(--shadow-warm),
    0 0 40px rgba(200, 149, 46, .05);
}

.tool-card:hover::before {
  opacity: 1;
  background: radial-gradient(ellipse at 30% 20%, rgba(200, 149, 46, .08) 0%, transparent 50%);
}

.tool-card:hover::after {
  left: 5%;
  right: 5%;
  background: linear-gradient(90deg, transparent, rgba(200, 149, 46, .3), transparent);
}

.tool-card-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── 3D Keycap Emoji — Mechanical keyboard key style ── */
.tool-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 22px;
  line-height: 1;
  background: linear-gradient(180deg, #2a2f2a 0%, #1a1f1a 60%, #151a15 100%);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .06);
  box-shadow:
    0 3px 0 #0a0d0a,
    0 4px 8px rgba(0, 0, 0, .4),
    inset 0 1px 0 rgba(255, 255, 255, .08),
    inset 0 -1px 0 rgba(0, 0, 0, .2);
  position: relative;
  transition: all .15s ease;
}

/* Keycap top surface highlight */
.tool-emoji::after {
  content: '';
  position: absolute;
  top: 2px; left: 3px; right: 3px;
  height: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,.06) 0%, transparent 100%);
  border-radius: 6px 6px 0 0;
  pointer-events: none;
}

.tool-card:hover .tool-emoji {
  box-shadow:
    0 3px 0 #0a0d0a,
    0 4px 12px rgba(0, 0, 0, .5),
    inset 0 1px 0 rgba(255, 255, 255, .1),
    0 0 20px rgba(200, 149, 46, .12);
}

.tool-category-tag {
  font-size: 10px;
  color: var(--beige-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  font-family: var(--font-en);
  background: rgba(74, 74, 48, .2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 500;
}

.tool-card-title {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-headline);
  color: var(--beige);
  letter-spacing: .2px;
}

.tool-card-desc {
  font-size: 13px;
  color: var(--beige-muted);
  line-height: 1.5;
}

.no-results {
  color: var(--beige-muted);
  padding: 40px 0;
  text-align: center;
  font-size: 15px;
}

/* ─────────────────────────────────────────────────────────────────────────
   TOOL WORKSPACE — Full-screen workspace with studio ambiance
   ───────────────────────────────────────────────────────────────────────── */
.tool-open { overflow: hidden; }

.tool-view {
  position: fixed;
  inset: 0;
  z-index: 200;
  overflow-y: auto;
  background: var(--bg);
  padding: 0 20px 80px;
}

/* Tungsten wash inside workspace */
.tool-view::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 10% 5%, rgba(200, 149, 46, .06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 90% 90%, rgba(200, 149, 46, .05) 0%, transparent 50%);
  z-index: -1;
}

.tool-view-inner {
  max-width: 780px;
  margin: 0 auto;
  padding-top: 24px;
}

.tool-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--beige-muted);
  border-radius: 999px;
  padding: 7px 18px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
  margin-bottom: 20px;
  transition: all .25s ease;
}

.tool-close:hover {
  color: var(--beige);
  border-color: var(--gold-dim);
  box-shadow: 0 0 12px rgba(200, 149, 46, .1);
}

.tool-head h2 {
  margin: 0 0 6px;
  padding-bottom: 10px;
  background: linear-gradient(90deg, transparent, rgba(200, 149, 46, .35), transparent) bottom / 120px 2px no-repeat;
  font-size: 26px;
  font-family: var(--font-headline);
  font-weight: 800;
  color: var(--beige);
  /* Embossed text effect — catches tungsten light */
  text-shadow:
    0 1px 0 rgba(0, 0, 0, .6),
    0 2px 4px rgba(0, 0, 0, .3),
    0 0 20px rgba(200, 149, 46, .08);
}

.tool-head p {
  margin: 0 0 12px;
  color: var(--beige-soft);
  font-size: 15px;
  line-height: 1.8;
}

.tool-body {
  margin-top: 20px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-card);
  position: relative;
}

/* Warm top-edge light on tool body */
.tool-body::before {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 149, 46, .12), transparent);
}

/* ─────────────────────────────────────────────────────────────────────────
   FORM ELEMENTS — Warm, tactile inputs
   ───────────────────────────────────────────────────────────────────────── */
.form-control {
  width: 100%;
  background: var(--bg-soft);
  color: var(--beige);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

textarea.form-control {
  resize: vertical;
  min-height: 84px;
  line-height: 1.55;
}

.form-control::placeholder {
  color: var(--beige-muted);
  opacity: .5;
}

.form-control:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px var(--amber-glow), 0 0 20px var(--amber-glow);
  background: rgba(15, 18, 16, .8);
}

/* ── Action Button — Warm gold, tactile press ── */
.btn-action {
  align-self: flex-start;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--gold) 0%, var(--amber) 50%, var(--gold-dim) 100%);
  color: #0a0b0b;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 11px 24px;
  font-size: 14px;
  font-family: var(--font);
  letter-spacing: .3px;
  transition: all .2s ease;
  box-shadow:
    0 2px 0 rgba(0, 0, 0, .2),
    0 4px 12px rgba(200, 149, 46, .2);
  position: relative;
  overflow: hidden;
}

.btn-action::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.15) 0%, transparent 100%);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.btn-action:hover {
  filter: brightness(1.1);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, .2),
    0 6px 20px rgba(200, 149, 46, .3),
    0 0 30px rgba(200, 149, 46, .1);
  transform: translateY(-1px);
}

.btn-action:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 2px 6px rgba(200, 149, 46, .15);
}

.btn-action:disabled {
  opacity: .5;
  cursor: not-allowed;
  filter: grayscale(.3);
}

.btn-ghost {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--border);
  color: var(--beige-soft);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13.5px;
  font-family: var(--font);
  cursor: pointer;
  transition: all .25s ease;
}

.btn-ghost:hover {
  color: var(--beige);
  border-color: var(--gold-dim);
  box-shadow: 0 0 12px rgba(200, 149, 46, .08);
}

/* ── State feedback ── */
.state-loading { color: var(--gold); font-size: 13.5px; }
.state-error   { color: var(--error); font-size: 13.5px; }
.state-success { color: var(--success); font-size: 13.5px; }

/* ── Result boxes ── */
.result-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 14px;
  word-break: break-word;
  white-space: pre-wrap;
  color: var(--beige);
}

.result-box.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre;
  overflow-x: auto;
}

.label-hint {
  font-size: 13px;
  font-weight: 600;
  color: var(--beige-soft);
  margin: -4px 0 0;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.row > * { flex: 1 1 auto; }

select.form-control {
  flex: 0 0 auto;
  min-width: 130px;
  cursor: pointer;
}

/* ── Stats grid ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 149, 46, .1), transparent);
}

.stat b {
  display: block;
  font-size: 22px;
  font-family: var(--mono);
  color: var(--gold-bright);
}

.stat span {
  font-size: 11.5px;
  color: var(--beige-muted);
}

img.result-img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.preview-canvas {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background:
    repeating-conic-gradient(var(--card-hover) 0% 25%, var(--card) 0% 50%) 50% / 18px 18px;
}

/* Windows cannot render flag emoji — the select uses real flag images. */
.flag-img {
  width: 20px; height: 15px; vertical-align: middle;
  border-radius: 2px; display: inline-block; object-fit: cover;
}
.flag-fallback {
  display: none; width: 22px; height: 15px; vertical-align: middle;
  background: var(--bg); border: 1px solid var(--border); border-radius: 3px;
  font-size: 8px; line-height: 13px; text-align: center;
  color: var(--beige-muted); letter-spacing: .3px; text-transform: uppercase;
}

/* ─────────────────────────────────────────────────────────────────────────
   STICKY NOTE — Torn yellow paper with handwritten blue ink
   ───────────────────────────────────────────────────────────────────────── */
.sticky-note {
  position: relative;
  background: linear-gradient(170deg, #f5e6a3 0%, #ede0a0 30%, #e8d88e 100%);
  color: #1a3366;
  font-family: 'Segoe Script', 'Comic Sans MS', 'Caveat', cursive;
  font-size: 13px;
  line-height: 1.5;
  padding: 20px 16px 16px;
  margin: 16px auto;
  max-width: 280px;
  border-radius: 2px;
  transform: rotate(-1.5deg);
  box-shadow:
    2px 3px 8px rgba(0, 0, 0, .25),
    inset 0 0 30px rgba(0, 0, 0, .03);
  /* Torn bottom edge */
  clip-path: polygon(
    0% 0%, 100% 0%, 100% 92%,
    95% 93%, 90% 91%, 85% 94%, 80% 92%, 75% 95%,
    70% 92%, 65% 93%, 60% 91%, 55% 94%, 50% 92%,
    45% 95%, 40% 92%, 35% 93%, 30% 91%, 25% 94%,
    20% 92%, 15% 95%, 10% 92%, 5% 93%, 0% 91%
  );
}

/* Pin */
.sticky-note::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, #999 30%, #666 60%, #444 100%);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255,255,255,.3);
  z-index: 1;
}

.sticky-note-title {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 4px;
  color: #0d2050;
}

/* ─────────────────────────────────────────────────────────────────────────
   ACTION FLOW — 3-step horizontal capsules
   ───────────────────────────────────────────────────────────────────────── */
.action-flow {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 20px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.action-step {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--beige);
  position: relative;
  transition: all .25s ease;
}

.action-step:hover {
  border-color: var(--gold-dim);
  box-shadow: 0 0 16px rgba(200, 149, 46, .1);
}

.action-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: var(--gold-bright);
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.action-arrow {
  color: var(--gold-dim);
  font-size: 18px;
  padding: 0 6px;
  opacity: .5;
}

/* ─────────────────────────────────────────────────────────────────────────
   3D KEYCAP BADGES — Keyboard shortcuts displayed as physical keys
   ───────────────────────────────────────────────────────────────────────── */
.keycap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  font-family: var(--font-en);
  font-size: 11px;
  font-weight: 700;
  color: var(--beige);
  background: linear-gradient(180deg, #2a2f2a 0%, #1a1f1a 60%, #151a15 100%);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 5px;
  box-shadow:
    0 2px 0 #0a0d0a,
    0 3px 6px rgba(0, 0, 0, .35),
    inset 0 1px 0 rgba(255, 255, 255, .07);
  text-transform: uppercase;
  letter-spacing: .5px;
  user-select: none;
}

/* ─────────────────────────────────────────────────────────────────────────
   FOOTER — Permanent branding with social icons
   ───────────────────────────────────────────────────────────────────────── */
.portal-footer {
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 20px 50px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 2;
}

/* Warm gold line separator */
.portal-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 149, 46, .2), transparent);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-headline);
  font-weight: 800;
  font-size: 18px;
  color: var(--beige);
  letter-spacing: .5px;
}

.footer-brand .footer-sep {
  color: var(--gold-dim);
  font-weight: 300;
}

.footer-brand .footer-tech {
  color: var(--gold);
  font-family: var(--font-en);
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(200, 149, 46, .2);
}

/* ── Social Icons ── */
.social-icons {
  display: flex;
  gap: 14px;
  align-items: center;
}

.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--beige-muted);
  text-decoration: none;
  transition: all .25s ease;
  position: relative;
  overflow: hidden;
}

.social-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(200, 149, 46, .1) 0%, transparent 60%);
  opacity: 0;
  transition: opacity .25s ease;
}

.social-icon:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
  box-shadow: 0 0 16px rgba(200, 149, 46, .12);
  transform: translateY(-2px);
}

.social-icon:hover::before { opacity: 1; }

.social-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  position: relative;
  z-index: 1;
}

.footer-note {
  font-size: 11.5px;
  color: var(--beige-muted);
  opacity: .6;
  text-align: center;
}

.footer-tools-count {
  font-size: 12px;
  color: var(--beige-muted);
  font-family: var(--font-en);
}

.footer-tools-count b {
  color: var(--gold);
  font-family: var(--mono);
}

/* ─────────────────────────────────────────────────────────────────────────
   SECTION INTRO — Welcome area with cinematic feel
   ───────────────────────────────────────────────────────────────────────── */
.portal-intro {
  text-align: center;
  padding: 30px 0 10px;
  position: relative;
}

.portal-intro h1 {
  font-family: var(--font-headline);
  font-weight: 800;
  font-size: 36px;
  color: var(--beige);
  margin: 0 0 8px;
  letter-spacing: 1px;
  /* Embossed acrylic text — interacts with tungsten light */
  text-shadow:
    0 1px 0 rgba(0, 0, 0, .7),
    0 3px 6px rgba(0, 0, 0, .35),
    0 0 40px rgba(200, 149, 46, .1);
  line-height: 1.3;
}

.portal-intro h1 .gold-text {
  color: var(--gold-bright);
  text-shadow:
    0 1px 0 rgba(0, 0, 0, .5),
    0 0 30px rgba(200, 149, 46, .25);
}

.portal-intro .subtitle {
  color: var(--beige-muted);
  font-size: 14px;
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────────────────────────────────
   SCROLL BAR — Warm themed
   ───────────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--beige-muted);
}

/* ─────────────────────────────────────────────────────────────────────────
   SELECTION
   ───────────────────────────────────────────────────────────────────────── */
::selection {
  background: rgba(200, 149, 46, .25);
  color: var(--beige);
}

/* ─────────────────────────────────────────────────────────────────────────
   RESPONSIVE (All Devices: Mobile, Tablet, Desktop)
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

@media (max-width: 768px) {
  .portal-intro h1 { font-size: 28px; }
  .action-flow { flex-direction: column; gap: 8px; }
  .action-arrow { transform: rotate(90deg); padding: 2px 0; }
  .sticky-note { max-width: 90%; }
}

@media (max-width: 560px) {
  .tools-grid { grid-template-columns: 1fr; }
  .header-inner { padding: 12px 14px 8px; gap: 10px; }
  .brand { justify-content: center; width: 100%; }
  .brand-name { font-size: 16px; }
  .brand-ar { font-size: 14px; }
  .search-wrap { flex: 1 1 100%; width: 100%; min-width: 0; }
  .sub-ribbon-inner { flex-direction: column; gap: 4px; text-align: center; font-size: 11px; }
  .portal-intro h1 { font-size: 24px; }
  .portal-intro .subtitle { font-size: 13px; padding: 0 12px; }
  .action-step { width: 100%; max-width: 320px; justify-content: center; padding: 9px 16px; }
  .portal-main { padding: 20px 14px 60px; }
  .tool-view { padding: 0 12px 60px; }
  .tool-body { padding: 16px 14px; }
  .golden-frame { inset: 3px; }
  .footer-brand { font-size: 16px; }
  .social-icon { width: 36px; height: 36px; }
}

@media (max-width: 380px) {
  .brand-name { font-size: 14px; }
  .brand-ar { font-size: 13px; }
  .portal-intro h1 { font-size: 21px; }
  .action-step { font-size: 12px; }
}

/* ─────────────────────────────────────────────────────────────────────────
   BIDI — Mixed Arabic/Latin text: each display element picks its paragraph
   direction from its first strong character (site root stays dir=ltr for
   layout). Covers all tool-generated content + grid cards. New tools are
   covered automatically inside #tool-body; give standalone elements
   dir="auto" instead of inline direction styles.
   ───────────────────────────────────────────────────────────────────────── */
#tool-body :not(input):not(textarea):not(select):not(option):not(script):not(style),
.tool-card-title,
.tool-card-desc {
  unicode-bidi: plaintext;
}
