/* ============================================================
   译核 · DeepSeek 翻译器  —  样式
   ============================================================ */

:root {
  --brand: #4d6bfe;
  --brand-2: #8b5cf6;
  --brand-soft: rgba(77, 107, 254, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI",
    system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "SF Mono", monospace;
  --speed: 0.18s;
}

html[data-theme="dark"] {
  --bg: #0c0e14;
  --bg-2: #12151f;
  --panel: #161a26;
  --panel-2: #1c2130;
  --border: #262c3d;
  --border-soft: #1e2432;
  --text: #e7eaf3;
  --text-dim: #9aa3ba;
  --text-faint: #6b7488;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  --glow: 0 0 0 3px rgba(77, 107, 254, 0.18);
}

html[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f7f9fd;
  --border: #e0e5f0;
  --border-soft: #eaeef7;
  --text: #1a1f2e;
  --text-dim: #5a6478;
  --text-faint: #8b94a8;
  --shadow: 0 14px 40px rgba(24, 39, 75, 0.12);
  --glow: 0 0 0 3px rgba(77, 107, 254, 0.14);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(77, 107, 254, 0.16), transparent 62%),
    radial-gradient(900px 520px at 96% 4%, rgba(139, 92, 246, 0.13), transparent 58%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ------------------------------ 顶栏 ------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg-2) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 22px rgba(77, 107, 254, 0.42);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.brand-text h1 span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.6px;
  margin-left: 6px;
}
.brand-text p { margin: 1px 0 0; font-size: 11.5px; color: var(--text-dim); }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.keybox {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 6px 0 10px;
  height: 36px;
  transition: var(--speed);
}
.keybox:focus-within { border-color: var(--brand); box-shadow: var(--glow); }
.keybox.ok { border-color: #2fa96b; }
.keybox.bad { border-color: #e0555f; }
.keybox .ico { width: 15px; height: 15px; fill: var(--text-faint); flex: 0 0 15px; }
.keybox input {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  width: 240px;
}
.keybox input::placeholder { font-family: var(--font); color: var(--text-faint); }

/* ------------------------------ 控件 ------------------------------ */

.select, .text-input {
  height: 36px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-family: var(--font);
  font-size: 13px;
  outline: 0;
  cursor: pointer;
  transition: var(--speed);
  max-width: 210px;
}
.text-input { cursor: text; width: 100%; max-width: none; font-family: var(--mono); font-size: 12.5px; }
.select:hover, .text-input:hover { border-color: color-mix(in srgb, var(--brand) 48%, var(--border)); }
.select:focus, .text-input:focus { border-color: var(--brand); box-shadow: var(--glow); }
html[data-theme="dark"] .select option { background: var(--panel-2); }

.icon-btn, .ghost-btn {
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  transition: var(--speed);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover, .ghost-btn:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
  background: var(--panel-2);
}
.ghost-btn { font-size: 12px; height: 27px; min-width: 0; padding: 0 9px; border-radius: 7px; }
.icon-btn.swap { font-size: 17px; color: var(--brand); }

/* 退出按钮：按住 1 秒才生效；按住期间有一条红色进度填充（松手即取消） */
.exit-btn { position: relative; overflow: hidden; }
.exit-btn svg {
  position: relative;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.exit-btn .exit-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: #e0555f;
  opacity: 0.22;
  pointer-events: none;
}
.exit-btn.holding { color: #e0555f; border-color: #e0555f; }
.exit-btn.holding .exit-fill { animation: exit-hold 1.2s linear forwards; }
@keyframes exit-hold { from { width: 0; } to { width: 100%; } }
.exit-btn.done { color: #2fa96b; border-color: #2fa96b; }
.exit-btn.error { color: #e0555f; border-color: #e0555f; }
.exit-btn:disabled { cursor: default; }

.primary-btn {
  height: 36px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  letter-spacing: 1.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--speed);
  box-shadow: 0 6px 18px rgba(77, 107, 254, 0.36);
}
.primary-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }
.primary-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: none; }

/* --------------------------- 引擎徽标 --------------------------- */

.engine-badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 11.5px;
  white-space: nowrap;
  border: 1px solid var(--border);
  color: var(--text-faint);
  background: var(--panel);
  transition: var(--speed);
}
.engine-badge.free {
  color: #2fa96b;
  border-color: color-mix(in srgb, #2fa96b 45%, transparent);
  background: rgba(47, 169, 107, 0.13);
}
.engine-badge.paid {
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 42%, transparent);
  background: var(--brand-soft);
}
.engine-badge.demo {
  color: #e0a355;
  border-color: color-mix(in srgb, #e0a355 50%, transparent);
  background: rgba(224, 163, 85, 0.13);
}

/* 免费引擎没有提示词内核，相关的提示词级功能整体置灰 */
body.engine-free #style,
body.engine-free #model,
body.engine-free #thinking,
body.engine-free #glossary,
body.engine-free #extra {
  opacity: 0.38;
  pointer-events: none;
  filter: grayscale(1);
}

.danger-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #e0555f;
  background: transparent;
  color: #e0555f;
  font-family: var(--font);
  font-size: 12.5px;
  cursor: pointer;
  transition: var(--speed);
}
.danger-btn:hover { background: rgba(224, 85, 95, 0.12); }

