/* ==========================================================================
   InstaSaver — single stylesheet, no framework.
   Mobile-first. Koi external font request nahi (Core Web Vitals ke liye).
   ========================================================================== */

:root {
  --bg:        #0d0d12;
  --bg-soft:   #15151d;
  --bg-card:   #1b1b25;
  --line:      #2a2a37;
  --text:      #eceaf3;
  --muted:     #a09eb4;
  /* Jaan-boojh kar Instagram ke purple-pink-orange se alag rakha hai —
     site affiliated nahi hai, aur dikhni bhi nahi chahiye. */
  --brand:     #0891b2;   /* cyan   */
  --brand-2:   #14b8a6;   /* teal   */
  --brand-3:   #4f46e5;   /* indigo */
  --link:      #22d3ee;   /* dark bg par readable link colour */
  --ok:        #38c172;
  --err:       #ff6b6b;
  --radius:    14px;
  --wrap:      1120px;
  --grad: linear-gradient(135deg, var(--brand-3), var(--brand) 55%, var(--brand-2));
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:      #ffffff;
    --bg-soft: #f5f8fa;
    --bg-card: #ffffff;
    --line:    #e2e8ee;
    --text:    #16151c;
    --muted:   #566072;
    --link:    #0e7490;   /* white par WCAG AA contrast ke liye gehra */
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* ---------- Header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.head-inner { display: flex; align-items: center; gap: 16px; min-height: 62px; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; background: var(--grad);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent);
}
.brand-name { font-size: 1.05rem; letter-spacing: -0.02em; }

.site-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.site-nav a {
  text-decoration: none; color: var(--muted); font-size: .93rem; font-weight: 500;
  padding: 7px 12px; border-radius: 9px;
}
.site-nav a:hover { color: var(--text); background: var(--bg-soft); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--bg-soft); }

.nav-burger { display: none; margin-left: auto; cursor: pointer; padding: 8px; }
.nav-burger span { display: block; width: 22px; height: 2px; background: var(--text); margin: 4px 0; border-radius: 2px; }

@media (max-width: 760px) {
  .nav-burger { display: block; }
  .site-nav {
    display: none; width: 100%; order: 3; flex-direction: column; gap: 0;
    padding-bottom: 10px;
  }
  .nav-toggle:checked ~ .site-nav { display: flex; }
  .site-nav a { padding: 11px 12px; }
}

/* ---------- Breadcrumbs ---------- */
.crumbs {
  padding-top: 14px; font-size: .84rem; color: var(--muted);
  display: flex; gap: 7px; flex-wrap: wrap; align-items: center;
}
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .current { color: var(--text); }

/* ---------- Hero + form ---------- */
.hero { padding: 40px 0 12px; text-align: center; }
.hero h1 {
  font-size: clamp(1.9rem, 5.2vw, 3rem); line-height: 1.14; margin: 0 0 12px;
  letter-spacing: -0.03em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--brand);
}
.lede { font-size: clamp(1rem, 2.4vw, 1.15rem); color: var(--muted); max-width: 640px; margin: 0 auto 26px; }

.notice {
  max-width: 720px; margin: 0 auto 22px; padding: 13px 16px; text-align: left;
  border: 1px solid color-mix(in srgb, var(--brand-2) 45%, var(--line));
  background: color-mix(in srgb, var(--brand-2) 9%, transparent);
  border-radius: 11px; font-size: .9rem; color: var(--text);
}

.dl-form { max-width: 720px; margin: 0 auto; }
.dl-row {
  display: flex; gap: 8px; padding: 8px; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--line);
  box-shadow: 0 10px 34px -18px rgba(0,0,0,.55);
}
.dl-row:focus-within { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); }

.dl-row input[type="url"] {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 1rem; padding: 12px 12px; font-family: inherit;
}
.dl-row input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }

