/* ============================================================
   单词镜 · WordLens
   纸墨质感的词典界面，明暗双主题
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --sans: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --serif: Georgia, "Times New Roman", "Songti SC", "STSong", "SimSun", serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Courier New", monospace;

  --bg: #f4f1e9;
  --surface: #fffdf7;
  --surface-2: #faf6ec;
  --ink: #1a1815;
  --ink-2: #46413a;
  --muted: #8b8478;
  --line: #e6dfcd;
  --line-strong: #d5cbb4;
  --accent: #b4552d;
  --accent-btn: #b4552d;
  --accent-ink: #8f3f1f;
  --accent-soft: #f3ddce;
  --on-accent: #fff8f0;
  --ring: rgba(180, 85, 45, .14);
  --amb-1: rgba(180, 85, 45, .10);
  --amb-2: rgba(58, 84, 96, .09);

  --shadow-sm: 0 1px 2px rgba(26, 24, 21, .05);
  --shadow: 0 1px 2px rgba(26, 24, 21, .05), 0 14px 34px -18px rgba(26, 24, 21, .35);
  --shadow-lg: 0 2px 4px rgba(26, 24, 21, .05), 0 24px 50px -20px rgba(26, 24, 21, .38);
  --shadow-xl: 0 30px 80px -24px rgba(26, 24, 21, .5);

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
}

html[data-theme="dark"] {
  --bg: #14130f;
  --surface: #1b1a16;
  --surface-2: #22201a;
  --ink: #efe9db;
  --ink-2: #c6bfae;
  --muted: #8d8677;
  --line: #302d25;
  --line-strong: #423d31;
  --accent: #e08358;
  --accent-btn: #c9663c;
  --accent-ink: #f0a985;
  --accent-soft: #3a271b;
  --on-accent: #fff5ee;
  --ring: rgba(224, 131, 88, .18);
  --amb-1: rgba(224, 131, 88, .10);
  --amb-2: rgba(96, 140, 158, .10);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -20px rgba(0, 0, 0, .8);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 26px 56px -22px rgba(0, 0, 0, .85);
  --shadow-xl: 0 34px 90px -26px rgba(0, 0, 0, .9);
}

/* ---------- 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* 组件用了 display:grid/flex，会盖掉 UA 的 [hidden]，这里补回来 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(920px 540px at 8% -10%, var(--amb-1), transparent 62%),
    radial-gradient(780px 520px at 96% 2%, var(--amb-2), transparent 58%);
  transition: background .3s;
}

::selection { background: var(--accent-soft); color: var(--ink); }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

kbd {
  font-family: var(--mono);
  font-size: .78em;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--ink-2);
  background: var(--surface-2);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(18px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid transparent;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  padding: 2px 6px 2px 2px;
}
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-btn);
  color: var(--on-accent);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1;
  padding-bottom: 2px;
  box-shadow: var(--shadow-sm);
}

.brand-text { display: flex; align-items: baseline; gap: 7px; }
.brand-text b { font-size: 15.5px; letter-spacing: .04em; font-weight: 650; }
.brand-text i {
  font-style: normal;
  font-family: var(--serif);
  font-size: 12.5px;
  letter-spacing: .12em;
  color: var(--muted);
  text-transform: uppercase;
}

.topbar-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-2);
  transition: background .18s, color .18s, transform .18s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 19px; height: 19px; }

.badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent-btn);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

html[data-theme="light"] .ico-sun,
html[data-theme="dark"] .ico-moon { display: none; }

/* ---------- 主区 ---------- */
.main {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(18px, 5vh, 52px) clamp(16px, 4vw, 24px) 40px;
  flex: 1;
}

.hero {
  text-align: center;
  max-height: 260px;
  opacity: 1;
  overflow: hidden;
  transition: max-height .42s cubic-bezier(.2, .75, .3, 1), opacity .3s, margin .42s;
  margin-bottom: 26px;
}
.main.compact .hero { max-height: 0; opacity: 0; margin-bottom: 4px; }

/* 出结果后上方留白收紧 */
.main.compact { padding-top: clamp(14px, 3vh, 26px); }

.hero-title {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 5.2vw, 40px);
  line-height: 1.2;
  letter-spacing: -.01em;
}
.hero-title em {
  font-style: normal;
  color: var(--accent);
  position: relative;
}
.hero-title em::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 6px;
  background: var(--accent-soft);
  z-index: -1;
  border-radius: 3px;
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .02em;
}

/* ---------- 搜索框 ---------- */
.search-wrap { position: relative; z-index: 30; }

.search-box {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 62px;
  padding: 0 9px 0 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring), var(--shadow);
}

.search-ico { width: 19px; height: 19px; color: var(--muted); flex: none; }

#q {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: none;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: .01em;
}
#q::placeholder { color: var(--muted); font-weight: 400; }

.clear-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
  transition: .18s;
}
.clear-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.clear-btn svg { width: 13px; height: 13px; }

.search-sep { width: 1px; height: 22px; background: var(--line); flex: none; }