.spinner {
  width: 13px; height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------ 横幅 ------------------------------ */

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 20px;
  font-size: 12.5px;
  background: linear-gradient(90deg, rgba(77, 107, 254, 0.16), rgba(139, 92, 246, 0.10));
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  flex: 0 0 auto;
}
.banner a { color: var(--brand); text-decoration: none; font-weight: 600; }
.banner a:hover { text-decoration: underline; }

/* ---------------------------- 控制条 ---------------------------- */

.controlbar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 11px 20px;
  background: color-mix(in srgb, var(--bg-2) 62%, transparent);
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.ctrl-group { display: flex; align-items: center; gap: 8px; }
.ctrl-group.grow { flex: 1 1 300px; min-width: 240px; }
.ctrl-label {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.5px;
  white-space: nowrap;
  text-transform: uppercase;
}
.ctrl-label .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ------------------------ 目标语言多选器 ------------------------ */

.picker { position: relative; flex: 1 1 auto; min-width: 0; }

.picker-btn {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  font-family: var(--font);
  transition: var(--speed);
}
.picker-btn:hover { border-color: color-mix(in srgb, var(--brand) 48%, var(--border)); }
.picker.open .picker-btn { border-color: var(--brand); box-shadow: var(--glow); }
.caret { color: var(--text-faint); font-size: 11px; flex: 0 0 auto; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 34%, transparent);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  white-space: nowrap;
}
.chip b { font-weight: 600; }
.chip .x { cursor: pointer; opacity: 0.6; font-size: 13px; line-height: 1; }
.chip .x:hover { opacity: 1; }
.chip.q { background: transparent; color: var(--text-dim); border-color: var(--border); }

.picker-panel {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  width: min(460px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 420px;
}
.picker-search { padding: 9px; border-bottom: 1px solid var(--border-soft); }
.picker-search input {
  width: 100%;
  height: 32px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0 10px;
  font-size: 12.5px;
  font-family: var(--font);
  outline: 0;
}
.picker-search input:focus { border-color: var(--brand); }
.picker-quick { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 9px; border-bottom: 1px solid var(--border-soft); }
.picker-quick .chip { cursor: pointer; }
.picker-list { overflow-y: auto; padding: 5px; flex: 1 1 auto; }
.lang-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: var(--speed);
}
.lang-row:hover { background: var(--panel-2); }
.lang-row.sel { background: var(--brand-soft); }
.lang-row input { accent-color: var(--brand); cursor: pointer; margin: 0; }
.lang-row .zh { flex: 0 0 auto; font-weight: 500; }
.lang-row .native { color: var(--text-faint); font-size: 12px; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-row .code { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; }
.picker-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-faint);
}
.picker-foot > div { display: flex; gap: 6px; }

/* --------------------------- 高级面板 --------------------------- */

.adv-panel {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg-2) 45%, transparent);
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.adv-col { flex: 1 1 260px; display: flex; flex-direction: column; gap: 6px; min-width: 220px; }
.adv-col.narrow { flex: 0 1 210px; }
.adv-col textarea {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
  outline: 0;
  line-height: 1.55;
}
.adv-col textarea:focus { border-color: var(--brand); box-shadow: var(--glow); }
.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; padding: 3px 0; }
.check input { accent-color: var(--brand); cursor: pointer; }