.btn-primary {
  border: 0; cursor: pointer; font-family: inherit; font-size: .96rem; font-weight: 650;
  color: #fff; background: var(--grad); padding: 12px 22px; border-radius: 10px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  white-space: nowrap; transition: transform .12s ease, filter .12s ease;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: .6; cursor: progress; }
.btn-sm { padding: 9px 16px; font-size: .87rem; }

.btn-paste, .btn-ghost {
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted);
  border-radius: 10px; padding: 12px 15px; font-family: inherit; font-size: .9rem;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center;
}
.btn-paste:hover, .btn-ghost:hover { color: var(--text); }

.form-hint { font-size: .82rem; color: var(--muted); margin: 12px 0 0; }

.dl-status { min-height: 26px; font-size: .9rem; color: var(--muted); margin-top: 14px; }
.dl-status.busy::before {
  content: ""; display: inline-block; width: 13px; height: 13px; margin-right: 8px;
  border: 2px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  max-width: 720px; margin: 16px auto 0; padding: 13px 16px; border-radius: 11px;
  font-size: .92rem; text-align: left;
}
.alert-error {
  border: 1px solid color-mix(in srgb, var(--err) 45%, var(--line));
  background: color-mix(in srgb, var(--err) 10%, transparent);
}

/* ---------- Result ---------- */
.result {
  max-width: 900px; margin: 26px auto 0; text-align: left;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  animation: result-in .28s ease both;
}
@keyframes result-in { from { opacity: 0; transform: translateY(8px); } }

