/* ─── Meeem design tokens ─────────────────────────────────────────── */
:root {
  --topH: 65px;
  --botH: 0px;
  --accent: #22c55e;
  --accent-2: #1fa06a;
  --accent-3: #2ecc87;
  --grad: linear-gradient(120deg, var(--accent-2), var(--accent-3));
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}
[data-theme="dark"] {
  --bg: #0a0c0b;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f7f5;
  --text-dim: #9aa6a0;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --glow: 0 0 24px rgba(46, 204, 135, 0.25);
  --glass: rgba(16, 22, 19, 0.5);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-shine: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --border: rgba(10, 40, 25, 0.12);
  --text: #10201a;
  --text-dim: #5d6e66;
  --shadow: 0 10px 30px rgba(15, 40, 28, 0.10), 0 2px 8px rgba(15, 40, 28, 0.06);
  --glow: 0 0 0 rgba(0,0,0,0);
  --glass: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-shine: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color-scheme: light;
}

/* ─── Liquid glass ────────────────────────────────────────────────── */
.lg {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shine), 0 10px 32px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html, body { overflow-x: clip; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font: 16px/1.6 "Inter", "Tajawal", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
  transition: background 0.4s, color 0.4s;
  padding-bottom: var(--botH);
}
html[lang="ar"] body { font-family: "Tajawal", "Inter", system-ui, sans-serif; }
h1, h2, h3 { font-family: "Space Grotesk", "Tajawal", sans-serif; letter-spacing: -0.02em; margin: 0; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { font-family: "Tajawal", sans-serif; letter-spacing: 0; }

#bg { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; }
[data-theme="light"] #bg { opacity: 0.5; }

/* ─── Header ──────────────────────────────────────────────────────── */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%);
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--glass-shine);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { border-radius: 9px; }
.brand-name { font-family: "Space Grotesk", "Tajawal", sans-serif; font-weight: 700; font-size: 19px; }
html[lang="ar"] .brand-name { font-family: "Tajawal", sans-serif; }
.top-actions { display: flex; gap: 8px; }

