:root {
  --bg: #f3f6f4;
  --card: #fff;
  --ink: #1a2822;
  --muted: #5c7168;
  --faint: #8fa39a;
  --line: #d5e2db;
  --green: #0c7a5c;
  --green-d: #085c45;
  --green-s: #d5f0e5;
  --amber: #c56a2d;
  --amber-s: #fff1e6;
  --blue: #2f5bb8;
  --blue-s: #e8eefc;
  --shadow: 0 10px 32px rgba(12, 60, 45, 0.08);
  --radius: 18px;
  /* UI stack may mix system CJK; headwords use --font-cjk-unified (single webfont). */
  --font: "Segoe UI", system-ui, -apple-system, "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-cjk: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  /* One family for 简（繁）lines — covers both scripts; load 400–900 so bold is real. */
  --font-cjk-unified: "Noto Sans SC", sans-serif;
  --mono: "SF Mono", "Cascadia Code", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, #d8f3e8 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, #ffe8d6 0%, transparent 50%),
    var(--bg);
  line-height: 1.55;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: var(--green-d);
}

/* Header */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(243, 246, 244, 0.88);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--green), #14a07a);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(12, 122, 92, 0.3);
}

.brand h1 {
  margin: 0;
  font-size: 1.12rem;
}

.brand p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s, background 0.15s;
}

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

.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 14px rgba(12, 122, 92, 0.28);
}

.btn-primary:hover {
  background: var(--green-d);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-soft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--green-s);
  color: var(--green-d);
  border: 1px solid #b7e4d2;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-soft:hover {
  background: #c6eadc;
}

.btn-soft:active {
  transform: scale(0.97);
}

.btn-icon {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  line-height: 1;
  /* ▶ 字形左侧留白偏大，旧版 iOS Safari 会显得歪/偏心 */
  text-indent: 0.12em;
}

.btn-icon.playing {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  animation: pulse 1.2s ease-in-out infinite;
}

.btn-icon.paused {
  background: #fff8e8;
  color: var(--amber, #b45309);
  border-color: #f0d9a8;
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(12, 122, 92, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px transparent;
  }
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 22px 18px 120px; /* 底部留给悬浮查词条 */
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* 旧 composer 样式保留兼容（已从 HTML 移除输入区） */
.composer {
  padding: 22px;
  margin-bottom: 18px;
}

.composer h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.composer .lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.input-wrap {
  position: relative;
}

.input-wrap textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
  background: #fafcfb;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.quick-start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
}

.quick-start-label {
  font-size: 0.82rem;
  color: var(--faint);
  font-weight: 600;
  flex-shrink: 0;
}

.quick-chip {
  border: 1px solid #b7e4d2;
  background: linear-gradient(180deg, #f3fbf7 0%, #e8f6ef 100%);
  color: var(--green-d);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  box-shadow: 0 1px 0 rgba(12, 122, 92, 0.08);
}

.quick-chip:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(12, 122, 92, 0.18);
}

.quick-chip:active {
  transform: translateY(0);
}

.quick-chip:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.input-wrap textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-s);
  background: #fff;
}

.composer-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.meta-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

input[type="range"] {
  width: 100px;
  accent-color: var(--green);
}

/* Chips（相关词 / cat-burst 仍用 .chip；旧示例区宫格样式保留兼容） */
.chips-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.chips-head-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.chips-head strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.chips-head #chips-count {
  font-size: 0.8rem;
  color: var(--faint);
}

.chips-head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.chips-head .btn-soft {
  flex-shrink: 0;
}

.chips-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  padding: 0 2px 2px;
}

.chips-foot .btn-soft {
  flex-shrink: 0;
}

.chip-cats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.chip-cat {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.chip-cat:hover {
  border-color: #9ecfbe;
  box-shadow: 0 6px 16px rgba(12, 90, 60, 0.1);
  transform: translateY(-1px);
}

.chip-cat.active {
  /* 轻提示当前类，避免粗绿框抢词条注意力 */
  border-color: #c5e6d8;
  background: #f7fcf9;
  box-shadow: none;
}

.chip-cat:focus {
  outline: none;
}

.chip-cat:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.chip-cat img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #f0f5f2;
}

