:root {
    --bg-primary: #1f1f1f;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --text-primary: #e3e3e3;
    --text-secondary: #b4b4b4;
    --text-tertiary: #8e8e8e;
    --border-color: #3c3c3c;
    --accent-color: #8ab4f8;
    --citation-bg: #5f6368;
    --button-hover: #3c4043;
    --input-bg: #303134;
    --suggestion-bg: #2a2a2a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Google Sans', 'Roboto', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-title {
    font-size: 22px;
    font-weight: 400;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    gap: 4px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--button-hover);
}

/* Chat Content */
.chat-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    scroll-behavior: smooth;
}

.chat-content::-webkit-scrollbar {
    width: 8px;
}

.chat-content::-webkit-scrollbar-track {
    background: transparent;
}

.chat-content::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 20px;
}

.welcome-icon {
    margin-bottom: 24px;
    color: var(--text-tertiary);
    opacity: 0.6;
}

.welcome-screen h2 {
    font-size: 28px;
    font-weight: 400;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-screen p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Messages */
.messages-container {
    max-width: 100%;
}

.message {
    margin-bottom: 32px;
    animation: fadeIn 0.3s ease;
}

.message-user {
    text-align: right;
}

.message-content-wrapper {
    display: inline-block;
    max-width: 80%;
    text-align: left;
    overflow: visible;
}

.message-user .message-content-wrapper {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
}

.message-assistant .message-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    padding-left: 40px;
}

.message-user .message-text {
    color: var(--text-primary);
    font-size: 15px;
}

/* Citation Badges with Tooltips */
.citation {
    display: inline-block;
    background: var(--citation-bg);
    color: white;
    padding: 0px 6px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin: 0 3px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.citation:hover {
    background: #6f7378;
}

.citation-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 13px;
    min-width: 200px;
    max-width: 350px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid var(--border-color);
    white-space: normal;
}

.citation:hover .citation-tooltip {
    opacity: 1;
    pointer-events: auto;
}

.citation-tooltip-file {
    font-weight: 500;
    color: var(--accent-color);
    display: block;
}

.citation-tooltip-content {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

/* Chinese Annotations */
.chinese-text {
    color: var(--text-primary);
    font-weight: 500;
}

.pinyin {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 14px;
    margin-left: 4px;
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    padding: 8px 0 8px 40px;
}

.action-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--button-hover);
    border-color: var(--text-tertiary);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* Suggestions inline with messages */
.message-suggestions {
    margin-top: 16px;
    padding-left: 40px;
}

.suggestion-btn {
    background: var(--suggestion-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 20px;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
    margin-bottom: 8px;
    display: block;
    width: 100%;
}

.suggestion-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-tertiary);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 16px 0 16px 40px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

/* Input Area */
.input-area {
    padding: 16px 20px 20px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.input-form {
    max-width: 100%;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border-radius: 24px;
    padding: 4px 4px 4px 20px;
    gap: 8px;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent-color);
}

.input-field {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 12px 0;
    outline: none;
    font-family: inherit;
}

.input-field::placeholder {
    color: var(--text-tertiary);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.send-btn {
    background: var(--accent-color);
    border: none;
    color: var(--bg-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.send-btn:hover:not(:disabled) {
    background: #9cc1f9;
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Markdown Styling */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5 {
    margin: 16px 0 8px;
    font-weight: 500;
    margin-bottom: -10px;
}

.message-text h1 {
    font-size: 22px;
}

.message-text h2 {
    font-size: 20px;
}

.message-text h3 {
    font-size: 18px;
}

.message-text h4 {
    font-size: 16px;
}

.message-text h5 {
    font-size: 14px;
}

.message-text ul,
.message-text ol {
    margin: 8px 0 8px 20px;
}

.message-text li {
    margin: 4px 0;
}

.message-text strong {
    font-weight: 500;
    color: var(--text-primary);
}

.message-text em {
    color: var(--text-secondary);
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.message-text p {
    margin: 8px 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 10px 16px;
    }

    .header-title {
        font-size: 18px;
    }

    .chat-content {
        padding: 16px;
    }

    .message-content-wrapper {
        max-width: 90%;
    }

    .message-assistant .message-text {
        padding-left: 20px;
    }

    .message-actions {
        padding-left: 20px;
    }

    .message-suggestions {
        padding-left: 20px;
    }

    .input-area {
        padding: 12px 16px 16px;
    }

    .citation-tooltip {
        max-width: 250px;
        font-size: 12px;
    }
}