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

body {
    font-family: 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
    font-size: 18px;
    line-height: 1.6;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

header {
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    position: relative;
}

header h1 {
    font-size: 1.4em; /* Reduced from 2.2em to prevent overflow */
    margin-bottom: 10px;
    line-height: 1.2; /* Better line height for wrapping if needed */
    text-align: center; /* Keep title centered */
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
    text-align: left; /* Changed from center to left alignment */
    margin-top: 8px; /* Add some spacing from title */
    padding: 0 5px; /* Add slight padding for better spacing */
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 60vh;
    border: 2px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafafa;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 10px;
    max-width: 80%;
}

.message.user {
    background: #e3f2fd;
    margin-left: auto;
    text-align: right;
}

.message.assistant {
    background: #f3e5f5;
    margin-right: auto;
}

.message p {
    font-size: 1.1em;
    line-height: 1.5;
}

.input-section {
    background: white;
    padding: 20px;
    border-top: 1px solid #ddd;
}

.quick-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.quick-btn {
    padding: 12px 20px;
    font-size: 1em;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.quick-btn:hover {
    background: #667eea;
    color: white;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 15px;
    font-size: 1.1em;
    border: 2px solid #ddd;
    border-radius: 10px;
    resize: vertical;
    min-height: 60px;
    -webkit-appearance: none;
    appearance: none;
}

#sendButton {
    padding: 15px 25px;
    font-size: 1.1em;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#sendButton:hover {
    background: #5a67d8;
}

.hidden {
    display: none;
}

.loading {
    opacity: 0.7;
    pointer-events: none;
}

.error {
    background: #ffebee !important;
    color: #c62828;
}

/* Mobile-first responsive design - Senior-friendly text sizes */
@media (max-width: 768px) {
    body {
        font-size: 20px; /* Increased from 16px for seniors */
    }
    
    .container {
        padding: 10px;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
    
    header {
        margin-bottom: 20px;
        padding: 15px;
        border-radius: 8px;
    }
    
    header h1 {
        font-size: 1.4em; /* Reduced from 2.2em to prevent overflow on mobile */
        margin-bottom: 8px;
        line-height: 1.2; /* Better line height for Korean text */
        text-align: center; /* Keep title centered on mobile too */
    }
    
    header p {
        font-size: 1.2em; /* Increased from 1em for seniors */
        text-align: left; /* Changed from center to left alignment */
        margin-top: 6px; /* Add spacing on mobile */
        padding: 0 3px; /* Add slight padding for mobile */
    }
    
    .chat-container {
        height: 50vh;
        border-radius: 8px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message {
        margin-bottom: 15px;
        padding: 12px;
        max-width: 90%;
        border-radius: 8px;
    }
    
    .message p {
        font-size: 1.2em; /* Increased from 1em for better readability */
    }
    
    .input-section {
        padding: 15px;
    }
    
    .quick-buttons {
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .quick-btn {
        padding: 12px 20px; /* Increased padding for easier tapping */
        font-size: 1.1em; /* Increased from 0.9em for better readability */
        border-radius: 20px;
        min-width: auto;
        flex: 1;
        min-height: 50px; /* Increased from 44px for easier touch targets */
    }
    
    .input-container {
        gap: 8px;
    }
    
    #messageInput {
        padding: 15px; /* Increased padding for comfort */
        font-size: 1.2em; /* Increased from 1em for better readability */
        min-height: 60px; /* Increased for easier interaction */
        border-radius: 8px;
    }
    
    #sendButton {
        padding: 15px 25px; /* Increased padding for easier tapping */
        font-size: 1.2em; /* Increased from 1em for better readability */
        border-radius: 8px;
        min-width: 90px; /* Increased for easier touch targets */
        min-height: 50px; /* Increased from 44px for easier touch targets */
    }
}

/* Extra small screens - Senior-friendly */
@media (max-width: 480px) {
    body {
        font-size: 18px; /* Increased from 14px - much larger for seniors */
    }
    
    .container {
        padding: 8px;
    }
    
    header {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    header h1 {
        font-size: 1.4em; /* Reduced from 2em to prevent overflow on small screens */
        line-height: 1.2; /* Better line height for Korean text */
    }
    
    .chat-container {
        height: 45vh;
    }
    
    .chat-messages {
        padding: 10px;
    }
    
    .message {
        margin-bottom: 12px;
        padding: 10px;
        max-width: 95%;
    }
    
    .input-section {
        padding: 10px;
    }
    
    .quick-buttons {
        gap: 6px;
        margin-bottom: 10px;
    }
    
    .quick-btn {
        padding: 10px 16px; /* Increased padding for easier touch */
        font-size: 1em; /* Increased from 0.8em for better readability */
        border-radius: 16px;
        min-height: 50px; /* Increased from 44px for easier touch targets */
    }
    
    .input-container {
        gap: 6px;
    }
    
    #messageInput {
        padding: 12px;
        font-size: 1.1em; /* Increased from 0.9em for better readability */
        min-height: 55px; /* Increased from 45px for easier interaction */
    }
    
    #sendButton {
        padding: 12px 20px; /* Increased padding for easier tapping */
        font-size: 1.1em; /* Increased from 0.9em for better readability */
        min-width: 80px; /* Increased from 70px for easier touch targets */
        min-height: 50px; /* Increased from 44px for easier touch targets */
    }
}

/* Landscape mobile optimization - Senior-friendly */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-container {
        height: 35vh;
    }
    
    .quick-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px; /* Increased gap for easier touch */
    }
    
    .quick-btn {
        padding: 8px 16px; /* Increased padding for easier touch */
        font-size: 1em; /* Increased from 0.85em for better readability */
    }
}

/* Improved focus states for accessibility */
.quick-btn:focus, #sendButton:focus, #messageInput:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Better input handling on mobile - Senior-friendly font size */
@media (max-width: 768px) {
    #messageInput {
        font-size: 18px; /* Increased from 16px to prevent zoom on iOS and improve readability */
    }
}