/* ============================================================================
 * 翻译助手 · 前端样式 v2（2026-10-21 重做）
 * ----------------------------------------------------------------------------
 * v1 的问题（用户原话「又复杂又不好用，界面又丑」）：
 *   · 顶部一大块深色 hero（4 个卖点标签）—— 每次都占掉 200px，却没人看第二眼
 *   · 语气 5 个 chip + 术语表一行 + 试试示例一行 + 双栏各自的标题栏 + 底部一排小按钮
 *     ⇒ 屏幕上 7 层控件，输入框反而不是主角
 *   · 输入框固定 320px 高：打一个词也只留一大片空白
 * v2 的原则：**一个标题、一个编辑器、一个按钮**。其余全部降级或收起。
 *   · hero 删掉 → 一行标题（衬线）+ 一句副标题
 *   · 语言选择移到标题右侧，和标题同一行
 *   · 术语表收成右上角一个小文字按钮，点开才占位
 *   · 示例从「一行按钮」挪进空结果区的空态
 *   · 输入/结果高度自适应，不再留死空白
 *
 * 配色不变：墨蓝 #10324a + 香槟金 #c39a3e + 纸白；金仍然只用在三处。
 * 🔴 全部类名前缀 `tl-`，作用域限定 #sub-translate。
 * ========================================================================== */

#sub-translate {
  --tl-ink: #10324a;
  --tl-ink-2: #1b4c6b;
  --tl-ink-3: #2a6a8f;
  --tl-gold: #c39a3e;
  --tl-gold-soft: #e8d3a0;
  --tl-paper: #fffdf9;
  --tl-line: rgba(16, 50, 74, .10);
  --tl-line-2: rgba(16, 50, 74, .06);
  --tl-text: #22323c;
  --tl-muted: #6d7d87;
  --tl-faint: #9aa8b1;
  --tl-err: #c0392b;
  --tl-ease: cubic-bezier(.2, .8, .2, 1);
  padding-bottom: 92px;
}
@media (min-width: 1024px) {
  #sub-translate { padding-bottom: 24px; }
}
#sub-translate * { box-sizing: border-box; }

/* ---------------------------------------------------------------- 1. 头部 */
#sub-translate .tl-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 2px 0 12px;
}
#sub-translate .tl-head h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", "Times New Roman", serif;
  font-size: 25px;
  font-weight: 500;
  letter-spacing: 2.5px;
  color: var(--tl-ink);
  line-height: 1.2;
}
#sub-translate .tl-head p {
  margin: 5px 0 0;
  font-size: 12px;
  letter-spacing: .3px;
  color: #8b9aa4;
}
#sub-translate .tl-langs { display: flex; align-items: center; gap: 8px; flex: none; }

/* 语言选择：白底细边，箭头在右 */
#sub-translate .tl-lang {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--tl-line);
  border-radius: 10px;
  background: #fff;
  color: var(--tl-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
}
#sub-translate .tl-lang:hover { border-color: rgba(16, 50, 74, .26); }
#sub-translate .tl-lang:focus-within {
  border-color: var(--tl-ink-3);
  box-shadow: 0 0 0 3px rgba(42, 106, 143, .10);
}
#sub-translate .tl-lang select {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; font-size: 16px;  /* 防 iOS 聚焦放大 */
}
#sub-translate .tl-lang::after {
  content: '';
  position: absolute; right: 11px; top: 50%;
  width: 6px; height: 6px; margin-top: -4px;
  border-right: 1.5px solid #7d8b94;
  border-bottom: 1.5px solid #7d8b94;
  transform: rotate(45deg);
  pointer-events: none;
}
#sub-translate .tl-lang b { font-weight: 600; letter-spacing: .2px; white-space: nowrap; }

#sub-translate .tl-swap {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--tl-line);
  border-radius: 10px;
  background: #fff;
  color: var(--tl-ink-2);
  transition: transform .4s var(--tl-ease), border-color .18s, background .18s;
}
#sub-translate .tl-swap:hover { border-color: rgba(16, 50, 74, .26); background: #f7fafb; }
#sub-translate .tl-swap svg { width: 15px; height: 15px; }
#sub-translate .tl-swap.spin { transform: rotate(180deg); }

/* ---------------------------------------------------------------- 2. 卡片 */
#sub-translate .tl-board {
  position: relative;
  border: 1px solid var(--tl-line);
  border-radius: 18px;
  background: var(--tl-paper);
  box-shadow: 0 10px 30px -24px rgba(16, 50, 74, .55), inset 0 1px 0 #fff;
  overflow: hidden;
}

