/* ============================================================
   style.css — 移动端优先 UI
   ============================================================ */
:root {
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --brand-deep: #4338ca;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1a1c25;
  --text-2: #5b6076;
  --text-3: #8b90a5;
  --line: #e8eaf2;
  --ok: #16a34a;
  --warn: #f59e0b;
  --err: #dc2626;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(28, 32, 60, .06);
  --shadow-lg: 0 8px 28px rgba(28, 32, 60, .12);
  --tab-h: 58px;
}

html[data-theme="dark"] {
  --brand: #8b8ffb;
  --brand-soft: #23254a;
  --brand-deep: #a5a8ff;
  --bg: #12131a;
  --card: #1b1d27;
  --text: #eceef7;
  --text-2: #a8adc4;
  --text-3: #73788f;
  --line: #2c2f3d;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.6;
  overscroll-behavior-y: none;
}
body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }

button, input, textarea, select { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex: none;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; flex: 1; letter-spacing: .3px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; color: var(--text-2);
  background: var(--bg); flex: none;
}
.icon-btn:active { background: var(--line); }

/* ---------- 页面容器 ---------- */
.view { display: none; padding: 14px 16px 20px; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card.tight { padding: 12px 14px; }
.sec-title {
  font-size: 13px; font-weight: 650; color: var(--text-3);
  letter-spacing: .6px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px;
}
.sec-title::before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: var(--brand); }

/* ---------- 搜索 ---------- */
.searchbar { display: flex; gap: 8px; align-items: center; }
.search-wrap {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 14px; padding: 0 12px;
  box-shadow: var(--shadow); height: 50px;
}
.search-wrap input { flex: 1; border: none; outline: none; background: none; height: 100%; }
.search-wrap .clear { color: var(--text-3); padding: 4px; display: none; }
.search-wrap.has-value .clear { display: block; }
.btn-primary {
  height: 50px; padding: 0 18px; border-radius: 14px; flex: none;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 15px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .28);
}
.btn-primary:active { background: var(--brand-deep); transform: scale(.98); }
.btn-ghost {
  height: 40px; padding: 0 14px; border-radius: 12px; background: var(--bg);
  color: var(--text-2); font-size: 14px;
}
.btn-ghost:active { background: var(--line); }

