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

:root, [data-theme="dark"] {
    --bg-primary: #0b0b0d;
    --bg-secondary: #141417;
    --bg-tertiary: #1b1b20;
    --bg-input: #1b1b20;
    --text-primary: #ededf1;
    --text-secondary: #a2a2ad;
    --text-muted: #7e7e8c;
    --accent: #e06a52;
    --accent-hover: #ec7d67;
    --border: #292930;
    --accent-soft: rgba(224,106,82,0.14);
    --accent-glow: rgba(224,106,82,0.30);
    --accent-grad: linear-gradient(135deg, #ec7d67 0%, #d15a44 100%);
    --msg-user: #1b1b20;
    --msg-ai: transparent;
    --scrollbar: #292930;
    --scrollbar-hover: #3a3a44;
    --shadow: rgba(0,0,0,0.5);
    --code-bg: #0e0e11;
    --code-inline-bg: rgba(255,255,255,0.06);
}

[data-theme="light"] {
    --bg-primary: #f7f5f3;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1eeeb;
    --bg-input: #f1eeeb;
    --text-primary: #211d1a;
    --text-secondary: #6a635c;
    --text-muted: #9a938b;
    --accent: #d15a42;
    --accent-hover: #b6472f;
    --border: #e7e2dd;
    --accent-soft: rgba(209,90,66,0.10);
    --accent-glow: rgba(209,90,66,0.22);
    --accent-grad: linear-gradient(135deg, #e06a52 0%, #cf5236 100%);
    --msg-user: #f1eeeb;
    --msg-ai: transparent;
    --scrollbar: #ddd6ce;
    --scrollbar-hover: #c8bfb5;
    --shadow: rgba(60,40,30,0.12);
    --code-bg: #f4f1ee;
    --code-inline-bg: rgba(0,0,0,0.06);
}

/* 'Inter' 仅作「本机若已装则优先用」的可选提示，非 webfont 依赖；未装自动降级 system-ui */
html, body { height: 100%; font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto, sans-serif; background: var(--bg-primary); color: var(--text-primary); }

/* Login Screen */
.login-screen {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; background: var(--bg-primary);
    position: relative; overflow: hidden;
}
/* Koi 大字水印：淡雅背景，纯 CSS，无 DOM 依赖 */
.login-screen::after {
    content: "Koi"; position: absolute; right: -6px; bottom: -64px;
    font-size: 210px; font-weight: 800; letter-spacing: -0.05em; line-height: 1;
    color: var(--accent); opacity: 0.10; transform: rotate(-8deg);
    pointer-events: none; user-select: none;
}
.login-card {
    position: relative; z-index: 1;
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 20px;
    padding: 56px 38px 44px; width: 380px; max-width: 90vw; text-align: center;
    box-shadow: 0 24px 60px -12px var(--shadow);
}
.login-card h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.025em; margin-bottom: 8px; }
.login-card h1 span { color: var(--accent); font-weight: 800; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form input {
    background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border);
    border-radius: 12px; padding: 13px 16px; font-size: 15px; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.login-form input::placeholder { color: var(--text-muted); }
.login-error { color: #ff4d6a; font-size: 13px; min-height: 18px; }
.login-form button {
    background: var(--accent-grad); color: white; border: none; border-radius: 12px;
    padding: 14px; font-size: 16px; font-weight: 700; cursor: pointer;
    box-shadow: 0 4px 16px -4px var(--accent-glow);
    transition: transform 0.12s, box-shadow 0.2s, filter 0.2s;
}
.login-form button:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 8px 22px -4px var(--accent-glow); }
.login-form button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Logout button */
.btn-logout {
    background: none; border: 1px solid var(--border); color: var(--text-secondary);
    padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: 13px;
    font-weight: 600; transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--accent); color: var(--accent); }

/* Layout */
.app { display: flex; height: 100vh; }

/* Main Chat Area */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.btn-icon {
    background: none; border: 1px solid var(--border); color: var(--text-secondary);
    width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 18px;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-tertiary); color: var(--text-primary); border-color: #444444; }

/* Export Menu */
.export-menu-item:hover { background: var(--bg-tertiary); }
.admin-export-popup div:hover { background: var(--bg-tertiary); }

/* Tool Drawer — 顶栏收纳：仅暴露 模型/CC/设置，其余收进抽屉 */
.tool-drawer { position: relative; display: inline-flex; }
.tool-drawer-menu {
    position: absolute; right: 0; top: 100%; margin-top: 6px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    z-index: 100; min-width: 200px; padding: 6px;
    display: flex; flex-direction: column; gap: 2px;
}
.tool-drawer-item-wrap { width: 100%; position: relative; }
.tool-drawer-item.btn-icon {
    width: 100%; height: auto; min-width: 0; min-height: 0;
    justify-content: flex-start; gap: 10px; padding: 10px 12px; border: none; border-radius: 8px;
}
.tool-drawer-item.btn-icon:hover { background: var(--bg-tertiary); border-color: transparent; }
.tool-label { font-size: 14px; color: var(--text-primary); line-height: 1; white-space: nowrap; }

.btn-send {
    background: var(--accent-grad); color: white; border: none; width: 38px; height: 38px;
    border-radius: 10px; cursor: pointer; font-size: 18px; flex-shrink: 0;
    box-shadow: 0 3px 12px -3px var(--accent-glow);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.12s, box-shadow 0.2s, filter 0.2s;
}
.btn-send:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 6px 18px -3px var(--accent-glow); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Modal */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 16px;
    width: 500px; max-width: 90vw; max-height: 80vh; overflow-y: auto;
    box-shadow: 0 20px 60px var(--shadow);
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 22px; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px 24px; }
.modal-body .setting-group { margin-bottom: 20px; }
.modal-body label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.modal-body select, .modal-body input[type="text"] {
    width: 100%; background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none;
}
.modal-body select:focus, .modal-body input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.modal-body .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Image Generation Button (in topbar) — inherits .btn-icon sizing */
.btn-image-topbar {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn-image-topbar:active { transform: scale(0.92); }

/* Generated Image in Chat */
.generated-image-wrap { margin-top: 8px; }
.generated-image-wrap img {
    max-width: 100%; max-height: 400px; border-radius: 10px; cursor: pointer;
    transition: transform 0.2s; border: 1px solid var(--border);
}
.generated-image-wrap img:hover { transform: scale(1.02); }
.generated-image-wrap .image-desc { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

/* Image Loading */
.image-loading {
    display: flex; align-items: center; gap: 10px; padding: 16px 0;
    color: var(--text-secondary); font-size: 14px;
}
.image-loading .spinner {
    width: 20px; height: 20px; border: 2px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Lightbox */
.lightbox-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85);
    z-index: 2000; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img { max-width: 92vw; max-height: 92vh; border-radius: 8px; object-fit: contain; }
.lightbox-close {
    position: absolute; top: 16px; right: 24px; background: none; border: none;
    color: white; font-size: 36px; cursor: pointer; opacity: 0.7; transition: opacity 0.2s;
}
.lightbox-close:hover { opacity: 1; }

/* Code Block Wrapper with Copy & Download Buttons */
.code-block-wrapper {
    position: relative; margin: 8px 0;
}
.code-block-wrapper pre {
    margin: 0;
}
.code-block-actions {
    position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0;
    transition: opacity 0.15s; z-index: 1;
}
.code-block-wrapper:hover .code-block-actions { opacity: 1; }
.code-copy-btn, .code-download-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary); border: 1px solid var(--border); border-radius: 6px;
    padding: 3px 10px; font-size: 12px; cursor: pointer;
    transition: background 0.15s;
}
.code-copy-btn:hover, .code-download-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.code-download-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Stop button (streaming state) */
.btn-send.streaming {
    background: #e74c3c;
}
.btn-send.streaming:hover {
    background: #c0392b;
}

