:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050814;
  --bg-elevated: #0a0f24;
  --surface: #0e1430;
  --surface2: #171e42;
  --text: #f4f7ff;
  --text-muted: #a5b0d0;
  --accent: #00f0ff;
  --accent-2: #c44dff;
  --accent-soft: rgba(0, 240, 255, 0.14);
  --violet-soft: rgba(196, 77, 255, 0.16);
  --green: #3dff9a;
  --green-soft: rgba(61, 255, 154, 0.14);
  --red: #ff5c7a;
  --red-soft: rgba(255, 92, 122, 0.14);
  --orange: #ffd60a;
  --nova-gradient: linear-gradient(135deg, #c44dff 0%, #5b7cff 48%, #00f0ff 100%);
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --border: rgba(255, 255, 255, 0.1);
  --ring: 0 0 0 3px rgba(0, 240, 255, 0.22);
  --theme-track: #171e42;
  --theme-thumb: #00f0ff;
  --theme-icon: #050814;
  --input-bg: rgba(5, 8, 20, 0.72);
  --card-glow: rgba(0, 240, 255, 0.12);
  --body-glow-1: rgba(196, 77, 255, 0.22);
  --body-glow-2: rgba(0, 240, 255, 0.16);
  --page-pad: clamp(0.85rem, 3.2vw, 2.25rem);
  --page-pad-y: clamp(0.75rem, 2vw, 1.35rem);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #e9eef8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface2: #e2e8f4;
  --text: #0b1224;
  --text-muted: #3a4663;
  --accent: #007a96;
  --accent-2: #7c1fc0;
  --accent-soft: rgba(0, 122, 150, 0.12);
  --violet-soft: rgba(124, 31, 192, 0.1);
  --green: #0a8f59;
  --green-soft: rgba(10, 143, 89, 0.12);
  --red: #c81e4a;
  --red-soft: rgba(200, 30, 74, 0.1);
  --orange: #b88600;
  --nova-gradient: linear-gradient(135deg, #8b2fd6 0%, #3f63f0 48%, #0096b5 100%);
  --shadow: 0 12px 32px rgba(30, 45, 90, 0.12);
  --border: #c5cede;
  --ring: 0 0 0 3px rgba(0, 122, 150, 0.2);
  --theme-track: #d5dceb;
  --theme-thumb: #7c1fc0;
  --theme-icon: #ffffff;
  --input-bg: #f3f6fb;
  --card-glow: rgba(0, 122, 150, 0.08);
  --body-glow-1: rgba(124, 31, 192, 0.08);
  --body-glow-2: rgba(0, 122, 150, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; min-height: 100dvh; }
body {
  font-family: Outfit, Cairo, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  position: relative;
  overflow-x: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
}
html[dir="rtl"] body { font-family: Cairo, Outfit, system-ui, sans-serif; }

.bg-glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 480px at 12% -10%, var(--body-glow-1), transparent 60%),
    radial-gradient(700px 420px at 90% 0%, var(--body-glow-2), transparent 55%),
    radial-gradient(600px 400px at 50% 110%, rgba(91, 124, 255, 0.12), transparent 60%);
  z-index: 0;
}

.topbar, .steps, .shell, .site-footer { position: relative; z-index: 1; width: 100%; }

.topbar {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: calc(var(--page-pad-y) + var(--safe-top)) var(--page-pad) 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1rem;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.85rem; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--nova-gradient);
  color: #050814;
  box-shadow: 0 8px 24px rgba(0, 240, 255, 0.25);
  font-size: 1.05rem;
}
.brand-text { display: flex; flex-direction: column; gap: 0.1rem; }
.brand-text strong { font-size: 1.05rem; letter-spacing: 0.01em; }
.brand-text span { color: var(--text-muted); font-size: 0.82rem; font-weight: 600; }

.top-controls { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.theme-bar {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.theme-bar-label { display: flex; flex-direction: column; line-height: 1.15; }
.theme-bar-label strong { font-size: 0.78rem; }
.theme-bar-label span { font-size: 0.68rem; color: var(--text-muted); }

.theme-toggle {
  position: relative;
  width: 58px; height: 30px;
  border: 0; border-radius: 999px;
  background: var(--theme-track);
  cursor: pointer;
  padding: 0;
}
.theme-toggle .theme-icons {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 9px; color: var(--text-muted); font-size: 0.72rem;
}
.theme-toggle .theme-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--theme-thumb);
  transition: transform 0.22s ease;
  display: grid; place-items: center;
}
.theme-toggle .theme-thumb::before {
  content: "\f186";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.7rem;
  color: var(--theme-icon);
}
html[data-theme="light"] .theme-toggle .theme-thumb { transform: translateX(28px); }
html[data-theme="light"] .theme-toggle .theme-thumb::before { content: "\f185"; }
html[dir="rtl"] .theme-toggle .theme-thumb { left: auto; right: 3px; }
html[dir="rtl"][data-theme="light"] .theme-toggle .theme-thumb { transform: translateX(-28px); }

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.lang-btn {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.55rem 0.85rem;
}
.lang-btn.is-active,
.lang-btn:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.steps {
  max-width: none;
  width: 100%;
  margin: 0.65rem 0 0;
  padding: 0 var(--page-pad);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.step {
  display: flex; align-items: center; gap: 0.45rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}
.step-ico {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.78rem;
  flex: 0 0 auto;
}
.step.is-active { color: var(--text); }
.step.is-active .step-ico {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}
.step.is-done .step-ico {
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 40%, transparent);
  color: var(--green);
}
.step-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  min-width: 12px;
}

