/* 编辑器页面样式 */

#view-editor {
  position: relative;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
}

/* ==============================
   顶栏
   ============================== */
.editor-top-bar {
  display: flex;
  align-items: center;
  padding: var(--ui-editor-topbar-pad-y) 0;
  gap: 6px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.topbar-btn {
  padding: clamp(5px, 1.6cqi, 8px) clamp(8px, 2.8cqi, 14px);
  font-size: calc(var(--font-size) * 0.875);
  background: var(--btn-default-bg);
  color: var(--btn-default-text);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.1s;
}
.topbar-btn:active { opacity: 0.7; }
.topbar-btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}

/* 故事名称按钮 - 可展开 */
.topbar-story-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s;
}
.topbar-story-btn:active { border-color: var(--input-focus); }
.topbar-story-name {
  flex: 1;
  font-size: var(--ui-fs-14);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.topbar-story-arrow {
  font-size: calc(var(--font-size) * 0.5625);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ==============================
   工具栏
   ============================== */
.editor-toolbar {
  /* 单行 N 等分（换行会吃掉下方内容区高度）。按钮 flex 均分，标签/图标用原字号
     （见 .tool-label/.tool-icon），不切字（无 overflow:hidden），真实设备宽度单行放得下。 */
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  padding: 4px;
  gap: 1px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  touch-action: pan-y;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: clamp(12px, calc(var(--font-size) * 0.9375), 15px);
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: visible;
  transition: background 0.1s;
  gap: 2px;
  /* 单行 N 等分铺满整条工具栏，原字号见 .tool-label/.tool-icon。 */
  flex: 1 1 0;
  min-width: 0;
}
.tool-btn:active { background: var(--bg-hover); }
.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tool-btn:disabled:active { background: none; }
.tool-icon { font-size: clamp(15px, calc(var(--font-size) * 1.375), 24px); line-height: 1; }
.tool-label { font-size: clamp(11px, calc(var(--font-size) * 0.9375), 14px); line-height: 1.2; }
/* 原字号下「流程图」(3 字最宽)在约 414px 以上完全放得下、不重合 → 那以上一个像素不动。
   只有更窄的手机宽度才会重合，按断点把标签静态降一档到刚好不重合（纯 CSS，非等比例、非全局、非极端）：
   - ≤413px（360/375/390 等较窄手机）：标签 12px，「流程图」≈36 能进按钮
   - ≤340px（320 等极窄安卓）：标签 10px，「流程图」≈30 能进更窄的按钮
   图标是单字符不会重合，全程不动。 */
@media (max-width: 413px) { .tool-label { font-size: 12px; } }
@media (max-width: 340px) { .tool-label { font-size: 10px; } }

.tool-sep {
  width: 1px;
  height: 18px;
  background: var(--border-light);
  margin: 0 1px;
  flex-shrink: 0;
  align-self: center;
}

/* ==============================
   工具弹窗 · 方块工具箱（与侧栏 tool-btn 同系图标+标签）
   ============================== */
.tools-toolbox {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 4px 4px;
  max-width: 420px;
  margin: 0 auto;
}
.tools-toolbox-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tools-toolbox-section-title {
  font-size: calc(var(--font-size) * 0.8125);
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: 0 2px;
}
.tools-toolbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tools-toolbox-grid--flat {
  margin-top: 0;
}
.cover-editor-section-block {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: var(--ui-pad-md-y);
  margin-bottom: var(--ui-pad-sm-y);
}
.tools-toolbox-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 86px;
  padding: 10px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 110px;
}
.tools-toolbox-tile:active {
  background: var(--bg-hover);
}
.tools-toolbox-tile-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}
.tools-toolbox-tile-primary:active {
  opacity: 0.9;
}
.tools-toolbox-icon {
  font-size: calc(var(--font-size) * 1.75);
  line-height: 1;
}
.tools-toolbox-name {
  font-size: calc(var(--font-size) * 0.8125);
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  max-width: 100%;
}
.tools-toolbox-tile:not(.tools-toolbox-tile-primary) .tools-toolbox-name {
  color: var(--text-primary);
}

/* 编辑器悬浮快捷输入 */
.editor-quick-input {
  position: absolute;
  right: 10px;
  bottom: 12px;
  z-index: 3000;
  width: 56px;
  height: 56px;
}
.editor-quick-input.hidden {
  display: none;
}
.editor-quick-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--btn-primary-bg);
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-size: calc(var(--font-size) * 1.75);
  line-height: 1;
  font-weight: 700;
  font-family: inherit;
  cursor: move;
  box-shadow: var(--shadow);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.editor-quick-fab:active {
  opacity: 0.88;
}

/* ==============================
   部件编辑区（标签页内容）
   ============================== */
.comp-tab-content {
  padding: 16px;
}

/* 部件名称行 */
.comp-name-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.comp-name-input {
  flex: 1;
  font-size: calc(var(--font-size) * 1.0625);
  font-weight: bold;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border-color);
  border-radius: 0;
  padding: 6px 0;
  color: var(--text-primary);
}
.comp-name-input:focus { border-bottom-color: var(--accent-color); }

