:root {
    --bg-color: #ffffff;
    --sidebar-bg: #f9f9f9;
    --border-color: #e5e5e5;
    --primary-color: #5D5FEF;
    --text-color: #333333;
    --text-secondary: #666666;
    --user-msg-bg: #f4f4f4;
    --ai-msg-bg: transparent;
    --input-bg: #ffffff;
    --card-bg: #ffffff;
    --hover-bg: #eee;
    --font-primary: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-heading: var(--font-primary);
}

[data-theme="dark"] {
    --bg-color: #1e1e1e;
    --sidebar-bg: #252526;
    --border-color: #3e3e3e;
    --primary-color: #7072f5;
    --text-color: #e0e0e0;
    --text-secondary: #a0a0a0;
    --user-msg-bg: #2d2d2d;
    --ai-msg-bg: transparent;
    --input-bg: #2d2d2d;
    --card-bg: #2d2d2d;
    --hover-bg: #333333;
}

[data-theme="dark"] .logo,
[data-theme="dark"] .mobile-logo {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 6px;
}

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

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    font-family: var(--font-primary);
    background: radial-gradient(circle at 12% 10%, rgba(93, 95, 239, 0.08), transparent 45%),
        radial-gradient(circle at 90% 20%, rgba(45, 212, 191, 0.08), transparent 50%),
        var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    height: 100dvh; /* Adapt to mobile dynamic viewport */
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    overflow: hidden; /* Prevent body scroll */
    transition: background-color 0.3s, color 0.3s;
}

[data-theme="dark"] body {
    background: radial-gradient(circle at 12% 10%, rgba(93, 95, 239, 0.12), transparent 45%),
        radial-gradient(circle at 90% 20%, rgba(45, 212, 191, 0.12), transparent 50%),
        var(--bg-color);
}

.lang-switch {
    position: fixed;
    top: 16px;
    right: 18px;
    z-index: 3000;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 4px;
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
    display: inline-flex;
    gap: 4px;
}

[data-theme="dark"] .lang-switch {
    background: rgba(37, 37, 38, 0.92);
}

.lang-switch button {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    border-radius: 999px;
    padding: 8px 12px;
}

.lang-switch button.active {
    color: #fff;
    background: var(--primary-color);
}

.app-container {
    display: flex;
    height: 100%;
    min-height: 0;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,248,252,0.96));
    border-right: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.3s ease;
}

[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, rgba(30,30,30,0.96), rgba(24,24,24,0.96));
    border-right: 1px solid rgba(148, 163, 184, 0.12);
}

.logo-area {
    margin-bottom: 30px;
}

.logo {
    height: 32px;
    margin-bottom: 20px;
    display: block;
}

/* New Chat Button */
.new-chat-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: var(--hover-bg);
}

[data-theme="dark"] .new-chat-btn {
    border-color: #3e3e3e;
    color: #e0e0e0;
}

[data-theme="dark"] .new-chat-btn:hover {
    background: #333;
    color: #fff;
    border-color: #555;
}

.history-list {
    flex: 1;
    overflow-y: auto;
}

.history-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: block;
    padding: 0 5px;
}

.history-item {
    padding: 10px;
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.history-item:hover {
    background: rgba(148, 163, 184, 0.14);
}

.history-delete-btn {
    opacity: 0;
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    line-height: 1;
    padding: 0 5px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.history-item:hover .history-delete-btn {
    opacity: 1;
}

.history-delete-btn:hover {
    color: #ff4d4f;
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, rgba(93, 95, 239, 0.8), rgba(45, 212, 191, 0.9));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 16px rgba(17, 24, 39, 0.18);
}

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

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

.user-info .status {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent;
    min-height: 0;
}

.mobile-header {
    display: none;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1200;
    background: var(--bg-color);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 34px 20px 24px;
    max-width: 880px;
    margin: 0 auto;
    width: 100%;
    min-height: 0;
}

.message {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    animation: fadeIn 0.3s ease;
}

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

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

.message-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(255,255,255,0.9);
}

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

