/* M2FORUM — Download gate popup (zeina theme)
 * Uses theme tokens: --color-primary / --color-primary-dark / --color-text(-dark)
 * are "r, g, b" triplets set by the zeina style; fallbacks below are used if missing.
 */

.dlgate {
  --dlg-primary: var(--color-primary, 59, 130, 246);
  --dlg-text: var(--color-text, 31, 41, 55);
  --dlg-bg: #fff;
  --dlg-surface: #f9fafb;
  --dlg-border: #e5e7eb;
  --dlg-fg: #1f2937;
  --dlg-muted: rgb(106, 112, 126);
  --dlg-shadow: none;

  position: fixed;
  inset: 0;
  z-index: 100000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--dlg-fg);
  visibility: hidden;
  pointer-events: none;
}

.dark .dlgate {
  --dlg-primary: var(--color-primary-dark, var(--color-primary, 96, 165, 250));
  --dlg-text: var(--color-text-dark, 226, 232, 240);
  --dlg-bg: #0f172a;
  --dlg-surface: #1e293b;
  --dlg-border: rgb(51 65 85 / .6);
  --dlg-fg: #e2e8f0;
  --dlg-muted: rgb(156, 163, 175);
  --dlg-shadow: none;
}

.dlgate *, .dlgate *::before, .dlgate *::after { box-sizing: border-box; }

.dlgate.is-open { visibility: visible; pointer-events: auto; }

/* Backdrop */
.dlgate-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / .55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .2s ease;
}
.dlgate.is-open .dlgate-backdrop { opacity: 1; }

/* Dialog card */
.dlgate-dialog {
  position: relative;
  width: 100%;
  max-width: 1222px;
  max-height: calc(100vh - 32px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: .75rem;
  border: 1px solid var(--dlg-border);
  background: var(--dlg-bg);
  box-shadow: none;
  opacity: 0;
  transform: translateY(12px) scale(.97);
  transition: opacity .22s ease, transform .26s cubic-bezier(.2, .9, .3, 1.15);
}
.dlgate.is-open .dlgate-dialog { opacity: 1; transform: none; }

/* Close */
.dlgate-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: rgb(15 23 42 / .55);
  color: #fff;
  cursor: pointer;
  transition: background-color .15s ease, transform .15s ease;
}
.dlgate-close:hover { background: rgb(15 23 42 / .8); }
.dlgate-close:active { transform: scale(.94); }
.dlgate-close svg { width: 16px; height: 16px; }

/* Header-style advertisement; native 1204 x 96 canvas, scaled on small screens. */
.dlgate-ad { padding: 8px 8px 0; }
.dlgate-ad .m2-ad-shell { position:relative; width:100%; max-width:1204px; margin:0 auto; overflow:hidden; border-radius:11px; background:#10192b; }
.dlgate-ad .banner-container { position:relative; width:100%; aspect-ratio:1204 / 96; overflow:hidden; }
.dlgate-ad .banner { position:absolute; inset:0; }
.dlgate-ad-media { position:absolute; inset:0; display:block; text-decoration:none; }
.dlgate-ad-media img,.dlgate-ad-media video { display:block; width:100%; height:100%; object-fit:contain; object-position:center; }
.dlgate-ad .m2-ad-badge { position:absolute; right:4px; bottom:4px; z-index:10; display:inline-block; padding:5px 9px; border:1px solid rgb(255 255 255 / .18); border-radius:5px; background:rgb(30 27 32 / .78); color:#fff; font-family:inherit; font-size:10px; font-weight:500; line-height:1.2; white-space:nowrap; pointer-events:none; }
.dlgate-ad .banner-overlay { position:absolute; inset:0; z-index:3; display:flex; align-items:center; justify-content:center; opacity:0; pointer-events:none; background:rgb(6 11 22 / .45); transition:opacity .22s ease; }
.dlgate-ad .banner-overlay span { padding:9px 14px; border:1px solid rgb(255 255 255 / .15); border-radius:7px; background:rgb(12 21 38 / .92); color:rgb(255 255 255 / .96); font-size:12px; font-weight:600; line-height:1; }
@media(hover:hover) and (pointer:fine) { .dlgate-ad .banner:hover .banner-overlay,.dlgate-ad .banner:focus-within .banner-overlay { opacity:1; } }
@media(hover:none) { .dlgate-ad .banner-overlay { display:none; } }
@media(prefers-reduced-motion:reduce) { .dlgate-ad .banner-overlay { transition:none; } }

/* ---------- Body ---------- */
.dlgate-body {
  max-width: 640px;
  margin-inline: auto;
  padding: 1.25rem 1.5rem 1.5rem;
}
.dlgate-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.dlgate-head-text { flex: 1; min-width: 0; }
.dlgate-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(var(--dlg-primary), .12);
  color: rgba(var(--dlg-primary), 1);
}
.dlgate-icon svg { width: 26px; height: 26px; }

.dlgate-heading {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.6rem;
  font-weight: 700;
  color: var(--dlg-fg);
}
.dlgate-sub {
  margin: .25rem 0 0;
  font-size: .875rem;
  color: var(--dlg-muted);
}

.dlgate-target {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin: 1rem 0 0;
  padding: .625rem .875rem;
  border: 1px solid var(--dlg-border);
  border-radius: .5rem;
  background: var(--dlg-surface);
  text-align: left;
  font-size: .8125rem;
}
.dlgate-target svg { flex-shrink: 0; width: 16px; height: 16px; color: var(--dlg-muted); }
.dlgate-target-text { min-width: 0; flex: 1; }
.dlgate-target-label { display: block; font-size: .6875rem; color: var(--dlg-muted); }
.dlgate-target-size {
  display: block;
  font-size: .75rem;
  color: var(--dlg-muted);
}
.dlgate-target-host {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
  color: var(--dlg-fg);
}

/* Actions */
.dlgate-actions {
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
}
.dlgate-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 44px;
  padding: .625rem 1.25rem;
  border-radius: .5rem;
  border: 1px solid transparent;
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.25rem;
  text-decoration: none !important;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s ease, opacity .15s ease, transform .1s ease;
}
.dlgate-btn:active { transform: scale(.98); }
.dlgate-btn svg { width: 18px; height: 18px; }