/* 语气条 */
#sub-translate .tl-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tl-line-2);
  background: #fff;
}
#sub-translate .tl-styles-label {
  font-size: 10px;
  letter-spacing: 1.8px;
  color: #a6b3ba;
  font-weight: 700;
  margin-right: 3px;
}
#sub-translate .tl-chip {
  height: 28px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #5d6d77;
  font-size: 12.5px;
  letter-spacing: .2px;
  transition: color .16s, background .16s, border-color .16s;
}
#sub-translate .tl-chip:hover { background: #f4f7f9; color: var(--tl-ink); }
#sub-translate .tl-chip.on {
  background: var(--tl-ink);
  border-color: var(--tl-ink);
  color: #fff;
}
#sub-translate .tl-bar-spacer { flex: 1; }
#sub-translate .tl-gloss-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: #8b9aa4;
  font-size: 11.5px;
  transition: color .16s, background .16s, border-color .16s;
}
#sub-translate .tl-gloss-btn:hover { color: var(--tl-ink); background: #f4f7f9; border-color: var(--tl-line); }
#sub-translate .tl-gloss-btn.on { color: var(--tl-ink); background: #f4f7f9; border-color: var(--tl-line); }

/* 术语表（点开才占位） */
#sub-translate .tl-gloss { display: none; padding: 12px 14px; border-bottom: 1px solid var(--tl-line-2); background: #fbfcfd; }
#sub-translate .tl-gloss.open { display: block; }
#sub-translate .tl-gloss textarea {
  width: 100%; min-height: 62px; padding: 10px 12px;
  border: 1px solid var(--tl-line); border-radius: 10px;
  background: #fff; color: var(--tl-text);
  font-size: 12.5px; line-height: 1.85; resize: vertical; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
#sub-translate .tl-gloss textarea:focus { border-color: var(--tl-ink-3); box-shadow: 0 0 0 3px rgba(42, 106, 143, .08); }
#sub-translate .tl-gloss-tip { margin: 7px 0 0; font-size: 11px; line-height: 1.7; color: var(--tl-faint); }
#sub-translate .tl-gloss-tip b { color: var(--tl-ink-2); font-weight: 600; }

/* ---------------------------------------------------------------- 3. 双栏 */
#sub-translate .tl-panes { display: grid; grid-template-columns: 1fr 1fr; }
#sub-translate .tl-pane { display: flex; flex-direction: column; min-width: 0; }
#sub-translate .tl-pane + .tl-pane {
  border-left: 1px solid var(--tl-line-2);
  background: linear-gradient(180deg, #fffdf9, #fdfbf6);
}
#sub-translate .tl-pane-head {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  font-size: 10px;
  letter-spacing: 1.6px;
  color: #a6b3ba;
  font-weight: 700;
}
#sub-translate .tl-pane-head .tl-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--tl-gold); }
#sub-translate .tl-pane-head .tl-count {
  margin-left: auto; font-size: 10.5px; letter-spacing: 0;
  color: #a6b3ba; font-weight: 500; font-variant-numeric: tabular-nums;
}

#sub-translate .tl-src-input {
  flex: none;
  width: 100%;
  min-height: 120px;
  max-height: 46vh;
  padding: 2px 16px 8px;
  border: 0;
  background: transparent;
  color: var(--tl-text);
  font-size: 14.5px;
  line-height: 1.9;
  resize: none;
  outline: none;
}
#sub-translate .tl-src-input::placeholder { color: #b7c2c9; }

#sub-translate .tl-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 8px;
  min-height: 40px;
}
#sub-translate .tl-mini {
  height: 26px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid transparent;
  color: #8b9aa4;
  font-size: 11.5px;
  transition: color .16s, background .16s, border-color .16s;
}
#sub-translate .tl-mini:hover { color: var(--tl-ink); background: #fff; border-color: var(--tl-line); }
#sub-translate .tl-mini:disabled { opacity: .4; cursor: not-allowed; }
#sub-translate .tl-mini.on { color: var(--tl-ink); background: #fff; border-color: var(--tl-line); font-weight: 600; }
#sub-translate .tl-mini svg { width: 12px; height: 12px; vertical-align: -1.5px; margin-right: 3px; }
#sub-translate .tl-foot .tl-spacer { flex: 1; }

