/* ==========================================================
   TechLex — 技术英语听打训练 / typing trainer for tech English
   亮色主题 / light theme
   ========================================================== */

:root {
  --bg:        #f7f8fb;
  --bg-tint:   #eef3fb;
  --surface:   #ffffff;
  --surface-2: #f2f4f9;
  --line:      #e3e7ef;
  --line-2:    #ccd3e0;
  --text:      #1a1d26;
  --muted:     #5c6474;
  --dim:       #6b7280;
  --pending:   #8a91a0;                 /* 尚未打到的字母 / letters not typed yet */
  --ok:        #15803d;
  --ok-soft:   rgba(21, 128, 61, .10);
  --err:       #e11d48;
  --err-soft:  rgba(225, 29, 72, .09);
  --accent:    #0b7d99;
  --accent-2:  #6d4aff;
  --shadow:    0 1px 2px rgba(20, 28, 48, .05), 0 10px 30px rgba(20, 28, 48, .06);

  --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

.sr-only {                     /* 只给读屏软件和搜索引擎 / for screen readers and crawlers */
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

body {
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1200px 620px at 50% -10%, var(--bg-tint) 0%, transparent 62%),
    var(--bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------- 顶栏 topbar ---------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding: 15px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, .78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
}

.brand { display: flex; align-items: baseline; gap: 12px; }
.logo {
  font-family: var(--mono); font-size: 19px; font-weight: 600;
  letter-spacing: -.4px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { font-size: 12px; color: var(--dim); letter-spacing: .5px; }

.controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

/* 口音切换 accent switch */
.seg {
  display: flex; padding: 3px; gap: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.seg-btn {
  font: inherit; font-size: 13px; color: var(--muted);
  padding: 6px 13px; border: 0; border-radius: 7px;
  background: transparent; cursor: pointer; transition: .18s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-on {
  background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 28, 48, .09);
}

.rate { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.rate input { width: 84px; accent-color: var(--accent); }

.switch { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.mode-btn {
  font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer;
  padding: 7px 14px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--line); transition: .18s;
}
.mode-btn:hover { border-color: var(--line-2); color: var(--text); }
.mode-btn.is-on {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(11, 125, 153, .25);
}

/* ---------------------------- 大类 tracks ---------------------------- */
.trackbar { display: flex; justify-content: center; padding: 20px clamp(16px, 4vw, 40px) 0; }
.track-btn {
  font: inherit; cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); transition: .18s; box-shadow: var(--shadow);
}
.track-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.track-btn .tb-label { font-size: 11px; color: var(--dim); letter-spacing: .5px; }
.track-btn .tb-zh { font-size: 15px; font-weight: 600; }
.track-btn .tb-n {
  font-family: var(--mono); font-size: 10.5px;
  padding: 1px 8px; border-radius: 20px;
  background: var(--surface-2); color: var(--muted);
}
.track-btn .tb-caret { font-size: 10px; color: var(--dim); }

/* 大类选择面板 / the track picker panel */
.sheet-wide { max-width: 780px; }
.group-title {
  font-size: 12px; font-weight: 600; color: var(--accent);
  letter-spacing: .8px; margin: 22px 0 10px;
}
.group-title span { color: var(--dim); font-weight: 400; letter-spacing: .3px; margin-left: 6px; }
.track-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 9px; }
.track-card {
  font: inherit; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 2px;
  padding: 11px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); transition: .16s;
}
.track-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.track-card .tc-zh { font-size: 14px; font-weight: 600; color: var(--text); }
.track-card .tc-en { font-size: 10.5px; color: var(--dim); }
.track-card .tc-n { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.track-card.is-on { background: var(--accent); border-color: var(--accent); }
.track-card.is-on .tc-zh { color: #fff; }
.track-card.is-on .tc-en, .track-card.is-on .tc-n { color: rgba(255, 255, 255, .8); }

/* -------------------------- 小类 categories -------------------------- */
.cats {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  padding: 14px clamp(16px, 4vw, 40px) 4px;
}
.cat-chip {
  font: inherit; font-size: 12.5px; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); transition: .18s;
}
.cat-chip:hover { border-color: var(--line-2); color: var(--text); }
.cat-chip.is-on {
  color: #fff; background: var(--accent); border-color: var(--accent);
  font-weight: 600; box-shadow: 0 2px 8px rgba(11, 125, 153, .25);
}

/* ----------------------------- 主舞台 stage ----------------------------- */
.stage {
  flex: 1; width: 100%; max-width: 820px; margin: 0 auto;
  padding: 20px clamp(16px, 4vw, 40px) 40px;
  display: flex; flex-direction: column; gap: 18px;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 26px clamp(18px, 4vw, 34px);
  box-shadow: var(--shadow);
}

.word-card { text-align: center; position: relative; overflow: hidden; transition: border-color .25s; }
.word-card::after {           /* 正确时的绿色柔光 / success glow */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 45%, var(--ok-soft), transparent 68%);
  opacity: 0; transition: opacity .25s;
}
.word-card.is-solved { border-color: rgba(21, 128, 61, .40); }
.word-card.is-solved::after { opacity: 1; }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--dim); margin-bottom: 20px;
}
.pill {
  padding: 4px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.counter { font-family: var(--mono); letter-spacing: .5px; }

.word-row { display: flex; align-items: center; justify-content: center; gap: 14px; }

.speak-btn {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  color: var(--accent); background: var(--surface-2);
  border: 1px solid var(--line); transition: .18s;
}
.speak-btn:hover {
  background: #e6f6fa; border-color: rgba(11, 125, 153, .45); transform: scale(1.05);
}
.speak-btn.is-speaking { animation: pulse 1s ease-out infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(11, 125, 153, .32); }
  100% { box-shadow: 0 0 0 14px rgba(11, 125, 153, 0); }
}

