:root {
  --bg: #0b0d11;
  --surface: #141821;
  --surface-2: #1b202b;
  --line: #262d3b;
  --text: #e9edf5;
  --muted: #8b95a8;
  --accent: #7db3ff;
  --accent-soft: rgba(125, 179, 255, 0.14);
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 18px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

#app { min-height: 100dvh; }

.serif { font-family: ui-serif, "New York", "Songti SC", Georgia, "Times New Roman", serif; }

/* ---------- 顶部 ---------- */
.topbar {
  padding: calc(env(safe-area-inset-top) + 16px) 20px 8px;
}
.topbar .kicker { font-size: 12px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.topbar h1 { margin: 6px 0 0; font-size: 27px; font-weight: 700; letter-spacing: -0.01em; }
.topbar h1.small { font-size: 22px; }

.page { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 16px 12px;
}

.card.flat { padding: 14px 16px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 今日 ---------- */
.hero {
  margin: 0 16px 12px;
  padding: 20px;
  border-radius: 22px;
  background: linear-gradient(160deg, #1a2233 0%, #141821 60%);
  border: 1px solid #2b3549;
  position: relative;
  overflow: hidden;
}
.hero .big { font-size: 54px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.hero .label { color: var(--muted); font-size: 14px; margin-top: 8px; }

.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 16px 12px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.stat .v { font-size: 22px; font-weight: 650; }
.stat .k { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 550;
  padding: 14px 18px;
  border-radius: 14px;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #071120; font-weight: 650; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 9px 12px; font-size: 14px; border-radius: 11px; width: auto; }
.btn:disabled { opacity: .45; }

.btnrow { display: flex; gap: 10px; margin: 0 16px 12px; }

/* ---------- 表单 ---------- */
input[type="text"], input[type="number"], textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 17px;
  font-family: inherit;
  outline: none;
}
input:focus, textarea:focus { border-color: #3d5a86; }
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
label.field { display: block; font-size: 13px; color: var(--muted); margin: 14px 2px 6px; }

/* ---------- 词条 ---------- */
.headword {
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.phon { color: var(--muted); font-size: 15px; margin-top: 6px; }

.posgroup { margin-top: 14px; }
.poslabel {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px 7px;
  margin-bottom: 8px;
}
.chips { display: flex; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 15px;
  margin: 0 8px 8px 0;
  cursor: pointer;
  line-height: 1.3;
  font-family: inherit;
}
.chip .tick { font-size: 12px; opacity: 0; width: 0; transition: .15s; }
.chip.on { border-color: #4a7fc4; background: var(--accent-soft); }
.chip.on .tick { opacity: 1; width: 12px; color: var(--accent); }

.senses { margin-top: 4px; }
details.domain { margin-top: 6px; }
details.domain > summary { font-size: 13px; color: var(--muted); cursor: pointer; padding: 8px 0; list-style: none; }
details.domain > summary::-webkit-details-marker { display: none; }
details.domain > summary::before { content: '▸ '; }
details.domain[open] > summary::before { content: '▾ '; }
.sense { padding: 10px 0; border-bottom: 1px dashed rgba(255,255,255,.07); font-size: 16px; line-height: 1.55; }
.sense:last-child { border-bottom: none; }
.sense .p { color: var(--accent); font-size: 13px; margin-right: 6px; }

/* ---------- 列表 ---------- */
.list { margin: 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.listitem { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.listitem:last-child { border-bottom: none; }
.listitem:active { background: var(--surface-2); }
.listitem .w { font-size: 17px; font-weight: 550; }
.listitem .w.smallw { font-size: 15px; font-weight: 400; line-height: 1.5; font-family: ui-serif, "New York", Georgia, serif; }
.listitem.dim { opacity: 0.45; }
.listitem .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; }
.badge.done { color: var(--good); border-color: rgba(74,222,128,.35); }
.badge.star { color: var(--good); border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.1); }

.empty { text-align: center; color: var(--muted); padding: 40px 24px; font-size: 14px; line-height: 1.7; }

/* ---------- 复习 ---------- */
.review {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.review .bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.progress { flex: 1; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s; }

.stage { flex: 1; overflow-y: auto; padding: 20px 22px 12px; display: flex; flex-direction: column; justify-content: center; }
.stage .cardword { font-size: 44px; line-height: 1.1; }
.stage .answer { margin-top: 26px; }
.stage .hint { color: var(--muted); font-size: 14px; text-align: center; margin-top: 40px; }

.example { margin-top: 18px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-size: 15px; line-height: 1.6; }
.example .src { font-size: 11px; color: var(--muted); margin-top: 8px; }
.example .ex-en { font-family: ui-serif, "New York", Georgia, serif; font-size: 16px; }
.example .ex-zh { color: var(--muted); font-size: 14px; margin-top: 6px; }

.rate { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 12px 16px 16px; }
.rate button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 13px;
  padding: 13px 0 11px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.rate button small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.rate button.r20 { border-color: rgba(248,113,113,.4); color: #f7a1a1; }
.rate button.r40 { border-color: rgba(251,191,36,.35); color: #f6cf7a; }
.rate button.r60 { border-color: rgba(125,179,255,.35); color: #a9caff; }
.rate button.r80 { border-color: rgba(74,222,128,.35); color: #94e6b0; }
.rate button.r100 { border-color: rgba(74,222,128,.6); color: #b6f2c9; }
.rate button:active { transform: scale(.96); }

/* ---------- 标签栏 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: rgba(14, 17, 23, .92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  z-index: 40;
}
.tabbar a {
  flex: 1;
  text-align: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  padding: 6px 0 4px;
}
.tabbar a.on { color: var(--accent); }
.tabbar .ic { display: block; line-height: 0; margin-bottom: 4px; }
.tabbar svg { width: 21px; height: 21px; }

/* ---------- 其它 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #2a3244;
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 90;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  max-width: 80vw;
  text-align: center;
}

.hist { margin-top: 10px; }
.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.hist-row:last-child { border-bottom: none; }

.divider { height: 1px; background: var(--line); margin: 14px 0; }

.fab-space { height: 8px; }

.speak {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--accent);
  border-radius: 10px;
  width: 38px; height: 38px;
  font-size: 17px;
  cursor: pointer;
}

.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }

/* ---------- 分段控件 ---------- */
.seg {
  display: flex;
  gap: 4px;
  margin: 4px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 4px;
}
.seg-item {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-family: inherit;
  padding: 9px 0;
  border-radius: 10px;
  cursor: pointer;
}
.seg-item.on { background: var(--surface-2); color: var(--text); font-weight: 600; }

/* ---------- 类型标签 ---------- */
.kindtag {
  display: inline-block;
  font-size: 10px;
  line-height: 1.6;
  padding: 0 6px;
  border-radius: 5px;
  margin-left: 6px;
  vertical-align: 2px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 400;
}
.kindtag.word { color: #9fc3ff; border-color: rgba(125,179,255,.35); }
.kindtag.phrase { color: #ffd08a; border-color: rgba(251,191,36,.35); }
.kindtag.sentence { color: #a3e6c8; border-color: rgba(74,222,128,.32); }

/* ---------- 提示条 ---------- */
.banner {
  margin: 0 16px 12px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--accent-soft);
  border: 1px solid rgba(125,179,255,.3);
  color: #cfe4ff;
  font-size: 14px;
}

.herostats { display: flex; gap: 14px; margin-top: 12px; font-size: 13px; color: var(--muted); }

/* ---------- 7 日柱状 ---------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 92px; margin-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-num { font-size: 10px; color: var(--muted); height: 14px; font-variant-numeric: tabular-nums; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; background: rgba(255,255,255,.03); border-radius: 6px; overflow: hidden; }
.bar-track > i { display: block; width: 100%; background: var(--accent); opacity: .55; border-radius: 6px; min-height: 2px; }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.bars.scroll .bar-label { font-size: 9px; }

.kicker-line { padding: 6px 20px 8px; }

/* ---------- 统计 ---------- */
.cardlink { cursor: pointer; }
.cardlink:active { background: var(--surface-2); }

.heat {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  margin-top: 12px;
}
.heat i {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.055);
}
.heat i.future { opacity: 0.25; }
.heat i.l1 { background: rgba(125, 179, 255, 0.28); }
.heat i.l2 { background: rgba(125, 179, 255, 0.5); }
.heat i.l3 { background: rgba(125, 179, 255, 0.72); }
.heat i.l4 { background: rgba(125, 179, 255, 0.95); }

.heatlegend { display: flex; align-items: center; gap: 4px; margin-top: 12px; }
.heatlegend i {
  width: 11px; height: 11px; border-radius: 3px; display: inline-block;
  background: rgba(255, 255, 255, 0.055);
}
.heatlegend i.l1 { background: rgba(125, 179, 255, 0.28); }
.heatlegend i.l2 { background: rgba(125, 179, 255, 0.5); }
.heatlegend i.l3 { background: rgba(125, 179, 255, 0.72); }
.heatlegend i.l4 { background: rgba(125, 179, 255, 0.95); }
.heatlegend span { margin: 0 4px; }

.bars.scroll { overflow-x: auto; padding-bottom: 4px; }

/* ---------- 句子 / 词组 ---------- */
.sentence-en { font-family: ui-serif, "New York", Georgia, serif; font-size: 19px; line-height: 1.55; }
.sentence-zh { font-size: 16px; line-height: 1.65; margin-top: 4px; }
.sentence-front {
  font-size: 25px;
  line-height: 1.5;
  letter-spacing: 0;
}
.headword.phrase { font-size: 34px; }

.kv { margin-top: 10px; font-size: 14px; color: var(--muted); line-height: 1.6; }
.phraselist { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.phraseitem { font-size: 15px; line-height: 1.5; }
.phraseitem b { color: var(--accent); font-weight: 550; }
.grammar { margin: 8px 0 0; padding-left: 18px; font-size: 15px; line-height: 1.7; color: var(--text); }
.grammar li { margin-bottom: 4px; }
