/* ============================================================
   编辑器与脚本域（FUNCTION-PARITY-3，17 条）
   真机依据：docs/reference/surfaces/editor-script-1920x1080.png
   布局：编辑器停靠在主区右侧（x=481..1919），文档选项卡条 22px，
        行号/断点槽 46px，代码区 13px Consolas/17px 行距，
        命令窗口压缩到主区底部（y=784..996，命中真机底栏位置）。
   本文件只影响编辑器打开态；默认首屏（像素门基线）不含编辑器，无回归。
   ============================================================ */

/* ---------------- 编辑器停靠面板 ---------------- */
#editor-dock {
  position: absolute; left: 481px; top: 0; width: 1438px; height: 612px;
  background: #f5f5f5; border-bottom: 1px solid #bfbfbf;
  display: flex; flex-direction: column; z-index: 6;
}
#editor-dock[hidden] { display: none; }

/* 文档选项卡条（真机：白底 22px，活动选项卡白底、非活动浅灰） */
.editor-docbar {
  position: relative; flex: 0 0 22px; height: 22px; background: #ffffff;
  border-bottom: 1px solid #bfbfbf;
}
.editor-tabs {
  position: absolute; left: 0; top: 0; right: 26px; height: 22px;
  display: flex; align-items: stretch; overflow: hidden;
}
.editor-doc-tab {
  position: relative; display: flex; align-items: center; height: 22px;
  min-width: 90px; max-width: 240px; padding: 0 6px 0 10px;
  font-size: 12px; color: #4a4a4a; background: #ececec;
  border-right: 1px solid #d0d0d0; cursor: default;
}
.editor-doc-tab.active { background: #ffffff; color: #1a1a1a; }
.ed-doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-doc-close {
  margin-left: 8px; width: 14px; height: 14px; font-size: 10px; line-height: 14px;
  color: #555; border-radius: 2px; background: transparent;
}
.ed-doc-close:hover { background: #dcdcdc; }
.editor-new-tab {
  position: absolute; right: 2px; top: 0; width: 22px; height: 22px;
  font-size: 15px; line-height: 22px; color: #333; background: transparent;
}
.editor-new-tab:hover { background: #e6f0fa; }

/* 编辑区 */
.editor-body { position: relative; flex: 1 1 auto; overflow: hidden; background: #ffffff; }
.editor-gutter {
  position: absolute; left: 0; top: 0; width: 46px; height: 100%;
  overflow: hidden; background: #f7f7f7; border-right: 1px solid #e2e2e2;
}
.ed-gutter-row { position: absolute; left: 0; width: 46px; height: 17px; }
.ed-gutter-row .ed-bp {
  position: absolute; left: 4px; top: 5px; width: 7px; height: 7px; border-radius: 50%;
  background: transparent;
}
.ed-gutter-row .ed-bp.on { background: #e03131; }
.ed-gutter-row .ed-bp:hover { background: #f2a2a2; }
.ed-line-no {
  position: absolute; right: 8px; top: 1px;
  font-family: var(--font-mono); font-size: 12px; color: #8a8a8a;
}
.ed-gutter-row.paused { background: #fff3c4; }
.editor-code { position: absolute; left: 46px; top: 0; right: 0; bottom: 0; overflow: hidden; background: #ffffff; }

.ed-highlight {
  position: absolute; left: 0; top: 0;
  font-family: var(--font-mono); font-size: 13px; line-height: 17px;
  color: #1a1a1a; white-space: pre; pointer-events: none;
}
.ed-hl-line { height: 17px; line-height: 17px; white-space: pre; }
.ed-hl-line.paused { background: #fff3c4; }
.ed-input {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  border: 0; outline: 0; padding: 0; margin: 0; resize: none;
  background: transparent; color: transparent; caret-color: #1a1a1a;
  font-family: var(--font-mono); font-size: 13px; line-height: 17px;
  white-space: pre; overflow: auto; tab-size: 4; z-index: 2;
}
.ed-input::selection { background: #b5d5ff; color: transparent; }
.ed-limit-guide {
  position: absolute; left: 570px; top: 0; bottom: 0; width: 1px;
  background: #e3e3e3; pointer-events: none;
}

/* 语法着色（真机编辑器配色：注释绿、字符串红、关键字蓝、函数棕、数字青） */
.m-comment { color: #22863a; }
.m-string { color: #a31515; }
.m-keyword { color: #0000ff; }
.m-func { color: #795e26; }
.m-num { color: #098658; }
.m-op { color: #2f2f2f; }
.m-punct { color: #2f2f2f; }
.m-ident { color: #1a1a1a; }
.m-plain { color: inherit; }

/* ---------------- 自动补全弹窗（3-05） ---------------- */
.ed-completion {
  position: absolute; z-index: 8; background: #ffffff;
  border: 1px solid #a0a0a0; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  border-radius: 3px; padding-top: 3px; min-width: 360px;
}
.ed-completion[hidden] { display: none; }
.ed-comp-strip { display: flex; align-items: center; gap: 4px; padding: 1px 6px; overflow: hidden; }
.ed-comp-item {
  display: flex; align-items: center; gap: 4px; height: 20px; padding: 0 4px;
  font-family: var(--font-mono); font-size: 13px; color: #1a1a1a; background: transparent;
}
.ed-comp-item.selected { background: #cce8ff; }
.ed-comp-index { color: #666; font-size: 12px; }
.ed-comp-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; padding: 0 4px 2px 0; }
.ed-comp-tool { width: 18px; height: 18px; font-size: 10px; color: #333; }
.ed-comp-tool:hover { background: #e6e6e6; }
.ed-comp-hint {
  border-top: 1px solid #d9d9d9; margin-top: 3px; padding: 3px 8px;
  font-size: 11px; color: #444;
}

/* ---------------- 编辑器上下文选项卡（编辑器/发布/视图） ---------------- */
.editor-ribbon-tab {
  position: absolute; top: 3px; height: 25px;
  font-size: 11px; line-height: 25px; text-align: center;
  color: #ffffff; white-space: nowrap; background: #1070c0;
}
.editor-ribbon-tab:hover { background: #1a7fd0; }
.editor-ribbon-tab.active { background: #f5f5f5; color: #1f1f1f; }
.editor-ribbon-tab[hidden] { display: none; }

/* ---------------- 编辑器功能区按钮 ---------------- */
.editor-rb {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 5px; border-radius: 2px;
}
.editor-rb:hover { background: #e9e9e9; }
.editor-rb .ed-rb-icon { height: 20px; display: flex; align-items: center; justify-content: center; }
.editor-rb .ed-rb-label {
  margin-top: 5px; max-width: 68px; font-size: 11px; line-height: 13px;
  color: #212121; text-align: center; white-space: normal;
}
.ed-rb-caret {
  margin-top: 2px; width: 0; height: 0;
  border-left: 3px solid transparent; border-right: 3px solid transparent;
  border-top: 4px solid #5a5a5a;
}
.editor-rb-small { display: flex; align-items: center; gap: 3px; padding: 0 3px; border-radius: 2px; }
.editor-rb-small:hover { background: #e9e9e9; }
.ed-rb-label-sm { font-size: 11px; color: #212121; white-space: nowrap; }
.ed-rb-caret-inline {
  width: 0; height: 0; margin-left: 1px;
  border-left: 3px solid transparent; border-right: 3px solid transparent;
  border-top: 4px solid #5a5a5a;
}
.editor-rb-small.disabled { opacity: 0.45; pointer-events: none; }
.ed-rb-caret-hit { background: transparent; border-radius: 2px; }
.ed-rb-caret-hit:hover { background: #e0e0e0; }
.ed-placeholder { position: absolute; left: 22px; top: 32px; font-size: 12px; color: #666; }

/* ---------------- 下拉菜单（新建 12 项 / 收藏夹 / 保存） ---------------- */
.ed-menu {
  position: absolute; z-index: 60; background: #ffffff;
  border: 1px solid #8a8a8a; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  padding: 4px 0; min-width: 170px;
}
.ed-new-menu { width: 196px; }
.ed-menu-item {
  display: flex; align-items: center; width: 100%; height: 29px;
  padding: 0 10px; font-size: 12px; color: #1a1a1a; text-align: left; background: transparent;
}
.ed-menu-item:hover { background: #e6f0fa; }
.ed-new-icon { width: 20px; margin-right: 6px; font-size: 13px; }
.ed-new-label { flex: 1 1 auto; }
.ed-new-caret, .ed-new-shortcut { color: #666; font-size: 11px; margin-left: 6px; }
.ed-menu-header { padding: 4px 10px; font-size: 11px; color: #666; border-bottom: 1px solid #e0e0e0; margin-bottom: 4px; }
.ed-menu-empty { padding: 6px 10px; font-size: 12px; color: #666; }
.ed-fav-label { flex: 1 1 auto; }
.ed-fav-kind { color: #777; font-size: 11px; }
.ed-fav-add { color: #0a58a5; border-top: 1px solid #e0e0e0; margin-top: 4px; }

/* ---------------- 对话框层 ---------------- */
.ed-dialog-layer {
  position: absolute; left: 0; top: 0; width: 1920px; height: 1032px;
  background: rgba(0, 0, 0, 0.16); z-index: 80;
  display: flex; align-items: flex-start; justify-content: center;
}
.ed-dialog-layer[hidden] { display: none; }
.ed-dialog {
  margin-top: 170px; width: 460px; background: #f5f5f5;
  border: 1px solid #7d7d7d; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.ed-dialog-title { height: 28px; line-height: 28px; padding: 0 10px; font-size: 12px; color: #ffffff; background: var(--mat-blue); }
.ed-dialog-body { padding: 10px; }
.ed-dialog-input {
  width: 100%; height: 24px; padding: 0 6px; font-family: var(--font-mono); font-size: 12px;
  border: 1px solid #7d7d7d; background: #ffffff;
}
.ed-dialog-results { max-height: 280px; overflow: auto; margin-top: 8px; }
.ed-dialog-item {
  display: flex; justify-content: space-between; align-items: baseline;
  width: 100%; padding: 4px 6px; font-size: 12px; color: #1a1a1a; text-align: left;
}
.ed-dialog-item:hover { background: #cce8ff; }
.ed-dialog-item-detail { color: #666; font-size: 11px; margin-left: 10px; }
.ed-dialog-hint { margin-top: 8px; font-size: 11px; line-height: 15px; color: #666; }
.ed-dialog-empty { padding: 6px; font-size: 12px; color: #666; }
.ed-dialog-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 4px 10px 10px; }
.ed-dialog-btn {
  height: 24px; padding: 0 16px; font-size: 12px; color: #1a1a1a;
  border: 1px solid #8a8a8a; background: #e6e6e6;
}
.ed-dialog-btn:hover { background: #dcdcdc; }
.ed-dialog-btn.primary { background: #0a58a5; border-color: #084a8a; color: #ffffff; }
.ed-dialog-btn.primary:hover { background: #0b63ba; }

/* ---------------- 状态栏编辑器信息 + 命令窗口压缩 ---------------- */
.ed-status-info { position: absolute; right: 120px; top: 11px; font-size: 11px; color: #3b3b3b; }
.ed-status-info[hidden] { display: none; }
body.editor-open #status-linecol { display: none; }

#cmdwin.cmd-compact #cmd-body { height: 160px; }
#cmdwin.cmd-compact #cmd-scroll { height: 160px; }
