/* ===========================================================
   组件：底栏、按钮、搜索框、卡片内容、图表、Toast
   v2：大圆角、字号上调
   =========================================================== */

/* 底栏：浮动胶囊 */
.tabbar {
  position: fixed;
  left: var(--tab-side);
  right: var(--tab-side);
  bottom: calc(var(--safe-b) + var(--tab-inset));
  height: var(--tab-h);
  padding: 4px;
  display: flex;
  background: rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: saturate(200%) blur(28px);
  backdrop-filter: saturate(200%) blur(28px);
  border: 0.5px solid rgba(0, 0, 0, 0.04);
  border-radius: var(--r-pill);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 3px 10px rgba(16, 24, 40, 0.04);
  z-index: 50;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin: 0 1px;
  border-radius: var(--r-pill);
  font-size: 11px;
  line-height: 13px;
  color: var(--text-2);
  transition: color var(--dur-fast) ease, background-color 0.18s ease;
}

.tab-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.tab[aria-selected="true"] {
  color: var(--text);
  background: rgba(120, 120, 128, 0.16);
}

.tab svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab[aria-selected="true"] { color: var(--text); }

/* 按钮 */
.btn {
  height: 48px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-btn);
  font-size: var(--fs-sub);
  font-weight: 600;
  background: var(--bg-group);
  color: var(--text);
  transition: transform var(--dur-fast) var(--ease-standard),
    opacity var(--dur-fast) ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--text); color: #fff; }

.btn-block {
  display: block;
  width: 100%;
  height: 54px;
  font-size: var(--fs-body);
  margin-top: var(--sp-4);
}

.icon-btn {
  width: 44px;
  height: 44px;
  margin-right: -10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 28px;
  font-weight: 300;
}

/* 搜索框 */
.searchbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 48px;
  padding: 0 var(--sp-4);
  background: var(--bg-group);
  border-radius: var(--r-input);
  color: var(--text-2);
}

.searchbar svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.searchbar input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-body);
  color: var(--text);
}

.searchbar input::placeholder { color: var(--text-3); }

.hint { margin: var(--sp-2) 2px 0; }

/* 标签 */
.chips {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding: 2px 0 var(--sp-1);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  background: var(--bg-group);
  color: var(--text);
  font-size: var(--fs-sub);
}

/* 卡片内元素 */
.today-card { margin-top: var(--sp-5); }
.big-num { font-size: 32px; line-height: 36px; font-weight: 700; margin-top: 2px; }
.ring { color: var(--accent); display: block; flex: 0 0 auto; }

.book-card .book-name {
  font-size: var(--fs-body);
  font-weight: 600;
  margin-bottom: 2px;
}

/* 统计四宫格 */
.grid4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}

.stat-card {
  background: var(--card);
  border: 1px solid rgba(0, 0, 0, 0.03);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: var(--sp-5);
}

.stat-value {
  font-size: 32px;
  line-height: 36px;
  font-weight: 700;
  margin-top: 6px;
}

/* 柱状图 */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 132px;
  padding-top: var(--sp-2);
}

.bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.bar span {
  display: block;
  width: 100%;
  max-width: 26px;
  border-radius: 10px 10px 4px 4px;
  background: var(--text);
}

.bar.is-empty span { background: var(--bg-group); }

.bar em {
  font-style: normal;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-2);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-b) + var(--sp-4));
  transform: translate(-50%, 12px);
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  font-size: 15px;
  line-height: 21px;
  padding: 12px 18px;
  border-radius: var(--r-input);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: 80vw;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 减弱动效 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============ 查词输入页（沉浸式） ============ */
.is-immersive .tabbar { display: none; }

.is-immersive .view {
  padding-bottom: calc(var(--safe-b) + 96px);
}

.lookup-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-bottom: var(--sp-4);
}

.lookup-title {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text);
}

.lookup-spacer { width: 44px; height: 44px; }

.lookup-bar .icon-btn { margin-right: 0; color: var(--text); }

.icon-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.searchbar-btn {
  width: 100%;
  text-align: left;
}