/* Image Prompt Modal input focus */
#image-prompt-input:focus { border-color: var(--accent); }
#btn-image-generate:hover { background: var(--accent-hover); }

/* Image Panel */
.image-panel-modal {
    width: 560px; max-width: 95vw; max-height: 85vh; display: flex; flex-direction: column;
}
.image-panel-header {
    padding: 0 24px; border-bottom: 1px solid var(--border); display: flex;
    justify-content: space-between; align-items: center;
}
.image-panel-tabs {
    display: flex; gap: 0;
}
.image-tab {
    background: none; border: none; color: var(--text-secondary); cursor: pointer;
    padding: 16px 16px 14px; font-size: 14px; font-weight: 600; border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.image-tab:hover { color: var(--text-primary); }
.image-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.image-panel-body {
    padding: 20px 24px; overflow-y: auto; flex: 1;
}
.image-tab-content { display: none; }
.image-tab-content.active { display: block; }

/* Style Grid */
.style-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
}
.style-btn {
    background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary);
    border-radius: 8px; padding: 8px 4px; font-size: 13px; cursor: pointer; transition: all 0.2s;
    text-align: center;
}
.style-btn:hover { border-color: var(--text-muted); color: var(--text-primary); }
.style-btn.active {
    border-color: var(--accent); color: var(--accent); background: rgba(160, 64, 64, 0.1);
}

