:root {
    --primary: #c4a661; /* Premium gold */
    --primary-light: #e2cca6;
    --primary-dark: #a38541;
    --accent: #d4af37; /* Bright gold */
    --accent-hover: #e8c655;
    
    --bg-color: #03050a; /* Pitch black / Deepest navy */
    --surface: #0a0e17; /* Very dark surface */
    --surface-light: #151a25;
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(196, 166, 97, 0.2); /* Faint gold border */
    
    /* Message colors */
    --user-msg-bg: #151a25;
    --user-msg-text: #ffffff;
    --ai-msg-bg: rgba(10, 14, 23, 0.8);
    --ai-msg-text: #e2e8f0;
    
    /* Shadows & Glows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.5);
    --shadow-md: 0 10px 20px rgba(0,0,0,0.8);
    --shadow-lg: 0 20px 40px rgba(0,0,0,0.9);
    --shadow-glow: 0 0 20px rgba(196, 166, 97, 0.15);
    
    /* Radii */
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    
    --font-family: 'Noto Sans JP', serif; /* Switch to serif for more elegance if available, otherwise sans is fine. We will use serif for headings. */
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, rgba(196,166,97,0.08), transparent 500px),
                      radial-gradient(circle at bottom left, rgba(196,166,97,0.03), transparent 500px);
    color: var(--text-main);
    line-height: 1.7;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 850px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: transparent;
    position: relative;
}

@media (min-width: 850px) {
    .app-container {
        height: 90vh;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-glow), var(--shadow-lg);
        overflow: hidden;
        border: 1px solid var(--border);
        background-color: var(--surface);
    }
}

/* Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    background-color: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.avatar-container {
    position: relative;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--primary);
    overflow: hidden;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.title-container h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    letter-spacing: 0.05em;
    font-family: 'Noto Serif JP', 'Noto Sans JP', serif;
}

.status {
    font-size: 0.85rem;
    color: var(--primary-light);
    font-weight: 500;
    letter-spacing: 0.02em;
    opacity: 0.8;
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    background-color: transparent;
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}
.chat-container::-webkit-scrollbar-track {
    background: transparent;
}
.chat-container::-webkit-scrollbar-thumb {
    background-color: rgba(196,166,97,0.3);
    border-radius: 10px;
}
.chat-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(196,166,97,0.5);
}

.message {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.user-message {
    align-self: flex-end;
}

.ai-message {
    align-self: flex-start;
}

.message-content {
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    line-height: 1.8;
    box-shadow: var(--shadow-md);
    word-break: break-word;
}

.user-message .message-content {
    background-color: var(--user-msg-bg);
    color: var(--user-msg-text);
    border-bottom-right-radius: 2px;
    border: 1px solid rgba(255,255,255,0.05);
}

.ai-message .message-content {
    background-color: var(--ai-msg-bg);
    color: var(--ai-msg-text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 2px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5), inset 0 0 20px rgba(196,166,97,0.03);
}

/* Markdown Styles inside AI Message */
.ai-message .message-content p {
    margin-bottom: 1rem;
}
.ai-message .message-content p:last-child {
    margin-bottom: 0;
}
.ai-message .message-content h1, 
.ai-message .message-content h2, 
.ai-message .message-content h3 {
    margin-top: 1.75rem;
    margin-bottom: 1rem;
    color: var(--primary);
    font-weight: 700;
    font-family: 'Noto Serif JP', 'Noto Sans JP', serif;
}
.ai-message .message-content h2 {
    font-size: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}
.ai-message .message-content h3 {
    font-size: 1.1rem;
}
.ai-message .message-content ul, 
.ai-message .message-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1.25rem;
}
.ai-message .message-content li {
    margin-bottom: 0.5rem;
}
.ai-message .message-content strong {
    color: var(--primary-light);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(196,166,97,0.2);
}

/* Loading Animation */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.5rem;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 500;
    background: rgba(10, 14, 23, 0.9);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-glow);
}

.typing-dots {
    display: flex;
    gap: 5px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 8px var(--primary); }
}

/* Input Area */
.input-area {
    padding: 1.25rem 2rem;
    background-color: rgba(10, 14, 23, 0.9);
    border-top: 1px solid var(--border);
    position: relative;
    z-index: 10;
    backdrop-filter: blur(10px);
}

#chat-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    background-color: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.5rem 0.5rem 1.25rem;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

#chat-form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary), inset 0 2px 4px rgba(0,0,0,0.5);
}

#user-input {
    flex: 1;
    border: none;
    background: none;
    padding: 0.5rem 0;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    resize: none;
    max-height: 150px;
    min-height: 28px;
    outline: none;
    line-height: 1.6;
}

#user-input::placeholder {
    color: #475569;
}

.send-btn {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #000;
    border: none;
    border-radius: var(--radius-md);
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-btn svg {
    stroke: #000;
}

.send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(196,166,97,0.3);
}

.send-btn:disabled {
    background: #1e293b;
    color: #475569;
    cursor: not-allowed;
    box-shadow: none;
}
.send-btn:disabled svg {
    stroke: #475569;
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    backdrop-filter: blur(10px);
    opacity: 1;
    transition: opacity 0.4s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.error-message.hidden {
    display: none;
}

.modal-content {
    background-color: var(--surface);
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 30px rgba(196,166,97,0.1);
    transform: translateY(0) scale(1);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border);
    overflow: hidden;
}

.modal.hidden .modal-content {
    transform: translateY(20px) scale(0.95);
}

.modal-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2.5rem 2rem 1.5rem;
    background: linear-gradient(to bottom, rgba(196,166,97,0.05), transparent);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.1em;
    font-family: 'Noto Serif JP', 'Noto Sans JP', serif;
    text-align: center;
}

.modal-body {
    padding: 1rem 2.5rem 3rem;
}

.modal-description {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    text-align: center;
    line-height: 1.6;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    background-color: rgba(0,0,0,0.3);
    color: #fff;
}

.form-group input:focus {
    border-color: var(--primary);
    background-color: rgba(0,0,0,0.5);
    box-shadow: 0 0 0 1px var(--primary);
}

.primary-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #000;
    border: none;
    border-radius: 4px;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.primary-btn:hover {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 8px 20px rgba(196,166,97,0.2);
    transform: translateY(-2px);
}