.chip-cat .cat-meta {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chip-cat .cat-name {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}

.chip-cat.active .cat-name {
  color: var(--green-d);
}

.chip-cat .cat-count {
  font-size: 0.72rem;
  color: var(--faint);
  font-weight: 500;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
  scroll-margin-top: 76px;
}

.chips.guide-on {
  outline: 2px dashed #9ecfbe;
  outline-offset: 4px;
  border-radius: 14px;
  padding: 8px 6px 10px;
  background: rgba(247, 252, 249, 0.7);
}

.chip {
  border: 1px solid var(--line);
  background: #f7faf8;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.chip.chip-nudge {
  border-color: var(--green);
  color: var(--green-d);
  background: #e8f6ef;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(12, 122, 92, 0.15);
  animation: chip-nudge 1.1s ease-in-out 2;
}

@keyframes chip-nudge {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

.chip:hover {
  border-color: var(--green);
  color: var(--green-d);
  background: var(--green-s);
}

kbd {
  font-family: var(--mono);
  font-size: 0.8em;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #f0f4f2;
}

/* Result */
.result {
  padding: 20px 22px;
  margin-bottom: 16px;
  display: none;
  overflow: hidden;
}

/* 配图置顶：满宽贴齐卡片上沿，比例接近立即学习词卡 */
.result-visual {
  position: relative;
  margin: -20px -22px 14px;
  padding: 0;
}

.result-visual[hidden] {
  display: none !important;
}

.result-visual img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 0;
  background: #eef4f0;
  border: none;
  border-bottom: 1px solid var(--line);
}

/* 配图左右热区：窄边条，避免误触；中间留给点图发音 */
.result-nav-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: min(14%, 56px);
  max-width: 56px;
  min-width: 48px;
  box-sizing: border-box;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.result-nav-zone-prev {
  left: 0;
}

.result-nav-zone-next {
  right: 0;
}

.result-nav-zone:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.06);
}

/* 切词圆钮：有配图时叠在图片两侧；无配图时改用 .result-nav-bar */
.result-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: var(--green-d);
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 600;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(20, 60, 45, 0.16);
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.result-nav:active {
  transform: translateY(-50%) scale(0.96);
}

.result-nav-prev {
  left: 10px;
}

.result-nav-next {
  right: 10px;
}

/* 无配图（或收起后配图不占位）时：摘要条两侧切词 */
.result-nav-bar {
  flex: 0 0 auto;
  align-self: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--green-d);
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 600;
  display: none;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(20, 60, 45, 0.08);
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.result-nav-bar:active {
  transform: scale(0.96);
}

/* 有图且展开：箭头在图上；无图或收起：箭头在摘要条 */
#result.no-visual .result-nav-bar,
#result.has-visual.collapsed .result-nav-bar {
  display: grid;
}

#result.has-visual:not(.collapsed) .result-nav-bar {
  display: none;
}

.cat-burst-wrap {
  margin-top: 6px;
}

.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font: inherit;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef5f1;
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cat-tag::after {
  content: "▾";
  font-size: 0.65em;
  opacity: 0.55;
  transition: transform 0.18s ease;
}

.cat-tag[aria-expanded="true"] {
  background: #e7f5ee;
  border-color: #c5e0d4;
  color: var(--green);
}

.cat-tag[aria-expanded="true"]::after {
  transform: rotate(180deg);
  opacity: 0.8;
}

.cat-tag:focus-visible {
  outline: 2px solid rgba(26, 122, 74, 0.35);
  outline-offset: 2px;
}

.cat-burst {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  max-width: 100%;
}

.cat-burst[hidden] {
  display: none !important;
}

.cat-burst.is-open {
  animation: cat-burst-in 0.22s ease;
}

.cat-burst .chip {
  border-color: #c5e0d4;
  background: #f3faf6;
  animation: cat-chip-pop 0.28s ease both;
}

.cat-burst .chip:nth-child(1) {
  animation-delay: 0.01s;
}
.cat-burst .chip:nth-child(2) {
  animation-delay: 0.03s;
}
.cat-burst .chip:nth-child(3) {
  animation-delay: 0.05s;
}
.cat-burst .chip:nth-child(4) {
  animation-delay: 0.07s;
}
.cat-burst .chip:nth-child(5) {
  animation-delay: 0.09s;
}
.cat-burst .chip:nth-child(6) {
  animation-delay: 0.11s;
}
.cat-burst .chip:nth-child(7) {
  animation-delay: 0.13s;
}
.cat-burst .chip:nth-child(8) {
  animation-delay: 0.15s;
}
.cat-burst .chip:nth-child(9) {
  animation-delay: 0.17s;
}
.cat-burst .chip:nth-child(10) {
  animation-delay: 0.19s;
}
.cat-burst .chip:nth-child(11) {
  animation-delay: 0.21s;
}
.cat-burst .chip:nth-child(12) {
  animation-delay: 0.23s;
}

