/* InstaDown — mobile-first styles with light/dark themes via [data-theme] */

:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #d6249f;
  --primary-2: #fd5949;
  --primary-grad: linear-gradient(45deg, #f58529, #dd2a7b, #8134af, #515bd4);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --skeleton: #e2e8f0;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --skeleton: #334155;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  transition: background 0.2s ease, color 0.2s ease;
}

.shell { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; }
.logo-mark {
  width: 28px; height: 28px; border-radius: 8px; color: #fff;
  background: var(--primary-grad); padding: 4px;
}
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text);
  font-weight: 600; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* Hero */
.hero { padding: 16px 0 64px; }
.hero-title {
  margin: 12px 0 4px;
  font-size: 30px; font-weight: 800; letter-spacing: -0.02em; text-align: center;
  background: var(--primary-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { margin: 0 0 20px; color: var(--muted); text-align: center; font-size: 15px; }

/* Tabs */
.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px; margin-bottom: 16px;
}
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 10px 4px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.tab.active { background: var(--primary-grad); color: #fff; }

/* Form */
.form { display: grid; gap: 12px; }
.input-row { display: flex; gap: 8px; }
#urlInput {
  flex: 1; min-width: 0; padding: 14px 16px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--card); color: var(--text); outline: none;
}
#urlInput:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(214, 36, 159, 0.15); }
#urlInput:disabled { opacity: 0.6; }
.turnstile-row { display: flex; justify-content: center; min-height: 0; }

.btn {
  border: 0; border-radius: 12px; padding: 14px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary-grad); color: #fff; width: 100%; }
.btn-secondary { background: var(--primary); color: #fff; }
.btn-ghost { background: var(--card); color: var(--muted); border: 1px solid var(--border); }

/* Status / skeleton */
.status-line { text-align: center; color: var(--muted); font-size: 14px; margin-top: 16px; }
.skeleton {
  margin-top: 16px; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; box-shadow: var(--shadow);
}
.skl {
  border-radius: 8px; background: var(--skeleton);
  animation: pulse 1.3s ease-in-out infinite;
}
.skl-thumb { height: 200px; margin-bottom: 12px; }
.skl-line { height: 14px; margin-bottom: 8px; }
.skl-line.short { width: 40%; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Result card */
.result {
  margin-top: 20px; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; box-shadow: var(--shadow);
}
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.result-user { font-weight: 700; }
.badge {
  background: rgba(214, 36, 159, 0.12); color: var(--primary);
  border-radius: 999px; font-size: 12px; font-weight: 700; padding: 4px 10px;
  text-transform: capitalize;
}
.result-caption {
  color: var(--muted); font-size: 14px; margin: 8px 0 12px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.media-grid { display: grid; gap: 12px; margin-bottom: 14px; }
.media-item {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--bg);
}
.media-item img, .media-item video {
  display: block; width: 100%; max-height: 320px; object-fit: contain;
  background: #000;
}
.media-item .media-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; gap: 8px;
}
.media-kind { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.dl-link {
  display: inline-block; background: var(--primary); color: #fff;
  text-decoration: none; font-size: 14px; font-weight: 700;
  padding: 8px 14px; border-radius: 8px;
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #b91c1c; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow); z-index: 50;
}
.toast.ok { background: #166534; }

.legal-note { margin-top: 24px; text-align: center; color: var(--muted); font-size: 12px; }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .hero-title { font-size: 24px; }
  .btn { padding: 13px 14px; font-size: 14px; }
}
