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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --accent-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 50%, #f0f4f8 100%);
    min-height: 100vh;
    padding-bottom: 0;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Navigation - Modern Glass Effect */
.top-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 0;
    border-bottom: 1px solid rgba(229, 231, 235, 0.5);
}

.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 18px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h1 {
    font-size: 22px;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 14px;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.nav-link.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.nav-user {
    position: relative;
}

.nav-user .user-button {
    padding: 10px 20px;
    background: var(--secondary-gradient);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
}

.nav-user .user-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    min-width: 220px;
    display: none;
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown.show {
    display: block;
    animation: fadeInScale 0.2s ease-out;
}

.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.dropdown-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.dropdown-item {
    width: 100%;
    padding: 14px 16px;
    background: none;
    border: none;
    text-align: left;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
}

/* Welcome Section - Modern Hero */
.welcome-section {
    max-width: 1600px;
    margin: 0 auto;
    padding: 60px 40px 40px;
}

.welcome-content {
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
}

.welcome-badge {
    display: inline-block;
    padding: 8px 20px;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 24px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    animation: fadeInUp 0.6s ease-out;
}

.welcome-title {
    font-size: 56px;
    font-weight: 800;
    margin-bottom: 24px;
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: -1.5px;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 20px;
    line-height: 1.7;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

/* Container - Modern Card */
.container {
    max-width: 1600px;
    margin: 0 auto 40px;
    background: var(--bg-primary);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(229, 231, 235, 0.5);
    padding: 40px;
    animation: fadeInUp 0.6s ease-out 0.4s both;
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

/* Email Input Section */
.email-input-section {
    display: flex;
    flex-direction: column;
}

.email-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    padding: 6px;
    border-radius: 12px;
}

.email-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.email-tab:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.email-tab.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

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

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

.btn-clear-mini {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.btn-clear-mini:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.email-input-wrapper {
    position: relative;
}

.email-input-wrapper textarea {
    width: 100%;
    min-height: 400px;
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
}

.email-input-wrapper textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.email-input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.email-stats {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-icon {
    font-size: 14px;
}

/* Reply Content */
.reply-content {
    min-height: 400px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 2px solid var(--border-color);
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.reply-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.reply-stats {
    font-size: 13px;
    color: var(--text-muted);
}

.output-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    padding: 10px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-action:hover {
    background: var(--bg-tertiary);
    border-color: #667eea;
    transform: translateY(-1px);
}

/* Reply Section */
.reply-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tone-selection h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.tone-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.tone-card {
    padding: 16px 12px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.tone-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tone-card.active {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tone-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-md);
}

.tone-card span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Reply Options */
.reply-options {
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.reply-options h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.option-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.option-checkbox:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.option-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.option-checkbox span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.custom-instruction-section {
    margin-top: 24px;
}

.custom-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.custom-instruction-section textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: all 0.3s;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.custom-instruction-section textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* Generate Button */
.btn-generate {
    width: 100%;
    padding: 16px 32px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-loader {
    display: none;
}

/* Loading Indicator */
.loading-indicator {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-indicator.show {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.loading-indicator p {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Responsive Design */
@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .tone-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .container {
        padding: 32px;
    }
    
    .welcome-title {
        font-size: 48px;
    }
}

@media (max-width: 768px) {
    .nav-container {
        padding: 16px 24px;
    }
    
    .nav-links {
        gap: 4px;
    }
    
    .nav-link {
        padding: 8px 12px;
        font-size: 13px;
    }

    .welcome-section {
        padding: 40px 24px 30px;
    }
    
    .welcome-title {
        font-size: 36px;
    }
    
    .welcome-subtitle {
        font-size: 17px;
    }

    .container {
        padding: 24px;
        border-radius: 20px;
    }

    .tone-cards {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .email-tabs {
        flex-direction: column;
    }

    .output-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .welcome-title {
        font-size: 28px;
    }
    
    .tone-cards {
        grid-template-columns: 1fr;
    }
}