/* 可展开区块 */
.expandable {
  margin-bottom: 10px;
}
.expandable-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: calc(var(--font-size) * 0.875);
  color: var(--text-secondary);
  transition: background 0.1s;
}
.expandable-header:active { background: var(--bg-hover); }
.expandable-arrow {
  font-size: calc(var(--font-size) * 0.625);
  transition: transform 0.2s;
}
.expandable.open .expandable-arrow { transform: rotate(90deg); }
.expandable-title { flex: 1; }
.expandable-count {
  font-size: calc(var(--font-size) * 0.8125);
  color: var(--text-muted);
}
.expandable-body {
  display: none;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: calc(var(--font-size) * 0.875);
}
.expandable.open .expandable-body { display: block; }

/* 来源链接 */
.source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  margin: 2px;
  background: color-mix(in srgb, var(--accent-color) 22%, var(--bg-primary));
  border-radius: 10px;
  color: var(--text-primary);
  font-size: calc(var(--font-size) * 0.875);
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--accent-color) 72%, transparent);
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.source-link:hover {
  background: color-mix(in srgb, var(--accent-color) 30%, var(--bg-primary));
  border-color: color-mix(in srgb, var(--accent-color) 88%, transparent);
}
.source-link:active {
  transform: translateY(1px);
}

/* 设为开始按钮（部件标签页） */
.start-btn {
  border-color: color-mix(in srgb, var(--accent-color) 35%, var(--border-light));
}
.start-btn.is-start {
  background: color-mix(in srgb, var(--accent-color) 22%, var(--bg-tertiary));
  border-color: color-mix(in srgb, var(--accent-color) 70%, transparent);
  color: var(--text-primary);
  font-weight: 700;
}

/* 区块标题 */
.editor-section {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 0 8px;
  font-size: calc(var(--font-size) * 0.9375);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
}
.editor-section::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--accent-color);
  border-radius: 2px;
  margin-right: 8px;
}

/* 主编辑区小标题（文字内容/选项等）统一左对齐 */
.editor-section-title {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 12px 0 8px;
  font-size: calc(var(--font-size) * 0.9375);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
}
.editor-section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--accent-color);
  border-radius: 2px;
}

/* 快捷工具栏 */
.quick-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  flex-wrap: wrap;
}
.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: clamp(4px, 1.2cqi, 6px) clamp(8px, 2.4cqi, 12px);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  font-size: calc(var(--font-size) * 0.875);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}
.quick-btn:active { background: var(--bg-hover); }

/* 文字编辑区 */
.text-editor-area {
  width: 100%;
  min-height: 160px;
  padding: clamp(8px, 2.8cqi, 14px);
  background: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-size: calc(var(--font-size) * 1);
  font-family: inherit;
  line-height: 1.8;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}
.text-editor-area:focus { border-color: var(--accent-color); }
.text-editor-area::placeholder { color: var(--text-muted); }

/* ==============================
   选项卡片
   ============================== */
.option-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 6px;
}
.option-header {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.option-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: calc(var(--font-size) * 0.6875);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.option-header input { flex: 1 1 100%; min-width: 0; }

.option-target {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: calc(var(--font-size) * 0.875);
  flex-wrap: wrap;
}
/* 跳转/选项行内：按钮不缩小，输入框按比例保底宽度，一行放不下换行 */
.option-target .btn,
.option-target .badge-btn,
.option-header .btn,
.option-header .badge-btn {
  flex-shrink: 0;
  min-width: max(15%, 48px);
}
.option-target select,
.option-target input,
.option-header input {
  flex: 1 1 auto;
  width: auto;
  min-width: max(30%, 80px);
}
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-light);
}
.option-targets {
  margin-top: 8px;
  padding: 2px 8px 8px;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
}
.option-targets .option-target {
  margin-top: 6px;
  padding-top: 6px;
}
.option-targets .option-target:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.option-target-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.option-target-link {
  color: var(--color-preset-2);
  cursor: pointer;
  border-bottom: 1px dashed var(--color-preset-2);
  font-size: calc(var(--font-size) * 0.875);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
  padding: 0;
}
.option-target-link:active { opacity: 0.6; }

.option-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.badge-btn {
  padding: 4px 10px;
  font-size: calc(var(--font-size) * 0.8125);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s;
}
.badge-btn:active { background: var(--bg-hover); }
.badge-btn.has-value {
  color: var(--color-preset-3);
  border-color: color-mix(in srgb, var(--color-preset-3) 35%, transparent);
}

/* 结局提示 */
.end-hint {
  text-align: center;
  padding: 20px 12px;
  color: var(--text-muted);
  font-size: calc(var(--font-size) * 0.9375);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
}

/* ==============================
   变量管理
   ============================== */
.var-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 6px;
}
.var-item-name { flex: 1; font-size: calc(var(--font-size) * 1); }
.var-item-type { font-size: calc(var(--font-size) * 0.8125); color: var(--text-muted); }
.var-item-value { font-size: calc(var(--font-size) * 0.9375); color: var(--text-secondary); max-width: 80px; text-align: right; }
.var-item-vis { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-color); }
.var-item-vis.hidden-var { background: var(--text-muted); opacity: 0.4; }

/* ==============================
   条件构建器
   ============================== */
