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

/* ---------- 选项条 ---------- */
.tdf-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);
}
.tdf-opt { display: flex; align-items: center; margin: 0 5px 8px; }
.tdf-check {
  display: inline-flex;
  align-items: center;
  height: 32px;
  color: var(--text-2, #4e5969);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.tdf-check input {
  width: 15px;
  height: 15px;
  margin: 0 6px 0 0;
  accent-color: var(--tdf-primary, #1677ff);
  cursor: pointer;
}

.tdf-colhead {
  display: flex;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border, #e5e6eb);
  background: var(--bg-2, #f7f8fa);
  color: var(--text-3, #86909c);
  font-size: 11.5px;
  line-height: 1.5;
}
.tdf-ch {
  flex: 0 0 40px;
  text-align: center;
  border-right: 1px solid var(--border, #e5e6eb);
}
.tdf-ch-b { border-right: 0; border-left: 1px solid var(--border, #e5e6eb); }
.tdf-ch-sign { flex: 0 0 20px; }
.tdf-ch-rest { flex: 1 1 auto; padding-left: 8px; }

/* ---------- 按钮 ---------- */
.tdf-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;
}
.tdf-btn:hover:not(:disabled) {
  color: var(--tdf-primary, #1677ff);
  border-color: var(--tdf-primary, #1677ff);
  background: var(--tdf-soft, #e8f1ff);
}
.tdf-btn:disabled { opacity: .45; cursor: not-allowed; }
.tdf-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-3, #86909c);
}
.tdf-btn-ghost:hover:not(:disabled) { background: var(--tdf-soft, #e8f1ff); }
.tdf-btn:focus-visible,
.tdf-check input:focus-visible,
.tdf-help summary:focus-visible {
  outline: 2px solid var(--tdf-primary, #1677ff);
  outline-offset: 2px;
}

/* ---------- 工作区 ---------- */
.tdf-work { display: flex; align-items: stretch; margin-top: 8px; }
.tdf-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;
}
.tdf-mid {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tdf-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);
}
.tdf-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);
}
.tdf-panel-title {
  display: inline-flex;
  align-items: center;
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text, #1d2129);
  cursor: default;
}
.tdf-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--tdf-primary, #1677ff);
  flex: none;
}
.tdf-dot-green { background: var(--tdf-green, #00b42a); }
.tdf-tools { display: flex; align-items: center; margin-left: auto; }
.tdf-tools .tdf-btn { margin-left: 6px; }

.tdf-swap {
  height: 26px;
  margin: 0 5px 8px auto;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--text-3, #86909c);
  font-size: 12.5px;
  line-height: 26px;
  cursor: pointer;
  white-space: nowrap;
}
.tdf-swap:hover { color: var(--tdf-primary, #1677ff); }

.tdf-textarea {
  display: block;
  width: 100%;
  height: 300px;
  min-height: 200px;
  max-height: 56vh;
  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;
}
.tdf-textarea::placeholder { color: var(--text-3, #86909c); }
.tdf-textarea:focus { box-shadow: inset 0 0 0 2px rgba(22, 119, 255, .14); }

.tdf-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;
}
.tdf-hint { margin-left: 12px; color: var(--text-3, #86909c); }

/* ---------- 差异结果 ---------- */
.tdf-result {
  margin-top: 12px;
  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;
}
.tdf-result-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);
}
.tdf-rows {
  max-height: 420px;
  overflow: auto;
  background: var(--bg-input, #fff);
}
.tdf-row { display: flex; align-items: stretch; }
.tdf-ln {
  flex: 0 0 40px;
  padding: 3px 7px;
  color: var(--text-3, #86909c);
  font-size: 12px;
  line-height: 1.75;
  text-align: right;
  font-variant-numeric: tabular-nums;
  user-select: none;
  border-right: 1px solid var(--border, #e5e6eb);
}
.tdf-ln-b { border-right: 0; border-left: 1px solid var(--border, #e5e6eb); }
.tdf-sign {
  flex: 0 0 20px;
  padding: 3px 0;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.75;
  text-align: center;
  user-select: none;
  color: var(--text-3, #86909c);
}
.tdf-code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 3px 12px 3px 4px;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--text, #1d2129);
}
.tdf-row-eq .tdf-code { color: var(--text-2, #4e5969); }
.tdf-row-del { background: #fff1f0; }
.tdf-row-del .tdf-sign { color: #cf222e; }
.tdf-row-del .tdf-code { color: #a40e26; }
.tdf-row-add { background: #eaf7ec; }
.tdf-row-add .tdf-sign { color: #1a7f37; }
.tdf-row-add .tdf-code { color: #0e6027; }
.tdf-hl { border-radius: 3px; padding: 0 1px; }
.tdf-hl-del { background: #ffd4d1; }
.tdf-hl-add { background: #b9ecc3; }
.tdf-empty {
  padding: 30px 16px;
  color: var(--text-3, #86909c);
  font-size: 13px;
  text-align: center;
}
.tdf-note {
  margin: 0;
  padding: 8px 14px;
  border-top: 1px dashed var(--border, #e5e6eb);
  color: var(--text-3, #86909c);
  font-size: 12px;
  line-height: 1.6;
}
.tdf-result-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;
}
.tdf-legend { display: inline-flex; align-items: center; color: var(--text-3, #86909c); }
.tdf-lg {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 5px 0 10px;
  border-radius: 2px;
}
.tdf-lg-del { background: #ffd4d1; }
.tdf-lg-add { background: #b9ecc3; }

/* 复制失败时的临时选区，不放页面上 */
.tdf-sr {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ---------- 状态与说明 ---------- */
.tdf-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;
}
.tdf-status.is-active {
  color: var(--tdf-primary, #1677ff);
  border-color: var(--tdf-primary, #1677ff);
  background: var(--tdf-soft, #e8f1ff);
}
.tdf-status.is-diff {
  color: var(--tdf-green, #00b42a);
  border-color: var(--tdf-green, #00b42a);
  background: rgba(0, 180, 42, .08);
}

.tdf-help {
  margin-top: 12px;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 10px;
  background: var(--card, #fff);
  overflow: hidden;
}
.tdf-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;
}
.tdf-help summary::-webkit-details-marker { display: none; }
.tdf-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;
}
.tdf-help[open] summary::after { content: "−"; }
.tdf-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;
}
.tdf-help-body p { margin: 9px 0 0; }
.tdf-help-body b { color: var(--text, #1d2129); }
.tdf-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;
}
.tdf-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 .tdf-panel,
body.dark .tdf-result { box-shadow: 0 2px 12px rgba(0, 0, 0, .22); }
body.dark .tdf-textarea:focus { box-shadow: inset 0 0 0 2px rgba(96, 165, 250, .22); }
body.dark .tdf-row-del { background: rgba(248, 81, 73, .11); }
body.dark .tdf-row-del .tdf-code { color: #ffc4bf; }
body.dark .tdf-row-del .tdf-sign { color: #ff7b72; }
body.dark .tdf-row-add { background: rgba(63, 185, 80, .11); }
body.dark .tdf-row-add .tdf-code { color: #a9e6b5; }
body.dark .tdf-row-add .tdf-sign { color: #3fb950; }
body.dark .tdf-hl-del { background: rgba(248, 81, 73, .42); }
body.dark .tdf-hl-add { background: rgba(63, 185, 80, .38); }
body.dark .tdf-lg-del { background: rgba(248, 81, 73, .5); }
body.dark .tdf-lg-add { background: rgba(63, 185, 80, .45); }
body.dark .tdf-status.is-active { background: rgba(30, 58, 95, .55); }
body.dark .tdf-status.is-diff { background: rgba(46, 160, 67, .16); }

/* ---------- 手机 ---------- */
@media screen and (max-width: 760px) {
  .tdf-opts { margin: 0 0 6px; padding: 10px 12px 2px; }
  .tdf-opt { flex: 0 0 auto; width: 100%; margin: 0 0 10px; }
  .tdf-opt-check { flex: 0 0 50%; width: 50%; margin: 0 0 8px; }
  .tdf-work { flex-direction: column; }
  .tdf-panel { flex: 0 0 auto; width: 100%; }
  .tdf-mid { flex: 0 0 auto; height: 38px; }
  .tdf-mid-icon svg { transform: rotate(90deg); }
  .tdf-textarea { height: 200px; min-height: 160px; max-height: none; }
  .tdf-swap { width: 100%; margin: 0 0 4px; text-align: right; }
  .tdf-panel-head,
  .tdf-result-head { padding: 8px 10px 8px 12px; }
  .tdf-panel-foot,
  .tdf-result-foot { padding: 7px 12px; }
  .tdf-hint { display: none; }
  .tdf-rows { max-height: 320px; }
  .tdf-ln { flex: 0 0 30px; padding: 3px 5px; font-size: 11px; }
  .tdf-ch { flex: 0 0 30px; }
  .tdf-code { font-size: 12.5px; padding-right: 8px; }
  .tdf-legend { display: none; }
  .tdf-help-body { font-size: 12.5px; }
}

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