.scan-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 15px;
  border: 0;
  border-radius: 12px;
  background: var(--accent-btn);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 600;
  flex: none;
  transition: filter .18s, transform .18s;
  box-shadow: 0 2px 10px -4px var(--accent-btn);
}
.scan-btn:hover { filter: brightness(1.07); }
.scan-btn:active { transform: scale(.97); }
.scan-btn svg { width: 17px; height: 17px; }

/* ---------- 联想下拉 ---------- */
.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 9px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-height: min(396px, 56vh);
  overflow-y: auto;
  animation: drop .18s cubic-bezier(.2, .8, .3, 1);
}
.suggest::-webkit-scrollbar { width: 8px; }
.suggest::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }

.sug-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
}
.sug-item:hover { background: var(--surface-2); }
.sug-item[aria-selected="true"] { background: var(--accent-soft); }
.sug-word { font-weight: 600; font-size: 15px; flex: none; }
.sug-explain {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sug-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 词条小胶囊 ---------- */
.chips {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.chips-label {
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--muted);
  text-transform: uppercase;
  flex: none;
}
.chips-list { display: flex; gap: 7px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 13px;
  transition: .18s;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

/* ---------- 结果卡片 ---------- */
.stage { margin-top: 26px; min-height: 40px; }

.card {
  position: relative;
  padding: clamp(24px, 5vw, 36px) clamp(20px, 4.6vw, 38px) clamp(18px, 3vw, 26px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  animation: rise .4s cubic-bezier(.2, .8, .3, 1) both;
}

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.word-line { min-width: 0; }

.word {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(34px, 6.4vw, 48px);
  line-height: 1.08;
  letter-spacing: -.015em;
  word-break: break-word;
}

.star-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
  transition: .18s;
}
.star-btn:hover { border-color: var(--accent); color: var(--accent); }
.star-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.star-btn svg { width: 18px; height: 18px; }

.phonetics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.phon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  transition: .18s;
}
.phon:hover { border-color: var(--accent); background: var(--accent-soft); }
.phon-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--muted);
}
.phon:hover .phon-label { color: var(--accent-ink); }
.phon-ipa { font-family: var(--mono); font-size: 13.5px; }
.phon svg { width: 14px; height: 14px; opacity: .65; }
.phon.playing { border-color: var(--accent); background: var(--accent-soft); }
.phon.playing svg { animation: pulse .9s ease-in-out infinite; opacity: 1; }