.cond-group {
  padding: 8px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: var(--bg-secondary);
}
.cond-or-label {
  text-align: center;
  font-size: calc(var(--font-size) * 0.8125);
  color: var(--text-muted);
  padding: 4px 0;
}
.cond-rule {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.cond-rule select,
.cond-rule input {
  width: auto;
  flex: 1;
  min-width: 60px;
  font-size: calc(var(--font-size) * 0.875);
  padding: 6px 10px;
}

/* ==============================
   部件列表标签页
   ============================== */
.comp-list-search {
  display: flex;
  gap: var(--ui-gap-6);
  padding: var(--ui-pad-md-y) var(--ui-pad-md-x);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
}
.comp-list-search input {
  flex: 1;
  font-size: var(--ui-fs-13);
  padding: calc(var(--ui-pad-sm-y) + 1px) var(--ui-pad-sm-x);
}

.comp-list-filters {
  display: flex;
  gap: var(--ui-gap-4);
  padding: var(--ui-pad-sm-y) var(--ui-pad-md-x);
  overflow-x: hidden;
  flex-wrap: wrap;
}
.comp-list-filters::-webkit-scrollbar { display: none; }

.filter-chip {
  padding: var(--ui-gap-2) var(--ui-pad-sm-x);
  font-size: var(--ui-fs-11);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
}
.filter-chip.active {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

.comp-list-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: var(--ui-pad-md-y) calc(var(--ui-pad-md-x) + 2px);
  margin: var(--ui-list-card-mb) var(--ui-gap-8);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  cursor: pointer;
  gap: var(--ui-gap-10);
  transition: border-color 0.15s;
}
.comp-list-card:active { background: var(--bg-hover); }
.comp-list-card.active { border-color: var(--accent-color); }

.comp-card-dot {
  width: var(--ui-comp-dot-size);
  height: var(--ui-comp-dot-size);
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border-color);
  border: 1px solid var(--border-light);
}
.comp-card-dot.is-start {
  background: var(--status-start);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--status-start) 25%, transparent);
}
.comp-card-dot.is-end {
  background: var(--status-end);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--status-end) 20%, transparent);
}
.comp-card-dot.is-orphan {
  background: var(--status-orphan);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--status-orphan) 25%, transparent);
}