/* ---------- 单词头部 ---------- */
.word-head { display: flex; align-items: flex-start; gap: 10px; }
.word-main { flex: 1; min-width: 0; }
.word-title { font-size: 30px; font-weight: 700; letter-spacing: -.5px; line-height: 1.2; word-break: break-word; }
.phonetic { color: var(--text-2); font-size: 15px; margin-top: 2px; font-family: "Times New Roman", serif; }
.phonetic .sep { color: var(--text-3); margin: 0 4px; }
.word-actions { display: flex; gap: 8px; flex: none; }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: flex; align-items: center; justify-content: center;
}
.round-btn:active { transform: scale(.94); }
.round-btn.on { background: var(--brand); color: #fff; }
.accent-switch { display: flex; gap: 4px; margin-top: 8px; }
.accent-chip {
  padding: 3px 10px; border-radius: 20px; font-size: 12px;
  background: var(--bg); color: var(--text-2);
}
.accent-chip.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ---------- 释义 ---------- */
.sense { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.sense:last-child { border-bottom: none; }
.sense-pos {
  display: inline-block; font-size: 12px; font-style: italic; color: var(--brand);
  background: var(--brand-soft); padding: 1px 8px; border-radius: 6px; margin-right: 6px;
}
.sense-cn { font-weight: 600; }
.sense-en { color: var(--text-2); font-size: 14px; margin-top: 3px; }

/* ---------- 例句 ---------- */
.example { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.example:last-child { border-bottom: none; }
.example-en { font-size: 15px; }
.example-en b { color: var(--brand); font-weight: 700; }
.example-zh { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.example-tools { display: flex; gap: 10px; margin-top: 6px; }
.mini-btn { font-size: 12px; color: var(--brand); display: flex; align-items: center; gap: 3px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 12px; border-radius: 20px; background: var(--bg);
  font-size: 14px; color: var(--text); border: 1px solid transparent;
}
.chip:active { background: var(--brand-soft); }
.chip.syn { border-color: rgba(22, 163, 74, .25); color: var(--ok); }
.chip.ant { border-color: rgba(220, 38, 38, .25); color: var(--err); }

/* ---------- 段落页 ---------- */
.lang-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lang-pill {
  flex: 1; padding: 9px 0; text-align: center; border-radius: 12px;
  background: var(--card); box-shadow: var(--shadow); font-size: 14px; font-weight: 600;
}
.swap-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: flex; align-items: center; justify-content: center; flex: none;
}
textarea.input {
  width: 100%; min-height: 130px; border: none; outline: none; resize: vertical;
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); line-height: 1.65; font-size: 16px;
}
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.counter { font-size: 12px; color: var(--text-3); }

/* ---------- 译文 ---------- */
.result-cn { font-size: 17px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }

/* 逐句对照 */
.sentence-pair { padding: 12px 0; border-bottom: 1px solid var(--line); }
.sentence-pair:last-child { border-bottom: none; }
.sp-en { font-size: 15px; line-height: 1.7; }
.sp-zh { font-size: 15px; color: var(--text-2); margin-top: 4px; }

/* ---------- 逐词标注 ---------- */
.tk {
  display: inline-block; text-align: center; margin: 0 2px 10px; vertical-align: top;
  padding: 2px 3px; border-radius: 6px; position: relative;
}
.tk .w { font-size: 16px; line-height: 1.35; }
.tk .m {
  font-size: 11px; color: var(--brand); line-height: 1.2; margin-top: 1px;
  max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tk .m.loading { color: var(--text-3); }
.tk.punct { display: inline; margin: 0; }
.tk.clickable:active { background: var(--brand-soft); }
.tk.newline { display: block; height: 0; margin: 0; }
.tk.has-meaning { background: rgba(79, 70, 229, .05); }

/* ---------- 底部弹出词义卡 ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(15, 18, 32, .45); z-index: 90;
  display: none; align-items: flex-end;
}
.sheet-mask.show { display: flex; }
.sheet {
  width: 100%; background: var(--card); border-radius: 20px 20px 0 0;
  padding: 16px 18px calc(24px + env(safe-area-inset-bottom));
  max-height: 72vh; overflow-y: auto; animation: up .24s ease;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sheet-title { font-size: 20px; font-weight: 700; flex: 1; }

/* ---------- 生词本 ---------- */
.book-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.book-item:last-child { border-bottom: none; }
.book-word { flex: 1; min-width: 0; }
.book-word .w { font-size: 16px; font-weight: 600; }
.book-word .m { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-del { color: var(--text-3); padding: 6px; }

/* ---------- 底部导航栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
  display: flex;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-3); font-size: 11px;
}
.tab.on { color: var(--brand); font-weight: 600; }
.tab svg { width: 22px; height: 22px; }

/* ---------- 状态 ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); font-size: 14px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.spinner {
  width: 22px; height: 22px; border: 2.5px solid var(--line);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 18px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--line) 25%, var(--bg) 37%, var(--line) 63%);
  background-size: 400% 100%; animation: sk 1.3s ease infinite; margin: 8px 0;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px); transform: translateX(-50%) translateY(10px);
  background: rgba(26, 28, 37, .92); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 14px; z-index: 200; opacity: 0; transition: .22s; pointer-events: none; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.badge {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 6px;
  background: var(--brand-soft); color: var(--brand); margin-left: 6px;
}
.src-note { font-size: 12px; color: var(--text-3); margin-top: 10px; text-align: right; }

/* ---------- 设置面板 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.field input, .field select {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); outline: none;
}
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.switch {
  width: 46px; height: 27px; border-radius: 20px; background: var(--line); position: relative; transition: .2s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.switch.on { background: var(--brand); }
.switch.on::after { left: 22px; }

/* ---------- 桌面端居中 ---------- */
@media (min-width: 720px) {
  body { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); min-height: 100vh; }
  .tabbar, .topbar { max-width: 560px; left: 50%; right: auto; transform: translateX(-50%); width: 100%; }
  .sheet { max-width: 560px; margin: 0 auto; border-radius: 20px 20px 0 0; }
  .toast { bottom: 90px; }
}