/* ─── Buttons ─────────────────────────────────────────────────────── */
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  min-height: 38px; padding: 7px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font: inherit; font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background 0.2s, transform 0.15s var(--ease-out), border-color 0.2s;
}
.ghost-btn:hover { background: var(--surface-2); border-color: rgba(46, 204, 135, 0.4); }
.ghost-btn:active { transform: scale(0.96); }
.ghost-btn.icon-only { padding: 7px 10px; }
.ghost-btn.danger:hover { border-color: rgba(239, 68, 68, 0.6); color: #ef4444; }
.cta {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  min-height: 44px; padding: 10px 22px;
  background: var(--grad); color: #06120c;
  border: none; border-radius: 12px;
  font: inherit; font-size: 15px; font-weight: 700;
  box-shadow: var(--glow);
  transition: transform 0.18s var(--ease-pop), box-shadow 0.25s, filter 0.2s;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(46, 204, 135, 0.4); }
.cta:active { transform: scale(0.96); }
.cta:disabled { filter: saturate(0.3) brightness(0.7); cursor: not-allowed; transform: none; }
.cta.small { min-height: 40px; padding: 8px 14px; border-radius: 10px; }
.cta-arrow { transition: transform 0.2s var(--ease-out); }
.cta:hover .cta-arrow { transform: translateX(3px); }
html[dir="rtl"] .cta-arrow, html[dir="rtl"] .back-arrow { transform: scaleX(-1); }
html[dir="rtl"] .cta:hover .cta-arrow { transform: scaleX(-1) translateX(3px); }
:is(.ghost-btn, .cta, textarea, input):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ─── Hero ────────────────────────────────────────────────────────── */
.view { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.hero { padding: clamp(48px, 9vh, 110px) 0 28px; text-align: center; }
.hero-title {
  font-size: clamp(38px, 6.5vw, 72px); font-weight: 700; line-height: 1.08;
  animation: rise 0.8s var(--ease-out) both;
}
.grad {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(46, 204, 135, 0.25));
}
.hero-sub {
  color: var(--text-dim); font-size: clamp(16px, 2vw, 19px);
  max-width: 560px; margin: 18px auto 0;
  animation: rise 0.8s var(--ease-out) 0.08s both;
}

/* ─── Composer ────────────────────────────────────────────────────── */
.composer {
  max-width: 680px; margin: 36px auto 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px; text-align: start;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  transition: border-color 0.25s, box-shadow 0.25s;
  animation: rise 0.8s var(--ease-out) 0.16s both;
}
.composer:focus-within { border-color: rgba(46, 204, 135, 0.55); box-shadow: var(--shadow), 0 0 0 4px rgba(46, 204, 135, 0.12); }
.composer textarea {
  width: 100%; resize: vertical; min-height: 76px; max-height: 280px;
  background: transparent; border: none; outline: none; color: var(--text);
  font: inherit; font-size: 17px;
}
.composer textarea::placeholder, .chat-composer input::placeholder { color: var(--text-dim); }
.composer-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.hint { color: var(--text-dim); font-size: 12.5px; }

.hero-stats {
  display: flex; gap: clamp(18px, 4vw, 44px); justify-content: center; margin-top: 22px;
  animation: rise 0.8s var(--ease-out) 0.12s both;
}
.hstat { display: flex; flex-direction: column; align-items: center; gap: 0; }
.hstat b {
  font-family: "Space Grotesk", "Tajawal", sans-serif; font-size: clamp(22px, 3.4vw, 30px);
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hstat span { color: var(--text-dim); font-size: 12.5px; }
.explore-cta { margin-top: 22px; animation: rise 0.8s var(--ease-out) 0.3s both; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; animation: rise 0.8s var(--ease-out) 0.24s both; }
.chip {
  cursor: pointer; padding: 8px 14px; min-height: 38px;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px;
  font: inherit; font-size: 13.5px;
  transition: all 0.2s var(--ease-out);
}
.chip:hover { color: var(--text); border-color: rgba(46, 204, 135, 0.5); transform: translateY(-2px); }

/* ─── Projects grid ───────────────────────────────────────────────── */
.projects { padding: 48px 0 80px; }
.section-title { font-size: 20px; margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  padding: 18px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  transition: transform 0.25s var(--ease-out), border-color 0.25s, box-shadow 0.25s;
  animation: rise 0.5s var(--ease-out) both;
}
.card:hover { transform: translateY(-4px); border-color: rgba(46, 204, 135, 0.45); box-shadow: var(--shadow); }
.card-top { display: flex; align-items: center; gap: 10px; }
.card-emoji { font-size: 26px; }
.card-name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-prompt { color: var(--text-dim); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { color: var(--text-dim); text-align: center; padding: 40px 0; }

/* ─── App icons ───────────────────────────────────────────────────── */
.card-icon { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.feed-icon { width: 26px; height: 26px; border-radius: 7px; object-fit: cover; flex-shrink: 0; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 16px; }
.icon-tile {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  text-decoration: none; color: var(--text);
  transition: transform 0.2s var(--ease-pop);
}
.icon-tile:hover { transform: translateY(-3px) scale(1.04); }
.icon-tile:active { transform: scale(0.94); }
.app-icon, .icon-fallback {
  width: 64px; height: 64px; border-radius: 15px; object-fit: cover;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.icon-fallback {
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.icon-name {
  font-size: 11.5px; max-width: 80px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─── Status chip ─────────────────────────────────────────────────── */
.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
  width: fit-content;
}
.status-chip[data-s="live"] { color: #34d399; border-color: rgba(52, 211, 153, 0.4); }
.status-chip[data-s="error"] { color: #f87171; border-color: rgba(248, 113, 113, 0.4); }
.status-chip[data-s="working"] { color: var(--accent-3); border-color: rgba(46, 204, 135, 0.35); }
.status-chip[data-s="working"]::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-3); animation: pulse 1.1s ease-in-out infinite;
}
.status-chip[data-s="live"]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #34d399; }

/* ─── Project workspace ───────────────────────────────────────────── */
.project-head { display: flex; align-items: center; gap: 12px; padding: 18px 0 14px; }
.p-emoji { font-size: 30px; }
.p-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.p-meta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.p-stats { color: var(--text-dim); font-size: 12.5px; display: inline-flex; gap: 10px; }
.p-stats b { color: var(--text); font-weight: 700; }
.p-meta h2 { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-actions { margin-inline-start: auto; display: flex; gap: 8px; }

.workspace {
  display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 16px;
  height: calc(100dvh - 200px); min-height: 420px; padding-bottom: 24px;
}
.chat-panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
/* version timeline: a line of dots, click an older dot to roll back */
.version-bar {
  display: flex; align-items: center; padding: 14px 18px 4px;
  overflow-x: auto; scrollbar-width: none;
}
.version-bar::-webkit-scrollbar { display: none; }
.v-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; cursor: pointer;
  background: var(--surface-2); border: 2px solid var(--border); padding: 0;
  transition: transform 0.18s var(--ease-pop), border-color 0.2s, background 0.2s;
}
.v-dot:hover { transform: scale(1.4); border-color: var(--accent-3); }
.v-dot.current {
  background: var(--grad); border-color: var(--accent-3); cursor: default;
  box-shadow: 0 0 10px rgba(46, 204, 135, 0.5);
}
.v-line { flex: 1; min-width: 14px; height: 2px; background: var(--border); }

.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: var(--r-md); font-size: 14.2px; white-space: pre-wrap; word-break: break-word; animation: rise 0.35s var(--ease-out) both; }
.msg.user { align-self: flex-end; background: var(--grad); color: #06120c; border-end-end-radius: 4px; font-weight: 500; }
.msg.agent { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-end-start-radius: 4px; }
.msg.log { align-self: flex-start; color: var(--text-dim); font-size: 13px; padding: 2px 6px; }
.chat-composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-composer input {
  flex: 1; min-height: 42px; padding: 8px 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; outline: none;
  font: inherit; font-size: 14.5px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-composer input:focus { border-color: rgba(46, 204, 135, 0.55); box-shadow: 0 0 0 3px rgba(46, 204, 135, 0.12); }

.preview-panel { min-height: 0; }
.preview-shell {
  position: relative; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; box-shadow: var(--shadow);
}
.preview-shell iframe { width: 100%; height: 100%; border: none; background: #fff; }
[data-theme="dark"] .preview-shell iframe { background: #0d0f0e; }
.preview-idle {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  background: var(--bg); color: var(--text-dim); text-align: center; padding: 20px;
}
.orb {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--grad);
  filter: blur(2px);
  animation: orb 2.4s var(--ease-out) infinite;
}

/* ─── Store badges (hero) ─────────────────────────────────────────── */
.store-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-stores { margin-top: 26px; animation: rise 0.8s var(--ease-out) 0.25s both; }
.store-badge {
  display: inline-flex; align-items: center; gap: 11px;
  min-height: 54px; padding: 9px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  color: var(--text); text-decoration: none; text-align: start;
  transition: transform 0.18s var(--ease-pop), border-color 0.2s;
}
a.store-badge[href]:hover { transform: translateY(-2px); border-color: rgba(46, 204, 135, 0.45); }
.store-badge span { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.3; }
.store-badge small { font-size: 10.5px; color: var(--text-dim); }
.store-badge b { font-size: 15.5px; }
.store-badge.soon { opacity: 0.6; cursor: default; }

/* ─── Footer ──────────────────────────────────────────────────────── */
.foot {
  display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap;
  padding: 22px; color: var(--text-dim); font-size: 13px;
  border-top: 1px solid var(--border);
}
.foot-link { color: var(--text-dim); }
.foot-link:hover { color: var(--text); }

/* ─── Story (لماذا ميم؟) ──────────────────────────────────────────── */
.story {
  position: relative; max-width: 760px; margin: 0 auto; padding: 56px 0 90px;
  display: flex; flex-direction: column; gap: 28px;
}
.story-letter {
  position: absolute; inset-inline-end: -30px; top: 0;
  font-family: "Tajawal", sans-serif; font-weight: 800;
  font-size: clamp(160px, 30vw, 300px); line-height: 1;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  opacity: 0.07; pointer-events: none; user-select: none;
}
.story-block h2 { font-size: 24px; margin-bottom: 12px; }
.story-block p { color: var(--text-dim); font-size: 16px; margin: 0 0 10px; }
.story-block b { color: var(--text); font-weight: 700; }
html[lang="ar"] .story-block[lang="en"] { opacity: 0.75; }
html[lang="en"] .story-block[lang="ar"] { opacity: 0.75; }

/* ─── Top nav ─────────────────────────────────────────────────────── */
.top-nav { display: flex; gap: 4px; position: absolute; left: 50%; transform: translateX(-50%); }
.nav-link {
  padding: 7px 16px; min-height: 38px; display: inline-flex; align-items: center;
  color: var(--text-dim); text-decoration: none; font-size: 14.5px; font-weight: 600;
  border-radius: 999px; transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); background: var(--surface-2); }

/* ─── Feed ────────────────────────────────────────────────────────── */
.feed-view { flex: 1; width: 100%; max-width: none; padding: 0; position: relative; }
.feed-tabs {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 40;
  display: flex; gap: 4px; padding: 4px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border: 1px solid var(--glass-border); border-radius: 999px;
  box-shadow: var(--glass-shine), 0 8px 24px rgba(0,0,0,.25);
}
.feed-tab {
  cursor: pointer; border: none; background: transparent; color: var(--text-dim);
  font: inherit; font-size: 13.5px; font-weight: 600; padding: 7px 16px; min-height: 36px;
  border-radius: 999px; transition: all 0.2s var(--ease-out);
}
.feed-tab.active { background: var(--grad); color: #06120c; }
.feed-scroller {
  height: calc(100dvh - var(--topH) - var(--botH));
  overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain;
}
.feed-card {
  position: relative; height: calc(100dvh - var(--topH) - var(--botH)); scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; align-items: stretch; justify-content: center; padding: 10px 12px 14px;
}
.feed-frame {
  position: relative; width: min(520px, 100%); height: 100%;
  border-radius: 22px; overflow: hidden;
  border: 1px solid var(--border); background: #0d0f0e;
  box-shadow: var(--shadow);
}
/* feed mode: every pixel goes to the apps */
body.feed-open .foot { display: none; }

/* ─── Bottom nav (mobile app feel) ────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  background: var(--glass);
  backdrop-filter: blur(26px) saturate(175%); -webkit-backdrop-filter: blur(26px) saturate(175%);
  border-top: 1px solid var(--glass-border);
  box-shadow: var(--glass-shine);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 48px; justify-content: center;
  color: var(--text-dim); text-decoration: none;
  font-size: 11.5px; font-weight: 600; border-radius: 12px;
  transition: color 0.2s, transform 0.15s var(--ease-out);
}
.bn-item:active { transform: scale(0.94); }
.bn-item.active { color: var(--accent-3); }
.bn-item svg { flex-shrink: 0; }
.feed-frame iframe { width: 100%; height: 100%; border: none; background: #fff; }
/* Slim one-line info pill. No backdrop-filter here: blur can't sample iframe
   content (renders as a flat gray square on iOS Safari) — use translucency. */
.feed-overlay {
  position: absolute; bottom: 12px; inset-inline-start: 12px; inset-inline-end: 72px;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(10, 15, 12, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 20px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.feed-overlay > * { pointer-events: auto; }
.feed-info { color: #f2f6f4; min-width: 0; }
.feed-info .fname { font-weight: 700; font-size: 14.5px; display: flex; gap: 7px; align-items: center; min-width: 0; }
.feed-info .fname-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmeta { font-size: 11.5px; opacity: 0.75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* TikTok-style vertical action rail */
.feed-actions {
  position: absolute; bottom: 12px; inset-inline-end: 12px;
  display: flex; flex-direction: column; gap: 9px; align-items: center;
}
.feed-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0; cursor: pointer;
  width: 48px; height: 48px; justify-content: center;
  background: rgba(10, 15, 12, 0.74); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s var(--ease-pop), background 0.2s;
  text-decoration: none;
}
.feed-btn:hover { transform: scale(1.1); }
.feed-btn:active { transform: scale(0.92); }
.feed-btn.liked { color: #ff4d6d; background: rgba(120, 20, 40, 0.6); }
.feed-count { font-size: 10px; color: #f2f6f4; font-weight: 700; line-height: 1.1; }

/* ─── Auth modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(4, 8, 6, 0.6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.25s var(--ease-out) both;
}
.modal {
  position: relative; width: min(400px, 100%);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 32px 28px 24px; box-shadow: var(--shadow);
  animation: popIn 0.35s var(--ease-pop) both;
}
.modal-logo { border-radius: 12px; }
.modal h3 { font-size: 20px; }
.modal-close {
  position: absolute; top: 12px; inset-inline-end: 12px; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); color: var(--text-dim); border: 1px solid var(--border);
  transition: color 0.2s, transform 0.15s;
}
.modal-close:hover { color: var(--text); transform: scale(1.08); }
.oauth-col { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer;
  min-height: 44px; width: 100%;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  transition: border-color 0.2s, transform 0.15s var(--ease-out);
}
.oauth-btn:hover { border-color: rgba(46, 204, 135, 0.5); transform: translateY(-1px); }
.divider {
  display: flex; align-items: center; gap: 12px; width: 100%;
  color: var(--text-dim); font-size: 12.5px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
#authForm { display: flex; flex-direction: column; gap: 10px; width: 100%; }
#authForm input {
  width: 100%; min-height: 44px; padding: 10px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; outline: none;
  font: inherit; font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#authForm input:focus { border-color: rgba(46, 204, 135, 0.55); box-shadow: 0 0 0 3px rgba(46, 204, 135, 0.12); }
.cta.wide { width: 100%; justify-content: center; }
.auth-error { color: #f87171; font-size: 13.5px; margin: 0; }
.auth-tabs {
  display: flex; gap: 4px; width: 100%; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.auth-tab {
  flex: 1; cursor: pointer; min-height: 38px;
  background: transparent; color: var(--text-dim); border: none; border-radius: 9px;
  font: inherit; font-size: 14px; font-weight: 600;
  transition: all 0.2s var(--ease-out);
}
.auth-tab.active { background: var(--grad); color: #06120c; font-weight: 700; }
.oauth-btn.soon { opacity: 0.55; cursor: not-allowed; }
.oauth-btn.soon:hover { transform: none; border-color: var(--border); }
.soon-chip {
  margin-inline-start: auto; font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
}
.profile-chip { display: inline-flex; align-items: center; gap: 8px; }
.profile-chip .avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--grad); color: #06120c;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}

/* ─── Profile ─────────────────────────────────────────────────────── */
.profile-head { display: flex; align-items: center; gap: 16px; padding: 36px 0 10px; }
.profile-avatar {
  width: 76px; height: 76px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad); color: #06120c;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800; overflow: hidden;
  box-shadow: var(--glow);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.prof-handle { color: var(--text-dim); font-size: 14px; direction: ltr; unicode-bidi: embed; }
.profile-stats { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 0 6px; }
.stat {
  flex: 1; min-width: 110px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 10px;
  animation: rise 0.5s var(--ease-out) both;
}
.stat b { display: block; font-size: 22px; font-family: "Space Grotesk", "Tajawal", sans-serif; }
.stat span { color: var(--text-dim); font-size: 12.5px; }
.feed-flag {
  background: none; border: none; cursor: pointer; padding: 2px 6px;
  color: rgba(242, 246, 244, 0.45); vertical-align: middle;
}
.feed-flag:hover { color: #f87171; }
.c-flag { font-size: 13px; }
.feed-by a { color: inherit; text-decoration: none; }
.feed-by a:hover { text-decoration: underline; }
.feed-remix-credit { font-size: 11px; opacity: 0.6; }

/* ─── Notifications ───────────────────────────────────────────────── */
#bellBtn { position: relative; }
.bell-badge {
  position: absolute; top: 2px; inset-inline-end: 2px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: #ff4d6d; color: #fff; font-size: 10.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.bell-panel {
  position: absolute; top: 56px; inset-inline-end: clamp(16px, 4vw, 40px); z-index: 90;
  width: min(340px, calc(100vw - 32px)); max-height: 380px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow); padding: 8px;
  animation: popIn 0.25s var(--ease-pop) both;
}
.notif {
  display: flex; gap: 10px; align-items: center; cursor: pointer;
  padding: 10px 12px; border-radius: 10px; font-size: 13.5px; color: var(--text);
}
.notif:hover { background: var(--surface); }
.notif .when { color: var(--text-dim); font-size: 11.5px; }
.notif.unread { background: rgba(46, 204, 135, 0.08); }
.notif-empty { color: var(--text-dim); text-align: center; padding: 20px; font-size: 13.5px; }
.prefs-toggle {
  width: 100%; cursor: pointer; text-align: start;
  background: none; border: none; border-top: 1px solid var(--border);
  color: var(--text-dim); font: inherit; font-size: 12.5px; padding: 10px 12px 6px;
}
.prefs-toggle:hover { color: var(--text); }
.pref-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 12px; font-size: 13px; color: var(--text); cursor: pointer;
}
.pref-row input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ─── Comments ────────────────────────────────────────────────────── */
#commentsModal { align-items: flex-end; padding: 0; }
.comments-modal {
  width: 100%; max-width: 560px; margin: 0 auto;
  max-height: 78dvh; align-items: stretch;
  border-radius: 22px 22px 0 0; border-bottom: none;
  background: var(--glass);
  backdrop-filter: blur(26px) saturate(170%); -webkit-backdrop-filter: blur(26px) saturate(170%);
  border-color: var(--glass-border);
  box-shadow: var(--glass-shine), 0 -10px 40px rgba(0, 0, 0, 0.35);
}
.comments-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 120px; max-height: 50dvh; }
.comment {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 13px; animation: rise 0.3s var(--ease-out) both;
}
.comment-head { display: flex; align-items: center; gap: 8px; }
.comment-head .c-avatar {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad); color: #06120c;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}
.comment-head a { color: var(--text); font-weight: 600; font-size: 13px; text-decoration: none; }
.comment-head a:hover { text-decoration: underline; }
.comment-head .when { color: var(--text-dim); font-size: 11px; margin-inline-start: auto; }
.comment-head .c-del {
  cursor: pointer; background: none; border: none; color: var(--text-dim);
  font-size: 12px; padding: 2px 6px;
}
.comment-head .c-del:hover { color: #f87171; }
.comment-body { font-size: 14px; word-break: break-word; }
.comment-form { display: flex; gap: 8px; }
.comment-form input {
  flex: 1; min-height: 42px; padding: 8px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; outline: none;
  font: inherit; font-size: 14.5px;
}
.comment-form input:focus { border-color: rgba(46, 204, 135, 0.55); }
.comments-empty { color: var(--text-dim); text-align: center; padding: 30px 10px; font-size: 13.5px; }

/* ─── Code viewer ─────────────────────────────────────────────────── */
.code-modal { width: min(760px, 100%); max-height: 86dvh; align-items: stretch; }
.code-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.code-tab {
  cursor: pointer; padding: 6px 12px; min-height: 34px;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px;
  transition: all 0.15s var(--ease-out);
}
.code-tab.active { color: var(--text); border-color: rgba(46, 204, 135, 0.55); background: var(--surface-2); }
.code-wrap { position: relative; min-height: 0; flex: 1; display: flex; }
.code-wrap pre {
  flex: 1; margin: 0; overflow: auto; max-height: 56dvh;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; text-align: left;
}
.code-wrap code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; line-height: 1.55;
  color: var(--text); white-space: pre;
}
.code-copy { position: absolute; top: 8px; right: 8px; z-index: 2; min-height: 32px; font-size: 12.5px; }

/* ─── Build tips ──────────────────────────────────────────────────── */
.build-tip {
  max-width: 420px; min-height: 48px; margin: 0; padding: 0 12px;
  color: var(--text-dim); font-size: 14px; line-height: 1.6;
  transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
}
.build-tip.swap { opacity: 0; transform: translateY(8px); }
.feed-by { font-size: 11.5px; opacity: 0.65; }

/* ─── Animations ──────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.92) translateY(14px); } to { opacity: 1; transform: none; } }
.view:not([hidden]), .feed-view:not([hidden]) { animation: rise 0.45s var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.75); } }
@keyframes orb {
  0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(46, 204, 135, 0.35); }
  50% { transform: scale(1.15); box-shadow: 0 0 60px rgba(46, 204, 135, 0.6); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  #bg { display: none; }
}

/* ─── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .chat-panel { height: 44dvh; min-height: 320px; order: 2; }
  .preview-panel { height: 60dvh; order: 1; }
  .hero { padding-top: 40px; }
}
@media (max-width: 640px) {
  :root { --topH: 59px; --botH: calc(62px + env(safe-area-inset-bottom)); }
  .top { padding: 8px 12px; gap: 6px; }
  .top-nav { display: none; }            /* navigation moves to the bottom bar */
  .bottom-nav { display: flex; }
  .brand-name { font-size: 17px; }
  .ghost-btn { padding: 7px 9px; font-size: 13px; min-height: 36px; }
  .profile-chip span:last-child { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hero { padding-top: 26px; }
  .hero-title { font-size: clamp(32px, 9.5vw, 44px); }
  .hero-sub { font-size: 15px; margin-top: 12px; }
  .composer { margin-top: 24px; padding: 12px; }
  .composer textarea { font-size: 16px; min-height: 64px; }
  .chips { margin-top: 16px; }
  .projects { padding: 32px 0 40px; }
  .bell-panel { inset-inline-end: 8px; }
  .feed-tabs { top: calc(var(--topH) + 6px); }
  .feed-card { padding: 6px 6px 10px; }
  .feed-frame { border-radius: 16px; width: 100%; }
  .profile-head { flex-wrap: wrap; padding-top: 22px; }
  .profile-avatar { width: 60px; height: 60px; font-size: 26px; }
  .stat { min-width: calc(50% - 6px); flex: none; padding: 10px 8px; }
  .stat b { font-size: 18px; }
  .p-actions { gap: 6px; }
  .story { padding: 36px 0 48px; }
  .story-letter { font-size: 140px; inset-inline-end: 0; }
  /* Editor pinned like a native screen: preview on top, chat docked below.
     The body is frozen because any page scroll on iOS brings rubber-banding
     and address-bar resizing — that's what made the layout "move". */
  body.project-open { position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none; }
  body.project-open .foot { display: none; }
  .project-head { padding: 8px 0 6px; }
  .p-emoji { font-size: 22px; }
  .p-meta h2 { font-size: 15px; }
  /* stats stay, but as one compact non-wrapping line beside the status chip */
  .p-stats { font-size: 11px; gap: 8px; white-space: nowrap; }
  .p-meta-row { flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: none; }
  .p-meta-row::-webkit-scrollbar { display: none; }
  .p-actions .ghost-btn { min-height: 34px; padding: 6px 8px; font-size: 12.5px; }
  .workspace {
    grid-template-rows: minmax(0, 1fr) minmax(170px, 34%);
    height: calc(100dvh - var(--topH) - var(--botH) - 66px);
    min-height: 0; gap: 10px; padding-bottom: 6px;
  }
  .chat-panel { height: 100%; min-height: 0; }
  .preview-panel { height: 100%; min-height: 0; }
  .foot { padding: 14px; }
}
