/* ============================================================
   文字排版样式
   配合 parser.applyTypography 输出的 ty-* 类。
   段落级 .ty-para .ty-align-* / .ty-quote / .ty-dropcap / .ty-note / .ty-box-dashed / .ty-list-num / .ty-sep
   行内级 .ty-bold / .ty-italic / .ty-underline / .ty-strike / .ty-hollow / .ty-glow
   游戏运行时和编辑器排版预览共用同一套样式。
   ============================================================ */

/* ===== 段落级 ===== */
.ty-para {
  margin: var(--ui-gap-2, 0.25rem) 0;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* widget 引用在文字排版预览里的"box 容器"：把【类型·名字：内容】解析成一个虚框，
   内部显示 widget 文字信息（schema label + 字段标签 + 值），允许 typography 排版改字体等。
   box 整体 inline-block 让它能跟前后正文同行排版；内部分两段（head + body）视觉清楚。 */
.ty-widget-box {
  display: inline-block;
  max-width: 100%;
  margin: 0.25em 0.15em;
  padding: 0.4em 0.7em;
  border: 1.5px dashed var(--accent-color);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent-color) 6%, var(--bg-primary));
  vertical-align: top;
  line-height: 1.6;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ty-widget-box:hover {
  background: color-mix(in srgb, var(--accent-color) 14%, var(--bg-primary));
  border-style: solid;
}
.ty-widget-box-head {
  display: block;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 0.3em;
  letter-spacing: 0.05em;
}
.ty-widget-box-body {
  display: block;
  font-size: 1em;
  color: var(--text-primary);
}

.ty-align-left   { text-align: left; }
.ty-align-center { text-align: center; }
.ty-align-right  { text-align: right; }

.ty-indent {
  text-indent: 2em;
  text-align: left;
}