.searchbar-ph {
  color: var(--text-3);
  font-size: var(--fs-body);
}

.input-card {
  display: flex;
  align-items: flex-start;
  padding: 18px var(--sp-5);
  background: var(--card);
  border-radius: var(--r-input);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--dur-fast) ease;
}

.input-card:focus-within {
  box-shadow: 0 0 0 1.5px rgba(60, 60, 67, 0.16), var(--shadow-card);
}

.input-card textarea {
  flex: 1;
  width: 100%;
  min-height: 64px;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
}

.input-card textarea::placeholder { color: var(--text-3); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--sp-6) 0 var(--sp-1);
}

.section-head .group-label { margin: 0; }

.icon-btn.ghost { color: var(--text-2); font-size: 0; }
.icon-btn.ghost svg { width: 20px; height: 20px; }

.history-list { display: flex; flex-direction: column; }

.history-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 56px;
  text-align: left;
  border-bottom: 0.5px solid var(--line);
}

.history-row:last-child { border-bottom: 0; }

.history-tag {
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 18px;
  color: var(--text-2);
  background: var(--bg-group);
  border-radius: 8px;
  padding: 2px 8px;
}

.history-text {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-go {
  position: fixed;
  right: var(--page-pad);
  bottom: calc(var(--safe-b) + 20px);
  height: 48px;
  padding: 0 24px;
  border-radius: var(--r-pill);
  background: var(--text);
  color: #fff;
  font-size: var(--fs-sub);
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 60;
}

.search-go.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ============ 首页底部搜索条 ============ */
.view.has-dock {
  padding-bottom: calc(var(--tab-h) + var(--tab-inset) + var(--safe-b) + 78px);
}

.search-dock {
  position: fixed;
  left: var(--tab-side);
  right: var(--tab-side);
  bottom: calc(var(--safe-b) + var(--tab-inset) + var(--tab-h) + 10px);
  height: 52px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-5);
  background: var(--bg-group);
  border-radius: var(--r-pill);
  color: var(--text-2);
  z-index: 45;
}

.search-dock svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search-dock span {
  font-size: var(--fs-body);
  color: var(--text-3);
}

/* ============ 倒数日 ============ */
.count-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.count-card { padding: var(--sp-4) var(--sp-5); }

.count-label {
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--text-2);
}

.count-num {
  font-size: 40px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-top: 6px;
}

.count-unit {
  font-size: var(--fs-sub);
  font-weight: 600;
  color: var(--text-2);
  margin-left: 3px;
  letter-spacing: 0;
}

.count-date {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ============ 词本横滑条 ============ */
.book-strip {
  display: flex;
  gap: var(--sp-3);
  margin: 0 calc(var(--page-pad) * -1);
  padding: 2px var(--page-pad) 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.book-strip::-webkit-scrollbar { display: none; }

.book-mini {
  flex: 0 0 148px;
  text-align: left;
  padding: var(--sp-4);
  background: var(--card);
  border-radius: var(--r-inner);
  /* 横滑条会裁切溢出，这里用小阴影，避免出现一条硬边灰带 */
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.05);
}

.book-mini-name {
  font-size: var(--fs-sub);
  font-weight: 600;
  color: var(--text);
}

.book-mini-meta {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-2);
  margin-top: 4px;
}

/* ============ 倒数日（单卡） ============ */
.countdown {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  cursor: pointer;
}

.countdown-label {
  font-size: var(--fs-sub);
  font-weight: 600;
  color: var(--text);
}

.countdown-date {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-3);
  margin-top: 2px;
}

