:root {
  --bg: #ffffff;       /* 页面白底（仅顶部栏用天蓝） */
  --panel: #ffffff;
  --ink: #1d3456;        /* VOLVO 主蓝 - 深 */
  --blue: #0070c0;       /* 常用蓝 */
  --blue-soft: #e8f1fb;
  --pink: #FFC0CB;       /* 用户指定粉（取代原 #E91E8C 品红） */
  --pink-soft: #FFE6EC;
  --pink-dark: #C2185B;  /* 深玫瑰，小字/边框对比用 */
  --accent: var(--pink); /* 主点缀色：原金黄 → 粉红 */
  --warn: #cf7629;       /* 暖橙 */
  --text: #1d1d1b;
  --muted: #6b7280;
  --line: #e3e9f0;
  --good: #2e9e6b;
  --shadow: 0 10px 30px rgba(29, 52, 86, 0.10);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background: #87CEEB;     /* Sky Blue（用户指定，取代原深海军蓝渐变） */
  color: var(--ink);
  padding: 18px 24px 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 4px 18px rgba(29,52,86,0.18);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--accent); color: var(--ink);
  display: grid; place-items: center;
  font-size: 26px; font-weight: 800;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.brand-text h1 { margin: 0; font-size: 20px; letter-spacing: 0.5px; color: var(--ink); }
.brand-text p { margin: 2px 0 0; font-size: 12.5px; color: rgba(29,52,86,0.78); }

.level-tabs {
  display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap;
}
.level-tab {
  border: none; cursor: pointer;
  background: rgba(255,255,255,0.55);
  color: var(--ink); padding: 8px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; transition: all 0.18s;
}
.level-tab:hover { background: rgba(255,255,255,0.82); }
.level-tab.active { background: var(--accent); color: var(--ink); }
.level-tab.pending { opacity: 0.62; border: 1px dashed rgba(255,255,255,0.75); }

