/*
 * TTOnline Theme — Plugin Compatibility Styles
 * Chứa toàn bộ CSS giao diện của plugin (tất cả module).
 * Plugin chỉ lo logic/API — theme quyết định màu sắc, layout, typography.
 *
 * Nguồn gốc:
 *   modules/gemeni-vocab-pro-tts/assets/style.css
 *   modules/gemeni-dialogue-pro/assets/gemeni-dialogue-pro.css
 *   modules/gemeni-grammar-pro/assets/grammar.css           (đã nâng cấp dùng CSS vars)
 *   modules/gemeni-vocab-analysis/assets/gemeni-vocab-analysis.css
 *   modules/gvp-tap-viet/assets/tap-viet.css
 *   modules/pinyin-chart/assets/css/pinyin-chart.css        (đã nâng cấp dùng CSS vars)
 *
 * Cách sử dụng: theme enqueue file này; plugin KHÔNG enqueue CSS nữa.
 * Để ghi đè style của một module cụ thể: thêm rule vào file này (sau phần module đó).
 */

/* ============================================================
   SECTION 1 — VOCAB PRO TTS  (.gvp-pack, .gvp-group, .gvp-row…)
   ============================================================ */

/* ---------- Bridge token plugin → theme ---------- */
:root {
  --gvp-bg:            var(--bg, #ffffff);
  --gvp-card:          var(--surface, #ffffff);
  --gvp-surface:       color-mix(in oklab, var(--surface, #ffffff) 96%, transparent);
  --gvp-border:        var(--line, #e5e7eb);
  --gvp-border-light:  color-mix(in oklab, var(--line, #e5e7eb) 72%, transparent);
  --gvp-text:          var(--txt, #0f172a);
  --gvp-text-2:        var(--muted, #475569);
  --gvp-text-3:        color-mix(in oklab, var(--muted, #475569) 60%, transparent);
  --gvp-primary:       var(--brand, #0ea5e9);
  --gvp-primary-600:   color-mix(in oklab, var(--brand, #0ea5e9) 82%, black);
  --gvp-good:          #16a34a;
  --gvp-bad:           #dc2626;
  --gvp-radius:        16px;
  --gvp-shadow-sm:     0 8px 18px rgba(2,6,23,.06);
  --gvp-shadow:        0 12px 26px rgba(2,6,23,.10);
  --gvp-font:          inherit;
  --gvp-size-base:     clamp(14px, 1.6vw, 16px);
  --gvp-size-sm:       clamp(12px, 1.3vw, 14px);
  --gvp-size-lg:       clamp(18px, 2.5vw, 20px);
  --gvp-size-xl:       clamp(22px, 4vw, 28px);
}

/* Base container */
.gvp-pack {
  font-family:  var(--gvp-font);
  color:        var(--gvp-text);
  background:   var(--gvp-card);
  padding:      12px;
  border:       1px solid color-mix(in oklab, var(--gvp-border) 92%, transparent);
  border-radius: var(--gvp-radius);
  box-shadow:   var(--gvp-shadow-sm);
  font-size:    var(--gvp-size-base);
  margin-bottom: 20px;
}

.gvp-speed-btn.active {
  background:   var(--gvp-primary);
  color:        #fff;
  border-color: var(--gvp-primary);
}

/* Controls */
.gvp-controls {
  display: flex; align-items: center; gap: 12px;
  margin-block-end: 16px; flex-wrap: wrap;
}
.gvp-controls .gvp-play-all {
  appearance: none;
  background:   var(--gvp-primary); color: #fff;
  border:       1px solid var(--gvp-primary);
  border-radius: 12px;
  padding:      10px 16px; font-weight: 700; font-size: var(--gvp-size-sm);
  cursor:       pointer;
  box-shadow:   0 6px 18px color-mix(in oklab, var(--gvp-primary) 25%, transparent);
  transition:   transform .06s ease, box-shadow .2s ease, filter .15s ease;
}
.gvp-controls .gvp-play-all:hover  { filter: brightness(1.06); box-shadow: var(--gvp-shadow); }
.gvp-controls .gvp-play-all:active { transform: translateY(1px) scale(.99); }
.gvp-controls .gvp-play-all:disabled { opacity: .7; cursor: not-allowed; box-shadow: none; }
.gvp-controls label { font-size: var(--gvp-size-sm); color: var(--gvp-text-2); user-select: none; }

/* Card / group */
.gvp-group {
  margin-block: 12px 24px;
  padding:      12px;
  background:   var(--gvp-surface);
  border:       1px solid var(--gvp-border);
  border-radius: var(--gvp-radius);
  box-shadow:   var(--gvp-shadow-sm);
  transition:   box-shadow .18s ease, background .18s ease, transform .06s ease;
  will-change:  transform;
}
.gvp-group:hover { transform: translateY(-1px); box-shadow: var(--gvp-shadow); }

/* Row */
.gvp-row {
  display:   flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding:   10px 8px;
  border-block-end: 1px dashed var(--gvp-border-light);
  background: color-mix(in oklab, var(--gvp-card) 92%, transparent);
}
.gvp-group .gvp-row:last-child { border-block-end: none; }

.gvp-play svg, .gvp-play svg path,
.gvp-example .gvp-play svg,
.gvp-write-link svg { fill: currentColor; }
.gvp-play svg *, .gvp-example .gvp-play svg * { stroke: currentColor; }

.gvp-row .gvp-play {
  appearance: none; background: none; border: 1px solid transparent; cursor: pointer;
  padding: 6px; line-height: 0; color: var(--gvp-primary);
  border-radius: 12px;
  transition: color .15s ease, background .15s ease, transform .06s ease, border-color .15s ease;
}
.gvp-row .gvp-play:hover {
  color: var(--gvp-primary-600);
  background: color-mix(in oklab, var(--gvp-primary) 12%, transparent);
}
.gvp-row .gvp-play:active { transform: translateY(1px) scale(.98); }
.gvp-row .gvp-play:focus-visible {
  outline: none;
  border-color: var(--ring, var(--gvp-primary));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring, var(--gvp-primary)) 40%, transparent);
}
.gvp-row .gvp-play[disabled] { opacity: .7; cursor: progress; }

.gvp-spinner {
  display: inline-block; inline-size: 18px; block-size: 18px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: currentColor;
  animation: gvpSpin .8s linear infinite;
}
@keyframes gvpSpin { to { transform: rotate(360deg); } }

.gvp-playing {
  box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--gvp-primary) 18%, transparent);
  background: color-mix(in oklab, var(--gvp-primary) 7%, var(--gvp-surface));
}

.gvp-hanzi  { font-size: clamp(20px, 4.5vw, 26px); font-weight: 800; min-inline-size: 64px; letter-spacing: .01em; }
.gvp-pinyin { font-size: var(--gvp-size-sm); font-style: italic; color: var(--gvp-text-2); min-inline-size: 110px; }
.gvp-vi     { flex: 1; font-size: var(--gvp-size-base); color: var(--gvp-text); }

/* Practice link */
.gvp-write-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: .2em .5em; border-radius: 8px;
  background: color-mix(in oklab, var(--gvp-primary) 8%, transparent);
  text-decoration: none; color: var(--gvp-primary); font-size: 12px;
  border: 1px solid color-mix(in oklab, var(--gvp-primary) 20%, transparent);
  transition: background .15s ease, transform .06s ease, color .15s ease;
}
.gvp-write-link:hover {
  background: color-mix(in oklab, var(--gvp-primary) 14%, transparent);
  color: var(--gvp-primary-600);
}
.gvp-write-link:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--ring, var(--gvp-primary)) 45%, transparent);
  outline-offset: 2px;
}

/* Example block */
.gvp-example {
  margin-block-start: 8px; padding: 10px;
  font-size: var(--gvp-size-sm); line-height: 1.5; color: var(--gvp-text-2);
  background: color-mix(in oklab, var(--gvp-card) 94%, transparent);
  border: 1px solid var(--gvp-border-light); border-radius: 10px;
}
.gvp-example-zh     { font-weight: 700; font-size: clamp(15px, 2.6vw, 16px); margin-block-end: 4px; color: var(--gvp-text); }
.gvp-example-pinyin { font-style: italic; color: var(--gvp-text-3); margin-block-end: 6px; }
.gvp-example-vi     { display: flex; align-items: center; gap: 8px; }
.gvp-example .gvp-play { color: var(--gvp-primary); }

/* Usage block */
.gvp-usage {
  margin-block-start: 6px; font-size: 13px; color: var(--gvp-text);
  background: color-mix(in oklab, var(--gvp-surface) 92%, transparent);
  border: 1px solid var(--gvp-border); border-radius: 10px; padding: 8px;
}

/* Popup (player) */
.gvp-popup-backdrop {
  position: fixed; inset: 0;
  background: color-mix(in oklab, black 35%, transparent);
  display: none; align-items: center; justify-content: center; z-index: 9999;
  backdrop-filter: blur(1.5px);
}
.gvp-popup-backdrop.show { display: flex; animation: gvpFade .12s ease; }
@keyframes gvpFade { from { opacity: 0; } to { opacity: 1; } }

.gvp-popup {
  inline-size: min(720px, 92vw); background: var(--gvp-card);
  border: 1px solid var(--gvp-border); border-radius: 16px;
  box-shadow: var(--gvp-shadow); padding: 20px; position: relative;
}
.gvp-popup-close {
  position: absolute; inset-block-start: 10px; inset-inline-end: 12px;
  inline-size: 32px; block-size: 32px;
  border: 1px solid var(--gvp-border); background: transparent; color: inherit;
  border-radius: 10px; cursor: pointer; font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, border-color .15s ease;
}
.gvp-popup-close:hover { background: color-mix(in oklab, var(--gvp-text) 5%, transparent); }
.gvp-popup-close:focus-visible { outline: 2px solid color-mix(in oklab, var(--ring, var(--gvp-primary)) 45%, transparent); outline-offset: 2px; }

.gvp-popup-hanzi  { font-size: clamp(30px, 7vw, 44px); font-weight: 800; letter-spacing: .01em; color: var(--gvp-text); }
.gvp-popup-pinyin { margin-block-start: 6px; font-size: clamp(18px, 3.2vw, 22px); font-weight: 700; color: var(--gvp-primary); }
.gvp-popup-vi     { margin-block-start: 10px; font-size: var(--gvp-size-base); color: var(--gvp-text-2); }

.gvp-rate { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-block: 10px 6px; }
.gvp-rate .gvp-rate-val { font-weight: 700; }
.gvp-speed { display: flex; gap: 6px; flex-wrap: wrap; }
.gvp-speed button {
  padding: 8px 10px; border: 1px solid var(--gvp-border);
  border-radius: 10px; background: color-mix(in oklab, var(--gvp-card) 97%, transparent);
  color: var(--gvp-text); cursor: pointer; font-size: var(--gvp-size-sm);
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .06s ease;
}
.gvp-speed button:hover {
  background: color-mix(in oklab, var(--gvp-primary) 12%, transparent);
  border-color: color-mix(in oklab, var(--gvp-primary) 35%, transparent);
}
.gvp-speed button:active  { transform: translateY(1px) scale(.98); }
.gvp-speed button.active  { background: var(--gvp-primary); color: #fff; border-color: var(--gvp-primary); }

.gvp-popup-actions { margin-block-start: 12px; display: flex; gap: 10px; justify-content: flex-end; }
.gvp-popup-toggle {
  appearance: none; border: 1px solid var(--gvp-primary);
  color: #fff; background: #ef4444;
  border-radius: 12px; padding: 10px 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 14px color-mix(in oklab, #ef4444 35%, transparent);
  transition: transform .06s ease, box-shadow .2s ease, filter .15s ease;
}
.gvp-popup-toggle:hover  { filter: brightness(1.05); }
.gvp-popup-toggle:active { transform: translateY(1px) scale(.99); }

/* Load more */
.gvp-load-more {
  display: block; margin: 18px auto 6px; padding: 10px 18px;
  font-size: var(--gvp-size-sm); font-weight: 700;
  background-color: var(--gvp-primary); color: #fff;
  border: 1px solid var(--gvp-primary); border-radius: 12px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease, filter .15s ease;
  box-shadow: 0 6px 16px color-mix(in oklab, var(--gvp-primary) 22%, transparent);
}
.gvp-load-more:hover { filter: brightness(1.06); box-shadow: var(--gvp-shadow); }
.gvp-load-more:active { transform: translateY(1px); }
.gvp-load-more[disabled],
.gvp-load-more[aria-disabled="true"] {
  background-color: color-mix(in oklab, var(--gvp-text-2) 35%, transparent);
  border-color:     color-mix(in oklab, var(--gvp-text-2) 35%, transparent);
  color: #fff; cursor: not-allowed; transform: none; box-shadow: none;
}

/* Host theme text compat */
.entry-content .gvp-pack p,
.entry-content .gvp-pack td,
.entry-content .gvp-pack th { color: inherit; }

.gvp-sentinel { text-align: center; padding: 12px; color: var(--gvp-text-2); }

/* VI buttons */
.gvp-play-vi, .gvp-play-vi-example {
  border: none; background: color-mix(in oklab, var(--gvp-primary) 12%, transparent);
  color: var(--gvp-primary); border-radius: 8px; padding: 4px; cursor: pointer;
}
.gvp-play-vi:hover, .gvp-play-vi-example:hover {
  background: color-mix(in oklab, var(--gvp-primary) 18%, transparent);
}

/* ============================================================
   SECTION 2 — DIALOGUE PRO  (.gvp-dialogue, .gdp-cloze)
   ============================================================ */

.gvp-dialogue, .gdp-cloze { accent-color: var(--brand); }
.gvp-dialogue * { box-sizing: border-box; }
.gvp-dialogue .visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(1px,1px,1px,1px); white-space: nowrap;
}

.gvp-dialogue {
  background:   var(--surface);
  border:       1px solid var(--line);
  border-radius: 16px;
  padding:      14px; margin: 16px 0;
  transition:   box-shadow .2s ease, border-color .2s ease, transform .12s ease;
}
.gvp-dialogue:hover {
  box-shadow:   0 12px 26px rgba(2,6,23,.10);
  border-color: color-mix(in oklab, var(--brand) 18%, var(--line));
  transform:    translateY(-1px);
}
.gvp-dialogue:focus-within {
  outline: none;
  box-shadow:   0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent), 0 12px 26px rgba(2,6,23,.10);
  border-color: color-mix(in oklab, var(--ring) 55%, var(--line));
}

.gvp-dialogue .gvp-controls {
  display: flex; gap: 10px; align-items: center; justify-content: flex-start;
  flex-wrap: wrap; margin: 4px 0 10px;
}
.gvp-dialogue .gvp-play-all {
  background: var(--brand); color: #fff; border: 0;
  border-radius: 12px; padding: 10px 12px; cursor: pointer; font-weight: 600;
}
.gvp-dialogue .gvp-play-all:hover { filter: brightness(.95); }
.gvp-dialogue .gvp-play-all:focus-visible { outline: 3px solid color-mix(in oklab, var(--ring) 40%, transparent); outline-offset: 2px; }

.gvp-dialogue .gvp-turns { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.gvp-dialogue .gvp-turn {
  position: relative; display: block;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 10px 10px 52px;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .12s ease;
}
.gvp-dialogue .gvp-turn:hover { box-shadow: 0 8px 20px rgba(2,6,23,.06); transform: translateY(-1px); }
.gvp-dialogue .gvp-turn.is-current {
  border-color: color-mix(in oklab, var(--brand) 30%, var(--line));
  background:   linear-gradient(0deg, color-mix(in oklab, var(--brand) 10%, transparent), transparent 40%), var(--surface);
  box-shadow:   0 10px 22px rgba(2,6,23,.10);
}
.gvp-dialogue .gvp-turn::before {
  content: attr(data-ab);
  position: absolute; left: 12px; top: 12px; width: 26px; height: 26px; border-radius: 999px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--chip-bg); color: var(--chip-ink); border: 1px solid var(--line);
}
.gvp-dialogue .gvp-turn[data-ab="A"]::before {
  background: color-mix(in oklab, var(--brand) 24%, var(--chip-bg));
  color: #fff; border-color: color-mix(in oklab, var(--brand) 30%, var(--line));
}
.gvp-dialogue .gvp-turn[data-ab="B"]::before {
  background: color-mix(in oklab, rebeccapurple 24%, var(--chip-bg));
  color: #fff; border-color: color-mix(in oklab, rebeccapurple 30%, var(--line));
}
.gvp-dialogue .gvp-turn-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.gvp-dialogue .gvp-speaker { font-weight: 650; font-size: 15px; }
.gvp-dialogue .gvp-play {
  --_size: 28px; width: var(--_size); height: var(--_size);
  display: inline-grid; place-items: center; line-height: 1;
  background: transparent; color: var(--txt); border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer; font-size: 13px; padding: 0;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.gvp-dialogue .gvp-play:hover {
  background: rgba(14,165,233,.12);
  border-color: color-mix(in oklab, var(--brand) 28%, var(--line));
}
.gvp-dialogue .gvp-play:active { transform: translateY(1px) scale(.98); }
.gvp-dialogue .gvp-play:focus-visible { outline: 3px solid color-mix(in oklab, var(--ring) 40%, transparent); outline-offset: 2px; }

.gvp-dialogue .gvp-zh     { font-size: 16px; line-height: 1.5; }
.gvp-dialogue .gvp-pinyin { color: var(--muted); font-size: 13px; margin-top: 2px; }
.gvp-dialogue .gvp-vi     { font-size: 14px; color: var(--muted); }

.gvp-dialogue .gvp-zh a.gdp-hanzi-link {
  text-decoration: none; background: var(--chip-bg); color: var(--chip-ink);
  border: 1px solid var(--line); border-radius: 999px; padding: .5px 8px;
  display: inline-flex; align-items: center; gap: 6px;
}
.gvp-dialogue .gvp-zh a.gdp-hanzi-link:hover {
  filter: brightness(.97);
  border-color: color-mix(in oklab, var(--brand) 20%, var(--line));
}
.gvp-dialogue .gvp-zh a.gdp-hanzi-link:focus-visible { outline: 3px solid color-mix(in oklab, var(--ring) 40%, transparent); outline-offset: 2px; }

.gvp-dialogue .gvp-audio { width: 100%; margin-top: 8px; border-radius: 10px; background: var(--surface); }

/* Cloze */
.gdp-cloze {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; margin: 16px 0;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.gdp-cloze:hover { box-shadow: 0 12px 26px rgba(2,6,23,.10); border-color: color-mix(in oklab, var(--brand) 18%, var(--line)); }
.gdp-cloze h3 { margin: 0 0 10px; font-size: 18px; line-height: 1.3; }
.gdp-cloze .cloze-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.gdp-cloze .score { color: var(--muted); font-size: 13px; margin-left: auto; }
.gdp-cloze .turn { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; background: var(--surface); }
.gdp-cloze .turn .meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.gdp-cloze .turn .speaker { font-weight: 650; font-size: 14px; }
.gdp-cloze .turn .btn-audio { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; cursor: pointer; }
.gdp-cloze .turn .btn-audio:hover { background: rgba(14,165,233,.10); border-color: color-mix(in oklab, var(--brand) 28%, var(--line)); }
.gdp-cloze .turn .line { font-size: 15px; line-height: 1.8; word-break: break-word; }
.gdp-cloze .turn .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.gdp-cloze .turn input.cloze.input {
  min-width: 110px; max-width: 100%; width: auto;
  padding: 6px 8px; margin: 0 4px 2px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--txt);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.gdp-cloze .turn input.cloze.input:focus {
  outline: none;
  border-color: color-mix(in oklab, var(--ring) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 35%, transparent);
}
.gdp-cloze { --ok: #16a34a; --bad: #dc2626; }
.gdp-cloze .turn input.ok  { border-color: color-mix(in oklab, var(--ok) 60%, var(--line)); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 35%, transparent); }
.gdp-cloze .turn input.bad { border-color: color-mix(in oklab, var(--bad) 60%, var(--line)); box-shadow: 0 0 0 3px color-mix(in oklab, var(--bad) 35%, transparent); }
.gdp-cloze .btn-show  { background: transparent; color: var(--txt); border: 1px solid var(--line); }
.gdp-cloze .btn-show:hover  { background: rgba(14,165,233,.08); }
.gdp-cloze .btn-reset { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.gdp-cloze .btn-reset:hover { background: rgba(2,6,23,.04); }

/* ============================================================
   SECTION 3 — GRAMMAR PRO  (.ggp-pack, .ggp-item…)
   Nâng cấp từ màu cứng → CSS variables của theme
   ============================================================ */

.ggp-pack {
  border:       1px solid var(--line);
  padding:      12px;
  border-radius: 12px;
  background:   var(--surface);
}
.ggp-controls { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.ggp-play-all,
.ggp-load-more {
  padding:      6px 10px; border-radius: 8px;
  border:       1px solid var(--line);
  background:   color-mix(in oklab, var(--surface) 96%, var(--line) 4%);
  color:        var(--txt);
  cursor:       pointer;
  transition:   background .15s ease, border-color .15s ease;
}
.ggp-play-all:hover, .ggp-load-more:hover { background: color-mix(in oklab, var(--brand) 8%, var(--surface)); }
.ggp-list   { display: grid; gap: 12px; }
.ggp-item   { padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.ggp-row    { display: flex; align-items: center; gap: 8px; }
.ggp-play   { border: 0; background: var(--chip-bg); border-radius: 6px; padding: 4px 8px; cursor: pointer; color: var(--chip-ink); }
.ggp-play:hover { filter: brightness(.95); }
.ggp-pattern   { font-weight: 700; }
.ggp-structure { color: var(--badge-ink); background: var(--badge-bg); padding: 2px 6px; border-radius: 6px; }
.ggp-level     { background: color-mix(in oklab, #ef4444 12%, var(--surface)); color: #b91c1c; border-radius: 6px; padding: 2px 6px; font-size: 12px; }
.ggp-example-zh { margin-top: 6px; font-weight: 600; }
.ggp-example-py { color: var(--muted); }
.ggp-example-vi { color: var(--txt); }
.ggp-notes      { margin-top: 6px; color: var(--muted); }

/* ============================================================
   SECTION 4 — VOCAB ANALYSIS  (.gva-*, .gva-hw-*, .gva-write-*)
   ============================================================ */

:root {
  --tto-bg:          var(--bg);
  --tto-card:        var(--surface);
  --tto-text:        var(--txt);
  --tto-muted:       var(--muted);
  --tto-border:      var(--line);
  --tto-shadow:      0 12px 26px rgba(2,6,23,.10);
  --tto-primary:     var(--brand);
  --tto-primary-600: var(--brand);
  --tto-primary-700: color-mix(in oklab, var(--brand) 85%, black);
  --tto-primary-300: color-mix(in oklab, var(--brand) 35%, white);
  --tto-ring:        var(--ring);
  --tto-success:     #059669;
  --tto-danger:      #ef4444;
  --tto-radius:      16px;
  --tto-radius-lg:   24px;
  --tto-gap:         12px;
  --tto-maxw:        1200px;
  --tto-pad:         16px;
  --tto-pad-sm:      10px;
}

.gva-container { max-width: var(--tto-maxw); margin: 24px auto; padding: 0 16px; }
.gva-card      { padding: var(--tto-pad); }
.gva-h         { font-size: 28px; margin: 0 0 10px; color: var(--tto-text); }
.gva-meta      { color: var(--tto-muted); margin-bottom: 12px; }
.gva-sec       { margin-top: 18px; }
.gva-sec h3    { margin: 0 0 8px; font-size: 18px; color: var(--tto-text); }
.gva-list      { margin: 6px 0 0 18px; }
.gva-badge     { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--badge-bg); color: var(--badge-ink); font-size: 12px; margin-right: 6px; }
.gva-foot      { margin-top: 20px; color: var(--tto-muted); font-size: 12px; }
.gva-err       { background: color-mix(in oklab, var(--tto-danger) 6%, #fff); border: 1px solid color-mix(in oklab, var(--tto-danger) 35%, transparent); color: color-mix(in oklab, var(--tto-danger) 75%, black); border-radius: 8px; padding: 10px; margin-top: 12px; }

/* Hanzi grid */
.gva-hw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: var(--tto-gap); }
.gva-hw-tile {
  display: block; text-decoration: none; color: inherit; position: relative;
  background: var(--tto-card); border: 1px solid var(--tto-border); border-radius: var(--tto-radius);
  padding: var(--tto-pad-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.gva-hw-tile:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(2,6,23,.10); border-color: var(--tto-primary-300); }
.gva-hw-tile:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--tto-ring) 40%, transparent); }
.gva-hw-box     { width: 140px; height: 140px; margin: 0 auto; }
.gva-hw-caption { text-align: center; margin-top: 6px; font-weight: 600; color: var(--tto-text); }
.gva-hw-hint    { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #334155; opacity: 0; transition: opacity .2s; }
.gva-hw-tile:hover .gva-hw-hint { opacity: 1; }
.gva-hw-tile.is-animating { box-shadow: 0 0 0 2px var(--tto-primary-300) inset; }

/* Write modal */
.gva-write-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.6); display: none; z-index: 9999; }
.gva-write-modal { max-width: 720px; margin: 40px auto; background: var(--tto-card); border-radius: var(--tto-radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: var(--tto-pad); }
.gva-write-close { float: right; font-size: 22px; line-height: 1; border: 0; background: transparent; cursor: pointer; color: var(--tto-muted); }
.gva-write-top   { display: flex; align-items: center; gap: 12px; margin: 6px 0 12px; }
.gva-write-meta  { color: var(--tto-muted); }
.gva-write-actions { margin-left: auto; display: flex; gap: 8px; }
.gva-write-stage   { padding: 8px 0 6px; }
#gva-hw-main { width: 360px; height: 360px; margin: 0 auto; }
.gva-write-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }

/* Buttons */
.gva-btn { all: unset; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 12px; padding: 10px 14px; background: var(--surface); color: var(--txt); border: 1px solid var(--line); }
.gva-btn:hover         { box-shadow: 0 6px 16px rgba(2,6,23,.10); }
.gva-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent); }
.gva-btn--primary      { background: var(--brand); color: #fff; border-color: transparent; }
.gva-btn--primary:hover { filter: brightness(.95); }
.gva-btn--success      { background: var(--tto-success); color: #fff; border-color: transparent; }

.gva-wrap      { max-width: var(--tto-maxw); margin: 24px auto; padding: 0 16px; }
.gva-cand, .gva-nf-card { border: 1px solid var(--tto-border); border-radius: 16px; padding: 16px; background: var(--tto-card); margin: 10px 0; }

/* ============================================================
   SECTION 5 — TAP VIET  (.gvp-tv-*, .gvp-write-*, .gvp-infobar)
   ============================================================ */

:root {
  --gvp-radius-sm: 8px;
  --gvp-shadow-lg: 0 20px 60px rgba(2,6,23,.18);
  --gvp-blur:      8px;
  --gvp-transition: .22s cubic-bezier(.2,.6,.2,1);
}

.tap-viet-page .container { padding-top: 0; padding-bottom: 0; }
#gvp-tv-list.grid          { margin-top: 8px; }

.gvp-tv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 12px; }
.gvp-tv-item {
  padding: 14px; border: 1px solid var(--line); border-radius: var(--gvp-radius);
  background: var(--surface); box-shadow: var(--gvp-shadow-sm);
  display: flex; flex-direction: column; gap: 8px;
  transition: transform var(--gvp-transition), box-shadow var(--gvp-transition);
}
.gvp-tv-item:hover { transform: translateY(-2px); box-shadow: var(--gvp-shadow-lg); }
.gvp-tv-hz       { font-size: 30px; cursor: pointer; line-height: 1; }
.gvp-tv-hz:hover { text-decoration: underline; }
.gvp-tv-meta     { color: var(--muted); font-size: 13px; text-align: center; margin-top: 8px; }

.gvp-write-backdrop {
  position: fixed; inset: 0;
  background: rgba(2,6,23,.55);
  -webkit-backdrop-filter: blur(var(--gvp-blur)); backdrop-filter: blur(var(--gvp-blur));
  display: none; align-items: center; justify-content: center; z-index: 9999;
  opacity: 0; visibility: hidden;
  transition: opacity var(--gvp-transition), visibility var(--gvp-transition);
}
.gvp-write-backdrop.show { display: flex; opacity: 1; visibility: visible; }
.gvp-write-modal {
  width: min(92vw, 560px); background: var(--surface); color: var(--txt);
  border-radius: var(--gvp-radius); padding: 14px 14px 16px;
  box-shadow: var(--gvp-shadow-lg); position: relative;
  transform: translateY(10px);
  transition: transform var(--gvp-transition), box-shadow var(--gvp-transition);
}
.gvp-write-backdrop.show .gvp-write-modal { transform: translateY(0); }
.gvp-write-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  border: 1px solid var(--line); background: transparent; color: var(--txt);
  border-radius: 50%; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--gvp-transition), transform var(--gvp-transition);
}
.gvp-write-close:hover { background: rgba(148,163,184,.12); transform: scale(1.05); }
.gvp-write-top  { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.gvp-write-meta { font-weight: 600; color: var(--muted); }
#gvp-big-char   { font-size: 52px; line-height: 1; font-weight: 800; letter-spacing: .02em; }
.gvp-write-stage { margin-top: 6px; }
#gvp-hw         { width: 340px; height: 340px; margin: 0 auto; }

.gvp-write-actions { display: flex; gap: 8px; align-items: center; }
.gvp-write-actions.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--gvp-transition), visibility var(--gvp-transition); }
.gvp-write-actions button {
  min-width: 40px; height: 36px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--txt);
  border-radius: var(--gvp-radius-sm); cursor: pointer;
  transition: background var(--gvp-transition), transform var(--gvp-transition), border-color var(--gvp-transition);
}
.gvp-write-actions button:hover { filter: brightness(.97); transform: translateY(-1px); }
.gvp-write-actions button:active { transform: translateY(0); }
.gvp-write-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.gvp-write-controls button {
  padding: 8px 12px; border: 1px solid var(--line);
  background: linear-gradient(263deg, #fcbdbd, #2986fa); color: var(--txt);
  border-radius: var(--gvp-radius-sm); cursor: pointer;
  transition: box-shadow var(--gvp-transition), transform var(--gvp-transition);
}
.gvp-write-controls button:hover  { box-shadow: var(--gvp-shadow); transform: translateY(-1px); }
.gvp-write-controls button:active { transform: translateY(0); }

.gvp-infobar       { margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted); }
.gvp-infobar .dot  { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; margin: 0 2px; opacity: .6; animation: gvpblink 1.2s infinite; }
.gvp-infobar.loading .dot:nth-child(2) { animation-delay: .2s; }
.gvp-infobar.loading .dot:nth-child(3) { animation-delay: .4s; }
@keyframes gvpblink { 0% { opacity: .2; } 50% { opacity: 1; } 100% { opacity: .2; } }

/* ============================================================
   SECTION 6 — PINYIN CHART  (.pac-wrap, .pac-*, .pc-*)
   Nâng cấp từ màu cứng → CSS variables của theme
   ============================================================ */

.pac-wrap {
  background:   var(--surface);
  color:        var(--txt);
  padding:      16px; border-radius: 14px;
  border:       1px solid var(--line);
  max-width:    980px; margin: 0 auto;
  font-family:  inherit;
}

/* Topbar */
.pac-topbar {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.pac-search {
  flex: 1; max-width: 360px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; font-size: 15px;
  background: var(--bg); color: var(--txt);
}
.pac-search:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 35%, transparent); }
.pac-legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.pac-legend .dot { width: 10px; height: 10px; display: inline-block; border-radius: 999px; margin-right: 6px; }
.pac-legend .ok   { background: #16a34a; }
.pac-legend .miss { background: var(--line); }

/* Tabs */
.pc-filters { margin-top: 4px; }
.pc-tab {
  flex: 1; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--txt);
  cursor: pointer; font-size: 14px; transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.pc-tab--active { background: var(--txt); color: var(--bg); border-color: var(--txt); }

/* Sections */
.pac-section    { margin: 16px 0; }
.pac-section h3 { margin: 8px 0 12px; font-size: 18px; color: var(--txt); }

/* Grids */
.pac-grid          { display: grid; gap: 10px; }
.pac-grid.finals   { grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); }
.pac-grid.initials { grid-template-columns: repeat(auto-fill, minmax(56px,1fr)); }

/* Cards */
.pac-card      { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.pac-card .head { font-weight: 700; font-size: 18px; margin-bottom: 8px; }
.pac-card .tones { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.pac-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line); background: color-mix(in oklab, var(--surface) 96%, var(--line) 4%);
  color: var(--txt); cursor: pointer; transition: background .2s ease, box-shadow .15s ease; font-size: 15px;
}
.pac-btn.initial { height: 48px; font-weight: 700; }
.pac-btn.ok   { background: color-mix(in oklab, #16a34a 8%, var(--surface)); border-color: #bbf7d0; }
.pac-btn.ok:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(2,6,23,.06); }
.pac-btn.miss { background: var(--surface); color: var(--muted); }
.pac-btn[disabled] { cursor: not-allowed; opacity: .6; }
.pac-btn.playing   { outline: 2px solid #16a34a; }

/* Initial detail card */
.pac-initial-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 16px 0; }
.pac-initial-card h3 { font-size: 20px; margin: 0 0 8px; }
.pac-row       { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.pac-row .lab  { font-weight: 600; width: 60px; flex-shrink: 0; }
.pac-row .desc { font-size: 14px; color: var(--muted); }

/* Guide tab */
.pac-guide h2 { font-size: 20px; margin: 14px 0 8px; }
.pac-guide p  { margin: 4px 0; font-size: 15px; color: var(--txt); }

/* Empty + footer */
.pac-empty      { padding: 12px; color: var(--muted); font-size: 14px; }
.pc-footer-note { margin-top: 12px; font-size: 12px; color: var(--muted); }

/* Radical badges row (gvp-radicals inline badges on vocab rows) */
.gvp-rad-badges { margin: .4rem 0 .6rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.gvp-rad-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .5rem; border-radius: 999px;
  border: 1px solid var(--line); background: color-mix(in oklab, var(--surface) 96%, var(--line) 4%);
  text-decoration: none; color: var(--txt); font-size: 12px; line-height: 1;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.gvp-rad-badge:hover { border-color: color-mix(in oklab, var(--brand) 25%, var(--line)); box-shadow: 0 4px 10px rgba(2,6,23,.08); }
.gvp-rad-badge .glyph { font-size: 16px; font-weight: 600; }

/* Radical badge (shortcode index) */
.gvp-radical-badge {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  padding: .35rem .6rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: var(--txt);
  transition: box-shadow .15s ease, transform .1s ease;
}
.gvp-radical-badge:hover { box-shadow: 0 6px 16px rgba(2,6,23,.10); transform: translateY(-1px); }
.gvp-radical-badge .glyph { font-size: 18px; line-height: 1; }
.gvp-radical-badge .label { font-size: 12px; color: var(--muted); }

/* Radical hero (single radical page) */
.gvp-radical-hero {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); margin-bottom: 12px;
}
.gvp-radical-hero .glyph { font-size: 48px; line-height: 1; }
.gvp-radical-hero .meta  { font-size: 14px; color: var(--muted); }

/* Radical AI description block */
.gvp-radical-ai {
  margin-top: 12px; padding: 12px;
  border: 1px dashed color-mix(in oklab, var(--brand) 35%, var(--line));
  background: color-mix(in oklab, var(--brand) 5%, var(--surface));
  border-radius: 12px;
}

/* ============================================================
   RESPONSIVE (shared across all sections)
   ============================================================ */
@media (max-width: 560px) {
  .gvp-group    { padding: 10px; }
  .gvp-row      { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px; }
  .gvp-hanzi    { font-size: clamp(18px, 7vw, 22px); min-inline-size: auto; }
  .gvp-pinyin   { min-inline-size: auto; }
  .gvp-example  { padding-inline-start: 12px; }
  .gvp-dialogue { padding: 12px; }
  .gvp-dialogue .gvp-turn { padding-left: 48px; }
  .gdp-cloze .turn input.cloze.input { min-width: 90px; }
}
@media (max-width: 480px) {
  .pac-grid.finals { grid-template-columns: repeat(2,1fr); }
  .pac-row { flex-direction: column; gap: 4px; }
  .pac-row .lab { width: auto; }
}

/* ============================================================
   ACCESSIBILITY & MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .gvp-pack *, .gvp-dialogue *, .gdp-cloze *, .gvp-tv-item,
  .pac-btn, .gva-hw-tile, .gva-btn { transition: none !important; animation: none !important; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .gvp-pack      { box-shadow: none; border: none; padding: 0; }
  .gvp-controls, .gvp-play, .gvp-popup-backdrop, .gvp-load-more, .gvp-write-link { display: none !important; }
  .gvp-group     { break-inside: avoid; border: 1px solid #ddd; background: #fff; }
  .gvp-dialogue .gvp-play, .gvp-dialogue .gvp-play-all,
  .gdp-cloze .btn, .gdp-cloze .btn-audio, .gvp-dialogue .gvp-audio { display: none !important; }
  .gva-write-backdrop { display: none !important; }
  .gva-btn { display: none !important; }
}