.result-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--bg-soft); }
.result-id { min-width: 0; }
.result-user { margin: 0; font-weight: 650; }
.result-meta { margin: 0; font-size: .84rem; color: var(--muted); }
.result-tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Caption ---------- */
.result-caption { margin: 14px 0 0; }
.caption-text {
  margin: 0; font-size: .9rem; color: var(--muted); white-space: pre-wrap;
  border-left: 3px solid var(--line); padding-left: 12px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.result-caption.is-open .caption-text { -webkit-line-clamp: unset; display: block; }
.caption-tools { display: flex; gap: 14px; padding-left: 15px; margin-top: 6px; }
.link-btn {
  border: 0; background: none; padding: 0; cursor: pointer; font-family: inherit;
  font-size: .8rem; font-weight: 600; color: var(--link); text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { text-decoration-thickness: 2px; }

/* ---------- Media grid ---------- */
.media-grid {
  display: grid; gap: 14px; margin-top: 18px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.media-item {
  margin: 0; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
  transition: border-color .15s ease, transform .15s ease;
}
.media-item:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }

.media-thumb {
  position: relative; aspect-ratio: 4 / 5; background: var(--bg); overflow: hidden;
}
/* Skeleton — image aane tak isi par nazar padti hai */
.media-thumb::after {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(100deg,
    var(--bg-soft) 30%, color-mix(in srgb, var(--line) 70%, var(--bg-soft)) 50%, var(--bg-soft) 70%);
  background-size: 220% 100%; animation: shimmer 1.4s linear infinite;
}
.media-thumb.is-ready::after, .media-thumb.is-failed::after, .media-thumb.is-playing::after { display: none; }
@keyframes shimmer { to { background-position: -120% 0; } }

/* Poori tasveer dikhe — crop na ho. Peeche usi image ka blur bharaav rehta hai,
   isliye har tile ek hi shape ki rehti hai aur grid saaf lagta hai. */
.media-bg {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%; object-fit: cover;
  filter: blur(22px) saturate(1.5) brightness(.55); transform: scale(1.15);
}
.media-img {
  position: absolute; inset: 0; z-index: 2;
  width: 100%; height: 100%; object-fit: contain;
}
.media-thumb.is-failed .media-bg, .media-thumb.is-failed .media-img { display: none; }
.media-thumb.is-failed::before {
  content: "Preview unavailable"; position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center; padding: 12px; text-align: center;
  font-size: .8rem; color: var(--muted); background: var(--bg-soft);
}

/* Poori tile hi click target hai */
.media-open {
  position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%;
  border: 0; padding: 0; cursor: pointer; background: transparent;
  display: grid; place-items: center;
  transition: background .15s ease;
}
.media-open:hover, .media-open:focus-visible { background: rgba(0,0,0,.3); }
.media-open-icon {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(12,12,18,.62); color: #fff; backdrop-filter: blur(4px);
  display: grid; place-items: center; font-size: 1rem; line-height: 1;
  box-shadow: 0 2px 14px rgba(0,0,0,.4);
  transition: transform .15s ease, background .15s ease;
}
.media-open:hover .media-open-icon, .media-open:focus-visible .media-open-icon {
  transform: scale(1.1); background: var(--brand);
}
/* Photo ka zoom icon halka rahe, video ka play hamesha saaf dikhe */
.media-open[data-open="image"] .media-open-icon { opacity: 0; }
.media-open[data-open="image"]:hover .media-open-icon,
.media-open[data-open="image"]:focus-visible .media-open-icon { opacity: 1; }

.media-tag {
  position: absolute; inset: 8px auto auto 8px; z-index: 3;
  background: rgba(12,12,18,.65); color: #fff; font-size: .7rem; font-weight: 600;
  padding: 3px 8px; border-radius: 20px; letter-spacing: .02em;
}

.media-video {
  position: absolute; inset: 0; z-index: 4;
  width: 100%; height: 100%; background: #000; object-fit: contain;
}
.media-thumb.is-playing .media-open,
.media-thumb.is-playing .media-tag { display: none; }

.media-item figcaption {
  padding: 11px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.media-kind { font-size: .78rem; color: var(--muted); }
.media-size { font-variant-numeric: tabular-nums; }

.result-note, .result-legal { font-size: .8rem; color: var(--muted); margin: 14px 0 0; }
.result-legal { border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------- Loading skeleton (fetch ke dauraan) ---------- */
.result-skeleton { pointer-events: none; }
.sk {
  display: block; border-radius: 8px;
  background: linear-gradient(100deg,
    var(--bg-soft) 30%, color-mix(in srgb, var(--line) 70%, var(--bg-soft)) 50%, var(--bg-soft) 70%);
  background-size: 220% 100%; animation: shimmer 1.4s linear infinite;
}
.sk-avatar { width: 48px; height: 48px; border-radius: 50%; }
.sk-line { height: 13px; margin-bottom: 8px; }
.sk-line.sk-sm { height: 10px; }
.sk-tile { aspect-ratio: 4 / 5; border-radius: 12px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(6,6,10,.92); padding: 16px;
  animation: fade-in .18s ease both;
}
@keyframes fade-in { from { opacity: 0; } }
.no-scroll { overflow: hidden; }

.lb-stage {
  margin: 0; max-width: min(100%, 1100px); max-height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.lb-img {
  max-width: 100%; max-height: calc(100vh - 110px);
  width: auto; border-radius: 10px; object-fit: contain;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.8);
}
.lb-meta { font-size: .82rem; color: #cfcddb; font-variant-numeric: tabular-nums; }

/* Full-size image aane tak thumbnail hi dikhti hai — thoda soft, aur ek patli
   progress line, taaki pata chale ki behtar version aa raha hai. */
.lightbox.is-loading .lb-img { filter: blur(6px); transform: scale(.995); }
.lb-img { transition: filter .25s ease; }
.lightbox.is-loading .lb-meta::after {
  content: "loading full size…"; margin-left: 8px; opacity: .8;
}

.lb-btn {
  flex: none; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08);
  color: #fff; width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  font-size: 1.5rem; line-height: 1; display: grid; place-items: center;
  font-family: inherit; transition: background .15s ease;
}
.lb-btn:hover { background: rgba(255,255,255,.2); }
.lb-close { position: absolute; top: 14px; right: 14px; font-size: 1.4rem; }

@media (max-width: 620px) {
  .lb-prev, .lb-next { position: absolute; bottom: 18px; }
  .lb-prev { left: 22%; }
  .lb-next { right: 22%; }
  .lb-img { max-height: calc(100vh - 160px); }
}

/* ---------- Download progress toast ---------- */
.dl-toast {
  position: fixed; z-index: 210; left: 50%; bottom: 18px; transform: translateX(-50%);
  width: min(420px, calc(100vw - 32px));
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 44px -18px rgba(0,0,0,.7); overflow: hidden;
  animation: toast-in .22s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px); } }
.dl-toast-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px 10px;
}
.dl-toast-text { flex: 1; font-size: .85rem; font-variant-numeric: tabular-nums; }
.dl-toast-x {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 1.2rem; line-height: 1; padding: 0 2px; font-family: inherit;
}
.dl-toast-x:hover { color: var(--text); }
.dl-bar { height: 3px; background: var(--bg-soft); overflow: hidden; }
.dl-bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .18s linear; }
.dl-bar.indeterminate i {
  width: 40% !important; animation: bar-slide 1.1s ease-in-out infinite;
}
@keyframes bar-slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ---------- Content sections ---------- */
.band { padding: 44px 0 4px; }
.band > h2, .prose h2 { font-size: clamp(1.3rem, 3.2vw, 1.7rem); letter-spacing: -0.02em; margin: 0 0 18px; }