/* 单词逐字母 / the word, letter by letter */
.word {
  font-family: var(--mono);
  font-size: clamp(38px, 9vw, 76px);
  font-weight: 500; letter-spacing: .01em;
  display: flex; flex-wrap: wrap; justify-content: center;
  min-height: 1.25em;
}
.word.shake { animation: shake .22s; }
@keyframes shake {
  25% { transform: translateX(-5px); } 75% { transform: translateX(5px); }
}

.ch { position: relative; transition: color .09s; color: var(--pending); }
.ch.done  { color: var(--ok); }                       /* 打对 correct */
.ch.wrong { color: var(--err); background: var(--err-soft); border-radius: 4px; }  /* 打错 wrong */
.ch.wrong::after {                                    /* 错误下划线 / error underline */
  content: ""; position: absolute; left: 6%; right: 6%; bottom: .08em;
  height: 2px; background: var(--err); border-radius: 2px;
}
.ch.cur::before {                                     /* 光标 caret */
  content: ""; position: absolute; left: -3px; top: .1em; bottom: .1em;
  width: 2px; background: var(--accent); animation: blink 1.05s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.ch.space { width: .45em; }                            /* 词组里的空格要看得见 / visible space in a phrase */
.ch.space::after {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: .12em;
  height: 2px; background: var(--line-2); border-radius: 2px;
}
.ch.space.done::after { background: var(--ok); }
.ch.masked { color: transparent; }
.ch.masked::after {                                   /* 听写模式的下划线 / dictation blank */
  content: ""; position: absolute; left: 8%; right: 8%; bottom: .12em;
  height: 2px; background: var(--line-2); border-radius: 2px;
}

.meanings { margin-top: 22px; }
.meaning-zh {                                   /* 中文词意：仅次于单词的第二大 / the second largest thing */
  font-size: clamp(19px, 4.2vw, 29px);
  line-height: 1.5; font-weight: 500; color: var(--text);
  letter-spacing: .01em;
}
.meaning-en {
  margin-top: 9px; font-size: clamp(15px, 2.6vw, 18px);
  line-height: 1.6; color: var(--muted);
}

.phonetics {
  margin-top: 16px; display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap; font-size: 15px; color: var(--muted);
}
.ipa { font-family: var(--mono); }
.badges { display: inline-flex; gap: 6px; }
.badge {
  font-size: 10.5px; font-weight: 600; letter-spacing: .3px;
  padding: 2px 8px; border-radius: 20px; border: 1px solid transparent;
}
.badge-story { color: var(--accent); background: rgba(11, 125, 153, .10); border-color: rgba(11, 125, 153, .25); }
.badge-tag   { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.pos { font-size: 12px; color: var(--dim); font-style: italic; }

#typer {                       /* 输入框不可见，但接收全部键盘输入 */
  position: absolute; opacity: 0; width: 1px; height: 1px;
  border: 0; padding: 0; left: 50%; bottom: 0;
}

.typing-hint {
  margin-top: 18px; font-size: 12px; color: var(--dim);
  transition: color .2s;
}
.typing-hint[hidden] { display: none; }
.typing-hint.ok  { color: var(--ok); }
.typing-hint.err { color: var(--err); }

/* --------------------------- 释义卡 detail --------------------------- */
.detail-card { display: flex; flex-direction: column; gap: 20px; }
.block h3 {
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  letter-spacing: .8px; margin-bottom: 9px;
}
.block h3 span { color: var(--dim); font-weight: 400; letter-spacing: .3px; margin-left: 6px; }
.block p { font-size: 16px; line-height: 1.78; }
.block p.en { color: var(--text); }
.block p.zh { color: var(--muted); margin-top: 3px; }
.block p.ex2 { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.block p[hidden] { display: none; }
.block p.en:empty, .block p.zh:empty { display: none; }

/* ----------------------------- 底栏 stats ----------------------------- */
.statbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 13px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, .78);
  border-top: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.stats { display: flex; gap: 20px; flex-wrap: wrap; }
.stats b { font-family: var(--mono); font-size: 14px; color: var(--text); margin-right: 4px; }
.keys kbd {
  font-family: var(--mono); font-size: 10.5px; padding: 2px 6px; border-radius: 5px;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--muted);
  box-shadow: 0 1px 0 var(--line-2);
}