.shell {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 1rem var(--page-pad) 2.25rem;
  min-height: calc(100dvh - 11rem);
}

.page-nav {
  display: flex;
  justify-content: flex-start;
  margin: 0 0 0.75rem;
}
.page-back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.page-back:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--accent);
}

.hero-card, .panel-card {
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent-2) 10%, var(--surface)), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.05rem, 2.4vw, 1.6rem);
  position: relative;
  overflow: visible;
  width: 100%;
}
.hero-card::before, .panel-card::before {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 280px; height: 280px;
  background: radial-gradient(circle, var(--card-glow), transparent 70%);
  pointer-events: none;
}

.kicker {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.75rem; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: #050814;
  background: var(--nova-gradient);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  margin-bottom: 0.85rem;
}
.hero-card h1, .panel-card h1, .panel-card h2 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.45rem, 2.4vw, 1.9rem);
  letter-spacing: -0.02em;
}
.lead { margin: 0; color: var(--text-muted); max-width: 54rem; }

.form-grid { margin-top: 1.25rem; display: grid; gap: 0.9rem; width: 100%; }
.field label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.field .hint { margin-top: 0.35rem; color: var(--text-muted); font-size: 0.8rem; }
.input-wrap {
  display: flex; align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  overflow: hidden;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.input-wrap:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: var(--ring);
}
.input-wrap .ico {
  width: 46px; display: grid; place-items: center;
  color: var(--accent); background: transparent; flex: 0 0 auto;
}
.input-wrap input, .input-wrap textarea {
  flex: 1; border: 0; outline: none;
  background: transparent; color: var(--text);
  font: inherit; padding: 0.85rem 0.9rem 0.85rem 0;
  min-width: 0;
}
.input-wrap textarea { resize: vertical; min-height: 84px; padding-top: 0.85rem; }

.actions {
  display: flex; flex-wrap: wrap; gap: 0.7rem;
  margin-top: 1.15rem;
}
.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  border-radius: 999px;
  padding: 0.78rem 1.15rem;
  font: inherit; font-weight: 700;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #050814;
  background: var(--nova-gradient);
  box-shadow: 0 10px 28px rgba(0, 240, 255, 0.22);
}
.btn-secondary {
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
}
.btn-contact {
  color: #050814;
  background: linear-gradient(135deg, #ffd60a, #ff9f1a);
  box-shadow: 0 10px 24px rgba(255, 214, 10, 0.22);
}
.btn-danger-soft {
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid color-mix(in srgb, var(--red) 35%, transparent);
}
.btn-ghost {
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
}
.btn-icon {
  width: 40px; height: 40px; padding: 0; border-radius: 12px;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.alert {
  display: flex; gap: 0.65rem; align-items: flex-start;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin: 1rem 0 0;
  font-weight: 600;
}
.alert-ok { background: var(--green-soft); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); }
.alert-err { background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); }

.device-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  margin-top: 0.9rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--violet-soft);
  border: 1px solid color-mix(in srgb, var(--accent-2) 35%, transparent);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.contact-banner {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px dashed color-mix(in srgb, var(--orange) 45%, transparent);
  background: color-mix(in srgb, var(--orange) 10%, transparent);
  color: var(--text);
  display: flex; gap: 0.75rem; align-items: flex-start;
}
.contact-banner i { color: var(--orange); margin-top: 0.15rem; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(0.85rem, 2vw, 1.35rem);
  margin-top: 1rem;
  width: 100%;
  align-items: start;
}

.site-footer {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0 var(--page-pad) calc(1.35rem + var(--safe-bottom));
  color: var(--text-muted);
  font-size: 0.82rem;
  display: flex; gap: 0.5rem; align-items: center;
}

/* —— هاتف / شاشات ضيقة —— */
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .steps {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
  }
  .steps::-webkit-scrollbar { display: none; }
}

