/* ==========================================================================
   Insta Downloader - Light clean theme
   ========================================================================== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fafbff;
  --border: #e6e8f0;
  --text: #1c2230;
  --muted: #5b6478;
  --primary: #d62976;
  --primary-dark: #962fbf;
  --blue: #4f5bd5;
  --grad: linear-gradient(120deg, #4f5bd5 0%, #d62976 60%, #f77737 100%);
  --grad-brand: linear-gradient(120deg, #d62976 0%, #962fbf 100%);
  --shadow-sm: 0 1px 3px rgba(28, 34, 48, .06);
  --shadow-md: 0 10px 30px rgba(28, 34, 48, .08);
  --shadow-lg: 0 24px 60px rgba(28, 34, 48, .12);
  --radius: 16px;
  --radius-sm: 10px;
  --ok: #16a34a;
  --err: #dc2626;
  --maxw: 1080px;
  --nav-h: 66px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.section { padding: 56px 0; }
.section-alt { background: var(--surface); border-block: 1px solid var(--border); }

/* ---------- Typography ---------- */
h1, h2, h3 { line-height: 1.25; letter-spacing: -.02em; color: var(--text); }
h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 800; }
h3 { font-size: 1.12rem; font-weight: 700; }
p { margin-bottom: 14px; }
.lead { font-size: clamp(1rem, 2vw, 1.15rem); color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--nav-h); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { width: 30px; height: 30px; }
.brand .grad { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.site-nav { display: flex; gap: 26px; }
.site-nav a { color: var(--text); font-weight: 600; font-size: .95rem; }
.site-nav a:hover { color: var(--primary); text-decoration: none; }
.nav-toggle {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; cursor: pointer; color: var(--text);
}

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(900px 420px at 12% -20%, rgba(79, 91, 213, .14), transparent 60%),
    radial-gradient(900px 420px at 88% -20%, rgba(214, 41, 118, .12), transparent 60%);
  padding: 60px 0 48px;
}
.hero h1 { margin-bottom: 14px; }
.hero .lead { max-width: 640px; margin-inline: auto; margin-bottom: 26px; }

/* ---------- Tool card ---------- */
.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-md);
}
.tool-card label { display: block; font-weight: 600; margin-bottom: 8px; font-size: .9rem; }
.tool-row { display: flex; gap: 10px; }
.tool-input {
  flex: 1; padding: 14px 16px; font-size: 1rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border .2s, box-shadow .2s;
}
.tool-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(214, 41, 118, .12); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 22px; font-size: 1rem; font-weight: 700; color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
  background: var(--grad-brand);
  transition: opacity .2s, transform .1s, box-shadow .2s;
  box-shadow: 0 6px 18px rgba(214, 41, 118, .28);
}
.btn:hover { opacity: .92; box-shadow: 0 8px 24px rgba(214, 41, 118, .36); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-outline {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: none;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); opacity: 1; }

#loading { margin-top: 20px; text-align: center; color: var(--muted); }
.spinner {
  width: 42px; height: 42px; margin: 0 auto 12px;
  border: 4px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading .hint { font-size: .84rem; margin-top: 8px; }

#result { margin-top: 24px; }
.preview { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-start; }
.thumb {
  width: 320px; max-width: 100%;
  aspect-ratio: 4/5; object-fit: cover;
  border-radius: 0;
  border: 1px solid var(--border); background: var(--surface-2); box-shadow: var(--shadow-sm);
}
.meta { flex: 1; min-width: 240px; }
.meta h2 { font-size: 1.15rem; margin-bottom: 10px; word-wrap: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  font-size: .78rem; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}

#msg { margin-top: 18px; padding: 13px 16px; border-radius: var(--radius-sm); font-size: .92rem; }
#msg.error { background: rgba(220, 38, 38, .08); border: 1px solid var(--err); color: var(--err); }
#msg.info { background: rgba(22, 163, 74, .08); border: 1px solid var(--ok); color: var(--ok); }

/* ---------- Steps ---------- */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; margin-top: 30px; }
.step {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm);
}
.step-num {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  font-weight: 800; color: #fff; background: var(--grad-brand); margin-bottom: 14px;
}
.step h3 { margin-bottom: 6px; }