.countdown-num {
  font-size: 34px;
  line-height: 38px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.countdown-unit {
  font-size: var(--fs-sub);
  font-weight: 600;
  color: var(--text-2);
  margin-left: 3px;
  letter-spacing: 0;
}

/* ============ 双行历史 ============ */
.history-row { align-items: center; padding: 12px 0; }

.history-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-word {
  font-size: var(--fs-body);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-def {
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ 底部 dock 三个入口 ============ */
.search-dock { padding: 0 6px 0 4px; gap: 2px; }

.dock-input {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 100%;
  padding-left: var(--sp-4);
  color: var(--text-2);
}

.dock-input span {
  font-size: var(--fs-body);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
}

.dock-input svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.dock-act {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  color: var(--text-2);
}

.dock-act svg {
  width: 21px;
  height: 21px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============ 词条详情 ============ */
.view.has-action { padding-bottom: calc(var(--safe-b) + 100px); }

.detail-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-bottom: var(--sp-2);
}

.detail-spacer { width: 44px; }

.word-title {
  font-size: var(--fs-word);
  line-height: var(--lh-word);
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 2px 0 12px;
}

.ph-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}

.ph-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--bg-group);
  font-size: var(--fs-sub);
}

.ph-chip svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ph-tag { color: var(--text-2); font-size: var(--fs-caption); }

.ai-card { margin-bottom: var(--sp-3); }

.ai-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.3px;
  margin-bottom: var(--sp-2);
}

.ai-text {
  font-size: var(--fs-body);
  line-height: 29px;
  color: var(--text);
}

.ai-text.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ai-more {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: var(--sp-2);
  font-size: var(--fs-caption);
  color: var(--text-2);
}

.ai-more svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.def-card { margin-bottom: var(--sp-3); padding-top: 6px; padding-bottom: 6px; }

.def-row {
  display: flex;
  gap: 10px;
  padding: 12px 0;
}

.def-row + .def-row { border-top: 0.5px solid var(--line); }

.def-pos {
  font-style: italic;
  color: var(--text-2);
  font-size: var(--fs-sub);
  min-width: 32px;
  padding-top: 2px;
}

.def-cn { font-size: var(--fs-body); line-height: 26px; }

.section-title {
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-2);
  margin: var(--sp-5) 0 var(--sp-2) 2px;
}

.body-text { font-size: var(--fs-body); line-height: 28px; }

.chip-inline {
  font-size: var(--fs-sub);
  padding: 7px 14px;
  border-radius: 10px;
  background: var(--bg-group);
}

.chip-inline.is-ant { color: var(--text-2); }

.sent-card { padding-top: 4px; padding-bottom: 4px; }

.sent { padding: 14px 0; }
.sent + .sent { border-top: 0.5px solid var(--line); }

.sent-en { font-size: var(--fs-body); line-height: 27px; }

.sent-cn {
  font-size: var(--fs-sub);
  line-height: 22px;
  color: var(--text-2);
  margin-top: 4px;
}

.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px var(--page-pad) calc(var(--safe-b) + 10px);
  background: rgba(246, 246, 248, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--line);
  z-index: 55;
}

.action-bar .btn { width: 100%; height: 50px; font-size: var(--fs-body); }

/* 词条标签与同反义分组 */
.tag-row {
  display: flex;
  gap: 6px;
  margin: -4px 0 10px;
}

.word-tag {
  font-size: 11px;
  line-height: 18px;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--bg-group);
  color: var(--text-2);
}

.chip-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 0;
}

.chip-line + .chip-line { border-top: 0.5px solid var(--line); }

.chip-key {
  font-size: 12px;
  color: var(--text-2);
  width: 16px;
}

/* 词本横滑：尾部"全部"入口 */
.book-more {
  flex: 0 0 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: none;
  background: var(--bg-group);
  color: var(--text-2);
}

.book-more-arrow {
  font-size: 20px;
  line-height: 20px;
  color: var(--text);
}

.book-more-text {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-2);
  white-space: nowrap;
}

/* 空状态与占位文案 */
.empty-hint {
  padding: 36px 0;
  text-align: center;
  font-size: var(--fs-sub);
  color: var(--text-3);
}

.ai-muted {
  font-size: var(--fs-sub);
  line-height: 24px;
  color: var(--text-2);
}

/* ============ 底部弹层 ============ */
.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sheet-mask.show { opacity: 1; }