.prose { padding: 40px 0 4px; max-width: 780px; }
.prose-page { padding-top: 26px; }
.prose h1 { font-size: clamp(1.7rem, 4.4vw, 2.4rem); letter-spacing: -0.03em; margin: 0 0 18px; line-height: 1.2; }
.prose h2 { margin-top: 34px; }
.prose p, .prose li { color: var(--muted); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 8px; }
.prose a { color: var(--link); }

.article-meta { font-size: .84rem; color: var(--muted); margin-top: -8px; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px;
         grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.steps li {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 18px;
}
.step-n {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--grad); color: #fff; font-weight: 700; font-size: .85rem; margin-bottom: 10px;
}
.steps h3 { margin: 0 0 6px; font-size: 1rem; }
.steps p { margin: 0; font-size: .88rem; color: var(--muted); }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 18px;
  text-decoration: none;
}
.cards-link .card { transition: border-color .15s ease, transform .15s ease; }
.cards-link .card:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); transform: translateY(-2px); }
.card h2, .card h3 { margin: 0 0 7px; font-size: 1.02rem; }
.card p { margin: 0; font-size: .88rem; color: var(--muted); }
.card-meta { display: block; margin-top: 10px; font-size: .78rem; color: var(--muted); }

.faq { display: grid; gap: 10px; }
.faq details {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px;
}
.faq summary {
  cursor: pointer; padding: 13px 0; font-weight: 600; font-size: .96rem; list-style: none;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 1.25rem; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 0 14px; color: var(--muted); font-size: .91rem; }

.cta-box {
  margin-top: 40px; padding: 24px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  background: color-mix(in srgb, var(--brand) 7%, transparent);
}
.cta-box h2 { margin-top: 0; }
.cta-box p { margin-bottom: 16px; }

.back-home { margin-top: 34px; }

/* ---------- Footer ---------- */
.site-foot { margin-top: 64px; border-top: 1px solid var(--line); background: var(--bg-soft); padding-top: 40px; }
.foot-grid { display: grid; gap: 30px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.foot-about { grid-column: span 1; }
.foot-col h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 12px; }
.foot-col ul { list-style: none; padding: 0; margin: 0; }
.foot-col li { margin-bottom: 8px; }
.foot-col a { color: var(--muted); text-decoration: none; font-size: .9rem; }
.foot-col a:hover { color: var(--text); }
.foot-about p { font-size: .88rem; color: var(--muted); margin: 10px 0 0; }
.disclaimer { font-size: .8rem !important; opacity: .8; }
.foot-base { border-top: 1px solid var(--line); margin-top: 32px; padding-block: 18px; }
.foot-base p { margin: 0; font-size: .82rem; color: var(--muted); }

@media (min-width: 900px) { .foot-about { grid-column: span 2; padding-right: 30px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}