.comp-card-info { flex: 1 1 max-content; min-width: 0; max-width: 100%; }
.comp-card-name {
  font-size: var(--ui-fs-14);
  font-weight: 500;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.comp-card-meta {
  font-size: var(--ui-fs-11);
  color: var(--text-muted);
  margin-top: var(--ui-gap-2);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

/* ==============================
   检查结果
   ============================== */
.check-item {
  display: flex;
  align-items: flex-start;
  gap: var(--ui-gap-8);
  padding: var(--ui-pad-md-y) var(--ui-pad-md-x);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}
.check-item:active { background: var(--bg-hover); }
.check-icon {
  flex-shrink: 0;
  font-size: var(--ui-fs-14);
}
.check-icon.error { color: var(--status-error); }
.check-icon.warn { color: var(--status-warn); }
.check-icon.ok { color: var(--status-ok); }
.check-info { flex: 1; min-width: 0; }
.check-msg { font-size: var(--ui-fs-13); }
.check-loc { font-size: var(--ui-fs-11); color: var(--text-muted); margin-top: var(--ui-gap-2); }

/* ==============================
   格式设置标签页
   ============================== */
.format-tab .editor-section {
  margin-top: 18px;
  margin-bottom: 4px;
}
.format-tab input[type="text"] {
  transition: border-color 0.15s;
}
.format-tab input[type="text"]:focus {
  border-color: var(--accent-color);
  outline: none;
}

/* 覆盖 components 里 input 的 min-width:0；以 --ui-format-num-w 为最低宽度，实际宽度由 JS 按文本测量写入 width，超过容器由外层 row 的 flex-wrap 折行 */
input[type="text"].format-sym-field {
  min-width: var(--ui-format-num-w);
  flex-shrink: 0;
}

textarea.format-sym-field {
  min-width: var(--ui-format-num-w);
  min-height: 2.25em;
  line-height: 1.35;
}

.format-tab textarea.format-sym-field:focus {
  border-color: var(--accent-color);
  outline: none;
}

/* ==============================
   全局按钮可见性强化
   所有工具按钮至少 44px 触控区
   ============================== */
.tool-btn,
.topbar-btn,
.topbar-story-btn,
.quick-btn,
.badge-btn,
.source-link,
.filter-chip {
  min-height: var(--ui-chip-row-min-h);
}
.tool-btn { min-height: var(--ui-toolbar-btn-min-h); }
.topbar-btn,
.topbar-story-btn { min-height: var(--ui-toolbar-btn-min-h); font-size: var(--ui-fs-15); font-weight: 500; }
.topbar-btn-primary { font-weight: 700; }

/* 快捷按钮更醒目 */
.quick-btn {
  font-size: var(--ui-fs-13);
  padding: calc(var(--ui-pad-sm-y) + 1px) var(--ui-pad-md-x);
  border-color: var(--border-color);
  color: var(--text-primary);
}

/* 徽章按钮更大更明显 */
.badge-btn {
  font-size: var(--ui-fs-12);
  padding: calc(var(--ui-pad-sm-y) - 1px) var(--ui-pad-md-x);
  min-height: var(--ui-btn-min-h-sm);
}

/* ==============================
   分组标签全局样式
   ============================== */
.group-tag {
  display: inline-block;
  padding: 1px var(--ui-gap-8);
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 10px;
  font-size: var(--ui-fs-11);
  white-space: nowrap;
  vertical-align: middle;
}

/* 分组筛选条更明显 */
.filter-chip {
  font-size: var(--ui-fs-12);
  padding: calc(var(--ui-pad-sm-y) - 1px) var(--ui-pad-chip-x);
  font-weight: 500;
  border: 1px solid var(--border-light);
}
.filter-chip.active {
  font-weight: 700;
  border-color: var(--btn-primary-bg);
}

/* ==============================
   变量管理标签页
   ============================== */
.variable-tab {
  --ui-fs-11: calc(var(--font-size) * 1.0625);
  --ui-fs-12: calc(var(--font-size) * 1.125);
  --ui-fs-13: calc(var(--font-size) * 1.1875);
  --ui-fs-14: calc(var(--font-size) * 1.25);
  --ui-fs-15: calc(var(--font-size) * 1.3125);
  --ui-btn-min-h-md: 36px;
}

.var-tab-toolbar {
  display: flex;
  gap: var(--ui-gap-6);
  padding: var(--ui-pad-md-y) var(--ui-pad-md-x);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.var-tab-toolbar .btn {
  min-height: clamp(32px, 7.6cqi, 38px);
  font-size: calc(var(--font-size) * 1);
  line-height: 1.15;
  padding-left: clamp(8px, 2cqi, 12px);
  padding-right: clamp(8px, 2cqi, 12px);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .var-tab-toolbar .btn {
    font-size: calc(var(--font-size) * 0.8125);
    min-height: 36px;
    padding-left: 10px;
    padding-right: 10px;
  }
}

.var-tab-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}
.var-tab-search input {
  font-size: calc(var(--font-size) * 0.9375);
  padding: 8px 14px;
}

.var-tab-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}

/* 变量卡片增强 */
.var-item {
  min-height: 48px;
  gap: 10px;
}
.var-item-name {
  font-size: calc(var(--font-size) * 0.9375);
  font-weight: 500;
}
.var-type-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: calc(var(--font-size) * 0.625);
  font-weight: 600;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

/* ==============================
   媒体绑定标签页
   ============================== */
.image-section {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
}
.image-section-title {
  font-size: calc(var(--font-size) * 0.9375);
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.image-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 6px;
  text-align: center;
  position: relative;
}
.image-card img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  pointer-events: auto;
}
.image-card-name {
  font-size: calc(var(--font-size) * 0.6875);
  color: var(--text-secondary);
  margin-top: 4px;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.image-card-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--btn-danger-bg);
  color: var(--btn-danger-text);
  border: none;
  font-size: calc(var(--font-size) * 0.75);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}
.image-card-del:active { opacity: 1; }
.image-upload-btn {
  width: 100%;
  min-height: 44px;
  font-size: calc(var(--font-size) * 0.875);
}

/* 绑定卡片 */
.binding-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: calc(var(--font-size) * 0.8125);
}
.binding-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ==============================
   流程图标签页
   ============================== */
.flowchart-container {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 100%;
  padding: 8px;
}
.flowchart-container canvas {
  display: block;
}

/* ==============================
   测试器标签页
   ============================== */
.tester-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
}
.tester-vars {
  max-height: 100px;
  overflow-y: auto;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
  font-size: calc(var(--font-size) * 0.75);
  line-height: 1.6;
}
.tester-toolbar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.tester-toolbar .btn {
  min-height: 38px;
  flex: 0 1 120px;
  min-width: 0;
}
.tester-text {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-size: calc(var(--font-size) * 0.875);
  line-height: 1.8;
}
.tester-text .debug-info {
  color: var(--text-muted);
  opacity: 0.5;
  font-size: calc(var(--font-size) * 0.75);
}
.tester-choices {
  padding: 8px 12px;
  border-top: 1px solid var(--border-light);
}
.tester-choices .btn {
  width: 100%;
  margin-bottom: 4px;
  min-height: 40px;
  text-align: left;
  padding: 8px 12px;
  font-size: calc(var(--font-size) * 0.8125);
}

/* ==============================
   手机美化预览
   ============================== */
