/* Pinyin - giao diện. Màu nền, chữ, viền lấy theo biến của Lịch Việt. */
.py-root {
  --py-t1: #E24B4A; --py-t2: #BA7517; --py-t3: #639922; --py-t4: #378ADD;
  --py-bg: var(--bg, #fbf6ee); --py-surface: var(--surface, #fff); --py-soft: var(--soft, #f6ecdc);
  --py-ink: var(--ink, #2a1f1a); --py-muted: var(--muted, #7b6b60); --py-line: var(--line, #eadfce);
  --py-acc: var(--red, #a61e22); --py-acc-ink: var(--red-ink, #fff); --py-off: var(--off, #c0262c);
  color: var(--py-ink);
}
.py-root *, .py-root *::before, .py-root *::after { box-sizing: border-box; }
.py-t1 { color: var(--py-t1); } .py-t2 { color: var(--py-t2); } .py-t3 { color: var(--py-t3); } .py-t4 { color: var(--py-t4); }
.py-t5 { color: var(--py-muted); }
.py-root span[class^="py-t"] { font-weight: 600; }

.py-title { font-size: 1.1rem; margin: 6px 0 10px; }
.py-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--py-muted); margin: 18px 0 8px; font-weight: 700; }
.py-p { margin: 8px 0 12px; font-size: .95rem; }
.py-note { color: var(--py-muted); font-size: .84rem; margin: 10px 0 0; }
.py-leg { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; margin: 0 0 12px; }

.py-btn {
  min-height: 44px; padding: 0 14px; border: 1px solid var(--py-line); border-radius: 12px;
  background: var(--py-soft); color: var(--py-ink); font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
}
.py-btn:active, .py-opt:active, .py-lv:active { transform: scale(.98); }
.py-pri { background: var(--py-acc); border-color: var(--py-acc); color: var(--py-acc-ink); }
.py-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.py-end { margin: 20px 0 4px; }
.py-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 6px; }
.py-cnt { color: var(--py-muted); font-size: .9rem; font-weight: 600; }

.py-levels { display: flex; flex-direction: column; gap: 8px; }
.py-lv {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px;
  border: 1px solid var(--py-line); border-radius: 16px; background: var(--py-surface); color: inherit; font: inherit; cursor: pointer;
}
.py-lv[aria-disabled="true"] { opacity: .5; }
.py-n { flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--py-soft); font-weight: 700; }
.py-lt { flex: 1; min-width: 0; }
.py-lt b { display: block; }
.py-lt small { display: block; color: var(--py-muted); font-size: .82rem; }
.py-st { flex: none; font-size: .82rem; color: var(--py-muted); }
.py-ok { color: var(--py-t3); font-weight: 700; }
.py-set { margin-top: 18px; padding: 12px 14px; border: 1px solid var(--py-line); border-radius: 16px; background: var(--py-surface); }
.py-line { display: flex; justify-content: space-between; gap: 12px; font-size: .95rem; }
.py-line span:first-child { color: var(--py-muted); }

.py-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.py-c { background: var(--py-surface); border: 1px solid var(--py-line); border-radius: 14px; padding: 10px 12px; }
.py-wide { margin-top: 10px; }
.py-big { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.py-nm { font-size: .84rem; color: var(--py-muted); margin: 2px 0 4px; font-weight: 600; }
.py-tip { font-size: .84rem; margin: 4px 0 6px; }
.py-ex { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; min-height: 36px; }
.py-svg { display: block; color: var(--py-ink); }
.py-hear { width: 36px; height: 36px; padding: 0; border: 1px solid var(--py-line); border-radius: 50%; background: var(--py-soft); font-size: .95rem; cursor: pointer; }
.py-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.py-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border: 1px solid var(--py-line); border-radius: 999px; background: var(--py-surface); font-size: 1.05rem; }