.sheet-panel {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: 28px 28px 0 0;
  padding: var(--sp-5) var(--sp-5) calc(var(--safe-b) + var(--sp-4));
  transform: translateY(100%);
  transition: transform 0.24s var(--ease-standard);
  max-height: 86dvh;
  overflow-y: auto;
}

.sheet-mask.show .sheet-panel { transform: translateY(0); }

/* 居中的弹层：带输入框的表单用它，键盘弹起时不会被盖住 */
.sheet-mask.is-center {
  align-items: center;
  padding: 20px 16px;
}

.sheet-mask.is-center .sheet-panel {
  border-radius: 24px;
  padding: var(--sp-5);
  max-height: 72dvh;
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform 0.22s var(--ease-standard), opacity 0.22s ease;
}

.sheet-mask.is-center.show .sheet-panel {
  transform: none;
  opacity: 1;
}

.sheet-title {
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: 700;
  margin-bottom: var(--sp-4);
}

.field {
  width: 100%;
  height: 48px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  background: var(--bg);
  font-size: var(--fs-body);
  outline: 0;
}

.field:focus { border-color: rgba(60, 60, 67, 0.32); }

.field-label {
  font-size: var(--fs-caption);
  color: var(--text-2);
  margin: var(--sp-4) 0 var(--sp-2) 2px;
}

.color-row { display: flex; gap: var(--sp-3); margin: 2px 0 var(--sp-2); }

.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 2px solid transparent;
  transition: transform var(--dur-fast) ease;
}

.color-dot[aria-selected="true"] {
  border-color: var(--text);
  transform: scale(1.06);
}

.sheet-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

.sheet-actions .btn { flex: 1; height: 50px; }

.check-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 56px;
  border-bottom: 0.5px solid var(--line);
}

.check-row:last-of-type { border-bottom: 0; }

.check-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1.5px solid var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.check-dot[aria-checked="true"] {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.check-dot svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.4; }

.check-name { flex: 1; font-size: var(--fs-body); }
.check-meta { font-size: var(--fs-caption); color: var(--text-2); }

/* ============ 词本列表与词本详情 ============ */
.text-btn {
  font-size: var(--fs-sub);
  font-weight: 500;
  color: var(--accent);
  padding: 8px 4px;
}

.btn-danger { background: var(--danger); color: #fff; }

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  font-weight: 600;
}

.sheet-text {
  font-size: var(--fs-sub);
  line-height: 24px;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}

.empty-card { text-align: center; padding: 32px var(--sp-5); }

.empty-title { font-size: var(--fs-body); font-weight: 600; }

.empty-sub {
  font-size: var(--fs-sub);
  line-height: 22px;
  color: var(--text-2);
  margin-top: 6px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 44px;
  padding: 0 14px;
  background: var(--bg-group);
  border-radius: var(--r-input);
  margin: var(--sp-4) 0 var(--sp-3);
  color: var(--text-2);
}

.search-field svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-body);
  color: var(--text);
}

.segmented { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-2); }

.seg {
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--bg-group);
  font-size: 14px;
  color: var(--text-2);
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.seg[aria-selected="true"] { background: var(--text); color: #fff; }

.word-list { margin-top: var(--sp-2); }

.word-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 12px 0;
  border-bottom: 0.5px solid var(--line);
}

.word-row:last-child { border-bottom: 0; }

.row-stage { font-size: 12px; color: var(--text-3); }

.row-remove {
  font-size: 14px;
  color: var(--danger);
  padding: 6px 10px;
}

.book-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 18px var(--sp-5);
}

.book-card .ring { display: block; }

.book-empty {
  justify-content: center;
  background: transparent;
  border: 1px dashed rgba(60, 60, 67, 0.24);
  box-shadow: none;
  color: var(--text-2);
}

/* ============ 背诵 ============ */
.view.review-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding-bottom: calc(var(--safe-b) + var(--sp-4));
}

.review-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 44px;
}

.review-progress {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-group);
  overflow: hidden;
}

.review-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
  border-radius: 3px;
  transition: width 0.25s var(--ease-standard);
}

.review-count {
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: right;
}

.review-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1400px;
}

