:root {
  --edge-cyan: #00f6ff;
  --edge-dark: rgba(6, 14, 25, 0.92);
  --edge-glass: rgba(9, 18, 32, 0.78);
  --edge-border: rgba(0, 246, 255, 0.2);
  --edge-side-pad: clamp(14px, 6vw, 34px);
  --edge-header-h: clamp(64px, 10svh, 88px);
}

.mq-stage {
  position: relative;
  padding: calc(var(--edge-header-h, 72px) + 8px) 0 clamp(32px, 6vh, 64px);
  min-height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  background:
    linear-gradient(160deg, rgba(4, 15, 28, 0.62), rgba(3, 22, 38, 0.68)),
    url("../assets/background.png") center/cover no-repeat;
  background-attachment: scroll;
  overflow: visible;
  margin: 0;
  border-radius: 0;
}

html,
body {
  height: 100%;
}

body.mq-freeze {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

body.mq-freeze .mq-stage {
  height: 100dvh;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .mq-stage {
    background-attachment: fixed;
  }
}

@media (max-width: 768px) {
  .mq-stage {
    background:
      linear-gradient(160deg, rgba(4, 15, 28, 0.62), rgba(3, 22, 38, 0.68)),
      url("../assets/mobile_app_background.png") center/cover no-repeat;
    background-attachment: scroll;
  }
}

.mq-stage::before,
.mq-stage::after {
  content: "";
  position: absolute;
  inset: -12%;
  pointer-events: none;
  z-index: 0;
}

.mq-stage::before,
.mq-stage::after,
.mq-stage .mq-bg-overlay {
  display: none;
}


.edge-hero-topbar {
  width: 100%;
  margin: 0;
  padding: clamp(18px, 4vh, 28px) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(14px, 3vw, 28px);
  box-sizing: border-box;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10060;
  background: rgba(6, 14, 25, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.edge-hero {
  width: 100%;
  max-width: 1180px;
  margin: clamp(28px, 8vh, 88px) auto clamp(32px, 8vh, 96px);
  padding: 0 var(--edge-side-pad);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(18px, 4vh, 36px);
  color: #e6f9ff;
  box-sizing: border-box;
}


.edge-home-main {
  width: min(600px, calc(100% - 2 * var(--edge-side-pad)));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 3vh, 26px);
  text-align: center;
  box-sizing: border-box;
}

@media (min-width: 900px) {
  .edge-hero {
    align-items: flex-start;
    text-align: left;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  .edge-home-main {
    align-items: flex-start;
    text-align: left;
    width: 100%;
  }
}

.edge-home-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.edge-home-title {
  margin: 0;
  font-size: clamp(1.7rem, 2.3vw, 2.4rem);
  font-family: 'Orbitron', 'Segoe UI', sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.edge-home-main .edge-home-title {
  display: inline-block;
  padding: 0;
  color: transparent;
  background-image: linear-gradient(135deg, rgba(0, 246, 255, 0.95), rgba(180, 250, 255, 0.75));
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 0 16px rgba(0, 246, 255, 0.45), 0 0 32px rgba(0, 246, 255, 0.2);
  animation: titleSplash 7.6s ease-in-out infinite;
  position: relative;
}

.edge-home-main .edge-home-title::after {
  content: "";
  position: absolute;
  inset: -8px -14px;
  border-radius: 10px;
  background:
    linear-gradient(90deg, transparent 0%, rgba(0, 246, 255, 0.9) 60%, transparent 100%) top/200% 2px no-repeat,
    linear-gradient(270deg, transparent 0%, rgba(0, 246, 255, 0.9) 60%, transparent 100%) bottom/200% 2px no-repeat;
  opacity: 0.9;
  animation: titleSnake 6.5s linear infinite;
  pointer-events: none;
}

@keyframes titleSplash {
  0%, 22% {
    filter: saturate(1);
    text-shadow: 0 0 10px rgba(0, 246, 255, 0.25), 0 0 22px rgba(0, 246, 255, 0.15);
  }
  28% {
    filter: saturate(1.3);
    text-shadow: 0 0 18px rgba(0, 246, 255, 0.55), 0 0 36px rgba(0, 246, 255, 0.35);
  }
  34% {
    filter: saturate(1.6);
    text-shadow: 0 0 26px rgba(0, 246, 255, 0.85), 0 0 48px rgba(0, 246, 255, 0.45);
  }
  40% {
    filter: saturate(1.2);
    text-shadow: 0 0 16px rgba(0, 246, 255, 0.5), 0 0 30px rgba(0, 246, 255, 0.3);
  }
  68% {
    filter: saturate(1);
    text-shadow: 0 0 10px rgba(0, 246, 255, 0.25), 0 0 22px rgba(0, 246, 255, 0.15);
  }
  74% {
    filter: saturate(1.35);
    text-shadow: 0 0 20px rgba(0, 246, 255, 0.65), 0 0 40px rgba(0, 246, 255, 0.35);
  }
  78% {
    filter: saturate(1.6);
    text-shadow: 0 0 28px rgba(0, 246, 255, 0.9), 0 0 56px rgba(0, 246, 255, 0.5);
  }
  84%, 100% {
    filter: saturate(1);
    text-shadow: 0 0 12px rgba(0, 246, 255, 0.3), 0 0 24px rgba(0, 246, 255, 0.18);
  }
}

@keyframes titleSnake {
  0% {
    background-position: 0% 0%, 200% 100%;
  }
  25% {
    background-position: 100% 0%, 100% 100%;
  }
  50% {
    background-position: 200% 0%, 0% 100%;
  }
  75% {
    background-position: 100% 0%, 100% 100%;
  }
  100% {
    background-position: 0% 0%, 200% 100%;
  }
}

.edge-home-subtitle {
  margin: 0;
  max-width: 600px;
  color: rgba(214, 238, 255, 0.78);
  font-size: 1rem;
  line-height: 1.6;
}

.edge-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(1.7rem, 2.3vw, 2.4rem);
  font-family: 'Orbitron', 'Segoe UI', sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.edge-brand.is-stacked {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.edge-home-main .edge-brand span {
  font-family: 'Orbitron', 'Segoe UI', sans-serif !important;
  font-size: clamp(1.7rem, 2.3vw, 2.4rem) !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  line-height: 1.1 !important;
}

.edge-hero-topbar .edge-home-title {
  font-size: clamp(1rem, 1.4vw, 1.4rem);
  line-height: 1.1;
}

.edge-brand img {
  width: clamp(64px, 10vw, 120px);
  height: clamp(64px, 10vw, 120px);
  border-radius: clamp(10px, 1.2vw, 16px);
  box-shadow: 0 0 18px rgba(0, 246, 255, 0.35);
}

.edge-hero-topbar .edge-brand img {
  width: 50px;
  height: 50px;
  border-radius: 12px;
}

@media (min-width: 900px) {
  .edge-home-main .edge-home-title {
    font-size: clamp(1.1rem, 1.2vw, 1.5rem) !important;
  }
  .edge-home-main .edge-brand img {
    width: clamp(120px, 12vw, 180px);
    height: clamp(120px, 12vw, 180px);
  }
}

.edge-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.edge-hero-topbar__left,
.edge-hero-topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.edge-hero-topbar__left {
  padding-left: var(--edge-side-pad);
}

.edge-hero-topbar__right {
  margin-left: auto;
  padding-right: var(--edge-side-pad);
}

.edge-hero-topbar__right .user-icon-wrapper {
  width: 50px;
  height: 50px;
  margin-left: 12px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(0, 40, 60, 0.55);
  box-shadow: 0 0 18px rgba(0, 246, 255, 0.32);
}

.edge-hero-topbar__right #user-icon {
  width: 100% !important;
  height: 100% !important;
  border-radius: inherit !important;
  box-shadow: none;
  object-fit: cover;
}

.edge-hero-topbar__right .notif-dot {
  top: 4px;
  right: 4px;
}

.edge-actions-anchor {
  display: flex;
  align-items: center;
}

.edge-link-btn,
.edge-icon-btn {
  border: 1px solid rgba(0, 246, 255, 0.4);
  background: transparent;
  color: #dff9ff;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 24px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.edge-link-btn:hover,
.edge-icon-btn:hover {
  background: rgba(0, 246, 255, 0.12);
  border-color: rgba(0, 246, 255, 0.6);
  transform: translateY(-1px);
}

.edge-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  width: 42px;
  height: 42px;
  font-size: 1.4rem;
  line-height: 1;
}



.edge-sheet {
  position: fixed;
  left: 50%;
  bottom: -100%;
  transform: translate(-50%, 0);
  width: min(1650px, 94vw);
  max-height: 82vh;
  z-index: 20010;
  transition: bottom 0.45s ease;
  pointer-events: none;
}

.edge-sheet--open {
  bottom: 4vh;
  pointer-events: auto;
}

.edge-sheet-inner {
  background: var(--edge-dark);
  border: 1px solid var(--edge-border);
  border-radius: 26px;
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  padding: 20px clamp(18px, 4vw, 32px) clamp(22px, 4vw, 32px);
  display: flex;
  flex-direction: column;
  height: 100%;
  color: #f1fbff;
}

.edge-sheet-content .mq-shell__container {
  gap: clamp(22px, 4vw, 36px);
}

.edge-sheet-content .mq-page-hero {
  margin: 0;
}

.edge-sheet-handle {
  align-self: center;
  width: 56px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  margin-bottom: 12px;
}

.edge-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.edge-sheet-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.edge-sheet-actions .edge-icon-btn {
  width: 40px;
  height: 40px;
  padding: 8px;
  font-size: 1.2rem;
}

.edge-sheet-header h2 {
  font-size: 1.4rem;
  margin: 0;
}

.edge-sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 18px 0 12px;
}

.edge-sheet-tabs button {
  border: 1px solid rgba(0, 246, 255, 0.3);
  background: rgba(4, 19, 28, 0.6);
  color: inherit;
  padding: 8px 16px;
  border-radius: 18px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.edge-sheet-tabs button.active {
  background: rgba(0, 246, 255, 0.2);
  border-color: rgba(0, 246, 255, 0.55);
}

.edge-sheet-tabs button:hover {
  transform: translateY(-1px);
}

.edge-sheet-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: block;
}

.edge-sheet-panel {
  display: none;
  font-size: 0.98rem;
  line-height: 1.6;
}

.edge-sheet-panel.active {
  display: block;
}

.edge-sheet-panel h3 {
  margin-top: 0;
  font-size: 1.3rem;
}

.edge-sheet-panel h4 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.edge-sheet-panel iframe {
  width: 100%;
  height: clamp(320px, 60vh, 680px);
  border: 1px solid rgba(0, 246, 255, 0.2);
  border-radius: 20px;
  background: rgba(2, 14, 26, 0.92);
  box-shadow: inset 0 0 24px rgba(0, 246, 255, 0.08);
}

@media (max-width: 680px) {
  .edge-sheet-panel iframe {
    height: clamp(260px, 65vh, 560px);
    border-radius: 16px;
  }
}

@media (max-width: 900px) {
  :root {
    --edge-side-pad: clamp(12px, 6vw, 28px);
  }

  .edge-hero-topbar {
    padding: clamp(16px, 4vw, 24px) 0 clamp(12px, 4vw, 20px);
    gap: 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .edge-hero-topbar__left {
    width: 100%;
    padding-left: var(--edge-side-pad);
  }

  .edge-hero-topbar__right {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
    padding-right: var(--edge-side-pad);
  }

  .edge-hero {
    width: 100%;
    padding: clamp(26px, 8vw, 48px) var(--edge-side-pad) clamp(32px, 10vw, 52px);
    border-radius: clamp(24px, 10vw, 36px);
    align-items: center;
    text-align: center;
  }

  .edge-home-main {
    gap: 18px;
    width: min(600px, calc(100% - 2 * var(--edge-side-pad)));
    margin: 0 auto;
  }

  .edge-home-subtitle {
    max-width: 100%;
  }

  .edge-sheet {
    width: min(94vw, 680px);
  }

  .edge-sheet-inner {
    border-radius: 24px;
    padding: 20px;
  }
}

@media (max-width: 768px) {
  :root {
    --edge-side-pad: clamp(10px, 7vw, 24px);
  }

  .edge-hero-topbar {
    padding: clamp(14px, 5vw, 22px) 0 clamp(12px, 4vw, 18px);
    gap: 14px;
    flex-wrap: nowrap;
    align-items: center;
  }

  .edge-hero-topbar__left {
    padding-left: var(--edge-side-pad);
  }

  .edge-hero-topbar__right {
    width: 100%;
    padding-right: var(--edge-side-pad);
  }

  .edge-header-actions {
    justify-content: flex-end;
  }

  .mq-actions #btnAI {
    display: inline-flex !important;
  }

  .edge-hero {
    margin: 0 auto;
    min-height: calc(100svh - var(--edge-header-h, 64px));
    padding: clamp(18px, 7vw, 28px) var(--edge-side-pad) clamp(18px, 7vw, 28px);
    gap: 18px;
  }

  .edge-home-main {
    gap: 18px;
    width: min(560px, calc(100% - 2 * var(--edge-side-pad)));
  }

  .edge-home-title {
    font-size: clamp(0.95rem, 3.2vw, 1.2rem);
  }

  .edge-hero-topbar .edge-home-title {
    font-size: clamp(0.75rem, 3.4vw, 0.95rem);
  }

  .edge-home-subtitle {
    font-size: 0.98rem;
  }

  .edge-sheet {
    width: 100vw;
    left: 50%;
    transform: translate(-50%, 0);
    max-height: 90vh;
  }

  .edge-sheet--open {
    bottom: 0;
  }

  .edge-sheet-inner {
    border-radius: 24px 24px 0 0;
    padding: 20px 18px 26px;
  }

  .edge-sheet-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .edge-sheet-tabs button {
    flex: 0 0 auto;
  }
}

@media (max-width: 540px) {
  :root {
    --edge-side-pad: clamp(8px, 8vw, 20px);
  }

  .edge-hero-topbar {
    flex-direction: row;
    align-items: center;
    padding: 0 var(--edge-side-pad) clamp(12px, 4vw, 18px);
  }

  .edge-hero-topbar__left {
    padding-left: var(--edge-side-pad);
  }

  .edge-hero {
    min-height: unset;
    padding: clamp(20px, 9vw, 28px) var(--edge-side-pad) clamp(24px, 10vw, 32px);
    gap: 20px;
  }

  .edge-header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .edge-home-main {
    gap: 16px;
    width: min(500px, calc(100% - 2 * var(--edge-side-pad)));
  }

  .edge-home-title {
    font-size: 1.05rem;
  }

  .edge-home-subtitle {
    font-size: 0.95rem;
  }

  .edge-brand img {
    width: 34px;
    height: 34px;
  }

  .edge-sheet-inner {
    padding: 18px 14px 24px;
  }

}

@media (max-width: 420px) {
  .edge-hero {
    padding: 20px 14px 26px;
    border-radius: 22px;
  }

  .edge-home-title {
    font-size: 1rem;
  }

  .edge-home-subtitle {
    font-size: 0.92rem;
  }

  .edge-sheet-tabs {
    gap: 10px;
  }
}

@keyframes quantumDrift {
  0% { transform: translate3d(-3%, -2%, 0) scale(1.05); }
  100% { transform: translate3d(3%, 4%, 0) scale(1.08); }
}

@keyframes gridPulse {
  0%, 100% { opacity: 0.18; transform: scale(1); }
  50% { opacity: 0.28; transform: scale(1.04); }
}

@keyframes pulseNode {
  0%, 100% { opacity: 0.45; transform: translate3d(-2%, -1%, 0) scale(1); }
  50% { opacity: 0.8; transform: translate3d(2%, 3%, 0) scale(1.08); }
}

@keyframes sheenSweep {
  0% { transform: translateX(-40%) skewX(-12deg); opacity: 0; }
  25% { opacity: 0.35; }
  50% { transform: translateX(0) skewX(-6deg); opacity: 0.5; }
  75% { opacity: 0.3; }
  100% { transform: translateX(40%) skewX(-12deg); opacity: 0; }
}
/* Hide unused secondary tab strip on landing view */
.mq-stage .mq-tabs {
  display: none;
}


/* ✅ شاشات الجوال: قرّب الشعار من الحافة العلوية والجانبية */
@media (max-width: 768px) {
  /* قلّل البادينج العام للستيج مع مراعاة الـ safe area في iOS */
  .mq-stage {
    padding-top: max(6px, env(safe-area-inset-top)) !important;
    padding-bottom: clamp(24px, 6vh, 48px); /* كما تحب */
  }

  /* قلّل الحشوة الجانبية كلها (يسار/يمين) للهيدر */
  :root {
    --edge-side-pad: 10px;  /* كانت أكبر من كذا على الجوال */
  }

  /* الهيدر نفسه نخليه نحيف جدًا من فوق */
  .edge-hero-topbar {
    padding-top: 6px !important;
    padding-bottom: 4px !important;
    gap: 10px;
  }

  /* تأكيد قرب البراند من الحافة اليسرى */
  .edge-hero-topbar__left {
    padding-left: var(--edge-side-pad) !important;
    flex: 1 1 60%;
    min-width: 0;
    max-width: 62%;
    align-items: center;
  }
  .edge-hero-topbar__right {
    padding-right: var(--edge-side-pad) !important;
    flex: 0 0 auto;
    align-items: center;
  }

  /* حجم الشعار مثل أيقونة المستخدم */
  .edge-brand img {
    width: 44px !important;
    height: 44px !important;
  }
  .edge-brand span {
    font-size: clamp(0.95rem, 4.2vw, 1.2rem) !important;
    line-height: 1.1 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}




@media (max-width: 768px) {
  /* الهيدر ثابت */
  .edge-hero-topbar {
    position: fixed;
    top: env(safe-area-inset-top, 0);
    left: 0; right: 0;
    z-index: 10060;
    background: rgba(6,14,25,0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    /* ابقي أي paddings كما تحب */
  }

  :root {
    --edge-header-h: 72px;
  }

  .mq-stage {
    padding-top: calc(var(--edge-header-h, 72px) + env(safe-area-inset-top, 0) + 8px) !important;
  }

  /* نعوّض تلقائيًا بارتفاع الهيدر المحسوب */
  .edge-hero {
    margin-top: 0 !important;
    margin-bottom: 24px !important; /* بدل قيم vh لتجنّب اهتزاز iOS */
  }

  /* أمان ضد التمرير الأفقي */
  html, body { overflow-x: hidden; }
}


/* ✅ بطاقة المستخدم تحت الهيدر مباشرة على الجوال */
@media (max-width: 768px) {
  .user-card {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0) + var(--edge-header-h, 64px) + 8px) !important;
    right: 12px !important;
    left: auto !important;
    width: min(240px, calc(100vw - 24px)) !important;
    z-index: 10030 !important; /* أعلى من الهيدر المثبّت */
    --caret-left: calc(100% - 56px); /* سنجعل سهم الكارت يشير لأيقونة المستخدم يمينًا */
  }
}


/* اجعل المودال أعلى من البطاقة دائمًا (لو احتجت) */
@media (max-width: 768px) {
  .user-card { z-index: 10030 !important; } /* أقل من المودال */
}