.cat-burst .chip .rel-tailo {
  font-size: 0.72rem;
  color: var(--faint);
  font-weight: 500;
  margin-left: 2px;
}

.cat-burst-empty {
  font-size: 0.78rem;
  color: var(--faint);
  padding: 2px 0;
}

@keyframes cat-burst-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cat-chip-pop {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.chip.has-img {
  padding-left: 6px;
  gap: 6px;
  display: inline-flex;
  align-items: center;
}

.chip.has-img img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
}

.related-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.related-head h3 {
  margin: 0;
  min-width: 0;
}

.related-head .btn-soft {
  flex-shrink: 0;
}

.related-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.related-chips .chip {
  border-color: #c5e0d4;
  background: #f3faf6;
}

.related-chips .chip.is-current {
  border-color: var(--green);
  background: #e7f5ee;
  box-shadow: inset 0 0 0 1px rgba(26, 122, 74, 0.18);
}

.related-chips .chip .rel-tailo {
  font-size: 0.72rem;
  color: var(--faint);
  font-weight: 500;
  margin-left: 2px;
}

.result.show {
  display: block;
  animation: up 0.22s ease;
}

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

/* 結果卡：讀台語後 scrollIntoView 時避開頂欄 */
#result {
  scroll-margin-top: 72px;
  touch-action: pan-y;
}

/* 详情横滑切词时的轻拖拽反馈 */
#result .result-visual,
#result .result-bar {
  transition: transform 0.18s ease, opacity 0.18s ease;
  will-change: transform;
}

#result.result-dragging .result-visual,
#result.result-dragging .result-bar {
  transition: none;
}

.result-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

/* 详情摘要条：点空白可收起/展开；无图时两侧挂 ◀ ▶ 切词 */
.result-bar {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 8px 10px;
  align-items: center;
  cursor: pointer;
  font-family: var(--font-cjk-unified);
}

.result-bar button,
.result-bar a,
.result-bar [role="button"] {
  cursor: pointer;
}

.result-bar-main {
  min-width: 0;
  flex: 1;
}

.meaning-bar {
  margin-top: 4px;
  font-family: var(--font-cjk-unified);
  font-size: 0.98rem;
  color: var(--ink);
  line-height: 1.45;
  font-weight: 500;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-synthesis: none;
}

.meaning-raw {
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  opacity: 0.85;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 收起时桌面端故意截断摘要；展开/移动端完整换行见下方 media */
.result.collapsed .meaning-bar {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result.collapsed .meaning-raw {
  display: none;
}

.result-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-top: 0;
  border-top: none;
}

/* hidden 块不占位；避免 note-box 自带 margin 叠在 gap 上 */
.result-body > .note-box {
  margin-top: 0;
}

#related-section[hidden] {
  display: none !important;
}

.result.collapsed {
  padding-top: 14px;
  padding-bottom: 14px;
}

.result.collapsed .result-body {
  display: none !important;
}

/* 收起时只留摘要条，配图随详情隐藏 */
.result.collapsed .result-visual {
  display: none !important;
}

.result.collapsed .result-bar {
  align-items: center;
}

.result.collapsed .query-text {
  font-size: 1.35rem;
}

.result.collapsed .tailo-line {
  font-size: 0.92rem;
}

.query-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  flex-wrap: wrap;
}

.query-text {
  font-family: var(--font-cjk-unified);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin: 0;
  line-height: 1.2;
  font-synthesis: none;
}

/* 多段句标题：点词只发音，不换词条 / 不折叠 */
.query-text.is-query-karaoke {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.12em 0.28em;
  letter-spacing: 0;
}
.query-text .query-tok {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  border-radius: 4px;
  padding: 0 1px;
  text-decoration: underline;
  text-decoration-color: rgba(12, 122, 92, 0.35);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1.5px;
  transition: background 0.1s ease, color 0.1s ease, text-decoration-color 0.1s ease;
}
.query-text .query-tok:hover {
  text-decoration-color: rgba(12, 122, 92, 0.7);
  background: rgba(12, 122, 92, 0.06);
}
.query-text .query-tok:active,
.query-text .query-tok.is-speaking {
  background: #ffd54a;
  color: #1a1a12;
  text-decoration-color: transparent;
}
@media (hover: none), (pointer: coarse) {
  .query-text .query-tok {
    background: rgba(12, 122, 92, 0.06);
    text-decoration-thickness: 2px;
  }
  .query-text .query-tok.is-speaking {
    background: #ffd54a;
  }
}

