/* TikTok Downloader — improved UI */

.ttd-tool {
    --ttd-line: rgba(148, 163, 184, .18);
    --ttd-accent: #f472b6;
    --ttd-accent-2: #22d3ee;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ttd-tool [hidden] { display: none !important; }

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

.ttd-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) auto;
    gap: 1.25rem;
    align-items: center;
    padding: 1.2rem 1.3rem;
    border-radius: 18px;
    border: 1px solid var(--ttd-line);
    background:
        radial-gradient(900px 180px at 0% -30%, rgba(244, 114, 182, .2), transparent 55%),
        radial-gradient(700px 160px at 100% 0%, rgba(34, 211, 238, .12), transparent 50%),
        linear-gradient(145deg, rgba(15, 23, 41, .96), rgba(11, 22, 34, .9));
}

.ttd-kicker {
    margin: 0 0 .3rem;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ttd-accent);
}

.ttd-hero-title {
    margin: 0 0 .4rem;
    font-size: clamp(1.2rem, 2.4vw, 1.55rem);
    font-weight: 800;
    letter-spacing: -.02em;
    color: #f8fafc;
}

.ttd-hero-sub {
    margin: 0;
    max-width: 40rem;
    color: #94a3b8;
    font-size: .92rem;
    line-height: 1.55;
}

.ttd-hero-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .85rem;
}

.ttd-hero-chips span {
    font-size: .72rem;
    font-weight: 700;
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.04);
    border-radius: 999px;
    padding: .28rem .65rem;
}

.ttd-steps {
    list-style: none;
    margin: 0;
    padding: .85rem;
    display: grid;
    gap: .55rem;
    width: auto;
    min-width: 150px;
    max-width: 200px;
    align-self: center;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.1);
    background: rgba(2, 6, 23, .45);
}

.ttd-steps li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: .55rem;
    align-items: center;
    text-align: left;
    color: #cbd5e1;
    font-size: .82rem;
    font-weight: 650;
}

.ttd-steps strong {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #db2777, #f472b6);
    color: #fff;
    font-size: .78rem;
    flex-shrink: 0;
}

.ttd-card {
    padding: 1.1rem 1.15rem;
    border-radius: 16px;
    border: 1px solid var(--ttd-line);
    background: rgba(15, 23, 41, .72);
}

.ttd-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .8rem;
}

.ttd-card-head h3 {
    margin: 0;
    font-size: .95rem;
    font-weight: 800;
    color: #e2e8f0;
}

.ttd-pill {
    font-size: .72rem;
    font-weight: 700;
    color: #f9a8d4;
    background: rgba(236, 72, 153, .12);
    border: 1px solid rgba(244, 114, 182, .28);
    border-radius: 999px;
    padding: .28rem .65rem;
}











.ttd-mini {
    appearance: none;
    border: 1px solid var(--ttd-line);
    background: rgba(30, 41, 59, .85);
    color: #cbd5e1;
    font-size: .78rem;
    font-weight: 700;
    border-radius: 999px;
    padding: .35rem .75rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.ttd-mini:hover,
.ttd-mini-link:hover {
    border-color: rgba(244, 114, 182, .45);
    color: #fce7f3;
}

.ttd-note {
    margin: 0;
    font-size: .78rem;
    color: #64748b;
    line-height: 1.45;
    flex: 1;
    min-width: 12rem;
}

.ttd-progress {
    margin-top: 1rem;
    padding: .85rem .9rem;
    border-radius: 12px;
    border: 1px solid rgba(244, 114, 182, .25);
    background: rgba(80, 7, 36, .28);
}

.ttd-progress-head {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
    font-size: .85rem;
    color: #e2e8f0;
}

.ttd-progress-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(15, 23, 41, .85);
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, .2);
}

.ttd-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, #db2777, #f472b6, #22d3ee);
    transition: width .2s ease;
}

.ttd-progress-step {
    margin: .55rem 0 0;
    font-size: .78rem;
    color: #94a3b8;
}

.ttd-status {
    margin: .75rem 0 0;
    min-height: 1.2rem;
    font-size: .86rem;
    color: #94a3b8;
}

.ttd-status.is-error { color: #fca5a5; }
.ttd-status.is-ok { color: #86efac; }

.ttd-empty {
    border-radius: 16px;
    border: 1px dashed rgba(148, 163, 184, .28);
    background: rgba(15, 23, 41, .4);
    padding: 1rem;
}

.ttd-empty-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
}

.ttd-empty-item {
    padding: .85rem .9rem;
    border-radius: 12px;
    background: rgba(2, 6, 23, .35);
    border: 1px solid rgba(255,255,255,.06);
}

.ttd-empty-item strong {
    display: block;
    color: #f1f5f9;
    font-size: .9rem;
    margin-bottom: .25rem;
}

.ttd-empty-item span {
    color: #94a3b8;
    font-size: .8rem;
    line-height: 1.4;
}

.ttd-result-top {
    display: grid;
    grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
    gap: 1.15rem;
    align-items: start;
    margin-bottom: 1.1rem;
}

.ttd-preview-wrap {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #020617;
    border: 1px solid var(--ttd-line);
    aspect-ratio: 9 / 16;
    max-height: 380px;
    box-shadow: 0 18px 40px rgba(0,0,0,.28);
}

.ttd-preview,
.ttd-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #020617;
}

