
/* ============================================================
   Agent_CUG — 精仿 ChatGPT Dark Theme
   基于 ChatGPT 真实 CSS 变量和 Tailwind prose 排版
   ============================================================ */

:root {
    /* ChatGPT 色板 */
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --text-tertiary: #8e8e8e;
    --surface-primary: #212121;
    --surface-secondary: #2f2f2f;
    --surface-tertiary: #3a3a3a;
    --border-light: rgba(255,255,255,0.06);
    --border-medium: rgba(255,255,255,0.1);
    --border-strong: rgba(255,255,255,0.15);
    --brand-purple: #ab68ff;
    --brand-green: #19c37d;
    --brand-blue: #4a9eff;
    --brand-orange: #f59e0b;

    /* ChatGPT 布局变量 */
    --thread-content-max-width: 40rem;
    --sidebar-width: 260px;
    --header-height: 48px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.15s ease;
}

/* ====== Light Theme ====== */
[data-theme="light"] {
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-tertiary: #8e8e8e;
    --surface-primary: #ffffff;
    --surface-secondary: #f7f7f8;
    --surface-tertiary: #ececf1;
    --border-light: rgba(0,0,0,0.08);
    --border-medium: rgba(0,0,0,0.12);
    --border-strong: rgba(0,0,0,0.18);
}

@media (min-width: 1024px) {
    :root { --thread-content-max-width: 48rem; }
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 16px; line-height: 1.6;
    color: var(--text-primary); background: var(--surface-primary);
    overflow: hidden;
}

/* ====== 布局 ====== */
.app-container { display: flex; height: 100vh; width: 100vw; }

/* ====== 侧边栏 ====== */
.sidebar {
    width: var(--sidebar-width); min-width: var(--sidebar-width);
    background: var(--surface-primary); display: flex; flex-direction: column;
    border-right: 1px solid var(--border-light);
    transition: width var(--transition), min-width var(--transition), opacity var(--transition);
    overflow: hidden;
}
.sidebar.collapsed { width: 0; min-width: 0; opacity: 0; border-right: none; }

.sidebar-header { display: flex; align-items: center; gap: 8px; padding: 12px; }
.new-chat-btn {
    flex: 1; display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; background: transparent;
    border: 1px solid var(--border-strong); border-radius: var(--radius-md);
    color: var(--text-primary); font-size: 14px; cursor: pointer;
    transition: background var(--transition); white-space: nowrap;
}
.new-chat-btn:hover { background: var(--surface-secondary); }

.toggle-sidebar-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; background: transparent; border: none;
    border-radius: var(--radius-sm); color: var(--text-secondary);
    cursor: pointer; transition: background var(--transition); flex-shrink: 0;
}
.toggle-sidebar-btn:hover { background: var(--surface-tertiary); color: var(--text-primary); }

.sidebar-section { padding: 8px; }
.sidebar-label {
    padding: 8px 12px 4px; font-size: 12px; font-weight: 600;
    color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: var(--radius-md); color: var(--text-secondary);
    text-decoration: none; font-size: 14px; transition: all var(--transition); cursor: pointer;
}
.sidebar-nav-item:hover { background: var(--surface-secondary); color: var(--text-primary); }
.sidebar-nav-item.active { background: var(--surface-secondary); color: var(--text-primary); }

.history-list { flex: 1; overflow-y: auto; padding: 4px 0; max-height: calc(100vh - 340px); }
.history-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; margin: 2px 8px; border-radius: var(--radius-md);
    cursor: pointer; font-size: 13px; color: var(--text-secondary);
    transition: all var(--transition); position: relative;
}
.history-item:hover { background: var(--surface-secondary); color: var(--text-primary); }
.history-item.active { background: var(--surface-secondary); color: var(--text-primary); }