.btn-speak-word {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  font-size: 0.95rem;
  color: var(--green-d);
  border-color: #b7e4d2;
  background: var(--green-s);
}

.btn-speak-word:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.btn-speak-word[hidden] {
  display: none !important;
}

.tailo-line {
  font-family: var(--mono);
  color: var(--green-d);
  font-weight: 700;
  font-size: 1.1rem;
}

.meaning {
  font-family: var(--font-cjk-unified);
  font-synthesis: none;
  color: var(--muted);
  margin-top: 4px;
}

.section {
  margin-top: 0; /* 间距由 .result-body gap 统一控制 */
}

.section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section h3 span {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--faint);
}

/* 可折叠区块（辞书参考等） */
.section.collapsible {
  margin-top: 0;
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbf9;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.section-toggle:hover {
  border-color: #9ecfbe;
  background: #f0f8f4;
}

.section-toggle:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.section-toggle-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.section-toggle-sub {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--faint);
}

.section-chevron {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef5f1;
  color: var(--green-d);
  font-size: 0.85rem;
  line-height: 1;
  transition: transform 0.18s ease, background 0.15s;
}

.section-toggle[aria-expanded="true"] {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
  background: #f0f8f4;
}

.section-toggle[aria-expanded="true"] .section-chevron {
  transform: rotate(180deg);
  background: var(--green-s);
}

.section-body {
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 14px 14px;
  padding: 12px 14px 14px;
  background: #fff;
}

.section-body[hidden] {
  display: none !important;
}

.section-body .note-box {
  margin-top: 10px;
}

/* Examples */
.ex-item.from-moedict {
  border-color: #c5e6d8;
  background: #f7fcf9;
}
.ex-body {
  min-width: 0;
  flex: 1;
}

.ex-label {
  display: inline-block;
  font-family: system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--faint);
  background: #eef3f0;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 8px;
  vertical-align: 0.1em;
}

.ex-tailo {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--green-d);
  margin-top: 6px;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
}

.ex-tailo.muted {
  color: var(--faint);
  font-weight: 500;
}

.ex-item .note {
  margin-top: 6px;
  line-height: 1.45;
}

.ex-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ex-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #f8fbf9;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.ex-item .zh {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.55;
  word-break: break-word;
}

/* 例句跟读高亮 / 点词发音：播到或点到哪一段汉字亮到哪 */
.ex-item .zh .ex-tok {
  border-radius: 5px;
  padding: 2px 3px;
  margin: 0 -1px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
}
.ex-item .zh .ex-tok:active {
  background: #ffe082;
  color: #1a1a12;
}
.ex-item .zh .ex-tok.is-speaking {
  background: #ffd54a;
  color: #1a1a12;
  font-weight: 800;
  box-shadow: 0 0 0 3px #ffd54a;
}

/* 手机/触控：点词可发现（无 hover）；标题旁提示更醒目 */
@media (hover: none), (pointer: coarse), (max-width: 560px) {
  #ex-tap-hint:not([hidden]) {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--amber-s);
    color: var(--amber);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
  }
  .ex-item.is-karaoke .zh .ex-tok {
    background: rgba(12, 122, 92, 0.07);
    box-shadow: inset 0 -2px 0 rgba(12, 122, 92, 0.35);
  }
  .ex-item.is-karaoke .zh .ex-tok.is-speaking {
    background: #ffd54a;
    box-shadow: 0 0 0 3px #ffd54a;
  }
}

.ex-item .note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 2px;
}

.ex-item.template {
  background: #fafafa;
  border-style: dashed;
}

.ex-list .ex-more-btn {
  align-self: center;
  margin-top: 2px;
}

/* Links */
.link-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link-item {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.link-item:hover {
  border-color: #9ecfbe;
  background: #f7fcf9;
}

.link-item .name {
  font-weight: 700;
  color: var(--green-d);
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-item .desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 2px;
}

.tag-off {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--blue-s);
  color: var(--blue);
  font-weight: 600;
}

.tag-on {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--green-s);
  color: var(--green-d);
  font-weight: 600;
}

/* History（顶栏「最近」下拉） */
.hist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hist button,
.hist .hist-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.88rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist button:hover,
.hist .hist-chip:hover {
  border-color: var(--green);
  background: var(--green-s);
}

.empty-hist {
  color: var(--faint);
  font-size: 0.9rem;
}

