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

:root {
    --primary-color: #3b5998;
    --primary-hover: #2d4373;
    --primary-light: #4a6ca8;
    --secondary-color: #4285f4;
    --text-primary: #1c1c1e;
    --text-secondary: #86868b;
    --text-white: #f5f5f7;
    --background: #f5f5f7;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --border: #e5e5e7;
    --border-light: #d2d2d7;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-elevated: rgba(0, 0, 0, 0.15);
    --gradient: linear-gradient(135deg, #3b5998 0%, #4a6ca8 100%);
    --success: #4CAF50;
    --error: #F44336;
    --warning: #FFC107;
    --info: #2196F3;
}

[data-theme="dark"], body.dark {
    --primary-color: #4a6ca8;
    --primary-hover: #5a7bb8;
    --primary-light: #6a8bc8;
    --secondary-color: #5a9fd4;
    --text-primary: #f5f5f7;
    --text-secondary: #8e8e93;
    --background: #1c1c1e;
    --surface: #2c2c2e;
    --surface-elevated: #3a3a3c;
    --border: #3a3a3c;
    --border-light: #333333;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-elevated: rgba(0, 0, 0, 0.4);
    --gradient: linear-gradient(135deg, #4a6ca8 0%, #5a9fd4 100%);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 40px 24px;
}

.container-wide {
    max-width: 800px;
}

.logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-align: center;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    text-align: center;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-weight: 500;
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 89, 152, 0.1);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
    color: var(--text-secondary);
}

.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 89, 152, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 89, 152, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.btn-google {
    background: #4285f4;
    color: white;
    margin-top: 12px;
}

.btn-google:hover:not(:disabled) {
    background: #3367d6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.btn-google svg {
    width: 18px;
    height: 18px;
}

.divider {
    margin: 24px 0;
    text-align: center;
    position: relative;
    color: var(--text-secondary);
    font-size: 14px;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
    z-index: 1;
}

.divider span {
    background: var(--background);
    padding: 0 15px;
    position: relative;
    z-index: 2;
}

.link {
    font-size: 13px;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.link:hover {
    text-decoration: underline;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 20px;
    text-align: center;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    border: 1px solid #ffcdd2;
}

.error-message.show {
    opacity: 1;
}

body.dark .error-message {
    background: #3a1d1d;
    color: #ff6b6b;
    border-color: #5a2d2d;
}

.success-message {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 20px;
    text-align: center;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    border: 1px solid #c8e6c9;
}

.success-message.show {
    opacity: 1;
}

body.dark .success-message {
    background: #1d3a1d;
    color: #81c784;
    border-color: #2d5a2d;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.quota-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.quota-fill {
    height: 100%;
    background: var(--gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.quota-fill.premium {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
}

.quota-fill.warning {
    background: linear-gradient(135deg, #FFC107 0%, #FF9800 100%);
}

.quota-fill.critical {
    background: linear-gradient(135deg, #F44336 0%, #E91E63 100%);
}

.quota-numbers {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

.character-counter {
    display: flex;
    justify-content: flex-end;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.character-counter.warning {
    color: var(--warning);
}

.character-counter.error {
    color: var(--error);
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title img {
    width: 32px;
    height: 32px;
}

.header-title h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    color: var(--primary-color);
    background: transparent;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.auth-btn:hover {
    background: var(--surface-elevated);
    border-color: var(--primary-color);
}

.auth-btn-primary {
    background: var(--gradient);
    color: white;
    border: none;
}

.auth-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 89, 152, 0.3);
}

.profile-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.profile-icon:hover {
    transform: scale(1.05);
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--surface-elevated);
    border-color: var(--primary-color);
}

.version-info {
    text-align: center;
    margin-top: 24px;
    font-size: 11px;
    color: var(--text-secondary);
}

.premium-banner {
    background: linear-gradient(135deg, #ff8e8e, #ff6b6b);
    color: white;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.premium-banner:hover {
    transform: translateY(-2px);
}

.premium-banner-text {
    font-size: 14px;
}

.premium-banner-btn {
    background: white;
    color: #ff6b6b;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px var(--shadow-elevated);
}

body.modal-open {
    overflow: hidden;
}

@media (max-width: 480px) {
    .container {
        padding: 24px 16px;
    }

    h1 {
        font-size: 24px;
    }

    .btn {
        padding: 14px;
        font-size: 15px;
    }

    .card {
        padding: 20px;
    }

    .premium-banner {
        flex-direction: column;
        text-align: center;
    }

    .header-actions {
        gap: 8px;
    }

    .auth-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .header-title h2 {
        display: none;
    }
}
