/* ============================================================================
   dsv4p max stantard imdoing — 帧级视频播放器 样式表
   ----------------------------------------------------------------------------
   离线 / 零依赖桌面应用样式：纯 CSS，无 @import、无网络字体、无框架。
   直接以 file:// 打开 index.html 即可生效（Linux / Windows 通用）。
   设计语言：暗色视频工具 / 非线性剪辑（NLE）风格，紧凑、信息密集、精确。
   ============================================================================ */

/* ============================================================================
   1. 设计令牌（CSS 自定义属性）
   ============================================================================ */
:root {
  /* 颜色：背景（由深到浅） */
  --bg:            #0b0c10;
  --bg-2:          #10121a;
  --bg-3:          #151826;
  --bg-4:          #1a1e2e;
  --panel-bg:      #0e1018;

  /* 颜色：描边 */
  --border:        #20222c;
  --border-strong: #2b2f3e;
  --border-accent: #3a6a8a;

  /* 颜色：文字 */
  --text:          #d6dbe6;
  --text-muted:    #9aa3b2;
  --text-dim:      #6b7384;
  --text-faint:    #4a5060;

  /* 颜色：强调 / 语义 */
  --accent:        #5cc8ff;   /* 主强调 · 青色 */
  --accent-dim:    #3a9ed6;
  --accent-soft:   rgba(92, 200, 255, 0.14);
  --warm:          #ffd479;   /* 入点 / 出点 / 循环 */
  --warm-soft:     rgba(255, 212, 121, 0.14);
  --danger:        #ff6b81;   /* 危险 / 错误 */
  --danger-soft:   rgba(255, 107, 129, 0.14);
  --ok:            #8affc1;   /* 正常 / 成功 */
  --ok-soft:       rgba(138, 255, 193, 0.14);
  --warn:          #ffb46b;   /* 警告 */

  /* 几何 */
  --radius:        5px;
  --radius-sm:     4px;
  --radius-pill:   999px;

  /* 布局尺寸 */
  --topbar-h:      44px;
  --statusbar-h:   26px;
  --panel-left-w:  330px;
  --panel-right-w: 352px;
  --timeline-h:    96px;

  /* 字体 */
  --font-ui:  system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC",
              "Microsoft YaHei", "PingFang SC", "Source Han Sans SC", sans-serif;
  --font-mono: ui-monospace, "DejaVu Sans Mono", "Cascadia Mono", Consolas,
               "Noto Sans Mono", "Liberation Mono", Menlo, monospace;
}

/* ============================================================================
   2. 基础重置与全局
   ============================================================================ */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

html {
  color-scheme: dark;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;                    /* 应用外壳不滚动，仅侧栏内部滚动 */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

p {
  margin: 0 0 8px;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

canvas {
  display: block;
}

::selection {
  background: rgba(92, 200, 255, 0.3);
  color: #fff;
}

/* 隐藏属性：只需声明一次，[hidden] 与 .is-hidden 均强制生效 */
[hidden] {
  display: none !important;
}

.is-hidden {
  display: none !important;
}

/* 滚动条（WebKit）：窄、低调，贴合暗色主题 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background: #3a4154;
}

/* Firefox 滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* 禁止拖拽选择：所有“界面控件”性质的元素 */
button, .tab, label, .check, .field-inline, .btn, .topbar,
.tabs, .brand, .panel, .card, .hud, .drop-hint, .timeline-tools,
.transport, .chain-head, .chain-drag, .preset, .marker-item, .modal-head {
  user-select: none;
  -webkit-user-select: none;
}

/* 允许选择的文本类元素 */
input, textarea, select, .readout, .kv, .mono, .small,
.chain-doc, .chain-error, .st-code, .glyph-preview {
  user-select: text;
  -webkit-user-select: text;
}

/* ============================================================================
   3. 应用外壳：顶栏 / 工作区 / 状态栏 的垂直堆叠
   ============================================================================ */
.topbar {
  flex: 0 0 var(--topbar-h);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.workspace {
  flex: 1 1 auto;
  min-height: 0;                       /* 关键：允许内部网格正确收缩 */
  display: grid;
  grid-template-columns: var(--panel-left-w) 1fr var(--panel-right-w);
  grid-template-rows: 1fr;
}

.statusbar {
  flex: 0 0 var(--statusbar-h);
  height: var(--statusbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
}

.status-msg {
  color: var(--text);
}

.status-spacer {
  flex: 1 1 auto;
}

.statusbar .mono {
  color: var(--text-dim);
}

/* ============================================================================
   4. 顶栏内部：品牌 / 操作 / 媒体信息
   ============================================================================ */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 0 auto;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(92, 200, 255, 0.8);
  flex: 0 0 auto;
}

.brand-name {
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
}

.brand-name em {
  font-style: normal;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 6px;
  letter-spacing: 0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.media-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  overflow: hidden;
}

.media-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}

.badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  overflow: hidden;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

/* ============================================================================
   5. 按钮
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease,
              color 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  background: var(--bg-4);
  border-color: var(--border-accent);
  color: var(--text);
}

.btn:active {
  background: var(--bg-2);
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border);
  color: var(--text-dim);
  background: var(--bg-2);
  transform: none;
}

/* 主按钮 */
.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #06121c;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #04101a;
}

.btn-primary:disabled {
  background: var(--bg-3);
  border-color: var(--border);
  color: var(--text-dim);
}

/* 幽灵按钮 */
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-3);
  border-color: var(--border-strong);
  color: var(--text);
}