.note-box {
  padding: 14px 16px;
  font-size: 0.85rem;
  color: var(--muted);
  background: #f8faf9;
  border-radius: 12px;
  border: 1px dashed var(--line);
  margin-top: 12px;
}

.status {
  position: fixed;
  left: 50%;
  bottom: 84px; /* 在悬浮查词条上方 */
  transform: translateX(-50%) translateY(12px);
  background: #1a2822;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 60;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 识图后「制作词卡」：浮在查词条上方，明显但不抢搜索 */
.vocab-card-bar {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 56;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #b7e4d2;
  box-shadow: 0 8px 28px rgba(12, 60, 45, 0.12);
  pointer-events: auto;
  animation: vocab-card-bar-in 0.28s ease;
}

.vocab-card-bar[hidden] {
  display: none !important;
}

@keyframes vocab-card-bar-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.vocab-card-save-btn {
  flex-shrink: 0;
  height: 40px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.vocab-card-dismiss {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--faint);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.vocab-card-dismiss:hover {
  background: var(--green-s);
  color: var(--green-d);
}

.vocab-card-save-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

body.vocab-card-preview-open {
  overflow: hidden;
}

/* 词卡预览 sheet：先展示真实卡片，再触发系统分享 */
.vocab-card-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
}

.vocab-card-sheet:not([hidden]) {
  pointer-events: auto;
}

.vocab-card-sheet[hidden] {
  display: none !important;
}

.vocab-card-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 36, 30, 0.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: vocab-card-sheet-fade 0.22s ease;
}

.vocab-card-sheet-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-height: min(92vh, 920px);
  margin: 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  background: #f7fbf8;
  border: 1px solid rgba(183, 228, 210, 0.9);
  border-bottom: none;
  box-shadow: 0 -12px 40px rgba(12, 60, 45, 0.18);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  animation: vocab-card-sheet-up 0.28s ease;
}

.vocab-card-sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--faint);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}

.vocab-card-sheet-close:hover {
  background: var(--green-s);
  color: var(--green-d);
}

.vocab-card-sheet-img {
  display: block;
  width: 100%;
  max-height: min(68vh, 640px);
  object-fit: contain;
  border-radius: 16px;
  background: #e8f2ed;
  -webkit-touch-callout: default;
  user-select: none;
  -webkit-user-select: none;
}

