/* ── Variables ── */
:root {
    --bg: #080c14;
    --surface: #0e1520;
    --surface2: #141e2e;
    --border: rgba(255,255,255,0.07);
    --text: #e8edf5;
    --text-muted: #5a6a82;
    --text-dim: #8a9ab5;
    --accent: #3ddc97;
    --accent-dim: rgba(61,220,151,0.12);
    --accent-glow: rgba(61,220,151,0.3);
    --blue: #4f8ef7;
    --red: #f75a5a;
    --radius: 14px;
    --font-display: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Background effects ── */
.bg-grid {
    position: fixed; inset: 0; z-index: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.glow {
    position: fixed; z-index: 0;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    opacity: 0.35;
}
.glow-1 {
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(61,220,151,0.25), transparent 70%);
    top: -200px; right: -200px;
}
.glow-2 {
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(79,142,247,0.2), transparent 70%);
    bottom: -150px; left: -150px;
}

/* ── Brand ── */
.brand {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.brand-icon {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--accent);
    color: #080c14;
    border-radius: 9px;
    font-size: 16px;
}

/* ─────────────────────────────────
   LOGIN PAGE
───────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-wrap {
    position: relative; z-index: 1;
    display: flex; flex-direction: column;
    align-items: center; gap: 28px;
    width: 100%; max-width: 420px;
    padding: 24px;
}

.login-box {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px 36px;
    box-shadow: 0 32px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
}

.login-box h2 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.login-sub {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.field {
    margin-bottom: 16px;
}
.field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

input {
    width: 100%;
    padding: 13px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input::placeholder { color: var(--text-muted); }
input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    color: #080c14;
    border: none;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    margin-top: 8px;
}
.btn-primary:hover {
    background: #52e8a8;
    box-shadow: 0 0 20px var(--accent-glow);
}
.btn-primary:active { transform: scale(0.98); }

.error-msg {
    color: var(--red);
    font-size: 13px;
    margin-top: 14px;
    min-height: 18px;
    text-align: center;
}

.footer-note {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

/* ─────────────────────────────────
   APP PAGE (downloader)
───────────────────────────────── */
.app-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    position: relative; z-index: 10;
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 18px 40px;
    border-bottom: 1px solid var(--border);
    background: rgba(8,12,20,0.7);
    backdrop-filter: blur(12px);
}

.btn-logout {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
}
.btn-logout:hover {
    border-color: var(--red);
    color: var(--red);
    background: rgba(247,90,90,0.08);
}

/* Main */
.main-wrap {
    position: relative; z-index: 1;
    flex: 1;
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    padding: 60px 24px 40px;
}

.hero {
    text-align: center;
    margin-bottom: 44px;
}
.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(36px, 6vw, 58px);
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 1.1;
    margin-bottom: 14px;
}
.hero h1 .accent { color: var(--accent); }
.hero-sub {
    color: var(--text-muted);
    font-size: 15px;
    letter-spacing: 0.3px;
}

/* Card */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.35);
}

/* Platform pills */
.platform-pills {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 20px;
}
.pill {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface2);
    border: 1px solid var(--border);
    cursor: default;
    transition: all 0.2s;
    user-select: none;
}
.pill.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* URL input row */
.input-row {
    display: flex; gap: 10px;
    margin-bottom: 14px;
}
.url-input-wrap {
    position: relative; flex: 1;
    display: flex; align-items: center;
}
.input-icon {
    position: absolute; left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}
.url-input-wrap input {
    padding-left: 44px;
    padding-right: 40px;
}
.btn-clear-x {
    position: absolute; right: 12px;
    background: none; border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
    width: auto;
}
.btn-clear-x:hover { color: var(--text); }

.btn-fetch {
    width: auto;
    padding: 13px 24px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* API key row */
.apikey-row {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 4px;
}
.apikey-row svg { color: var(--text-muted); flex-shrink: 0; }
.apikey-row input {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 13px;
    flex: 1;
    min-width: 0;
    box-shadow: none;
}
.apikey-row input:focus { box-shadow: none; }
.api-link {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}
.api-link:hover { text-decoration: underline; }

/* Result area */
.result-area {
    margin-top: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    animation: fadeIn 0.3s ease;
}
.result-area.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.result-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.3px;
}

.download-links {
    display: flex; flex-wrap: wrap; gap: 10px;
}

.dl-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 18px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}
.dl-btn:hover {
    background: var(--accent);
    color: #080c14;
    box-shadow: 0 0 16px var(--accent-glow);
}

.status-msg {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-dim);
    font-size: 14px;
}

.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-result {
    color: var(--red);
    font-size: 14px;
    line-height: 1.6;
}
.error-result small { color: var(--text-muted); font-size: 12px; display: block; margin-top: 6px; }

/* Thumbnail */
.result-thumb {
    width: 100%; max-height: 200px; object-fit: cover;
    border-radius: 10px; margin-bottom: 16px;
}

/* How-to section */
.how-section {
    margin-top: 44px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
}
.how-section h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 20px;
}
.steps { display: flex; flex-direction: column; gap: 14px; }
.step {
    display: flex; align-items: flex-start; gap: 14px;
}
.step-num {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; flex-shrink: 0;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
}
.step p {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.55;
    padding-top: 4px;
}
.step p a {
    color: var(--accent);
    text-decoration: none;
}
.step p a:hover { text-decoration: underline; }
.step p strong { color: var(--text); }

/* Footer */
.footer {
    position: relative; z-index: 1;
    text-align: center;
    padding: 24px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 20px;
}

/* Shake animation for login error */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .topbar { padding: 14px 20px; }
    .main-wrap { padding: 40px 16px 32px; }
    .input-row { flex-direction: column; }
    .btn-fetch { width: 100%; justify-content: center; }
    .card, .how-section, .result-area { padding: 20px; }
    .login-box { padding: 32px 24px; }
}

/* Download section labels */
.dl-section-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
}

.dl-btn { cursor: pointer; font-family: inherit; }
.dl-btn:disabled { opacity: 0.6; cursor: not-allowed; }