.flip-wrap {
  position: relative;
  width: 100%;
  height: clamp(190px, 40dvh, 340px);
  transform-style: preserve-3d;
  transition: transform var(--dur-flip) var(--ease-standard);
  cursor: pointer;
}

.flip-wrap.is-flipped { transform: rotateY(180deg); }

.flip-wrap.flash-ok .face { box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.35), var(--shadow-card); }
.flip-wrap.flash-no .face { box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.28), var(--shadow-card); }

.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: var(--sp-5);
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.face.back {
  transform: rotateY(180deg);
  align-items: stretch;
  justify-content: center;
  gap: 4px;
}

.review-word {
  font-size: 40px;
  line-height: 46px;
  font-weight: 700;
  letter-spacing: -0.5px;
  word-break: break-all;
  text-align: center;
}

.review-ph {
  font-size: var(--fs-sub);
  color: var(--text-2);
}

.review-hint {
  position: absolute;
  bottom: 22px;
  font-size: 12px;
  color: var(--text-3);
}

.back-def {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  font-size: 19px;
  line-height: 30px;
}

.review-actions {
  display: flex;
  gap: var(--sp-3);
  padding-top: var(--sp-2);
}

.btn-wide {
  flex: 1;
  height: 56px;
  font-size: var(--fs-body);
}

.review-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}

/* ============ 完成页 ============ */
.view.done-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-bottom: calc(var(--safe-b) + var(--sp-5));
}

.done-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.done-label { font-size: var(--fs-sub); color: var(--text-2); }

.done-num {
  font-size: 68px;
  line-height: 76px;
  font-weight: 700;
  letter-spacing: -2px;
}

.done-unit {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-2);
  margin-left: 2px;
  letter-spacing: 0;
}

.done-sub { font-size: var(--fs-caption); color: var(--text-3); }

.done-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.done-stats .stat-card { padding: var(--sp-3) var(--sp-4); }

.done-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* ============ 完成庆祝过渡 ============ */
[hidden] { display: none !important; }

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(246, 246, 248, 0.96);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 1;
  transition: opacity 0.18s ease;
}

.celebrate.hide { opacity: 0; }

.celebrate-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.celebrate-check {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: popIn 0.38s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.celebrate-check svg {
  width: 36px;
  height: 36px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.celebrate-ring {
  position: absolute;
  top: -6px;
  left: 50%;
  margin-left: -43px;
  width: 86px;
  height: 86px;
  border-radius: 999px;
  border: 2px solid rgba(28, 28, 30, 0.16);
  animation: ringOut 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.celebrate-text {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text);
  animation: fadeUpIn 0.3s ease 0.1s both;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes ringOut {
  0% { transform: scale(0.8); opacity: 0.55; }
  100% { transform: scale(2.2); opacity: 0; }
}

@keyframes fadeUpIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.view.done-page { animation: fadeUp 0.32s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .celebrate-check,
  .celebrate-ring,
  .celebrate-text,
  .view.done-page { animation: none !important; }
}

.check-row.is-owned { opacity: 0.55; }
.check-row.is-owned .check-name { color: var(--text-2); }

.sheet-note {
  font-size: var(--fs-caption);
  color: var(--text-2);
  padding: var(--sp-2) 0 0;
}

/* ============ 默写模式 ============ */
.spell-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spell-card {
  width: 100%;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.spell-tag {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-3);
}

.spell-defs .back-def { padding: 4px 0; }

.spell-hint {
  font-size: var(--fs-sub);
  color: var(--text-3);
  letter-spacing: 3px;
  margin-top: 6px;
}

.spell-foot { padding: var(--sp-3) 0 var(--sp-2); }

.spell-input {
  width: 100%;
  height: 60px;
  padding: 0 var(--sp-4);
  border: 1.5px solid var(--line);
  border-radius: var(--r-input);
  background: var(--card);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 1px;
  text-align: center;
  color: var(--text);
  outline: 0;
  transition: border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.spell-input:focus { border-color: var(--text); }
.spell-input.is-ok { border-color: var(--ok); color: var(--ok); }
.spell-input.is-bad { border-color: var(--danger); color: var(--danger); }

.result-word {
  font-size: 34px;
  line-height: 42px;
  font-weight: 700;
  letter-spacing: -0.5px;
  word-break: break-all;
}

.result-word.is-ok { color: var(--ok); }
.result-word .diff { color: var(--danger); }

.result-ph { font-size: var(--fs-sub); color: var(--text-2); }

.result-meta {
  font-size: var(--fs-caption);
  color: var(--text-2);
}

.result-meta b { color: var(--danger); font-weight: 600; }

.result-sent {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 0.5px solid var(--line);
  font-size: var(--fs-sub);
  line-height: 24px;
  color: var(--text);
}

.result-sent span { color: var(--text-2); }

.spell-skip {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 0;
  text-align: center;
  font-size: var(--fs-caption);
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============ 今日页 ============ */
.today-hero { margin-top: 4px; }

.mode-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  margin-top: var(--sp-3);
  padding: 18px var(--sp-5);
}

.mode-name {
  font-size: var(--fs-body);
  font-weight: 600;
  margin-bottom: 2px;
}

.mode-arrow {
  color: var(--text-3);
  display: flex;
}

.mode-arrow svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  transform: rotate(-90deg);
}

.today-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}

.done-line {
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
  margin-top: 2px;
}

/* ============ 我的 / 设置 ============ */
.profile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 4px 0 18px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  flex: 0 0 auto;
}

.profile-name {
  display: block;
  font-size: 20px;
  line-height: 26px;
  font-weight: 700;
}

.profile-sub {
  display: block;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-2);
  margin-top: 2px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px 0;
}