/* ---------- Feature grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm);
}
.card .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px; background: var(--surface-2); }
.card .icon svg { width: 24px; height: 24px; stroke: var(--primary); }
.card h3 { margin-bottom: 6px; }
.card p { color: var(--muted); font-size: .95rem; margin: 0; }

/* ---------- Testimonials ---------- */
.testimonial { display: flex; flex-direction: column; gap: 10px; }
.stars { color: #f5b301; font-size: 1.05rem; letter-spacing: 2px; }
.testimonial .quote { color: var(--text); font-size: .98rem; font-style: italic; flex: 1; }
.testimonial .tname { color: var(--muted); font-size: .88rem; font-weight: 600; }

/* ---------- Ad slots ---------- */
.ad-slot { margin: 18px auto; max-width: var(--maxw); text-align: center; overflow: hidden; }

/* ---------- FAQ ---------- */
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; overflow: hidden; }
.faq-q {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 18px 20px; font-size: 1rem; font-weight: 700; color: var(--text);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq-q::after { content: "+"; font-size: 1.4rem; font-weight: 600; color: var(--primary); transition: transform .2s; }
.faq-item.open .faq-q::after { transform: rotate(45deg); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.faq-a-inner { padding: 0 20px 18px; color: var(--muted); }
.faq-a p:last-child { margin-bottom: 0; }

/* ---------- Page content (legal / about) ---------- */
.page-hero { padding: 48px 0 24px; }
.page-hero h1 { margin-bottom: 8px; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 18px; }
.prose { max-width: 780px; }
.prose h2 { margin: 32px 0 12px; font-size: 1.35rem; }
.prose h3 { margin: 22px 0 8px; font-size: 1.05rem; }
.prose h2, .prose h3 { scroll-margin-top: 92px; }
.prose p, .prose li { color: #3c4353; }
.prose ul, .prose ol { margin: 0 0 16px 22px; }
.prose li { margin-bottom: 8px; }
.prose code { background: var(--surface-2); border: 1px solid var(--border); padding: 2px 6px; border-radius: 6px; font-size: .88em; }

/* ---------- Rich editor output (blog / page content) ---------- */
.prose table { border-collapse: collapse; width: 100%; margin: 18px 0; }
.prose td, .prose th { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.prose th { background: var(--surface-2); font-weight: 700; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.prose img.align-left { float: left; margin: 0 16px 8px 0; }
.prose img.align-right { float: right; margin: 0 0 8px 16px; }
.prose img.align-center { display: block; margin: 0 auto; }
.prose figure.img-caption { max-width: 100%; margin: 18px auto; text-align: center; }
.prose figure.img-caption img { display: block; margin: 0 auto; }
.prose figure.img-caption figcaption { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.prose blockquote { border-left: 4px solid var(--primary); background: var(--surface-2); padding: 10px 16px; margin: 18px 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--muted); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { border: none; border-top: 2px solid var(--border); margin: 26px 0; }
.prose pre.code-block { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; line-height: 1.55; margin: 18px 0; }
.prose pre.code-block code { background: none; border: none; padding: 0; color: inherit; }
.prose pre:not(.code-block) { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; line-height: 1.55; margin: 18px 0; }
.prose .alert-box { background: #fff7ed; border: 1px solid #fcd9b6; border-left: 4px solid #f59e0b; border-radius: var(--radius-sm); padding: 12px 16px; margin: 18px 0; }
.prose .alert-box p:last-child { margin-bottom: 0; }
.prose .video-wrap { position: relative; padding-top: 56.25%; margin: 18px 0; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.prose .video-wrap iframe, .prose .video-wrap video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.prose .toc { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 14px 18px; margin: 18px 0; background: var(--surface-2); }
.prose .toc ul { margin: 8px 0 0 1.2em; list-style: none; }
.prose .toc ul ul { margin-left: 1.2em; }
.prose .toc a { text-decoration: none; }
.prose .toc li { margin-bottom: 5px; }
.prose .btn { margin: 4px 0; }

/* ---------- Contact form ---------- */
.form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-md); max-width: 640px; }
.form label { display: block; font-weight: 600; margin: 16px 0 6px; font-size: .9rem; }
.form input, .form textarea {
  width: 100%; padding: 13px 14px; font-size: 1rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; font-family: inherit;
}
.form input:focus, .form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(214, 41, 118, .12); }
.form textarea { resize: vertical; min-height: 140px; }
.form .btn { margin-top: 20px; }
.form-status { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 8px; font-size: .92rem; }
.form-status.success { background: rgba(22, 163, 74, .08); border: 1px solid var(--ok); color: var(--ok); }
.form-status.error { background: rgba(220, 38, 38, .08); border: 1px solid var(--err); color: var(--err); }
.hp-field { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* ---------- Footer ---------- */
.site-footer { background: #161a24; color: #aab0c0; padding: 48px 0 26px; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; margin-bottom: 30px; }
.site-footer h4 { color: #fff; font-size: .95rem; margin-bottom: 14px; }
.site-footer ul { list-style: none; }
.site-footer li { margin-bottom: 8px; }
.site-footer a { color: #aab0c0; font-size: .92rem; }
.site-footer a:hover { color: #fff; text-decoration: none; }
.footer-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: #fff; font-size: 1.05rem; margin-bottom: 12px; }
.footer-brand svg { width: 26px; height: 26px; }
.footer-brand .grad { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.copyright { border-top: 1px solid #262c3a; padding-top: 20px; text-align: center; font-size: .82rem; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 90px 20px; }
.notfound .code { font-size: clamp(4rem, 12vw, 7rem); font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.notfound h1 { margin: 6px 0 10px; }

/* ---------- Utilities ---------- */
.center { text-align: center; }
.mt-1 { margin-top: 12px; } .mt-2 { margin-top: 24px; } .mt-3 { margin-top: 40px; }
.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .site-nav {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    background: #fff; border-bottom: 1px solid var(--border);
    flex-direction: column; gap: 0; padding: 8px 20px 16px;
    box-shadow: var(--shadow-md); display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 4px; border-bottom: 1px solid var(--border); }
  .site-nav a:last-child { border-bottom: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .tool-row { flex-direction: column; }
  .section { padding: 44px 0; }
  .hero { padding: 44px 0 36px; }
  .tool-card { padding: 20px; }
  .preview { justify-content: center; text-align: center; }
  .meta { min-width: 100%; }
  .chips { justify-content: center; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
}
/* ---------- Tool landing pages ---------- */
.tool-item{display:flex;align-items:center;justify-content:space-between;gap:12px;border:1px solid var(--border);border-radius:12px;padding:10px 12px;background:var(--surface-2,#fafbff)}
.tool-item-info{min-width:0;flex:1}
.tool-item-name{font-size:.9rem;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-bottom:4px}
.tool-item .btn{flex-shrink:0}
#toolZipWrap button{width:100%}

/* ---------- Media preview gallery (tool pages) ---------- */
#toolGallery{margin-top:14px}
.gallery-head{font-size:.85rem;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;margin-bottom:8px}
.tool-gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:10px}
.gallery-cell{position:relative;display:block;aspect-ratio:1;border-radius:12px;overflow:hidden;border:1px solid var(--border);background:var(--surface-2,#fafbff)}
.gallery-cell img{width:100%;height:100%;object-fit:cover;display:block;opacity:0;transition:opacity .3s ease,transform .25s ease}
.gallery-cell img.loaded{opacity:1}
.gallery-cell:hover img{transform:scale(1.06)}
.gallery-cell:hover{border-color:var(--primary)}
.gallery-tag{position:absolute;right:6px;bottom:6px;background:rgba(20,24,40,.72);color:#fff;font-size:.7rem;font-weight:700;padding:2px 7px;border-radius:999px;line-height:1.4}
.gallery-cell.broken::after{content:"—";position:absolute;inset:0;display:grid;place-items:center;color:var(--muted)}
@media(max-width:480px){.tool-gallery{grid-template-columns:repeat(3,1fr)}}

/* ---------- uploader line + thumb fade ---------- */
.tool-uploader{margin:10px 0 4px;font-size:.95rem;color:var(--muted)}
.tool-uploader .chip{font-weight:700;color:var(--primary)}
.thumb{opacity:0;transition:opacity .35s ease}
.thumb.loaded{opacity:1}
.tool-uploader{margin:6px 0 10px;font-size:.95rem;color:var(--muted)}
.tool-uploader .chip{background:rgba(214,41,118,.1);color:var(--primary);font-weight:700}