/* 小号按钮 */
.btn-small {
  height: 22px;
  padding: 0 8px;
  font-size: 11.5px;
}

/* 图标按钮 */
.btn-icon {
  width: 26px;
  padding: 0;
  font-size: 13px;
  font-family: var(--font-mono);
}

/* 播放按钮：更圆润、略大 */
.btn-play {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-4);
  border-color: var(--border-strong);
}

.btn-play:hover {
  background: var(--bg-3);
  border-color: var(--accent);
  color: var(--accent);
}

/* 切换态（如：播放中） */
.btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-play.is-active {
  background: var(--accent);
  color: #04101a;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(92, 200, 255, 0.45);
}

/* ============================================================================
   6. 标签页（tabs）与面板内容（tabpanes）
   ============================================================================ */
.tabs {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  height: 34px;
  padding: 0 6px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}

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

.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-3);
  font-weight: 600;
}

/* ============================================================================
   7. 侧栏面板与卡片
   ============================================================================ */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;                       /* 关键：允许列内滚动 */
  min-width: 0;
  background: var(--panel-bg);
  overflow: hidden;
}

.panel-left {
  border-right: 1px solid var(--border);
}

.panel-right {
  border-left: 1px solid var(--border);
}

.tabpanes {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;                    /* 独立滚动只在两个侧栏发生 */
  overflow-x: hidden;
}

.tabpane {
  display: none;
  padding: 10px;
}

.tabpane.is-active {
  display: block;
}