.dlgate-btn-primary {
  flex: 1;
  overflow: hidden;
  border-color: rgba(var(--dlg-primary), 1);
  background: rgba(var(--dlg-primary), .95);
  color: #fff !important;
  box-shadow: none;
}
.dlgate-btn-primary:hover { background: rgba(var(--dlg-primary), .85); }

/* countdown progress fill */
.dlgate-btn-primary .dlgate-progress {
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / .18);
  transform-origin: left center;
  transform: scaleX(0);
  pointer-events: none;
}
.dlgate-btn-primary > span:not(.dlgate-progress), .dlgate-btn-primary > svg { position: relative; }

.dlgate-btn-primary[aria-disabled="true"] {
  cursor: not-allowed;
  background: rgba(var(--dlg-primary), .55);
  box-shadow: none;
}
.dlgate-btn-primary[aria-disabled="true"]:active { transform: none; }

.dlgate-btn-ghost {
  border-color: var(--dlg-border);
  background: transparent;
  color: var(--dlg-fg);
}
.dlgate-btn-ghost:hover { background: var(--dlg-surface); }

.dlgate-note {
  margin: .875rem 0 0;
  text-align: center;
  font-size: .75rem;
  color: var(--dlg-muted);
}

.dlgate-btn:focus-visible,
.dlgate-close:focus-visible,
.dlgate-ad-media:focus-visible {
  outline: 2px solid rgba(var(--dlg-primary), 1);
  outline-offset: 2px;
}

html.dlgate-lock { overflow: hidden; }

@keyframes dlgate-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

@media (max-width: 480px) {
  .dlgate { align-items: flex-end; padding: 0; }
  .dlgate-dialog {
    max-width: none;
    max-height: 92vh;
    border-radius: 1rem 1rem 0 0;
    transform: translateY(100%);
    transition: opacity .2s ease, transform .3s cubic-bezier(.2, .9, .3, 1);
  }
  .dlgate-body { padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); }
  .dlgate-actions { flex-direction: column-reverse; }
  .dlgate-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .dlgate-backdrop, .dlgate-dialog, .dlgate-btn,
  .dlgate-ad-media img, .dlgate-ad-media video { transition: none !important; }
  .dlgate-dialog { transform: none !important; }
  .dlgate-ad-media::before { animation: none; }
}

.dlgate [hidden] { display: none !important; }