/* History item actions */
.history-item-main {
    flex: 1; overflow: hidden; min-width: 0; margin-right: 8px;
}
.history-item .history-title {
    display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item .history-title {
    display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item .history-time {
    display: block; font-size: 11px; color: var(--text-tertiary); margin-top: 2px;
}
.history-actions {
    display: flex; gap: 4px; flex-shrink: 0; opacity: 0.6; transition: opacity var(--transition);
}
.history-item:hover .history-actions {
    opacity: 1;
}
.history-action-btn {
    padding: 4px; border: none; background: transparent; color: var(--text-tertiary);
    cursor: pointer; border-radius: var(--radius-sm); display: flex; align-items: center;
    transition: all var(--transition);
}
.history-action-btn:hover {
    background: var(--surface-tertiary); color: var(--text-primary);
}
.history-action-btn[data-action="delete"]:hover {
    color: #ef4444;
}
.history-empty {
    padding: 20px 12px; text-align: center; color: var(--text-tertiary); font-size: 13px;
}

.history-empty { padding: 16px 12px; text-align: center; color: var(--text-tertiary); font-size: 13px; }
.history-title { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.history-time { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; margin-left: 8px; }

.sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid var(--border-light); }
.user-info { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-md); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--brand-purple);
    display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}
.user-name { font-size: 14px; font-weight: 500; }

/* ====== 主区域 ====== */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--surface-primary); }
.panel { display: none; flex-direction: column; height: 100%; }
.panel.active { display: flex; }

/* ====== 顶栏 ====== */
.chat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 20px; height: var(--header-height); flex-shrink: 0;
}
.chat-header h2 { font-size: 16px; font-weight: 600; }

.model-badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
    background: var(--surface-secondary); border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary);
}
.icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; background: transparent; border: none;
    border-radius: var(--radius-sm); color: var(--text-secondary);
    cursor: pointer; transition: all var(--transition);
}
.icon-btn:hover { background: var(--surface-tertiary); color: var(--text-primary); }
.doc-count { font-size: 13px; color: var(--text-tertiary); }

/* ====== 消息区域 ====== */
.chat-messages { flex: 1; overflow-y: auto; }

/* 欢迎页 */
.welcome-screen {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; padding: 40px 20px; text-align: center;
}
.welcome-logo { font-size: 56px; margin-bottom: 16px; }
.welcome-screen h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.welcome-subtitle { color: var(--text-tertiary); font-size: 15px; margin-bottom: 32px; }
.suggestion-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 600px; }
.chip {
    padding: 10px 18px; background: transparent;
    border: 1px solid var(--border-strong); border-radius: var(--radius-xl);
    color: var(--text-secondary); font-size: 14px; cursor: pointer;
    transition: all var(--transition); white-space: nowrap;
}
.chip:hover { background: var(--surface-secondary); border-color: var(--text-tertiary); color: var(--text-primary); }

/* ====== ChatGPT 消息行 (agent-turn) ====== */
.message-row {
    /* 仿 agent-turn: mx-auto max-w-(--thread-content-max-width) */
    max-width: var(--thread-content-max-width);
    margin: 0 auto; padding: 24px 40px;
    display: flex; width: 100%; min-width: 0;
    position: relative;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }


.message-row.assistant { background: var(--surface-secondary); }
.message-row.tool { background: rgba(171, 104, 255, 0.04); }

.message-inner {
    display: flex; gap: 20px; align-items: flex-start;
    width: 100%; min-width: 0;
}

/* 头像 */
.message-avatar { display: none; /* hidden */
    width: 30px; height: 30px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; flex-shrink: 0; margin-top: 2px;
    background: var(--surface-tertiary);
}
.message-row.user .message-avatar { background: var(--brand-purple); }
.message-row.assistant .message-avatar { background: var(--brand-green); }
.message-row.tool .message-avatar { background: var(--brand-orange); }

/* 消息内容容器 — 仿 text-message */
.message-content {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 4px;
    /* break-words whitespace-normal */
    word-break: break-word; overflow-wrap: anywhere;
    white-space: normal;
}

/* ChatGPT-style: user right, assistant left */
.message-row.user .message-inner {
    flex-direction: row-reverse;
}
.message-row.user .message-content {
    text-align: right;
}
.message-row.assistant .message-content {
    text-align: left;
}
.message-row.user .message-actions {
    justify-content: flex-end;
}