.dist-label {
  width: 56px;
  font-size: 14px;
  color: var(--text-2);
}

.dist-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-group);
  overflow: hidden;
}

.dist-bar i {
  display: block;
  height: 100%;
  background: var(--text);
  border-radius: 4px;
}

.dist-num {
  width: 30px;
  text-align: right;
  font-size: 14px;
  color: var(--text-2);
}

.set-group-label {
  font-size: 13px;
  color: var(--text-2);
  margin: var(--sp-5) 0 var(--sp-2) 4px;
}

.set-card { padding: 0; overflow: hidden; }

.set-row {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 15px 18px;
  text-align: left;
  border-bottom: 0.5px solid var(--line);
}

.set-row:last-child { border-bottom: 0; }
.set-row.static { cursor: default; }

.set-label { flex: 0 0 auto; font-size: var(--fs-body); white-space: nowrap; }

.set-value {
  margin-left: auto;
  min-width: 0;
  max-width: 62%;
  font-size: var(--fs-sub);
  color: var(--text-2);
  margin-right: 6px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-chev { color: var(--text-3); font-size: 18px; line-height: 1; }

/* 释义折叠 */
.def-row.is-hidden { display: none; }
.def-card.expanded .def-row.is-hidden { display: flex; }

.def-more {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: var(--sp-2);
  font-size: var(--fs-caption);
  color: var(--text-2);
}

.def-more svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.form-row .def-cn { color: var(--text-2); }

.form-base {
  display: block;
  width: 100%;
  margin: var(--sp-3) 0 var(--sp-2);
  padding: 12px;
  border-radius: var(--r-input);
  background: var(--bg-group);
  font-size: var(--fs-sub);
  color: var(--accent);
  text-align: center;
}

.btn-gen {
  margin-top: var(--sp-3);
  height: 44px;
  padding: 0 18px;
  background: var(--text);
  color: #fff;
  font-size: var(--fs-sub);
  font-weight: 600;
  border-radius: var(--r-btn);
}

.btn-gen[disabled] { opacity: 0.5; }

/* ============ 长难句 ============ */
.sent-orig {
  font-size: var(--fs-body);
  line-height: 31px;
  color: var(--text);
}

.sent-word {
  border-bottom: 1px dashed rgba(60, 60, 67, 0.28);
  padding-bottom: 1px;
}

.sent-word:active {
  background: var(--bg-group);
}

.part-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--line);
}