.vocab-card-sheet-share {
  width: 100%;
  height: 48px;
  min-height: 48px;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.vocab-card-sheet-share:disabled {
  opacity: 0.55;
  cursor: wait;
}

@keyframes vocab-card-sheet-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes vocab-card-sheet-up {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 560px) {
  .vocab-card-sheet {
    align-items: center;
    padding: 24px;
  }

  .vocab-card-sheet-panel {
    border-radius: 22px;
    border-bottom: 1px solid rgba(183, 228, 210, 0.9);
    max-height: min(88vh, 860px);
  }
}

/* —— 悬浮查词条（全页可用） —— */
.float-lookup {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  /* 无底幕/渐变雾：只靠实心条本身，键盘顶起时也不盖一层白纱 */
  background: transparent;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* 评论 / 发音区打开时：搜索条始终可见；加底边距避免与悬浮条重叠 */
body.comments-open main,
body.voice-open main {
  padding-bottom: calc(168px + env(safe-area-inset-bottom, 0px));
}

body.comments-open .hero-comment-panel,
body.voice-open .hero-voice-panel {
  scroll-margin-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

.float-lookup-inner {
  pointer-events: auto;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 18px;
  background: #fff;
  border: 1px solid #b7e4d2;
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(20, 60, 45, 0.14), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  transform: scale(1);
  transform-origin: center center;
  transition: transform 0.2s ease;
}

.float-lookup-inner:focus-within,
.float-lookup-inner:active {
  transform: scale(1.03);
}

.float-input {
  flex: 0 1 auto;
  width: 10.5em;
  min-width: 6em;
  max-width: 14em;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--ink);
  padding: 8px 4px;
  line-height: 1.2;
}

.float-input::placeholder {
  color: var(--faint);
  font-weight: 500;
}

.float-btn {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: none;
  font-size: 1.05rem;
}

.float-speak {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0;
}

.float-cam {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 999px;
  color: var(--green-d);
  overflow: hidden;
}

.float-cam .float-cam-icon {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  /* 避免旧 Safari 对 inline SVG 基线偏移造成「歪了」 */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.float-cam.recognizing {
  background: #e8f4ff;
  border-color: #a8c8f0;
  color: #1d4ed8;
  animation: float-cam-pulse 1.1s ease-in-out infinite;
}

.float-cam:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

@keyframes float-cam-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(29, 78, 216, 0.25);
  }
  50% {
    box-shadow: 0 0 0 7px transparent;
  }
}

@media (max-width: 560px) {
  .float-lookup {
    padding: 10px 12px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .float-btn {
    height: 44px;
    min-height: 44px;
    padding: 0 14px;
    font-size: 1.02rem;
  }
  /* 必须盖过 .float-btn 的左右 padding，否则圆钮内容区会被挤歪 */
  .float-speak,
  .float-cam {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
  }
  .float-cam .float-cam-icon {
    width: 20px;
    height: 20px;
  }
  .float-lookup-inner {
    gap: 7px;
    padding: 8px 8px 8px 16px;
  }
  .float-input {
    width: 9.5em;
    font-size: 1.1rem;
  }
}

.footer {
  text-align: center;
  color: var(--faint);
  font-size: 0.8rem;
  margin-top: 8px;
}

@media (max-width: 560px) {
  .query-text {
    font-size: 1.35rem;
  }
  .composer-bar {
    align-items: stretch;
  }
  .composer-actions {
    width: 100%;
  }
  .composer-actions .btn-primary {
    flex: 1;
    justify-content: center;
  }
  .related-head .btn-soft {
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  /* 结果卡：降低窄屏密度，徽章可换行，配图上下排 */
  #result.result {
    padding: 14px 14px 16px;
  }
  #result.result .result-visual {
    margin: -14px -14px 12px;
  }
  .result.collapsed {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .result-bar {
    gap: 6px 8px;
  }
  .result-bar-main {
    flex: 1 1 auto;
    min-width: 0;
  }
  .result-nav,
  .result-nav-bar {
    width: 34px;
    height: 34px;
    font-size: 1.35rem;
  }
  .query-row {
    gap: 8px;
    margin-bottom: 2px;
  }
  .btn-speak-word {
    width: 36px;
    height: 36px;
    font-size: 0.88rem;
  }
  .tailo-line {
    font-size: 0.98rem;
  }
  .meaning-bar {
    margin-top: 6px;
    font-size: 0.9rem;
    line-height: 1.4;
    font-weight: 500;
  }
  .meaning-bar:empty {
    display: none;
  }
  .meaning-raw {
    margin-top: 4px;
    font-size: 0.72rem;
    line-height: 1.4;
  }
  .cat-burst-wrap {
    margin-top: 8px;
  }
  .cat-tag {
    font-size: 0.72rem;
    padding: 2px 9px;
  }
  .result-body {
    gap: 8px;
    margin-top: 8px;
    padding-top: 0;
  }
  .result-visual img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
    border-radius: 0;
  }

  /* 释义仅出现在摘要条：窄屏完整换行，避免 line-clamp/ellipsis 截断 */
  .result.collapsed .meaning-bar {
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    overflow: visible;
  }
  .result.collapsed .meaning-bar:empty {
    display: none;
  }
}

/* ============================================================
   首页改版（学习卡 / 分类抽屉 / 点赞评论）— 2026-07 redesign
   结构与交互参考「播放器式学习卡 + 分类宫格」，配色/字体延续既有
   薄荷绿品牌，不引入紫色/奶油杏色/报纸风等参照禁用元素。
   ============================================================ */

:root {
  --font-display: "Space Grotesk", var(--font);
  --font-serif: "Noto Serif TC", "Noto Serif SC", "Songti TC", var(--font);
  --like: #e2484f;
  --like-s: #fdeceb;
  --ink-deep: #0a1a14;
}

/* 更有层次的氛围底：薄荷 + 杏橘双光斑叠加暗角，替代纯平色块 */
body {
  background:
    radial-gradient(1100px 520px at -6% -14%, rgba(112, 214, 173, 0.32) 0%, transparent 58%),
    radial-gradient(820px 460px at 108% -6%, rgba(255, 190, 138, 0.28) 0%, transparent 55%),
    radial-gradient(1000px 640px at 50% 118%, rgba(70, 170, 140, 0.14) 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed, fixed, fixed, fixed;
}

/* —— 顶栏：分类入口 + 品牌 + 查词跳转 —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(243, 248, 245, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  position: relative;
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.topbar-recent-wrap {
  position: relative;
}

.topbar-recent.is-open {
  background: var(--green-s);
}

.recent-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: min(320px, calc(100vw - 28px));
  max-height: min(52vh, 360px);
  overflow: auto;
  padding: 12px 14px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 14px 36px rgba(12, 40, 30, 0.16);
  -webkit-overflow-scrolling: touch;
}

.recent-panel-head {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.recent-panel .hist {
  max-height: none;
}

.recent-panel .hist button,
.recent-panel .hist .hist-chip {
  font-size: 0.86rem;
  max-width: 100%;
}

@media (max-width: 420px) {
  .topbar-recent span {
    display: none;
  }
  .topbar-recent {
    padding: 8px;
  }
}

a.topbar-btn {
  text-decoration: none;
  color: inherit;
}

.topbar-btn {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--green-d);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.topbar-btn:hover {
  background: var(--green-s);
}

.topbar-btn:active {
  transform: scale(0.96);
}

.topbar-search {
  padding: 8px;
}

.topbar-icon {
  flex-shrink: 0;
}

.topbar-brand {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  font-family: var(--font-display);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: 9px;
  transition: transform 0.12s ease, opacity 0.15s ease;
  z-index: 1;
}

.topbar-brand:hover {
  opacity: 0.9;
}

.topbar-brand:active {
  transform: translateX(-50%) scale(0.96);
}

.topbar-brand:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.topbar-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--green), #14a07a);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 0.88rem;
  box-shadow: 0 3px 10px rgba(12, 122, 92, 0.32);
}

.topbar-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .topbar-name {
    display: none;
  }
}

/* —— 分类抽屉：只保留类型宫格 —— */
.cat-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(8, 22, 17, 0.45);
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}

.cat-drawer-overlay:not([hidden]) {
  pointer-events: auto;
}

.cat-drawer-overlay.is-open {
  opacity: 1;
}

body.cat-drawer-active {
  overflow: hidden;
}

.cat-drawer {
  position: fixed;
  z-index: 71;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 82vh;
  background: #fff;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -16px 50px rgba(8, 40, 28, 0.28);
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  transform: translateY(102%);
  transition: transform 0.28s cubic-bezier(0.22, 0.85, 0.28, 1);
}

.cat-drawer.is-open {
  transform: translateY(0);
}

.cat-drawer-grab {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 8px auto 12px;
}

.cat-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.cat-drawer-head strong {
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--ink);
}