/* 词库分段加载状态 / 致命错误提示 */
.load-status {
  display: none;
  margin: 0 auto 10px;
  padding: 7px 14px;
  max-width: 720px;
  border-radius: 10px;
  background: var(--blue-soft, #eaf2fb);
  color: var(--blue, #0070c0);
  font-size: 13px;
  text-align: center;
}
.load-status.show { display: block; }
.load-status.err { background: #fdecea; color: #b3261e; }

.fatal-banner {
  display: none;
  margin: 0 auto 12px;
  padding: 12px 16px;
  max-width: 720px;
  border: 1px solid #f0c2bd;
  border-left: 4px solid #b3261e;
  border-radius: 10px;
  background: #fdecea;
  color: #7d1f18;
  font-size: 14px;
  line-height: 1.7;
}
.fatal-banner.show { display: block; }

/* Main */
.app-main { max-width: 820px; margin: 0 auto; padding: 22px 18px 40px; }

.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.toolbar-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 200px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; background: var(--panel);
}
.search:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.switch { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; cursor: pointer;
  font-weight: 600; transition: all 0.16s; white-space: nowrap;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.primary:hover { background: #005fa3; color: #fff; }
/* Flip & Annotate primary CTAs → pink accent (light pink fill + navy text for legibility) */
#flipBtn, #annoBtn { background: var(--pink); color: var(--ink); border-color: var(--pink-dark); }
#flipBtn:hover, #annoBtn:hover { background: #F7A8BC; border-color: #F7A8BC; }
.btn.ghost { background: transparent; }
.btn.mode.active { background: var(--pink); color: var(--ink); border-color: var(--pink-dark); }

/* Card */
.card-scene { perspective: 1600px; margin-bottom: 16px; }
.card {
  width: 100%;
  height: 460px;
  cursor: pointer;
  position: relative;
}
.card-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 0.55s cubic-bezier(.2,.7,.2,1);
  transform-style: preserve-3d;
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 26px; display: flex; flex-direction: column;
}
.card-front { align-items: center; justify-content: center; text-align: center; }
.card-back { transform: rotateY(180deg); overflow-y: auto; }

.pos-tag {
  display: inline-block; background: var(--blue-soft); color: var(--blue);
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.5px;
}
.hanzi { font-size: 88px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.pinyin { font-size: 26px; color: var(--blue); margin-top: 10px; letter-spacing: 1px; }
.match-tag { margin-top: 14px; min-height: 0; color: var(--pink-dark); font-size: 13px;
  font-weight: 600; background: var(--pink-soft); border: 1px solid var(--pink); border-radius: 999px;
  padding: 4px 12px; display: none; }
.match-tag.show { display: inline-block; }
.hanzi-sm { font-size: 30px; font-weight: 800; color: var(--ink); }
.pinyin-sm { font-size: 17px; color: var(--blue); margin-left: 10px; }

/* English word + IPA (replaces hanzi/pinyin for the English tool) */
.word { font-size: 52px; font-weight: 800; color: var(--ink); line-height: 1.1; word-break: break-word; }
.ipa { font-size: 24px; color: var(--blue); margin-top: 10px; letter-spacing: 1px; font-family: "Lucida Console", "Courier New", monospace; }
.word-sm { font-size: 30px; font-weight: 800; color: var(--ink); }
.ipa-sm { font-size: 17px; color: var(--blue); margin-left: 10px; font-family: "Lucida Console", "Courier New", monospace; }
.flip-hint { margin-top: auto; color: var(--muted); font-size: 13px; }
.speak-btn {
  margin-top: 18px; border: 1px solid var(--line); background: var(--blue-soft);
  color: var(--blue); border-radius: 999px; padding: 8px 18px; font-size: 14px;
  cursor: pointer; font-weight: 600;
}
.speak-btn:hover { background: var(--blue); color: #fff; }
.speak-btn.small { margin-top: 0; padding: 6px 12px; }

/* Back face content */
.back-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }
.back-word { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; }
.label { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.meaning { font-size: 22px; color: var(--text); font-weight: 700; }
.meaning-block, .scenario-block, .examples-block { margin-bottom: 16px; }
.scenario {
  font-size: 15.5px; line-height: 1.7; color: #2b2b2b;
  background: var(--pink-soft); border-left: 4px solid var(--pink);
  padding: 12px 14px; border-radius: 8px;
}
.examples { margin: 0; padding-left: 22px; }
.examples li { margin-bottom: 14px; }
.ex-zh { font-size: 17px; color: var(--ink); font-weight: 600; }
.ex-py { font-size: 14.5px; color: var(--blue); margin: 2px 0; }
.ex-en { font-size: 15.5px; color: var(--ink); font-weight: 600; line-height: 1.5; }
.ex-cn { font-size: 14px; color: var(--muted); margin-top: 2px; }
.ex-row { display: flex; align-items: flex-start; gap: 8px; }
.ex-play { border: none; background: transparent; cursor: pointer; font-size: 15px; }

/* Controls */
.card-controls { display: flex; gap: 10px; justify-content: center; margin: 4px 0 10px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn.star { color: var(--warn); border-color: #f0d6c0; }
.btn.star.on { background: var(--warn); color: #fff; border-color: var(--warn); }
.counter { font-size: 13px; color: var(--muted); }

/* Progress */
.progress-section { margin-top: 22px; }
.progress-bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--blue), var(--accent)); transition: width 0.3s; }
.progress-text { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }

/* Quiz */
.quiz-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px; text-align: center;
}
.quiz-progress { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.quiz-question { margin-bottom: 22px; }
.quiz-question .hanzi { font-size: 70px; }
.quiz-question .word { font-size: 46px; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quiz-opt {
  border: 1.5px solid var(--line); background: var(--panel); border-radius: 12px;
  padding: 14px; font-size: 15px; cursor: pointer; font-weight: 600; color: var(--ink);
  transition: all 0.15s;
}
.quiz-opt:hover { border-color: var(--blue); }
.quiz-opt.correct { background: #e6f6ee; border-color: var(--good); color: var(--good); }
.quiz-opt.wrong { background: #fdecec; border-color: #e25555; color: #e25555; }
.quiz-opt:disabled { cursor: default; }
.quiz-feedback { margin: 16px 0; font-size: 15px; font-weight: 700; min-height: 22px; }
.quiz-feedback.ok { color: var(--good); }
.quiz-feedback.no { color: #e25555; }
.quiz-controls { margin-top: 8px; }

/* Footer */
.app-footer { text-align: center; padding: 18px; font-size: 12px; color: var(--muted); }
.hidden { display: none !important; }

/* App nav (词卡 / 拼音标注器) — lives inside the sticky header */
.app-nav {
  display: flex; gap: 6px; margin-top: 12px;
}
.app-nav-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 9px 20px; border-radius: 999px; font-size: 14.5px; font-weight: 700;
  cursor: pointer; transition: all 0.16s; white-space: nowrap;
}
.app-nav-btn:hover { border-color: var(--blue); color: var(--blue); }
.app-nav-btn.active { background: var(--pink); color: var(--ink); border-color: var(--pink-dark); }

/* Pinyin Annotator */
.annotate-card { padding: 22px; }
.annotate-title { margin: 0 0 10px; font-size: 18px; color: var(--ink); }
.anno-input {
  width: 100%; min-height: 108px; resize: vertical;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 16px; line-height: 1.7; font-family: inherit; color: var(--text);
  background: #fff;
}
.anno-input::placeholder { font-size: 13px; line-height: 1.5; color: var(--muted); }
.anno-input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.anno-annotate { width: 100%; margin-top: 12px; font-size: 15px; padding: 12px 16px; }

.anno-settings {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px;
  background: #f7fafd; border: 1px solid var(--line); border-radius: 10px;
}
.rate-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.rate-label input { width: 100px; }
/* Speed control → pink accent */
.rate-label#speedLabel { color: var(--pink-dark); }
.rate-label input[type=range] { accent-color: var(--pink); }
.anno-clear { padding: 7px 14px; font-size: 13px; margin-left: auto; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button {
  border: none; background: var(--panel); color: var(--ink);
  padding: 7px 14px; font-size: 13.5px; cursor: pointer; font-weight: 600; font-family: inherit;
}
.seg button.on { background: var(--pink); color: var(--ink); }

.anno-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px;
}

.anno-out {
  margin-top: 16px; padding: 18px; border: 1px dashed var(--line);
  border-radius: 12px; background: #fcfdff; line-height: 2.4;
}
.anno-out.small { line-height: 1.9; }
.anno-para { margin-bottom: 14px; }
ruby.anno-rb {
  cursor: pointer; margin: 0 1px; padding: 2px 1px; border-radius: 6px;
  transition: background 0.12s;
}
ruby.anno-rb:hover { background: var(--blue-soft); }
ruby.anno-rb > .chz { color: var(--ink); font-weight: 700; font-size: 26px; line-height: 1.1; }
ruby.anno-rb > rt {
  color: var(--blue); font-size: 14px; font-weight: 600;
  user-select: none;
}
.anno-out.big ruby.anno-rb > .chz { font-size: 32px; }
.anno-out.big ruby.anno-rb > rt { font-size: 17px; }
.anno-out.small ruby.anno-rb > .chz { font-size: 18px; }
.anno-out.small ruby.anno-rb > rt { font-size: 11px; }
.anno-nh { color: var(--text); }
.annotate-stat {
  margin-top: 12px; font-size: 13.5px; color: var(--muted);
  background: var(--pink-soft); border-left: 4px solid var(--pink);
  padding: 10px 14px; border-radius: 8px;
}
.annotate-stat.warn-note { background: #fff3e6; border-left-color: var(--warn); }
.anno-empty { color: var(--muted); text-align: center; padding: 20px; }

/* Clickable English words in the Reader */
.anno-word {
  cursor: pointer; color: var(--blue); font-weight: 600;
  border-radius: 6px; padding: 2px 2px; transition: background 0.12s;
  font-size: 22px;
}
.anno-word:hover { background: var(--blue-soft); }
.anno-out.big .anno-word { font-size: 30px; }
.anno-out.small .anno-word { font-size: 18px; }

/* IPA shown inside 🔊 speak buttons (front / back / quiz) */
.ipa-in-btn {
  font-family: "Lucida Console", "Courier New", monospace;
  font-size: .74em; opacity: .9; margin-left: 5px; font-weight: 500;
  letter-spacing: .3px;
}
.speak-btn { display: inline-flex; align-items: center; }

/* Inline IPA appended after each clickable word in the Reader */
.anno-ipa {
  font-family: "Lucida Console", "Courier New", monospace;
  font-size: 11px; color: var(--muted); margin: 0 3px; font-weight: 400;
  vertical-align: baseline;
}
/* IPA shown in the Reader status line when a word is clicked */
.anno-ipa-inline {
  font-family: "Lucida Console", "Courier New", monospace;
  font-size: .92em; color: var(--blue); margin: 0 4px; font-weight: 600;
}

/* English translation block */
.anno-trans { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.trans-head { font-weight: 700; color: var(--blue); margin-bottom: 8px; font-size: 15px; }
.trans-note { font-weight: 400; color: var(--muted); font-size: 12px; }
.trans-para { margin: 6px 0; color: var(--ink); font-size: 16px; line-height: 1.6; }
.trans-loading, .trans-err { color: var(--muted); font-size: 14px; }
.trans-err { color: var(--warn); }

/* Bridge button shown when a Chinese search has no HSK match */
.link-btn {
  display: inline-block; margin-top: 10px; padding: 7px 14px;
  background: var(--blue); color: #fff; border: none; border-radius: 8px;
  cursor: pointer; font-size: 13px;
}
.link-btn:hover { opacity: .92; }

/* Region / translation engine selector */
.region-select {
  font-size: 13px; padding: 4px 6px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer;
  margin-left: 4px;
}

@media (max-width: 560px) {
  .app-nav { top: 0; }
  ruby.anno-rb > .chz { font-size: 22px; }
  ruby.anno-rb > rt { font-size: 12px; }
  .anno-settings { gap: 12px; }
  .anno-clear { margin-left: 0; }
}

/* Toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 50;
}
.toast.hidden { display: none; }

@media (max-width: 560px) {
  .hanzi { font-size: 64px; }
  .card { height: 520px; }
  .quiz-options { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { align-self: flex-end; }
}
