:root {
    --primary-color: #4a4e69;
    --accent-color: #9a8c98;
    --bg-gradient-start: #f2e9e4;
    --bg-gradient-end: #c9ada7;
    --chat-bg: rgba(255, 255, 255, 0.85);
    --bot-msg-bg: #ffffff;
    --user-msg-bg: #22223b;
    --user-msg-text: #ffffff;
    --text-color: #22223b;
    --border-radius: 16px;
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    --intro-title-color: #4a4e69;
    /* Matched to primary */
    --list-bullet-color: #9a8c98;
    /* Matched to accent */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Pretendard', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.background-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('https://www.transparenttextures.com/patterns/cubes.png');
    opacity: 0.2;
    z-index: -1;
}

.chat-container {
    width: 100%;
    max-width: 600px;
    /* PC */
    height: 90vh;
    background: var(--chat-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out;
}

@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        border-radius: 0;
    }
}

.chat-header {
    background: rgba(255, 255, 255, 0.5);
    padding: 10px 20px;
    /* Reduced vertical padding */
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-header h1 {
    font-family: 'Noto Serif KR', serif;
    font-size: 1.5rem;
    color: var(--text-color);
    margin-bottom: 5px;
}

.chat-header p {
    font-size: 0.75rem;
    /* Reduced font size */
    color: var(--primary-color);
    opacity: 0.8;
}


.chat-window {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Intro Modal Overlay Styles */
.intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.intro-container {
    max-width: 90%;
    width: 400px;
    padding: 30px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.4s ease-out;
    cursor: pointer;
    position: relative;
}

.intro-container::after {
    content: "화면을 터치하면 닫힙니다";
    display: block;
    text-align: center;
    font-size: 0.8rem;
    color: #999;
    margin-top: 20px;
    pointer-events: none;
}

.intro-title {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--intro-title-color);
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Noto Serif KR', serif;
    text-align: center;
}

.intro-list {
    list-style: none;
    padding: 0;
    font-size: 15px;
    color: #444746;
    line-height: 1.8;
}

.intro-list li {
    margin-bottom: 6px;
    padding-inline-start: 20px;
    position: relative;
}

.intro-list li::before {
    content: "•";
    position: absolute;
    inset-inline-start: 0;
    color: var(--list-bullet-color);
    font-size: 1.2em;
}

.version-info {
    font-size: 12px;
    color: #9aa0a6;
    margin-top: 15px;
    border-top: 1px solid #eee;
    padding-top: 10px;
    line-height: 1.5;
    text-align: center;
}

.message {
    max-width: 85%;
    display: flex;
    animation: slideUp 0.3s ease-out;
}

/* Restore missing base styles */
.message-content {
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-word;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.bot-message {
    align-self: flex-start;
    max-width: 100%;
    width: 100%;
    margin-bottom: 5px;
    padding: 0 10px;
}

.bot-message .message-content {
    border-radius: 12px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid #f0f0f0;
}

.user-message {
    align-self: flex-end;
    /* user message always on end (right in LTR, left in RTL) ?? 
       Actually standard UI: User Right (LTR). In RTL User Left.
       align-self: flex-end handles this automatically if direction is correct. */
    flex-direction: row-reverse;
    /* row-reverse might be tricky in RTL. 
       If base is row, reverse is right-to-left. 
       In RTL, base is right-to-left, reverse is left-to-right.
       If we want icon/content swapped */

    margin-inline-end: 20px;
    margin-inline-start: 20px;
    max-width: 85%;
}

.user-message .message-content {
    background: var(--user-msg-bg);
    color: var(--user-msg-text);
    border-bottom-right-radius: 4px;
    /* Physical radius might need logical equivalent if supported or override */
}

/* Fix for RTL border radius corner */
html[dir="rtl"] .user-message .message-content {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 16px;
}

.input-area {
    padding: 12px 20px 60px 20px;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 24px;
    padding: 5px 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    padding: 12px 5px;
    font-family: 'Pretendard', sans-serif;
    font-size: 1rem;
    max-height: 100px;
    background: transparent;
}

#send-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary-color);
    padding: 10px;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-btn:hover {
    transform: scale(1.1);
    color: var(--user-msg-bg);
}

/* Flip send button in RTL */
html[dir="rtl"] #send-btn {
    transform: scaleX(-1);
}

html[dir="rtl"] #send-btn:hover {
    transform: scaleX(-1) scale(1.1);
}

.disclaimer {
    font-size: 0.75rem;
    color: #888;
    text-align: center;
    margin-top: 10px;
}

/* Typography for citations */
.citation-btn {
    margin-top: 10px;
    padding: 6px 14px;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 15px;
    background: #fff;
    cursor: pointer;
    color: #666;
    transition: background 0.2s;
}

.citation-btn:hover {
    background: #f0f0f0;
}

.citation-content {
    display: none;
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 13px;
    border-inline-start: 3px solid var(--accent-color);
    white-space: pre-wrap;
    color: #444;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Markdown Styles within Message */
.message-content strong {
    font-weight: 600;
}

.message-content h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
    margin-top: 10px;
}

.message-content ul,
.message-content ol {
    padding-inline-start: 20px;
    margin-bottom: 10px;
}

.message-content p {
    margin-bottom: 8px;
}

/* Language Selector */
.language-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.lang-btn {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #444;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.4;
    font-family: 'Pretendard', sans-serif;
    min-width: 60px;
}

.lang-btn:hover {
    background: #fff;
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.lang-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.intro-highlight {
    font-weight: 600;
    color: var(--primary-color);
    list-style: none;
    margin-top: 30px;
    /* Increased from 10px */
}

.intro-highlight::before {
    content: "" !important;
    /* Remove bullet for this item */
}

.intro-notice {
    font-size: 0.85rem;
    /* Smaller font size */
    color: #666;
    /* Slightly lighter color */
    line-height: 1.4;
    margin-top: 5px;
}

/* Recommendation Links */
.rec-link {
    cursor: pointer;
    color: #1a0dab;
    /* Standard link blue */
    text-decoration: none;
    transition: opacity 0.2s;
    font-weight: 500;
}

.rec-link:hover {
    text-decoration: underline;
    /* Optional: add underline on hover for affordance */
    opacity: 1;
}

/* Loading Animation */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    opacity: 0.8;
}

.typing-dots::before {
    content: "";
    width: 12px;
    height: 12px;
    border: 2px solid #ccc;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}