/**
 * Insta Video Download — premium mobile (Snapgram hero, tabs, downloader, footer)
 */
@media (max-width: 768px) {
  :root {
    --header-h: calc(56px + env(safe-area-inset-top, 0px));
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    overflow-x: hidden;
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  body.ivd-has-sticky-ad {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
  }

  .ts-header {
    padding: env(safe-area-inset-top, 0) max(0.75rem, env(safe-area-inset-left, 0)) 0
      max(0.75rem, env(safe-area-inset-right, 0));
    min-height: var(--header-h);
    height: auto;
    gap: 0.5rem;
  }

  .ts-brand {
    font-size: 1rem;
    min-width: 0;
    flex: 1;
  }

  .ts-brand span,
  .ts-brand:not(:has(img)) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ts-logo-img {
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0;
  }

  .ts-menu-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .ts-nav {
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ts-nav a,
  .sg-nav-tools-btn {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.65rem 0.5rem;
  }

  /* —— Snapgram hero —— */
  .sg-hero {
    padding: 0.85rem max(0.65rem, env(safe-area-inset-left, 0)) 1.75rem
      max(0.65rem, env(safe-area-inset-right, 0));
    background: linear-gradient(165deg, #b8a9e8 0%, #fbc2eb 38%, #f5a8d0 100%);
  }

  .sg-tools-bar {
    margin-bottom: 1rem;
    position: relative;
  }

  .sg-tools-bar::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 28px;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45));
    border-radius: 0 18px 18px 0;
  }

  .sg-tools-inner {
    border-radius: 16px;
    padding: 0.45rem 0.5rem;
    gap: 0.35rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-padding-inline: 12px;
  }

  .sg-tool-tab {
    scroll-snap-align: center;
    min-height: 44px;
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
    -webkit-tap-highlight-color: transparent;
  }

  .sg-tool-tab.active {
    box-shadow: 0 4px 14px rgba(131, 58, 180, 0.22);
  }

  .sg-tab-icon-img,
  .sg-tab-icon {
    width: 20px !important;
    height: 20px !important;
    font-size: 1rem;
  }

  .sg-hero-copy {
    margin-bottom: 1rem;
    padding: 0 0.15rem;
  }

  .sg-hero-title {
    font-size: clamp(1.35rem, 6.5vw, 1.75rem);
    line-height: 1.2;
    margin-bottom: 0.5rem;
  }

  .sg-hero-lead {
    font-size: 0.92rem;
    line-height: 1.5;
    padding: 0 0.25rem;
  }

  .sg-hero-perk {
    font-size: 0.85rem;
  }

  .sg-downloader-mount {
    padding: 0 0.15rem;
  }

  .sg-hero .karoo-card {
    border-radius: 18px;
    box-shadow: 0 12px 36px rgba(131, 58, 180, 0.16);
  }

  .sg-hero .karoo-card-inner {
    padding: 1rem 0.9rem 1.1rem;
  }

  .sg-hero .karoo-card-lead {
    font-size: 0.86rem;
    margin-bottom: 0.85rem;
  }

  .sg-hero .karoo-input-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.55rem;
    border-radius: 14px;
  }

  .sg-hero .karoo-input-icon {
    display: none;
  }

  .sg-hero .karoo-url {
    width: 100%;
    font-size: 16px !important;
    min-height: 48px;
    padding: 0.35rem 0.25rem;
  }

  .sg-hero .karoo-btn-paste {
    width: 100%;
    min-height: 48px;
    font-size: 0.95rem;
    border-radius: 12px;
  }

  .sg-hero .karoo-btn-dl {
    min-height: 52px;
    font-size: 1rem;
    border-radius: 14px;
  }

  .sg-hero .karoo-fmt-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  .sg-hero .karoo-fmt {
    min-height: 44px;
    font-size: 0.78rem;
  }

  .sg-how {
    margin-top: 0.85rem;
  }

  .sg-how a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    padding: 0.35rem 0.75rem;
  }

  .sg-below {
    padding: 1.15rem 0.65rem 1.5rem;
  }

  /* Tools grid (home) */
  .ts-tools-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0 0.75rem 2.5rem;
    margin-top: 1.25rem;
  }

  .ts-tool-card,
  .sg-tool-card {
    padding: 1.1rem 1rem;
    border-radius: 16px;
    -webkit-tap-highlight-color: transparent;
  }

  .ts-tool-card:active,
  .sg-tool-card:active {
    transform: scale(0.98);
  }

  .ts-steps {
    padding: 0 0.75rem 1.5rem;
  }

  .ts-step {
    padding: 0.85rem;
  }

  /* Footer */
  .ivd-site-footer {
    padding: 2rem 0.85rem calc(1.25rem + env(safe-area-inset-bottom, 0));
    margin-top: 1.25rem;
  }

  .ivd-footer-logo {
    font-size: 1.05rem;
  }

  .ivd-footer-col a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .ivd-footer-link {
    padding: 0.35rem 0 !important;
  }

  /* DP viewer */
  .ivd-dp-viewer {
    max-width: 100%;
    margin: 0 0.15rem;
    padding: 1rem 0.75rem 1.25rem;
  }

  .ivd-dp-avatar-sm {
    width: 96px;
    height: 96px;
  }

  .ivd-dp-lightbox-close {
    top: max(12px, env(safe-area-inset-top, 12px));
    right: max(12px, env(safe-area-inset-right, 12px));
    width: 44px;
    height: 44px;
  }

  .ivd-dp-lightbox-img {
    max-width: min(92vw, 420px);
    max-height: 70dvh;
  }

  /* Preview / status */
  .ts-preview-wrap,
  .karoo-preview {
    margin: 0 0.15rem;
  }

  .karoo-preview-media img {
    max-height: min(50dvh, 280px);
  }

  /* Ads: no side rails, compact slots */
  .ivd-ad-slot {
    margin: 0.65rem auto;
    padding: 0 0.35rem;
  }

  .ivd-ad-sticky-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

@media (max-width: 380px) {
  .sg-tool-tab {
    padding: 0.45rem 0.65rem;
    font-size: 0.76rem;
  }

  .sg-tool-label {
    max-width: 4.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Touch devices: reduce hover-only effects */
@media (hover: none) and (pointer: coarse) {
  .ts-tool-card:hover,
  .sg-tool-card:hover,
  .ivd-cross-card:hover {
    transform: none;
  }

  .karoo-btn-dl:not(:disabled):active {
    transform: scale(0.98);
  }
}