/* ====== Prose / Markdown 排版 (仿 Tailwind prose dark:prose-invert) ====== */
.message-content h1 { font-size: 1.5em; font-weight: 700; margin: 1.2em 0 0.6em; line-height: 1.3; }
.message-content h2 { font-size: 1.25em; font-weight: 600; margin: 1em 0 0.5em; line-height: 1.35; }
.message-content h3 { font-size: 1.1em; font-weight: 600; margin: 0.8em 0 0.4em; line-height: 1.4; }
.message-content p { margin-bottom: 0.75em; line-height: 1.75; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 0.5em 0; padding-left: 1.5em; }
.message-content li { margin-bottom: 0.25em; line-height: 1.7; }
.message-content strong { font-weight: 600; color: var(--text-primary); }
.message-content em { font-style: italic; }
.message-content a { color: var(--brand-blue); text-decoration: underline; text-underline-offset: 2px; }
.message-content a:hover { color: #7ab8ff; }

/* 行内代码 */
.message-content :not(pre) > code {
    background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 4px;
    font-size: 0.875em; font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
    color: #e8e8e8; white-space: pre-wrap;
}

/* 代码块 */
.message-content pre {
    position: relative; background: #1a1a1a;
    border: 1px solid var(--border-medium); border-radius: var(--radius-md);
    padding: 16px; margin: 12px 0; overflow-x: auto;
    font-size: 14px; line-height: 1.55;
}
.message-content pre code {
    background: none; padding: 0; font-size: inherit; color: #e0e0e0;
    white-space: pre; font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

/* 代码块顶部栏 */
.code-block-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px; background: #1e1e1e;
    border: 1px solid var(--border-medium); border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 12px; color: var(--text-tertiary);
}
.code-block-header + pre { margin-top: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); }

.copy-btn {
    display: flex; align-items: center; gap: 4px; padding: 4px 8px;
    background: transparent; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); color: var(--text-secondary);
    font-size: 12px; cursor: pointer; transition: all var(--transition);
}
.copy-btn:hover { background: var(--surface-tertiary); color: var(--text-primary); }
.copy-btn.copied { color: var(--brand-green); border-color: var(--brand-green); }

/* 引用块 */
.message-content blockquote {
    border-left: 3px solid var(--text-tertiary); padding: 4px 0 4px 16px;
    margin: 12px 0; color: var(--text-secondary); font-style: italic;
}

/* 表格 */
.message-content table {
    width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px;
}
.message-content th, .message-content td {
    padding: 8px 12px; border: 1px solid var(--border-medium); text-align: left;
}
.message-content th { background: var(--surface-tertiary); font-weight: 600; }
.message-content tr:nth-child(even) { background: rgba(255,255,255,0.02); }

/* 分隔线 */
.message-content hr { border: none; border-top: 1px solid var(--border-medium); margin: 16px 0; }

/* ====== 思考过程（可折叠） ====== */
.thinking-section {
    margin-bottom: 16px; border: 1px solid rgba(171, 104, 255, 0.2);
    border-radius: var(--radius-md); overflow: hidden;
}
.thinking-header {
    display: flex; align-items: center; gap: 8px; padding: 10px 14px;
    background: rgba(171, 104, 255, 0.08); cursor: pointer;
    font-size: 13px; color: var(--text-secondary); user-select: none;
    transition: background var(--transition);
}
.thinking-header:hover { background: rgba(171, 104, 255, 0.14); }
.thinking-header .toggle-icon { transition: transform 0.2s; font-size: 10px; }
.thinking-section.open .toggle-icon { transform: rotate(90deg); }

.thinking-body {
    max-height: 0; overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    font-size: 14px; line-height: 1.6; color: var(--text-secondary);
    border-top: 0 solid transparent;
}
.thinking-section.open .thinking-body {
    max-height: 2000px; padding: 12px 14px;
    border-top-color: rgba(171, 104, 255, 0.15);
}

/* ====== 工具调用展示 ====== */
.tool-call-display {
    margin: 8px 0; padding: 10px 14px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: var(--radius-md); font-size: 13px;
}
.tool-call-display .tool-name {
    font-weight: 600; color: var(--brand-orange); margin-bottom: 4px;
}
.tool-call-display .tool-result {
    color: var(--text-secondary); white-space: pre-wrap;
    font-family: "SF Mono", monospace; font-size: 12px;
}