.forms {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.forms b { color: var(--ink-2); font-weight: 600; }

.defs {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.defs li { display: flex; gap: 10px; font-size: 15px; line-height: 1.65; }
.pos {
  flex: none;
  min-width: 38px;
  padding-top: 1px;
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
}

/* ---------- 区块 ---------- */
.block { margin-top: 30px; padding-top: 22px; border-top: 1px dashed var(--line); }

.block-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 15px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.block-title .count {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.block-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.phrases {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(216px, 1fr));
  gap: 9px;
}
.phrase {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: .18s;
  animation: rise .35s both;
}
.phrase:hover { border-color: var(--accent); transform: translateY(-1px); }
.phrase b { display: block; font-size: 14px; font-weight: 600; letter-spacing: .01em; }
.phrase span { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; }

.synos { display: flex; flex-direction: column; gap: 10px; }
.syno-group { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.syno-pos {
  flex: none;
  min-width: 38px;
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 12px;
}
.syno-words { display: flex; flex-wrap: wrap; gap: 6px; }
.syno-word {
  padding: 3px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 13.5px;
  color: var(--ink-2);
  transition: .16s;
}
.syno-word:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

.examples { margin: 0; padding: 0; list-style: none; }.examples li {
  position: relative;
  padding: 12px 40px 12px 18px;
  border-left: 2px solid var(--line-strong);
  border-radius: 0 8px 8px 0;
  transition: .2s;
  animation: rise .35s both;
}
.examples li:hover { border-left-color: var(--accent); background: var(--surface-2); }

.ex-en { margin: 0; font-size: 14.5px; line-height: 1.62; font-family: var(--serif); }
.ex-en mark {
  background: linear-gradient(transparent 58%, var(--accent-soft) 58%);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}
.ex-zh { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.ex-from {
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 10.5px;
  letter-spacing: .02em;
  white-space: nowrap;
}

.speak-btn {
  position: absolute;
  right: 6px;
  top: 11px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  transition: .18s;
}
.examples li:hover .speak-btn { opacity: 1; }
.speak-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.speak-btn svg { width: 14px; height: 14px; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .04em;
}
.card-foot .stamp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.card-foot svg { width: 12px; height: 12px; }

/* ---------- 空态 / 骨架 / 错误 ---------- */
.blank {
  text-align: center;
  padding: 34px 20px;
  color: var(--muted);
  font-size: 13.5px;
  animation: rise .4s both;
}
.blank .samples { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 16px; }
.blank-title {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.skeleton { pointer-events: none; }
.sk-line {
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite linear;
}
.sk-word { height: 42px; width: 40%; border-radius: 10px; margin-bottom: 18px; }
.sk-line:nth-child(2) { width: 22%; margin-bottom: 22px; }
.sk-line:nth-child(3) { width: 88%; margin-bottom: 9px; }
.sk-line:nth-child(4) { width: 72%; margin-bottom: 9px; }
.sk-line:nth-child(5) { width: 80%; }

.error-box {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: rise .35s both;
}
.error-box svg { width: 18px; height: 18px; color: var(--accent); flex: none; margin-top: 2px; }
.error-box h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 650; }
.error-box p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.error-box code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- 底部 ---------- */
.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 22px 20px 30px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .03em;
}
.foot-dot { opacity: .5; }

/* ---------- 扫一扫弹窗 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vw, 28px);
  background: rgba(18, 16, 13, .55);
  backdrop-filter: blur(7px);
  animation: fade .2s ease;
}

.modal {
  width: min(700px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: pop .26s cubic-bezier(.2, .85, .3, 1);
}

.modal-head {
  position: relative;
  padding: 22px 24px 14px;
  flex: none;
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: .02em; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.modal-head .icon-btn { position: absolute; top: 14px; right: 14px; }

.modal-body { padding: 0 24px 24px; overflow-y: auto; }

.cam-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: 44vh;
  border-radius: 15px;
  overflow: hidden;
  background: #0c0b09;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.cam-frame video { width: 100%; height: 100%; object-fit: cover; display: none; }
.cam-frame.live video { display: block; }
.cam-frame.live .cam-placeholder { display: none; }
.cam-frame.dragover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring) inset; }

.cam-placeholder {
  display: grid;
  place-items: center;
  gap: 8px;
  color: #6b6357;
  font-size: 12.5px;
}
.cam-placeholder svg { width: 34px; height: 34px; opacity: .6; }

.reticle { position: absolute; inset: 13%; pointer-events: none; }
.reticle i {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, .8);
  border-radius: 2px;
}
.reticle i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.reticle i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.reticle i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.reticle i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }

.scan-line {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 13%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  pointer-events: none;
}
.scanning .scan-line { opacity: 1; animation: sweep 1.5s ease-in-out infinite alternate; }

.cam-actions {
  display: flex;
  gap: 9px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 17px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 550;
  transition: .18s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: var(--accent-btn); border-color: var(--accent-btn); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.07); color: var(--on-accent); }
.btn.ghost { background: transparent; }

.scan-tip { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

.scan-progress { margin-top: 16px; }
.scan-progress .bar {
  height: 5px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--line);
}
.scan-progress .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .25s ease;
}
.scan-progress span {
  display: block;
  margin-top: 7px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.scan-result { margin-top: 16px; animation: rise .3s both; }
.scan-result-title { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.scan-result-title b { color: var(--accent-ink); }

.word-cloud { display: flex; flex-wrap: wrap; gap: 6px; max-height: 176px; overflow-y: auto; }
.word-tag {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13.5px;
  font-family: var(--mono);
  transition: .16s;
}
.word-tag:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

.raw-text { margin-top: 12px; }
.raw-text summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.raw-text summary::-webkit-details-marker { display: none; }
.raw-text summary::before { content: "▸"; font-size: 10px; transition: .2s; }
.raw-text[open] summary::before { transform: rotate(90deg); }
.raw-text pre {
  margin: 8px 0 0;
  padding: 12px;
  max-height: 150px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--ink-2);
}

/* ---------- 生词本抽屉 ---------- */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-xl);
  animation: slideIn .28s cubic-bezier(.2, .85, .3, 1);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: .03em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 10px; }
.drawer-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.drawer-foot .btn { width: 100%; }

.book-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}
.book-item:hover { background: var(--surface-2); }
.book-item b { font-weight: 600; font-size: 14.5px; font-family: var(--serif); }
.book-item .book-def {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-del {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  flex: none;
  opacity: 0;
  transition: .15s;
}
.book-item:hover .book-del { opacity: 1; }
.book-del:hover { background: var(--accent-soft); color: var(--accent-ink); }
.book-del svg { width: 13px; height: 13px; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(18, 16, 13, .4);
  backdrop-filter: blur(3px);
  animation: fade .2s;
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 16px);
  z-index: 120;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  box-shadow: var(--shadow-lg);
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 动画 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.16); } }
@keyframes sweep { from { top: 13%; } to { top: 85%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 触屏设备：不能只靠 hover 露出操作 ---------- */
@media (hover: none) {
  .speak-btn { opacity: .55; }
  .book-del { opacity: .55; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .brand-text i { display: none; }
  .search-box { height: 56px; padding-left: 14px; border-radius: 16px; }
  .scan-btn { padding: 0 13px; height: 40px; }
  .scan-btn span { display: none; }
  .main { padding-top: 14px; }
  .hero { margin-bottom: 18px; }
  .card { border-radius: 18px; }
  .phrases { grid-template-columns: 1fr; }
  .examples li { padding-right: 16px; }
  .speak-btn { opacity: .55; position: static; margin-left: auto; }
  .ex-head { display: flex; align-items: flex-start; gap: 8px; }
  .card-foot { flex-direction: column; align-items: flex-start; gap: 4px; }
  .modal-body { padding: 0 16px 18px; }
  .modal-head { padding: 18px 16px 12px; }
}
