: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 {
  overflow-x: hidden;
  max-width: 100%;
}
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;
  width: 100%;
  max-width: 100%;
  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%;
  max-width: 100%;
  min-width: 0;
}

.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: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.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;
  width: 100%;
  min-width: 0;
}
.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 46px;
  pointer-events: none;
}
.input-wrap input, .input-wrap textarea {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding-block: 0.85rem;
  padding-inline-start: 0.15rem;
  padding-inline-end: 0.9rem;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
.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;
  font-weight: 700;
  max-width: 100%;
  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%;
  max-width: 100%;
  min-width: 0;
  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;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
    max-width: 100%;
  }
  .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; flex-basis: 42px; }
  .input-wrap input, .input-wrap textarea {
    padding-block: 0.8rem;
    padding-inline-start: 0.15rem;
    padding-inline-end: 0.75rem;
    font-size: 1rem; /* يمنع zoom تلقائي على iOS */
  }

  .actions { gap: 0.55rem; }
  .shell .hero-card > .actions .btn,
  .shell .panel-card > .actions .btn,
  .shell .form-grid > .actions .btn,
  .dash-head__logout .btn {
    width: 100%;
    min-height: 48px;
    padding: 0.85rem 1rem;
  }
  .shell .form-grid > .actions .btn,
  .shell .hero-card > .actions .btn,
  .shell .panel-card > .actions .btn { flex: 1 1 100%; }
  .contact-banner .actions .btn { width: auto; flex: 1 1 auto; }
  .playlist-actions .btn { width: 100%; min-height: 40px; }

  .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;
  }
}

@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%; min-width: 0; }
.playlist-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.7rem;
  padding: 1rem 1.05rem;
  border-radius: 16px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  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-url-hidden {
  display: inline-flex !important;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  letter-spacing: 0.01em;
  white-space: normal !important;
  overflow: visible;
  max-width: 100%;
}
.playlist-url-hidden i {
  opacity: 0.85;
  color: var(--accent);
}
.reveal-error {
  color: #fecaca;
  background: color-mix(in srgb, #ef4444 16%, transparent);
  border: 1px solid color-mix(in srgb, #ef4444 40%, transparent);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  font-size: 0.88rem;
  font-weight: 600;
}
.reveal-result label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
}
.reveal-url-box {
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: auto;
  max-height: min(28vh, 9.5rem);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  background: color-mix(in srgb, var(--surface2) 90%, transparent);
  user-select: all;
  -webkit-overflow-scrolling: touch;
}
.pin-pair {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
}
@media (min-width: 560px) {
  .pin-pair { grid-template-columns: 1fr 1fr; }
}
.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: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  padding-top: 0.15rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  min-width: 0;
}
.playlist-action-btn {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 12px !important;
  font-weight: 800;
}
.playlist-action-btn i { font-size: 0.85rem; }
.playlist-action-btn span { min-width: 0; }
.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: 1000;
  background: rgba(5, 8, 20, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom)) max(1rem, var(--safe-left));
  overscroll-behavior: contain;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  width: min(420px, 100%);
  max-width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.15rem 1.2rem;
  max-height: min(85dvh, 100%);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}
.modal-handle { display: none; }
.modal h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1.3;
}
.modal h3 i { font-size: 0.92rem; opacity: 0.9; flex: 0 0 auto; }
.modal p {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}
.modal .form-grid {
  gap: 0.85rem;
  margin-top: 0;
  display: grid;
  width: 100%;
}
.modal .field {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}
.modal .field label {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.3;
}
.modal .input-wrap {
  min-height: 48px;
}
.modal .input-wrap .ico {
  width: 44px;
  flex: 0 0 44px;
}
.modal .input-wrap input {
  font-size: 16px;
  padding-block: 0.75rem;
  padding-inline-start: 0.2rem;
  padding-inline-end: 0.85rem;
  line-height: 1.35;
  min-height: 48px;
}
.modal .actions {
  margin-top: 0.95rem;
  gap: 0.55rem;
  flex-wrap: wrap;
  flex-direction: row;
}
.modal .actions .btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 0.6rem 0.7rem;
  font-size: 0.88rem;
  border-radius: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