/* --------------------------- 错题面板 sheet --------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 28, 48, .32); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade .16s;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }

.sheet {
  width: 100%; max-width: 640px; max-height: 84vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 24px clamp(18px, 4vw, 28px);
  box-shadow: 0 24px 60px rgba(20, 28, 48, .18);
  animation: rise .2s;
}
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 19px; font-weight: 600; }
.sheet-head h2 span { font-size: 13px; font-weight: 400; color: var(--dim); margin-left: 7px; }
.icon-btn {
  font: inherit; font-size: 15px; color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; border: 1px solid var(--line);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.sheet-note { margin-top: 12px; font-size: 12.5px; line-height: 1.7; color: var(--muted); }
.sheet-note span { color: var(--dim); }

.sheet-actions { display: flex; gap: 10px; margin: 16px 0 6px; flex-wrap: wrap; }
.sheet-actions button {
  font: inherit; font-size: 13px; padding: 8px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); transition: .18s;
}
.sheet-actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.sheet-actions .primary:hover { filter: brightness(1.08); }
.sheet-actions .primary:disabled { background: var(--surface-2); border-color: var(--line); color: var(--dim); cursor: default; filter: none; }
.sheet-actions .ghost { background: var(--surface); color: var(--muted); }
.sheet-actions .ghost:hover { border-color: var(--line-2); color: var(--text); }

.mlist { list-style: none; }
.mitem {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 2px; border-bottom: 1px solid var(--line);
}
.mitem:last-child { border-bottom: 0; }
.mitem .mw { font-family: var(--mono); font-size: 18px; font-weight: 500; }
.mitem .mm { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.mitem .mn {
  font-family: var(--mono); font-size: 11px; flex: none;
  padding: 2px 8px; border-radius: 20px; color: var(--err); background: var(--err-soft);
}
.mitem .icon-btn { flex: none; }
.sheet-empty { margin-top: 18px; font-size: 13.5px; line-height: 1.8; color: var(--muted); text-align: center; padding: 20px 0; }
.sheet-empty span { color: var(--dim); }

/* 这一题是回来复习的 / this word came back for review */
.pill.review { background: var(--err-soft); border-color: rgba(225, 29, 72, .3); color: var(--err); font-weight: 600; }