/* Image Grid (for my-images and my-photos) */
.image-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.image-grid-item {
    position: relative; border-radius: 8px; overflow: hidden; cursor: pointer;
    aspect-ratio: 1; background: var(--bg-tertiary); border: 1px solid var(--border);
}
.image-grid-item img {
    width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s;
}
.image-grid-item:hover img { transform: scale(1.05); }
.image-grid-item .image-grid-label {
    position: absolute; bottom: 0; left: 0; right: 0; padding: 4px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7)); color: #fff;
    font-size: 11px; display: flex; justify-content: space-between; align-items: flex-end;
}
.image-grid-item .image-grid-label .style-tag {
    background: rgba(160,64,64,0.7); padding: 1px 6px; border-radius: 4px; font-size: 10px;
}
.image-empty {
    text-align: center; color: var(--text-muted); padding: 40px 0; font-size: 14px;
}
.btn-load-more {
    display: block; width: 100%; background: var(--bg-tertiary); border: 1px solid var(--border);
    color: var(--text-secondary); padding: 10px; border-radius: 8px; cursor: pointer;
    font-size: 13px; margin-top: 12px; transition: all 0.2s;
}
.btn-load-more:hover { border-color: var(--text-muted); color: var(--text-primary); }
.btn-upload-photo {
    background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary);
    padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
    transition: all 0.2s;
}
.btn-upload-photo:hover { border-color: var(--accent); color: var(--accent); }

/* Lightbox actions */
.lightbox-actions {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 12px; z-index: 2001;
}
.lightbox-action-btn {
    background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3);
    color: white; width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
    backdrop-filter: blur(8px);
}
.lightbox-action-btn:hover { background: rgba(255,255,255,0.3); }
.lightbox-delete-btn:hover { background: rgba(220,50,50,0.6); }

/* Image gen result in panel */
#image-gen-result .generated-image-wrap { margin-top: 8px; }
#image-gen-result .generated-image-wrap img {
    max-width: 100%; max-height: 300px; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--border);
}

@media (max-width: 768px) {
    .image-panel-modal { max-width: 100vw; max-height: 90vh; }
    .style-grid { grid-template-columns: repeat(4, 1fr); }
    .image-grid { grid-template-columns: repeat(3, 1fr); }
    .image-tab { padding: 14px 10px 12px; font-size: 13px; }
}

/* Responsive */
@media (max-width: 768px) {
    .btn-icon { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }

}