/* ====== 消息来源 ====== */
.message-sources {
    margin-top: 16px; padding: 12px 14px;
    background: rgba(255,255,255,0.03); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); font-size: 12px;
}
.message-sources .sources-label { color: var(--text-tertiary); font-weight: 600; margin-bottom: 6px; }
.message-sources .source-item { display: flex; gap: 8px; padding: 3px 0; color: var(--text-secondary); }
.message-sources .source-idx { color: var(--text-tertiary); min-width: 24px; }

/* ====== 流式光标 ====== */
.streaming-cursor::after {
    content: '\258D'; animation: blink 0.8s step-end infinite;
    color: var(--text-primary); font-weight: 100;
}
@keyframes blink { 50% { opacity: 0; } }

/* ====== 输入区域 ====== */
.chat-input-area { padding: 0 24px 16px; flex-shrink: 0; }

.input-container {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 16px; background: var(--surface-secondary);
    border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
    transition: border-color var(--transition);
    max-width: var(--thread-content-max-width); margin: 0 auto;
}
.input-container:focus-within { border-color: rgba(255,255,255,0.3); }

.message-input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--text-primary); font-size: 16px; font-family: inherit;
    resize: none; max-height: 200px; line-height: 1.5; padding: 6px 0;
}
.message-input::placeholder { color: var(--text-tertiary); }

.send-btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; background: var(--text-secondary);
    border: none; border-radius: 8px; color: #1a1a1a;
    cursor: pointer; transition: all var(--transition); flex-shrink: 0;
}
.send-btn:hover { background: var(--text-primary); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.input-footer { text-align: center; font-size: 11px; color: var(--text-tertiary); padding: 8px 0 0; }

/* ====== 知识库 ====== */
.rag-content { flex: 1; overflow-y: auto; padding: 24px; max-width: 800px; margin: 0 auto; width: 100%; }
.rag-upload-section, .rag-query-section { margin-bottom: 32px; }
.rag-upload-section h3, .rag-query-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.rag-upload-section p { color: var(--text-tertiary); font-size: 13px; margin-bottom: 16px; }
.upload-dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; padding: 40px; border: 2px dashed var(--border-medium);
    border-radius: var(--radius-lg); cursor: pointer; transition: all var(--transition); color: var(--text-tertiary);
}
.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--brand-purple); background: rgba(171, 104, 255, 0.05); color: var(--brand-purple);
}
.upload-status { margin-top: 12px; font-size: 13px; }
.upload-status .success { color: var(--brand-green); }
.upload-status .info { color: var(--brand-blue); }
.upload-status .error { color: #ef4444; }
.rag-query-input { display: flex; gap: 10px; margin-bottom: 16px; }
.rag-query-input input {
    flex: 1; padding: 10px 16px; background: var(--surface-secondary);
    border: 1px solid var(--border-strong); border-radius: var(--radius-md);
    color: var(--text-primary); font-size: 14px; outline: none; transition: border-color var(--transition);
}
.rag-query-input input:focus { border-color: var(--text-tertiary); }
.btn-primary {
    padding: 10px 20px; background: var(--text-primary); color: #1a1a1a;
    border: none; border-radius: var(--radius-md); font-size: 14px; font-weight: 500;
    cursor: pointer; transition: opacity var(--transition); white-space: nowrap;
}
.btn-primary:hover { opacity: 0.85; }
.rag-results { display: flex; flex-direction: column; gap: 12px; }
.rag-result-item {
    padding: 16px; background: var(--surface-secondary);
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
}
.rag-result-item .result-header { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; color: var(--text-tertiary); }
.rag-result-item .result-score { color: var(--brand-green); font-weight: 600; }
.rag-result-item .result-content { font-size: 14px; line-height: 1.6; color: var(--text-secondary); }

/* ====== 设置 ====== */
.settings-content { flex: 1; overflow-y: auto; padding: 24px; max-width: 600px; margin: 0 auto; width: 100%; }
.settings-group { margin-bottom: 32px; }
.settings-group h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }
.setting-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.setting-item label { font-size: 14px; color: var(--text-secondary); }
.setting-value { font-size: 14px; color: var(--text-primary); font-family: "SF Mono", monospace; }
.status-ok { color: var(--brand-green) !important; }

/* ====== 滚动条 ====== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ====== 响应式 ====== */
@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
    .sidebar.collapsed { left: -260px; }
    .message-row { padding: 16px; }
    .chat-input-area { padding: 0 12px 12px; }
}