/* 手机美化 - 全部使用主题变量，随美化风格变化 */
.phone-preview {
  background: var(--phone-bg);
  border-radius: 16px;
  padding: 12px;
  max-width: 300px;
  margin: 8px auto;
  border: 2px solid var(--phone-border, var(--border-color));
  font-family: inherit;
}
.phone-preview-header {
  text-align: center;
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--phone-border, var(--border-color));
  margin-bottom: 8px;
  font-size: calc(var(--font-size) * 0.75);
  color: var(--phone-header-color, var(--text-muted));
}
.phone-msg {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: flex-start;
}
.phone-msg.right {
  flex-direction: row-reverse;
}
.phone-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--font-size) * 0.875);
  flex-shrink: 0;
  overflow: hidden;
  color: var(--text-primary);
}
.phone-msg.left .phone-avatar {
  background: var(--phone-avatar-left, var(--bg-hover));
}
.phone-msg.right .phone-avatar {
  background: var(--phone-avatar-right, var(--bg-active));
}
.phone-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: auto;
}
.phone-content {
  max-width: 70%;
  min-width: 0;
}
.phone-name {
  font-size: calc(var(--font-size) * 0.625);
  color: var(--phone-name-color, var(--text-muted));
  margin-bottom: 2px;
  padding: 0 4px;
}
.phone-msg.right .phone-name { text-align: right; }
.phone-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: calc(var(--font-size) * 0.8125);
  line-height: 1.5;
  color: var(--phone-text-color, var(--text-primary));
  word-break: break-word;
}
.phone-msg.left .phone-bubble {
  background: var(--phone-bubble-left, var(--bg-secondary));
  border-bottom-left-radius: 4px;
}
.phone-msg.right .phone-bubble {
  background: var(--phone-bubble-right, var(--bg-hover));
  border-bottom-right-radius: 4px;
}

/* ==============================
   条件构建器弹窗增强
   ============================== */