.part-row:last-child { border-bottom: 0; }

.part-seg {
  font-size: var(--fs-sub);
  line-height: 24px;
  color: var(--text);
}

.part-role {
  align-self: flex-start;
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg-group);
  border-radius: 8px;
  padding: 2px 8px;
}

.point-line {
  font-size: var(--fs-sub);
  line-height: 25px;
  color: var(--text);
  padding: 5px 0;
}

.sk-line {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--bg-group) 25%, #f7f7f9 37%, var(--bg-group) 63%);
  background-size: 400% 100%;
  animation: sk 1.2s ease infinite;
  margin: 10px 0;
}

@keyframes sk {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ============ 离线提示 / 更新条 ============ */
.offline-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 6px 12px;
  text-align: center;
  font-size: 12px;
  line-height: 18px;
  color: #fff;
  background: #FF9500;
  transform: translateY(-100%);
  transition: transform 0.2s ease;
  z-index: 90;
}

.offline-bar.show { transform: none; }

.sw-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--safe-b) + 92px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-btn);
  background: rgba(28, 28, 30, 0.94);
  color: #fff;
  font-size: var(--fs-sub);
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.22);
  z-index: 120;
}

.sw-bar button {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============ 页面转场 & 内容入场 ============ */
::view-transition-old(root) {
  animation: pageOut 0.18s ease both;
}

::view-transition-new(root) {
  animation: pageIn 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes pageOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.view > * {
  animation: enter 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.view > *:nth-child(2) { animation-delay: 0.03s; }
.view > *:nth-child(3) { animation-delay: 0.06s; }
.view > *:nth-child(4) { animation-delay: 0.09s; }
.view > *:nth-child(5) { animation-delay: 0.12s; }
.view > *:nth-child(6) { animation-delay: 0.15s; }
.view > *:nth-child(n+7) { animation-delay: 0.18s; }

@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* 有 View Transition 时不再叠加入场动画，避免转场结束后重放 */
html.vt-supported .view > * { animation: none; }

/* 不支持毛玻璃的浏览器：退回接近不透明，避免文字穿透 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar { background: rgba(255, 255, 255, 0.96); }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root),
  .view > * { animation: none !important; }
}

/* ============ 自定义背景 ============ */
#bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg);
  pointer-events: none;
}

body.has-bg { background: transparent; }

body.has-bg #bg-layer::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
}

body.has-bg #bg-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, var(--bg-veil, 0.88));
}

/* ============ 收藏的句子 ============ */
.sent-list { padding: 4px 0; }

.sent-item {
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--line);
  cursor: pointer;
}

.sent-item:last-child { border-bottom: 0; }
.sent-item:active { background: var(--bg-group); }

.sent-item-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: var(--fs-sub);
  line-height: 24px;
  color: var(--text);
}

.sent-item-meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}

/* ============ 背诵页模式切换 ============ */
.mode-seg {
  display: flex;
  gap: 2px;
  margin: 4px auto 12px;
  padding: 3px;
  width: fit-content;
  background: var(--bg-group);
  border-radius: var(--r-pill);
}

.mode-seg button {
  padding: 6px 20px;
  border-radius: var(--r-pill);
  font-size: 13px;
  color: var(--text-2);
  transition: background-color 0.18s ease, color 0.18s ease;
}

.mode-seg button[aria-selected="true"] {
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

/* ============ 备份提醒 ============ */
.nudge-card {
  background: #FFF8EC;
  border: 0.5px solid #F3E0BE;
  margin-bottom: 16px;
}

.nudge-title {
  font-size: var(--fs-sub);
  font-weight: 600;
  color: #8A5A00;
}

.nudge-sub {
  margin-top: 4px;
  font-size: 13px;
  line-height: 19px;
  color: #A97A2E;
}

.nudge-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.nudge-actions .btn {
  flex: 1;
  height: 44px;
}

.nudge-actions .btn:not(.btn-primary) {
  background: rgba(255, 255, 255, 0.8);
  color: #8A5A00;
}
