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

:root {
    --primary-color: #5046e4;
    --primary-hover: #4338ca;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-sm: 4px;
}

body {
    font-family: 'Söhne', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

/* Site Header */
.site-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.site-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.menu-button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.menu-button:hover {
    color: var(--text-primary);
}

/* Dropdown Menu Styles */
.dropdown-menu {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 100%;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.dropdown-menu.open {
    right: 0;
}

.menu-container {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.menu-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.menu-logo {
    height: 40px;
}

.close-menu {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.close-menu:hover {
    color: var(--primary-color);
}

.menu-content {
    flex: 1;
    padding: 30px 20px;
}

.menu-section {
    margin-bottom: 35px;
}

.menu-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-list li {
    margin-bottom: 10px;
}

.menu-list a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    display: block;
    padding: 8px 0;
    transition: all 0.2s;
}

.menu-list a:hover {
    color: var(--primary-color);
    padding-left: 10px;
}

.menu-footer {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid var(--border-color);
}

.menu-footer .copyright {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
}

.menu-footer .tagline {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* Overlay for menu */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.menu-overlay.show {
    display: block;
    opacity: 1;
}

/* Main Content */
.main-content {
    position: fixed;
    top: 57px; /* Height of header */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background: white;
    padding: 0;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

/* Chat Container as Article Card */
.chat-container {
    background: white;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.article-header {
    padding: 32px 24px;
    border-bottom: 1px solid var(--border-color);
    background: white;
    text-align: center;
}

.category-badge {
    display: none;
}

.article-header h2 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.article-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.read-time {
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-indicator {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    background: #e8f5e9;
    color: #2e7d32;
    font-weight: 500;
    transition: all 0.3s ease;
}

.status-indicator.loading {
    background: #fff3e0;
    color: #e65100;
}

.status-indicator.error {
    background: #ffebee;
    color: #c62828;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    scroll-behavior: smooth;
    width: 100%;
    box-sizing: border-box;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Messages */
.message {
    margin-bottom: 20px;
    padding: 0;
    display: flex;
    animation: fadeIn 0.3s ease;
    width: 100%;
}

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

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

.message.user {
    justify-content: flex-start;
}

.message.assistant {
    justify-content: flex-start;
    width: 100%;
}

.message-content {
    max-width: 100%;
    padding: 0;
    line-height: 1.75;
    word-wrap: break-word;
    font-size: 16px !important;
    letter-spacing: 0;
}

.message.user .message-content {
    background: #f3f4f6;
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    margin-right: auto;
    max-width: 85%;
    font-size: 16px !important;
    border: 1px solid #e5e7eb;
}

.message.assistant .message-content {
    color: var(--text-primary);
    padding: 12px 0;
    background: transparent;
    border: none;
    font-size: 16px !important;
    width: 100% !important;
    max-width: 100% !important;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 8px;
}

/* Question Options in Chat */
.questions-message {
    margin-bottom: 16px;
    padding: 0;
    width: 100%;
}

/* Google Related Searches Container */
.google-related-searches {
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.questions-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 100%;
}

.question-option {
    padding: 12px 16px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px !important;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
    line-height: 1.5;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.question-option:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    transform: translateX(4px);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.question-option:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.question-option.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Google Related Searches Label - Only style our label, not Google's unit */
.related-searches-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* DO NOT STYLE #relatedsearches1 or its contents - Google handles this */
/* Styling Google's ad units violates their policies */

/* Prefilled input animation */
.message-input.prefilled {
    animation: prefillPulse 0.5s ease;
    border-color: #667eea !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

@keyframes prefillPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

/* Code Blocks */
.message-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 14px;
}

.message-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', monospace;
    color: #e01e5a;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Chat Input */
.chat-input-container {
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    position: relative;
    width: 100%;
    max-width: 100%;
}

.message-input {
    flex: 1;
    min-width: 0; /* Prevent flex item from overflowing */
    width: 100%; /* Explicit width constraint */
    max-width: 100%; /* Never exceed container */
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    max-height: 120px;
    line-height: 1.5;
    background: white;
    box-sizing: border-box; /* Include padding in width calculation */
}

.message-input:focus:not(:disabled) {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(80, 70, 228, 0.1);
}

.message-input:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
    opacity: 0.7;
}

.message-input::placeholder {
    color: var(--text-tertiary);
}

.send-button {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button svg {
    width: 20px;
    height: 20px;
}

.send-button:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(80, 70, 228, 0.25);
}

.send-button:active:not(:disabled) {
    transform: translateY(0);
}

.send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-info {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Typing Status */
.typing-status {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    display: none;
    align-items: center;
    gap: 8px;
}

.typing-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Google AdSense Ads */
.search-ads-wrapper {
    margin: 20px 0;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 100%;
    /* Prevent CLS by reserving space and using opacity instead of display */
    min-height: 150px; /* Reserve minimum space for 1 ad + related searches */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.search-ads-wrapper.loaded {
    opacity: 1;
    visibility: visible;
}

.ads-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    font-weight: 600;
}

/* Google Ad Containers */
/* POLICY COMPLIANT: Only reserve space for CLS prevention, don't style Google's content */
#afscontainer1 {
    min-height: 80px; /* Reserve space to prevent layout shift - this is allowed */
}

/* DO NOT style #relatedsearches1 or its children - Google controls all styling */
/* Policy: https://support.google.com/adsense/answer/1354757 */

/* Test mode indicator */
.search-ads-wrapper[data-test="true"]::before {
    content: '🧪 TEST MODE';
    display: block;
    background: #fef3c7;
    color: #92400e;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 8px;
    width: fit-content;
}

/* Production mode indicator */
.search-ads-wrapper[data-test="false"]::before {
    content: '✅ PRODUCTION ADS';
    display: block;
    background: #d1fae5;
    color: #065f46;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 8px;
    width: fit-content;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-block;
    padding: 8px 0;
    background: transparent;
    border: none;
}

.typing-indicator span {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-tertiary);
    margin: 0 1.5px;
    animation: typing 1.8s infinite ease-in-out;
    opacity: 0.4;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-8px) scale(1.2);
        opacity: 0.8;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .main-content {
        /* padding: 24px 0; */
    }
    
    .page-title {
        font-size: 32px;
    }
    
    /* Mobile dropdown menu */
    .dropdown-menu {
        width: 100%;
        right: -100%;
    }
    
    .article-header h2 {
        font-size: 24px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 15px !important;
    }
    
    .questions-content {
        max-width: 90%;
    }
    
    .question-option {
        padding: 10px 12px;
        font-size: 14px !important;
    }
    
    .ads-content-wrapper {
        max-width: 95%;
        padding: 16px;
    }
    
    .chat-input-container {
        padding: 16px;
        position: relative; /* Ensure proper positioning on mobile */
    }

    .input-wrapper {
        gap: 8px; /* Reduce gap on mobile for more space */
    }

    .message-input {
        padding: 10px 12px;
        font-size: 16px; /* iOS requires 16px to prevent auto-zoom */
        -webkit-text-size-adjust: 100%; /* Prevent iOS text size adjustment */
        touch-action: manipulation; /* Improve touch responsiveness */
    }

    .send-button {
        width: 40px;
        height: 40px;
        flex-shrink: 0; /* Never shrink button on mobile */
    }

    .send-button svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .header-container {
        padding: 12px 16px;
    }
    
    .site-logo {
        width: 28px;
        height: 28px;
    }
    
    .site-name {
        font-size: 18px;
    }
    
    .page-title {
        font-size: 28px;
    }
    
    .article-header {
        padding: 16px;
    }
    
    .article-header h2 {
        font-size: 20px;
    }
    
}