/* ---- File Manager ---- */
.fm-header { margin-bottom: 16px; }
.fm-breadcrumb { font-size: 14px; margin-bottom: 12px; color: var(--text-secondary); display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.fm-bc-link { color: var(--accent); cursor: pointer; }
.fm-bc-link:hover { text-decoration: underline; }
.fm-bc-sep { color: var(--text-secondary); }
.fm-bc-current { color: var(--text-primary); font-weight: 600; }
.fm-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.fm-btn { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px; padding: 8px 16px; font-size: 13px; cursor: pointer; transition: background 0.2s; }
.fm-btn:hover { background: var(--border); }
.fm-btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.fm-btn-accent:hover { background: var(--accent-hover); }

.fm-list { max-height: 400px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.fm-item { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: default; transition: background 0.15s; }
.fm-item:last-child { border-bottom: none; }
.fm-item:hover { background: var(--bg-tertiary); }
.fm-folder { cursor: pointer; }
.fm-item-icon { font-size: 20px; width: 32px; text-align: center; flex-shrink: 0; }
/* svgIcon() 生成的行内图标：补 baseline 对齐，跟文字并排时不偏低 */
svg.ico { vertical-align: -0.15em; flex-shrink: 0; }
/* 文件夹图标染暖金，跟中性灰文件图标区分（方案A） */
svg.ico--folder { color: #c9a55a; }
.fm-item-info { flex: 1; min-width: 0; margin-left: 8px; }
.fm-item-name { font-size: 14px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-item-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.fm-item-actions { display: flex; gap: 4px; flex-shrink: 0; margin-left: 8px; opacity: 0; transition: opacity 0.15s; }
.fm-item:hover .fm-item-actions { opacity: 1; }
.fm-btn-sm { background: none; border: none; cursor: pointer; font-size: 14px; padding: 4px; border-radius: 4px; text-decoration: none; }
.fm-btn-sm:hover { background: var(--border); }
.fm-empty { padding: 40px; text-align: center; color: var(--text-secondary); font-size: 14px; }

.fm-storage { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.fm-storage-text { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.fm-storage-bar { height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; }
.fm-storage-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }

@media (max-width: 768px) {
    .fm-item-actions { opacity: 1; }
    .fm-toolbar { width: 100%; }
    .fm-btn { flex: 1; text-align: center; padding: 10px 8px; }
    .fm-list { max-height: 300px; }
}

/* ---- 小C 开发助手面板 ---- */
.xiaoc-overlay {
    display: none; position: fixed; inset: 0; z-index: 1100;
    background: rgba(0,0,0,0.7); align-items: center; justify-content: center;
}
.xiaoc-overlay.active { display: flex; }
.xiaoc-panel {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 16px; width: 760px; max-width: 94vw; height: 84vh; max-height: 84vh;
    display: flex; flex-direction: column; box-shadow: 0 20px 60px var(--shadow);
}
.xiaoc-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.xiaoc-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.xiaoc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.xiaoc-state-badge {
    font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px;
    background: var(--bg-tertiary); color: var(--text-secondary); margin-left: 4px;
}
.xiaoc-state-badge.confirming { background: rgba(200,140,40,0.18); color: #d8a040; }
.xiaoc-state-badge.executing { background: rgba(160,64,64,0.2); color: var(--accent-hover); }
.xiaoc-header-right { display: flex; align-items: center; gap: 10px; }
.xiaoc-model {
    background: var(--bg-tertiary); color: var(--text-secondary);
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 12px; padding: 4px 8px; cursor: pointer; max-width: 150px;
}
.xiaoc-model:hover { color: var(--text-primary); }
.xiaoc-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer; line-height: 1;
}
.xiaoc-close:hover { color: var(--text-primary); }
.xiaoc-stream { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.xiaoc-msg { max-width: 88%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.6; word-wrap: break-word; }
.xiaoc-msg.user { align-self: flex-end; background: var(--bg-tertiary); color: var(--text-primary); }
.xiaoc-msg.assistant { align-self: flex-start; color: var(--text-primary); }
.xiaoc-msg.assistant.streaming::after { content: "▋"; color: var(--accent); animation: xiaoc-blink 1s steps(2) infinite; }
.xiaoc-msg.muted { color: var(--text-muted); font-size: 13px; }
.xiaoc-msg.error { color: #ff6b6b; }
/* 小C 找图（#364）内联缩略图：封顶高度收成缩略、点开看原图（与 cc.css #366 同策略）。 */
.xiaoc-msg img {
    max-width: 100%; max-height: 260px; width: auto; height: auto;
    border-radius: 8px; display: block; margin: 6px 0;
    border: 1px solid var(--border); cursor: zoom-in;
}
@keyframes xiaoc-blink { 50% { opacity: 0; } }
.xiaoc-card {
    align-self: stretch; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.xiaoc-card-goal { font-size: 14px; color: var(--text-primary); line-height: 1.5; }
.xiaoc-card-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; }
.xiaoc-risk { padding: 2px 8px; border-radius: 8px; font-weight: 600; }
.xiaoc-risk.low { background: rgba(60,160,90,0.18); color: #4caf7d; }
.xiaoc-risk.medium { background: rgba(200,140,40,0.18); color: #d8a040; }
.xiaoc-risk.high { background: rgba(200,60,60,0.2); color: #e05555; }
.xiaoc-mut { color: var(--text-secondary); }
.xiaoc-card-warn { font-size: 12px; color: #e05555; }
.xiaoc-card-actions { display: flex; gap: 8px; justify-content: flex-end; }
.xiaoc-card-actions button { border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; cursor: pointer; }
.xiaoc-btn-cancel { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border) !important; }
.xiaoc-btn-confirm { background: var(--accent); color: #fff; }
.xiaoc-btn-confirm:hover { background: var(--accent-hover); }
.xiaoc-card-done { font-size: 13px; color: var(--text-muted); }
.xiaoc-msg.exec {
    align-self: stretch; max-width: 100%; background: var(--code-bg);
    border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
    display: flex; flex-direction: column; gap: 6px;
}
.xiaoc-exec-head { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.xiaoc-exec-report { margin-top: 8px; font-size: 12px; }
.xiaoc-exec-report > summary { cursor: pointer; color: var(--text-secondary); user-select: none; }
.xiaoc-exec-report-pre { margin: 6px 0 0; padding: 8px 10px; max-height: 320px; overflow: auto; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; font-family: monospace; font-size: 12px; line-height: 1.5; color: var(--text-muted); white-space: pre-wrap; word-break: break-word; }
.xiaoc-input-bar { display: flex; gap: 8px; align-items: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }
.xiaoc-input-bar textarea {
    flex: 1; resize: none; background: var(--bg-input); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
    font-size: 14px; line-height: 1.4; outline: none; max-height: 160px; font-family: inherit;
}
.xiaoc-input-bar textarea:focus { border-color: var(--accent); }
.xiaoc-input-bar textarea:disabled { opacity: 0.5; }
.xiaoc-send, .xiaoc-abort { border: none; border-radius: 10px; padding: 10px 18px; font-size: 14px; cursor: pointer; }
.xiaoc-send { background: var(--accent); color: #fff; }
.xiaoc-send:hover { background: var(--accent-hover); }
.xiaoc-abort { background: #c0392b; color: #fff; }
.xiaoc-mic {
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 10px; padding: 10px;
    background: var(--bg-input); color: var(--text-secondary); cursor: pointer;
    touch-action: none; -webkit-user-select: none; user-select: none;
    transition: background .15s, color .15s, border-color .15s;
}
.xiaoc-mic:hover { color: var(--text-primary); border-color: var(--accent); }
.xiaoc-mic.recording { background: var(--accent); color: #fff; border-color: var(--accent); animation: xiaoc-mic-pulse 1.2s ease-in-out infinite; }
.xiaoc-mic.busy { opacity: 0.5; cursor: default; }
@keyframes xiaoc-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(160, 64, 64, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(160, 64, 64, 0); }
}
.xiaoc-mic-status {
    display: none; margin: 8px 20px 0; padding: 6px 10px; font-size: 12px;
    color: var(--text-secondary); background: var(--bg-input);
    border: 1px solid var(--border); border-radius: 8px;
}
.xiaoc-mic-status.show { display: block; }
.xiaoc-mic-status.error { color: var(--accent-hover); border-color: var(--accent); }
@media (max-width: 768px) {
    .xiaoc-panel { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
}

/* ---- 融合主页（issue #361 Phase 1）：CC 内核嵌入 #app ---- */
/* #cc-root 是 .app flex 容器的唯一子项，需撑满宽度 */
.app > #cc-root { flex: 1; min-width: 0; }
/* .app 高度跟随 body（cc.css 用 --app-vh 管理真实视口高） */
.app { height: 100%; }
/* CC header 里混入的主页工具按钮尺寸对齐 cc 图标按钮 */
#cc-conv-header > .btn-icon,
#cc-conv-header > .tool-drawer > .btn-icon { flex-shrink: 0; }
/* 引擎选择器进了抽屉，ID 特异性会盖掉 .tool-drawer-item.btn-icon，显式对齐抽屉项 */
.tool-drawer-menu #cc-agent-btn {
  width: 100%; max-width: none; height: auto; min-width: 0; min-height: 0;
  justify-content: flex-start; gap: 10px; padding: 10px 12px;
  border: none; border-radius: 8px; background: none;
}
.tool-drawer-menu #cc-agent-btn:hover { background: var(--bg-tertiary); border-color: transparent; }
/* 图片模型选择器进了抽屉，同引擎选择器显式对齐抽屉项 */
.tool-drawer-menu #cc-imgmodel-btn {
  width: 100%; max-width: none; height: auto; min-width: 0; min-height: 0;
  justify-content: flex-start; gap: 10px; padding: 10px 12px;
  border: none; border-radius: 8px; background: none;
}
.tool-drawer-menu #cc-imgmodel-btn:hover { background: var(--bg-tertiary); border-color: transparent; }

/* ---- 融合主页换肤：让 CC 内核读起来像原主页 ----
   全部 scoped 到 body[data-cc-embedded]，独立 cc.html（无该属性）保持开发工具原貌。
   前缀带 body[data-cc-embedded] 特异性高于 cc.css 的裸 #id，故无视加载顺序稳定生效。 */

/* 列宽向原主页靠拢：左栏 280（对话列表），右栏 FILES 收窄一点。
   ⚠️ 只在桌面生效——cc.css @media(max-width:768px) 把三栏塌成单栏（左栏/FILES 走抽屉），
   这里若不限定 min-width，特异性更高的裸规则会盖掉手机单栏，露出空 FILES 列的黑条。 */
@media (min-width: 769px) {
  body[data-cc-embedded] #cc-root { grid-template-columns: 280px 1fr 300px; }
  body[data-cc-embedded] #cc-root.files-collapsed { grid-template-columns: 280px 1fr 0; }
}

/* 浅色模式：cc.css 的变量(--bg/--panel/…)是硬编码深色、不跟 data-theme。
   融合页复用主 app 的 data-theme，这里把 cc.css 变量重映射到浅色，
   让内嵌 cc-root 的气泡/面板/边框整体跟随设置里的浅/深色。scoped 到融合页，独立 cc.html 不受影响。 */
body[data-cc-embedded][data-theme="light"] {
  --bg: #f7f5f3; --panel: #ffffff; --panel2: #f1eeeb;
  --border: #e7e2dd; --border-strong: #d6cfc8;
  --text: #211d1a; --muted: #9a938b;
  --accent-soft: rgba(209,90,66,0.10);
  --accent-glow: rgba(209,90,66,0.22);
  --accent-grad: linear-gradient(135deg, #e06a52 0%, #cf5236 100%);
}

/* 全局去掉开发感的大写/字距 */
body[data-cc-embedded] aside header,
body[data-cc-embedded] #cc-conv-header { text-transform: none; letter-spacing: 0; }

/* 左栏 = 亲切的对话列表 */
body[data-cc-embedded] #cc-workspaces { background: var(--bg-secondary); }
body[data-cc-embedded] #cc-workspaces > header {
  padding: 16px; background: var(--bg-secondary);
  color: var(--text-primary); font-size: 20px; font-weight: 700;
}
body[data-cc-embedded] #cc-workspaces > header span { flex: 1; font-weight: 700; }
/* ＋新对话 → accent 药丸按钮（原 .btn-new-chat 观感） */
body[data-cc-embedded] #cc-new-ws {
  margin-left: auto; width: auto; height: auto; padding: 8px 14px;
  background: var(--accent-grad); color: #fff; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  box-shadow: 0 2px 10px -2px var(--accent-glow);
  transition: transform 0.12s, box-shadow 0.2s, filter 0.2s;
}
body[data-cc-embedded] #cc-new-ws:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 6px 16px -3px var(--accent-glow); }
/* 搜索框：低调一点 */
body[data-cc-embedded] #cc-ws-search {
  margin: 0 12px 6px; background: var(--bg-tertiary); border-color: var(--border);
  border-radius: 8px; font-family: inherit;
}
/* 对话项：大内边距、圆角、悬停高亮 */
body[data-cc-embedded] #cc-workspaces ul { padding: 8px; }
body[data-cc-embedded] #cc-workspaces li { padding: 2px; margin-bottom: 2px; border-radius: 8px; }
body[data-cc-embedded] #cc-workspaces li.system { font-weight: 400; }
body[data-cc-embedded] #cc-workspaces li .cc-ws-body { padding: 9px 12px; }
body[data-cc-embedded] #cc-workspaces li .cc-ws-body > div:first-child {
  font-size: 14px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body[data-cc-embedded] #cc-workspaces li.active .cc-ws-body > div:first-child { color: var(--text-primary); }
body[data-cc-embedded] #cc-workspaces li .meta { font-size: 11px; color: var(--text-muted); }
body[data-cc-embedded] #cc-workspaces li { position: relative; }
body[data-cc-embedded] #cc-workspaces li:hover { background: var(--bg-tertiary); }
body[data-cc-embedded] #cc-workspaces li.active { background: var(--accent-soft); }
body[data-cc-embedded] #cc-workspaces li.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 999px; background: var(--accent-grad);
}
/* 底部工具按钮：低调 */
body[data-cc-embedded] #cc-file-archive-btn,
body[data-cc-embedded] #cc-recycle-btn,
body[data-cc-embedded] #cc-trial-btn { border-radius: 8px; }

/* 顶栏：对齐原主页 topbar 高度/内边距 */
body[data-cc-embedded] #cc-conv-header { min-height: 56px; padding: 10px 16px; background: var(--bg-primary); }
body[data-cc-embedded] #cc-conv-title { color: var(--text-primary); font-size: 15px; }

/* 消息区：更宽松的留白 */
body[data-cc-embedded] #cc-messages { padding: 20px; }

/* 输入区：对齐原主页手感 */
body[data-cc-embedded] #cc-input-bar { padding: 14px 18px; background: var(--bg-primary); }
body[data-cc-embedded] #cc-input { border-radius: 10px; }

/* FILES：留着（用户要），仅去掉开发感的大写标题 */
body[data-cc-embedded] #cc-files > header { color: var(--text-secondary); }

/* 浅色模式下 cc.css 消息渲染里几处硬编码的深色主题色会失效（白字白底/深字深底），
   逐个改成浅色可读值。仅融合页浅色生效，深色与独立 cc.html 不动。 */
body[data-cc-embedded][data-theme="light"] .cc-msg.assistant strong,
body[data-cc-embedded][data-theme="light"] .cc-msg.assistant th { color: #1a1a2e; }
body[data-cc-embedded][data-theme="light"] .cc-msg.assistant pre { background: #f0f2f5; }
body[data-cc-embedded][data-theme="light"] .cc-msg.assistant pre code { color: #1a1a2e; }
body[data-cc-embedded][data-theme="light"] .cc-msg.assistant code { color: #b83280; }
body[data-cc-embedded][data-theme="light"] .cc-msg.tool_use { background: #eaf5ee; color: #1a1a2e; }

/* 对话区 Koi 大字水印（融合主页专属，纯 CSS，压在消息层之下不挡文字；
   独立 cc.html 开发工具无 data-cc-embedded，不受影响） */
body[data-cc-embedded] #cc-conversation { position: relative; overflow: hidden; }
body[data-cc-embedded] #cc-conversation::after {
  content: "Koi"; position: absolute; right: -4px; bottom: 78px;
  font-size: 170px; font-weight: 800; letter-spacing: -0.05em; line-height: 1;
  color: var(--accent); opacity: 0.08; transform: rotate(-8deg);
  pointer-events: none; user-select: none; z-index: 0;
}
/* 手机端：输入区/量表占底部更多高度，水印上移一些以免被压到底边或叠到输入框 */
@media (max-width: 768px) {
  body[data-cc-embedded] #cc-conversation::after { bottom: 140px; }
}
body[data-cc-embedded] #cc-messages,
body[data-cc-embedded] #cc-meters,
body[data-cc-embedded] #cc-input-bar { position: relative; z-index: 1; }
/* 顶栏层级要高于消息区：抽屉「…」下拉菜单是 header 内的绝对定位子元素，其 z-index 只在
   header 的 stacking context 内有效；若 header 与 #cc-messages 同为 z-index:1，DOM 更靠后的
   消息区会整体盖住下拉，加上 AI 气泡 --msg-ai:transparent 无填充，消息深色文字便叠印在白色
   菜单上（看着像菜单透明）。把 header 提到消息区之上，下拉正常遮盖消息。 */
body[data-cc-embedded] #cc-conv-header { position: relative; z-index: 30; }
