/* ==========================================================================
   EasyRenpy 浮窗代码编辑器（v1.1）
   - 全部选择器以 .code-editor 前缀隔离，不污染全局样式
   - 颜色 / 字体 / 圆角 / 阴影全部使用 src/styles/base.css 变量
   - 层级：编辑器 z-index 250（低于模态框 300、toast 500）
   ========================================================================== */

.code-editor {
  position: fixed;
  inset: 0;
  z-index: 250;
  pointer-events: none;
  font-family: var(--font-ui);
  color: var(--text);
  --ce-font-size: 14px;
  --ce-line-height: 23px;
  --ce-char-width: 8.4px;
  --ce-pad-x: 12px;
  --ce-pad-y: 8px;
  --ce-indent-guide: rgba(148, 163, 184, 0.16);
  --ce-current-line: rgba(148, 163, 184, 0.06);
}

.code-editor[hidden] {
  display: none !important;
}

.code-editor.is-dragging,
.code-editor.is-dragging * {
  user-select: none !important;
  cursor: grabbing !important;
}

/* --------------------------------------------------------------------------
   窗口
   -------------------------------------------------------------------------- */

.code-editor-window {
  position: absolute;
  left: 80px;
  top: 60px;
  width: 1080px;
  height: 680px;
  display: flex;
  flex-direction: column;
  min-width: 560px;
  min-height: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  pointer-events: auto;
  animation: code-editor-in 0.16s var(--ease);
}

@keyframes code-editor-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.code-editor-window.is-maximized {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

.code-editor-window.is-minimized {
  height: auto !important;
  min-height: 0;
}

.code-editor-window.is-minimized .code-editor-tabs,
.code-editor-window.is-minimized .code-editor-info,
.code-editor-window.is-minimized .code-editor-find,
.code-editor-window.is-minimized .code-editor-body,
.code-editor-window.is-minimized .code-editor-lint,
.code-editor-window.is-minimized .code-editor-status,
.code-editor-window.is-minimized .code-editor-resize-handle,
.code-editor-window.is-minimized .code-editor-popover {
  display: none !important;
}

/* --------------------------------------------------------------------------
   标题栏
   -------------------------------------------------------------------------- */

.code-editor-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
  height: 38px;
  padding: 0 8px 0 12px;
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-panel));
  border-bottom: 1px solid var(--border);
  cursor: move;
  user-select: none;
}

.code-editor-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.code-editor-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 6px;
  background: var(--accent-weak);
  color: var(--accent-text);
}

.code-editor-title-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-editor-title-badge {
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-faint);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.code-editor-title-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  flex: none;
  cursor: default;
}

.code-editor-title-btn {
  width: 28px;
  height: 28px;
  color: var(--text-dim);
}

.code-editor-title-btn.is-danger:hover {
  background: var(--danger-weak);
  color: #fca5a5;
}

/* --------------------------------------------------------------------------
   标签页
   -------------------------------------------------------------------------- */

.code-editor-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex: none;
  height: 34px;
  padding: 0 8px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
}

.code-editor-tabs::-webkit-scrollbar {
  height: 4px;
}

.code-editor-tabs-empty {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 6px;
  color: var(--text-faint);
  font-size: 11px;
}

.code-editor-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 230px;
  height: 28px;
  flex: none;
  padding: 0 6px 0 10px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.12s var(--ease),
    color 0.12s var(--ease);
}

.code-editor-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.code-editor-tab.is-active {
  background: var(--bg-panel);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 -1px 0 var(--accent) inset;
}

.code-editor-tab.is-readonly .code-editor-tab-label {
  color: var(--text-dim);
}

.code-editor-tab-lock {
  display: inline-flex;
  color: var(--text-faint);
  flex: none;
}

.code-editor-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

/* v1.3 实时同步徽章 */
.code-editor-tab-live {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--success-weak);
  color: #86efac;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.code-editor-tab-live svg {
  width: 9px;
  height: 9px;
}

.code-editor-tab-live.is-paused {
  background: var(--warn-weak);
  color: #fcd34d;
}

.code-editor-tab-live.is-error {
  background: var(--danger-weak);
  color: #fca5a5;
}

html[data-theme="light"] .code-editor-tab-live {
  color: #15803d;
}
html[data-theme="light"] .code-editor-tab-live.is-paused {
  color: #b45309;
}
html[data-theme="light"] .code-editor-tab-live.is-error {
  color: #b91c1c;
}

.code-editor-tab-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-weak);
}

