*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-input: #12151e;
    --border: #2a2f3e;
    --text: #e8eaed;
    --text-muted: #9aa0b0;
    --primary: #4f7cff;
    --primary-hover: #3d6aef;
    --facebook: #1877f2;
    --instagram: #e1306c;
    --error: #ff6b6b;
    --success: #51cf66;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1.1rem;
}

.logo-icon {
    background: var(--primary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.nav {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text);
    background: rgba(79, 124, 255, 0.1);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.main {
    flex: 1;
    padding: 2rem 0 3rem;
}

/* Auth */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: radial-gradient(ellipse at top, rgba(79, 124, 255, 0.08), transparent 60%);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.auth-hint {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.auth-hint code {
    background: var(--bg-input);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="url"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    width: 100%;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-download {
    background: var(--success);
    color: #0f1117;
    min-width: 140px;
}

.btn-download:hover {
    filter: brightness(1.1);
}

/* Hero */
.hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.hero p {
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Platform cards */
.platform-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.platform-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.25s;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.platform-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.platform-facebook:hover {
    border-color: var(--facebook);
}

.platform-instagram:hover {
    border-color: var(--instagram);
}

.platform-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.platform-facebook .platform-icon {
    background: rgba(24, 119, 242, 0.15);
    color: var(--facebook);
}

.platform-instagram .platform-icon {
    background: rgba(225, 48, 108, 0.15);
    color: var(--instagram);
}

.platform-card h2 {
    font-size: 1.25rem;
}

.platform-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    flex: 1;
}

.platform-cta {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Info cards */
.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.info-card h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.info-card ol,
.info-card ul {
    padding-left: 1.25rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.info-card li {
    margin-bottom: 0.35rem;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-header-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.platform-header-facebook .page-header-icon {
    background: rgba(24, 119, 242, 0.15);
    color: var(--facebook);
}

.platform-header-instagram .page-header-icon {
    background: rgba(225, 48, 108, 0.15);
    color: var(--instagram);
}

.page-header h1 {
    font-size: 1.5rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Download panel */
.download-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    gap: 0.75rem;
}

.input-group input {
    flex: 1;
}

.form-hint {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-top: 1rem;
}

.alert-error {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: var(--error);
}

.hidden {
    display: none !important;
}

/* Results */
.results {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.result-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.result-thumb {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.result-header h2 {
    font-size: 1.1rem;
    line-height: 1.4;
}

.result-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.result-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.result-link-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.quality-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.quality-icon {
    width: 40px;
    height: 40px;
    background: rgba(79, 124, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.quality-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.quality-type {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--text);
}

/* Loader */
.btn-loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Footer */
.footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 640px) {
    .header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 0.75rem 0;
    }

    .nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .input-group {
        flex-direction: column;
    }

    .result-link-item {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .quality-badge {
        justify-content: center;
    }

    .btn-download {
        width: 100%;
    }
}