.cat-drawer-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--faint);
  font-weight: 500;
}

.cat-drawer-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.cat-drawer-close:hover {
  border-color: #9ecfbe;
  color: var(--green-d);
  background: var(--green-s);
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding-bottom: 8px;
}

.cat-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--faint);
  padding: 20px 0;
  font-size: 0.9rem;
}

a.cat-grid-item {
  text-decoration: none;
  color: inherit;
}

.cat-grid-item {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 16px 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-align: center;
  background: var(--green-s);
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  animation: cat-grid-pop 0.32s ease forwards;
  animation-delay: calc(var(--cat-i, 0) * 0.03s);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.cat-grid-item:nth-child(3n+2) {
  background: var(--amber-s);
}

.cat-grid-item:nth-child(3n) {
  background: var(--blue-s);
}

.cat-grid-item:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 10px 22px rgba(12, 90, 60, 0.14);
  border-color: rgba(12, 90, 60, 0.12);
}

.cat-grid-item:active {
  transform: translateY(0) scale(0.98);
}

.cat-grid-item.is-active {
  border-color: rgba(12, 90, 60, 0.42);
  box-shadow: 0 0 0 2px rgba(12, 90, 60, 0.16);
}

.cat-grid-icon {
  font-size: 1.55rem;
  line-height: 1;
}

.cat-grid-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.2;
}

.cat-grid-count {
  font-size: 0.68rem;
  color: var(--faint);
  font-weight: 500;
}

@keyframes cat-grid-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (min-width: 720px) {
  .cat-drawer {
    left: auto;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 92vw);
    max-height: none;
    border-radius: 0;
    transform: translateX(102%);
    padding: 18px 22px calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .cat-drawer.is-open {
    transform: translateX(0);
  }
  .cat-drawer-grab {
    display: none;
  }
}

/* —— 学习卡主视觉：配图叠字说明 + 点图可发音提示 —— */
.result-visual img {
  cursor: pointer;
  transition: transform 0.5s ease;
}

.result-visual:hover img {
  transform: scale(1.015);
}

.hero-tap-hint {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(8, 24, 18, 0.55);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}

.hero-tap-hint[hidden] {
  display: none !important;
}