/* Right-click context menu */
.context-menu {
    position: fixed; z-index: 1000; background: var(--surface-primary);
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3); min-width: 140px; padding: 4px;
}
.context-menu-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
    color: var(--text-primary); transition: background var(--transition);
}
.context-menu-item:hover {
    background: var(--surface-secondary);
}
.context-menu-item.danger {
    color: #ef4444;
}
.context-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}


/* ====== Custom Modal ====== */
.custom-modal-overlay {
    position: fixed; z-index: 2000; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.15s ease;
}
.custom-modal {
    background: var(--surface-primary); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); width: 380px; max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4); overflow: hidden;
    animation: slideUp 0.2s ease;
}
.custom-modal-header {
    padding: 16px 20px; font-size: 15px; font-weight: 600;
    color: var(--text-primary); border-bottom: 1px solid var(--border-light);
}
.custom-modal-body { padding: 20px; }
.custom-modal-message {
    color: var(--text-secondary); font-size: 14px; line-height: 1.6; margin: 0;
}
.custom-modal-input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); background: var(--surface-secondary);
    color: var(--text-primary); font-size: 14px; outline: none;
    box-sizing: border-box;
}
.custom-modal-input:focus {
    border-color: var(--accent); box-shadow: 0 0 0 2px rgba(171,104,255,0.2);
}
.custom-modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 20px; border-top: 1px solid var(--border-light);
}
.custom-modal-btn {
    padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-light);
    background: var(--surface-secondary); color: var(--text-primary);
    font-size: 13px; cursor: pointer;
}
.custom-modal-btn:hover { background: var(--surface-tertiary); }
.custom-modal-btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.custom-modal-btn.primary:hover { opacity: 0.9; }
.custom-modal-btn.danger { background: #ef4444; color: white; border-color: #ef4444; }
.custom-modal-btn.danger:hover { background: #dc2626; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }


/* ====== Message actions (copy) ====== */
.message-actions {
    display: flex; align-items: center; gap: 8px;
    margin-top: 12px; padding-top: 8px;
}
.message-copy-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 8px; border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); background: transparent;
    color: var(--text-tertiary); font-size: 12px; cursor: pointer;
    transition: all var(--transition);
}
.message-copy-btn:hover {
    background: var(--surface-secondary); color: var(--text-primary);
    border-color: var(--text-tertiary);
}
.message-copy-btn.copied { color: #4ade80; border-color: #4ade80; }



/* Edit button: sits below text at bottom-right, does not overlap */
.message-row.user .message-content {
    position: relative;
    padding-bottom: 28px;
}
.message-row.user .message-actions {
    position: absolute;
    bottom: 2px;
    right: 0;
    margin: 0;
    padding: 2px 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
    justify-content: flex-end;
}
.message-row.user:hover .message-actions {
    opacity: 1;
}
/* Inline edit textarea */
.message-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}
.message-edit-textarea:focus {
    border-color: var(--brand-purple);
    box-shadow: 0 0 0 2px rgba(171,104,255,0.15);
}
/* Confirm/cancel buttons during inline edit */
.message-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    justify-content: flex-end;
}
.message-edit-confirm,
.message-edit-cancel {
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
}
.message-edit-confirm {
    background: var(--brand-purple);
    color: white;
    border-color: var(--brand-purple);
}
.message-edit-confirm:hover { opacity: 0.85; }
.message-edit-cancel:hover {
    background: var(--surface-secondary);
    color: var(--text-primary);
}
/* Edit button icon style */
.message-edit-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 8px; border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); background: transparent;
    color: var(--text-tertiary); font-size: 12px; cursor: pointer;
    transition: all var(--transition);
}
.message-edit-btn:hover {
    background: var(--surface-secondary); color: var(--text-primary);
    border-color: var(--text-tertiary);
}

/* ====== Theme Toggle ====== */
.theme-toggle-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); background: transparent;
    color: var(--text-secondary); font-size: 13px; cursor: pointer;
    transition: all var(--transition);
}
.theme-toggle-btn:hover {
    background: var(--surface-secondary); color: var(--text-primary);
}
.theme-toggle-btn .icon-sun, .theme-toggle-btn .icon-moon {
    width: 16px; height: 16px;
}
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }
