.wchip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.15rem 0.5rem;
  margin: 0.15rem 0.2rem;
  font-size: 0.92rem;
}

.wchip b {
  font-size: 1.05rem;
}

.wchip-tl {
  color: var(--accent-deep);
}

textarea,
#vb-in,
#gr-in {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfd;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 6.5rem;
  resize: vertical;
}

#vb-in,
#gr-in {
  min-height: 0;
  max-width: 32rem;
}

textarea:focus,
#vb-in:focus,
#gr-in:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
  background: #fff;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

/* 文法分類 17 个：細螢幕愛換逝，袂使撐開頁面（390px 原本闊 500px） */
#gr-note-cats {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  border-radius: var(--radius-sm);
}

.seg-btn {
  border: 0;
  background: var(--card);
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-soft);
}

.seg-btn.is-active {
  background: var(--accent-deep);
  color: var(--accent-ink);
}

.hints {
  margin-top: 0.8rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.6rem;
  font-size: 0.92rem;
}

.hints .hint-title {
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.hints ul {
  margin: 0.3rem 0 0;
  padding-inline-start: 1.2rem;
}

.hints code {
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 0.05em 0.4em;
  border-radius: 6px;
}

.hints details.calque {
  margin-top: 0.5rem;
}

.hints summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 600;
}


/* —— 文法檢查佮教學（轉換頁 #cv-gram） —— */
.hints .chk-list li {
  margin: 0.25rem 0;
  line-height: 1.75;
}

.chk-han {
  /* 建議檢查，毋是判錯：虛線底標「看這搭」，無用紅色 */
  border-bottom: 2px dotted var(--ink-soft);
}

.chk-n {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.chk-note {
  margin-left: 0.4rem;
  font-size: 0.75rem;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: none;
  border-radius: 6px;
  padding: 0.05rem 0.45rem;
  cursor: pointer;
}

.gram-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.gram-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.55rem;
  font-size: 0.88rem;
  cursor: pointer;
}

.gram-chip:hover {
  border-color: var(--accent);
}

.gram-chip b {
  font-size: 0.98rem;
}

.gram-chip-t {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.gr-note.flash {
  animation: gr-flash 1.5s ease 2;
}

@keyframes gr-flash {
  0%,
  100% {
    background: transparent;
  }
  30% {
    background: #fff3c4;
  }
}
.dict-link {
  font-size: 0.72rem;
  color: var(--accent-deep);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.05rem 0.4rem;
  margin-inline-start: 0.3rem;
  vertical-align: middle;
  white-space: nowrap;
}

.dict-link:hover {
  background: var(--accent-soft);
}

.anno.word.rime:hover {
  background: #fdf0ee;
}

.row {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  margin-block: 0.7rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.55rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn.primary {
  background: var(--accent-deep);
  color: var(--accent-ink);
  border-color: transparent;
}

.btn.primary:hover {
  background: #095f57;
}

.btn-ghost {
  border: 0;
  background: transparent;
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

.opt {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.hint {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.out-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr;
}

.out-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  background: linear-gradient(180deg, #fdfefe, #f7faf9);
}

.out-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.out-head h3 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.roman {
  display: block;
  font-size: 1.3rem;
  line-height: 1.95;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  min-height: 2.6em;
  margin-top: 0.25rem;
}

.anno {
  margin-top: 0.9rem;
  line-height: 2.15;
  overflow-wrap: anywhere;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
}

.anno.word {
  border: 0;
  background: none;
  padding: 0 0.12em;
  cursor: pointer;
  border-bottom: 2px dotted var(--accent);
  font-size: 1.12rem;
  border-radius: 4px;
  transition: background 0.12s ease;
}

.anno.word:hover {
  background: var(--accent-soft);
}

.anno.word.rime {
  border-bottom: 2px dotted var(--miss);
}

.rimetag {
  display: inline-block;
  font-size: 0.66rem;
  color: var(--miss);
  border: 1px dashed var(--miss);
  border-radius: 5px;
  padding: 0 0.3rem;
  margin-inline-start: 0.35rem;
  vertical-align: middle;
  white-space: nowrap;
}

.anno.miss {
  color: var(--miss);
  font-weight: 700;
}

.ex-cell .ex {
  font-size: 0.92rem;
  line-height: 1.45;
  padding-block: 0.2rem;
}

.ex-cell .ex + .ex {
  border-top: 1px dashed var(--line);
  margin-top: 0.3rem;
  padding-top: 0.3rem;
}


.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

#vb-tbl,
#gr-tbl {
  width: 100%;
  border-collapse: collapse;
}

#vb-tbl th,
#vb-tbl td,
#gr-tbl th,
#gr-tbl td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

#vb-tbl th,
#gr-tbl th {
  position: sticky;
  top: 0;
  background: #f7f9fa;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.gr-notes {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.7rem;
}

.gr-note {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem 0.55rem;
  background: linear-gradient(180deg, #fdfefe, #f7faf9);
  /* 28 篇筆記：畫面外的先免排版（字型載入時逐擺重排全頁，TBT） */
  content-visibility: auto;
  contain-intrinsic-size: auto 520px;
}

.gr-note h3 {
  margin: 0.2rem 0 0.4rem;
  font-size: 1.06rem;
}

.gr-note p {
  font-size: 0.93rem;
  line-height: 1.78;
  margin: 0.3rem 0;
}

.gr-cat {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--accent-deep);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
}

.gr-ex {
  margin: 0.5rem 0;
  padding-inline-start: 0.8rem;
  border-inline-start: 3px solid var(--accent-soft);
}

.gr-ex .han {
  font-weight: 700;
  font-size: 1.02rem;
}

.gr-ex .tl {
  color: var(--accent-deep);
}

.gr-ex .hua {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.gr-refs {
  border-top: 1px dashed var(--line);
  margin-top: 0.6rem;
  padding-top: 0.45rem;
}

.gr-src-tag {
  display: inline-block;
  margin-inline-start: 0.45rem;
  font-size: 0.68rem;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 0.3rem;
  vertical-align: middle;
}

.gr-refs a {
  color: var(--accent-deep);
}

#vb-tbl tbody tr:nth-child(even),
#gr-tbl tbody tr:nth-child(even) {
  background: #fafbfc;
}

#vb-tbl td.w,
#gr-tbl td.w {
  font-weight: 700;
  white-space: nowrap;
}

/* .roman（轉換輸出）是 block＋anywhere 斷字：表格內愛轉做 table-cell、照詞斷，
   若無欄會擠甲 40px 闊、逝逝 180px 懸 */
#vb-tbl td.roman,
#gr-tbl td.roman {
  display: table-cell;
  min-height: 0;
  margin: 0;
  font-size: inherit;
  line-height: inherit;
  overflow-wrap: break-word;
  min-width: 7em;
}

