/* ============ 全局重置 ============ */
[v-cloak] { display: none !important; }
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #app {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 13px;
  background: #1e1e1e;
  color: #d4d4d4;
  user-select: none;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ============ 顶部工具栏 ============ */
.toolbar {
  height: 44px;
  background: #323233;
  border-bottom: 1px solid #3c3c3c;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.logo {
  font-weight: 600;
  font-size: 14px;
  color: #569cd6;
  margin-right: 8px;
  white-space: nowrap;
}
.engine-switcher {
  display: flex;
  gap: 2px;
  background: #252526;
  padding: 2px;
  border-radius: 4px;
  border: 1px solid #3c3c3c;
}
.engine-tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  color: #888;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.engine-tab:hover {
  color: #ddd;
  background: #2d2d30;
}
.engine-tab.active {
  background: #1e1e1e;
  border-bottom: 2px solid currentColor;
}
.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #d4d4d4;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  transition: all 0.15s;
}
.tool-btn:hover {
  background: #3c3c3c;
  border-color: #4d4d4d;
}
.tool-btn:active { background: #505050; }
.tool-btn.small { padding: 2px 8px; font-size: 11px; }
.tool-btn.btn-primary {
  background: #0e639c;
  border-color: #1177bb;
  color: #fff;
}
.tool-btn.btn-primary:hover { background: #1177bb; }
.tool-btn.active {
  background: #2d5a3d;
  border-color: #4a8c60;
  color: #8ee8a8;
}

/* 语法检查角标 */
.lint-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  margin-left: 4px;
}
.lint-badge.error {
  background: #5a2020;
  color: #ff8080;
  border: 1px solid #803030;
}
.lint-badge.warn {
  background: #5a4520;
  color: #ffc880;
  border: 1px solid #806630;
}

/* CodeMirror lint 标记颜色覆盖（配合dracula主题） */
.cm-s-dracula .CodeMirror-lint-marker-error {
  background: #ff5370;
  border-radius: 50%;
}
.cm-s-dracula .CodeMirror-lint-marker-warning {
  background: #ffcb6b;
  border-radius: 50%;
}
.cm-s-dracula .CodeMirror-lint-tooltip {
  background: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #444;
  font-size: 12px;
}
.cm-s-dracula .CodeMirror-lint-message-error {
  color: #ff8080;
}
.cm-s-dracula .CodeMirror-lint-message-warning {
  color: #ffc880;
}

/* 命令自动补全弹窗（配合dracula主题） */
.CodeMirror-hints {
  background: #282a36;
  border: 1px solid #44475a;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  padding: 4px 0;
  max-height: 240px;
  z-index: 1000;
}
.CodeMirror-hint {
  color: #f8f8f2;
  padding: 4px 12px;
}
li.CodeMirror-hint-active {
  background: #44475a;
  color: #50fa7b;
}

/* 草稿恢复提示条 */
.draft-toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: #2d5a3d;
  color: #8ee8a8;
  padding: 8px 18px;
  border-radius: 6px;
  border: 1px solid #4a8c60;
  font-size: 13px;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.divider {
  width: 1px;
  height: 20px;
  background: #4d4d4d;
  margin: 0 4px;
}
.type-select {
  background: #3c3c3c;
  color: #d4d4d4;
  border: 1px solid #4d4d4d;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}
.filename-wrap {
  display: inline-flex;
  align-items: center;
}
.filename {
  font-size: 12px;
  color: #9cdcfe;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background 0.15s;
}
.filename:hover {
  background: rgba(255,255,255,0.08);
}
.filename-input {
  background: #1e1e1e;
  border: 1px solid #569cd6;
  color: #9cdcfe;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 3px;
  width: 200px;
  outline: none;
  font-family: inherit;
}
.filename.modified::after {
  content: ' ●';
  color: #e0c286;
}

/* ============ 主体布局 ============ */
.main {
  display: flex;
  flex: 1;
  height: calc(100% - 44px - 24px);
  overflow: hidden;
}

/* ============ 左侧面板 ============ */
.left-panel {
  width: 240px;
  min-width: 180px;
  max-width: 500px;
  background: #252526;
  border-right: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.left-panel.collapsed {
  width: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
}
.panel-header {
  height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2d2d2d;
  border-bottom: 1px solid #3c3c3c;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #bbb;
  flex-shrink: 0;
}
.collapse-btn {
  background: transparent;
  border: none;
  color: #888;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 3px;
}
.collapse-btn:hover { background: #3c3c3c; color: #fff; }
.panel-search { padding: 8px; flex-shrink: 0; }
.search-input {
  width: 100%;
  background: #3c3c3c;
  border: 1px solid #4d4d4d;
  color: #d4d4d4;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}
.search-input:focus { border-color: #0e639c; }

.cmd-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.cmd-list::-webkit-scrollbar { width: 8px; }
.cmd-list::-webkit-scrollbar-track { background: #252526; }
.cmd-list::-webkit-scrollbar-thumb { background: #424242; border-radius: 4px; }
.cmd-list::-webkit-scrollbar-thumb:hover { background: #555; }

.cmd-category { margin-bottom: 2px; }
.cat-title {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #c5c5c5;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  user-select: none;
}
.cat-title:hover { background: #2a2d2e; }
.cat-items { padding: 2px 0; }
.cmd-item {
  padding: 5px 12px 5px 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 2px solid transparent;
}
.cmd-item:hover {
  background: #2a2d2e;
  border-left-color: #569cd6;
}
.cmd-name {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  color: #dcdcaa;
}
.cmd-desc {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ 拖拽分隔条 ============ */
.resizer {
  width: 5px;
  flex-shrink: 0;
  background: #3c3c3c;
  cursor: col-resize;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
}
.resizer:hover,
.resizer.dragging {
  background: #0e639c;
}
.resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 32px;
  background: #666;
  border-radius: 1px;
}
.resizer:hover::after {
  background: #fff;
}

/* ============ 中间编辑区 ============ */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #2d2d2d;
  border-bottom: 1px solid #3c3c3c;
  flex-wrap: wrap;
}
.search-bar .search-input { width: 180px; }
.close-btn { margin-left: auto; }

#editor { display: none; }
.CodeMirror {
  flex: 1;
  height: 100% !important;
  font-family: 'Consolas', 'Courier New', monospace !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
}
.CodeMirror-gutters {
  background: #252526 !important;
  border-right: 1px solid #3c3c3c !important;
}
.CodeMirror-linenumber { color: #858585 !important; }
.CodeMirror-activeline-background { background: #2a2d2e !important; }

/* ============ 右侧AI面板 ============ */
.right-panel {
  width: 480px;
  min-width: 300px;
  max-width: 700px;
  background: #252526;
  border-left: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.right-panel.collapsed {
  width: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
}
.ai-quick {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid #3c3c3c;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.quick-btn {
  background: #3c3c3c;
  border: 1px solid #4d4d4d;
  color: #d4d4d4;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
}
.quick-btn:hover { background: #505050; border-color: #0e639c; }

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  position: relative;
}
.chat-list::-webkit-scrollbar { width: 6px; }
.chat-list::-webkit-scrollbar-thumb { background: #424242; border-radius: 3px; }

.jump-bottom-btn {
  position: sticky;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: table;
  margin: 10px auto 0;
  padding: 5px 14px;
  background: #0e639c;
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  z-index: 10;
}
.jump-bottom-btn:hover { background: #1177bb; }

.chat-msg {
  display: flex;
  margin-bottom: 12px;
}
.chat-msg.user { justify-content: flex-end; }
.msg-content {
  max-width: 90%;
  background: #2d2d2d;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}
.chat-msg.user .msg-content {
  background: #0e639c;
  color: #fff;
}
.msg-text { white-space: pre-wrap; }
.msg-text p { margin-bottom: 8px; }
.msg-text p:last-child { margin-bottom: 0; }
.msg-text code {
  background: #1e1e1e;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  color: #ce9178;
}
.msg-text pre {
  background: #1e1e1e;
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg-text ul, .msg-text ol { padding-left: 20px; margin: 6px 0; }

.code-block {
  background: #1e1e1e;
  border: 1px solid #3c3c3c;
  border-radius: 6px;
  margin: 8px 0;
  overflow: hidden;
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: #2d2d2d;
  border-bottom: 1px solid #3c3c3c;
  font-size: 11px;
  color: #888;
}
.code-header > div { display: flex; gap: 4px; }
.code-action {
  background: #3c3c3c;
  border: 1px solid #4d4d4d;
  color: #d4d4d4;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
}
.code-action:hover { background: #505050; }
.code-action.primary { background: #0e639c; border-color: #1177bb; color: #fff; }
.code-action.primary:hover { background: #1177bb; }
.code-block pre {
  padding: 10px;
  overflow-x: auto;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #d4d4d4;
  max-height: 240px;
  overflow-y: auto;
}

.typing { color: #888; font-style: italic; }
.dots { animation: blink 1.4s infinite; }
@keyframes blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.ai-input {
  padding: 10px;
  border-top: 1px solid #3c3c3c;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.ai-input textarea {
  flex: 1;
  background: #3c3c3c;
  border: 1px solid #4d4d4d;
  color: #d4d4d4;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  resize: none;
  height: 60px;
  outline: none;
}
.ai-input textarea:focus { border-color: #0e639c; }
.send-btn {
  background: #0e639c;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  font-size: 13px;
  align-self: flex-end;
  height: 60px;
}
.send-btn:hover:not(:disabled) { background: #1177bb; }
.send-btn:disabled { background: #3c3c3c; color: #666; cursor: not-allowed; }
.send-btn.stop-btn { background: #8b2e2e; }
.send-btn.stop-btn:hover { background: #a83838; }

/* ============ 底部状态栏 ============ */
.statusbar {
  height: 24px;
  background: #007acc;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 20px;
  font-size: 11px;
  flex-shrink: 0;
}

/* ============ 设置弹窗 ============ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: #252526;
  border: 1px solid #3c3c3c;
  border-radius: 8px;
  padding: 24px;
  width: 520px;
  max-width: 90vw;
}
.modal h3 {
  font-size: 16px;
  margin-bottom: 18px;
  color: #fff;
}
.form-item {
  margin-bottom: 14px;
}
.form-item label {
  display: block;
  font-size: 12px;
  color: #bbb;
  margin-bottom: 5px;
}
.form-item input, .form-item textarea {
  width: 100%;
  background: #3c3c3c;
  border: 1px solid #4d4d4d;
  color: #d4d4d4;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
}
.form-item input:focus, .form-item textarea:focus { border-color: #0e639c; }
.form-row { display: flex; gap: 10px; }
.form-col { flex: 1; min-width: 0; }
.form-col label { font-size: 11px; }
.form-switch { display: flex; align-items: center; }
.switch-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: #d4d4d4 !important; margin: 0 !important; }
.switch-label input { width: auto !important; margin: 0; }
.msg-reasoning {
  background: #252530;
  border-left: 3px solid #6b5b95;
  border-radius: 4px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #9a9ab0;
}
.reasoning-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
}
.reasoning-header:hover { background: #2d2d3a; }
.reasoning-toggle { margin-left: auto; font-size: 11px; color: #7a7a90; }
.reasoning-icon { font-size: 12px; }
.reasoning-body {
  padding: 0 10px 10px 10px;
  white-space: pre-wrap;
  line-height: 1.6;
  max-height: 240px;
  overflow-y: auto;
  border-top: 1px solid #33333f;
  padding-top: 8px;
}
.apply-key-link {
  color: #569cd6;
  font-size: 11px;
  text-decoration: none;
  margin-left: 8px;
}
.apply-key-link:hover { text-decoration: underline; color: #7fbeff; }
.settings-tip {
  font-size: 11px;
  color: #888;
  line-height: 1.5;
  margin: 10px 0 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 折叠时隐藏内部内容 */
.left-panel.collapsed .panel-header > span,
.right-panel.collapsed .panel-header > span,
.right-panel.collapsed .panel-header > div { display: none; }
.left-panel.collapsed .panel-header,
.right-panel.collapsed .panel-header {
  justify-content: center;
  writing-mode: vertical-rl;
  height: auto;
  padding: 12px 0;
  cursor: pointer;
  gap: 8px;
}
.left-panel.collapsed .panel-header .collapse-btn,
.right-panel.collapsed .panel-header .collapse-btn {
  writing-mode: horizontal-tb;
  font-size: 14px;
  padding: 4px;
  background: transparent;
  border: none;
  color: #888;
}
.left-panel.collapsed .panel-header .collapse-btn:hover,
.right-panel.collapsed .panel-header .collapse-btn:hover {
  color: #fff;
}
.left-panel.collapsed .panel-header:hover,
.right-panel.collapsed .panel-header:hover {
  background: #3c3c3c;
}

/* ============ 知识库设置 ============ */
.kb-section {
  border-top: 1px solid #3c3c3c;
  padding-top: 12px;
  margin-top: 4px;
}
.kb-status {
  font-size: 12px;
  color: #4ec9b0;
}
.donate-btn {
  color: #f0b040 !important;
}
.donate-btn:hover {
  background: #3c2c10 !important;
  border-color: #8a6d2f !important;
}

/* ============ 反馈弹窗 ============ */
.modal-small {
  width: 380px !important;
  text-align: center;
}
.feedback-text, .donate-text, .donate-sub {
  font-size: 14px;
  color: #d4d4d4;
  margin-bottom: 12px;
  line-height: 1.6;
}
.donate-sub {
  font-size: 12px;
  color: #888;
}
.feedback-email {
  margin: 16px 0;
}
.feedback-email a {
  font-size: 18px;
  color: #569cd6;
  text-decoration: none;
  font-family: 'Consolas', monospace;
}
.feedback-email a:hover {
  text-decoration: underline;
}
.feedback-note {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
}

/* ============ 打赏弹窗 ============ */
.donate-modal .donate-qr {
  margin: 20px auto;
  display: flex;
  justify-content: center;
}
.qr-placeholder {
  width: 200px;
  height: 200px;
  background: #1e1e1e;
  border: 2px dashed #4d4d4d;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #666;
}
.qr-placeholder p:first-child {
  font-size: 48px;
  margin-bottom: 8px;
}
.qr-tip {
  font-size: 11px !important;
  color: #888 !important;
  line-height: 1.5;
}
.qr-tip code {
  background: #3c3c3c;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  color: #ce9178;
}
.donate-thanks {
  font-size: 14px;
  color: #f0b040;
  margin-top: 12px;
}
.donate-modal .modal-actions {
  justify-content: center;
  margin-top: 16px;
}
.donate-qr-img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #3c3c3c;
}

/* ========== 标签栏 ========== */
.tab-bar {
  display: flex;
  align-items: center;
  background: #252526;
  border-bottom: 1px solid #1e1e1e;
  height: 34px;
  padding: 0 4px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  user-select: none;
}
.tab-bar::-webkit-scrollbar { height: 3px; }
.tab-bar::-webkit-scrollbar-thumb { background: #3c3c3c; border-radius: 2px; }

.tab {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 8px 0 12px;
  margin-right: 2px;
  background: #2d2d2d;
  color: #969696;
  font-size: 12.5px;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  border: 1px solid transparent;
  border-bottom: none;
  transition: background .12s, color .12s;
}
.tab:hover {
  background: #333333;
  color: #d4d4d4;
}
.tab.active {
  background: #1e1e1e;
  color: #ffffff;
  border-color: #2b2b2b;
}
.tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: #007acc;
  border-radius: 2px 2px 0 0;
}
.tab-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-dot {
  color: #e0a040;
  font-size: 10px;
  line-height: 1;
}
.tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 3px;
  font-size: 11px;
  color: #888;
}
.tab-close:hover {
  background: #464647;
  color: #fff;
}
.tab-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: 4px;
  background: transparent;
  color: #969696;
  border: none;
  border-radius: 4px;
  font-size: 18px;
  cursor: pointer;
}
.tab-new:hover {
  background: #333333;
  color: #fff;
}

/* 编辑器区域适配标签栏 */
.editor-area {
  display: flex;
  flex-direction: column;
}
.editor-area .CodeMirror {
  flex: 1;
  height: auto !important;
}

.qq-group-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  background: #1e2228;
  border: 1px solid #2d3139;
  border-radius: 6px;
  font-size: 13px;
}
.qq-group-label { color: #c8ccd4; }
.qq-group-number {
  color: #4fc3f7;
  font-weight: 600;
  font-family: 'Consolas', 'Monaco', monospace;
  letter-spacing: 0.5px;
}
.qq-copy-btn {
  padding: 3px 10px !important;
  font-size: 12px !important;
  margin-left: auto;
}

/* ============ 云端存储模块 ============ */

/* 用户登录区域 */
.user-auth-area {
  display: flex;
  align-items: center;
  margin-left: 4px;
}
.user-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.user-dropdown:hover {
  background: #3c3c3c;
}
.user-name {
  font-size: 12px;
  color: #9cdcfe;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-arrow {
  font-size: 10px;
  color: #888;
}
.user-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: #2d2d2d;
  border: 1px solid #3c3c3c;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  min-width: 140px;
  z-index: 1000;
  padding: 4px 0;
}
.user-menu-item {
  padding: 8px 14px;
  font-size: 12px;
  color: #d4d4d4;
  cursor: pointer;
  transition: background 0.1s;
}
.user-menu-item:hover {
  background: #3c3c3c;
  color: #fff;
}

/* 登录/注册弹窗 */
.auth-modal {
  width: 380px !important;
}
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid #3c3c3c;
}
.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: #888;
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.auth-tab:hover {
  color: #d4d4d4;
}
.auth-tab.active {
  color: #569cd6;
  border-bottom-color: #0e639c;
}
.auth-error {
  color: #f44747;
  font-size: 12px;
  margin: 8px 0;
  padding: 6px 10px;
  background: rgba(244,71,71,0.1);
  border-radius: 4px;
}

/* 云端面板 */
.cloud-panel {
  width: 280px;
  min-width: 220px;
  max-width: 500px;
  background: #252526;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.cloud-panel-header {
  height: 36px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2d2d2d;
  border-bottom: 1px solid #3c3c3c;
  flex-shrink: 0;
}
.cloud-tabs {
  display: flex;
  gap: 2px;
}
.cloud-tab {
  background: transparent;
  border: none;
  color: #888;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}
.cloud-tab:hover {
  color: #d4d4d4;
  background: #3c3c3c;
}
.cloud-tab.active {
  color: #fff;
  background: #37373d;
}
.cloud-panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cloud-login-hint {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #888;
  font-size: 13px;
  padding: 20px;
  text-align: center;
}
.cloud-toolbar {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid #3c3c3c;
  align-items: center;
  flex-shrink: 0;
}
.cloud-search {
  flex: 1;
  min-width: 0;
}
.cloud-toolbar.var-actions {
  border-bottom: none;
  padding-bottom: 4px;
}
.var-type-filter {
  background: #3c3c3c;
  border: 1px solid #4d4d4d;
  color: #d4d4d4;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 11px;
  outline: none;
  cursor: pointer;
  max-width: 110px;
}

/* 文件夹树 */
.cloud-tree {
  flex-shrink: 0;
  max-height: 45%;
  overflow-y: auto;
  border-bottom: 1px solid #3c3c3c;
}
.cloud-tree::-webkit-scrollbar { width: 6px; }
.cloud-tree::-webkit-scrollbar-track { background: #252526; }
.cloud-tree::-webkit-scrollbar-thumb { background: #424242; border-radius: 3px; }

.tree-folder {
  display: flex;
  align-items: center;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  gap: 4px;
  transition: background 0.1s;
  user-select: none;
}
.tree-folder:hover {
  background: #2a2d2e;
}
.tree-folder.active {
  background: #094771;
  color: #fff;
}
.tree-folder.root {
  font-weight: 600;
}
.folder-toggle {
  width: 16px;
  text-align: center;
  font-size: 10px;
  color: #888;
  flex-shrink: 0;
}
.folder-icon {
  font-size: 13px;
  flex-shrink: 0;
}
.folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-count {
  font-size: 10px;
  color: #888;
  background: #3c3c3c;
  padding: 1px 6px;
  border-radius: 8px;
}
.folder-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}
.tree-folder:hover .folder-actions {
  display: flex;
}
.icon-btn {
  background: transparent;
  border: none;
  color: #888;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}
.icon-btn:hover {
  background: #4d4d4d;
  color: #fff;
}
.icon-btn.danger:hover {
  background: #5a2020;
  color: #ff8080;
}

/* 脚本列表 */
.cloud-script-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.cloud-script-list::-webkit-scrollbar { width: 6px; }
.cloud-script-list::-webkit-scrollbar-track { background: #252526; }
.cloud-script-list::-webkit-scrollbar-thumb { background: #424242; border-radius: 3px; }

.cloud-script-item {
  display: flex;
  align-items: center;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  gap: 6px;
  transition: background 0.1s;
}
.cloud-script-item:hover {
  background: #2a2d2e;
}
.script-icon {
  font-size: 12px;
  flex-shrink: 0;
}
.script-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #d4d4d4;
}
.script-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}
.cloud-script-item:hover .script-actions {
  display: flex;
}
.cloud-loading, .cloud-empty {
  text-align: center;
  padding: 20px;
  color: #666;
  font-size: 12px;
}

/* 变量列表 */
.var-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.var-list::-webkit-scrollbar { width: 6px; }
.var-list::-webkit-scrollbar-track { background: #252526; }
.var-list::-webkit-scrollbar-thumb { background: #424242; border-radius: 3px; }

.var-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  gap: 8px;
  font-size: 12px;
  border-bottom: 1px solid #2a2a2a;
}
.var-item:hover {
  background: #2a2d2e;
}
.var-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Consolas', monospace;
  flex-shrink: 0;
}
.var-badge.type-U { background: #1a3a5c; color: #569cd6; }
.var-badge.type-T { background: #2a4a2a; color: #4ec9b0; }
.var-badge.type-G { background: #4a3a1a; color: #dcdcaa; }
.var-badge.type-P { background: #4a1a3a; color: #c586c0; }
.var-badge.type-D { background: #4a2a1a; color: #ce9178; }
.var-badge.type-S { background: #3a3a4a; color: #9cdcfe; }

.var-name-text {
  font-family: 'Consolas', 'Courier New', monospace;
  color: #dcdcaa;
  font-weight: 600;
  min-width: 42px;
  flex-shrink: 0;
}
.var-desc {
  flex: 1;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.var-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}
.var-item:hover .var-actions {
  display: flex;
}
.var-count {
  font-size: 10px;
  color: #888;
  background: #3c3c3c;
  padding: 1px 5px;
  border-radius: 8px;
}

/* 扫描结果 */
.scan-results {
  border-bottom: 1px solid #3c3c3c;
  max-height: 200px;
  overflow-y: auto;
  flex-shrink: 0;
}
.scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 11px;
  color: #888;
  background: #2d2d2d;
  position: sticky;
  top: 0;
}
.scan-list {
  padding: 4px 0;
}
.scan-item {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}
.scan-item:hover {
  background: #2a2d2e;
}
.scan-item input[type="checkbox"] {
  accent-color: #0e639c;
}

/* 云端保存弹窗 */
.cloud-save-modal {
  width: 420px !important;
}

/* 新增变量类型徽章颜色 (M/N/A/I) */
.var-badge.type-M { background: #3a2a4a; color: #c586c0; }
.var-badge.type-N { background: #1a4a3a; color: #4ec9b0; }
.var-badge.type-A { background: #4a2a2a; color: #f48771; }
.var-badge.type-I { background: #2a3a4a; color: #9cdcfe; }
.var-badge.type-J { background: #3a2a3a; color: #c9a0dc; }
.var-badge.type-F { background: #4a3a1a; color: #dcdcaa; }

/* ============ 移动端适配（<=768px） ============ */
.mobile-nav { display: none; }

@media screen and (max-width: 768px) {
  html, body, #app {
    font-size: 14px;
  }

  /* 顶部工具栏：可横向滚动，隐藏次要按钮 */
  .toolbar {
    height: auto;
    min-height: 44px;
    padding: 6px 8px;
    flex-wrap: wrap;
    gap: 4px;
  }
  .toolbar-left {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    gap: 4px;
  }
  .toolbar-left::-webkit-scrollbar { display: none; }
  .toolbar-right {
    width: 100%;
    justify-content: flex-end;
    gap: 4px;
  }
  .logo { display: none; }
  .tool-btn {
    padding: 6px 10px;
    font-size: 13px;
  }
  .divider { display: none; }
  .filename { font-size: 12px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }

  /* 主体：相对定位，面板绝对覆盖 */
  .main {
    position: relative;
    height: calc(100% - 44px - 52px - 24px);
  }
  .main.is-mobile .resizer { display: none !important; }

  /* 左侧命令面板：移动端作为覆盖层 */
  .main.is-mobile .left-panel {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 80% !important;
    max-width: 320px !important;
    min-width: 0 !important;
    z-index: 50;
    box-shadow: 2px 0 12px rgba(0,0,0,.5);
    transform: translateX(-100%);
    transition: transform .2s;
  }
  .main.is-mobile .left-panel:not(.collapsed) {
    transform: translateX(0);
  }

  /* 云端面板：全屏覆盖 */
  .main.is-mobile .cloud-panel {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    z-index: 40;
    margin: 0;
  }

  /* 右侧AI面板：全屏覆盖 */
  .main.is-mobile .right-panel {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    z-index: 40;
  }
  .main.is-mobile .right-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden;
  }

  /* 编辑器字号放大，方便触屏查看 */
  .CodeMirror {
    font-size: 15px !important;
    line-height: 1.7 !important;
  }
  .CodeMirror-gutters { min-width: 36px; }
  .CodeMirror-linenumber { font-size: 12px !important; padding: 0 6px 0 0; }

  /* 标签栏 */
  .tab-bar { overflow-x: auto; }
  .tab { padding: 6px 12px; font-size: 13px; }

  /* 云端面板触屏优化 */
  .cloud-script-item {
    padding: 12px 10px;
    min-height: 44px;
  }
  .cloud-script-item .script-name { font-size: 14px; }
  .icon-btn {
    min-width: 32px;
    min-height: 32px;
    font-size: 16px;
  }
  .var-item {
    padding: 10px 12px;
    min-height: 44px;
  }
  .tree-folder {
    padding: 10px 12px;
    min-height: 44px;
  }

  /* AI对话区 */
  .ai-quick { padding: 6px; gap: 4px; }
  .quick-btn { padding: 6px 10px; font-size: 12px; }
  .chat-list { padding: 10px; }
  .chat-msg { margin-bottom: 10px; }
  .msg-content {
    max-width: 88%;
    padding: 10px 12px;
    font-size: 14px;
  }
  .ai-input {
    padding: 8px;
    gap: 6px;
  }
  .ai-input textarea {
    height: 48px;
    font-size: 14px;
  }
  .send-btn {
    height: 48px;
    padding: 0 16px;
    font-size: 14px;
  }

  /* 命令面板 */
  .cmd-item { padding: 8px 12px 8px 20px; min-height: 36px; }
  .cmd-name { font-size: 13px; }
  .cmd-desc { font-size: 12px; }
  .cat-title { padding: 10px 12px; font-size: 13px; min-height: 40px; }

  /* 弹窗适配 */
  .modal-content { width: 92% !important; max-width: none !important; margin: 20px auto !important; }
  .modal-content input, .modal-content select, .modal-content textarea {
    font-size: 14px;
    padding: 8px 10px;
  }
  .auth-modal { width: 92% !important; }

  /* 底部三Tab导航 */
  .mobile-nav {
    display: flex;
    height: 52px;
    background: #252526;
    border-top: 1px solid #3c3c3c;
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mobile-nav-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #888;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    position: relative;
    transition: color .15s;
  }
  .mobile-nav-btn:active { background: #2d2d30; }
  .mobile-nav-btn.active {
    color: #569cd6;
  }
  .mn-icon { font-size: 20px; line-height: 1; }
  .mn-label { font-size: 11px; }
  .mn-dot {
    position: absolute;
    top: 6px;
    right: calc(50% - 22px);
    width: 8px;
    height: 8px;
    background: #e04040;
    border-radius: 50%;
  }

  /* 状态栏缩小 */
  .statusbar {
    height: 20px;
    font-size: 10px;
    padding: 0 8px;
    gap: 10px;
  }

  /* 扫描结果、变量列表等可滚动区域优化 */
  .scan-item { padding: 8px; min-height: 40px; }
  .scan-results { max-height: 40vh; }
  .search-input { font-size: 14px; padding: 8px 10px; }
}

@media screen and (max-width: 380px) {
  .toolbar-right .tool-btn { padding: 6px 8px; font-size: 12px; }
  .engine-tab { padding: 3px 8px; font-size: 11px; }
}

/* ====== 自动补全下拉项（命令+中文说明） ====== */
ul.CodeMirror-hints {
  font-family: 'Consolas', 'Microsoft YaHei', sans-serif;
  font-size: 13px;
  max-height: 320px;
  z-index: 9999;
  margin-top: 6px;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
li.CodeMirror-hint.mir-hint-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 10px;
  white-space: nowrap;
}
.mir-hint-code {
  font-family: 'Consolas', 'Courier New', monospace;
  font-weight: 600;
  color: #dcdcaa;
  min-width: 120px;
}
.mir-hint-code.type-var { color: #9cdcfe; }
.mir-hint-code.type-cmd { color: #dcdcaa; }
.mir-hint-desc {
  color: #6a9955;
  font-size: 12px;
  font-family: 'Microsoft YaHei', sans-serif;
}
li.CodeMirror-hint.mir-hint-item.CodeMirror-hint-active {
  background: #04395e;
}
li.CodeMirror-hint.mir-hint-item.CodeMirror-hint-active .mir-hint-desc {
  color: #b5cea8;
}