/* Message Content */
.message-content {
    background: rgba(255, 255, 255, 0.92);
    padding: 12px 16px;
    border-radius: 14px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
    line-height: 1.6;
    font-size: 15px;
    color: var(--text-color); /* Use variable for text color */
    max-width: 100%;
    overflow-wrap: break-word;
}

[data-theme="dark"] .message-content {
    background: rgba(30, 30, 30, 0.88);
    box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}

/* Markdown Styles */
.message-content p {
    margin: 0 0 10px 0;
}
.message-content p:last-child {
    margin-bottom: 0;
}
.message-content h1, .message-content h2, .message-content h3 {
    margin-top: 15px;
    margin-bottom: 10px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-color);
}
.message-content h1 { font-size: 1.4em; }
.message-content h2 { font-size: 1.25em; }
.message-content h3 { font-size: 1.1em; }

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}
.message-content li {
    margin-bottom: 4px;
}
.message-content strong {
    font-weight: 600;
    color: var(--text-color); /* Adaptive strong text */
}
.message-content pre {
    background: var(--bg-color); /* Adaptive code block bg */
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    margin: 10px 0;
    border: 1px solid var(--border-color);
}
.message-content code {
    background: rgba(128,128,128,0.15); /* Semi-transparent for both modes */
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #d63384; /* Pink is readable on both usually */
}
.message-content pre code {
    background: none;
    padding: 0;
    color: var(--text-color);
    font-size: inherit;
}
.message-content blockquote {
    border-left: 4px solid var(--border-color);
    margin: 10px 0;
    padding-left: 15px;
    color: var(--text-secondary);
}

.ai-message .message-content {
    border-top-left-radius: 0;
    /* Background handled by generic .message-content rules above */
}

/* User Message Style */
.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: var(--primary-color);
    color: #ffffff;
    padding: 12px 16px;
    border-radius: 14px;
    border-top-right-radius: 6px;
    max-width: 80%;
    flex: unset;
    box-shadow: 0 2px 5px rgba(93, 95, 239, 0.2);
}

.user-message .message-content p,
.user-message .message-content strong {
    color: #ffffff !important;
}

[data-theme="dark"] .user-message .message-content {
    background: var(--primary-color);
    color: #ffffff;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 4px;
    width: 100%;
}

.welcome-hero {
    position: relative;
    padding: 4px 0 6px;
}

.hero-kicker {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 28px;
    margin-bottom: 6px;
    color: var(--text-color);
}

.hero-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-hint {
    font-size: 13px;
    color: var(--primary-color);
    background: rgba(93, 95, 239, 0.08);
    border: 1px solid rgba(93, 95, 239, 0.2);
    padding: 8px 12px;
    border-radius: 12px;
    margin: 6px 0 8px;
}

.hero-subtitle-secondary {
    margin-top: 2px;
    opacity: 0.85;
}

.assistant-switch {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    display: grid;
    gap: 8px;
    max-height: 420px;
    opacity: 1;
    transform: translateY(0);
    transition: max-height 0.35s ease, opacity 0.35s ease, transform 0.35s ease, margin-top 0.35s ease;
    overflow: hidden;
}

.assistant-switch.is-collapsed {
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px);
    margin-top: 0;
    pointer-events: none;
}

.assistant-switch.is-expanded {
    opacity: 1;
    transform: translateY(0);
}

.assistant-switch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.assistant-switch-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.assistant-switch-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.assistant-switch-btn {
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: transparent;
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.assistant-switch-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.assistant-switch-btn.is-active {
    background: var(--primary-color);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(93, 95, 239, 0.25);
}

.assistant-switch-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.assistant-admin-link {
    font-size: 12px;
    color: var(--primary-color);
    text-decoration: none;
    align-self: flex-start;
    border: 1px solid rgba(93, 95, 239, 0.35);
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(93, 95, 239, 0.08);
    transition: all 0.2s ease;
}

.action-btn.is-panel-open {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(93, 95, 239, 0.1);
}

.assistant-admin-link:hover {
    border-color: var(--primary-color);
    background: rgba(93, 95, 239, 0.16);
    text-decoration: none;
}

/* hero meta pills removed */

/* Hero cards removed for a cleaner layout */

.prompt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    margin-bottom: 2px;
}