#gr-tbl td.gr-id {
  white-space: nowrap;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

#gr-group {
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfd;
  max-width: 22rem;
}

.gr-sub {
  margin: 1.4rem 0 0.3rem;
  font-size: 1.02rem;
  color: var(--accent-deep);
}

.gr-snips {
  margin: 0.3rem 0;
  padding-inline-start: 1.2rem;
  font-size: 0.95rem;
  line-height: 1.9;
}

.gr-snips a {
  color: var(--accent-deep);
  font-weight: 600;
}

@media (min-width: 48rem) {
  .out-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* 轉換頁語音「🔊 唸予我聽」（預設關） */
.tts {
  margin: 0.75rem 0;
}
.tts-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0.5rem 0;
}
.tts-about {
  font-size: 0.9rem;
  color: var(--muted, #555);
}
.tts-about summary {
  cursor: pointer;
}
.tts-about ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}
/* 轉換輸出逐句右上角的細 ▶（文字由 CSS 畫，複製輸出袂濫著） */
.tool-app .cv-say {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  top: -0.55em; /* 右上角：比字的頂懸較懸 */
  width: 1.2rem;
  height: 1.2rem;
  margin: 0 0.2rem 0 0.05rem;
  padding: 0 0 0 0.1rem; /* ▶ 視覺置中 */
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--surface, #fff);
  color: var(--brand, #0b6f55);
  font-family: system-ui, sans-serif;
  font-size: 0.55rem;
  line-height: 1;
  vertical-align: baseline;
  cursor: pointer;
  opacity: 0.8;
}
.tool-app .cv-say::before {
  content: "\25B6\FE0E"; /* ▶ 文字款（毋是 emoji） */
}
.tool-app .cv-say.is-playing::before {
  content: "\25A0"; /* ■ */
  padding-right: 0.1rem;
}
.tool-app .cv-say:hover,
.tool-app .cv-say:focus-visible,
.tool-app .cv-say.is-playing {
  opacity: 1;
}
/* 唸的時詞光（時間是推算：照短語聲音長度按字母數分） */
.tool-app .cv-w,
.tool-app .cv-sent {
  border-radius: var(--radius-sm, 4px);
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}
.tool-app .cv-w.is-speaking,
.tool-app .cv-sent.is-speaking {
  background: color-mix(in srgb, var(--brand, #0b6f55) 20%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand, #0b6f55) 20%, transparent);
}
@media (prefers-reduced-motion: reduce) {
  .tool-app .cv-w,
  .tool-app .cv-sent { transition: none; }
}