.card {
  margin-bottom: 10px;
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card:last-child {
  margin-bottom: 0;
}

.card h4 {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* 行布局 */
.row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  min-width: 0;
}

.row:last-child {
  margin-bottom: 0;
}

.row-wrap {
  flex-wrap: wrap;
}

.row-add {
  flex-wrap: nowrap;
}

.row-add .select {
  flex: 1 1 auto;
  min-width: 0;
}

/* 字段 */
.field {
  margin-bottom: 12px;
  min-width: 0;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.field > label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.field label output {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  margin-left: 2px;
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

/* 提示文字 */
.hint {
  margin: 6px 0;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.5;
}

/* 分隔线 */
.divider {
  height: 1px;
  margin: 10px 0;
  background: var(--border);
}

/* 竖向分隔（transport 行内） */
.sep {
  flex: 0 0 1px;
  align-self: stretch;
  margin: 4px 2px;
  background: var(--border);
}

/* ============================================================================
   8. 表单控件
   ============================================================================ */
.input,
.select,
.textarea {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0 7px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.input {
  height: 26px;
  width: 100%;
  min-width: 0;
}

.select {
  height: 26px;
  max-width: 100%;
  min-width: 0;
  padding-right: 20px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 13px) 11px, calc(100% - 9px) 11px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.select-small {
  height: 22px;
  font-size: 11.5px;
}

.textarea {
  width: 100%;
  min-width: 0;
  padding: 6px 7px;
  resize: vertical;
  line-height: 1.5;
  font-family: var(--font-mono);
  font-size: 12px;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(92, 200, 255, 0.16);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

/* 时间码 / 帧号输入：等宽、居中 */
.input-tc,
.input-frame {
  font-family: var(--font-mono);
  text-align: center;
  letter-spacing: 0.02em;
}

.input-tc {
  width: 120px;
}

.input-frame {
  width: 76px;
}

/* 数字输入：尺寸合适即可，保留原生上下箭头 */
.input-num {
  width: 60px;
  height: 22px;
  font-family: var(--font-mono);
  text-align: right;
  padding: 0 6px;
}

/* 复选框 + 行内标签 */
.check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.check input[type="checkbox"] {
  margin: 0;
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* 滑块（range） */
.range,
.range-vol,
.range-split {
  height: 22px;
  min-width: 80px;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.range {
  width: 100%;
}

.range-vol {
  width: 90px;
}

.range-split {
  width: 80px;
}

/* WebKit 滑块轨道 */
.range::-webkit-slider-runnable-track,
.range-vol::-webkit-slider-runnable-track,
.range-split::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

/* WebKit 滑块拇指 */
.range::-webkit-slider-thumb,
.range-vol::-webkit-slider-thumb,
.range-split::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid var(--border-strong);
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.range::-webkit-slider-thumb:hover,
.range-vol::-webkit-slider-thumb:hover,
.range-split::-webkit-slider-thumb:hover {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(92, 200, 255, 0.5);
}

/* Firefox 轨道 */
.range::-moz-range-track,
.range-vol::-moz-range-track,
.range-split::-moz-range-track {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

/* Firefox 拇指 */
.range::-moz-range-thumb,
.range-vol::-moz-range-thumb,
.range-split::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid var(--border-strong);
}

.range::-moz-range-thumb:hover,
.range-vol::-moz-range-thumb:hover,
.range-split::-moz-range-thumb:hover {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(92, 200, 255, 0.5);
}

/* 对比分割线滑块：暖色强调 */
.range-split::-webkit-slider-thumb {
  background: var(--warm);
  border-color: #9a7a33;
}

.range-split::-moz-range-thumb {
  background: var(--warm);
  border-color: #9a7a33;
}

/* 音量滑块：青色强调 */
.range-vol::-webkit-slider-thumb {
  background: var(--accent);
  border-color: var(--accent-dim);
}

.range-vol::-moz-range-thumb {
  background: var(--accent);
  border-color: var(--accent-dim);
}

/* ============================================================================
   9. 中央舞台：画面 / 时间轴 / 播放控制
   ============================================================================ */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;                        /* 关键：防止画布撑破网格 */
  min-height: 0;
  background: var(--bg);
}

.stage-view {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #050608;
}

/* GL 画布：完全填充画面区，JS 负责像素缓冲尺寸，此处不得加边框/内边距 */
.gl-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* 隐藏视频：保持 1×1 且透明、可解码，绝不挪到视口外 */
.hidden-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* 拖放提示：大号居中虚线框 */
.drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 12, 16, 0.88);
  z-index: 5;
  transition: opacity 0.25s ease;
}

.drop-hint[hidden] {
  display: none !important;
}

.drop-hint.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.drop-hint-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 52px;
  border: 1px dashed var(--border-accent);
  border-radius: var(--radius);
  background: rgba(16, 18, 26, 0.6);
  text-align: center;
  color: var(--text-muted);
}

.drop-hint-inner strong {
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}

.drop-hint-inner span {
  font-size: 12px;
  color: var(--text-dim);
}

/* HUD：左上角等宽半透明信息堆 */
.hud {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  z-index: 6;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  pointer-events: none;
}

.hud > * {
  padding: 2px 7px;
  background: rgba(11, 12, 16, 0.68);
  border: 1px solid rgba(32, 34, 44, 0.7);
  border-radius: var(--radius-sm);
  color: var(--accent);
  backdrop-filter: blur(2px);
}

/* 放大镜：右下角浮动框 */
.magnifier {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 5px;
  background: rgba(11, 12, 16, 0.85);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.magnifier canvas {
  width: 132px;
  height: 132px;
  border-radius: var(--radius-sm);
  image-rendering: pixelated;
  background: #000;
}

.magnifier-readout {
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  min-width: 132px;
}

/* ============================================================================
   10. 通知（toast）
   ============================================================================ */
.toast-stack {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 8;
  max-width: 320px;
}

.toast {
  padding: 7px 11px;
  background: rgba(16, 18, 26, 0.92);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.2s ease;
  word-break: break-word;
}

.toast.is-error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.toast.is-ok {
  border-left-color: var(--ok);
  color: var(--ok);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 阻断层：居中警告卡片 */
.blocker {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 8, 0.82);
  z-index: 9;
}

.blocker[hidden] {
  display: none !important;
}

.blocker-box {
  max-width: 420px;
  width: calc(100% - 40px);
  padding: 18px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
}

.blocker-box h3 {
  margin-bottom: 8px;
  color: var(--danger);
  font-size: 14px;
}

.blocker-box p {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.blocker-box .btn {
  margin-top: 10px;
}

/* ============================================================================
   11. 时间轴
   ============================================================================ */
.timeline-wrap {
  position: relative;
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}

.timeline {
  display: block;
  width: 100%;
  height: var(--timeline-h);
  cursor: crosshair;
}

.timeline-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}

.timeline-tools .btn-icon {
  width: 22px;
  height: 20px;
  font-size: 12px;
}

.timeline-tools .mono {
  margin-left: 2px;
}

/* ============================================================================
   12. 播放控制（transport）
   ============================================================================ */
.transport {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  padding: 6px 8px;
}

.transport-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

.transport-row-2 {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* 时间码区块 */
.tc-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  flex: 0 0 auto;
}

.tc-block .input {
  height: 22px;
  font-size: 12px;
}

.tc-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  white-space: nowrap;
  min-height: 12px;
}

/* ============================================================================
   13. 数据读出（readout / kv）
   ============================================================================ */
.readout {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text);
}

.kv {
  display: flex;
  align-items: baseline;
  min-width: 0;
}

.kv-k {
  flex: 0 0 108px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kv-v {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
  word-break: break-word;
}

/* ============================================================================
   14. 色板（swatches）与字符预览（glyph-preview）
   ============================================================================ */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.swatch:hover {
  transform: scale(1.15);
  border-color: var(--accent);
}

.glyph-preview {
  margin-top: 6px;
  padding: 6px;
  min-height: 28px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================================================================
   15. 滤镜链（chain，JS 动态生成）
   ============================================================================ */
.chain-list {
  margin: 8px 0;
}

.chain-item {
  position: relative;
  margin-bottom: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chain-item.is-disabled {
  opacity: 0.55;
}

.chain-item.is-error {
  border-left: 3px solid var(--danger);
}

.chain-item.is-dragging {
  opacity: 0.5;
}

/* 拖放目标指示线 */
.chain-item.drop-before::before,
.chain-item.drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 2;
  pointer-events: none;
}

.chain-item.drop-before::before {
  top: -1px;
}

.chain-item.drop-after::after {
  bottom: -1px;
}

.chain-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  min-width: 0;
}

.chain-drag {
  flex: 0 0 auto;
  cursor: grab;
  color: var(--text-faint);
  font-size: 13px;
  letter-spacing: -1px;
}

.chain-drag:active {
  cursor: grabbing;
}

.chain-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text);
}

.chain-cat {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-4);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 10px;
  white-space: nowrap;
}