.prompt-chip {
    border: 1px dashed var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.prompt-chip:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 6px 16px rgba(93, 95, 239, 0.15);
}

@media (prefers-reduced-motion: reduce) {
    .prompt-chip {
        transition: none;
    }
}

/* Theme Settings Button */
.theme-settings-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-settings-btn:hover {
    background: var(--hover-bg);
    color: var(--text-color);
}

/* Theme Modal */
.theme-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.theme-option input {
    display: none;
}

.theme-preview {
    width: 80px;
    height: 80px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    transition: all 0.2s;
    background: var(--bg-color);
}

.theme-option input:checked + .theme-preview {
    border-color: var(--primary-color);
    background: rgba(93, 95, 239, 0.1);
}

.theme-option span {
    font-size: 14px;
    color: var(--text-color);
}

.action-btn {
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 10px 14px;
    border-radius: 18px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-color);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    width: 100%;
    white-space: nowrap;
}

.action-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
}

.action-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(93, 95, 239, 0.08);
}

/* Input Area */
.input-area {
    padding: 16px 20px 22px;
    background: transparent;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
}

.mode-indicator {
    font-size: 12px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.mode-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.7);
}

.mode-indicator.is-oneclaw::before {
    background: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(93, 95, 239, 0.2);
}

.mode-hint {
    font-size: 12px;
    color: var(--primary-color);
    margin-bottom: 10px;
    white-space: pre-line;
    display: none;
}

.mode-hint.show {
    display: block;
}

.input-wrapper {
    position: relative;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-wrapper.is-disabled {
    opacity: 0.75;
    cursor: not-allowed;
    border-color: rgba(148, 163, 184, 0.4);
    box-shadow: none;
}

.input-wrapper.is-disabled textarea {
    cursor: not-allowed;
}

[data-theme="dark"] .input-wrapper {
    background: rgba(24, 24, 24, 0.9);
    border-color: rgba(148, 163, 184, 0.25);
    box-shadow: 0 16px 32px rgba(0,0,0,0.45);
}

[data-theme="dark"] .action-btn {
    background: rgba(30, 30, 30, 0.88);
    border-color: rgba(148, 163, 184, 0.25);
}

[data-theme="dark"] .action-btn:hover {
    background: rgba(93, 95, 239, 0.15);
}

[data-theme="dark"] .assistant-switch {
    background: rgba(20, 20, 20, 0.75);
    border-color: rgba(148, 163, 184, 0.2);
}

[data-theme="dark"] .assistant-switch-btn {
    border-color: rgba(148, 163, 184, 0.35);
}

[data-theme="dark"] .assistant-switch-desc {
    color: rgba(226, 232, 240, 0.68);
}

[data-theme="dark"] .mode-hint {
    color: rgba(199, 210, 254, 0.9);
}

[data-theme="dark"] .assistant-admin-link {
    border-color: rgba(148, 163, 184, 0.4);
    background: rgba(93, 95, 239, 0.12);
}

[data-theme="dark"] .send-btn {
    background: #f8fafc;
    color: #111827;
    box-shadow: 0 10px 22px rgba(248, 250, 252, 0.2);
}

[data-theme="dark"] .send-btn:hover {
    box-shadow: 0 14px 26px rgba(248, 250, 252, 0.25);
}

.input-wrapper:focus-within {
    border-color: rgba(93, 95, 239, 0.6);
    box-shadow: 0 18px 40px rgba(93, 95, 239, 0.18);
}

textarea {
    flex: 1;
    border: none;
    resize: none;
    padding: 6px 0;
    font-family: inherit;
    font-size: 15px;
    outline: none;
    max-height: 220px;
    background: transparent;
    line-height: 1.5;
}

.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 6px;
    color: var(--text-secondary);
    transition: color 0.2s;
    margin-right: 4px;
    margin-bottom: 0;
}

.upload-btn:hover {
    color: var(--primary-color);
}

.oneclaw-btn {
    border-radius: 12px;
    background: rgba(93, 95, 239, 0.06);
    border: 1px solid transparent;
    padding: 6px 8px;
}

.oneclaw-btn .oneclaw-emoji {
    font-size: 18px;
    line-height: 1;
}