/* 引用段：左右带粗体引号 + 居中 */
.ty-quote {
  text-align: center;
  font-style: italic;
  padding: 0.6em 1em;
  position: relative;
  color: var(--text-secondary, #555);
}
.ty-quote::before,
.ty-quote::after {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6em;
  line-height: 1;
  font-style: normal;
  color: var(--accent-color, #888);
  vertical-align: -0.2em;
}
.ty-quote::before { content: "\201C"; margin-right: 0.2em; }
.ty-quote::after  { content: "\201D"; margin-left: 0.2em; }

/* 首字大：第一个字符放大 */
.ty-dropcap::first-letter {
  font-size: 2.2em;
  font-weight: 700;
  float: left;
  line-height: 1;
  margin: 0.05em 0.15em 0 0;
  color: var(--accent-color, inherit);
}

/* 注释样式：缩进 + 浅色 + 左侧细线 */
.ty-note {
  font-size: 0.92em;
  color: var(--text-muted, #888);
  border-left: 2px solid var(--border-color, #ccc);
  padding: 0.2em 0 0.2em 0.7em;
  margin-left: 0.4em;
}

/* 虚线框 */
.ty-box-dashed {
  border: 1px dashed var(--border-color, #888);
  padding: 0.5em 0.7em;
  border-radius: 4px;
}
/* 实线框 */
.ty-box-solid {
  border: 1px solid var(--border-color, #888);
  padding: 0.5em 0.7em;
  border-radius: 4px;
}
/* 双线框 */
.ty-box-double {
  border: 3px double var(--border-color, #888);
  padding: 0.5em 0.7em;
  border-radius: 4px;
}
/* 代码块：等宽 + 浅灰底 */
.ty-code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
  padding: 0.5em 0.8em;
  border-radius: 4px;
  white-space: pre-wrap;
  font-size: 0.95em;
}
/* 诗段：居中+斜体+略小 */
.ty-verse {
  text-align: center;
  font-style: italic;
  font-size: 0.95em;
  padding: 0.4em 1em;
  letter-spacing: 0.05em;
}
/* 行距 */
.ty-line-tight { line-height: 1.2; }
.ty-line-loose { line-height: 2.4; }

/* 行内：高亮（背景）/ 上标 / 下标 */
.ty-highlight {
  padding: 0 0.15em;
  border-radius: 2px;
  /* 高亮背景默认黄色（或作者自定义高彩色），文字强制深色保证可读，否则浅色文字撞黄底全糊 */
  color: #333;
}
.ty-sup {
  vertical-align: super;
  font-size: 0.75em;
}
.ty-sub {
  vertical-align: sub;
  font-size: 0.75em;
}

/* 序号项：左侧标记 + 内容，悬挂缩进（内容换行后仍与首行文字左边对齐）。
   标记宽度按内容自适应——罗马序号到两位数就超过一个字宽，写死宽度会把点号挤到下一行。 */
.ty-list-num {
  margin-left: 1.6em;
  text-indent: -1.6em;
  text-align: left;
}
.ty-list-num .ty-list-marker {
  display: inline-block;
  min-width: 1.4em;
  margin-right: 0.2em;
  text-indent: 0;
  white-space: nowrap;
  text-align: left;
  font-weight: 600;
  color: var(--accent-color, inherit);
}

/* ===== 分隔符 ===== */
.ty-sep {
  margin: 0.8em 0;
  border: 0;
  height: auto;
  display: block;
  text-align: center;
  line-height: 1;
}

/* 细线 */
.ty-sep-thin {
  border-top: 1px solid var(--border-color, #888);
  width: 60%;
  margin-left: auto;
  margin-right: auto;
}

/* 双线 */
.ty-sep-double {
  border-top: 3px double var(--border-color, #888);
  width: 60%;
  margin-left: auto;
  margin-right: auto;
}

/* 虚线 */
.ty-sep-dashed {
  border-top: 1px dashed var(--border-color, #888);
  width: 60%;
  margin-left: auto;
  margin-right: auto;
}

/* 花纹分隔：用 ::before 渲染装饰图案 */
.ty-sep-fancy::before {
  content: "\2726 \2014 \2014 \2726 \2014 \2014 \2726";
  letter-spacing: 0.15em;
  color: var(--accent-color, #888);
  font-size: 0.85em;
}

/* 点线 */
.ty-sep-dotted {
  border-top: 2px dotted var(--border-color, #888);
  width: 60%;
  margin-left: auto;
  margin-right: auto;
}
/* 粗线 */
.ty-sep-bold {
  border-top: 3px solid var(--text-primary, #333);
  width: 60%;
  margin-left: auto;
  margin-right: auto;
}
/* 波浪 */
.ty-sep-wavy::before {
  content: "～～～～～～～～～";
  letter-spacing: 0;
  color: var(--accent-color, #888);
  font-size: 0.9em;
}
/* 锯齿 */
.ty-sep-zigzag::before {
  content: "∧∨∧∨∧∨∧∨∧∨∧∨";
  letter-spacing: -0.05em;
  color: var(--accent-color, #888);
  font-size: 0.85em;
}
/* 星点 */
.ty-sep-stars::before {
  content: "✦  ✦  ✦  ✦  ✦";
  letter-spacing: 0.2em;
  color: var(--accent-color, #888);
  font-size: 0.85em;
}
/* 心形 */
.ty-sep-hearts::before {
  content: "♡  ♡  ♡  ♡  ♡";
  letter-spacing: 0.2em;
  color: var(--accent-color, #888);
  font-size: 0.9em;
}

/* 段级中间指令 inline chip：嵌在段块内部，跟段文字句子 inline 流式排，不占整行。
   作者一眼看出「这一段开头有这个指令」+ ×删除按钮 + 点击重开编辑。 */
.typography-preview .ty-inline-directive-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 6px 0 0;
  padding: 1px 4px 1px 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent-color, #888) 18%, transparent);
  border: 1px dashed color-mix(in srgb, var(--accent-color, #888) 50%, transparent);
  color: var(--text-secondary);
  font-size: 0.8em;
  line-height: 1.2;
  vertical-align: baseline;
  cursor: default;
  user-select: none;
  white-space: nowrap;
}
.typography-preview .ty-inline-directive-chip .ty-inline-directive-chip-text {
  flex: 0 0 auto;
}
.typography-preview .ty-inline-directive-chip .ty-inline-directive-chip-del {
  background: none;
  border: 0;
  padding: 0 2px;
  margin: 0;
  font-size: 0.95em;
  line-height: 1;
  color: var(--btn-danger-bg, #d33);
  cursor: pointer;
}
.typography-preview .ty-inline-directive-chip .ty-inline-directive-chip-del:hover {
  color: #f55;
}

/* 分隔符段：hover 显示删除按钮 */
.typography-preview .ty-preview-block.ty-sep-block {
  position: relative;
  cursor: default;
}
/* × 删除按钮 always 显示（手机端没 hover） */
.typography-preview .ty-sep-del-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-primary);
  color: var(--btn-danger-bg, #d33);
  border: 1px solid var(--btn-danger-bg, #d33);
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  padding: 0;
}

/* ===== 行内级 ===== */
.ty-bold      { font-weight: 700; }
.ty-italic    { font-style: italic; }
.ty-underline { text-decoration: underline; text-underline-offset: 0.15em; }
.ty-strike    { text-decoration: line-through; }

/* 镂空：中间填充色（默认 transparent 真镂空），加 8 方向 1px text-shadow 模拟描边。
   两种描边技术叠加：
     - -webkit-text-stroke：现代浏览器原生支持，圆滑
     - 8 方向 text-shadow：兼容性兜底；某些字体下 -webkit-text-stroke 边缘弱时它撑住
   注意：text-shadow 用纯 0 偏移黑色 hard 边，不是发散光，不是假发光。 */
.ty-hollow {
  --ty-hollow-fill: transparent;
  --ty-hollow-stroke: var(--text-primary, #000);
  color: var(--ty-hollow-fill);
  -webkit-text-fill-color: var(--ty-hollow-fill);
  -webkit-text-stroke-width: 1px;
  -webkit-text-stroke-color: var(--ty-hollow-stroke);
  /* 字号 ×1.25 让 1px 描边相对笔画细，密笔画中文也能看出"空心"；
     不加 font-weight，不叠 text-shadow，免得描边把笔画间填满 */
  font-size: 1.25em;
  letter-spacing: 0.05em;
}

/* 发光：纯 text-shadow 多层叠加。不动 font-weight（不假装加粗）。 */
.ty-glow {
  --ty-glow-color: #fff;
  text-shadow:
    0 0 2px var(--ty-glow-color),
    0 0 6px var(--ty-glow-color),
    0 0 12px var(--ty-glow-color),
    0 0 18px var(--ty-glow-color),
    0 0 24px var(--ty-glow-color);
}

/* 镂空+发光叠加：text-shadow 优先发光（彩色发散），描边保留 -webkit-text-stroke */
.ty-hollow.ty-glow,
.ty-glow.ty-hollow {
  color: var(--ty-hollow-fill, transparent);
  -webkit-text-stroke-width: 1.2px;
  -webkit-text-stroke-color: var(--text-primary, #000);
  /* 发光的 text-shadow 用 var --ty-glow-color 已在 .ty-glow 内定义；
     这里覆盖 .ty-hollow 的硬边 text-shadow（让发光效果优先显示） */
}

/* ===== 文字排版预览：占位状态栏 =====
   显示在 .typography-preview 上方，模拟实机状态栏视觉。
   作者写 ◆状态栏：xxx◆ 时图会铺这里，所见即所得；没设也保持占位、不让 preview 跳位置。 */
.typography-preview-statusbar {
  display: flex;
  align-items: center;
  /* 按真实游戏顶部状态栏视觉比例（500 宽 × 96 高 ≈ 5.2:1）锁定高宽比，预览所见即运行时所得 */
  aspect-ratio: 500 / 96;
  width: 100%;
  min-height: 40px;
  padding: 6px 12px;
  margin-bottom: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 1px solid var(--border-light);
  box-sizing: border-box;
  user-select: none;
  cursor: default;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.typography-preview-statusbar .status-values {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}
.typography-preview-statusbar .ty-statusbar-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  /* 铺上图后让占位字带浅黑底，避免被亮色背景图盖住完全看不见 */
  background: color-mix(in srgb, var(--bg-primary) 50%, transparent);
  padding: 2px 6px;
  border-radius: 3px;
}
/* 占位状态栏紧接 preview，把 preview 顶部圆角去掉 */
.typography-preview-statusbar + .typography-preview {
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* ===== 编辑器内排版预览容器 =====
   弹窗预览区使用这个类，让排版效果跟运行时一致。
   字号略大，让镂空/发光等细节肉眼可见 */
.typography-preview {
  font-family: inherit;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-primary);
  background: var(--bg-primary);
  padding: 1em 1.2em;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 200px;
  overflow-y: auto;
  word-break: break-word;
}

.typography-preview {
  /* 关掉 contenteditable focus 时浏览器默认蓝框 */
  outline: none;
}
/* 选中文字的视觉样式：用主题强调色半透明背景，不要浏览器默认蓝 */
.typography-preview ::selection {
  background: color-mix(in srgb, var(--accent-color) 35%, transparent);
  color: inherit;
}
.typography-preview ::-moz-selection {
  background: color-mix(in srgb, var(--accent-color) 35%, transparent);
  color: inherit;
}
.typography-preview .ty-preview-block {
  border-radius: 3px;
  padding: 4px 6px;
  margin: 2px 0;
  /* 不再有 hover/选中边框：当前段 = 光标在哪段，原生光标本身已经显示了 */
}
/* 虚拟展开段（条件分支/循环展开）：禁止编辑，给一个细微浅色背景表示"只读" */
.typography-preview .ty-preview-block.ty-preview-virtual {
  background: color-mix(in srgb, var(--text-muted) 6%, transparent);
  border-left: 2px solid color-mix(in srgb, var(--text-muted) 25%, transparent);
  cursor: not-allowed;
}
/* 空段 block：CSS ::before 显示提示「可以直接在这里打字」。
   :empty 匹配是看 textContent 是否为空——因为里面只有 zero-width space，::before 在 placeholder 状态显示。
   作者一旦输入字符就会有更长内容，提示自动消失（用 :focus-within / 内容长度判断）。 */
.typography-preview .ty-preview-empty-block {
  position: relative;
  /* 撑满预览区，提示才真正在中心（否则空 block 只有一行零宽空格那么矮，
     top:50% 相对极矮父等于贴顶）。box-sizing 保证含 padding 不溢出。 */
  min-height: 100%;
  box-sizing: border-box;
}
.typography-preview .ty-preview-empty-block::before {
  content: '本部件还没有内容，可以直接在这里打字';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* 限宽在预览区内、可换行居中：长提示在窄宽/缩放下不再横向出画截断 */
  max-width: 86%;
  text-align: center;
  line-height: 1.6;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-style: italic;
  pointer-events: none;
  user-select: none;
}
/* 作者一开始输入（或者本就有更多内容），把空状态提示藏掉——
   靠"内含 .ty-para 文本长度 > 1"判断不可行（CSS 没法计数），改用 :focus-within + 临时 class。
   简化方案：JS 给 block 加 .has-content class 来动态隐藏 ::before。 */
.typography-preview .ty-preview-empty-block.has-content::before {
  display: none;
}

.typography-preview .ty-preview-empty {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 30px 0;
  /* 占位文字不能被选中或编辑（与 contentEditable=false 配合） */
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

/* 小组件在排版预览里的展示块 */
.typography-preview .ty-widget-block {
  display: inline-block;
  border: 1px dashed var(--accent-color);
  background: color-mix(in srgb, var(--accent-color) 6%, var(--bg-secondary));
  padding: 4px 8px;
  margin: 2px;
  border-radius: 4px;
  vertical-align: middle;
  max-width: 100%;
}
.typography-preview .ty-widget-block .ty-widget-name {
  display: block;
  font-size: 0.8em;
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: 2px;
}
.typography-preview .ty-widget-block .ty-widget-content {
  display: block;
  color: var(--text-primary);
  font-size: 0.92em;
  word-break: break-word;
}
/* widget body 里：结构标签 / 字段分隔符 / 缩进 — 用淡色当装饰，提示这是格式而非用户内容 */
.typography-preview .ty-widget-block .ty-widget-label,
.typography-preview .ty-widget-block .ty-widget-sep,
.typography-preview .ty-widget-block .ty-widget-indent {
  color: var(--text-tertiary, var(--text-secondary));
  opacity: 0.6;
  user-select: none;
  cursor: default;
}
/* widget body 里：用户值用正常前景色，可编辑可加效果 */
.typography-preview .ty-widget-block .ty-widget-value {
  color: var(--text-primary);
}

/* ===== 色环弹窗 ===== */
.color-wheel-popup {
  position: fixed;
  z-index: 10000;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #ccc);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 12px;
  width: 220px;
  box-sizing: border-box;
  user-select: none;
}
.color-wheel-popup .cw-canvas-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto;
}
.color-wheel-popup .cw-canvas {
  display: block;
  margin: 0;
  cursor: crosshair;
  border-radius: 50%;
  background: transparent;
  touch-action: none;
}
/* 当前选中色的指示器：白色描边小圆，左上角对准点位 */
.color-wheel-popup .cw-indicator {
  position: absolute;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  background: transparent;
  left: 50%;
  top: 50%;
}
.color-wheel-popup .cw-light-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.color-wheel-popup .cw-light-label {
  font-size: 12px;
  color: var(--text-muted, #888);
  min-width: 32px;
}
.color-wheel-popup .cw-light-input {
  flex: 1;
  margin: 0;
}
.color-wheel-popup .cw-bottom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.color-wheel-popup .cw-preview {
  width: 36px;
  height: 24px;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 3px;
  flex-shrink: 0;
}
.color-wheel-popup .cw-hex-input {
  width: 90px;
  flex: 0 0 auto;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 3px;
  background: var(--bg-secondary, #f5f5f5);
  color: var(--text-primary, #222);
  box-sizing: border-box;
  text-align: center;
}

/* ===== 文字排版弹窗 ===== */
.typography-modal-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* 文字排版内容密集（提示+状态栏占位+正文预览+大量字体/效果按钮），
     给它接近弹窗上限的定高（与 modal max-height:80vh 同体系），自身不溢出弹窗；
     内部 hint 固定、中心预览区抢主空间、工具区按比例上限各自滚。 */
  height: 74vh;
  max-height: 74vh;
  min-height: 0;
  overflow: hidden;
}
.typography-modal-hint {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 6px 10px;
  border-radius: 4px;
  border-left: 3px solid var(--accent-color);
}
.typography-modal-wrap .typography-preview {
  /* 中心预览区是这个弹窗的主角：抢全部剩余空间，内部自己滚；不设 vh 上限（zoom 下会被截） */
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
}
.typography-toolbar {
  /* 工具区可收缩，最多占弹窗内容区的 38%（相对父，zoom 自适应；中心预览区是主角占大头），
     字体/效果按钮多时自己滚；不用 vh。 */
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  max-height: 30%;
  overflow-y: auto;
}
.typography-tool-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.typography-tool-group-title {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.typography-tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.typography-tool-row-inline {
  align-items: center;
}
.typography-tool-btn {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.typography-tool-btn:hover {
  background: var(--bg-tertiary);
}
.typography-tool-btn:active {
  background: color-mix(in srgb, var(--accent-color) 20%, var(--bg-primary));
}
/* 当前段已含此样式 → 按钮高亮显示"已激活" */
.typography-tool-btn.is-active {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3);
}
.typography-tool-btn.is-active:hover {
  filter: brightness(1.1);
}
.typography-size-slider {
  flex: 1;
  margin: 0;
  min-width: 100px;
}
.typography-toolbar input.typography-size-num {
  width: 56px;
  flex: 0 0 56px;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 3px;
  text-align: center;
  box-sizing: border-box;
  margin: 0;
}
.typography-size-suffix {
  font-size: 12px;
  color: var(--text-muted);
}
.typography-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  padding: 0;
}
.typography-color-swatch:hover {
  outline: 2px solid var(--accent-color);
  outline-offset: 1px;
}
.typography-color-custom {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 2px solid var(--accent-color);
  background: #FF0000;
  color: #fff;
  border-radius: 3px;
  cursor: pointer;
  text-shadow: 0 0 2px rgba(0,0,0,0.4);
  transition: transform 0.08s;
}
.typography-color-custom:hover {
  transform: scale(1.05);
}

/* 字体单选列表（直接展开 chip，移动端无需先 tap 展开下拉，每段单选）。
   chip 文字本身用对应字体渲染，让作者预览字体外观。 */
.typography-font-subgroup-title {
  font-size: 10px;
  color: var(--text-muted);
  margin: 4px 0 2px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.typography-font-chip {
  /* 字体名可能比普通按钮宽，给点 padding；fontFamily 由 JS 内联在 style 里 */
  min-width: 72px;
  text-align: center;
  font-size: 13px;
  line-height: 1.3;
}

/* 镂空/发光按钮 + 紧贴的取色色块 */
.typography-effect-with-color {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  margin: 0;
}
.typography-effect-with-color .typography-tool-btn-paired {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}
.typography-effect-with-color .typography-effect-color-btn {
  width: 18px;
  border: 1px solid var(--border-color);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
  cursor: pointer;
  padding: 0;
  margin: 0;
}
.typography-effect-with-color .typography-effect-color-btn:hover {
  outline: 2px solid var(--accent-color);
  outline-offset: 1px;
}

/* 默认颜色按钮（清除颜色样式）：用斜划线表示"无" */
.typography-color-default {
  padding: 2px 6px;
  font-size: 11px;
  border: 1px dashed var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  height: 22px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
}
.typography-color-default:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* 色块外包一层让删除按钮浮在右上角 */
.typography-color-swatch-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}
/* 自定义色块 × 删除按钮 always 显示（手机端没 hover） */
.typography-color-swatch-wrap .typography-color-swatch-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  background: var(--bg-primary);
  color: var(--btn-danger-bg, #d33);
  border: 1px solid var(--btn-danger-bg, #d33);
  border-radius: 50%;
  font-size: 11px;
  line-height: 12px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  display: block;
}

/* "加自定义色"按钮 */
.typography-color-add {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px dashed var(--accent-color);
  background: transparent;
  color: var(--accent-color);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.typography-color-add:hover {
  background: color-mix(in srgb, var(--accent-color) 12%, transparent);
}
.typography-font-select {
  flex: 1;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 3px;
}

/* 预览里"未渲染指令"的灰色提示块 */
.typography-preview .ty-directive-hint {
  display: inline-block;
  font-size: 0.82em;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 0 4px;
  border-radius: 2px;
  margin: 0 2px;
}

/* 行内图片：自适应宽度，可点击 */
.ty-inline-image {
  display: inline-block;
  max-width: 100%;
  max-height: 50vh;
  vertical-align: middle;
  border-radius: 4px;
  margin: 4px 2px;
  cursor: pointer;
}
.ty-image-missing {
  display: inline-block;
  font-size: 0.85em;
  color: var(--btn-danger-text, #d33);
  background: color-mix(in srgb, var(--btn-danger-bg, #d33) 12%, transparent);
  border: 1px dashed var(--btn-danger-bg, #d33);
  padding: 2px 6px;
  border-radius: 3px;
  margin: 0 2px;
}

/* 媒体模式提示 */
.typography-media-mode-hint {
  font-size: 0.85em;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--accent-color) 8%, var(--bg-secondary));
  border-left: 3px solid var(--accent-color);
  padding: 6px 10px;
  margin: 6px 0;
  border-radius: 3px;
}