.ttd-preview-badge {
    position: absolute;
    left: .65rem;
    top: .65rem;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #ecfdf5;
    background: rgba(6, 95, 70, .88);
    border: 1px solid rgba(110, 231, 183, .45);
    border-radius: 999px;
    padding: .28rem .55rem;
    backdrop-filter: blur(8px);
}

.ttd-author-row {
    display: flex;
    gap: .7rem;
    align-items: center;
    margin-bottom: .65rem;
}

.ttd-avatar {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    object-fit: cover;
    border: 2px solid rgba(244, 114, 182, .45);
    background: #0f172a;
}

.ttd-author {
    margin: 0;
    font-size: .92rem;
    font-weight: 750;
    color: #f8fafc;
}

.ttd-stats {
    margin: .15rem 0 0;
    font-size: .78rem;
    color: #94a3b8;
}

.ttd-meta h3 {
    margin: 0 0 .45rem;
    font-size: 1.05rem;
    font-weight: 800;
    color: #f8fafc;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ttd-music {
    margin: 0 0 .75rem;
    font-size: .84rem;
    color: #94a3b8;
}

.ttd-meta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.ttd-mode-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .9rem;
}

.ttd-mode {
    appearance: none;
    border: 1px solid var(--ttd-line);
    background: rgba(15, 23, 41, .8);
    color: #cbd5e1;
    font-size: .8rem;
    font-weight: 750;
    border-radius: 999px;
    padding: .4rem .85rem;
    cursor: pointer;
}

.ttd-mode.is-active {
    border-color: rgba(244, 114, 182, .55);
    background: rgba(131, 24, 67, .35);
    color: #fce7f3;
}

.ttd-formats {
    display: grid;
    gap: .55rem;
}

.ttd-format {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: .75rem;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: .8rem .9rem;
    border-radius: 14px;
    border: 1px solid var(--ttd-line);
    background: rgba(2, 6, 23, .45);
    color: #e2e8f0;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .15s;
}

.ttd-format:hover {
    border-color: rgba(244, 114, 182, .35);
    transform: translateY(-1px);
}

.ttd-format.is-active {
    border-color: rgba(244, 114, 182, .6);
    background: rgba(131, 24, 67, .28);
    box-shadow: 0 0 0 1px rgba(244, 114, 182, .18);
}

.ttd-format-badge {
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: .32rem .48rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, .06);
    color: #f9a8d4;
}

.ttd-format-badge.is-clean {
    background: rgba(16, 185, 129, .16);
    color: #6ee7b7;
}

.ttd-format-badge.is-wm {
    background: rgba(251, 191, 36, .14);
    color: #fcd34d;
}

.ttd-format-badge.is-audio {
    background: rgba(56, 189, 248, .14);
    color: #7dd3fc;
}

.ttd-format-badge.is-image {
    background: rgba(167, 139, 250, .16);
    color: #c4b5fd;
}

.ttd-format .ttd-format-select {
    all: unset;
    cursor: pointer;
    min-width: 0;
    display: block;
}

.ttd-format strong {
    display: block;
    font-size: .92rem;
    color: #f8fafc;
}

.ttd-format .ttd-format-sub {
    display: block;
    font-size: .75rem;
    color: #94a3b8;
    margin-top: .18rem;
}

.ttd-format-dl {
    appearance: none;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(145deg, #db2777, #f472b6);
    color: #fff;
    font-size: .75rem;
    font-weight: 800;
    padding: .45rem .7rem;
    cursor: pointer;
    white-space: nowrap;
}

.ttd-format-dl:hover { filter: brightness(1.06); }

.ttd-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    margin-top: 1rem;
    align-items: stretch;
}

.ttd-actions .btn {
    min-height: 44px;
    justify-content: center;
    text-align: center;
}

.ttd-download-main {
    min-width: 180px;
}

@media (max-width: 768px) {
    .ttd-hero {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 0.9rem;
        align-items: stretch;
    }

    .ttd-hero-copy {
        width: 100%;
        min-width: 0;
    }

    .ttd-result-top,
    .ttd-empty-grid {
        grid-template-columns: 1fr;
    }

    .ttd-hero-sub {
        font-size: 0.88rem;
        max-width: none;
    }

    /* Mobile: full-width 3-step bar under hero (not the desktop sidebar box) */
    .ttd-steps {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        max-width: none;
        min-width: 0;
        margin: 0;
        padding: 0.55rem;
        gap: 0.4rem;
        box-sizing: border-box;
        align-self: stretch;
    }

    .ttd-steps li {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        gap: 0.3rem;
        margin: 0;
        padding: 0.5rem 0.3rem;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.04);
        min-width: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .ttd-steps li span {
        display: block;
        width: 100%;
        font-size: 0.72rem;
        line-height: 1.25;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .ttd-steps strong {
        width: 26px;
        height: 26px;
        font-size: 0.72rem;
    }

    

    

    .ttd-url-row 

    .ttd-download-main {
        min-width: 0;
        width: 100%;
    }

    .ttd-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
        width: 100%;
    }

    .ttd-actions .btn {
        width: 100%;
        min-width: 0;
        min-height: 48px;
        justify-content: center;
    }

    .ttd-input-card {
        padding: 1rem;
    }
}