.oneclaw-btn.is-active {
    border-color: rgba(93, 95, 239, 0.5);
    box-shadow: 0 6px 16px rgba(93, 95, 239, 0.18);
    color: var(--primary-color);
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    overflow: hidden;
}

.file-preview span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.send-btn {
    background: #111827;
    color: white;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 6px;
    margin-bottom: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 20px rgba(17, 24, 39, 0.25);
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

.upload-btn svg {
    width: 20px;
    height: 20px;
}

.send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px rgba(17, 24, 39, 0.35);
}

.login-gate {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    padding: 20px;
}

.login-gate-card {
    width: min(92vw, 420px);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.login-gate-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.login-gate-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.disclaimer {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin-top: 10px;
}

/* Widget Cards (Price, etc.) */
.widget-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.widget-title {
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invest-card {
    padding: 18px;
}

.invest-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.invest-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.invest-badge {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: rgba(93, 95, 239, 0.08);
    white-space: nowrap;
}

[data-theme="dark"] .invest-badge {
    background: rgba(112, 114, 245, 0.14);
}

.invest-meter {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
    margin-bottom: 12px;
}

.invest-meter-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(93, 95, 239, 0.7), rgba(45, 212, 191, 0.75));
}

.invest-reco {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-color);
    background: rgba(93, 95, 239, 0.06);
    border: 1px solid rgba(93, 95, 239, 0.16);
    border-radius: 12px;
    padding: 12px 12px;
    margin-bottom: 14px;
}

[data-theme="dark"] .invest-reco {
    background: rgba(112, 114, 245, 0.1);
    border-color: rgba(112, 114, 245, 0.22);
}

.invest-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 920px) {
    .invest-grid {
        grid-template-columns: 1fr;
    }
}

.invest-section {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
    padding: 12px;
}

[data-theme="dark"] .invest-section {
    background: rgba(37, 37, 38, 0.55);
}

.invest-section-title {
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 8px;
}

.invest-list {
    margin: 0;
    padding-left: 18px;
}

.invest-list li {
    margin: 6px 0;
    line-height: 1.45;
    color: var(--text-secondary);
    font-size: 13px;
}

.invest-empty {
    color: var(--text-secondary);
    font-size: 13px;
}

.invest-foot {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed rgba(148, 163, 184, 0.45);
}

.invest-foot-text {
    font-size: 12px;
    color: #999;
}

.price-table {
    width: 100%;
    border-collapse: collapse;
}

.price-table th, .price-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.price-table th {
    color: #999;
    font-weight: 500;
    font-size: 12px;
}

.price-val {
    color: var(--primary-color);
    font-weight: bold;
}

/* Login Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal-container {
    background: var(--card-bg);
    border-radius: 16px;
    width: 400px;
    max-width: 90%;
    padding: 30px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    text-align: center;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.login-content h2 {
    margin-bottom: 10px;
}

.qr-placeholder {
    margin: 0 auto;
    width: 180px;
    height: 180px;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--sidebar-bg);
}

.wechat-login-btn {
    background: #07c160;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    cursor: pointer;
    font-weight: bold;
}

/* WeChat Login Container */
.wx-login-container {
    text-align: center;
    background: var(--card-bg);
    padding: 20px;
}

/* Ensure text inputs inherit text color */
input, textarea {
    color: var(--text-color);
}

textarea::placeholder {
    color: var(--text-secondary);
}

/* Scrollbar styling for dark mode */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.wx-iframe-mock {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 20px;
    display: inline-block;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.wx-iframe-mock h3 {
    font-size: 18px;
    margin-bottom: 20px;
    font-weight: 500;
}

/* Profile Edit & Logout */
.avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    border-radius: 50%;
}

.profile-avatar-large {
    position: relative; /* Ensure overlay positions correctly */
}

.profile-avatar-large:hover .avatar-overlay {
    opacity: 1;
}

.edit-icon-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
}

.edit-icon-btn:hover {
    color: #fff;
}

#userName[contenteditable="true"] {
    border-bottom: 1px solid #fff;
    outline: none;
    padding-right: 5px;
}

