:root{
  /* Dock */
  --dock-split: 8px;
  --dock-min-pane: 220px;
  --dock-left: 60%;
  --dock-top: 60%;

  /* Layout */
  --page-pad: clamp(10px, 1.4vw, 18px);
  --radius: 18px;
  --radius-sm: 12px;

  /* Colors (no hard seams) */
  --bg0: #060913;
  --bg1: #0b1430;
  --appTop: #0b1633;    /* 实心：顶部条/容器一致 */
  --appBot: #060913;

  --panelTop: #0a1531;  /* pane 主背景（实心/线性） */
  --panelBot: #070f24;

  --fg: #e6edf3;
  --muted: rgba(166,179,199,.9);

  --stroke: rgba(148,163,184,.16);
  --stroke2: rgba(148,163,184,.10);

  --accent: #6d5ef7;
  --accent2: #22d3ee;
  --red: #ef4444;
  --green: #22c55e;
  --blue: #60a5fa;

  --shadow-app: 0 18px 42px rgba(0,0,0,.45);
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
  overflow: hidden; /* 全页不滚动：只允许 pane 内部滚动 */
}

body{
  padding: var(--page-pad);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft Yahei", Arial, sans-serif;

  /* 背景氛围放在 body：轻量光斑，不影响内部一致性 */
  background:
    radial-gradient(900px 520px at 18% -10%, rgba(34,211,238,.10), transparent 60%),
    radial-gradient(900px 520px at 85% 0%, rgba(109,94,247,.12), transparent 62%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
}

/* App 容器：有边距、有圆角、有整体阴影 */
.app{
  width: calc(100vw - var(--page-pad) * 2);
  height: calc(100vh - var(--page-pad) * 2);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  border-radius: var(--radius);
  border: 1px solid rgba(148,163,184,.14);
  box-shadow: var(--shadow-app);

  /* 容器内部背景采用线性渐变（稳定，无断层） */
  background: linear-gradient(180deg, var(--appTop) 0%, var(--appBot) 100%);
}

/* ===== Topbar（关键：实心不透底，消除右上断层） ===== */
.topbar{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 14px 16px;
  user-select: none;

  /* 实心背景：不要 rgba 透明 */
  background: linear-gradient(180deg, #0c1938 0%, #081127 100%);
  border-bottom: 1px solid rgba(148,163,184,.14);
}

/* Brand */
.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-dot{
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow: 0 8px 18px rgba(0,0,0,.35);
  flex: 0 0 auto;
}

.brand-text{
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-title{
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub{
  font-size: 12px;
  color: rgba(166,179,199,.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ===== Brand Icon: Streaming Wave + Bolt (pure CSS) ===== */
.brand-mark{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  position: relative;
  flex: 0 0 auto;

  background: linear-gradient(135deg, rgba(34,211,238,.22), rgba(109,94,247,.20));
  border: 1px solid rgba(148,163,184,.18);
  box-shadow: 0 8px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06);
  overflow: hidden;
}

/* 声波/流式：4 根柱状条（用 box-shadow 复制，不用多 DOM） */
.brand-mark .mark-wave{
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 3px;
  height: 8px;
  border-radius: 999px;

  background: rgba(230,237,243,.92);

  /* 复制出另外 3 根柱（高度不同） */
  box-shadow:
    6px  -4px 0 rgba(230,237,243,.92),   /* 第二根更高 */
    12px  2px 0 rgba(230,237,243,.92),   /* 第三根更低 */
    18px -7px 0 rgba(230,237,243,.92);   /* 第四根最高 */

  opacity: .95;
}

/* 给声波一点“流式速度线”质感（很轻量） */
.brand-mark .mark-wave::after{
  content: "";
  position: absolute;
  left: -6px;
  top: -10px;
  width: 28px;
  height: 28px;
  background:
    linear-gradient(90deg, rgba(34,211,238,.0) 0%,
                           rgba(34,211,238,.18) 35%,
                           rgba(109,94,247,.0) 70%);
  transform: rotate(-18deg);
  pointer-events: none;
}

/* 闪电：右侧叠加，表示低延迟/加速 */
.brand-mark .mark-bolt{
  position: absolute;
  right: 6px;
  top: 7px;
  width: 14px;
  height: 18px;

  background: linear-gradient(180deg, rgba(34,211,238,.95), rgba(109,94,247,.95));
  clip-path: polygon(45% 0%, 100% 0%, 62% 45%, 95% 45%, 35% 100%, 52% 56%, 20% 56%);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
}
@media (prefers-reduced-motion: no-preference){
  .brand-mark .mark-wave::after{
    animation: waveSweep 1.2s linear infinite;
  }
  @keyframes waveSweep{
    from{ transform: translateX(-6px) rotate(-18deg); opacity:.65; }
    to  { transform: translateX(10px) rotate(-18deg); opacity:.95; }
  }
}

/* Controls */
.controls{
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.field{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke2);
  background: rgba(255,255,255,.04); /* 很轻，不影响性能 */
}

.field-label{
  font-size: 12px;
  color: rgba(166,179,199,.9);
}

select{
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  background: rgba(0,0,0,.18);
  color: var(--fg);
  border: 1px solid rgba(148,163,184,.20);
  border-radius: 999px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

/* 下拉箭头（轻量） */
.field{
  position: relative;
}
.field::after{
  content: "";
  position: absolute;
  right: 10px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(230,237,243,.75);
  pointer-events: none;
}

/* Buttons */
button{
  border: 1px solid rgba(148,163,184,.18);
  color: rgba(230,237,243,.95);
  background: rgba(255,255,255,.06);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}

button:hover{
  background: rgba(255,255,255,.10);
}

button:disabled{
  opacity: .55;
  cursor: not-allowed;
}

/* ===== Settings: 随机生成按钮的“箭头自旋” ===== */
/* 让 ↻ 能被 transform 旋转（inline 元素不稳定，强制 inline-block） */
#btnSettingsRandom .icon-rotate{
  display: inline-block;
  transform-origin: 50% 50%;
}

/* loading 状态：只转按钮里的 ↻，不依赖系统光标 */
@media (prefers-reduced-motion: no-preference){
  #btnSettingsRandom.loading .icon-rotate{
    animation: settingsSpin 0.85s linear infinite;
  }
}

@keyframes settingsSpin{
  from{ transform: rotate(0deg); }
  to  { transform: rotate(360deg); }
}

/* 可选：loading 时文字略微变淡（不影响功能，不想要可删） */
#btnSettingsRandom.loading .btn-text{
  opacity: 0.85;
}

.btn-group{
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

/* 两个按钮一组 */
.btn-cluster{
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* 组与组之间的分隔线 */
.btn-sep{
  width: 1px;
  height: 26px;
  background: rgba(148,163,184,.28);
  border-radius: 999px;
  align-self: center;
}


#btnCall{
  background: linear-gradient(135deg, rgba(109,94,247,.95), rgba(34,211,238,.55));
  border-color: rgba(109,94,247,.35);
}

#btnHang{
  background: linear-gradient(135deg, rgba(239,68,68,.95), rgba(239,68,68,.55));
  border-color: rgba(239,68,68,.45);
}

button.ghost{
  background: rgba(255,255,255,.05);
  border-color: rgba(148,163,184,.16);
}

/* ===== Dock Layout ===== */
main.dock{
  position: relative;
  flex: 1 1 auto;
  min-height: 0;

  display: grid;
  grid-template-columns: var(--dock-left) var(--dock-split) 1fr;
  grid-template-rows: var(--dock-top) var(--dock-split) 1fr;

  padding: 12px;   /* 让内容与 app 边框有“呼吸感” */
  gap: 0;
  overflow: hidden;
}

/* panes */
section.pane{
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  border-radius: 14px;
  border: 1px solid var(--stroke2);

  /* pane 背景：线性、实心、稳定 */
  background: linear-gradient(180deg, var(--panelTop) 0%, var(--panelBot) 100%);

  /* 轻量内高光：精致但不重绘昂贵 */
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);

  /* 约束重绘范围（通常能帮 splitter 拖动更顺） */
  contain: layout paint;
}

.pane-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  border-bottom: 1px solid rgba(148,163,184,.10);
}

.pane-header h3{
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .2px;
  color: rgba(230,237,243,.92);
}

.hdr-actions{
  display: flex;
  align-items: center;
  gap: 8px;
}

.pane-body{
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 10px 12px;

  display: flex;
  flex-direction: column;
}

/* Splitters（轻量：不加阴影、不加滤镜） */
.splitter{
  background: rgba(148,163,184,.08);
  border-left: 1px solid rgba(148,163,184,.10);
  border-top: 1px solid rgba(148,163,184,.10);
  z-index: 5;
}
.splitter:hover{ background: rgba(148,163,184,.14); }
.splitter.v{ cursor: col-resize; }
.splitter.h{ cursor: row-resize; }
.splitter.c{ cursor: nwse-resize; }

/* ===== Dialog ===== */
.bubbles{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 6px;

  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble{
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.55;

  border: 1px solid rgba(148,163,184,.14);
  background: rgba(255,255,255,.04);
}

.bubble.user{
  align-self: flex-end;
  background: rgba(109,94,247,.10);
  border-color: rgba(109,94,247,.22);
}

.bubble.assistant{
  align-self: flex-start;
  background: rgba(34,211,238,.08);
  border-color: rgba(34,211,238,.18);
}

.bubble small{
  display: block;
  margin-top: 6px;
  color: rgba(166,179,199,.85);
}

/* ===== Logs ===== */
.logs-pre{
  height: 100%;
  overflow: auto;
  white-space: pre; /* 不换行 */
  word-break: normal;
  overflow-wrap: normal;
  padding-right: 6px;

  font-size: 12px;
  color: rgba(166,179,199,.92);
}

/* ===== Wave ===== */
.wave-body{
  padding: 10px 12px 12px;
}

.wave-container{
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 140px;

  overflow-x: auto;
  overflow-y: hidden;

  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(0,0,0,.16);
}

#waveCanvas{
  display: block;
  height: 100%;
  max-width: none; /* 允许内部比容器宽，由容器横向滚动 */
}

.wave-tooltip{
  position: absolute;
  bottom: 6px;
  transform: translate(-50%, -120%);
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(6,9,19,.95);
  border: 1px solid rgba(148,163,184,.35);
  color: rgba(230,237,243,.95);
  pointer-events: none;
  white-space: nowrap;
  display: none;
}

/* ===== Wave Legend: force 2 rows (4 items per row) ===== */
/* ===== Wave Legend (clean & deterministic) ===== */
.legend-wrap{
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-caption{
  font-size: 12px;
  font-weight: 700;
  color: rgba(230,237,243,.88);
  opacity: .95;
}

/* 固定为 4 列网格：8 项 = 2 行；小屏自动降级 */
.hint{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 12px;
  align-items: center;

  color: rgba(166,179,199,.90);
  font-size: 12px;
}

.hint-item{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.hint-text{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend{
  display: inline-block;
  width: 12px;
  height: 6px;
  border-radius: 999px;
  flex: 0 0 auto;
}

/* 响应式降级 */
@media (max-width: 980px){
  .hint{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px){
  .hint{ grid-template-columns: 1fr; }
}

.legend-in{ background: var(--green); }
.legend-out{ background: var(--blue); }
.legend-definite{ background: #FF0000; }
.legend-tts-first{ background: #9999FF; }
.legend-sim-all{ background: #FF8000; }
.legend-first-chunk{ background: #FF00FF; }
.legend-short-reply{ background: #00FFFF; }
.legend-follow-reply{ background: #A0A0A0; }


/* ===== Keydata ===== */
/* ===== Keydata (Right-Top) ===== */
.keydata-wrap{
  height: 100%;
  min-height: 0;

  /* 从原来的 column flex，改为：上性能 + 下内容区 */
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

/* 下半区：思考模式 + 日志 并排 */
.kd-grid{
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* 小屏：自动改为上下堆叠 */
@media (max-width: 980px){
  .kd-grid{
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

/* ===== Logs Card (embedded) ===== */
.logs-card{
  min-height: 0;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.12);
  background: rgba(255,255,255,.03);
  overflow: hidden;

  display: flex;
  flex-direction: column;
}

.logs-head{
  flex: 0 0 auto;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  border-bottom: 1px solid rgba(148,163,184,.10);
}

.logs-title{
  color: rgba(230,237,243,.92);
  font-size: 13px;
  font-weight: 700;
}

/* 让 pre 在卡片中真正“占满剩余高度” */
.logs-pre{
  flex: 1 1 auto;
  min-height: 0;

  overflow: auto;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;

  padding: 10px 12px;
  padding-right: 6px;

  font-size: 12px;
  color: rgba(166,179,199,.92);
}


.perf-card{
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.12);
  background: rgba(255,255,255,.03);
  padding: 10px 12px;
}

.perf-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}

.perf-title{
  font-size: 13px;
  font-weight: 700;
  color: rgba(230,237,243,.92);
}

.perf-unit{
  font-size: 12px;
  color: rgba(166,179,199,.90);
}

.perf-grid{
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px 10px;
  margin-top: 8px;
}

.kv{
  display:flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(148,163,184,.12);
  font-size: 12px;
  color: rgba(230,237,243,.90);
}

.kv b{
  font-weight: 700;
  color: rgba(230,237,243,.95);
}

.kv span{
  font-variant-numeric: tabular-nums;
  color: rgba(166,179,199,.95);
}

/* ===== Thinking chain ===== */
.think-card{
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.12);
  background: rgba(255,255,255,.03);
  overflow: hidden;
  display:flex;
  flex-direction: column;
}

.think-head{
  flex: 0 0 auto;
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148,163,184,.10);
}

.think-head .title{
  color: rgba(230,237,243,.92);
  font-size: 13px;
  font-weight: 700;
}

.thinking-chain{
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 14px 12px;
  display:flex;
  align-items: center;
  gap: 10px;
}

.think-node{
  display:flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}

/* ========= 仅修改这里：让主界面 pill 与弹窗 pill 一致（含字体） ========= */
.think-pill{
  height: 24px;
  padding: 0 12px;
  border-radius: 999px !important;

  background: rgba(255,255,255,.06) !important;
  border: 1px solid rgba(148,163,184,.18) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12) !important;

  font-family: inherit !important;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1px;
  color: rgba(6,9,19,.95) !important;

  max-width: calc(6em + 24px);
  min-width: 72px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ========= 仅修改结束 ========= */

/* 连接器：用绝对定位把线钉到垂直中线 */
.think-connector{
  position: relative;            /* 关键：给绝对定位参照 */
  display: flex;
  align-items: center;           /* 横向居中 */
  justify-content: center;       /* 纵向空间分配由绝对元素处理 */
  height: 34px;                  /* 与 pill 高度一致（你 pill 是 34px） */
}

/* 线：固定在 think-connector 的垂直中线 */
.think-connector .line{
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 120px;
}


/* 文字：固定在中线(线)的上方 */
.think-connector .jia{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% - 10px)); /* 往上抬一点（10px 可调） */
  margin: 0;
  text-align: center;
}


/* ===== Scrollbars统一（轻量） ===== */
.nice-scroll{
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,.40) rgba(0,0,0,0);
}

.nice-scroll::-webkit-scrollbar{
  width: 10px;
  height: 10px;
}

.nice-scroll::-webkit-scrollbar-track{
  background: rgba(0,0,0,0);
  border-radius: 999px;
}

.nice-scroll::-webkit-scrollbar-thumb{
  background: rgba(148,163,184,.30);
  border-radius: 999px;
  border: 2px solid rgba(6,9,19,.55);
}

.nice-scroll::-webkit-scrollbar-thumb:hover{
  background: rgba(148,163,184,.45);
}

/* ===== Hidden audio ===== */
#player{
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ===== Fix: 主界面思考栏目(1号)标签与弹窗(2号)标签统一样式 ===== */
/* 只作用于主界面思考栏容器 #thinkingChain 内的 .think-badge */
.think-card #thinkingChain .think-badge{
  /* 胶囊形状（弹窗同款） */
  height: 28px !important;
  line-height: 28px !important;
  padding: 0 14px !important;
  border-radius: 999px !important;

  /* 字体与排版（弹窗同款观感） */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: .2px !important;
  font-family: ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft Yahei", Arial, sans-serif !important;

  /* 精致描边与轻阴影（性能友好，无 blur/filter） */
  border: 1px solid rgba(255,255,255,.22) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.20),
    0 8px 16px rgba(0,0,0,.22) !important;

  /* 文字颜色（弹窗那种“深色字”效果） */
  color: rgba(6,9,19,.92) !important;

  /* 重要：不要动 background，让行内 background(rgb...) 继续生效 */
  background-image: none !important;

  /* 文本收敛（保留你最多6字/省略需求） */
  max-width: calc(6em + 24px) !important;
  min-width: 72px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
/* ===== FIX: 思考栏目连接线垂直居中 + 文本在线上方（且不放大） ===== */
.think-connector{
  position: relative;
  width: 120px;
  min-width: 120px;   /* 防止被压缩导致线看不见 */
  height: 34px;       /* 让“中线”与两侧 badge 的垂直中心一致（如 badge 不是 34px 就改成一致的高度） */
  flex: 0 0 auto;
  overflow: visible;  /* 允许文本显示在线上方 */
}

/* 连接线：固定在垂直中线，确保可见 */
.think-connector .line{
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);

  height: 3px;
  border-radius: 3px;
  background: rgba(148,163,184,.40);

  z-index: 1;
}

/* 连接线文字：固定在线上方，保持原来“小字号+不换行+省略号” */
.think-connector .jia{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-100% - 8px)); /* -8px 是线到文字的间距，可调 */

  max-width: 120px;
  font-size: 11px;        /* 关键：防止变巨大 */
  line-height: 1.2;
  color: rgba(166,179,199,.85);

  white-space: nowrap;    /* 关键：防止竖着一列换行 */
  overflow: hidden;
  text-overflow: ellipsis;

  z-index: 2;
  pointer-events: none;
}
/* ===== Topbar Settings Button ===== */
#btnSettings{
  /* 颜色不同但不抢眼：偏灰蓝、低饱和 */
  background: linear-gradient(135deg, rgba(148,163,184,.22), rgba(148,163,184,.08));
  border-color: rgba(148,163,184,.28);
  color: rgba(230,237,243,.92);
}
#btnSettings:hover{
  background: linear-gradient(135deg, rgba(148,163,184,.28), rgba(148,163,184,.12));
}

/* ===== In-page Modal (Overlay) ===== */
.modal-backdrop{
  position: fixed;
  inset: 0;
  display: none;                /* 默认隐藏 */
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,.55);
  z-index: 999;
}
.modal-backdrop.open{
  display: flex;
}