@media (max-width: 600px) {
  .topbar { justify-content: center; }
  .rate { display: none; }
  .mode-btn { font-size: 12px; padding: 6px 11px; }
  .track-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .keys { display: none; }
  .statbar { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ========================= 关于页 about page ========================= */

a.logo { text-decoration: none; }

.nav-link {
  font-size: 12.5px; color: var(--muted); text-decoration: none;
  padding: 5px 11px; border-radius: 8px; border: 1px solid transparent; transition: .18s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); border-color: var(--line); }
.nav-link.back { border-color: var(--line); background: var(--surface); }

.page {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 34px clamp(16px, 4vw, 40px) 72px;
  font-size: 15.5px; line-height: 1.85; color: var(--muted);
}
.page h1 { font-size: clamp(24px, 5vw, 32px); font-weight: 600; color: var(--text); margin-bottom: 18px; }
.page h2 { font-size: 19px; font-weight: 600; color: var(--text); margin: 40px 0 12px; }
.page h1 span, .page h2 span { font-size: 13px; font-weight: 400; color: var(--dim); margin-left: 8px; }
.page p { margin-bottom: 12px; }
.page p.en, .page .en { color: var(--dim); font-size: 14px; }
.page strong { color: var(--text); font-weight: 600; }
.page em { font-family: var(--mono); font-style: normal; color: var(--accent); }
.page kbd {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 5px;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--muted);
}

.steps { list-style: none; counter-reset: step; margin: 16px 0; }
.steps li {
  counter-increment: step; position: relative; padding: 10px 0 10px 42px; font-size: 15px;
}
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 12px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: #fff; background: var(--accent);
}
.steps b { color: var(--text); font-weight: 600; }

.about-cats { list-style: none; margin: 16px 0; display: flex; flex-direction: column; gap: 9px; }
.about-cats li {
  font-size: 13.5px; padding: 12px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--dim);
}
.about-cats b { display: block; color: var(--text); font-weight: 600; font-size: 14px; margin-bottom: 4px; }

.page dt { color: var(--text); font-weight: 600; font-size: 15px; margin-top: 20px; }
.page dd { margin-top: 5px; }

/* 赞赏 / tip */
.donate-note { font-size: 14.5px; }
.donate {
  margin: 20px 0 8px; display: inline-flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 20px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.donate img { width: 240px; height: auto; display: block; border-radius: 10px; }
.donate figcaption { font-size: 12.5px; color: var(--dim); }

.about-foot { margin-top: 42px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--dim); }
.about-foot a { color: var(--accent); text-decoration: none; }
.about-foot a:hover { text-decoration: underline; }

/* 关于页的词库总表 / the track table on the about page */
.about-cats .about-group {
  background: none; border: 0; padding: 16px 0 2px; color: var(--accent);
  font-size: 12px; letter-spacing: .8px;
}
.about-cats .eg { display: block; margin-top: 4px; font-family: var(--mono); font-size: 11.5px; color: var(--dim); }

/* 关于页的开场白与数据条 / lede and stat row on the about page */
.page .lede { font-size: 17.5px; line-height: 1.8; color: var(--text); margin-bottom: 10px; }
.statgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin: 18px 0 20px;
}
.statgrid > div {
  padding: 14px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
}
.statgrid b { display: block; font-family: var(--mono); font-size: 26px; color: var(--accent); line-height: 1.2; }
.statgrid span { font-size: 11.5px; color: var(--dim); }

/* 盲写过程中：只显示你打的字母，不透露对错 / blind input, no verdict yet */
.ch.typed { color: var(--text); }

/* 发音来源说明 / the note about where the voice comes from */
.voices-note { font-size: 14.5px; }
.voices-note .en { display: block; margin-top: 6px; color: var(--dim); font-size: 13px; }
.voices-empty { font-size: 13px; color: var(--dim); }