/* ----------------------------- 工作区 ----------------------------- */

.workbench {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px 20px 18px;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.10);
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel-2);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.pane-title { font-size: 12.5px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.5px; }
.pane-title .detected {
  font-style: normal;
  font-size: 11px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
}
.pane-title .stat { font-style: normal; font-size: 11px; color: var(--text-faint); margin-left: 6px; font-weight: 400; }
.pane-tools { display: flex; align-items: center; gap: 6px; }
.counter { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

#input {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  min-height: 0;
}
#input::placeholder { color: var(--text-faint); }

.outputs { flex: 1 1 auto; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 11px; }

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 30px;
}
.empty-logo {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  display: grid;
  place-items: center;
  opacity: 0.28;
  margin-bottom: 4px;
}
.empty-state p { margin: 0; font-size: 13.5px; color: var(--text-dim); }
.empty-state span { font-size: 11.5px; }

.out-card {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  animation: rise 0.24s ease;
  /* 关键：不许被 flex 压缩。
     .outputs 是 column flex 容器，子项默认 flex-shrink:1。长译文会把卡片压到
     容器高度以内，于是 scrollHeight == clientHeight —— 既不滚动，内容又被
     overflow:hidden 裁掉，用户永远看不到后半段（手机上尤其明显）。
     钉成 0 之后卡片保持自然高度，.outputs 才会真正溢出并出现滚动。 */
  flex: 0 0 auto;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.out-card.err { border-color: #e0555f; background: rgba(224, 85, 95, 0.07); }

.out-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}
.out-head .flag-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand);
  flex: 0 0 7px;
}
.out-card.streaming .flag-dot { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.72); } }
.out-head h3 { margin: 0; font-size: 12.5px; font-weight: 600; }
.out-head .native { color: var(--text-faint); font-size: 11.5px; }
.out-head .grow { flex: 1 1 auto; }
.out-head .meta { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); }
.out-head button {
  background: transparent;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: var(--font);
  transition: var(--speed);
}
.out-head button:hover { color: var(--brand); background: var(--brand-soft); }

.out-text {
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 46px;
  outline: 0;
}
.out-text:empty::after { content: "…"; color: var(--text-faint); }
.out-card.err .out-text { color: #e0555f; font-size: 13px; }
.out-text .cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--brand);
  vertical-align: text-bottom;
  animation: blink 0.9s step-end infinite;
  border-radius: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ------------------------------ 抽屉 ------------------------------ */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(430px, 92vw);
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 90;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s ease;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.drawer-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.drawer-head > div { display: flex; gap: 7px; align-items: center; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 13px 16px; }
.settings-body { display: flex; flex-direction: column; gap: 9px; }
.settings-body .ctrl-label { margin-top: 8px; }

.hint { font-size: 11.5px; color: var(--text-faint); }
.hint.block { margin: 0; line-height: 1.65; }
.hint code, .settings-body code {
  font-family: var(--mono);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 11px;
}

.status-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 12.5px; }
.status-grid .k { color: var(--text-faint); }
.status-grid .v { font-family: var(--mono); font-size: 12px; }