@media (max-width: 640px) {
  :root {
    --page-pad: 0.9rem;
    --radius: 14px;
  }

  .topbar {
    align-items: flex-start;
    gap: 0.75rem;
  }
  .brand { min-width: 0; flex: 1 1 auto; }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .brand-text strong { font-size: 0.98rem; }
  .brand-text span { font-size: 0.75rem; }

  .top-controls {
    width: 100%;
    justify-content: space-between;
    gap: 0.55rem;
  }
  .theme-bar {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.4rem 0.55rem;
  }
  .theme-bar-label strong { font-size: 0.72rem; }
  .theme-bar-label span { display: none; }

  .step span:not(.step-ico) { font-size: 0.74rem; }
  .step-ico { width: 28px; height: 28px; border-radius: 8px; font-size: 0.72rem; }

  .shell { padding-top: 0.85rem; min-height: calc(100dvh - 10rem); }

  .hero-card h1, .panel-card h1, .panel-card h2 {
    font-size: clamp(1.28rem, 6.5vw, 1.55rem);
  }
  .lead { font-size: 0.92rem; }

  .input-wrap .ico { width: 42px; }
  .input-wrap input, .input-wrap textarea {
    padding: 0.8rem 0.75rem 0.8rem 0;
    font-size: 1rem; /* يمنع zoom تلقائي على iOS */
  }

  .actions { gap: 0.55rem; }
  .btn {
    width: 100%;
    min-height: 48px;
    padding: 0.85rem 1rem;
  }
  .actions .btn { flex: 1 1 100%; }
  .contact-banner .actions .btn { width: auto; flex: 1 1 auto; }
  .playlist-actions .btn { width: auto; min-height: 44px; }

  .page-back { min-height: 42px; }

  .remain-top { gap: 0.7rem; }
  .remain-ico { width: 42px; height: 42px; border-radius: 12px; }
  .remain-big {
    width: 100%;
    margin-inline-start: 0;
    text-align: start;
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    flex-wrap: wrap;
  }
  .remain-big em { display: inline; font-size: 1.65rem; }
  .remain-big small { display: inline; }
  .remain-sub { width: 100%; margin-top: 0; }

  .device-chip {
    max-width: 100%;
    font-size: 0.72rem;
  }

  .playlist-meta span {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .modal {
    width: 100%;
    max-height: min(92dvh, 100%);
    overflow: auto;
    border-radius: 16px;
  }
  .modal-backdrop { padding: 0.65rem; align-items: flex-end; }
}

@media (min-width: 1100px) {
  .dash-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  }
}

@media (min-width: 1400px) {
  .hero-card h1, .panel-card h1 {
    font-size: clamp(1.7rem, 1.6vw, 2.1rem);
  }
}

.playlist-list { display: grid; gap: 0.85rem; width: 100%; }
.playlist-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
  padding: 1rem 1.05rem;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--accent-2) 22%, var(--border));
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 55%),
    color-mix(in srgb, var(--surface2) 82%, transparent);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
}
.playlist-meta { min-width: 0; }
.playlist-meta strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 1.02rem;
  font-weight: 800;
}
.playlist-meta span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  word-break: break-all;
}
.playlist-meta .badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin-top: 0.55rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem; font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.playlist-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  padding-top: 0.15rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}
.playlist-action-btn {
  flex: 1 1 120px;
  min-height: 42px;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 12px !important;
  font-weight: 800;
}
.playlist-action-btn i { font-size: 0.85rem; }
.empty-state {
  text-align: center;
  padding: 1.6rem 1rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}
.empty-state i { font-size: 1.5rem; margin-bottom: 0.5rem; color: var(--accent); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(5, 8, 20, 0.62);
  display: none; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem;
}
.modal h3 { margin: 0 0 0.4rem; }
.modal p { margin: 0 0 0.9rem; color: var(--text-muted); }

.remain-card {
  margin: 0 0 1rem;
  padding: 1.1rem 1.2rem 1rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 55%),
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 10%, var(--surface)), var(--surface));
  box-shadow: var(--shadow);
  animation: remainIn 0.45s ease both;
}
@keyframes remainIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.remain-top {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.remain-ico {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--nova-gradient);
  color: #050814;
  font-size: 1.1rem;
  flex: 0 0 auto;
}
.remain-copy {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.remain-copy strong { font-size: 1.02rem; }
.remain-copy span { color: var(--text-muted); font-size: 0.86rem; }
.remain-copy b { color: var(--text); }
.remain-big {
  text-align: center;
  min-width: 120px;
  margin-inline-start: auto;
}
.remain-big em {
  display: block;
  font-style: normal;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--nova-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.05;
}
.remain-big em.is-expired {
  font-size: 1rem;
  color: var(--red);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
}
.remain-big small {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.78rem;
}
.remain-sub {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.remain-bar {
  margin-top: 0.85rem;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface2) 80%, transparent);
  overflow: hidden;
}
.remain-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--nova-gradient);
  transition: width 0.6s ease;
}