.cond-builder-group {
  padding: 10px;
  border: 2px solid var(--border-color);
  border-left: 3px solid var(--accent-color);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--bg-secondary);
}
.cond-builder-group-label {
  font-size: calc(var(--font-size) * 0.6875);
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.cond-and-label {
  text-align: center;
  font-size: calc(var(--font-size) * 0.75);
  color: var(--color-preset-2);
  font-weight: 700;
  padding: 4px 0;
}
.cond-or-label {
  text-align: center;
  font-size: calc(var(--font-size) * 0.8125);
  color: var(--color-preset-1);
  font-weight: 700;
  padding: 6px 0;
}
.cond-rule-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.cond-rule-btn {
  min-height: 36px;
  padding: 6px 14px;
  font-size: calc(var(--font-size) * 0.8125);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.cond-rule-btn:active { border-color: var(--accent-color); }
.cond-rule-btn.selected {
  border-color: var(--accent-color);
  background: var(--bg-hover);
}
.cond-op-group {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}
.cond-op-btn {
  min-height: 32px;
  padding: 4px 10px;
  font-size: calc(var(--font-size) * 0.75);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
}
.cond-op-btn.active {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}

/* ==============================
   弹窗内变量选择器增强
   ============================== */
/* 快捷插入弹窗内通用「内容框」：把同类内容（变量分组、本部件选项等）整体框起来，避免散乱 */
.qi-section-box {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
/* 变量分组容器：复用通用框样式 */
.var-picker-group {
  margin-bottom: 10px;
  padding: 6px 8px 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.var-picker-group-title {
  font-size: calc(var(--font-size) * 0.6875);
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 4px;
}

/* 快捷插入大标题：左侧主色条 + 加粗稍大字号，体现一级层级 */
.qi-section-header {
  font-size: calc(var(--font-size) * 0.9375);
  font-weight: 700;
  border-left: 3px solid var(--btn-primary-bg);
  padding-left: 10px;
}
/* 快捷插入小标题（变量分组）：弱化背景 + 普通字重，作为二级层级 */
.qi-group-header {
  font-size: calc(var(--font-size) * 0.8125);
  font-weight: 500;
  background: var(--bg-tertiary);
  border-left: 2px solid var(--border-color);
  padding-left: 8px;
}
.var-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
  min-height: 40px;
  flex-wrap: wrap;
}
.var-picker-item:active { background: var(--bg-hover); }
.var-picker-item-name {
  flex: 1;
  font-size: calc(var(--font-size) * 0.875);
}
.var-picker-item-type {
  font-size: calc(var(--font-size) * 0.6875);
  color: var(--text-muted);
}

/* ==============================
   通用增强：大按钮模式
   ============================== */
.btn-lg {
  min-height: 44px;
  padding: 10px 20px;
  font-size: calc(var(--font-size) * 0.9375);
  font-weight: 600;
}

/* 内容区通用内边距 */
.tab-content-padded {
  padding: 14px;
}

/* 空行提示文字 */
.hint-text {
  font-size: calc(var(--font-size) * 0.75);
  color: var(--text-muted);
  line-height: 1.6;
  padding: 8px 0;
}

/* 弹窗内分组标题 */
.modal-section-title {
  font-size: calc(var(--font-size) * 0.875);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 8px;
}

/* 预览区域 */
.preview-box {
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: calc(var(--font-size) * 0.8125);
  color: var(--text-secondary);
  word-break: break-all;
  line-height: 1.6;
  margin-top: 8px;
  border: 1px dashed var(--border-light);
}

/* 操作按钮行 */
.action-row {
  display: flex;
  gap: 6px;
  margin: 8px 0;
  flex-wrap: wrap;
}
.action-row .btn { min-height: 38px; font-size: calc(var(--font-size) * 0.8125); }

@media (max-width: 640px) {
  /* 窄屏：按钮自身仍按 flex-wrap 自然换行，仅放大字号与触控尺寸 */
  .tester-toolbar .btn,
  .action-row .btn {
    font-size: calc(var(--font-size) * 0.875);
    min-height: 38px;
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* 选项跳转区增强 */
.option-target select {
  min-height: 38px;
  font-size: calc(var(--font-size) * 0.9375);
}

/* 是否样式增强(更大触控区) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 6px;
}
.toggle-row-label {
  font-size: calc(var(--font-size) * 1);
  font-weight: 500;
}

/* 搜索框统一 */
.search-bar {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
}
.search-bar input {
  flex: 1;
  font-size: calc(var(--font-size) * 1);
  padding: 10px 14px;
  min-height: 40px;
}

/* 卡片通用hover/active */
.card-interactive {
  cursor: pointer;
  transition: border-color 0.15s, background 0.1s;
}
.card-interactive:active { background: var(--bg-hover); }

/* 用户自定义快捷输入按钮 */
.quick-input-user {
  background: var(--bg-secondary);
  border-color: var(--accent-color);
  color: var(--text-primary);
}

/* 部件标签页：紧凑快捷工具栏（用于文字框上方） */
.quick-toolbar-compact {
  gap: 3px;
  padding: 4px 0 6px;
}
.quick-toolbar-compact .quick-btn-compact {
  font-size: calc(var(--font-size) * 0.8125);
  padding: 4px 10px;
  min-height: 32px;
  border-radius: 12px;
}

@media (max-width: 640px) {
  .variable-tab {
    --ui-fs-11: calc(var(--font-size) * 1);
    --ui-fs-12: calc(var(--font-size) * 1.0625);
    --ui-fs-13: calc(var(--font-size) * 1.125);
    --ui-fs-14: calc(var(--font-size) * 1.1875);
    --ui-fs-15: calc(var(--font-size) * 1.25);
    --ui-btn-min-h-md: 34px;
  }

  .editor-top-bar {
    padding: var(--ui-editor-topbar-pad-y) 6px !important;
    gap: 4px !important;
  }
  .topbar-btn {
    min-height: 34px !important;
    font-size: calc(var(--font-size) * 0.8125) !important;
    padding: 5px 8px !important;
  }
  .topbar-story-btn {
    padding: 6px 8px !important;
  }
  .topbar-story-name {
    font-size: calc(var(--font-size) * 0.875) !important;
  }
  .editor-section,
  .editor-section-title {
    font-size: calc(var(--font-size) * 0.875) !important;
    padding: 8px 0 6px !important;
  }
  .quick-btn {
    font-size: calc(var(--font-size) * 0.8125) !important;
    min-height: 34px !important;
    padding: 6px 10px !important;
  }
  .text-editor-area {
    font-size: calc(var(--font-size) * 0.9375) !important;
    line-height: 1.6 !important;
    padding: 10px !important;
  }
}

/*
 * 测试页 9:16 同比例预览卡片。
 * 两种模式共用同一个卡片外壳：
 *   - 图片模式：内部用 .game-area.is-media-mode + .game-media-layer + .game-media-text-dock，
 *               CSS 从 layout.css 直接复用
 *   - 纯文字模式：.game-area（非 is-media-mode） + 顶部状态栏 + .game-text-mode
 * 卡片内变量栏收起与游戏页一致（.tester-sb-toggle）；图片模式下状态栏叠在选项全屏层之上，选项容器用 pointer-events 仅让网格接点击。
 */
/* 外层包裹：控制布局占位，JS 动态设置 width/height 为缩放后的视觉尺寸 */
.tester-card-scale-wrap {
  position: relative;
  overflow: hidden;
  margin: var(--ui-gap-10, 10px) auto;
}
/* 卡片固定 500×889 设计尺寸（与实机 #app-scale-inner、页面预览 rp-scale-inner 同一套），
 * JS 通过 transform:scale 适配可视区域，container-query 始终在设计尺寸上解析 */
.tester-stage-card {
  display: flex;
  flex-direction: column;
  width: 500px;
  height: calc(500px * 16 / 9);
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  border-left: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: clip;
  background: var(--bg-primary);
  box-sizing: border-box;
  /* 与实机 #app-scale-inner 一致：只有左右边框，无上下边框，container query 上下文匹配 */
  container-type: size;
  container-name: stage-card;
  font-size: calc(var(--font-size) * 1.375);
}
/* 纯文字 / 图片模式卡片：与 layout.css #view-game 完全一致的值。
 * 注意：gap / padding 直接用 cqb 会解析到外层祖先容器（#app-scale-inner）而非卡片自身的 889px，
 * 导致布局偏移。改用 cqb 在 889px 设计高度下的精确等价像素值，保证卡片内部布局始终一致。
 * --game-nav-h 等自定义属性不受影响（CSS 自定义属性在 var() 使用时才解析 cq 单位）。 */
.tester-stage-card--text,
.tester-stage-card.tester-stage-card--media {
  --game-nav-h: clamp(28px, 12.8cqmin, 64px);
  --game-bottom-tap-min: clamp(28px, 5cqb, 44px);
  gap: 3.556px;
  padding: 2.667px 0;
}
/* safe-area padding 由主游戏页面处理，测试卡片不需要额外的 safe-area 内边距 */
.tester-stage-card .tester-stage-nav.nav-bar {
  flex: 0 0 auto;
  flex-shrink: 0;
  box-sizing: border-box;
  height: var(--game-nav-h);
  min-height: var(--game-nav-h);
  max-height: var(--game-nav-h);
  display: flex;
  align-items: stretch;
  padding: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  pointer-events: none;
}
/* !important 压过 base.css @media(max-width:640px) 的 .btn 全局 !important 覆盖 */
.tester-stage-card .tester-stage-nav.nav-bar .btn {
  flex: 1 !important;
  align-self: stretch !important;
  min-height: 0 !important;
  height: 100% !important;
  margin: 0 clamp(2px, 0.5cqmin, 6px) !important;
  font-size: var(--font-size) !important;
  padding: 0 clamp(6px, 1cqmin, 12px) !important;
  box-sizing: border-box !important;
}
.tester-stage-card .tester-stage-body {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow: clip;
  background: color-mix(in srgb, var(--bg-tertiary) 50%, var(--bg-primary));
}
/* 纯文字卡片：与 .game-area 一致，供 layout.css 的 .status-bar-toggle 绝对定位锚定 */
.tester-stage-card--text .tester-stage-body.game-area {
  position: relative;
}
.tester-stage-card .game-stage-aspect {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: clip;
}
/* 测试页纯文字模式：只补充 flex 和 overflow，其余（font-size / padding / line-height）
 * 全部继承 layout.css 的 .game-text-mode 规则，与游戏主页面完全一致 */
.tester-stage-card--text .game-text-mode {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: clip;
  overflow-y: auto;
}
/*
 * 测试页图片模式：显式设置全部媒体层规则，确保与游戏主页面一致。
 */
.tester-stage-card .game-media-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  isolation: isolate;
  pointer-events: none;
  --gm-z-bg: 0;
  --gm-z-character: 2;
  --gm-z-fx: 3;
  /* 高于 .choice-area(8)，否则出选项时无法点击顶栏变量与收起钮 */
  --gm-z-status: 9;
  --gm-z-cg: 5;
  --gm-z-name: 6;
}
/* 测试卡背景用 <img> 渲染（不同于实机用 <div> + background-image），
 * 必须用 object-fit:cover + width/height:100% 来填满容器 */
.tester-stage-card .game-media-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: var(--gm-z-bg, 0);
  /* 与立绘一致：装饰层不命中，避免 dock 透明区穿透后点到 CG/背景而正文框内小组件点不动 */
  pointer-events: none;
}
.tester-stage-card .game-media-character {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  max-height: 95%;
  max-width: 95%;
  object-fit: contain;
  object-position: bottom center;
  pointer-events: none;
  z-index: var(--gm-z-character, 2);
}
.tester-stage-card .game-media-cg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: var(--gm-z-cg, 5);
  pointer-events: none;
}
.tester-stage-card .game-media-name {
  z-index: var(--gm-z-name, 6);
}
.tester-stage-card .game-media-text-dock {
  position: absolute;
  top: 0;
  left: 6%;
  right: 6%;
  bottom: 4%;
  z-index: 7;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  gap: clamp(3px, 1.5cqmin, 8px);
  pointer-events: none;
  box-sizing: border-box;
}
.tester-stage-card .game-media-text-dock > .game-text-mode {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  height: calc(100% * 22 / 96);
  min-height: 0;
  max-height: calc(100% * 22 / 96);
  overflow-x: clip;
  overflow-y: auto;
  padding: clamp(6px, 2cqmin, 14px) clamp(8px, 2.5cqmin, 16px);
  margin: 0;
  background: color-mix(in srgb, var(--visual-textbox-bg, var(--bg-secondary)) 62%, transparent);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  border: 1px solid color-mix(in srgb, var(--accent-color, var(--border-color)) 45%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-glow, var(--accent-color, #88aaff)) 18%, transparent),
              0 0 16px color-mix(in srgb, var(--accent-glow, var(--accent-color, #88aaff)) 22%, transparent);
  border-radius: var(--radius-sm);
  pointer-events: auto;
  cursor: pointer;
}
.tester-stage-card .game-media-text-dock > .game-text-mode.game-text-mode--collapsed {
  display: none !important;
}
/* 选项区：在 game-media-layer 内绝对定位居中 */
.tester-stage-card .game-media-layer > .choice-area {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: row;
  padding: min(10%, 72px) 6%;
  box-sizing: border-box;
  background: transparent;
  border-top: none;
  /* 容器不拦截命中：空白处落到下层；仅网格与倒计时接点击（与游戏页 .game-media-layer > .choice-area 一致） */
  pointer-events: none;
  max-height: none;
  overflow-y: visible;
}
.tester-stage-card .game-media-layer > .choice-area.hidden {
  display: none;
}
.tester-stage-card .game-media-layer > .choice-area > .choice-grid {
  display: grid;
  /* 与真游戏页面的媒体选项保持一致：默认 1 列，宽屏才允许并排 */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(3px, 1.4cqmin, 10px);
  width: min(96%, 400px);
  max-width: 100%;
  flex: none;
  min-height: 0;
  max-height: 100%;
  pointer-events: auto;
}
.tester-stage-card .game-media-layer > .choice-area > .choice-countdown {
  pointer-events: auto;
}

/* 状态栏：layout.css 已通过 :is(#status-bar, #tester-status-bar) 统一规则，
 * 此处不再重复定义，只保留必要的差异（z-index 提高以覆盖选项层） */

/* 状态栏内容等比缩放：layout.css 基础规则已用 cqmin 等比缩放，
 * 卡片同为 container-type:size 的 9:16 容器，cqmin 值自动随卡片大小缩放，无需额外覆盖 */

/* 状态栏：layout.css 已通过 :is(#status-bar, #tester-status-bar) 统一全部规则，
 * 包括左右浮动面板、收起/展开、头像/值列表等，此处不再重复 */

/* 测试卡片内小组件页内弹层：宽度随卡片，不用 94vw/520px 最小宽度，避免窄卡片横向出画 */
.tester-stage-card .media-beauty-inpage-layer .media-beauty-inpage-layer__panel {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
}
.tester-stage-card .media-beauty-inpage-layer .modal.modal-widget-panel {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
}

/* 编辑器测试器 varArea 内的状态栏：不覆盖任何值，完全复用游戏主页面的 .status-bar / .status-values 样式 */

/* 文字模式卡片内选项：与游戏主页面 #view-game > .choice-area 对应的 flex 底栏 */
.tester-stage-card--text > .choice-area.tester-card-choices {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(3px, 0.6cqb, 6px) clamp(3px, 0.8cqmin, 6px);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  min-height: 0;
  max-height: clamp(140px, 40cqb, 360px);
  overflow-y: auto;
  box-sizing: border-box;
}
.tester-stage-card--text > .choice-area.tester-card-choices.hidden {
  display: none;
}

/* 状态栏收起/展开/左右浮动：layout.css 通过 :is(#status-bar, #tester-status-bar) 已全部统一 */

/*
 * 编辑器测试页显示模式切换：
 *   缩放模式（默认）：JS 计算 bodyScroll 的可用空间，设置卡片 max-width = min(bsW, bsH * 9/16)，
 *     确保 9:16 的卡片完全在可视区域内，不需要滚动
 *   全页面模式：卡片撑满可用宽度，超出时可滚动
 */
/* 测试页卡片内所有层级：overflow 用 clip（裁剪但不创建滚动容器），
 * 滚动事件穿透到外层 bodyScroll，鼠标滚轮和触摸拖动都能正常滚动。
 * 需要 !important 压过 layout.css 中 .game-area.is-media-mode .game-stage-aspect 等高特异性规则 */
.tester-stage-card,
.tester-stage-card .game-area,
.tester-stage-card .game-area .game-stage-aspect,
.tester-stage-card .game-media-layer {
  overflow: clip !important;
  overflow-x: clip !important;
  overflow-y: clip !important;
  overscroll-behavior: auto !important;
  touch-action: auto !important;
}

/* 非调试 + 缩放模式：卡片宽度满，高度按 16:9 推算可能溢出，允许竖向滚动 */
.tester-tab--scale-fit.tester-tab--no-debug > .tester-body-scroll {
  overflow-x: hidden !important;
  overflow-y: auto !important;
}
/* 非调试缩放：textArea 去掉 padding，wrap 去掉 margin，让卡片完全贴边 */
.tester-tab--scale-fit.tester-tab--no-debug > .tester-body-scroll > .tester-text-area {
  padding: 0 !important;
}
.tester-tab--scale-fit.tester-tab--no-debug .tester-card-scale-wrap {
  margin: 0 auto !important;
}
/* 调试/全页面模式：wrap 居中 */
.tester-tab--scale-fit .tester-card-scale-wrap {
  margin: 0 auto !important;
}

/* === 拼拼乐 拼图页/组 标签 === */
.puzzle-sheet-bar {
  scrollbar-width: none;
}
.puzzle-sheet-bar::-webkit-scrollbar { display: none; }

/* 未选中标签：暗沉的主题色，明显不活跃 */
.puzzle-sheet-tab {
  position: relative;
  padding: clamp(8px, 2.4cqi, 14px) clamp(14px, 4cqi, 24px);
  font-size: calc(var(--font-size) * 1.0625);
  font-family: inherit;
  color: var(--text-muted);
  background: var(--bg-hover);
  border: 2px solid var(--border-color);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  margin-bottom: -2px;
  transition: background 0.15s, color 0.15s;
  outline: none;
  opacity: 0.7;
}
.puzzle-sheet-tab:hover {
  opacity: 0.85;
}
/* 选中标签：主题主色，和内容区连通 */
.puzzle-sheet-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 700;
  border-color: var(--border-color);
  border-bottom: 2px solid var(--bg-primary);
  opacity: 1;
  z-index: 1;
}
/* 新建按钮：虚线 + 强调色 */
.puzzle-sheet-tab-add {
  border: 2px dashed var(--accent-color);
  color: var(--accent-color);
  background: transparent;
  font-weight: 600;
}
.puzzle-sheet-tab-add:hover {
  background: color-mix(in srgb, var(--accent-color) 10%, var(--bg-secondary));
}

/* 组内容容器 — 被标签包裹的区域 */
.puzzle-group-content {
  background: var(--bg-primary);
}