.hist-item {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-bottom: 9px;
  cursor: pointer;
  transition: var(--speed);
  background: var(--panel);
}
.hist-item:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--border)); transform: translateX(-2px); }
.hist-item .hi-head { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text-faint); margin-bottom: 6px; }
.hist-item .hi-head .pair { color: var(--brand); font-weight: 600; font-size: 11.5px; }
.hist-item .hi-head .grow { flex: 1 1 auto; }
.hist-item .src { font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hist-item .dst { font-size: 12.5px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.42); z-index: 80; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------ Toast ------------------------------ */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  box-shadow: var(--shadow);
  z-index: 200;
  max-width: min(560px, 90vw);
  animation: toastIn 0.22s ease;
}
.toast.err { border-left-color: #e0555f; }
.toast.ok { border-left-color: #2fa96b; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ------------------------ 点词查词（可点击文本） ------------------------ */

.wordview {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.95;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 0;
}

/* 可点击的单词：默认就带虚线下划线，让人一眼看出是「链接」；
   只靠 hover 变色的话，用户根本不知道这里能点。 */
.w {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 1px;
  border-bottom: 1px dashed color-mix(in srgb, var(--brand) 72%, transparent);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.w:hover {
  background: var(--brand);
  color: #fff;
  border-bottom-color: var(--brand);
  border-bottom-style: solid;
}
.w.active {
  background: var(--brand);
  color: #fff;
  border-bottom-color: var(--brand);
  border-bottom-style: solid;
}

/* 「查词」按钮处于激活态时高亮，提示当前文本可点 */
.ghost-btn.on {
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
  background: var(--brand-soft);
}

.wordview-tip {
  padding: 7px 16px 0;
  font-size: 11.5px;
  color: var(--text-faint);
}
.wordview-tip b { color: var(--brand); font-weight: 600; }

/* 译文里的可点击文本复用同一套外观 */
.out-text.clickable { cursor: default; }

/* -------------------------- 查词 / 语法 浮窗 -------------------------- */

.lookup-win {
  position: fixed;
  z-index: 150;
  width: min(580px, 94vw);
  max-height: min(78vh, 760px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: lwIn 0.18s ease;
}
@keyframes lwIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.lw-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel-2);
  cursor: move;
  user-select: none;
  flex: 0 0 auto;
}
.lw-kind {
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  white-space: nowrap;
}
.lw-kind.grammar { background: rgba(139, 92, 246, 0.16); color: var(--brand-2); }
.lw-title { font-size: 15px; font-weight: 700; }
.lw-sub { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); }
.lw-grow { flex: 1 1 auto; }
.lw-meta { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); white-space: nowrap; }
.lw-btn {
  background: transparent;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--font);
  transition: var(--speed);
  white-space: nowrap;
}
.lw-btn:hover { color: var(--brand); background: var(--brand-soft); }
.lw-btn.web {
  color: #2fa96b;
  border: 1px solid color-mix(in srgb, #2fa96b 40%, transparent);
  background: rgba(47, 169, 107, 0.1);
}
.lw-btn.web:hover { color: #2fa96b; background: rgba(47, 169, 107, 0.2); }

/* 降级视图里的「免费通道」大按钮 */
.lw-cta {
  display: block;
  width: 100%;
  margin: 14px 0 6px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, #2fa96b 45%, transparent);
  background: rgba(47, 169, 107, 0.12);
  color: #2fa96b;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--speed);
  text-align: center;
}
.lw-cta:hover { background: rgba(47, 169, 107, 0.22); transform: translateY(-1px); }
.lw-cta small { display: block; font-weight: 400; opacity: 0.8; margin-top: 3px; font-size: 11px; }

.lw-hint {
  padding: 6px 13px;
  font-size: 11px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--panel) 60%, transparent);
}
.lw-hint:empty { display: none; }
.lw-hint.warn { color: #e0a355; }

.lw-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 16px 18px;
  font-size: 13.5px;
  line-height: 1.8;
}
.lw-body h3,
.lw-body h4,
.lw-body h5,
.lw-body h6 {
  margin: 15px 0 7px;
  font-size: 13px;
  color: var(--brand);
  border-left: 3px solid var(--brand);
  padding-left: 8px;
  letter-spacing: 0.4px;
}
.lw-body h3:first-child,
.lw-body h4:first-child { margin-top: 0; }
.lw-body p { margin: 5px 0; }
.lw-body ul { margin: 5px 0; padding-left: 19px; }
.lw-body li { margin: 3px 0; }
.lw-body code {
  font-family: var(--mono);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}
.lw-body strong { color: var(--text); font-weight: 650; }
.lw-body em { color: var(--text-dim); font-style: italic; }
.lw-cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--brand);
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: blink 0.9s step-end infinite;
}

/* ---------------------------- 新手教程 ---------------------------- */

kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

.icon-btn.help {
  font-weight: 700;
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--border));
}
.icon-btn.help:hover { background: var(--brand-soft); }

.ghost-btn.accent {
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  background: var(--brand-soft);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  height: 27px;
}
.ghost-btn.accent:hover { background: color-mix(in srgb, var(--brand) 22%, transparent); }
a.ghost-btn.accent { padding: 0 10px; }

