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

:root {
    --bg-deep:    #0a0e1a;
    --bg-surface: rgba(15, 20, 40, 0.7);
    --bg-glass:   rgba(25, 32, 60, 0.55);
    --border:     rgba(100, 120, 200, 0.15);
    --border-lit: rgba(140, 160, 255, 0.25);
    --accent-v:   #8b5cf6;
    --accent-c:   #06b6d4;
    --accent-p:   #ec4899;
    --text:       #e2e8f0;
    --text-dim:   #94a3b8;
    --text-mute:  #64748b;
    --success:    #34d399;
    --radius:     12px;
    --radius-sm:  8px;
    --font:       'Outfit', sans-serif;
    --mono:       'JetBrains Mono', monospace;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body::before {
    content: '';
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 20% 10%, rgba(139,92,246,0.08) 0%, transparent 70%),
        radial-gradient(ellipse 50% 60% at 80% 90%, rgba(6,182,212,0.06) 0%, transparent 70%),
        radial-gradient(ellipse 40% 40% at 50% 50%, rgba(236,72,153,0.04) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ── Layout ── */
.shell {
    position: relative; z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ── Header ── */
header { margin-bottom: 2rem; }
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--accent-v), var(--accent-c));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
header p {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

/* ── Glass card ── */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: border-color 0.25s;
}
.card:hover { border-color: var(--border-lit); }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.7rem 1.2rem;
    border: none; border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.88rem; font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.25s, opacity 0.2s;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-v), #7c3aed);
    box-shadow: 0 2px 12px rgba(139,92,246,0.3);
}
.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(139,92,246,0.45);
}
.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
}
.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-c);
    color: var(--accent-c);
}
.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    min-height: 36px;
}
.btn-block {
    display: flex;
    width: 100%;
    justify-content: center;
}
.btn-dl {
    background: linear-gradient(135deg, var(--accent-c), #0891b2);
    box-shadow: 0 2px 10px rgba(6,182,212,0.25);
    font-size: 0.78rem;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    white-space: nowrap;
    min-height: 40px;
}
.btn-dl:hover { box-shadow: 0 4px 18px rgba(6,182,212,0.4); }

/* ── Search ── */
.search-wrap {
    display: flex; gap: 0.6rem;
    margin-bottom: 1.5rem;
}
.search-wrap input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 48px;
}
.search-wrap input:focus {
    border-color: var(--accent-v);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}
.search-wrap input::placeholder { color: var(--text-mute); }

/* ── Creator list ── */
.creator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}
.creator-item {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.9rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 60px;
}
.creator-item:hover { background: rgba(139,92,246,0.08); }
.creator-item:active { background: rgba(139,92,246,0.14); }

.creator-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-v), var(--accent-p));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem;
    flex-shrink: 0;
    text-transform: uppercase;
    color: #fff;
}
.creator-info { min-width: 0; }
.creator-name {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.creator-service {
    font-size: 0.75rem;
    color: var(--text-mute);
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Breadcrumb ── */
.breadcrumb {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-dim);
    flex-wrap: wrap;
}
.breadcrumb a {
    color: var(--accent-c);
    text-decoration: none;
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}
.breadcrumb a:hover { text-decoration: underline; }
.bc-sep { color: var(--text-mute); font-size: 0.75rem; }

/* ── Post separator ── */
.post-sep {
    font-size: 0.72rem;
    color: var(--text-mute);
    font-family: var(--mono);
    padding: 0.6rem 0 0.3rem;
    border-top: 1px solid var(--border);
    margin-top: 0.6rem;
}
.post-sep:first-child {
    border-top: none;
    margin-top: 0;
}

/* ── Media grid ── */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.4rem;
    margin-top: 0.75rem;
}
.media-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    background: var(--bg-surface);
    transition: border-color 0.2s, transform 0.15s;
}
.media-item:hover {
    border-color: var(--accent-c);
    transform: scale(1.03);
}
.media-item:active { transform: scale(0.98); }
.media-item img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}