.code-editor-tab-conflict {
  display: inline-flex;
  color: var(--danger);
  flex: none;
}

.code-editor-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 4px;
  color: var(--text-faint);
  opacity: 0.55;
}

.code-editor-tab:hover .code-editor-tab-close,
.code-editor-tab.is-active .code-editor-tab-close {
  opacity: 1;
}

.code-editor-tab-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* --------------------------------------------------------------------------
   信息栏
   -------------------------------------------------------------------------- */

.code-editor-info {
  flex: none;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.code-editor-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 12px;
}

.code-editor-info-path {
  color: var(--text-dim);
  font-size: 11.5px;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-editor-info-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.code-editor-info-badges .chip {
  height: 19px;
  padding: 0 7px;
  font-size: 10px;
}

.code-editor-info-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-editor-info-notice {
  padding: 0;
}

.code-editor-info-notice:not(:empty) {
  padding: 0 12px 7px;
}

.code-editor-notice {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 24px;
  margin-top: 3px;
  padding: 4px 9px;
  border-radius: var(--radius-s);
  font-size: 11.5px;
  line-height: 1.5;
}

.code-editor-notice-icon {
  display: inline-flex;
  flex: none;
}

.code-editor-notice.is-info {
  background: var(--accent-weak);
  color: var(--accent-text);
}

.code-editor-notice.is-conflict {
  background: var(--warn-weak);
  color: #fcd34d;
}

.code-editor-notice.is-danger {
  background: var(--danger-weak);
  color: #fca5a5;
}

.code-editor-notice.is-muted {
  padding: 0;
  color: var(--text-faint);
  min-height: 18px;
}

.code-editor-notice .btn {
  height: 24px;
  font-size: 11px;
  flex: none;
}

.code-editor-notice-hint {
  margin-left: 4px;
  color: var(--text-faint);
  font-size: 11px;
}

/* --------------------------------------------------------------------------
   查找 / 替换
   -------------------------------------------------------------------------- */

.code-editor-find {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 6px 12px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.code-editor-find[hidden] {
  display: none !important;
}

.code-editor-find-icon {
  display: inline-flex;
  color: var(--text-faint);
  flex: none;
}

.code-editor-find-input {
  height: 26px;
  flex: 0 1 210px;
  min-width: 90px;
  padding: 0 8px;
  font-size: 12px;
}

.code-editor-find-count {
  min-width: 76px;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.code-editor-find-case {
  width: 26px;
  height: 26px;
  font-family: var(--font-code);
  font-size: 11px;
  font-weight: 700;
}

.code-editor-find-case.active {
  background: var(--accent-weak);
  color: var(--accent-text);
}

.code-editor-find-replace {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   代码区域
   -------------------------------------------------------------------------- */

.code-editor-body {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.code-editor-code {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  background: var(--bg-inset);
}

/* 行号 */
.code-editor-gutter {
  position: relative;
  flex: none;
  width: 52px;
  overflow: hidden;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  user-select: none;
}

.code-editor-gutter-inner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  will-change: transform;
}

.code-editor-line-number {
  height: var(--ce-line-height);
  line-height: var(--ce-line-height);
  padding-right: 10px;
  text-align: right;
  font-family: var(--font-code);
  font-size: var(--ce-font-size);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.code-editor-line-number.is-current {
  color: var(--accent-hover);
  font-weight: 600;
}

/* 编辑面板 */
.code-editor-pane {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.code-editor-current-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--ce-line-height);
  background: var(--ce-current-line);
  pointer-events: none;
  z-index: 0;
}

.code-editor-match-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.code-editor-match {
  position: absolute;
  border-radius: 2px;
  background: rgba(245, 158, 11, 0.22);
}

.code-editor-match.is-current {
  background: rgba(245, 158, 11, 0.42);
  outline: 1px solid rgba(245, 158, 11, 0.85);
}

/* 多光标（v1.2）：主光标使用原生 caret，附加光标由该层渲染 */
.code-editor-multi-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.code-editor-multi-cursor {
  position: absolute;
  width: 2px;
  border-radius: 1px;
  background: var(--accent-hover);
  box-shadow: 0 0 0 1px rgba(10, 12, 18, 0.35);
}

.code-editor-multi-selection {
  position: absolute;
  border-radius: 2px;
  background: rgba(99, 102, 241, 0.2);
}

html[data-theme="light"] .code-editor-multi-selection {
  background: rgba(79, 70, 229, 0.14);
}

html[data-theme="light"] .code-editor-multi-cursor {
  background: #4f46e5;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

/* 只读 CTA：生成文件只读 → 创建覆盖后可编辑 */
.code-editor-notice.is-readonly-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px dashed rgba(99, 102, 241, 0.55);
  background: var(--accent-weak);
  color: var(--accent-text);
}

.code-editor-notice.is-readonly-cta .code-editor-notice-text {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 12px;
}

.code-editor-notice.is-readonly-cta .btn {
  height: 26px;
  flex: none;
}

.code-editor-pane.is-readonly .code-editor-textarea {
  cursor: default;
}

.code-editor-status-multi {
  color: var(--accent-hover);
  font-weight: 600;
}

/* 高亮层（位于 textarea 背后） */
.code-editor-highlight {
  position: absolute;
  inset: 0;
  z-index: 2;
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
  font-family: var(--font-code);
  font-size: var(--ce-font-size);
  line-height: var(--ce-line-height);
  color: var(--text);
  white-space: pre;
  tab-size: 4;
  -moz-tab-size: 4;
}

.code-editor-hl-inner {
  position: absolute;
  top: 0;
  left: 0;
  white-space: pre;
  will-change: transform;
}

.code-editor .hl-line {
  display: block;
  height: var(--ce-line-height);
  line-height: var(--ce-line-height);
  white-space: pre;
  min-width: 100%;
}

/* 透明文字 textarea（可见的只有光标与选区） */
.code-editor-textarea {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--ce-pad-y) var(--ce-pad-x);
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  font-family: var(--font-code);
  font-size: var(--ce-font-size);
  line-height: var(--ce-line-height);
  white-space: pre;
  overflow: auto;
  tab-size: 4;
  -moz-tab-size: 4;
  letter-spacing: 0;
  font-variant-ligatures: none;
}

.code-editor-textarea:focus {
  box-shadow: none;
  border: 0;
}

.code-editor-textarea::selection {
  background: rgba(99, 102, 241, 0.35);
  color: transparent;
}

html[data-theme="light"] .code-editor-textarea::selection {
  background: rgba(79, 70, 229, 0.22);
}

html[data-theme="light"] .code-editor {
  --ce-indent-guide: rgba(15, 23, 42, 0.12);
  --ce-current-line: rgba(15, 23, 42, 0.05);
}

.code-editor-pane.is-readonly .code-editor-textarea {
  caret-color: var(--text-faint);
}

/* IME 组合输入：恢复原生文字显示，隐藏高亮层避免错位 */
.code-editor-pane.is-composing .code-editor-textarea {
  color: var(--text);
}

.code-editor-pane.is-composing .code-editor-highlight {
  visibility: hidden;
}

.code-editor-mirror {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  visibility: hidden;
  pointer-events: none;
  white-space: pre;
  overflow: hidden;
  font-family: var(--font-code);
  font-size: var(--ce-font-size);
  line-height: var(--ce-line-height);
  padding: var(--ce-pad-y) var(--ce-pad-x);
  tab-size: 4;
}

.code-editor-probe {
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
  white-space: pre;
  font-family: var(--font-code);
  font-size: var(--ce-font-size);
}

/* --------------------------------------------------------------------------
   Token 颜色
   -------------------------------------------------------------------------- */

.code-editor .tok-comment {
  color: #6b7280;
  font-style: italic;
}
.code-editor .tok-keyword {
  color: #c792ea;
  font-weight: 600;
}
.code-editor .tok-string {
  color: #a5d6a7;
}
.code-editor .tok-tag {
  color: #f472b6;
}
.code-editor .tok-number {
  color: #fbbf24;
}
.code-editor .tok-label {
  color: #7dd3fc;
}
.code-editor .tok-definition {
  color: #fbbf24;
  font-weight: 600;
}
.code-editor .tok-builtin {
  color: #67e8f9;
}
.code-editor .tok-attribute {
  color: #a5b4fc;
}
.code-editor .tok-call {
  color: #93c5fd;
}
.code-editor .tok-operator {
  color: #94a3b8;
}
.code-editor .tok-punct {
  color: #94a3b8;
}
.code-editor .tok-plain {
  color: var(--text);
}
.code-editor .is-bracket-match {
  background: rgba(99, 102, 241, 0.28);
  outline: 1px solid rgba(129, 140, 248, 0.55);
  border-radius: 2px;
}

html[data-theme="light"] .code-editor .tok-comment {
  color: #7b8794;
}
html[data-theme="light"] .code-editor .tok-keyword {
  color: #7c3aed;
}
html[data-theme="light"] .code-editor .tok-string {
  color: #15803d;
}
html[data-theme="light"] .code-editor .tok-tag {
  color: #be185d;
}
html[data-theme="light"] .code-editor .tok-number {
  color: #b45309;
}
html[data-theme="light"] .code-editor .tok-label {
  color: #0369a1;
}
html[data-theme="light"] .code-editor .tok-definition {
  color: #b45309;
}
html[data-theme="light"] .code-editor .tok-builtin {
  color: #0e7490;
}
html[data-theme="light"] .code-editor .tok-attribute {
  color: #4338ca;
}
html[data-theme="light"] .code-editor .tok-call {
  color: #1d4ed8;
}
html[data-theme="light"] .code-editor .tok-operator,
html[data-theme="light"] .code-editor .tok-punct {
  color: #64748b;
}

/* --------------------------------------------------------------------------
   补全下拉
   -------------------------------------------------------------------------- */

.code-editor-completions {
  position: absolute;
  z-index: 8;
  display: flex;
  flex-direction: column;
  max-height: 300px;
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-2);
}

.code-editor-completions[hidden] {
  display: none !important;
}

.code-editor-completion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
  padding: 5px 9px;
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 10px;
  white-space: nowrap;
}

.code-editor-completion-tip {
  color: var(--text-faint);
  opacity: 0.85;
}

.code-editor-completion-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.code-editor-completion-item {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 9px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  line-height: 1.35;
}

.code-editor-completion-item:hover {
  background: var(--bg-hover);
}

.code-editor-completion-item.is-active {
  background: var(--accent-weak);
}

.code-editor-completion-icon {
  display: inline-flex;
  flex: none;
  color: var(--text-dim);
}

.code-editor-completion-item.is-active .code-editor-completion-icon {
  color: var(--accent-text);
}

.code-editor-completion-label {
  flex: none;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-code);
  font-size: 12px;
  font-weight: 600;
}