.logout-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
    z-index: 10;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 900;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        height: 100svh;
        height: 100dvh;
    }

    .lang-switch {
        top: calc(env(safe-area-inset-top, 0px) + 8px);
        right: 10px;
        padding: 3px;
        z-index: 1500;
    }

    .lang-switch button {
        padding: 7px 10px;
        font-size: 12px;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 260px;
        transform: translateX(-100%);
        height: 100%;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
        position: sticky;
        top: 0;
        min-height: 58px;
        padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
        justify-content: flex-start;
        background: var(--bg-color);
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
    }
    
    .chat-container {
        padding: 16px 14px;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 160px);
        max-width: 100%;
    }
    
    .mobile-logo {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        height: 28px;
        max-width: 158px;
        width: auto;
        pointer-events: none;
    }
    
    .menu-btn {
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: var(--text-color);
        padding: 0; /* Remove default padding */
        z-index: 2;
        line-height: 1;
    }

    [data-theme="dark"] .menu-btn {
        color: #fff; /* Explicitly white in dark mode */
    }

    .message {
        gap: 12px;
        margin-bottom: 18px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
    }

    .message-content {
        padding: 10px 12px;
        font-size: 14px;
    }

    .user-message .message-content {
        max-width: 88%;
    }

    .quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .hero-title {
        font-size: 22px;
    }


    .prompt-chips {
        gap: 8px;
    }

    .assistant-switch {
        padding: 12px 12px;
    }

    .assistant-switch-header {
        align-items: flex-start;
    }

    .assistant-switch-buttons {
        width: 100%;
    }

    .assistant-switch-btn {
        flex: 1 1 auto;
        text-align: center;
    }

    .action-btn {
        padding: 9px 12px;
        font-size: 13px;
    }

    .input-area {
        padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
        max-width: 100%;
        flex-shrink: 0;
    }

    .input-wrapper {
        padding: 8px 10px;
    }

    textarea {
        font-size: 16px;
    }

    /* Mobile Login Logic */
    .pc-login-view {
        display: none;
    }
    .mobile-login-view {
        display: block;
    }
}

@media (max-width: 480px) {
    .chat-container {
        padding: 14px 12px;
    }

    .action-btn {
        font-size: 12px;
        padding: 9px 10px;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .message-content h1 {
        font-size: 24px;
        line-height: 1.35;
    }

    .input-area {
        padding-left: 10px;
        padding-right: 10px;
    }
}

@media (min-width: 769px) and (max-width: 1100px) {
    .sidebar {
        width: 238px;
        padding: 18px 16px;
    }

    .chat-container {
        max-width: 760px;
        padding: 30px 18px;
    }

    .input-area {
        max-width: 760px;
    }
}

/* History Item Styles (Global) */
.history-item.active {
    background: rgba(93, 95, 239, 0.18);
    color: var(--text-color);
}

[data-theme="dark"] .history-item {
    color: #e0e0e0;
    border: 1px solid transparent;
}

[data-theme="dark"] .history-item:hover {
    background: #333;
    color: #fff;
    border-color: #555;
}

[data-theme="dark"] .history-item.active {
    background: #333;
    color: #fff;
    border-color: #555;
}

/* Dark Mode KB Manager */
[data-theme="dark"] .kb-modal {
    background: #1e1e1e;
    color: #fff;
}
[data-theme="dark"] .kb-content h2 {
    color: #fff;
}
[data-theme="dark"] .kb-header span {
    color: #aaa !important;
}
[data-theme="dark"] .kb-file-list {
    border-top-color: #333 !important;
}
[data-theme="dark"] .kb-item {
    border-bottom-color: #333 !important;
}
[data-theme="dark"] .kb-filename {
    color: #fff !important;
}
[data-theme="dark"] .close-kb-modal {
    color: #fff;
}
[data-theme="dark"] .kb-item[id="temp-upload-item"] {
    background: #2a2a2a !important;
}

/* Typing Indicator Animation */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #999;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.typing-text-tip {
    font-size: 13px;
    color: #999;
    margin-left: 10px;
    animation: fadeText 0.5s ease-in-out;
    min-width: 120px; /* Avoid layout shift */
}

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