.banner-actions { display: flex; gap: 7px; flex: 0 0 auto; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(3px);
  animation: fade 0.18s ease;
}
.modal-box {
  width: min(780px, 96vw);
  max-height: min(90vh, 940px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: lwIn 0.2s ease;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel-2);
  flex: 0 0 auto;
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 20px 26px; }

.tut-intro { margin: 0 0 15px; font-size: 13px; line-height: 1.8; color: var(--text-dim); }
.tut-intro b { color: var(--text); }

.tut-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tut-tab {
  flex: 1 1 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: var(--speed);
}
.tut-tab:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); color: var(--text); }
.tut-tab.on {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 600;
}

.tut-step { display: flex; gap: 13px; margin-bottom: 19px; }
.tut-num {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.tut-content { min-width: 0; flex: 1 1 auto; }
.tut-content h3 { margin: 0 0 6px; font-size: 14px; font-weight: 650; }
.tut-content p { margin: 0 0 7px; font-size: 13px; line-height: 1.82; color: var(--text-dim); }
.tut-content b { color: var(--text); }
.tut-content a { color: var(--brand); text-decoration: none; }
.tut-content a:hover { text-decoration: underline; }
.tut-note { font-size: 12px !important; color: var(--text-faint) !important; }
.tut-warn {
  font-size: 12.5px !important;
  color: #e0a355 !important;
  background: rgba(224, 163, 85, 0.1);
  border-left: 3px solid #e0a355;
  border-radius: 6px;
  padding: 8px 11px;
}
.tut-btnrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.tut-verify-result { font-size: 12.5px; line-height: 1.6; }
.tut-verify-result.ok { color: #2fa96b; }
.tut-verify-result.bad { color: #e0555f; }

.tut-table { width: 100%; border-collapse: collapse; margin: 9px 0; font-size: 12.5px; }
.tut-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  line-height: 1.7;
  vertical-align: top;
}
.tut-table td:first-child { color: var(--text); white-space: nowrap; }
.tut-table.err td:first-child { font-family: var(--mono); font-size: 11.5px; }
.tut-table b { color: var(--brand); }

/* 把「¥20 能翻多少」那一行拎出来，让人一眼看到 */
.tut-table tr.tut-hi { background: var(--brand-soft); }
.tut-table tr.tut-hi td { border-bottom: 0; }
.tut-table tr.tut-hi td:first-child { white-space: normal; border-radius: 8px 0 0 8px; }
.tut-table tr.tut-hi td:last-child { border-radius: 0 8px 8px 0; }
.tut-table tr.tut-hi b { font-size: 13.5px; }

.tut-errors,
.tut-privacy { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.tut-errors h3,
.tut-privacy h3 { margin: 0 0 8px; font-size: 13.5px; }
.tut-privacy p { margin: 0 0 9px; font-size: 13px; line-height: 1.82; color: var(--text-dim); }
.tut-privacy b { color: var(--text); }

.tut-cta { margin-top: 18px; }

/* 只在手机上出现的区块（顶栏塞不下的控件挪到设置里） */
.mobile-only { display: none; flex-direction: column; gap: 8px; }

/* AI 生成内容标识（合规要求，别删） */
.ai-tag {
  font-size: 10.5px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  cursor: help;
}

/* ---------------------------- 法律声明 ---------------------------- */

.legal {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 11.5px;
  line-height: 1.78;
  color: var(--text-faint);
}
.legal p {
  margin: 0;
  padding-left: 9px;
  border-left: 2px solid var(--border);
}
.legal b { color: var(--text-dim); }

/* ---------------------- 第一次来的三步引导 ---------------------- */

.welcome {
  position: relative;
  margin: 14px 20px 0;
  padding: 18px 22px 16px;
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--border));
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 10%, transparent), transparent 60%),
    var(--panel);
  flex: 0 0 auto;
  animation: rise 0.24s ease;
}
.welcome-x {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 15px;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 6px;
  min-width: 30px;
  min-height: 30px;
  line-height: 1;
}
.welcome-x:hover { color: var(--text); background: var(--panel-2); }

.welcome h2 { margin: 0 0 6px; font-size: 16px; font-weight: 650; }
.welcome-sub { margin: 0 0 14px; font-size: 12.5px; line-height: 1.75; color: var(--text-dim); max-width: 760px; }
.welcome-sub b { color: var(--text); }