/* 折叠 / 开关 */
.chain-toggle {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  color: var(--text-muted);
  font-size: 11px;
}

.chain-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.chain-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.chain-actions .btn {
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 11px;
}

.chain-body {
  padding: 2px 7px 7px 7px;
  border-top: 1px solid var(--border);
}

.chain-doc {
  margin: 4px 0;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chain-error {
  margin: 4px 0;
  padding: 6px 7px;
  background: var(--danger-soft);
  border: 1px solid rgba(255, 107, 129, 0.35);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================================
   16. 滤镜参数（param，JS 动态生成）
   ============================================================================ */
.param {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 5px 0;
  min-width: 0;
}

.param-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 11.5px;
}

.param-value {
  flex: 0 0 56px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
}

.param-control {
  flex: 1 1 140px;
  min-width: 0;
  height: 22px;
}

.param-reset {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  color: var(--text-faint);
  font-size: 10px;
}

.param-reset:hover {
  color: var(--warm);
  border-color: var(--warm);
}

/* 颜色参数 */
.param-color {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 140px;
  min-width: 0;
}

.param-color input[type="color"] {
  width: 30px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}

.param-color input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 1px;
}

.param-color input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.param-color input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 2px;
}

/* 枚举参数 */
.param-enum select {
  width: 100%;
  height: 22px;
  font-size: 11.5px;
}

