:root {
    /* Color Palette - DJ Myungri Inspired */
    --bg-dark: #0a0a0c;
    --bg-panel: #141417;
    --bg-chat: #0a0a0c;
    --accent-primary: #8A2BE2;
    /* Neon Purple */
    --accent-glow: rgba(138, 43, 226, 0.4);
    --accent-secondary: #00E5FF;

    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;

    --border-color: #2a2a2e;

    /* 5 Elements Colors */
    --wood: #4caf50;
    /* Green */
    --fire: #f44336;
    /* Red */
    --earth: #ff9800;
    /* Brown/Orange */
    --metal: #9e9e9e;
    /* Silver/Gray */
    --water: #2196f3;
    /* Blue */

    --font-main: 'Inter', sans-serif;
    --font-serif: 'Noto Serif KR', serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
}

/* API Key Input Section (New) */
.api-key-section {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.key-input-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.mini-input {
    background: #1e1e24;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.4rem;
    color: #fff;
    font-size: 0.8rem;
    width: 100%;
}

.icon-btn {
    background: var(--accent-primary);
    border: none;
    border-radius: 6px;
    color: #fff;
    width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-btn:hover {
    background: #6a0dad;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.brand {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-primary);
}

.user-mini-profile {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.avatar {
    width: 36px;
    height: 36px;
    background: #2a2a2e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-weight: 600;
}

.user-info h3 {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Markdown Styling inside Bubbles */
.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4 {
    margin: 1.2rem 0 0.6rem 0;
    color: var(--accent-primary);
    font-family: var(--font-serif);
}

.bubble h1:first-child,
.bubble h2:first-child,
.bubble h3:first-child {
    margin-top: 0;
}

.bubble p {
    margin-bottom: 0.8rem;
    line-height: 1.6;
}

.bubble p:last-child {
    margin-bottom: 0;
}

.bubble ul,
.bubble ol {
    margin-bottom: 1rem;
    padding-left: 1.2rem;
}

.bubble li {
    margin-bottom: 0.4rem;
}

.bubble strong {
    color: var(--accent-secondary);
    font-weight: 600;
}

.bubble hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1.5rem 0;
}

.ai-message .bubble {
    color: rgba(255, 255, 255, 0.9);
}

.user-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.section-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    font-family: var(--font-serif);
}

/* Saju Grid Matrix */
.saju-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto auto auto;
    gap: 8px;
    margin-bottom: 2rem;
}

.grid-header {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-bottom: 4px;
    font-family: var(--font-serif);
}

.pillar-box {
    aspect-ratio: 1;
    background: #1e1e24;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    border: 1px solid var(--border-color);
    position: relative;
    transition: all 0.3s;
}

.pillar-box.day-master {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
}

/* Element Colors Classes */
.wood {
    color: var(--wood) !important;
    border-color: rgba(76, 175, 80, 0.3);
}

.fire {
    color: var(--fire) !important;
    border-color: rgba(244, 67, 54, 0.3);
}

.earth {
    color: var(--earth) !important;
    border-color: rgba(255, 152, 0, 0.3);
}

.metal {
    color: var(--metal) !important;
    border-color: rgba(158, 158, 158, 0.3);
}

.water {
    color: var(--water) !important;
    border-color: rgba(33, 150, 243, 0.3);
}

.analysis-card {
    background: linear-gradient(135deg, rgba(30, 30, 36, 0.5), rgba(138, 43, 226, 0.1));
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.analysis-card h4 {
    font-size: 0.9rem;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-serif);
}

.analysis-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.sidebar-nav {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--accent-primary);
    color: #fff;
}

/* Chat Interface */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-chat);
}

.chat-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agent-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.agent-avatar {
    width: 42px;
    height: 42px;
    background: #1e1e24;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
}

.agent-info h3 {
    font-size: 1rem;
    font-weight: 600;
}

.status-indicator {
    font-size: 0.75rem;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 50%; /* 채팅 영역의 절반 정도 차지 */
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user-message {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message.ai-message {
    margin-right: auto;
}

.bubble {
    padding: 1rem 1.2rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.ai-message .bubble {
    background: #1e1e24;
    border: 1px solid var(--border-color);
    border-top-left-radius: 0;
}

.user-message .bubble {
    background: var(--accent-primary);
    color: #fff;
    border-top-right-radius: 0;
}

/* Chat Input Area */
.chat-input-area {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
}

.suggestion-chips {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.suggestion-chips button {
    background: #1e1e24;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.suggestion-chips button:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.input-wrapper {
    display: flex;
    gap: 0.8rem;
    background: #1e1e24;
    padding: 0.5rem;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    align-items: center;
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.5rem;
    color: white;
}

.input-wrapper input:focus {
    box-shadow: none;
    outline: none;
}

.send-btn,
.attach-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
}

.attach-btn {
    background: transparent;
    color: var(--text-secondary);
}

.send-btn {
    background: var(--accent-primary);
    color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

/* Markdown Styling in Chat */
.markdown-body {
    color: inherit;
    font-family: inherit;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.markdown-body strong {
    color: var(--accent-secondary);
}

.markdown-body ul {
    padding-left: 1.5rem;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}