@media (max-width: 640px) {
    

    

    .ttd-url-row 

    .ttd-fetch-label {
        font-size: 0.88rem;
    }

    .ttd-preview-wrap {
        max-width: 260px;
        margin: 0 auto;
    }

    /* Download buttons: all full-width on phones */
    .ttd-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.55rem;
        width: 100%;
    }

    .ttd-actions .ttd-download-main {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }

    .ttd-actions .btn {
        width: 100%;
        min-width: 0;
        min-height: 48px;
        padding-left: 0.65rem;
        padding-right: 0.65rem;
        white-space: normal;
        line-height: 1.25;
    }
}

@media (max-width: 480px) {
    .ttd-hero {
        padding: 0.9rem;
    }

    .ttd-hero-title {
        font-size: 1.15rem;
    }

    /* Phone: keep steps as one full-width row of 3 equal chips */
    .ttd-steps {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        max-width: none;
        min-width: 0;
        padding: 0.45rem;
        gap: 0.3rem;
    }

    .ttd-steps li {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        gap: 0.25rem;
        padding: 0.45rem 0.2rem;
    }

    .ttd-steps li span {
        font-size: 0.68rem;
        text-align: center;
    }

    .ttd-steps strong {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    

    .ttd-url-row 

    .ttd-mini {
        min-height: 44px;
        padding: 0.55rem 1.1rem;
        font-size: 0.85rem;
    }

    /* Phone: stack all download actions full width */
    .ttd-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .ttd-actions .ttd-download-main,
    .ttd-actions .btn {
        grid-column: 1;
        width: 100%;
        min-width: 0;
        min-height: 48px;
    }
}

.ttd-profile-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.ttd-profile-actions,
.ttd-profile-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}
.ttd-profile-toolbar {
    margin-bottom: 1rem;
    padding: .75rem;
    border-radius: 12px;
    border: 1px solid var(--ttd-line);
    background: rgba(2, 6, 23, .35);
}
.ttd-check-all {
    display: inline-flex;
    gap: .4rem;
    align-items: center;
    color: #cbd5e1;
    font-size: .85rem;
    font-weight: 700;
}
.ttd-profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .75rem;
}
.ttd-profile-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    padding: .55rem;
    border-radius: 14px;
    border: 1px solid var(--ttd-line);
    background: rgba(15, 23, 41, .75);
    cursor: pointer;
}
.ttd-profile-card.is-checked {
    border-color: color-mix(in srgb, var(--ttd-accent) 55%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ttd-accent) 35%, transparent);
}
.ttd-profile-card input {
    position: absolute;
    top: .65rem;
    left: .65rem;
    z-index: 2;
    width: 1.05rem;
    height: 1.05rem;
}
.ttd-profile-thumb {
    display: block;
    aspect-ratio: 9/12;
    border-radius: 10px;
    background: #020617 center/cover no-repeat;
}
.ttd-profile-meta strong {
    display: block;
    font-size: .78rem;
    color: #e2e8f0;
    line-height: 1.3;
    max-height: 2.5em;
    overflow: hidden;
}
.ttd-profile-meta em {
    display: block;
    font-style: normal;
    font-size: .7rem;
    color: #94a3b8;
}
.ttd-profile-one {
    appearance: none;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(145deg, #ec4899, #f472b6);
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    padding: .4rem .55rem;
    cursor: pointer;
}

/* Mobile: tiktok profile actions */
@media (max-width: 640px) {
  .ttd-profile-actions,
  .ttd-profile-toolbar {
    width: 100%;
  }
  .ttd-profile-actions .btn,
  .ttd-profile-toolbar .btn {
    flex: 1 1 100%;
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }
  .ttd-format {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .ttd-format-dl {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
}


/* Input stack: row 1 URL | row 2 Paste | row 3 Fetch + Clear */
.ttd-url-stack {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  width: 100%;
}
.ttd-url-stack--actions { margin-top: .65rem; }
.ttd-url-field { position: relative; min-width: 0; width: 100%; }
.ttd-url-icon {
  position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  color: #94a3b8; pointer-events: none; z-index: 1;
}
.ttd-url-input { padding-left: 2.55rem !important; min-height: 50px; }
.ttd-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; width: 100%; }
.ttd-paste-btn,
.ttd-fetch-btn,
.ttd-clear-btn {
  width: 100%; min-height: 48px; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 700; border-radius: 12px; padding: .7rem 1rem;
}
.ttd-paste-btn { border-style: dashed; }
.ttd-fetch-btn { box-shadow: 0 8px 22px color-mix(in srgb, var(--ttd-accent, #f472b6) 28%, transparent); }