.code-editor-completion-detail {
  flex: 1;
  min-width: 0;
  color: var(--text-faint);
  font-size: 11px;
}

.code-editor-completion-cat {
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-inset);
  color: var(--text-faint);
  font-size: 9.5px;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   悬停文档
   -------------------------------------------------------------------------- */

.code-editor-hover {
  position: absolute;
  z-index: 20;
  width: min(360px, 70%);
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--bg-elev);
  box-shadow: var(--shadow-2);
  font-size: 12px;
  pointer-events: none;
  animation: code-editor-hover-in 0.12s var(--ease);
}

.code-editor-hover[hidden] {
  display: none !important;
}

@keyframes code-editor-hover-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.code-editor-hover-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.code-editor-hover-cat {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.code-editor-hover-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-editor-hover-signature {
  margin: 0 0 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-inset);
  color: var(--accent-text);
  font-family: var(--font-code);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-editor-hover-doc {
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.code-editor-hover-hint {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  color: var(--text-faint);
  font-size: 10px;
}

/* --------------------------------------------------------------------------
   Lint 问题条
   -------------------------------------------------------------------------- */

.code-editor-lint {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 30px;
  max-height: 34px;
  padding: 2px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  font-size: 11px;
  overflow: hidden;
}

.code-editor-lint-summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 600;
}

.code-editor-lint-summary.is-ok {
  color: #86efac;
  background: var(--success-weak);
}

.code-editor-lint-summary.is-warn {
  color: #fcd34d;
  background: var(--warn-weak);
}

.code-editor-lint-summary.is-error {
  color: #fca5a5;
  background: var(--danger-weak);
}

.code-editor-lint-summary.is-muted {
  color: var(--text-faint);
  background: var(--bg-elev);
}

.code-editor-lint-list {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.code-editor-lint-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  max-width: 340px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
}

.code-editor-lint-item:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.code-editor-lint-item.is-error {
  border-left: 2px solid var(--danger);
}

.code-editor-lint-item.is-warn {
  border-left: 2px solid var(--warn);
}

.code-editor-lint-item.is-info {
  border-left: 2px solid var(--accent);
}

.code-editor-lint-line {
  flex: none;
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--text-faint);
}