.welcome-steps {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.welcome-steps li {
  display: flex;
  gap: 10px;
  padding: 12px 13px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.ws-n {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.welcome-steps li > div { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.welcome-steps b { font-size: 13px; }
.welcome-steps span { font-size: 12px; line-height: 1.7; color: var(--text-dim); }
.welcome-steps code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
}
.welcome-steps .ghost-btn { align-self: flex-start; margin-top: 2px; }

.welcome-foot {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.welcome-foot b { color: var(--brand); }

/* 手机专用紧凑版引导：默认隐藏，手机断点里打开 */
.welcome-compact { display: none; flex-direction: column; gap: 9px; }
.wc-title { font-size: 15px; font-weight: 650; }
.wc-line { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }
/* 手机上那条省钱提示：给点颜色和左边框，别让它淹没在文字里 */
.wc-line.wc-tip {
  color: var(--text);
  font-size: 12px;
  line-height: 1.65;
  padding: 7px 9px;
  border-left: 3px solid var(--brand);
  border-radius: 0 7px 7px 0;
  background: var(--brand-soft);
}
.wc-line.wc-tip b { color: var(--brand); }
.wc-btns { display: flex; gap: 7px; flex-wrap: wrap; }
.wc-btns .ghost-btn { height: 34px; padding: 0 11px; }

@media (max-width: 700px) {
  .welcome { margin: 10px 12px 0; padding: 14px 16px; }
}

/* ---------------------------- 滚动条 ---------------------------- */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------------------------- 响应式 ---------------------------- */

/* 平板 / 窄桌面：面板上下排 */
@media (max-width: 980px) {
  .workbench { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .keybox input { width: 150px; }
  .brand-text p { display: none; }
}

/* ============================== 手机 ==============================
   手机上的核心矛盾是「chrome 占的竖向空间太多」：
   顶栏一排控件 + 控制条两三排 → 两个面板被挤到只剩一条缝。
   所以手机上大幅砍掉常驻控件，能进设置的一律进设置。
   ================================================================= */
@media (max-width: 760px) {
  /* 用 dvh，避开手机地址栏伸缩导致的高度跳动 */
  html, body { height: 100dvh; }

  /* ---------- 顶栏：只留 logo + Key + 两个图标 ---------- */
  .topbar {
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
    gap: 8px;
    flex-wrap: nowrap;
  }
  .logo { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; font-size: 18px; }
  .brand { gap: 9px; }
  .brand-text h1 { font-size: 15px; letter-spacing: 0; }
  .brand-text h1 span { display: none; }        /* 副标题不占位 */
  .brand-text p { display: none; }

  /* 引擎 / 模型 / 主题 / 退出 全部收进设置 —— 手机上没地方摆 */
  #engine, #model, #themeBtn, #exitBtn { display: none; }
  .mobile-only { display: flex; }
  .select.wide { width: 100%; max-width: none; }
  .topbar-right { gap: 6px; flex-wrap: nowrap; }

  /* Key 输入框收窄，但字号保持 16px —— 小于 16px iOS 聚焦时会自动放大整页 */
  .keybox { height: 36px; padding: 0 4px 0 9px; }
  .keybox input { width: 104px; font-size: 16px; }
  .keybox .ico { width: 14px; height: 14px; flex: 0 0 14px; }
  #toggleKey { display: none; }

  /* ---------- 控制条：压成两行 ---------- */
  .controlbar {
    padding: 8px 12px 9px;
    gap: 7px;
    align-items: center;
  }
  .ctrl-label { display: none; }                 /* 「源语言」这种标签手机上是噪音 */
  .ctrl-group { gap: 6px; min-width: 0; }

  /* 第一行：源语言 + 互换 + 目标语言 挤在一起 */
  #sourceLang { flex: 1 1 0; min-width: 0; }
  .ctrl-group.grow { flex: 1 1 96px; min-width: 84px; }
  .select { max-width: none; height: 38px; font-size: 14px; }
  .icon-btn { height: 38px; min-width: 38px; }
  .icon-btn.swap { flex: 0 0 38px; }
  .picker-btn { min-height: 38px; padding: 4px 9px; }
  .chip { font-size: 12px; padding: 3px 8px; }

  /* 第二行：风格 + 徽标 + 高级/历史 + 翻译 */
  #style { flex: 0 1 82px; min-width: 72px; }
  .engine-badge {
    font-size: 10px;
    padding: 0 7px;
    height: 22px;
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 1 auto;
  }
  #translateBtn {
    flex: 1 1 auto;
    min-width: 96px;
    height: 42px;
    font-size: 15px;
    letter-spacing: 2px;
    order: 0;
    margin-top: 0;
  }

  /* ---------- 高级面板 ---------- */
  .adv-panel { padding: 10px 12px; gap: 10px; }
  .adv-col, .adv-col.narrow { flex: 1 1 100%; min-width: 0; }
  .adv-col textarea { font-size: 16px; }         /* 同样防 iOS 放大 */

  /* ---------- 工作区：上下各一半 ---------- */
  .workbench {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 9px;
    padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
    min-height: 0;
  }
  .pane { min-height: 0; border-radius: 12px; }
  .pane-head { padding: 6px 10px; gap: 6px; flex-wrap: nowrap; }
  .pane-title { font-size: 12px; }
  .pane-tools { gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .pane-tools::-webkit-scrollbar { display: none; }
  .counter { display: none; }                    /* 「0 字符」手机上看不出价值 */
  .ai-tag { display: none; }                     /* 声明在设置页里还在 */
  .ghost-btn { height: 30px; padding: 0 8px; font-size: 11.5px; }
  /* .ghost-btn.accent 的优先级更高，得单独覆盖，否则横幅里的按钮还是 27px */
  .ghost-btn.accent { height: 30px; }

  /* 输入与译文都提到 16px：既好读，也避免 iOS 聚焦时把整页放大 */
  #input { font-size: 16px; line-height: 1.7; padding: 12px 13px; }
  .wordview { font-size: 16px; line-height: 1.9; padding: 12px 13px; }
  .out-text { font-size: 16px; line-height: 1.75; padding: 11px 13px; }
  .outputs { padding: 9px; gap: 9px; }
  .out-head { padding: 6px 10px; font-size: 11.5px; }
  .out-head button { padding: 4px 7px; }

  /* ---------- 触摸优化 ---------- */
  .ghost-btn, .icon-btn, .select, .primary-btn, .w,
  .side-item, .tut-tab, .lang-row, .picker-btn {
    touch-action: manipulation;                  /* 去掉双击缩放那 300ms 延迟 */
    -webkit-tap-highlight-color: transparent;
  }
  /* 可点的词给大一点的热区，手机上更好点中 */
  .w { padding: 1px 2px; margin: 0 -1px; }

  /* ---------- 查词浮窗 → 底部抽屉 ---------- */
  .lookup-win {
    left: 0 !important;
    top: auto !important;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-height: 84dvh;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheetUp 0.22s ease;
  }
  .lw-head { cursor: default; }
  .lw-body { padding: 12px 15px 20px; font-size: 15px; }
  .lw-body h3, .lw-body h4 { font-size: 14px; }
  .lw-btn { padding: 6px 9px; font-size: 13px; }

  /* ---------- 教程 → 全屏 ---------- */
  .modal { padding: 0; align-items: stretch; }
  .modal-box {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-body { padding: 14px 16px 24px; }
  .tut-tabs { flex-direction: column; }
  .tut-step { gap: 10px; }

  /* ---------- 抽屉全宽 ---------- */
  .drawer {
    width: 100vw;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* ---------- 欢迎卡片：手机上换成紧凑版 ---------- */
  .welcome { margin: 9px 12px 0; padding: 13px 14px; }
  .welcome h2, .welcome-sub, .welcome-steps, .welcome-foot { display: none; }
  .welcome-compact { display: flex; }
  /* 双保险：就算以后加了内容，也不许它把面板挤没 */
  .welcome { max-height: 32dvh; overflow-y: auto; }

  /* ---------- Toast 别被底部安全区挡住 ---------- */
  .toast { bottom: calc(18px + env(safe-area-inset-bottom)); font-size: 13px; }
}

@keyframes sheetUp {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* 横屏手机：竖向太矮，两栏并排更合理 */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .workbench {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
  }
  #translateBtn { flex: 0 0 auto; order: 0; }
}