.py-lb { font-size: .82rem; color: var(--py-muted); margin: 12px 0 6px; font-weight: 600; }
.py-ch { display: flex; flex-wrap: wrap; gap: 6px; }
.py-ch button { min-height: 40px; min-width: 44px; padding: 0 10px; font: inherit; font-size: 1rem; color: var(--py-ink); background: var(--py-surface); border: 1px solid var(--py-line); border-radius: 10px; cursor: pointer; }
.py-ch button[aria-pressed="true"] { background: var(--py-acc); border-color: var(--py-acc); color: var(--py-acc-ink); }
.py-eq { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; min-height: 52px; font-size: 1.8rem; font-weight: 600; }
.py-op { font-size: 1.2rem; color: var(--py-muted); font-weight: 400; }
.py-res { padding: 2px 12px; border-radius: 12px; background: var(--py-surface); border: 1px solid var(--py-line); }
.py-fb { font-size: .9rem; min-height: 1.4em; margin: 8px 0 0; color: var(--py-muted); }
.py-good { color: var(--py-t3); } .py-bad { color: var(--py-off); }
.py-all { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.py-all div { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; background: var(--py-surface); border: 1px solid var(--py-line); border-radius: 10px; padding: 6px 10px; font-size: 1.2rem; font-weight: 600; }
.py-all small { flex-basis: 100%; font-size: .75rem; font-weight: 400; color: var(--py-muted); }

.py-rules { display: flex; flex-direction: column; gap: 8px; }
.py-rule { background: var(--py-surface); border: 1px solid var(--py-line); border-radius: 12px; padding: 10px 12px; font-size: .9rem; }
.py-words { display: flex; flex-direction: column; gap: 8px; }
.py-word { background: var(--py-surface); border: 1px solid var(--py-line); border-radius: 12px; padding: 10px 12px; }
.py-wp { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 1.2rem; }
.py-wv { color: var(--py-muted); font-size: .9rem; margin-top: 2px; }
.py-wn { font-size: .8rem; color: var(--py-muted); margin-top: 4px; }

.py-prog { height: 6px; border-radius: 3px; background: var(--py-soft); overflow: hidden; margin: 8px 0 14px; }
.py-prog span { display: block; height: 100%; background: var(--py-acc); }
.py-q { font-size: 1.05rem; margin: 6px 0 12px; }
.py-play { margin-bottom: 12px; }
.py-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.py-opts1 { grid-template-columns: 1fr; }
.py-opts1:has(svg) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.py-opt { min-height: 56px; padding: 8px 10px; display: flex; align-items: center; justify-content: center; text-align: center; font: inherit; font-size: 1.05rem; color: var(--py-ink); background: var(--py-surface); border: 1px solid var(--py-line); border-radius: 12px; cursor: pointer; }
.py-opt:disabled { cursor: default; }
.py-right { border-color: var(--py-t3); background: color-mix(in srgb, var(--py-t3) 16%, var(--py-surface)); }
.py-wrong { border-color: var(--py-off); background: color-mix(in srgb, var(--py-off) 14%, var(--py-surface)); }

/* ---------- Mục Đọc ---------- */
.rd-tool { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 4; background: var(--py-bg); padding: 6px 0 8px; border-bottom: 1px solid var(--py-line); margin-bottom: 8px; }
.rd-tool .py-row { margin-top: 0; }
.rd-tool .py-ch { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rd-tool .py-ch button { min-width: 0; padding: 0 10px; min-height: 38px; font-size: .88rem; }
.rd-box { display: flex; flex-direction: column; gap: 8px; }
.rd-line { padding: 10px 12px; border: 1px solid var(--py-line); border-radius: 14px; background: var(--py-surface); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.rd-line.rd-cur { border-color: var(--py-acc); background: color-mix(in srgb, var(--py-acc) 9%, var(--py-surface)); }
.rd-cells { display: flex; flex-wrap: wrap; gap: 2px 4px; align-items: flex-end; }
.rd-c { display: inline-flex; flex-direction: column; align-items: center; min-width: 1.1em; padding: 2px 3px; border-radius: 8px; }
.rd-curc { background: color-mix(in srgb, var(--py-acc) 22%, transparent); }
.rd-z { font-size: 1.7rem; line-height: 1.25; }
.rd-p { font-size: .82rem; line-height: 1.2; white-space: nowrap; }
.rd-sp { width: .6em; }
.rd-vi { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--py-line); font-size: .9rem; color: var(--py-muted); }
.rd-nozh .rd-z { visibility: hidden; }
.rd-nopy .rd-p { visibility: hidden; }
.rd-novi .rd-vi { display: none; }
.rd-line.rd-syl .rd-z { display: none; }
.rd-line.rd-syl .rd-p { font-size: 1.15rem; }
.rd-line.rd-nopyl .rd-p { display: none; }
.rd-bad { color: var(--py-off); text-decoration: underline wavy; }
.rd-warn { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; font-size: .84rem; color: var(--py-off); background: color-mix(in srgb, var(--py-off) 10%, var(--py-surface)); }
.rd-vitext { margin: 10px 0 0; font-size: .92rem; color: var(--py-muted); }
.rd-in { display: block; width: 100%; box-sizing: border-box; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--py-ink); background: var(--py-surface); border: 1px solid var(--py-line); border-radius: 12px; resize: vertical; }
.rd-voc { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rd-w { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; text-align: left; font: inherit; color: var(--py-ink); background: var(--py-surface); border: 1px solid var(--py-line); border-radius: 12px; cursor: pointer; }
.rd-wz { font-size: 1.3rem; }
.rd-wp { font-size: .84rem; }
.rd-wv { font-size: .82rem; color: var(--py-muted); }
.rd-line.rd-mis { border-color: var(--py-off); }
.rd-mist { margin-top: 6px; font-size: .82rem; color: var(--py-off); }
.rd-c[data-rd] { cursor: pointer; }
.rd-c[data-rd]:active { background: color-mix(in srgb, var(--py-acc) 22%, transparent); }