/* 详情卡展开动画：加一点缩放，呼应「一屏一景」的主视觉进场 */
.result.show {
  animation: hero-up 0.26s cubic-bezier(0.22, 0.85, 0.28, 1);
  box-shadow: 0 26px 60px rgba(10, 60, 42, 0.14), var(--shadow);
}

@keyframes hero-up {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* —— 点赞 / 评论（本机存储 stub） —— */
.hero-social {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.hero-like,
.hero-comment,
.hero-voice {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 4px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font-display);
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.hero-like:hover,
.hero-comment:hover,
.hero-voice:hover {
  color: var(--ink);
}

.hero-like:disabled,
.hero-comment:disabled,
.hero-voice:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hero-like-icon,
.hero-comment-icon,
.hero-voice-icon {
  color: var(--faint);
  transition: color 0.15s ease, transform 0.15s ease;
}

.hero-voice.is-recording,
.hero-voice.is-recording .hero-voice-icon {
  color: var(--like);
}

.hero-voice.is-recording {
  animation: hero-voice-pulse 1.1s ease-in-out infinite;
}

@keyframes hero-voice-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.hero-like.is-liked {
  color: var(--like);
}

.hero-like.is-liked .hero-like-icon {
  color: var(--like);
}

.hero-like.like-pop .hero-like-icon {
  animation: like-pop 0.26s ease;
}

@keyframes like-pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.4);
  }
  100% {
    transform: scale(1);
  }
}

.hero-voice-panel,
.hero-comment-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.hero-voice-panel[hidden],
.hero-comment-panel[hidden] {
  display: none !important;
}

.hero-panel-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  font-family: var(--font-display);
}

.hero-voice-list,
.hero-comment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding-right: 2px;
}

.hero-comment-item {
  background: #f7fcf9;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}

.hero-comment-text {
  font-size: 0.86rem;
  color: var(--ink);
  line-height: 1.42;
  word-break: break-word;
}

.hero-comment-meta {
  font-size: 0.68rem;
  color: var(--faint);
  margin-top: 3px;
}

.hero-comment-empty {
  font-size: 0.82rem;
  color: var(--faint);
  padding: 6px 2px;
}

.hero-voice-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #f7fcf9;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.hero-voice-preview[hidden] {
  display: none !important;
}

.hero-voice-send,
.hero-voice-rerecord,
.hero-voice-cancel {
  flex-shrink: 0;
  font-size: 0.82rem;
  padding: 6px 12px;
}

.hero-voice-rerecord,
.hero-voice-cancel {
  color: var(--muted);
}

.hero-comment-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hero-comment-form[hidden] {
  display: none !important;
}

.hero-comment-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  /* iOS Safari zooms inputs with computed font-size < 16px on focus */
  font-size: 16px;
  outline: none;
  background: #fafcfb;
  font-family: var(--font-cjk-unified);
}

.hero-comment-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-s);
}

.hero-comment-mic,
.hero-comment-submit {
  flex-shrink: 0;
}

.hero-comment-mic {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--green-d);
  border-color: #b7e4d2;
  background: var(--green-s);
}

.hero-comment-mic:hover {
  background: #c8ebe0;
  border-color: #9ad4c0;
}

.hero-comment-mic.is-recording {
  color: #fff;
  background: var(--like);
  border-color: var(--like);
  animation: mic-pulse 1.1s ease-in-out infinite;
}

.hero-comment-mic:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@keyframes mic-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(226, 72, 79, 0.35);
  }
  50% {
    box-shadow: 0 0 0 7px transparent;
  }
}

.hero-voice-status,
.hero-comment-status {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.hero-voice-status.is-error,
.hero-comment-status.is-error {
  color: #8a4b1a;
}

.hero-voice-status[hidden],
.hero-comment-status[hidden] {
  display: none !important;
}

.hero-voice-count {
  font-variant-numeric: tabular-nums;
}

.hero-comment-voice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.hero-comment-play {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid #b7e4d2;
  background: var(--green-s);
  color: var(--green-d);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
}

.hero-comment-play:hover {
  background: #c8ebe0;
}

.hero-comment-play.is-playing {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.hero-comment-voice-label {
  font-size: 0.82rem;
  color: var(--ink);
  font-weight: 600;
}

.hero-comment-voice-dur {
  font-size: 0.72rem;
  color: var(--faint);
  font-weight: 500;
}

@media (max-width: 560px) {
  .hero-social {
    gap: 10px;
  }
  .hero-voice-label {
    display: none;
  }
  .hero-voice-list,
  .hero-comment-list {
    max-height: 220px;
  }
}
