:root {
    --bg: #0f1115;
    --card: #1a1d24;
    --card-hover: #20242c;
    --border: #2a2f38;
    --text: #e6e8eb;
    --muted: #8b929e;
    --accent: #ef4444;
    --accent-hover: #dc2626;
    --accent-soft: rgba(239, 68, 68, 0.12);
    --success: #22c55e;
    --error: #f87171;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.5;
}

.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 48px 20px 80px;
}

header {
    text-align: center;
    margin-bottom: 32px;
}

header h1 {
    margin: 0 0 8px;
    font-size: 28px;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--muted);
    margin: 0;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.row {
    display: flex;
    gap: 10px;
}

input[type="url"], select {
    flex: 1;
    background: #0c0e12;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s ease;
    width: 100%;
}

input[type="url"]:focus, select:focus {
    border-color: var(--accent);
}

button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
    white-space: nowrap;
}

button:hover:not(:disabled) {
    background: var(--accent-hover);
}

button:active:not(:disabled) {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.status {
    margin: 12px 0 0;
    min-height: 20px;
    font-size: 14px;
    color: var(--muted);
}

.status.error { color: var(--error); }
.status.success { color: var(--success); }

.hidden { display: none !important; }

.info-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 18px;
    margin-bottom: 22px;
}

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

#thumbnail {
    width: 100%;
    border-radius: 10px;
    background: #000;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border: 1px solid var(--border);
}

.info-text h2 {
    margin: 0 0 6px;
    font-size: 18px;
    line-height: 1.35;
}

.info-text p {
    margin: 2px 0;
}

.muted { color: var(--muted); font-size: 14px; }

.download-controls {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}

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

.progress-wrapper {
    margin-top: 18px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #f59e0b);
    border-radius: 999px;
    transition: width 0.2s ease;
}

.progress-fill.indeterminate {
    width: 40% !important;
    animation: slide 1.2s linear infinite;
}

@keyframes slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

.progress-label {
    font-size: 13px;
    color: var(--muted);
    margin: 8px 0 0;
}

footer {
    text-align: center;
    margin-top: 40px;
    font-size: 13px;
}

footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Quota pill ─────────────────────────────────────────── */
.quota-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    color: var(--muted);
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.quota-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.quota-pill.low {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.08);
}
.quota-pill.low .dot {
    background: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.quota-pill.exhausted {
    color: var(--error);
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.08);
}
.quota-pill.exhausted .dot {
    background: var(--error);
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

/* ── Paywall modal ──────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 7, 10, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fade-in 0.18s ease-out;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px 26px 22px;
    max-width: 460px;
    width: calc(100% - 32px);
    box-shadow: var(--shadow);
    animation: pop-in 0.22s cubic-bezier(0.2, 0.8, 0.3, 1.2);
    position: relative;
}

/* ── Auth modal redesign ────────────────────────────────── */
.modal-auth {
    max-width: 420px;
    padding: 32px 32px 20px;
    background: linear-gradient(180deg, #1c2029 0%, var(--card) 60%);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--muted);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.auth-header {
    text-align: center;
    margin-bottom: 22px;
}

.auth-logo {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    background: linear-gradient(135deg, var(--accent) 0%, #f59e0b 100%);
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.35);
}

.auth-header h2 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.auth-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
}

.modal h2 {
    margin: 0 0 8px;
    font-size: 20px;
    letter-spacing: -0.01em;
}

.plan-bullets {
    list-style: none;
    padding: 0;
    margin: 16px 0;
}

.plan-bullets li {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
}

.plan-bullets strong { color: var(--accent); }

.small { font-size: 12px; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

button.ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}
button.ghost:hover:not(:disabled) {
    background: var(--card-hover);
    color: var(--text);
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pop-in {
    from { transform: scale(0.94); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ── Topbar / auth ──────────────────────────────────────── */
.topbar {
    background: rgba(15, 17, 21, 0.85);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-inner {
    max-width: 1024px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    color: var(--accent);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.auth-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-actions button {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
}

.user-email {
    color: var(--text);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tier-badge {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tier-badge.pro {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, 0.4);
}

.tier-badge.premium {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.4);
}

/* ── Auth form ──────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 22px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.tab {
    flex: 1;
    background: transparent;
    color: var(--muted);
    border: none;
    border-radius: 9px;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}

.tab.active {
    color: var(--text);
    background: var(--card-hover);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset,
                0 4px 10px rgba(0, 0, 0, 0.25);
}

.tab:hover:not(.active) { color: var(--text); }

#auth-form .field {
    margin-bottom: 14px;
}

#auth-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap .input-icon {
    position: absolute;
    left: 14px;
    color: var(--muted);
    pointer-events: none;
    transition: color 0.15s;
}

.input-wrap input {
    width: 100%;
    background: #0c0e12;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px 12px 42px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrap input::placeholder {
    color: #4a505b;
}

.input-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

.input-wrap input:focus ~ .input-icon,
.input-wrap:focus-within .input-icon {
    color: var(--accent);
}

.input-action {
    position: absolute;
    right: 6px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--muted);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.input-action:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.field-hint {
    margin: 6px 2px 0;
    font-size: 12px;
    color: var(--muted);
}

.btn-block {
    width: 100%;
    margin-top: 6px;
    padding: 13px 18px;
    font-size: 14px;
}

#auth-error {
    margin: 12px 0 0;
}

#auth-error:empty {
    margin: 0;
    min-height: 0;
}

.auth-footer {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.auth-footer svg {
    color: var(--success);
    flex-shrink: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

/* ── Verification banner ────────────────────────────────── */
.verify-banner {
    background: rgba(251, 191, 36, 0.08);
    border-bottom: 1px solid rgba(251, 191, 36, 0.3);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 13px;
    color: #fbbf24;
}

.verify-banner svg { flex-shrink: 0; }

.banner-btn {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.banner-btn:hover { background: rgba(251, 191, 36, 0.25); }

.banner-close {
    background: transparent;
    border: none;
    color: #fbbf24;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
    margin-left: auto;
}
.banner-close:hover { opacity: 1; }

/* ── Forgot password / link button ─────────────────────── */
.link-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    transition: color 0.15s;
}
.link-btn:hover { color: var(--accent); }

/* ── Upgrade plan cards (paywall) ───────────────────────── */
.upgrade-plans {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

@media (max-width: 400px) {
    .upgrade-plans { grid-template-columns: 1fr; }
}

.upgrade-plan-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.05s;
    text-align: left;
}

.upgrade-plan-btn:hover {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.upgrade-plan-btn--featured {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.06);
}

.upgrade-plan-btn--featured:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--accent);
}

.upgrade-plan-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.upgrade-plan-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.upgrade-plan-price small {
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}

.upgrade-plan-desc {
    font-size: 12px;
    color: var(--muted);
}