html.modal-open,
html.modal-open body {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}
body.modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
}
html.modal-open .modal-backdrop {
  touch-action: none;
  overscroll-behavior: none;
}
html.modal-open .modal {
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.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;
  overflow: hidden;
  max-width: 100%;
  min-width: 0;
  transition:
    border-color 0.45s ease,
    box-shadow 0.45s ease,
    transform 0.45s cubic-bezier(.22,1.2,.36,1);
}
.remain-card.is-updating {
  transform: translateY(-2px);
}
.remain-card.is-extend {
  border-color: color-mix(in srgb, var(--green) 55%, var(--border));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--green) 28%, transparent),
    0 16px 36px color-mix(in srgb, var(--green) 18%, transparent),
    var(--shadow);
}
.remain-card.is-shrink {
  border-color: color-mix(in srgb, var(--orange) 55%, var(--border));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--orange) 28%, transparent),
    0 16px 36px color-mix(in srgb, var(--orange) 16%, transparent),
    var(--shadow);
}
@keyframes remainIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes remainIcoSpin {
  0% { transform: rotate(0deg) scale(1); }
  40% { transform: rotate(-18deg) scale(1.08); }
  100% { transform: rotate(0deg) scale(1); }
}
@keyframes remainDaysPop {
  0% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.12); filter: brightness(1.15); }
  100% { transform: scale(1); filter: brightness(1); }
}
@keyframes remainDeltaIn {
  from { opacity: 0; transform: translateY(6px); }
  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;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.remain-card.is-updating .remain-ico {
  animation: remainIcoSpin 0.7s cubic-bezier(.22,1.2,.36,1);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent);
}
.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); transition: color 0.35s ease; }
.remain-card.is-extend .remain-copy b { color: var(--green); }
.remain-card.is-shrink .remain-copy b { color: var(--orange); }
.remain-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  padding: 0.22rem 0.55rem;
  width: fit-content;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  animation: remainDeltaIn 0.4s ease both;
}
.remain-delta.is-extend {
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid color-mix(in srgb, var(--green) 35%, transparent);
}
.remain-delta.is-shrink {
  color: var(--orange);
  background: var(--orange-soft);
  border: 1px solid color-mix(in srgb, var(--orange) 35%, transparent);
}
.remain-big {
  text-align: center;
  min-width: 0;
  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;
  transition: transform 0.35s ease;
}
.remain-big em.is-animating {
  animation: remainDaysPop 0.65s cubic-bezier(.22,1.2,.36,1);
}
.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 1.15s cubic-bezier(.22,1,.36,1), filter 0.45s ease;
  will-change: width;
  transform-origin: inline-start center;
}
.remain-card.is-extend .remain-bar span {
  filter: saturate(1.15) brightness(1.05);
}
.remain-card.is-shrink .remain-bar span {
  filter: saturate(1.05) hue-rotate(-12deg);
}

/* —— تخطيط لوحة القوائم —— */
.dash-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-start;
}
.dash-head__info { min-width: 0; flex: 1 1 220px; }
.dash-head__logout { flex: 0 0 auto; }

img, video, svg { max-width: 100%; height: auto; }
.form-grid, .field, .input-wrap, .hero-card, .panel-card, .remain-card {
  max-width: 100%;
  min-width: 0;
}

/* ========================================
   Responsive — هواتف وشاشات صغيرة
   (في نهاية الملف ليغلب القواعد السابقة)
   ======================================== */
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .steps {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
    max-width: 100%;
  }
  .steps::-webkit-scrollbar { display: none; }
}