.modal-card{
  width: min(760px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  border-radius: 16px;
  border: 1px solid rgba(148,163,184,.18);
  background: linear-gradient(180deg, #0a1531 0%, #070f24 100%);
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
}

.modal-head{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148,163,184,.12);
}

.modal-title{
  font-size: 13px;
  font-weight: 800;
  color: rgba(230,237,243,.92);
  letter-spacing: .2px;
}

.modal-close{
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
}

.modal-body{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  /* 新增：让内部表单可以“撑满”，最后一个输入框吃掉空白 */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  /* 新增：占满 modal-body，最后一行 1fr 给“通话背景” */
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: auto auto auto 1fr;
}
.form-field{
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-field.span2{
  grid-column: 1 / span 2;
}
.form-label{
  font-size: 12px;
  color: rgba(166,179,199,.92);
}

.form-grid input,
.form-grid textarea{
  width: 100%;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(0,0,0,.18);
  color: rgba(230,237,243,.92);
  outline: none;
  font-size: 12px;
}
.form-grid textarea{
  resize: vertical;
  min-height: 70px;
  /* 关键：禁用原生右下角丑角标 */
  resize: none;
  /* 给自定义 resizer 留空间 */
  padding-right: 14px;
  padding-bottom: 14px;
}
/* ===== 自定义 textarea 右下角 resizer：和滚动条 thumb 同风格 ===== */
.ta-wrap{
  position: relative;
  min-height: 0;
}

.ta-resizer{
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 16px;
  height: 16px;
  border-radius: 8px;

  /* 对齐 nice-scroll thumb 的质感 */
  background: rgba(148,163,184,.30);
  border: 2px solid rgba(6,9,19,.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.10);

  cursor: nwse-resize;
  touch-action: none;
  user-select: none;
}

.ta-resizer::after{
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 6px;
  background: repeating-linear-gradient(
    135deg,
    rgba(2,6,23,.00) 0 2px,
    rgba(2,6,23,.35) 2px 3px,
    rgba(2,6,23,.00) 3px 6px
  );
  opacity: .9;
}

.ta-resizer:hover{
  background: rgba(148,163,184,.45);
  border-color: rgba(148,163,184,.35);
}

/* ===== 让“通话背景”自动吃掉 form-hint 被删后腾出的高度 ===== */
.form-field.call-bg{
  min-height: 0;
}
.form-field.call-bg .ta-wrap{
  flex: 1 1 auto;
  min-height: 0;
}
.form-field.call-bg textarea{
  height: 100%;
}

.form-hint{
  margin-top: 10px;
  font-size: 12px;
  color: rgba(166,179,199,.80);
}

.modal-actions{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid rgba(148,163,184,.12);
}

.modal-actions-right{
  display: inline-flex;
  gap: 10px;
}

/* 弱化注意：随机生成按钮更小、更轻 */
.btn-subtle{
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  border: 1px dashed rgba(148,163,184,.22);
  color: rgba(166,179,199,.88);
  opacity: .90;
}
.btn-subtle:hover{
  background: rgba(255,255,255,.06);
  opacity: 1;
}
/* ===== 随机生成：等待请求时只旋转箭头 ===== */
#btnSettingsRandom{
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#btnSettingsRandom .icon-rotate{
  display: inline-block;
  transform-origin: 50% 50%;
}

#btnSettingsRandom.loading{
  cursor: wait;
}

/* 即使 disabled 也保持更清晰的可见度 */
#btnSettingsRandom.loading:disabled{
  opacity: .90;
}

#btnSettingsRandom.loading .icon-rotate{
  animation: spin 0.9s linear infinite;
}

@keyframes spin{
  to{ transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce){
  #btnSettingsRandom.loading .icon-rotate{ animation: none; }
}

/* 确认按钮稍微“主按钮”一点，但不要比拨打/挂断抢眼 */
.btn-primary{
  background: linear-gradient(135deg, rgba(109,94,247,.70), rgba(34,211,238,.28));
  border-color: rgba(109,94,247,.28);
}
#btnNew{
  background: linear-gradient(135deg, rgba(148,163,184,.18), rgba(148,163,184,.06));
  border-color: rgba(148,163,184,.24);
}
#btnNew:hover{
  background: linear-gradient(135deg, rgba(148,163,184,.24), rgba(148,163,184,.10));
}