/* 布尔参数 */
.param-bool {
  flex: 1 1 140px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.param-bool input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
}

/* ============================================================================
   17. 代码编辑器（custom 滤镜，JS 动态生成）
   ============================================================================ */
.code-editor {
  width: 100%;
  min-width: 0;
  min-height: 220px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  tab-size: 2;
  color: var(--text);
  resize: vertical;
  white-space: pre;
}

.code-editor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(92, 200, 255, 0.16);
}

.code-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

/* ============================================================================
   18. 风格预设（preset，JS 动态生成）
   ============================================================================ */
.preset-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 8px 0;
}

.preset {
  position: relative;
  padding: 7px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 0;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.preset:hover {
  border-color: var(--border-accent);
  background: var(--bg-3);
}

.preset.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.preset-title {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset.is-active .preset-title {
  color: var(--accent);
}

.preset-desc {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preset-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1;
}

.preset-del:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ============================================================================
   19. 标记（marker，JS 动态生成）
   ============================================================================ */
.marker-list {
  margin-top: 8px;
}

.marker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: var(--radius-sm);
  min-width: 0;
}

.marker-item:hover {
  background: var(--bg-3);
}

.marker-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.marker-frame {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.marker-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px dashed transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marker-label:hover {
  border-bottom-color: var(--border-strong);
}

.marker-del {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1;
}

.marker-del:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ============================================================================
   20. 自检结果行（st-*，JS 动态生成）
   ============================================================================ */
.st-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 0;
  min-width: 0;
}

.st-ok,
.st-fail,
.st-warn {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
}

.st-ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.st-fail {
  color: var(--danger);
  background: var(--danger-soft);
}

.st-warn {
  color: var(--warn);
  background: var(--warm-soft);
}

.st-code {
  margin: 4px 0 8px;
  padding: 7px;
  max-height: 160px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre;
}

/* ============================================================================
   21. 快捷键表（keymap，JS 动态生成）
   ============================================================================ */
.keymap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.keymap-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.key {
  flex: 0 0 auto;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
}

/* ============================================================================
   22. 徽章（badge，用于顶栏媒体信息）
   ============================================================================ */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--bg-4);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge-ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: rgba(138, 255, 193, 0.35);
}

.badge-warn {
  color: var(--warn);
  background: var(--warm-soft);
  border-color: rgba(255, 212, 121, 0.35);
}

.badge-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(255, 107, 129, 0.35);
}

/* ============================================================================
   23. 进度条
   ============================================================================ */
.progress {
  height: 4px;
  margin: 6px 0;
  background: var(--bg-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;                           /* JS 设置具体宽度 */
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.15s ease;
}

/* ============================================================================
   24. 模态弹窗
   ============================================================================ */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 8, 0.7);
  z-index: 100;
}

.modal[hidden] {
  display: none !important;
}

.modal-box {
  display: flex;
  flex-direction: column;
  width: min(640px, calc(100vw - 48px));
  max-height: 80vh;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  font-size: 13px;
  color: var(--text);
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
}

/* ============================================================================
   25. 辅助类
   ============================================================================ */
.mono {
  font-family: var(--font-mono);
}

.small {
  font-size: 11px;
}

/* ============================================================================
   26. 响应式断点
   ============================================================================ */
/* 窄桌面：右栏收窄至 300px */
@media (max-width: 1240px) {
  :root {
    --panel-right-w: 300px;
  }
}

/* 更窄：隐藏两侧栏，只保留舞台 */
@media (max-width: 1040px) {
  .panel-left,
  .panel-right {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   27. 减少动态效果
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------ */
/* 补充：三个布局辅助类（与主样式同源，单独列出便于查找）              */
/* ------------------------------------------------------------------ */
.row-chain-actions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.row-loop-fields {
  gap: 10px;
}

.preset-list-user {
  margin-top: 8px;
}