@media (max-width: 720px) {
  :root {
    --page-pad: 0.85rem;
    --page-pad-y: 0.7rem;
    --radius: 14px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .brand { min-width: 0; }
  .brand-text { min-width: 0; }
  .brand-text strong,
  .brand-text span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 0.95rem; }
  .brand-text strong { font-size: 0.98rem; }
  .brand-text span { font-size: 0.74rem; }

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

  .shell {
    padding: 0.85rem var(--page-pad) 1.5rem;
    min-height: calc(100dvh - 9.5rem);
  }

  .hero-card,
  .panel-card,
  .remain-card {
    padding: 1rem 0.95rem 0.95rem;
    border-radius: 14px;
  }
  .hero-card h1,
  .panel-card h1,
  .panel-card h2 {
    font-size: clamp(1.2rem, 6vw, 1.5rem);
    line-height: 1.25;
  }
  .lead { font-size: 0.9rem; max-width: none; }

  .dash-head {
    flex-direction: column;
    align-items: stretch;
  }
  .dash-head__logout,
  .dash-head__logout .btn {
    width: 100%;
  }

  .remain-top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .remain-ico {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }
  .remain-copy { flex: 1 1 auto; }
  .remain-big {
    width: 100%;
    margin-inline-start: 0;
    text-align: start;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem 0.55rem;
    min-width: 0;
  }
  .remain-big em {
    display: inline;
    font-size: clamp(1.55rem, 7vw, 1.85rem);
  }
  .remain-big small { display: inline; }
  .remain-sub {
    width: 100%;
    margin-top: 0.1rem;
  }
  .remain-delta { font-size: 0.7rem; }

  .actions {
    flex-direction: column;
    gap: 0.55rem;
  }
  .shell .hero-card > .actions .btn,
  .shell .panel-card > .actions .btn,
  .shell .form-grid > .actions .btn,
  .dash-head__logout .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
    padding: 0.85rem 1rem;
  }
  .shell .form-grid > .actions .btn,
  .shell .hero-card > .actions .btn,
  .shell .panel-card > .actions .btn { flex: 1 1 100%; }
  .playlist-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    padding-top: 0.45rem;
  }
  .playlist-actions .btn,
  .playlist-action-btn {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    height: auto;
    padding: 0.4rem 0.28rem !important;
    border-radius: 10px !important;
    font-size: 0.68rem;
    font-weight: 700;
    gap: 0.22rem;
    white-space: normal;
    line-height: 1.15;
  }
  .playlist-action-btn--show {
    grid-column: auto;
  }
  .playlist-action-btn i { font-size: 0.72rem; flex: 0 0 auto; }
  .playlist-action-btn span {
    display: inline !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .contact-banner {
    flex-direction: column;
    gap: 0.65rem;
  }
  .contact-banner .actions {
    width: 100%;
    flex-direction: row;
  }
  .contact-banner .actions .btn {
    width: auto;
    flex: 1 1 auto;
    min-height: 42px;
    padding: 0.65rem 0.85rem;
  }

  .alert {
    font-size: 0.88rem;
    line-height: 1.45;
    padding: 0.75rem 0.85rem;
    word-break: break-word;
  }

  .input-wrap .ico { width: 42px; flex-basis: 42px; }
  .input-wrap input,
  .input-wrap textarea {
    font-size: 16px; /* يمنع zoom iOS */
    padding-block: 0.8rem;
    padding-inline-start: 0.15rem;
    padding-inline-end: 0.75rem;
  }

  .device-chip {
    font-size: 0.72rem;
    width: 100%;
    justify-content: flex-start;
  }

  .playlist-item {
    padding: 0.75rem 0.8rem;
    border-radius: 14px;
    gap: 0.55rem;
  }
  .playlist-meta span {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
  }

  .page-nav { margin-bottom: 0.55rem; }
  .page-back { min-height: 42px; width: auto; max-width: 100%; }

  /* نافذة في الوسط — لا تتجاوز عرض الشاشة */
  .modal-backdrop {
    padding: max(0.75rem, var(--safe-top)) 0.75rem max(0.75rem, var(--safe-bottom));
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .modal {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: min(82dvh, calc(100% - 1.5rem - var(--kb-inset, 0px)));
    border-radius: 16px;
    padding: 0.95rem 0.85rem 1rem;
    margin: 0;
    box-shadow: var(--shadow);
  }
  .modal-handle { display: none; }
  .modal h3 { font-size: 1rem; }
  .modal p { font-size: 0.84rem; margin-bottom: 0.7rem; }
  .modal .field label { font-size: 0.8rem; }
  .modal .form-grid { gap: 0.7rem; }
  .modal .actions {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.4rem;
    margin-top: 0.8rem;
    min-width: 0;
  }
  .modal .actions .btn {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 42px;
    padding: 0.5rem 0.45rem;
    font-size: 0.82rem;
    border-radius: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .reveal-url-box {
    font-size: 0.75rem;
    max-height: 6.5rem;
    padding: 0.6rem 0.7rem;
  }

  .site-footer {
    flex-wrap: wrap;
    font-size: 0.76rem;
    line-height: 1.4;
    padding-bottom: calc(1.1rem + var(--safe-bottom));
  }

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

@media (max-width: 420px) {
  :root { --page-pad: 0.72rem; }

  .theme-bar-label { display: none; }
  .theme-bar { padding: 0.3rem 0.4rem; flex: 0 0 auto; }
  .lang-btn { padding: 0.55rem 0.75rem; font-size: 0.74rem; min-height: 40px; }
  .theme-toggle { width: 54px; height: 32px; }

  .steps { gap: 0.3rem; }
  .step span:not(.step-ico) {
    max-width: 4.6rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .remain-big em { font-size: 1.45rem; }
  .kicker { font-size: 0.72rem; }
  .hero-card h1,
  .panel-card h1 { font-size: 1.2rem; }

  .pin-pair { grid-template-columns: 1fr; }

  .playlist-action-btn {
    min-height: 38px;
    padding: 0.35rem 0.2rem !important;
    font-size: 0.64rem;
    gap: 0.18rem;
  }
  .playlist-action-btn span { display: inline !important; }

  .modal {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0.85rem 0.75rem 0.9rem;
    max-height: min(80dvh, calc(100% - 1.2rem - var(--kb-inset, 0px)));
  }
  .modal h3 { font-size: 0.95rem; }
  .modal p { font-size: 0.8rem; }
  .modal .actions .btn {
    min-height: 40px;
    padding: 0.45rem 0.45rem;
    font-size: 0.78rem;
    gap: 0.25rem;
  }
  .modal .actions .btn i { font-size: 0.75rem; }
}

/* تحسين اللمس على الشاشات اللمسية */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .page-back,
  .lang-btn,
  .theme-toggle,
  .playlist-action-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .btn:active { transform: scale(0.98); }
}