/* Download secure — extension integration */
.ds-gate-page{margin:0;font-family:system-ui,-apple-system,"Segoe UI",sans-serif;background:transparent}
.ds-gate-page .dlgate{position:relative;min-height:100dvh;height:auto;overflow:visible;padding:12px;align-items:center;}
.ds-gate-page .dlgate-dialog{opacity:1;transform:none;max-height:none;overflow:visible;width:100%;}
.ds-gate-page .ds-intro{font-size:14px;color:var(--dlg-muted);margin:8px 0 0}
.ds-gate-page .dlgate-heading{font-size:22px;margin:0}
.ds-gate-page .ds-captcha{display:flex;justify-content:center;min-height:65px;margin:20px 0 8px}
.ds-status{text-align:center;color:var(--dlg-muted);font-size:13px;min-height:20px}
.ds-error{padding:12px;border-radius:6px;color:#991b1b;background:#fee2e2;font-size:14px}.dark .ds-error{background:#431f25;color:#fecaca}
.dlgate-btn-primary:disabled{opacity:.55;cursor:not-allowed}.dlgate-btn-primary:disabled:active{transform:none}
.ds-modal{padding:0;border:0;background:transparent;width:min(1262px,calc(100vw - 16px));max-width:none;height:min(800px,calc(100dvh - 16px));max-height:none;overflow:hidden;color:inherit}
.ds-modal::backdrop{background:rgb(15 23 42 / .6);backdrop-filter:blur(5px)}
.ds-modal iframe{display:block;width:100%;height:100%;border:0;background:transparent;border-radius:12px}

@media(max-width:480px){.ds-gate-page .dlgate{padding:8px;align-items:flex-start}.ds-gate-page .dlgate-dialog{border-radius:12px;transform:none}.ds-gate-page .dlgate-body{padding:18px}.ds-modal{width:100vw;height:100dvh;margin:0}.ds-modal iframe{border-radius:0}}

/* 1.0.1: inline verification states and flat popup */
.dlgate,.dlgate *,.dlgate *::before,.dlgate *::after,.ds-modal,.ds-modal iframe{box-shadow:none!important;text-shadow:none!important;filter:none!important}
.ds-status.is-success{color:#15803d}.dark .ds-status.is-success{color:#86efac}
.ds-status.is-error{color:#b91c1c}.dark .ds-status.is-error{color:#fca5a5}
.dlgate-close,.dlgate-close:hover,.dlgate-close:focus,.dlgate-close:active{text-decoration:none!important}
.dlgate-close{width:36px;height:36px;border:1px solid rgb(255 255 255 / .2);border-radius:9px;color:#fff!important;background:#172335;line-height:1}
.dlgate-close svg{display:block;width:18px;height:18px;pointer-events:none}
.dlgate-actions{justify-content:center;align-items:center;flex-direction:row}
.dlgate-actions .dlgate-btn-primary{flex:0 1 auto;min-width:220px;width:auto;max-width:100%}
@media(max-width:480px){.dlgate-actions{flex-direction:row;justify-content:center}.dlgate-actions .dlgate-btn-primary{width:auto;min-width:0;padding-inline:24px}}

/* 1.0.2: centered viewport, no visible scrollbars, explicit countdown state. */
.ds-gate-page{height:100dvh;overflow:hidden;box-sizing:border-box}
.ds-gate-page .dlgate{box-sizing:border-box;height:100dvh;min-height:0;overflow:hidden;padding:12px;align-items:center;justify-content:center}
.ds-gate-page .dlgate-dialog{box-sizing:border-box;max-height:calc(100dvh - 24px);overflow-x:hidden;overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none}
.ds-gate-page .dlgate-dialog::-webkit-scrollbar{width:0;height:0;display:none}
.ds-modal{margin:auto!important;width:min(1262px,calc(100vw - 16px));height:min(800px,calc(100dvh - 16px));overflow:hidden}
.dlgate-close{background:#f8fafc;color:#334155!important;border-color:#cbd5e1}
.dark .dlgate-close{background:#1e293b;color:#e2e8f0!important;border-color:#475569}
@media(hover:hover) and (pointer:fine){.dlgate-close:hover{background:#e2e8f0}.dark .dlgate-close:hover{background:#334155}}
.dlgate-btn-primary[data-countdown="true"],.dlgate-btn-primary[data-countdown="true"]:hover{background:#e5e7eb;border-color:#d1d5db;color:#6b7280!important;opacity:1;cursor:not-allowed}
.dark .dlgate-btn-primary[data-countdown="true"],.dark .dlgate-btn-primary[data-countdown="true"]:hover{background:#334155;border-color:#475569;color:#94a3b8!important}
.ds-honeypot{display:none!important}
@media(max-width:480px){.ds-gate-page .dlgate{padding:8px;align-items:center}.ds-gate-page .dlgate-dialog{max-height:calc(100dvh - 16px)}.ds-modal{width:calc(100vw - 16px);height:calc(100dvh - 16px);margin:auto!important}}

/* Keep the loading state small; no close icon is rendered by the loader. */


/* On phones the close control has its own row, clear of the thin banner and badge. */
@media(max-width:480px){.dlgate-ad{padding-top:52px}.dlgate-close{top:8px;right:8px}}

/* 1.0.5: header-sized advertising and a left-aligned two-column task layout. */
.ds-modal{width:min(1082px,calc(100vw - 16px))}
.ds-gate-page .dlgate-dialog{max-width:1042px}
.ds-toolbar{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px 20px 12px}
.ds-toolbar .dlgate-heading{font-size:18px;line-height:1.4}
.ds-toolbar .dlgate-close{position:static;flex:none}
.dlgate-ad{padding:0 8px;width:100%;max-width:1040px;margin-inline:auto}
.dlgate-ad .m2-ad-shell{max-width:1024px}
.dlgate-ad .banner-container{aspect-ratio:1024 / 96}
.dlgate-ad .banner{position:absolute;inset:0}
.dlgate-ad .m2-ad-badge{position:absolute;right:4px;bottom:4px;z-index:10}
.ds-gate-page .dlgate-body{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:36px;max-width:none;margin:0;padding:28px 32px 32px;text-align:left}
.ds-summary{min-width:0}
.ds-gate-page .ds-intro{margin:0;font-size:15px;line-height:1.6;max-width:48ch;color:var(--dlg-fg)}
.dlgate-target{margin-top:20px}
.dlgate-note{text-align:left;line-height:1.6;margin-top:16px;max-width:54ch}
.ds-gate-page .ds-captcha{justify-content:flex-start;margin:0 0 12px}
.ds-status{text-align:left;margin:0 0 16px;line-height:1.5}
.dlgate-actions{justify-content:flex-start;margin:0}
.dlgate-actions .dlgate-btn-primary{min-width:0;padding-inline:24px}
.dlgate-ad .dlgate-ad-media img,.dlgate-ad .dlgate-ad-media video{object-fit:contain}
@media(max-width:760px){.ds-gate-page .dlgate-body{grid-template-columns:minmax(0,1fr);gap:24px;padding:20px}.ds-toolbar{padding:12px 16px}.ds-gate-page .ds-captcha{min-height:65px}.dlgate-actions{justify-content:flex-start}.dlgate-actions .dlgate-btn-primary{width:auto}.dlgate-note{max-width:none}}
@media(max-width:480px){.ds-modal{width:calc(100vw - 16px)}.dlgate-ad{padding:0 8px}.ds-gate-page .dlgate-body{padding:18px;gap:22px}}
@media(max-width:480px){.dlgate-ad .m2-ad-badge{padding:2px 6px;font-size:9px;bottom:3px;right:3px}}

/* 1.0.8: source in header, advertisement, then verification and one action. */
.ds-toolbar{padding:18px 20px 16px;align-items:center}
.ds-file-heading{min-width:0}
.ds-toolbar .dlgate-heading{font-size:18px;line-height:1.4}
.ds-file-source{display:flex;gap:5px;min-width:0;margin:3px 0 0;font-size:12px;line-height:1.5;color:var(--dlg-muted)}
.ds-file-source span{flex:none}
.ds-file-source strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;font-weight:500;color:var(--dlg-fg)}
.ds-gate-page .dlgate-body{display:block;padding:24px 20px}
.dlgate-body [data-ds-form]{display:flex;justify-content:space-between;align-items:center;gap:24px;flex-wrap:wrap}
.ds-verification{flex:1 1 300px;min-width:0;max-width:100%}
.ds-gate-page .ds-captcha{margin:0;min-height:65px;justify-content:flex-start}
.ds-verification .ds-status{margin:8px 0 0;min-height:20px;max-width:44ch;font-size:12px;line-height:1.5}
.dlgate-actions{margin:0;justify-content:flex-end}
.dlgate-actions .dlgate-btn-primary{min-width:180px;border-radius:10px;padding:12px 24px;font-size:14px;line-height:20px}
.dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled){background:#176b3d;border-color:#176b3d;color:#fff!important}
@media(hover:hover) and (pointer:fine){.dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled):hover{background:#125832;border-color:#125832}}
.dark .dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled){background:#a7e8bd;border-color:#a7e8bd;color:#163621!important}
@media(hover:hover) and (pointer:fine){.dark .dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled):hover{background:#c0f1d0;border-color:#c0f1d0}}
.dlgate-body>.ds-status{margin:0}
@media(max-width:600px){
 .ds-toolbar{padding:14px 16px}
 .ds-gate-page .dlgate-body{padding:20px 16px}
 .dlgate-body [data-ds-form]{flex-direction:column;align-items:stretch;gap:20px}
 .ds-verification{flex:none}
 .dlgate-actions,.dlgate-actions .dlgate-btn-primary{width:100%}
 .dlgate-actions .dlgate-btn-primary{min-width:0}
}

/* 1.0.9: larger, centered action on a separate row. */
.dlgate-body [data-ds-form]{flex-direction:column;align-items:stretch;gap:24px}
.ds-verification{flex:none;width:100%}
.dlgate-actions{width:100%;justify-content:center}
.dlgate-actions .dlgate-btn-primary{flex:none;width:320px;max-width:100%;min-width:0;min-height:56px;padding:16px 36px;border-radius:12px;font-size:16px;line-height:22px;font-weight:600}
.dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled){background:#4f46e5;border-color:#4f46e5;color:#fff!important}
@media(hover:hover) and (pointer:fine){.dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled):hover{background:#4338ca;border-color:#4338ca}}
.dark .dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled){background:#818cf8;border-color:#818cf8;color:#111b3a!important}
@media(hover:hover) and (pointer:fine){.dark .dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled):hover{background:#a5b4fc;border-color:#a5b4fc}}
.dlgate-actions .dlgate-btn-primary:focus-visible{outline:3px solid #818cf8;outline-offset:3px}

/* 1.0.10: inherit the live Zeina accent, including changes while open. */
.dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled),
.dark .dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled){background:rgb(var(--dlg-primary));border-color:rgb(var(--dlg-primary));color:var(--ds-accent-ink,#fff)!important}
@media(hover:hover) and (pointer:fine){
 .dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled):hover,
 .dark .dlgate-actions .dlgate-btn-primary:not([data-countdown="true"]):not(:disabled):hover{background:rgba(var(--dlg-primary),.88);border-color:rgb(var(--dlg-primary))}
}
.dlgate-actions .dlgate-btn-primary:focus-visible{outline-color:rgb(var(--dlg-primary))}
.dlgate-actions .dlgate-btn-primary>svg{display:block;width:20px;height:20px;flex:none;pointer-events:none}
/* Paint a usable shell synchronously; no loading copy or animated shimmer. */
.ds-popup-shell{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);box-sizing:border-box;width:calc(100% - 24px);max-width:1042px;max-height:calc(100% - 24px);overflow:hidden;padding:24px 20px;background:#fff;border:1px solid #e5e7eb;border-radius:12px}
.dark .ds-popup-shell{background:#0f172a;border-color:#334155}
.ds-popup-close{position:absolute;top:14px;right:16px;display:grid;place-items:center;width:36px;height:36px;padding:0;border:1px solid #cbd5e1;border-radius:9px;background:#f8fafc;color:#334155;cursor:pointer}
.dark .ds-popup-close{background:#1e293b;border-color:#475569;color:#e2e8f0}
.ds-popup-close svg{display:block;width:18px;height:18px}
.ds-popup-close:focus-visible{outline:3px solid rgba(var(--color-primary,79,70,229),.6);outline-offset:2px}
.ds-placeholder{background:#eef2f6;border-radius:7px;pointer-events:none}
.dark .ds-placeholder{background:#1e293b}
.ds-placeholder-heading{width:120px;height:20px;margin-bottom:24px}
.ds-placeholder-banner{width:100%;aspect-ratio:1024/96;margin-bottom:24px}
.ds-placeholder-verification{width:300px;max-width:100%;height:65px;margin-bottom:24px}
.ds-placeholder-action{width:320px;max-width:100%;height:56px;margin-inline:auto;border-radius:12px}