.code-editor-lint-message {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

/* --------------------------------------------------------------------------
   状态栏
   -------------------------------------------------------------------------- */

.code-editor-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  height: 26px;
  padding: 0 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-faint);
  font-size: 11px;
  user-select: none;
  white-space: nowrap;
}

.code-editor-status-item {
  display: inline-flex;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.code-editor-status .btn {
  width: 20px;
  height: 20px;
  color: var(--text-faint);
}

.code-editor-status .btn:hover {
  color: var(--text);
}

.code-editor-status-sep {
  width: 1px;
  height: 12px;
  background: var(--border);
  flex: none;
}

.code-editor-status-state {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.code-editor-status-state.is-saved {
  color: #86efac;
  background: var(--success-weak);
}

.code-editor-status-state.is-dirty {
  color: #fcd34d;
  background: var(--warn-weak);
}

.code-editor-status-state.is-readonly {
  color: var(--accent-text);
  background: var(--accent-weak);
}

.code-editor-status-state.is-error {
  color: #fca5a5;
  background: var(--danger-weak);
}

.code-editor-status-state.is-synced {
  color: #86efac;
  background: var(--success-weak);
}

/* v1.3 实时同步提示条 */
.code-editor-notice.is-readonly-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px dashed rgba(99, 102, 241, 0.55);
  background: var(--accent-weak);
  color: var(--accent-text);
}

.code-editor-notice.is-readonly-cta .code-editor-notice-text {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 12px;
}

.code-editor-notice.is-readonly-cta .btn {
  height: 26px;
  flex: none;
}

.code-editor-sync-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

/* --------------------------------------------------------------------------
   设置 / 帮助浮层
   -------------------------------------------------------------------------- */

.code-editor-popover {
  position: absolute;
  top: 44px;
  right: 10px;
  z-index: 30;
  width: 286px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--bg-elev);
  box-shadow: var(--shadow-2);
  font-size: 12px;
  animation: code-editor-popover-in 0.13s var(--ease);
}