/* 结果 */
#sub-translate .tl-out {
  flex: 1;
  min-height: 120px;
  max-height: 46vh;
  overflow: auto;
  padding: 2px 18px 8px;
  font-size: 14.5px;
  line-height: 1.9;
  color: var(--tl-text);
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}
#sub-translate .tl-out.empty {
  display: flex; align-items: center; justify-content: center;
  white-space: normal; text-align: center; padding: 12px 18px;
}
#sub-translate .tl-empty { max-width: 300px; }
#sub-translate .tl-empty svg { width: 26px; height: 26px; color: #c9d3d8; margin-bottom: 8px; }
#sub-translate .tl-empty p { margin: 0; font-size: 12.5px; line-height: 1.85; color: #a6b3ba; }
#sub-translate .tl-empty-try { margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
#sub-translate .tl-empty-try span { font-size: 11px; color: #b7c2c9; }
#sub-translate .tl-empty-try button {
  height: 24px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--tl-line); background: #fff;
  color: var(--tl-ink-2); font-size: 11px;
  transition: border-color .16s, color .16s, background .16s;
}
#sub-translate .tl-empty-try button:hover { border-color: rgba(16,50,74,.28); background: #f7fafb; }

#sub-translate .tl-out .tl-caret {
  display: inline-block; width: 2px; height: 1.05em;
  margin-left: 2px; vertical-align: -2px;
  background: var(--tl-ink-3);
  animation: tlCaret .9s steps(1) infinite;
}
@keyframes tlCaret { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }

#sub-translate .tl-skel { padding: 6px 0; }
#sub-translate .tl-skel i {
  display: block; height: 10px; margin: 0 0 10px; border-radius: 4px;
  background: linear-gradient(90deg, #f0f3f5 25%, #f8fafb 37%, #f0f3f5 63%);
  background-size: 400% 100%;
  animation: tlShimmer 1.3s ease infinite;
}
#sub-translate .tl-skel i:nth-child(1) { width: 92%; }
#sub-translate .tl-skel i:nth-child(2) { width: 84%; }
#sub-translate .tl-skel i:nth-child(3) { width: 62%; }
@keyframes tlShimmer { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

/* 对照 */
#sub-translate .tl-compare { display: none; flex: 1; min-height: 120px; max-height: 46vh; overflow: auto; padding: 2px 0 6px; }
#sub-translate .tl-board.mode-compare .tl-out { display: none; }
#sub-translate .tl-board.mode-compare .tl-compare { display: block; }
#sub-translate .tl-board.mode-compare .tl-panes { grid-template-columns: 1fr; }
#sub-translate .tl-board.mode-compare .tl-pane:first-child { display: none; }
#sub-translate .tl-board.mode-compare .tl-pane + .tl-pane { border-left: 0; }
#sub-translate .tl-row {
  display: grid;
  grid-template-columns: 26px 1fr 1fr;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px dashed var(--tl-line-2);
}
#sub-translate .tl-row:last-child { border-bottom: 0; }
#sub-translate .tl-row .tl-no { font-size: 10px; color: #b7c2c9; font-variant-numeric: tabular-nums; padding-top: 4px; }
#sub-translate .tl-row .tl-a { font-size: 13px; line-height: 1.8; color: #7b8b95; }
#sub-translate .tl-row .tl-b { font-size: 13.5px; line-height: 1.8; color: var(--tl-text); }
#sub-translate .tl-compare-empty { padding: 24px 18px; text-align: center; color: #a6b3ba; font-size: 12.5px; line-height: 1.9; }

