:root {
    --bg-color: #0f111a;
    --text-primary: #e0e6ed;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --input-bg: rgba(15, 23, 42, 0.6);
    --user-msg-bg: #2563eb;
    --bot-msg-bg: rgba(51, 65, 85, 0.5);
    --font-main: 'Inter', sans-serif;
    --font-tc: 'Noto Sans TC', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main), var(--font-tc);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Effects */
.background-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: float 10s infinite ease-in-out;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.3) 0%, rgba(0, 0, 0, 0) 70%);
    top: -50px;
    left: -50px;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, rgba(0, 0, 0, 0) 70%);
    bottom: -100px;
    right: -100px;
    animation-delay: -5s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(20px, 30px);
    }
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 1000px;
    /* Wider for code blocks */
    height: 100%;
    max-height: 100vh;
    /* Full height on mobile */
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    border-left: 1px solid var(--glass-border);
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

@media (min-width: 768px) {
    .app-container {
        height: 95vh;
        max-width: 95%;
        /* Wider on desktop */
        max-height: 95vh;
        border-radius: 20px;
        border: 1px solid var(--glass-border);
    }
}

@media (min-width: 1400px) {
    .app-container {
        max-width: 1400px;
        /* Cap width for very large screens */
    }
}

/* Header */
.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.3);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    color: var(--accent-primary);
    width: 32px;
    height: 32px;
}

.logo-area h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.model-badge {
    font-size: 0.75rem;
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    vertical-align: middle;
    margin-left: 0.25rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444;
    /* Default red */
    box-shadow: 0 0 5px #ef4444;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.status-indicator.connected .status-dot {
    background-color: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.welcome-message {
    text-align: center;
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    opacity: 0.8;
}

.welcome-message h2 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
    color: var(--text-primary);
}

/* Messages */
.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.message.user .avatar {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    box-shadow: 0 2px 10px rgba(168, 85, 247, 0.3);
}

.message.bot .avatar {
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.message-content {
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    font-size: 0.95rem;
    word-break: break-word;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--user-msg-bg);
    color: white;
    border-bottom-right-radius: 2px;
}

.message.bot .message-content {
    background: var(--bot-msg-bg);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 2px;
}

/* Markdown Styling within bot messages */
.message-content p {
    margin-bottom: 0.75em;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content pre {
    background: #0d1117;
    /* Github dark dimmed */
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85em;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2em 0.4em;
    border-radius: 4px;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    font-size: 0.9em;
}

/* Input Area */
.input-area {
    padding: 1.5rem;
    padding-top: 0;
    background: linear-gradient(to top, var(--bg-color) 20%, transparent);
    /* Gradient fade */
    position: relative;
    z-index: 10;
}

.input-glass-container {
    background: var(--input-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.input-glass-container:focus-within {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    padding: 0.75rem 0;
    max-height: 200px;
    outline: none;
}

#user-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.send-btn:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    background: #475569;
    cursor: not-allowed;
    opacity: 0.7;
}

.disclaimer {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    opacity: 0.6;
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #1e293b;
    border: 1px solid var(--glass-border);
    padding: 2rem;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: #ef4444;
}

.modal-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal-content li {
    margin-bottom: 0.5rem;
}

.primary-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    width: 100%;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: #2563eb;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.input-group input {
    width: 100%;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: white;
    border-radius: 4px;
}