.code-editor-popover[hidden] {
  display: none !important;
}

@keyframes code-editor-popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.code-editor-popover-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.code-editor-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.code-editor-setting-label {
  color: var(--text-dim);
  font-size: 11.5px;
}

.code-editor-setting-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-editor-setting-control .btn {
  height: 24px;
  min-width: 24px;
  padding: 0 8px;
  font-size: 11px;
}

.code-editor-setting-control .btn-icon {
  width: 24px;
  padding: 0;
}

.code-editor-setting-control .btn.active {
  background: var(--accent-weak);
  border-color: transparent;
  color: var(--accent-text);
}

.code-editor-setting-value {
  min-width: 40px;
  text-align: center;
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--text);
}

.code-editor-setting-hint {
  margin: 8px 0 0;
  color: var(--text-faint);
  font-size: 10.5px;
  line-height: 1.6;
}

.code-editor-setting-reset {
  margin-top: 8px;
}

.code-editor-help {
  width: 350px;
}

.code-editor-help-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 0;
  font-size: 11.5px;
  line-height: 1.5;
}

.code-editor-help-row .kbd {
  flex: none;
  white-space: nowrap;
}

.code-editor-help-desc {
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   8 向缩放手柄
   -------------------------------------------------------------------------- */

.code-editor-resize-handle {
  position: absolute;
  z-index: 25;
}

.code-editor-resize-n {
  top: -3px;
  left: 10px;
  right: 10px;
  height: 6px;
  cursor: ns-resize;
}
.code-editor-resize-s {
  bottom: -3px;
  left: 10px;
  right: 10px;
  height: 6px;
  cursor: ns-resize;
}
.code-editor-resize-e {
  top: 10px;
  bottom: 10px;
  right: -3px;
  width: 6px;
  cursor: ew-resize;
}
.code-editor-resize-w {
  top: 10px;
  bottom: 10px;
  left: -3px;
  width: 6px;
  cursor: ew-resize;
}
.code-editor-resize-ne {
  top: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
}
.code-editor-resize-sw {
  bottom: -3px;
  left: -3px;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
}
.code-editor-resize-nw {
  top: -3px;
  left: -3px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}
.code-editor-resize-se {
  bottom: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

/* 最大化时隐藏缩放手柄 */
.code-editor-window.is-maximized .code-editor-resize-handle {
  display: none;
}

/* --------------------------------------------------------------------------
   小屏适配
   -------------------------------------------------------------------------- */

@media (max-width: 760px) {
  .code-editor-window {
    min-width: 0;
    min-height: 0;
  }
  .code-editor-info-path {
    max-width: 30%;
  }
  .code-editor-tab-label {
    max-width: 96px;
  }
}