/* ---------------------------------------------------------------- 4. 底部 */
#sub-translate .tl-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--tl-line-2);
  background: linear-gradient(180deg, #fbfcfd, #f5f8fa);
}
#sub-translate .tl-note {
  min-width: 0; flex: 1;
  font-size: 11.5px; line-height: 1.6; color: #8b9aa4;
}
#sub-translate .tl-note.err { color: var(--tl-err); font-weight: 500; }
#sub-translate .tl-note kbd {
  display: inline-block; padding: 0 4px;
  border: 1px solid var(--tl-line); border-bottom-width: 2px; border-radius: 4px;
  background: #fff; font-size: 10px; font-family: inherit; color: #5d6d77;
}
#sub-translate .tl-go {
  position: relative; flex: none;
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 22px;
  border-radius: 11px;
  border: 1px solid rgba(140, 105, 30, .35);
  background: linear-gradient(120deg, #f0dca8 0%, #dcbb6d 42%, #c39a3e 100%);
  color: #23190a;
  font-size: 13.5px; font-weight: 700; letter-spacing: 1.5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 10px 20px -14px rgba(120, 88, 20, .8);
  transition: transform .18s var(--tl-ease), box-shadow .22s, filter .18s;
  overflow: hidden;
}
#sub-translate .tl-go::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 34%, rgba(255, 255, 255, .62) 50%, transparent 66%);
  transform: translateX(-120%); transition: transform .8s var(--tl-ease);
}
#sub-translate .tl-go:hover { box-shadow: inset 0 1px 0 rgba(255,255,255,.65), 0 14px 26px -14px rgba(120, 88, 20, .9); }
#sub-translate .tl-go:hover::after { transform: translateX(120%); }
#sub-translate .tl-go:active { transform: translateY(1px) scale(.997); }
#sub-translate .tl-go[disabled] { filter: saturate(.55) brightness(.98); cursor: wait; }
#sub-translate .tl-go svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- 5. 最近 */
#sub-translate .tl-recent {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--tl-line);
  border-radius: 14px;
  background: var(--tl-paper);
}
#sub-translate .tl-recent-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
  font-size: 10px; letter-spacing: 2px; color: #a6b3ba; font-weight: 700;
}
#sub-translate .tl-recent-head button {
  margin-left: auto; font-size: 11px; letter-spacing: 0;
  color: #a6b3ba; text-transform: none; font-weight: 500;
}
#sub-translate .tl-recent-head button:hover { color: var(--tl-ink); }
/* 最近记录做成"胶囊"，不再一行占满整幅宽度（一条记录撑 1000px 很怪） */
#sub-translate .tl-recent-list { display: flex; flex-wrap: wrap; gap: 8px; }
#sub-translate .tl-recent-item {
  display: flex; align-items: center; gap: 8px;
  width: auto; max-width: 340px; padding: 6px 10px;
  border: 1px solid var(--tl-line-2); border-radius: 999px;
  background: #fff; text-align: left;
  transition: background .16s, border-color .16s;
}
#sub-translate .tl-recent-item:hover { background: #f7fafb; border-color: rgba(16,50,74,.22); }
#sub-translate .tl-recent-item .tl-rx { opacity: 0; transition: opacity .15s; }
#sub-translate .tl-recent-item:hover .tl-rx { opacity: 1; }
#sub-translate .tl-recent-item .tl-rl {
  flex: none; height: 20px; padding: 0 7px; border-radius: 5px;
  background: #f0f4f6; color: var(--tl-ink-2);
  font-size: 10px; line-height: 20px; letter-spacing: .3px;
}
#sub-translate .tl-recent-item .tl-rt {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12.5px; color: #5d6d77;
}
#sub-translate .tl-recent-item .tl-rx {
  flex: none; width: 20px; height: 20px; border-radius: 5px;
  color: #c3ccd1; font-size: 14px; line-height: 20px; text-align: center;
  align-self: center;
}
#sub-translate .tl-recent-item .tl-rx:hover { color: var(--tl-err); background: #fdf3f1; }
#sub-translate .tl-recent-empty { font-size: 12px; color: #b0bcc2; }

/* ---------------------------------------------------------------- 6. 响应式 */
@media (max-width: 900px) {
  /* 竖排：标题一行，语言框单独一行 —— 挤在一行时下拉只剩 60px，文字全被截断 */
  #sub-translate .tl-top { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 10px; }
  #sub-translate .tl-head { display: flex; align-items: baseline; gap: 8px; }
  #sub-translate .tl-head h2 { font-size: 20px; letter-spacing: 1.5px; }
  #sub-translate .tl-head p { display: block; margin: 0; font-size: 11px; }
  #sub-translate .tl-langs { flex: 1; min-width: 0; width: 100%; }
  #sub-translate .tl-lang { flex: 1 1 0; min-width: 0; height: 34px; font-size: 12.5px; padding: 0 22px 0 10px; }
  #sub-translate .tl-lang b { overflow: hidden; text-overflow: ellipsis; }
  #sub-translate .tl-swap { width: 32px; height: 32px; }

  #sub-translate .tl-panes { grid-template-columns: 1fr; }
  #sub-translate .tl-pane + .tl-pane { border-left: 0; border-top: 1px solid var(--tl-line-2); }
  #sub-translate .tl-src-input { min-height: 110px; max-height: 38vh; font-size: 15px; }
  #sub-translate .tl-out, #sub-translate .tl-compare { min-height: 120px; max-height: 38vh; font-size: 15px; }
  #sub-translate .tl-row { grid-template-columns: 20px 1fr; gap: 4px 8px; padding: 9px 14px; }
  #sub-translate .tl-row .tl-b { grid-column: 2; }

  #sub-translate .tl-bar { padding: 8px 10px; gap: 4px; }
  #sub-translate .tl-chip { height: 26px; padding: 0 9px; font-size: 12px; }
  #sub-translate .tl-styles-label { display: none; }
  #sub-translate .tl-gloss-btn { margin-left: auto; }

  #sub-translate .tl-actions { flex-wrap: wrap; padding: 10px 12px; }
  #sub-translate .tl-note { order: 2; width: 100%; font-size: 11px; }
  #sub-translate .tl-go { width: 100%; justify-content: center; height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  #sub-translate *, #sub-translate *::before, #sub-translate *::after {
    animation-duration: .001s !important;
    transition: none !important;
  }
}
