/* 文本去重 · tdd- 前缀，颜色全部走全站变量，日/夜模式自动跟随 */
.tdd-app {
  --tdd-primary: var(--blue, #1677ff);
  --tdd-soft: var(--blue-soft, #e8f1ff);
  --tdd-green: var(--green, #00b42a);
  width: 100%;
  color: var(--text, #1d2129);
  font-size: 14px;
  line-height: 1.6;
}
.tdd-app * { box-sizing: border-box; }
.tdd-app button,
.tdd-app textarea,
.tdd-app select,
.tdd-app input { font-family: inherit; }

/* ---------- 选项条 ---------- */
.tdd-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 -5px 6px;
  padding: 10px 5px 2px;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 12px;
  background: var(--bg-2, #f7f8fa);
}
.tdd-opt { display: flex; align-items: center; margin: 0 5px 8px; }
.tdd-opt-label {
  margin-right: 6px;
  color: var(--text-3, #86909c);
  font-size: 12.5px;
  line-height: 1.4;
  white-space: nowrap;
}
.tdd-select,
.tdd-input {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 8px;
  background: var(--bg-input, #fff);
  color: var(--text, #1d2129);
  font-size: 13px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.tdd-select { min-width: 122px; max-width: 210px; }
.tdd-input { width: 76px; text-align: center; }
.tdd-select:focus,
.tdd-input:focus { border-color: var(--tdd-primary, #1677ff); }
.tdd-check {
  display: inline-flex;
  align-items: center;
  height: 32px;
  color: var(--text-2, #4e5969);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.tdd-check input {
  width: 15px;
  height: 15px;
  margin: 0 6px 0 0;
  accent-color: var(--tdd-primary, #1677ff);
  cursor: pointer;
}

/* ---------- 按钮 ---------- */
.tdd-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 7px;
  background: var(--card, #fff);
  color: var(--text-2, #4e5969);
  font-size: 13px;
  line-height: 30px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .16s, border-color .16s, background .16s, box-shadow .16s;
}
.tdd-btn:hover:not(:disabled) {
  color: var(--tdd-primary, #1677ff);
  border-color: var(--tdd-primary, #1677ff);
  background: var(--tdd-soft, #e8f1ff);
}
.tdd-btn:disabled { opacity: .45; cursor: not-allowed; }
.tdd-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-3, #86909c);
}
.tdd-btn-ghost:hover:not(:disabled) { background: var(--tdd-soft, #e8f1ff); }
.tdd-btn:focus-visible,
.tdd-select:focus-visible,
.tdd-input:focus-visible,
.tdd-check input:focus-visible,
.tdd-help summary:focus-visible {
  outline: 2px solid var(--tdd-primary, #1677ff);
  outline-offset: 2px;
}

/* ---------- 工作区 ---------- */
.tdd-work { display: flex; align-items: stretch; margin-top: 8px; }
.tdd-panel {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 12px;
  background: var(--card, #fff);
  box-shadow: 0 2px 10px rgba(15, 23, 42, .05);
  overflow: hidden;
}
.tdd-mid {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tdd-mid-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px dashed var(--border-2, #c9cdd4);
  border-radius: 50%;
  background: var(--card, #fff);
  color: var(--text-3, #86909c);
}

.tdd-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  min-height: 44px;
  padding: 8px 12px 8px 14px;
  border-bottom: 1px solid var(--border, #e5e6eb);
  background: var(--bg-2, #f7f8fa);
}
.tdd-panel-title {
  display: inline-flex;
  align-items: center;
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text, #1d2129);
  cursor: pointer;
}
.tdd-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--tdd-primary, #1677ff);
  flex: none;
}
.tdd-dot-green { background: var(--tdd-green, #00b42a); }
.tdd-tools { display: flex; align-items: center; margin-left: auto; }
.tdd-tools .tdd-btn { margin-left: 6px; }

.tdd-textarea {
  display: block;
  width: 100%;
  height: 360px;
  min-height: 240px;
  max-height: 62vh;
  margin: 0;
  padding: 14px 16px;
  border: 0;
  border-radius: 0;
  background: var(--bg-input, #fff);
  color: var(--text, #1d2129);
  font-size: 14px;
  line-height: 1.8;
  resize: vertical;
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.tdd-textarea::placeholder { color: var(--text-3, #86909c); }
.tdd-textarea:focus { box-shadow: inset 0 0 0 2px rgba(22, 119, 255, .14); }
.tdd-output {
  background: var(--bg-2, #f7f8fa);
  resize: vertical;
}
.tdd-output::selection { background: rgba(22, 119, 255, .22); }

.tdd-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  min-height: 34px;
  padding: 7px 14px;
  border-top: 1px solid var(--border, #e5e6eb);
  background: var(--bg-2, #f7f8fa);
  color: var(--text-3, #86909c);
  font-size: 12px;
}
.tdd-hint { margin-left: 12px; color: var(--text-3, #86909c); }

/* ---------- 状态与说明 ---------- */
.tdd-status {
  min-height: 36px;
  margin-top: 12px;
  padding: 8px 12px;
  border: 1px dashed var(--border, #e5e6eb);
  border-radius: 9px;
  background: var(--bg-2, #f7f8fa);
  color: var(--text-3, #86909c);
  font-size: 12.5px;
  line-height: 1.6;
  transition: color .16s, border-color .16s, background .16s;
}
.tdd-status.is-active {
  color: var(--tdd-primary, #1677ff);
  border-color: var(--tdd-primary, #1677ff);
  background: var(--tdd-soft, #e8f1ff);
}

.tdd-help {
  margin-top: 12px;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 10px;
  background: var(--card, #fff);
  overflow: hidden;
}
.tdd-help summary {
  position: relative;
  padding: 11px 38px 11px 14px;
  color: var(--text-2, #4e5969);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.tdd-help summary::-webkit-details-marker { display: none; }
.tdd-help summary::after {
  content: "+";
  position: absolute;
  right: 14px;
  top: 50%;
  margin-top: -10px;
  width: 20px;
  height: 20px;
  line-height: 18px;
  text-align: center;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 50%;
  color: var(--text-3, #86909c);
  font-size: 15px;
  font-weight: 400;
}
.tdd-help[open] summary::after { content: "−"; }
.tdd-help-body {
  padding: 0 14px 13px;
  border-top: 1px solid var(--border, #e5e6eb);
  color: var(--text-2, #4e5969);
  font-size: 13px;
  line-height: 1.85;
}
.tdd-help-body p { margin: 9px 0 0; }
.tdd-help-body b { color: var(--text, #1d2129); }
.tdd-help-body code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-code, #f5f5f5);
  color: var(--text, #1d2129);
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12.5px;
}
.tdd-help-note {
  margin-top: 12px !important;
  padding-top: 10px;
  border-top: 1px dashed var(--border, #e5e6eb);
  color: var(--text-3, #86909c) !important;
  font-size: 12.5px;
}

/* ---------- 暗色补充：只补写死的阴影/强调色 ---------- */
body.dark .tdd-panel { box-shadow: 0 2px 12px rgba(0, 0, 0, .22); }
body.dark .tdd-textarea:focus { box-shadow: inset 0 0 0 2px rgba(96, 165, 250, .22); }
body.dark .tdd-status.is-active { background: rgba(30, 58, 95, .55); }

/* ---------- 手机 ---------- */
@media screen and (max-width: 760px) {
  .tdd-opts { margin: 0 0 6px; padding: 10px 12px 2px; }
  .tdd-opt { flex: 0 0 auto; width: 100%; margin: 0 0 10px; }
  .tdd-opt-label { flex: 0 0 58px; }
  .tdd-select { flex: 1 1 0; width: auto; min-width: 0; max-width: none; }
  .tdd-input { flex: 1 1 0; width: auto; min-width: 0; }
  .tdd-opt-check { width: auto; }
  .tdd-work { flex-direction: column; }
  .tdd-panel { flex: 0 0 auto; width: 100%; }
  .tdd-mid { flex: 0 0 auto; height: 38px; }
  .tdd-mid-icon svg { transform: rotate(90deg); }
  .tdd-textarea { height: 220px; min-height: 168px; max-height: none; }
  .tdd-panel-head { padding: 8px 10px 8px 12px; }
  .tdd-panel-foot { padding: 7px 12px; }
  .tdd-hint { display: none; }
  .tdd-help-body { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .tdd-app * { transition: none !important; }
}
