<!DOCTYPE html>
<html lang="{{ lang }}">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>TikTok MP3 Downloader Free & Fast | SSSTikTok</title>
  <meta name="description"
    content="Want Tiktok Mp3 Fast? Tiktok Mp3 Downloader By Ssstiktok Lets You Convert Videos To Mp3 For Free, Easily, And Without A Watermark. Download High Quality Tiktok Audio Instantly!">
  <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;600;700;800&display=swap"
    rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">


  <style>
    :root {
      /* Base Theme (unchanged for rest of page) */
      --indigo: #4f46e5;
      --purple: #7c3aed;
      --purple-2: #a855f7;
      --ink: #0f1220;
      --muted: #6b7280;
      --line: #ececf3;
      --card: #ffffff;
      --max: 1100px;
      --shadow: 0 10px 24px rgba(16, 24, 40, .08);



      .hero-ss {
        --grad: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 40%, #ec4899 100%);
        color: #fff;
        background: var(--grad);
        padding: 18px 18px 60px;
        position: relative;
        /* IMPORTANT: allow dropdown to appear above hero */
        overflow: visible;
        z-index: 0;
      }

      /* SnapTik-style hero colors */
      --snap-start:#0b3c5d;
      /* deep teal/blue */
      --snap-mid:#116a72;
      --snap-end:#1a9a7f;
      --snap-grad: linear-gradient(140deg, var(--snap-start) 0%, var(--snap-mid) 45%, var(--snap-end) 100%);
      --snap-pill:#ffffff;
      --snap-pill-text:#0f1220;
      --snap-chip:#0ea5a5;

      /* FIX: no green — use brand indigo for primary button */
      --snap-download: var(--indigo);
    }



    body {
      font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0
    }

    body {
      font-family: Inter, system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
      background: #f7f7fb;
      color: #1f2430;
      line-height: 1.6
    }

    img {
      max-width: 100%;
      display: block
    }

    a {
      text-decoration: none;
      color: inherit
    }

    /* ===================== SNAP HERO ===================== */
    .hero-ss {
      background: var(--snap-grad);
      color: #fff;
      padding: 18px 18px 64px;
      position: relative;
      overflow: visible;
      z-index: 0;
    }

    .hero-ss__top {
      max-width: var(--max);
      margin: 0 auto;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px
    }

    /* NEW: cluster for menu + logo (keeps logo on the left) */
    .hero-ss__left {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .hero-ss__logo {
      display: flex;
      align-items: center;
      gap: 8px
    }

    /* Keep your pill nav but deemphasize it (hidden on small) */
    .hero-ss__pillnav {
      background: rgba(255, 255, 255, .14);
      color: #fff;
      border-radius: 14px;
      padding: 6px 8px;
      box-shadow: 0 8px 20px rgba(0, 0, 0, .15);
      display: inline-block;

    }

    .pill-track {
      position: relative;
      display: flex;
      gap: 4px;
      align-items: center;
    }

    .pill {
      appearance: none;
      border: 0;
      background: transparent;
      cursor: pointer;
      color: #fff;
      font-weight: 800;
      font-size: 14px;
      padding: 8px 12px;
      border-radius: 10px;
      position: relative;
      z-index: 1;
      text-decoration: none;
      transition: transform .12s ease, color .12s ease;
      opacity: .92;
    }

    .pill:hover {
      transform: translateY(-1px);
    }

    .pill.active {
      color: #fff;
    }

    .pill-thumb {
      position: absolute;
      top: 5px;
      left: 0;
      height: calc(100% - 10px);
      width: 0;
      border-radius: 8px;
      background: rgba(255, 255, 255, .18);
      transition: transform .22s cubic-bezier(.2, .7, .3, 1), width .22s cubic-bezier(.2, .7, .3, 1);
      will-change: transform, width;
    }

    .hero-ss__controls {
      display: flex;
      align-items: center;
      gap: 8px
    }

    .hero-ss__lang,
    .hero-ss__theme {
      background: rgba(255, 255, 255, .15);
      color: #fff;
      border: 1px solid rgba(255, 255, 255, .25);
      backdrop-filter: blur(6px);
      font-weight: 700;
      cursor: pointer;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    .hero-ss__lang {
      padding: 10px 14px;
    }

    .hero-ss__theme {
      width: 42px;
      height: 42px;
      justify-content: center;
      line-height: 0;
    }

    /* ===== NEW: mobile-only menu button ===== */
    .mobile-menu-btn {
      display: none;
      /* hidden on desktop */
      width: 42px;
      height: 42px;
      border-radius: 999px;
      border: 1px solid rgba(255, 255, 255, .35);
      background: rgba(255, 255, 255, .15);
      color: #fff;
      font-weight: 800;
      font-size: 18px;
      cursor: pointer;
      place-items: center;
      line-height: 0;
      backdrop-filter: blur(6px);
    }

    @media (max-width:1024px) {
      .mobile-menu-btn {
        display: grid;
      }

      /* show on mobile + tablet */
    }


    /* ===== NEW: mobile drawer with nav links ===== */
    .mobile-nav {
      position: fixed;
      inset: 0 0 auto 0;
      /* top overlay */
      background: rgba(0, 0, 0, .35);
      -webkit-backdrop-filter: blur(10px);
      backdrop-filter: blur(10px);
      border-bottom: 1px solid rgba(255, 255, 255, .18);
      transform: translateY(-100%);
      opacity: 0;
      pointer-events: none;
      transition: transform .28s cubic-bezier(.2, .7, .3, 1), opacity .2s ease;
      z-index: 60;
      padding: 12px 14px 18px;
    }

    .mobile-nav.open {
      transform: translateY(0);
      opacity: 1;
      pointer-events: auto;
    }

    .mobile-nav__inner {
      max-width: var(--max);
      margin: 0 auto;
      padding-top: 60px;
    }

    .mobile-nav__links {
      list-style: none;
      display: grid;
      gap: 10px;
    }

    .mobile-nav__link a {
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: rgba(255, 255, 255, .16);
      border: 1px solid rgba(255, 255, 255, .22);
      color: #fff;
      font-weight: 800;
      padding: 12px 14px;
      border-radius: 12px;
    }

    .mobile-nav__link a:hover {
      background: #fff;
      color: #0f1220;
    }

    .mobile-nav__close {
      position: absolute;
      right: 14px;
      top: 14px;
      width: 42px;
      height: 42px;
      border-radius: 999px;
      display: grid;
      place-items: center;
      cursor: pointer;
      border: 1px solid rgba(255, 255, 255, .35);
      background: rgba(255, 255, 255, .15);
      color: #fff;
      font-weight: 800;
    }

    @media (min-width:769px) {
      .mobile-nav {
        display: none;
      }
    }

    /* never on desktop */

    /* Center block */
    .hero-center {
      max-width: 980px;
      margin: 66px auto 0;
      text-align: center;
      padding: 0 12px;
    }

    .hero-brand {
      font-size: 56px;
      line-height: 1.05;
      font-weight: 800;
      letter-spacing: .5px
    }

    .hero-sub {
      opacity: .95;
      font-weight: 700;
      font-size: 22px;
      margin-top: 8px
    }

    /* Space below the hero subheading */
    .hero-sub {
      margin-top: 8px;
      margin-bottom: clamp(14px, 2.5vw, 28px);
    }

    /* Mode tab bar: flex container with wrapping and centering */
    .mode-tabs {
      margin-top: clamp(10px, 1.8vw, 24px);
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      gap: 10px;
      max-width: 560px;
      margin-left: auto;
      margin-right: auto;
    }

    /* Form spacing
     * Align URL input and buttons on a single row.  Flex with
     * centre alignment keeps the download button centred
     * vertically relative to the input.  The gap sets consistent
     * spacing between elements.  The mobile media query will
     * override the direction for small screens.
     */
    .snap-form {
      margin-top: clamp(14px, 2vw, 28px);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    /* Featured button styling */
    .mode-btn.featured {
      background: var(--snap-download);
      color: #ffffff;
      font-weight: 700;
    }

    /* Loading overlay */
    .loading-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(255, 255, 255, 0.8);
      z-index: 2000;
    }
    .loading-overlay[hidden] {
      display: none;
    }
    .spinner {
      border: 4px solid rgba(0, 0, 0, 0.1);
      border-top: 4px solid var(--snap-download);
      border-radius: 50%;
      width: 40px;
      height: 40px;
      animation: spin 1s linear infinite;
    }
    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    @media (max-width: 768px) {
      .hero-center {
        margin: 30px auto 0;
      }
    }

    /* Mode buttons: inline‑flex for centred content */
    .mode-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      text-decoration: none;
      white-space: nowrap;
      border: 0;
      font-family: 'Poppins', sans-serif;
      font-weight: 300;
      font-size: 15px;
      line-height: 24px;
      padding: 10px 14px;
      border-radius: 10px;
      cursor: pointer;
      color: #ffffff;
      background: rgba(255, 255, 255, 0.16);
      -webkit-backdrop-filter: blur(8px);
      backdrop-filter: blur(8px);
      transition: background .15s ease, color .15s ease, transform .12s ease, box-shadow .15s ease, -webkit-backdrop-filter .15s ease, backdrop-filter .15s ease;
    }

    .mode-btn:hover {
      transform: translateY(-1px);
      background: #ffffff;
      color: #0f1220;
      -webkit-backdrop-filter: blur(10px);
      backdrop-filter: blur(10px);
      box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
    }

    .mode-btn[aria-pressed="true"] {
      background: #ffffff;
      color: #0f1220;
      box-shadow: 0 6px 16px rgba(0, 0, 0, .10) inset, 0 2px 8px rgba(0, 0, 0, .06);
      border: 1px solid rgba(0, 0, 0, 0.06);
    }

    .mode-btn:focus-visible {
      outline: 2px solid rgba(0, 0, 0, .25);
      outline-offset: 2px;
      border-radius: 12px;
    }

    /* Mobile tweaks for tab bar and buttons */
    @media (max-width: 480px) {
      .mode-tabs {
        gap: 8px;
        max-width: 100%;
        padding: 0 8px;
      }
      .mode-btn {
        font-size: 14px;
        padding: 9px 12px;
        border-radius: 12px;
      }
    }

    .mode-buttons {
      padding-bottom: 120px;
    }

    .spacer {
      height: 50px;
      background: transparent;
    }

    /* Input row */
    .snap-form {
      margin: 10px auto 0;
      display: flex;
      align-items: center;
      gap: 12px;
      background: #fff;
      border-radius: 14px;
      padding: 8px;
      max-width: 860px;
      box-shadow: 0 14px 28px rgba(0, 0, 0, .22);
    }

    .snap-form input {
      flex: 1;
      border: 0;
      outline: 0;
      padding: 14px;
      border-radius: 10px;
      font-size: 15px;
      color: #111827
    }

    .snap-actions {
      display: flex;
      gap: 8px
    }

    /* Input-group wraps the URL field and the paste button.  The paste button will sit inside the input field on
     * small screens but remain inline on larger screens.  Without this wrapper the paste button could overlap the
     * download button on mobile devices. */
    .input-group {
      position: relative;
      flex: 1;
    }
    .input-group input {
      width: 100%;
    }
    .input-group .btn-ghost {
      position: absolute;
      top: 50%;
      right: 12px;
      transform: translateY(-50%);
      padding: 4px 10px;
      font-size: 14px;
      gap: 6px;
    }

    .btn-ghost,
    .btn-primary {
      display: inline-flex;
      align-items: center;
      /* Center the icon and text horizontally */
      justify-content: center;
      /* Remove default line-height to vertically center the text */
      line-height: 1;
      gap: 8px;
      border: 0;
      cursor: pointer;
      padding: 10px 14px;
      border-radius: 10px;
      font-weight: 800;
      transition: .15s transform ease;
    }

    /* Ensure icons inside buttons don't affect baseline alignment */
    .btn-ghost svg,
    .btn-primary svg {
      display: block;
    }

    .btn-ghost {
      background: #eef2ff;
      color: rgba(0, 0, 0, 0.533)
    }

    .btn-primary {
      background: var(--snap-download);
      color: #fff
    }

    .btn-ghost:hover,
    .btn-primary:hover {
      transform: translateY(-1px)
    }

    @media (max-width:720px) {
      .hero-brand {
        font-size: 40px
      }

      .hero-sub {
        font-size: 18px
      }

      .snap-form {
        flex-direction: column;
        align-items: stretch
      }

      .snap-actions {
        justify-content: space-between
      }

      /* Move mode tabs below the input on small screens and reposition the
       * paste button inside the input.  See index.html for details. */
      .hero-center {
        display: flex;
        flex-direction: column;
      }
      .hero-center .snap-form {
        order: 1;
      }
      .hero-center .mode-tabs {
        order: 2;
      }
      .snap-form {
        position: relative;
      }
      .input-group input {
        /* Reserve space for the paste button so that text and icon don't overlap */
        padding-right: 100px;
      }
      .snap-actions {
        width: 100%;
        margin-top: 8px;
      }
      .input-group .btn-ghost {
        /*
         * Anchor the paste button to the top and bottom of the input so it
         * fills the height and aligns the icon/text centrally.  Removing
         * the translate ensures perfect vertical alignment.
         */
        position: absolute;
        right: 12px;
        top: 8px;
        bottom: 8px;
        transform: none;
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 0 12px;
        font-size: 14px;
      }
      .snap-actions .btn-primary {
        width: 100%;
      }

      /* Reduce spacer height on small viewports */
      .spacer {
        height: 8px;
      }

      /* Expand mode tabs into two equal columns on mobile for better alignment */
      .mode-tabs {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        width: 100%;
        max-width: 100%;
        padding: 0 8px;
      }
      .mode-btn {
        width: 100%;
        justify-content: center;
      }
      /* Reduce top margin on the form to tighten spacing */
      .snap-form {
        margin-top: 0;
      }
      /* Ensure the paste button fills the input height with equal padding top and bottom */
      .input-group .btn-ghost {
        top: 8px;
        bottom: 8px;
        padding: 0 12px;
      }
      /* tabs hidden on mobile via rule above */
    }

    /* ===== SECTION WRAPPER (unchanged below) ===== */
    .section {
      padding: 46px 16px
    }

    .wrap {
      max-width: var(--max);
      margin: 0 auto
    }

    .title {
      text-align: center;
      font-size: 36px;
      font-weight: 800;
      color: var(--ink);
      margin: 8px 0 18px
    }

    .title span {
      background: linear-gradient(135deg, var(--purple), var(--purple-2));
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent
    }

    .steps {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 14px;
      margin-top: 10px
    }

    .step {
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 14px;
      padding: 14px;
      box-shadow: var(--shadow)
    }

    .step-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px
    }

    .num {
      width: 42px;
      height: 42px;
      border-radius: 12px;
      display: grid;
      place-items: center;
      font-weight: 800;
      color: #7c3aed;
      background: rgba(124, 58, 237, .10)
    }

    .corner-ico {
      font-size: 16px;
      color: #a1a1b0
    }

    .step h3 {
      font-size: 15px;
      font-weight: 700;
      margin-bottom: 6px
    }

    .step p {
      color: #595a67;
      font-size: 13.5px
    }

    .cta {
      display: flex;
      justify-content: center;
      margin: 18px 0 8px
    }

    .btn {
      background: #2563eb;
      color: #fff;
      border: 0;
      border-radius: 999px;
      padding: 12px 18px;
      font-weight: 700;
      cursor: pointer;
      box-shadow: 0 8px 18px rgba(37, 99, 235, .25)
    }

    .features {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 16px;
      margin-top: 12px
    }

    .feature {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 14px;
      align-items: start;
      background: #fff;
      border: 1px solid #e7d4fa;
      border-radius: 16px;
      padding: 18px;
      box-shadow: var(--shadow)
    }

    .ico {
      width: 56px;
      height: 56px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: rgba(124, 58, 237, .08)
    }

    /* Ensure feature icons scale correctly within their circular container */
    .ico img {
      width: 32px;
      height: 32px;
      object-fit: contain;
    }

    .feature h4 {
      font-size: 20px;
      font-weight: 800;
      margin-bottom: 6px
    }

    .feature p {
      color: #5e5f6c;
      font-size: 14px
    }

    @media (max-width:1024px) {
      .steps {
        grid-template-columns: repeat(2, 1fr)
      }
    }

    @media (max-width:560px) {
      .title {
        font-size: 28px
      }

      .steps {
        grid-template-columns: 1fr
      }

      .features {
        grid-template-columns: 1fr
      }
    }

    .why-choose {
      background: #d8d8de;
      padding: 56px 16px
    }

    .wc-wrap {
      max-width: var(--max);
      margin: 0 auto
    }

    .wc-title {
      text-align: center;
      font-size: 34px;
      font-weight: 800;
      margin-bottom: 34px;
      color: var(--ink)
    }

    .wc-title span {
      background: linear-gradient(135deg, var(--purple), var(--indigo));
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent
    }

    .wc-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 28px;
      align-items: start
    }

    .wc-item {
      text-align: center;
      padding: 6px 6px 0;
      opacity: 0;
      transform: translateY(12px)
    }

    .wc-item.reveal {
      opacity: 1;
      transform: translateY(0);
      transition: .45s ease
    }

    .wc-icon {
      width: 64px;
      height: 64px;
      margin: 0 auto 14px;
      display: grid;
      place-items: center;
      border-radius: 18px;
      background: #fff;
      box-shadow: 0 6px 18px rgba(79, 70, 229, .15);
      border: 1px solid rgba(79, 70, 229, .15)
    }

    /* Ensure "Why choose" icons scale correctly within their square container */
    .wc-icon img {
      width: 48px;
      height: 48px;
      object-fit: contain;
    }

    .wc-item h3 {
      font-size: 18px;
      font-weight: 700;
      color: var(--ink);
      margin-bottom: 6px
    }

    .wc-item p {
      font-size: 14.5px;
      color: var(--muted);
      max-width: 260px;
      margin: 0 auto 6px
    }

    @media (max-width:1024px) {
      .wc-grid {
        grid-template-columns: repeat(2, 1fr)
      }
    }

    @media (max-width:560px) {
      .wc-grid {
        grid-template-columns: 1fr
      }

      .wc-title {
        font-size: 28px
      }
    }

    .faq-sec {
      padding: 56px 16px
    }

    .faq-wrap {
      max-width: 920px;
      margin: 0 auto
    }

    .faq-title {
      font-size: 36px;
      font-weight: 800;
      text-align: center;
      color: var(--ink);
      margin-bottom: 8px
    }

    .faq-sub {
      text-align: center;
      color: var(--muted);
      margin-bottom: 26px
    }

    .faq-list {
      border-top: 1px solid var(--line)
    }

    .faq-item {
      border-bottom: 1px solid var(--line)
    }

    .faq-btn {
      width: 100%;
      background: #F5F5F9;
      border: 0;
      text-align: left;
      cursor: pointer;
      padding: 18px 6px;
      display: flex;
      align-items: center;
      gap: 12px;
      justify-content: space-between;
      font-weight: 700;
      color: #1f2430
    }

    .faq-btn:hover {
      background: #fafafa
    }

    .faq-btn .ico {
      width: 22px;
      height: 22px;
      flex: 0 0 auto;
      stroke: url(#grad-stroke);
      stroke-width: 2;
      fill: none;
      transform: rotate(0);
      transition: transform .2s
    }

    .faq-panel {
      max-height: 0;
      overflow: hidden;
      color: #6b7280;
      padding: 0;
      transition: max-height .3s ease, padding .3s ease, opacity .2s ease;
      opacity: .9
    }

    .faq-btn[aria-expanded="true"]+.faq-panel {
      max-height: 200px;
      padding: 0 0 16px
    }

    .faq-btn[aria-expanded="true"] .ico {
      transform: rotate(45deg)
    }

    /* Footer */
    .ft {
      background: linear-gradient(135deg, #b06bff 0%, #8a75ff 45%, #e17bff 100%);
      color: #111827;
      padding: 40px 18px 26px;
      border-top-left-radius: 20px;
      border-top-right-radius: 20px
    }

    .ft-wrap {
      max-width: var(--max);
      margin: 0 auto 22px;
      display: grid;
      grid-template-columns: 2fr 1fr 1.5fr;
      gap: 26px;
      align-items: start
    }

    .ft-about p {
      color: #1a1433;
      opacity: .9;
      line-height: 1.7;
      max-width: 340px
    }

    .ft-links h6,
    .ft-newsletter h6 {
      font-size: 12px;
      letter-spacing: .12em;
      font-weight: 800;
      color: #1a1433;
      opacity: .9;
      margin-bottom: 14px
    }

    .ft-links ul {
      list-style: none;
      display: grid;
      gap: 12px
    }

    .ft-links a {
      color: #111827;
      font-weight: 600
    }

    .ft-links a:hover {
      text-decoration: underline
    }

    .ft-form {
      display: grid;
      gap: 10px
    }

    .ft-form input {
      padding: 12px 14px;
      border-radius: 10px;
      border: none;
      outline: none;
      background: #fff;
      color: #111827;
      font-weight: 500;
      box-shadow: 0 2px 0 rgba(0, 0, 0, .04) inset
    }

    .ft-form button {
      border: none;
      cursor: pointer;
      font-weight: 700;
      padding: 12px 14px;
      border-radius: 10px;
      background: var(--indigo);
      color: #fff;
      box-shadow: 0 6px 18px rgba(79, 70, 229, .28);
      transition: transform .15s
    }

    .ft-form button:hover {
      transform: translateY(-1px)
    }

    .ft-msg {
      display: block;
      margin-top: 6px;
      min-height: 18px;
      color: #0b3d0b;
      font-weight: 600
    }

    .ft-msg.error {
      color: #5f0b0b
    }

    .ft-line {
      max-width: var(--max);
      margin: 20px auto;
      border: none;
      height: 1px;
      background: rgba(255, 255, 255, .55)
    }

    .ft-copy {
      text-align: center;
      color: #1a1433;
      font-weight: 600;
      opacity: .95
    }

    /* FIX: stack footer earlier for better responsiveness */
    @media (max-width:980px) {
      .ft-wrap {
        grid-template-columns: 1fr 1fr
      }
    }

    @media (max-width:780px) {
      .ft-wrap {
        grid-template-columns: 1fr
      }

      .ft-about p {
        max-width: none
      }

      .ft-form {
        grid-template-columns: 1fr
      }
    }

    /* Force heading colors you asked to keep */
    .step h3.always-black,
    [data-theme="dark"] .step h3.always-black {
      color: #4F46E5 !important;
      -webkit-text-fill-color: #4F46E5 !important;
    }

    .feature h4.always-purple,
    [data-theme="dark"] .feature h4.always-purple {
      color: #4F46E5 !important;
      -webkit-text-fill-color: #4F46E5 !important;
    }

    /* Language popup */
    .lang-wrap {
      position: relative;
      display: flex;
      align-items: center;
    }

    .lang-pop {
      position: absolute;
      right: 0;
      top: calc(100% + 10px);
      width: clamp(320px, 56vw, 520px);
      background: #fff;
      color: #0f1220;
      border: 1px solid rgba(0, 0, 0, .08);
      border-left: 6px solid #C13584;
      border-radius: 14px;
      box-shadow: 0 16px 40px rgba(0, 0, 0, .18);
      padding: 8px;
      z-index: 100;
      opacity: 0;
      transform: translateY(-6px);
      pointer-events: none;
      transition: opacity .18s ease, transform .18s ease;
      max-height: 420px;
      overflow: auto;
    }

    .lang-wrap.open .lang-pop {
      opacity: 1;
      transform: translateY(0);
      pointer-events: auto;
    }

    .lang-pop[hidden] {
      display: none;
    }

    .lang-wrap.open .hero-ss__lang svg {
      transform: rotate(180deg);
    }

    .lang-list {
      display: grid;
      grid-template-columns: 1fr 1fr;
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
    }

    .lang-list li {
      list-style: none;
      border-bottom: 1px solid #eee;
    }

    .lang-list li:nth-child(odd) {
      border-right: 1px solid #eee;
    }

    .lang-opt {
      width: 100%;
      text-align: left;
      background: transparent;
      border: 0;
      cursor: pointer;
      padding: 10px 12px;
      font-weight: 600;
      color: #111827;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .lang-opt:hover {
      background: #f3f4f6;
    }

    .lang-opt .check {
      opacity: 0;
      color: #C13584;
      font-weight: 800;
      margin-left: 12px;
    }

    .lang-opt[aria-selected="true"] {
      background: #fde7f3;
      color: #C13584;
    }

    .lang-opt[aria-selected="true"] .check {
      opacity: 1;
    }

    @media (max-width:560px) {
      .lang-pop {
        width: min(92vw, 420px)
      }

      .lang-list {
        grid-template-columns: 1fr
      }

      .lang-list li:nth-child(odd) {
        border-right: 0
      }
    }

    /* Dark theme support */
    [data-theme="dark"] .snap-form {
      background: #101828;
      box-shadow: 0 14px 28px rgba(0, 0, 0, .35);
    }

    [data-theme="dark"] .snap-form input {
      color: #f1f5f9;
      background: #0f172a;
    }

    [data-theme="dark"] body {
      background: #12162a;
      color: #eef0ff;
    }

    [data-theme="dark"] .hero-ss {
      --grad: linear-gradient(135deg, #1a1550 0%, #3c2f9a 40%, #7b3fa4 100%);
    }

    [data-theme="dark"] .hero-ss__pillnav {
      background: rgba(255, 255, 255, .12);
    }

    [data-theme="dark"] .pill {
      color: #e9e9ff;
    }

    [data-theme="dark"] .pill.active {
      color: #111827;
    }

    [data-theme="dark"] .pill-thumb {
      background: rgba(255, 255, 255, .16);
    }

    [data-theme="dark"] .hero-ss__center p {
      color: #d7d9ff;
    }

    [data-theme="dark"] .hero-ss__search {
      background: #1a1f3a;
      box-shadow: 0 10px 24px rgba(0, 0, 0, .28);
    }

    [data-theme="dark"] .hero-ss__search input {
      color: #f1f5f9;
    }

    [data-theme="dark"] .lang-pop {
      background: #0f1228;
      color: #e9e9ff;
      border-color: #23264a;
    }

    [data-theme="dark"] .lang-list li {
      border-color: #262a55;
    }

    [data-theme="dark"] .lang-opt:hover {
      background: #ffffff;
    }

    [data-theme="dark"] .lang-opt[aria-selected="true"] {
      background: #1a2060;
      color: #fcfcfd;
    }

    [data-theme="dark"] .lang-opt .check {
      color: #cfd2ff;
    }

    .step h3.always-black,
    [data-theme="dark"] .step h3.always-black {
      color: #4F46E5 !important;
      -webkit-text-fill-color: #4F46E5 !important;
    }

    .feature h4.always-purple,
    [data-theme="dark"] .feature h4.always-purple {
      color: #4F46E5 !important;
      -webkit-text-fill-color: #4F46E5 !important;
    }
  </style>
</head>

<body>

  <!-- Include Reusable Navbar -->
  {% include 'navbar.html' %}

  <!-- ========================= HERO ========================= -->
  <section class="hero-ss">
    <div class="hero-center">
      <!-- Use translated MP3 title and generic tagline -->
      <h1 class="hero-brand">{{ translations.mp3 }}</h1>
      <p class="hero-sub">{{ translations.hero_sub }}</p>

      <!-- Mode Tabs (hidden on mobile by CSS above) -->
      <div class="mode-tabs" role="tablist" aria-label="Download mode">
        {# Reordered tool buttons #}
        <a class="mode-btn" href="{{ url_for('story_viewer_mode', lang=lang) }}">{{ translations.story_viewer }}</a>
        <a class="mode-btn" href="{{ url_for('story_downloader', lang=lang) }}">{{ translations.story_downloader }}</a>
        <a class="mode-btn" href="{{ url_for('mp3_page', lang=lang) }}">{{ translations.download_mp3_full }}</a>
        <a class="mode-btn" href="{{ url_for('photos_page', lang=lang) }}">{{ translations.photo }}</a>
        <a class="mode-btn featured" href="{{ url_for('video_page', lang=lang) }}">{{ translations.video_nowm }}</a>
      </div>

      <div class="spacer"></div>

      <!-- Your form (unchanged behavior) -->
      <form class="snap-form" id="heroSearch" action="{{ url_for('index', lang=lang) }}" method="POST" novalidate
        data-preview-url="/{{ lang }}/preview">
        <input type="hidden" name="mode" id="modeField" value="video" />
        <div class="input-group">
          <input id="ssUrl" name="url" type="url" placeholder="{{ translations.paste_placeholder }}" required pattern="https?://.+" />
          <button type="button" id="ssPaste" class="btn-ghost" aria-label="Paste from clipboard">
            <svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true">
              <path
                d="M9 3h6l1 2h2a2 2 0 0 1 2 2v3M7 5h2m-2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V10m-5-5h-4"
                fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
            </svg>
            {{ translations.paste }}
          </button>
        </div>
        <div class="snap-actions">
          <button type="submit" id="ssSubmit" class="btn-primary">
            <svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true">
              <!-- Use a download arrow icon instead of a search icon -->
              <path d="M12 5v10m0 0l-4-4m4 4l4-4M5 20h14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
            {{ translations.download }}
          </button>
        </div>
      </form>
    </div>
  </section>

  <!-- ===== HOW TO + FEATURES (kept as-is) ===== -->
  <section class="section">
    <div class="wrap">
      <h2 class="title"><span>How to Use TikTok MP3 Downloader to Save Audio</span></h2>

      <div class="steps">
        <article class="step">
          <div class="step-head"><span class="num">01</span><span class="corner-ico"></span></div>
          <img src="https://tiktok.leadsniper.online/templates/images/step1.png" alt="Copy TikTok Link" />
          <h3 class="always-black">Copy the TikTok Video Link</h3>
          <p>Open the TikTok app and select the video you want to use. Tap on the "Share" button, then select "Copy
            Link." This TikTok video URL is needed for the downloader to fetch your file. Ensure you copy the link
            correctly before proceeding.</p>
        </article>

        <article class="step">
          <div class="step-head"><span class="num">02</span><span class="corner-ico"></span></div>
          <img src="https://tiktok.leadsniper.online/templates/images/step2.png" alt="Paste the Link" />
          <h3 class="always-black">Paste the Link in the Downloader Search Bar</h3>
          <p>Go to any trusted TikTok online downloader. Paste your copied TikTok link into the downloader’s search bar.
            These TikTok link downloader tools automatically detect your video and prepare it for conversion, giving you
            a quick and easy experience.</p>
        </article>

        <article class="step">
          <div class="step-head"><span class="num">03</span><span class="corner-ico"></span></div>
          <img src="https://tiktok.leadsniper.online/templates/images/step3.png" alt="Click Download" />
          <h3 class="always-black">Choose the MP3 Option</h3>
          <p>Once your TikTok video loads, click on the MP3 format option. The TikTok to MP3 converter will extract the
            audio only, allowing you to download it without the video. This feature enables you to save background
            music, songs, or voiceovers with ease.</p>
        </article>

        <article class="step">
          <div class="step-head"><span class="num">04</span><span class="corner-ico"></span></div>
          <img src="https://tiktok.leadsniper.online/templates/images/step4.png" alt="Save Without Watermark" />
          <h3 class="always-black">Click Download to Save the Audio File</h3>
          <p>After selecting MP3, press the "Download" button to save your TikTok audio. The tool will start downloading
            your TikTok MP3 file immediately. Enjoy a free and fast TikTok MP3 download with high-quality sound, ready
            for offline listening anytime.</p>
        </article>
      </div>
      <div class="spacer"></div>
      <div class="cta">
        <button class="btn" type="button" id="getStartedBtn">Downlode with SSS TikTOk without watermark</button>

      </div>

      <h2 class="title" style="margin-top:40px"><span>Key Features of TikTok MP3 Downloader</span></h2>

      <div class="features">
        <article class="feature">
          <div class="ico">
            <!-- Image for extracting MP3 in high quality. Recommended size: 32×32 pixels. -->
            <img src="{{ url_for('static', filename='icons/music.png') }}" alt="Extract MP3" width="32" height="32">
          </div>
          <div>
            <h4 class="always-purple">Extract High Quality MP3 from TikTok Videos</h4>
            <p>With TikTok MP3 Downloader, you can easily extract high-quality MP3 audio from any TikTok video. This
              TikTok music downloader allows you to save background sounds, music, and voiceovers in crystal clear
              format. Enjoy your favorite TikTok soundtrack anytime with this powerful TikTok audio extractor.</p>
        </article>

        <article class="feature">
          <div class="ico">
            <!-- Image for fast and free audio downloads. Recommended size: 32×32 pixels. -->
            <img src="{{ url_for('static', filename='icons/fast.png') }}" alt="Fast &amp; Free Audio" width="32" height="32">
          </div>
          <div>
            <h4 class="always-purple">Fast and Free &amp; Audio Downloads</h4>
            <p>Experience fast TikTok MP3 download speeds with no hidden limits. This free TikTok audio downloader
              allows unlimited conversions so you can save as many sounds as you like. Whether it's trending music or
              viral sounds, get them all quickly with this free TikTok converter tool.</p>
        </article>

        <article class="feature">
          <div class="ico">
            <!-- Image for no login required. Recommended size: 32×32 pixels. -->
            <img src="{{ url_for('static', filename='icons/watermark.png') }}" alt="No Login Required" width="32" height="32">
          </div>
          <div>
            <h4 class="always-purple">No Login or &amp; Signup Required </h4>
            <p>No need to create an account or install software. This TikTok online converter works instantly without
              any registration. Just open the <a href="https://ssstiktok.cc/tiktok-video-downloader" target="_blank"
                rel="noopener noreferrer">TikTok Video Downloader</a>, paste your link, and download MP3 files directly.
              It's safe, secure, and perfect for quick, hassle free use.</p>
        </article>

        <article class="feature">
          <div class="ico">
            <!-- Image for works on all devices. Recommended size: 32×32 pixels. -->
            <img src="{{ url_for('static', filename='icons/hd.png') }}" alt="All Devices &amp; Browsers" width="32" height="32">
          </div>
          <div>
            <h4 class="always-purple">Works on All Devices and Browsers</h4>
            <p>Whether you’re on Android, iPhone, PC, or Mac, the TikTok MP3 Downloader works smoothly on all platforms.
              It supports major browsers like Chrome, Firefox, and Safari. This mobile TikTok audio downloader ensures a
              seamless experience anytime, anywhere, without compatibility issues.</p>
        </article>
      </div>

      <svg width="0" height="0" style="position:absolute">
        <defs>
          <linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
            <stop offset="0%" stop-color="#7c3aed" />
            <stop offset="100%" stop-color="#a855f7" />
          </linearGradient>
        </defs>
      </svg>
    </div>
  </section>

  <div class="spacer"></div>
  <!-- ===== WHY CHOOSE US ===== -->
  <section class="why-choose">
    <div class="wc-wrap">
      <h2 class="wc-title"> <span>Why Choose SSSTikTok MP3 Downloader</span></h2>
      <div class="spacer"></div>
      <div class="wc-grid">
        <article class="wc-item">
          <div class="wc-icon">
            <!-- Image for simple & easy to use. Recommended size: 48×48 pixels. -->
            <img src="{{ url_for('static', filename='icons/wc-fast.png') }}" alt="Simple &amp; Easy" width="48" height="48">
          </div>
          <h3>Simple and Easy to Use</h3>
          <p>The SSSTikTok downloader features a user-friendly interface, making it extremely simple for anyone to use.
            Paste your TikTok link, click 'Convert', and you're done! This TikTok online tool quickly turns videos into
            MP3s with zero confusion or extra steps.</p>
        </article>

        <article class="wc-item">
          <div class="wc-icon">
            <!-- Image for safe & secure audio downloads. Recommended size: 48×48 pixels. -->
            <img src="{{ url_for('static', filename='icons/wc-secure.png') }}" alt="Safe &amp; Secure" width="48" height="48">
          </div>
          <h3>Safe and Secure Audio Downloads</h3>
          <p>Your privacy and safety come first! The Safe TikTok MP3 downloader ensures secure conversions without
            tracking or data leaks. Enjoy high quality music with this no watermark TikTok downloader. Every audio you
            save is clean, smooth, and completely TikTok music without a watermark.</p>
        </article>

        <article class="wc-item">
          <div class="wc-icon">
            <!-- Image for unlimited free conversions. Recommended size: 48×48 pixels. -->
            <img src="{{ url_for('static', filename='icons/wc-unlimited.png') }}" alt="Unlimited Free Conversions" width="48" height="48">
          </div>
          <h3>Unlimited Free Conversions</h3>
          <p>With the SSSTikTok MP3 Downloader, there's no limit! Get unlimited TikTok MP3 downloads anytime without
            paying a penny. This free TikTok MP3 download tool lets you grab all your favorite TikTok sounds and songs
            quickly, easily, and totally free TikTok music downloads.</p>
        </article>

        <article class="wc-item">
          <div class="wc-icon">
            <!-- Image for platform compatibility. Recommended size: 48×48 pixels. -->
            <img src="{{ url_for('static', filename='icons/wc-nologin.png') }}" alt="Compatible with All Platforms" width="48" height="48">
          </div>
          <h3>Compatible with All Platforms</h3>
          <p>Whether you're on Android, iPhone, or PC, SSSTikTok MP3 Downloader works everywhere! It supports all major
            devices and browsers, serving as your ideal TikTok MP3 player compatible tool. Now you can save TikTok music
            online and listen anytime, anywhere.</p>
        </article>
      </div>
    </div>
    <div class="spacer"></div>
    <div class="spacer"></div>
  </section>

  <!-- gradient defs for FAQ icons -->
  <svg width="0" height="0" style="position:absolute">
    <defs>
      <linearGradient id="grad-stroke" x1="0" y1="0" x2="1" y2="1">
        <stop offset="0%" stop-color="#7c3aed" />
        <stop offset="100%" stop-color="#4f46e5" />
      </linearGradient>
    </defs>
  </svg>


  <!-- ===== FAQ ===== -->
  <section class="faq-sec" id="faq">
    <div class="faq-wrap">
      <h2 class="faq-title">FAQs About TikTok MP3 Downloader</h2>
      <p class="faq-sub">Quick answers about downloading TikTok videos without watermark.</p>

      <div class="faq-list">
        <!-- Item 1 -->
        <article class="faq-item">
          <button class="faq-btn" aria-expanded="false" aria-controls="faq1">
            <span>How Can I Convert TikTok Videos to MP3?</span>
            <svg class="ico" viewBox="0 0 24 24" aria-hidden="true">
              <path d="M12 5v14M5 12h14" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
          </button>
          <div class="faq-panel" id="faq1">
            <p>You can easily convert TikTok videos to MP3 using a trusted TikTok MP3 converter. Paste the video link
              into a TikTok to MP3 online converter and click 'Convert'. In seconds, your favorite TikTok video will be
              converted into an audio file, ready to download.</p>
          </div>
        </article>

        <!-- Item 2 -->
        <article class="faq-item">
          <button class="faq-btn" aria-expanded="false" aria-controls="faq2">
            <span>Is It Safe to Download TikTok Audio Files?</span>
            <svg class="ico" viewBox="0 0 24 24" aria-hidden="true">
              <path d="M12 5v14M5 12h14" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
          </button>
          <div class="faq-panel" id="faq2">
            <p>Yes, it's completely safe! A safe TikTok downloader ensures your files remain private with no viruses or
              data tracking. The secure TikTok MP3 download process uses encryption, and every file is watermark-free.
              Always choose a reliable TikTok online downloader for the best results.</p>
          </div>
        </article>

        <!-- Item 3 -->
        <article class="faq-item">
          <button class="faq-btn" aria-expanded="false" aria-controls="faq3">
            <span>Can I Use It on Mobile and Desktop?</span>
            <svg class="ico" viewBox="0 0 24 24" aria-hidden="true">
              <path d="M12 5v14M5 12h14" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
          </button>
          <div class="faq-panel" id="faq3">
            <p>Absolutely! The TikTok MP3 downloader operates smoothly on all devices, including Android, iPhone, and
              PC. Whether you use Chrome or Safari, this TikTok online converter is fully compatible, just like other
              tools such as the <a href="https://ssstiktok.cc/tiktok-photo-downloader" target="_blank"
                rel="noopener noreferrer">TikTok Photo Downloader</a>, offering great flexibility across platforms.</p>
          </div>
        </article>

        <!-- Item 4 -->
        <article class="faq-item">
          <button class="faq-btn" aria-expanded="false" aria-controls="faq4">
            <span>Is It Free and Without Limits?</span>
            <svg class="ico" viewBox="0 0 24 24" aria-hidden="true">
              <path d="M12 5v14M5 12h14" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
          </button>
          <div class="faq-panel" id="faq4">
            <p>Yes, this tool offers free TikTok MP3 downloads with unlimited TikTok MP3 conversions. No signup or
              registration is needed. Paste your TikTok link and start downloading. Enjoy this TikTok converter free of
              charge, without restrictions or hidden fees fast, easy, and free.</p>
          </div>
        </article>





        <article class="faq-item">
          <button class="faq-btn" aria-expanded="false" aria-controls="faq4">
            <span>Can I Edit or Reuse the Downloaded Audio?</span>
            <svg class="ico" viewBox="0 0 24 24" aria-hidden="true">
              <path d="M12 5v14M5 12h14" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
          </button>
          <div class="faq-panel" id="faq4">
            <p>Of course! Once you download your TikTok MP3 file, you can store it safely and use it at any time. The
              file works on any TikTok MP3 compatible player, so you can easily edit, trim, or mix your favorite sounds
              using basic TikTok audio editing tools.</p>
          </div>
        </article>
      </div>
    </div>
  </section>

  <div class="spacer"></div>
  <!-- ===== FOOTER (kept) ===== -->
  <footer class="ft">
    <div class="ft-wrap">
      <div class="ft-about">
        <div class="ft-logo" aria-label="Brand">
          <img src="{{ url_for('static', filename='SSSTiktok.png') }}" alt="Logo" width="250" height="70">
        </div>
        <p>Clarity gives you the blocks and components you need to create a truly professional website.</p>
      </div>

      <nav class="ft-links" aria-label="Footer navigation">
        <h6>PAGES</h6>
        <ul>
          <li><a href="{{ url_for('contact') }}">Contact Us</a></li>
          <li><a href="{{ url_for('about') }}">About</a></li>
          <li><a href="{{ url_for('terms') }}">Terms &amp; Conditions</a></li>
          <li><a href="{{ url_for('privacy') }}">Privacy Policy</a></li>
        </ul>
      </nav>

      <div class="ft-newsletter">
        <h6>NEWSLETTER</h6>
        <form id="ftForm" class="ft-form" novalidate>
          <input type="email" id="ftEmail" placeholder="Enter your email address" required />
          <button type="submit">Subscribe Now</button>
        </form>
        <small id="ftMsg" class="ft-msg" aria-live="polite"></small>
      </div>
    </div>

    <hr class="ft-line" />
    <div class="ft-copy">© <span id="ftYear"></span> SSS Tiktok — All Rights Reserved</div>
  </footer>

  <script>
    // ===== Theme Toggle (kept) =====
    // ===== Mode tabs: set hidden field only (kept server flow) =====
    (function () {
      const field = document.getElementById('modeField');
      const btns = document.querySelectorAll('.mode-btn');
      btns.forEach(b => {
        b.addEventListener('click', () => {
          btns.forEach(x => x.setAttribute('aria-pressed', 'false'));
          b.setAttribute('aria-pressed', 'true');
          field.value = b.dataset.mode || 'video';
        });
      });
    })();

    // ===== Auto-redirect + Paste (kept behavior) =====
    (function () {
      const pasteBtn = document.getElementById('ssPaste');
      const input = document.getElementById('ssUrl');
      const form = document.getElementById('heroSearch');
      const submit = document.getElementById('ssSubmit');

      let isRedirecting = false;
      let inputTimer = null;
      const TYPE_DEBOUNCE_MS = 600;
      const REDIRECT_DELAY_MS = 2000;

      function isValidUrl(v) { return /^https?:\/\/.+/i.test(v || ''); }
      function setLoading() {
        // Show loading overlay during link processing
        const overlay = document.getElementById('loadingOverlay');
        if (overlay) {
          overlay.hidden = false;
        }
        if (submit) {
          submit.disabled = true;
          if (!submit.dataset._old) { submit.dataset._old = submit.innerHTML; }
          submit.innerHTML = 'Preparing preview…';
        }
      }
      function redirectToPreview(url) {
        if (isRedirecting) return;
        isRedirecting = true;
        const target = (form?.dataset.previewUrl) || '/preview';
        setTimeout(() => { window.location.href = `${target}?url=${encodeURIComponent(url)}`; }, REDIRECT_DELAY_MS);
      }
      function maybeRedirect(val) {
        const clean = (val || '').trim();
        if (isValidUrl(clean)) {
          setLoading();
          redirectToPreview(clean);
        }
      }
      pasteBtn?.addEventListener('click', async () => {
        try {
          const txt = await navigator.clipboard.readText();
          input.value = (txt || '').trim();
          maybeRedirect(input.value);
          if (!isRedirecting && !isValidUrl(input.value)) { input.focus(); alert('Please paste a valid TikTok URL.'); }
        } catch {
          alert('Clipboard not available. Paste with Ctrl/⌘+V.');
          input.focus();
        }
      });
      input?.addEventListener('paste', () => { setTimeout(() => { maybeRedirect(input.value); }, 0); });
      input?.addEventListener('input', () => {
        if (isRedirecting) return;
        clearTimeout(inputTimer);
        inputTimer = setTimeout(() => { maybeRedirect(input.value); }, TYPE_DEBOUNCE_MS);
      });
      form?.addEventListener('submit', (e) => {
        e.preventDefault();
        if (isRedirecting) return;
        const val = (input.value || '').trim();
        if (!isValidUrl(val)) {
          input.reportValidity?.();
          input.focus();
          return;
        }
        setLoading();
        redirectToPreview(val);
      });
    })();

    // Scroll reveal + FAQ (kept)
    (function () { const btn = document.getElementById('getStartedBtn'); btn?.addEventListener('click', () => window.scrollTo({ top: 0, behavior: 'smooth' })); })();
    (function () {
      function initReveal() {
        const items = document.querySelectorAll('.wc-item');
        if (!items.length) return;
        if ('IntersectionObserver' in window) {
          const io = new IntersectionObserver((entries, obs) => {
            entries.forEach(entry => {
              if (entry.isIntersecting) {
                entry.target.classList.add('reveal');
                obs.unobserve(entry.target);
              }
            });
          }, { threshold: 0.2, rootMargin: '0px 0px -10% 0px' });
          items.forEach(el => io.observe(el));
        } else {
          items.forEach(el => el.classList.add('reveal'));
        }
      }
      if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', initReveal);
      } else { initReveal(); }
    })();
    (function () {
      const items = document.querySelectorAll('.faq-item');
      items.forEach((it, i) => {
        const btn = it.querySelector('.faq-btn');
        if (!btn) return;
        if (i === 0) btn.setAttribute('aria-expanded', 'true');
        btn.addEventListener('click', () => {
          const open = btn.getAttribute('aria-expanded') === 'true';
          items.forEach(other => { const b = other.querySelector('.faq-btn'); if (b && b !== btn) b.setAttribute('aria-expanded', 'false'); });
          btn.setAttribute('aria-expanded', String(!open));
        });
      });
    })();

    // Footer year (kept)
    document.getElementById('ftYear').textContent = new Date().getFullYear();
    (function () {
      const form = document.getElementById('ftForm');
      const emailEl = document.getElementById('ftEmail');
      const msg = document.getElementById('ftMsg');
      if (!form) return;
      form.addEventListener('submit', async e => {
        e.preventDefault();
        const email = (emailEl.value || '').trim();
        const ok = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
        if (!ok) {
          msg.textContent = 'Please enter a valid email.';
          msg.classList.add('error');
          return;
        }
        msg.classList.remove('error');
        try {
          const res = await fetch('/subscribe', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ email }),
          });
          const data = await res.json();
          if (res.ok && data.status === 'ok') {
            msg.textContent = 'Thanks! You are subscribed.';
            form.reset();
          } else {
            msg.textContent = (data && data.message) || 'There was a problem. Please try again later.';
            msg.classList.add('error');
          }
        } catch (err) {
          msg.textContent = 'There was a problem. Please try again later.';
          msg.classList.add('error');
        }
      });
    })();

  </script>
  <!-- Loading overlay for form submission -->
  <div id="loadingOverlay" class="loading-overlay" hidden>
    <div class="spinner"></div>
  </div>
</body>

</html>