/* Video items */
.media-video {
    background: linear-gradient(135deg, rgba(15,20,40,0.9), rgba(25,32,60,0.8));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem;
}
.video-play-icon {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: rgba(139,92,246,0.4);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.media-video:hover .video-play-icon {
    background: rgba(139,92,246,0.7);
}
.video-label {
    font-family: var(--mono);
    font-size: 0.6rem;
    color: var(--text-mute);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.media-item-saved {
    border-color: var(--success);
    overflow: visible;
}
.media-item-saved::after {
    content: '✓';
    position: absolute;
    top: -4px; right: -4px;
    width: 22px; height: 22px;
    background: var(--success);
    color: #fff;
    border-radius: 50%;
    font-size: 0.7rem;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.media-item-saved .video-play-icon {
    background: rgba(52,211,153,0.4);
}
.media-item-saved:hover .video-play-icon {
    background: rgba(52,211,153,0.7);
}

/* ── Media type badges ── */
.media-badge {
    position: absolute;
    bottom: 4px; left: 4px;
    width: 22px; height: 22px;
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    z-index: 2;
    pointer-events: none;
}
.media-badge-video { background: rgba(139,92,246,0.85); }
.media-badge-image { background: rgba(6,182,212,0.7); }

/* ── Video thumbnail overlay ── */
.video-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.2);
    transition: background 0.2s;
    pointer-events: none;
}
.media-video:hover .video-play-overlay {
    background: rgba(0,0,0,0.35);
}

/* ── Other file type in grid ── */
.media-file {
    background: linear-gradient(135deg, rgba(15,20,40,0.9), rgba(25,32,60,0.8));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem;
}
.media-file-icon { font-size: 1.8rem; }

/* ── Media saving state ── */
.media-saving {
    opacity: 0.5;
    pointer-events: none;
}
.media-saving::after {
    content: '';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    border-radius: var(--radius-sm);
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(1rem);
    background: rgba(15, 20, 40, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-lit);
    border-radius: var(--radius);
    padding: 0.65rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    z-index: 800;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    white-space: nowrap;
}
.toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Download-All bar ── */
.dl-all-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    background: rgba(6,182,212,0.06);
    border: 1px solid rgba(6,182,212,0.15);
    border-radius: var(--radius);
    gap: 0.75rem;
}
.dl-all-bar span {
    color: var(--text-dim);
    font-size: 0.82rem;
}

/* ── Pagination ── */
.pagination {
    display: flex; justify-content: center; gap: 0.75rem;
    margin-top: 1.5rem;
}
.pagination .btn { flex: 1; max-width: 200px; justify-content: center; }

/* ── Badge ── */
.badge {
    display: inline-block;
    background: rgba(139,92,246,0.15);
    color: var(--accent-v);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    margin-left: 0.4rem;
}
.badge-cyan {
    background: rgba(6,182,212,0.15);
    color: var(--accent-c);
}

/* ── History ── */
.history-section { margin-bottom: 1.5rem; }
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.history-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── History item delete ── */
.history-item {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}
.btn-history-delete {
    position: absolute;
    top: 0.5rem; right: 0.5rem;
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--accent-p);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: transform 0.15s;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}
.btn-history-delete:active { transform: scale(0.9); }
.history-item.show-delete .btn-history-delete { display: flex; }
.history-item.show-delete {
    border-color: var(--accent-p);
    animation: shake 0.3s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* ── Loading / Status ── */
.status {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-mute);
    font-size: 0.88rem;
}
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-v);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Lightbox ── */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 1rem;
}
.lightbox.active { display: flex; }
.lightbox img, .lightbox video {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius);
    object-fit: contain;
}

/* ── Login ── */
.login-shell {
    position: relative; z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-card {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
}
.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--accent-v), var(--accent-c));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 0.25rem;
}
.login-subtitle {
    color: var(--text-mute);
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 2rem;
}
.login-error {
    background: rgba(236,72,153,0.1);
    border: 1px solid rgba(236,72,153,0.25);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    font-size: 0.82rem;
    color: var(--accent-p);
    margin-bottom: 1.25rem;
    text-align: center;
}
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
}
.form-group input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 48px;
}
.form-group input:focus {
    border-color: var(--accent-v);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}
.login-card .btn-block {
    margin-top: 0.5rem;
    min-height: 48px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    html { font-size: 14px; }
    .shell { padding: 1rem 0.85rem 3rem; }

    header h1 { font-size: 1.35rem; }
    header p { font-size: 0.78rem; }

    .search-wrap { flex-direction: column; }
    .search-wrap .btn { justify-content: center; }

    .creator-grid { grid-template-columns: 1fr; }

    .media-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }

    .dl-all-bar {
        flex-direction: column;
        text-align: center;
        gap: 0.6rem;
    }
    .dl-all-bar .btn-dl { width: 100%; justify-content: center; }

    .pagination { gap: 0.5rem; }
    .pagination .btn { max-width: none; }

    .breadcrumb { font-size: 0.8rem; }

    .login-card { padding: 2rem 1.5rem; }

    .video-play-icon { width: 36px; height: 36px; }
    .video-play-icon svg { width: 20px; height: 20px; }
}

@media (max-width: 380px) {
    .shell { padding: 0.75rem 0.65rem 2.5rem; }
    .card { padding: 1rem; }
    .media-grid { grid-template-columns: repeat(3, 1fr); }
    .creator-avatar { width: 36px; height: 36px; font-size: 0.88rem; }
}
