:root {
  --bg: #0b0b0c;
  --panel: #141416;
  --panel2: #1b1b1e;
  --line: #2a2a2f;
  --text: #ecebe8;
  --muted: #9a9894;
  --ti: #c9c3b6;       /* 哑光钛金 */
  --ti-d: #8f897d;
  --ok: #6fcf97;
  --bad: #ef7a7a;
  --warn: #e6c26e;
  --lv1: #6fcf97;
  --lv2: #7fb2e5;
  --lv3: #c49be8;
  --r: 14px;
  --nav-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
h1 { font-size: 24px; margin: 8px 0 4px; letter-spacing: .5px; }
h2 { font-size: 18px; margin: 24px 0 8px; color: var(--ti); }
h3 { font-size: 16px; margin: 0 0 8px; }
a { color: var(--ti); }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 11, 12, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; letter-spacing: 1px; color: var(--ti); }
.logo {
  display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 6px;
  border-radius: 8px; background: linear-gradient(145deg, #2b2a27, #141416); border: 1px solid #3a3833;
  font-size: 13px; color: var(--ti);
}
#syncDot { width: 10px; height: 10px; border-radius: 50%; background: #444; }
#syncDot.ok { background: var(--ok); }
#syncDot.busy { background: var(--warn); animation: pulse 1s infinite; }
#syncDot.err { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }

main { max-width: 820px; margin: 0 auto; padding: 8px 16px 32px; }
.intro { color: var(--muted); margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.okc { color: var(--ok); }
.badc { color: var(--bad); }
.warn { color: var(--warn); }

button, .btnlike {
  font: inherit; color: var(--text); cursor: pointer;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel2);
  padding: 9px 14px; min-height: 40px; -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .5; }
button.primary { background: var(--ti); color: #111; border-color: var(--ti); font-weight: 600; }
button.primary.big { width: 100%; padding: 14px; font-size: 18px; margin: 8px 0 16px; }
button.ghost, .btnlike.ghost { background: transparent; }
button.sm { padding: 4px 10px; min-height: 32px; font-size: 14px; }
button.icon { background: transparent; border: none; padding: 4px 6px; min-height: 32px; font-size: 18px; }
button.term {
  background: none; border: none; padding: 0; min-height: 0; color: var(--ti);
  border-bottom: 1px dashed var(--ti-d); border-radius: 0; font-size: inherit; line-height: inherit;
}
input[type=text], input[type=search], input[type=password], textarea, select {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; width: 100%; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--ti-d); }
select { width: auto; }
textarea { font-size: 18px; resize: vertical; min-height: 90px; }
form.row input { flex: 1; width: auto; }
.row.gap input[type=text], .row.gap input[type=password] { flex: 1; width: auto; min-width: 160px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; }
.card.good { border-color: #2f4d3b; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid #1f1f23; }
.kv:last-of-type { border-bottom: none; }
.kv > span:first-child { flex-shrink: 0; }
.kv > span:last-child:not(:first-child) { text-align: right; color: var(--muted); font-size: 14px; }

.seg { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0 12px; scrollbar-width: none; }
.seg button { white-space: nowrap; flex: 0 0 auto; }
.seg button.on { background: var(--ti); color: #111; border-color: var(--ti); }
.seg.small button { padding: 6px 12px; min-height: 34px; font-size: 14px; }

/* 逐词对照卡片 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  display: inline-flex; flex-direction: column; align-items: center; position: relative;
  padding: 6px 10px; min-height: 0; border-radius: 10px; background: var(--panel); line-height: 1.3;
}
.chip .cz { font-size: 17px; }
.chip .ce { font-size: 13px; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.key { border-color: #3b3a35; background: var(--panel2); }
.chip.key .ce { color: var(--ti); font-weight: 600; }
.chip.none .ce { opacity: .4; }
.chip.punct { border: none; background: none; padding: 6px 2px; color: var(--muted); }
.chip .lv { position: absolute; top: -6px; right: -6px; }
.lv { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font-size: 10px; color: #111; font-weight: 700; vertical-align: middle; }
.lv1 { background: var(--lv1); } .lv2 { background: var(--lv2); } .lv3 { background: var(--lv3); }

.sent .en.big { font-size: 22px; line-height: 1.5; margin-bottom: 6px; }
.wlink { background: none; border: none; padding: 0; min-height: 0; font: inherit; color: inherit; border-bottom: 1px solid #3a3833; border-radius: 0; }
.wlink:hover { color: var(--ti); }

/* 跟打 */
.typer { margin-top: 10px; }
.tg {
  font: 22px/1.7 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 1px;
  word-break: break-word; margin-bottom: 8px; text-align: left;
}
.tg span.todo { color: #5d5c58; }
.tg span.ok { color: var(--ok); }
.tg span.cur { color: var(--text); border-bottom: 2px solid var(--ti); }
.tg span.bad { color: #111; background: var(--bad); border-radius: 3px; }
.tin { font: 20px ui-monospace, "SF Mono", Menlo, monospace !important; }
.trow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.tstat { color: var(--muted); font-size: 13px; margin-left: auto; }
.done .tin { border-color: var(--ok); }

.note { border-bottom: 1px solid var(--line); padding: 10px 0; }
.note .nz { font-size: 17px; }
.note .ne { color: var(--ti); }
.note.done .nz::after { content: " ✓"; color: var(--ok); }
.tbox:empty { display: none; }

/* 入门 */
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 12px 0; }
.letter { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 10px 12px; }
.lbig { font-size: 28px; font-weight: 600; color: var(--ti); }
.lph { font-size: 12px; color: var(--muted); }
.lw { font-size: 14px; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.grp { display: flex; flex-direction: column; align-items: flex-start; text-align: left; }
.grp span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.grp.done { border-color: #2f4d3b; }
.grp.done b::after { content: " ✓"; color: var(--ok); }
.wlist, #blist { margin: 8px 0; }
.wrow { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.wmain {
  flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; text-align: left;
  background: none; border: none; padding: 10px 0; min-height: 0;
}
.wmain .cn { color: var(--muted); font-size: 14px; }
.wmain .ctx { flex-basis: 100%; }
.ph { color: var(--muted); font-family: "Lucida Sans Unicode", "Arial Unicode MS", sans-serif; }
.wbig { font-size: 40px; font-weight: 600; letter-spacing: 1px; margin: 6px 0; color: var(--text); }
.cn { color: var(--text); }
.cn.big { font-size: 22px; margin: 8px 0; }
.ctx { color: var(--muted); font-size: 14px; margin: 8px 0; padding: 8px 10px; background: var(--panel2); border-radius: 10px; text-align: left; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 2px 0 4px; flex: 0 0 auto; }
.st-new { background: #777; } .st-learn { background: var(--warn); } .st-master { background: var(--ok); }

.progress { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress div { height: 100%; background: var(--ti); transition: width .3s; }

/* 复习 */
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 26px; color: var(--ti); }
.stat span { font-size: 13px; color: var(--muted); }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.grades .g0 { border-color: #5a2c2c; } .grades .g1 { border-color: #5a4b2c; }
.grades .g2 { border-color: #2c4a3a; } .grades .g3 { border-color: #2c3f5a; }
.gmsg { margin: 12px 0 8px; font-weight: 600; }
.gmsg.g0 { color: var(--bad); } .gmsg.g1 { color: var(--warn); } .gmsg.g2, .gmsg.g3 { color: var(--ok); }
#rc .typer { max-width: 460px; margin: 10px auto; }
#rc .tg { text-align: center; }

/* 我的 */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.bar { flex: 1; background: #3a3833; border-radius: 2px 2px 0 0; min-height: 3px; }
.bar.today { background: var(--ti); }
.steps { padding-left: 20px; } .steps li { margin: 6px 0; }
.qr { background: #fff; padding: 12px; border-radius: 12px; width: min(280px, 80vw); margin: 10px auto; }
.qr svg { width: 100%; height: auto; display: block; }
details summary { cursor: pointer; color: var(--ti); margin: 8px 0; }
.honest { margin: 24px 0 8px; padding: 12px 16px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); font-size: 14px; }
.honest li { margin: 6px 0; }
.credits { margin-top: 16px; }

/* 弹出层 */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .15s; }
.sheet-wrap.show { opacity: 1; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 85vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}
.sheet-x { position: absolute; top: 8px; right: 8px; background: none; border: none; font-size: 26px; min-height: 0; color: var(--muted); }
.sheet .where { color: var(--ti); font-size: 14px; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #26252a; border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 40; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 导航：手机在底部 */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: rgba(14, 14, 16, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav button {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0;
  background: none; border: none; border-radius: 0; height: var(--nav-h); padding: 6px 0; color: var(--muted);
}
#nav button.on { color: var(--ti); }
#nav .ni { font-size: 20px; line-height: 1.2; filter: grayscale(.6); }
#nav button.on .ni { filter: none; }
#nav .nl { font-size: 12px; }
.badge { position: absolute; top: 4px; left: 54%; background: var(--bad); color: #fff; font-size: 11px; border-radius: 9px; padding: 0 6px; line-height: 18px; }

/* 电脑：导航放左边 */
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 120px; }
  #nav { top: 0; bottom: 0; right: auto; width: 120px; flex-direction: column; justify-content: flex-start; padding-top: 70px; border-top: none; border-right: 1px solid var(--line); }
  #nav button { flex: 0 0 auto; height: 70px; }
  .top { padding-left: 24px; }
  #toast { bottom: 32px; }
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 18px; }
  main { padding-top: 16px; }
}
