/* ===== Màu sắc ===== */
:root {
  --bg: #f6f0e4;
  --bg-2: #efe6d4;
  --card: #fffaf0;
  --ink: #2a2420;
  --ink-2: #51473f;
  --muted: #6b5f52;
  --line: #ddd0b9;
  --accent: #9e3b2b;      /* đỏ son */
  --accent-ink: #fff8ee;
  --gold: #85591a;
  --hex: #2a2420;
  --hex-dong: #c0412c;
  --highlight: #fbe7c6;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .07);
  --serif: 'Noto Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --han: 'Noto Serif TC', 'Songti TC', 'Noto Serif CJK TC', 'Source Han Serif TC', 'PMingLiU', 'MingLiU', serif;
  --tab-h: 0px;
  --bam: #e6d9c1;          /* nền khi đang bấm */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1815;
    --bg-2: #24201c;
    --card: #26221e;
    --ink: #ece3d3;
    --ink-2: #cbbfad;
    --muted: #a89a89;
    --line: #3b342d;
    --accent: #e8866b;
    --accent-ink: #1b1815;
    --gold: #d9ab55;
    --hex: #ece3d3;
    --hex-dong: #f08a6c;
    --highlight: #3a2c1f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --bam: #3a332c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1815;
  --bg-2: #24201c;
  --card: #26221e;
  --ink: #ece3d3;
  --ink-2: #cbbfad;
  --muted: #a89a89;
  --line: #3b342d;
  --accent: #e8866b;
  --accent-ink: #1b1815;
  --gold: #d9ab55;
  --hex: #ece3d3;
  --hex-dong: #f08a6c;
  --highlight: #3a2c1f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --bam: #3a332c;
  color-scheme: dark;
}
/* Cỡ chữ: mọi kích thước tính theo rem nên chỉ cần đổi gốc */
html { font-size: 100%; }
html[data-cochu="lon"] { font-size: 112.5%; }
html[data-cochu="rat-lon"] { font-size: 127%; }

/* ===== Nền tảng ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scroll-padding-top: 120px; }
@media (max-width: 720px) { html { scroll-padding-top: 64px; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.75 var(--serif);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--sans); line-height: 1.3; letter-spacing: -.01em; color: var(--ink); }
h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); margin: 0 0 .4em; font-weight: 700; }
h2 { font-size: 1.45rem; margin: 2.2em 0 .6em; }
h3 { font-size: 1.2rem; margin: 1.8em 0 .5em; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 640px; }
.muted { color: var(--muted); }
.nho { font-size: .88rem; }
.lead { font-size: 1.12rem; color: var(--ink-2); }
.eyebrow { font: 600 .78rem/1.4 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--gold); margin: 0 0 .5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; z-index: 99; background: var(--card); padding: 8px 12px; }
.han { font-family: var(--han); font-weight: 500; }
.center { text-align: center; justify-content: center; }

/* ===== Đầu trang ===== */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 700 1.1rem var(--sans); }
.brand-mark { width: 22px; height: auto; }
.brand-mark .vach { fill: var(--accent); }
.nav { display: flex; gap: 2px; margin-left: auto; font: 500 .92rem var(--sans); }
.nav a { color: var(--ink-2); text-decoration: none; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .nav a:hover { background: var(--bg-2); } }
.nav a[aria-current="page"] { color: var(--accent); background: var(--bg-2); }
@media (max-width: 720px) {
  :root { --tab-h: 64px; }
  .site-header { position: static; }
  .nav { display: none; }
}

/* ===== Chân trang ===== */
.site-footer { margin-top: 72px; border-top: 1px solid var(--line); background: var(--bg-2); padding: 28px 0 40px; font-size: .9rem; color: var(--ink-2); }
.site-footer p { margin: 0 0 .7em; }

/* ===== Nút ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink);
  font: 600 1rem var(--sans); text-decoration: none; cursor: pointer;
  transition: transform 120ms var(--ease-out), filter 150ms ease;
}
@media (hover: hover) and (pointer: fine) { .btn:hover { filter: brightness(1.06); } }
.btn:active { transform: scale(.98); }
.btn-ghost { background: transparent; color: var(--accent); }
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 1.4em 0; }

/* ===== Hình quẻ ===== */
.hex .vach { fill: var(--hex); }
.hex .vach.dong { fill: var(--hex-dong); }
.hex text { fill: var(--muted); font: 9px var(--sans); }
.hex .vung-bam { fill: transparent; }
.hex a:focus .vach { fill: var(--accent); }
@media (hover: hover) and (pointer: fine) { .hex a:hover .vach { fill: var(--accent); } }
.hex a:focus { outline: none; }
.hex-lg { width: 120px; height: auto; }
.hex-md { width: 76px; height: auto; }
.hex-sm { width: 40px; height: auto; flex: none; }
.hex-tri { width: 54px; height: auto; }
.hex-line { width: 100px; height: 10px; }

/* ===== Trang chủ ===== */
.home-hero { padding: 48px 0 24px; }
.home-hero h1 { font-size: clamp(2rem, 8vw, 3rem); }
.cards { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card {
  display: block; padding: 20px; border-radius: 16px; background: var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
  transition: transform 120ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .card:hover { transform: translateY(-2px); } }
.card h2 { margin: .3em 0 .3em; font-size: 1.2rem; }
.card p { margin: 0; color: var(--ink-2); font-size: .97rem; line-height: 1.6; }
.card-num { font: 700 .8rem var(--sans); color: var(--accent-ink); background: var(--accent); width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; }
.que-hom-nay { margin-top: 40px; }
.qhn { display: flex; gap: 18px; align-items: center; padding: 18px 20px; border-radius: 16px; border: 1px dashed var(--gold); text-decoration: none; color: var(--ink); }
.qhn strong { display: block; font-family: var(--sans); }
.qhn-cau { color: var(--ink-2); font-style: italic; }

/* ===== Đầu trang con ===== */
.page-head { padding: 36px 16px 8px; }
.search input {
  width: 100%; min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: 1rem var(--sans);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ===== Danh sách 64 quẻ ===== */
.que-grid { list-style: none; padding: 0 16px; margin: 20px auto 0; display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .que-grid { grid-template-columns: 1fr 1fr; } }
.que-grid a {
  display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
@media (hover: hover) and (pointer: fine) { .que-grid a:hover { border-color: var(--accent); } }
.qg-text { font-family: var(--sans); line-height: 1.35; }
.qg-so { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.qg-phu { display: block; color: var(--ink-2); font-size: .88rem; }

/* ===== Trang một quẻ ===== */
.que-hero { background: var(--bg-2); border-bottom: 1px solid var(--line); padding: 28px 0 24px; }
.que-hero-inner { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center; }
@media (max-width: 520px) {
  .que-hero-inner { grid-template-columns: 1fr 64px; gap: 16px; align-items: start; }
  .que-hero-hex { order: 2; padding-top: 4px; }
  .hex-lg { width: 64px; }
}
.que-hero h1 { margin-bottom: .2em; }
.que-hero h1 .sub { display: block; font-size: .55em; font-weight: 500; color: var(--ink-2); margin-top: .2em; }
.que-meta { margin: 0; color: var(--muted); font: .92rem/1.5 var(--sans); }
.mot-cau { font-style: italic; font-size: 1.1rem; color: var(--accent); margin: .7em 0 0; }
.toc { position: sticky; top: 57px; z-index: 5; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
@media (max-width: 720px) {
  /* Điện thoại: bỏ lớp làm mờ nền khi cuộn (nặng với máy yếu), dùng nền gần đục. */
  .toc { top: 0; background: color-mix(in srgb, var(--bg) 97%, transparent); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
.toc-inner { display: flex; gap: 8px; overflow-x: auto; padding-top: 10px; padding-bottom: 10px; scrollbar-width: none; }
.toc-inner::-webkit-scrollbar { display: none; }
.toc a {
  flex: none; font: 500 .85rem var(--sans); padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); background: var(--card);
}
.que-section h2 { font-size: 1.35rem; padding-top: .4em; border-top: 1px solid var(--line); margin-top: 2em; }
.que-section:first-child h2 { border-top: 0; }
.hao { margin: 1.2em 0; padding: 4px 0 4px 16px; border-left: 3px solid var(--line); border-radius: 0; }
.hao h3 { margin: 0 0 .4em; font-size: 1.08rem; }
.hao-nhan { display: block; font: 600 .78rem var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--gold); }
.hao p:last-child em:first-child { font-style: normal; font-weight: 600; font-family: var(--sans); color: var(--accent); }
.nen-doc-day { background: var(--highlight); border-left-color: var(--hex-dong); border-radius: 0 12px 12px 0; padding: 10px 14px 6px 16px; position: relative; }
section.nen-doc-day { padding: 2px 14px 10px; border-radius: 12px; }
.nen-doc-day::before {
  content: 'Nên đọc'; position: absolute; top: -10px; right: 12px;
  font: 600 .72rem var(--sans); background: var(--hex-dong); color: var(--accent-ink); padding: 2px 8px; border-radius: 999px;
}
.gieo-banner { margin-top: 16px; }
.gieo-banner:not([hidden]) {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  background: var(--highlight); border-radius: 12px; padding: 12px 16px; font: .93rem/1.5 var(--sans);
}
.gieo-banner p { margin: 0; }
.que-pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 48px; font-family: var(--sans); }
.que-pager a { text-decoration: none; padding: 10px 0; }
.que-pager small { display: block; color: var(--muted); font-size: .8rem; }
.que-pager .right { text-align: right; }
.que-pager .center { font-size: .9rem; }

/* ===== Văn bản dài ===== */
.prose p, .prose li { hyphens: auto; }
.prose blockquote { margin: 1em 0; padding: .2em 1em; border-left: 3px solid var(--gold); color: var(--ink-2); }
.prose strong .han, .prose p > strong:only-child { font-size: 1.05em; }
.table-wrap { overflow-x: auto; margin: 1em 0; }
table { border-collapse: collapse; width: 100%; font: .95rem/1.5 var(--sans); }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; background: var(--bg-2); }
.toc-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 20px; font-family: var(--sans); font-size: .97rem; }
.toc-box ol { padding-left: 1.2em; }
.toc-box a { text-decoration: none; }
.am-duong { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 1em 0; }
.am-duong > div, .bq { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 6px; font-family: var(--sans); }
.am-duong .hex-line { width: 80px; height: 8px; margin-bottom: 6px; }
.am-duong span, .bq small { color: var(--ink-2); font-size: .9rem; line-height: 1.4; }
.bat-quai { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 1em 0; }
@media (min-width: 600px) { .bat-quai { grid-template-columns: repeat(4, 1fr); } }
.bq { align-items: flex-start; }
.bq .hex-tri { margin-bottom: 6px; }
.bq span { color: var(--accent); font-size: .95rem; }
.vi-du-que { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 1.4em 0; padding: 20px; background: var(--card); border-radius: 14px; border: 1px solid var(--line); }
.vi-du-que svg { width: 220px; }
.vi-du-que figcaption { font: .9rem/1.5 var(--sans); color: var(--ink-2); text-align: center; }

/* ===== Gieo quẻ ===== */
.gieo-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); font-family: var(--sans); }
.field { display: block; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.field small { font-weight: 400; color: var(--muted); }
textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: vertical;
  font: 1rem/1.5 var(--sans); background: var(--bg); color: var(--ink);
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-2); border-radius: 12px; padding: 4px; margin: 16px 0; }
.tabs button { min-height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font: 600 .92rem var(--sans); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.gieo-stage { display: grid; gap: 16px; justify-items: center; }
.dong-xu { display: flex; gap: 14px; min-height: 72px; align-items: center; perspective: 800px; }
.xu {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font: 600 .8rem var(--sans); border: 3px solid var(--gold); background: var(--bg-2); color: var(--ink-2);
  position: relative;
}
.xu::after { content: ''; width: 14px; height: 14px; border: 2px solid var(--gold); position: absolute; opacity: .5; }
.xu.ngua, .xu.sap { padding-top: 34px; }
.xu.ngua { background: linear-gradient(145deg, #f2d48a, #c99a3e); color: #3a2a10; }
.xu.sap { background: linear-gradient(145deg, #8f7a5a, #5f4e36); color: #f6ecd6; }
/* Lật xu: một vòng, nhấc nhẹ 7px, ba xu lệch nhau một chút. Tổng 580ms, khớp với gieo-que.js. */
.xu.dang-lat {
  background: linear-gradient(145deg, #f2d48a, #8f7a5a);
  animation: xu-quay 500ms var(--ease-out) both, xu-nhac 500ms ease-in-out both;
}
.xu.dang-lat:nth-child(2) { animation-delay: 40ms; }
.xu.dang-lat:nth-child(3) { animation-delay: 80ms; }
@keyframes xu-quay { from { rotate: y 0deg; } to { rotate: y 360deg; } }
@keyframes xu-nhac { 0%, 100% { translate: 0 0; } 50% { translate: 0 -7px; } }
/* Hào vừa gieo hiện ra nhẹ nhàng. */
.hang-hao.moi { animation: hao-hien 220ms var(--ease-out) both; }
@keyframes hao-hien { from { opacity: 0; transform: translateY(6px); } }
@keyframes mo-dan { from { opacity: 0; } }
/* Giảm chuyển động: xu không lật, chỉ mờ đi rồi rõ lại; hào mới chỉ mờ dần. */
@media (prefers-reduced-motion: reduce) {
  .xu { transition: opacity 150ms ease; }
  .xu.dang-lat { animation: none; opacity: .55; }
  .hang-hao.moi { animation: mo-dan 150ms ease both; }
}
.que-dang-gieo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 8px; width: 100%; max-width: 260px; }
.hang-hao { display: grid; grid-template-columns: 52px 1fr 20px; gap: 12px; align-items: center; font-size: .8rem; color: var(--muted); }
.hang-hao .hex-line { width: 100%; height: 12px; }
.hang-hao .cho { height: 10px; border: 1px dashed var(--line); border-radius: 3px; }
.hang-hao .so { font-variant-numeric: tabular-nums; text-align: right; }
.hang-hao.dong .so { color: var(--hex-dong); font-weight: 700; }
.trang-thai { text-align: center; color: var(--ink-2); min-height: 3em; margin: 12px 0 0; font-size: .95rem; }
.hang-tay { border: 0; padding: 0; margin: 0 0 12px; }
.hang-tay legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.hang-tay legend small { font-weight: 400; color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: grid; place-items: center; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; font-size: .85rem; cursor: pointer; background: var(--bg); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.loi { color: var(--hex-dong); font-size: .9rem; }

.ket-qua { margin-top: 28px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 4px 18px 18px; box-shadow: var(--shadow); }
.ket-qua:focus { outline: none; }
.ket-qua h2 { margin-top: .8em; }
.cau-hoi { font-family: var(--sans); color: var(--ink-2); }
.hai-que { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px 0; }
.mui-ten { font-size: 1.6rem; color: var(--muted); }
.the-que { flex: 1; max-width: 220px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); text-decoration: none; color: var(--ink); text-align: center; font-family: var(--sans); }
.the-nhan { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--gold); font-weight: 600; }
.the-phu { font-size: .85rem; color: var(--ink-2); line-height: 1.35; }
.nen-doc h3 { margin-top: 1.2em; }
.nen-doc ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.nen-doc li a { display: block; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-family: var(--sans); }
.nen-doc li.chinh-yeu a { border-color: var(--hex-dong); background: var(--highlight); }
.nd-que { display: block; font-size: .8rem; color: var(--muted); }
.nd-ten { font-weight: 600; }
.chi-tiet { font-family: var(--sans); font-size: .92rem; color: var(--ink-2); margin-top: 12px; }
.chi-tiet summary { cursor: pointer; }

/* ===== Trợ năng ===== */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button { font-family: var(--sans); }
.icon { width: 1.2em; height: 1.2em; flex: none; }

/* ===== Nút cài đặt (Aa) ===== */
.nut-cai-dat {
  margin-left: 6px; min-width: 44px; min-height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: 700 .95rem var(--sans); cursor: pointer;
}
@media (max-width: 720px) { .nut-cai-dat { margin-left: auto; } }
.nut-cai-dat[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.cai-dat { border-top: 1px solid var(--line); background: var(--card); padding: 12px 0; font-family: var(--sans); }
.cai-dat .wrap { display: grid; gap: 10px; }
.cd-hang { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cd-hang > span { width: 70px; font-weight: 600; font-size: .9rem; }
.cd-hang button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; font-size: .9rem; }
.cd-hang button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ===== Thanh điều hướng dưới màn hình (điện thoại) ===== */
.tab-bar { display: none; }
@media (max-width: 720px) {
  body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .tab-bar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--card) 97%, transparent);
    border-top: 1px solid var(--line);
  }
  .tab-bar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    text-decoration: none; color: var(--muted); font: 500 .72rem var(--sans);
  }
  .tab-bar .icon { width: 24px; height: 24px; }
  .tab-bar a[aria-current="page"] { color: var(--accent); font-weight: 700; }
}

/* ===== Nút lên đầu trang, thông báo ===== */
.len-dau {
  position: fixed; right: 16px; bottom: calc(20px + var(--tab-h) + env(safe-area-inset-bottom)); z-index: 15;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center;
}
.len-dau svg { width: 22px; height: 22px; }
.thong-bao {
  position: fixed; left: 50%; bottom: calc(24px + var(--tab-h) + env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s ease;
  max-width: calc(100% - 32px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font: .92rem/1.4 var(--sans); box-shadow: var(--shadow);
}
.thong-bao.hien { opacity: 1; transform: translate(-50%, 0); }
/* Giảm chuyển động: bỏ phần trượt và nhích, giữ mờ dần cho thông báo. */
@media (prefers-reduced-motion: reduce) {
  .thong-bao { transform: translate(-50%, 0); transition: opacity .2s ease; }
  .btn:active, .card:hover, .card:active, .the-que:active, .qhn:active { transform: none; }
}

/* ===== Bảng chia sẻ (máy tính) ===== */
.bang-chia-se { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); display: grid; place-items: end center; }
@media (min-width: 600px) { .bang-chia-se { place-items: center; } }
.bcs-hop { width: min(420px, 100%); background: var(--card); border-radius: 18px 18px 0 0; padding: 16px; display: grid; gap: 8px; font-family: var(--sans); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .bcs-hop { border-radius: 18px; } }
.bcs-tieu-de { margin: 0 0 4px; font-weight: 700; }
.bcs-hop button, .bcs-hop a {
  display: block; text-align: left; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: 500 1rem var(--sans); text-decoration: none; cursor: pointer;
}
.bcs-hop small { display: block; color: var(--muted); font-size: .8rem; }
.bcs-hop .bcs-dong { text-align: center; background: transparent; border: 0; color: var(--muted); }

/* ===== Nút nhỏ ===== */
.nut-nho {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 500 .9rem var(--sans);
  text-decoration: none; cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .nut-nho:hover { border-color: var(--accent); color: var(--accent); } }
.hero-nut { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.nut-chu { background: none; border: 0; padding: 8px 0; color: var(--accent); font: 500 .9rem var(--sans); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ===== Đọc tiếp ===== */
.tiep-tuc-hang, .doc-tiep { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.doc-tiep { margin: 0 0 8px; }
.tiep-tuc {
  display: block; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  text-decoration: none; color: var(--ink); font: 600 .95rem/1.35 var(--sans);
}
.tiep-tuc small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }
@media (hover: hover) and (pointer: fine) { .tiep-tuc:hover { border-color: var(--accent); } }

/* ===== Gieo quẻ: kết quả chi tiết, lịch sử ===== */
.checkbox { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; font-size: .88rem; color: var(--ink-2); line-height: 1.45; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
.checkbox small { color: var(--muted); }
.btn:disabled { opacity: .6; cursor: default; }
.doc-muc { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); }
.doc-muc.chinh-yeu { border-color: var(--hex-dong); background: var(--highlight); }
.doc-muc h4 { margin: .1em 0 .4em; font-size: 1.1rem; }
.dm-nhan { margin: 0; font: 600 .78rem var(--sans); color: var(--gold); text-transform: uppercase; letter-spacing: .04em; }
.dm-nhan strong { color: var(--hex-dong); }
.dm-kinh { margin: 0 0 .5em; font-family: var(--serif); }
.dm-khuyen { margin: 0 0 .6em; font-family: var(--serif); }
.dm-khuyen strong { font-family: var(--sans); color: var(--accent); }
.dm-link { font: 600 .92rem var(--sans); }
.goi-y-chung { margin-top: 18px; padding: 14px 16px; border-radius: 14px; border: 1px dashed var(--gold); }
.goi-y-chung h3 { margin-top: 0; font-size: 1.05rem; }
.goi-y-chung p { font-family: var(--serif); }
.goi-y-chung a { font: 600 .92rem var(--sans); }
.ket-qua .cta-row .btn { flex: 1 1 200px; }
.lich-su { margin-top: 36px; font-family: var(--sans); }
.lich-su h2 { font-size: 1.2rem; margin-bottom: .2em; }
.lich-su .dem { font-size: .85rem; color: var(--muted); font-weight: 500; }
.lich-su ul { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.lich-su li button {
  width: 100%; text-align: left; display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .lich-su li button:hover { border-color: var(--accent); } }
.ls-ngay { font-size: .78rem; color: var(--muted); }
.ls-que { font-weight: 600; }
.ls-hoi { font-size: .9rem; color: var(--ink-2); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Bảng tra 8 x 8 ===== */
.bang-tra-wrap { margin: 12px -16px 0; padding: 0 16px; }
.bang-tra { min-width: 600px; font-size: .85rem; text-align: center; }
.bang-tra caption { caption-side: top; text-align: left; color: var(--muted); padding-bottom: 8px; }
.bang-tra th, .bang-tra td { padding: 4px; text-align: center; border: 1px solid var(--line); }
.bang-tra thead th, .bang-tra tbody th { background: var(--bg-2); font-weight: 600; font-size: .8rem; }
.bang-tra tbody th { position: sticky; left: 0; z-index: 1; }
.hex-xs { display: block; width: 26px; height: auto; margin: 2px auto 3px; }
.bang-tra td a { display: block; padding: 6px 2px; border-radius: 8px; text-decoration: none; color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .bang-tra td a:hover { background: var(--highlight); } }
.bang-tra td strong { display: block; color: var(--accent); }
.bang-tra td span { font-size: .78rem; }
.page-head .tabs { margin-bottom: 4px; }

/* ===== Trang thông tin ===== */
.lien-he { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; font-family: var(--sans); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.lien-he dt { font-weight: 600; color: var(--ink-2); }
.lien-he dd { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 16px; font-family: var(--sans); }
.footer-links a { color: var(--ink); text-decoration: none; padding: 4px 0; }
@media (hover: hover) and (pointer: fine) { .footer-links a:hover { color: var(--accent); } }
.trang-loi { padding-top: 64px; }

/* ===== In ra giấy ===== */
@media print {
  .site-header, .tab-bar, .len-dau, .toc, .que-pager, .site-footer, .hero-nut, .gieo-banner, .thong-bao { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; padding: 0; }
  .que-hero { background: none; border: 0; }
  a { color: inherit; text-decoration: none; }
  .hao, .doc-muc { break-inside: avoid; }
}
@media (max-width: 600px) {
  .bang-tra { min-width: 0; table-layout: fixed; }
  .bang-tra caption { white-space: normal; }
  .bang-tra td span { display: none; }
  .bang-tra th, .bang-tra td { padding: 3px 1px; font-size: .72rem; }
  .bang-tra td a { padding: 8px 0; }
  .bang-tra td strong { font-size: .95rem; }
  .hex-xs { width: 20px; }
  .bang-tra thead th:first-child span[aria-hidden] { font-size: .62rem; }
}
@media (max-width: 600px) {
  .bang-tra thead th { font-size: .62rem; letter-spacing: -.02em; }
  .home-hero { padding-top: 28px; }
}

/* ===== Hỏi Kinh Dịch: chọn việc và mức thuận/nghịch ===== */
.chon-viec { border: 0; margin: 0 0 14px; padding: 0; }
.chon-viec legend { font: 600 .95rem var(--sans); margin-bottom: 8px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; }
.chips span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font: 500 .9rem var(--sans); cursor: pointer; }
.chips input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
a.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); text-decoration: none; font: 500 .9rem var(--sans); }
@media (hover: hover) and (pointer: fine) { a.chip:hover { border-color: var(--accent); color: var(--accent); } }

.danh-gia { --m: var(--muted); margin: 14px 0 18px; padding: 16px 18px; border-radius: 16px; border: 2px solid var(--m); background: var(--bg); text-align: center; }
.danh-gia.m5 { --m: #2f7d4a; } .danh-gia.m4 { --m: #4f8a3a; } .danh-gia.m3 { --m: #8a6d1f; } .danh-gia.m2 { --m: #b5652a; } .danh-gia.m1 { --m: #a63a2e; }
:root[data-theme="dark"] .danh-gia.m5, :root[data-theme="dark"] .danh-gia.m4 { --m: #7cc48f; }
:root[data-theme="dark"] .danh-gia.m3 { --m: #d9ab55; } :root[data-theme="dark"] .danh-gia.m2 { --m: #e89a5e; } :root[data-theme="dark"] .danh-gia.m1 { --m: #f08a6c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .danh-gia.m5, :root:not([data-theme="light"]) .danh-gia.m4 { --m: #7cc48f; }
  :root:not([data-theme="light"]) .danh-gia.m3 { --m: #d9ab55; }
  :root:not([data-theme="light"]) .danh-gia.m2 { --m: #e89a5e; }
  :root:not([data-theme="light"]) .danh-gia.m1 { --m: #f08a6c; }
}
.dg-nhan { margin: 0; font: 600 .82rem var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dg-muc { margin: 4px 0 8px; font: 700 clamp(1.6rem, 7vw, 2.1rem)/1.2 var(--serif); color: var(--m); }
.thang-muc { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.thang-muc span { width: 34px; height: 8px; border-radius: 4px; background: var(--line); }
.thang-muc span.day { background: var(--m); }
.dg-giai { margin: 0 0 6px; font-family: var(--serif); }
.dg-xu-huong { margin: 6px 0; font-family: var(--serif); }
.dg-chu { margin: 8px 0 0; font-size: .85rem; color: var(--muted); }
.dg-chu em { font-style: normal; }
.theo-viec { margin: 0 0 18px; padding: 12px 16px; border-radius: 14px; background: var(--highlight); }
.theo-viec h3 { margin: 0 0 6px; font-size: 1.05rem; }
.theo-viec p { margin: 6px 0; font-family: var(--serif); }
.tv-nhan { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 6px; background: var(--card); font: 600 .78rem var(--sans); color: var(--accent); vertical-align: 1px; }
details.theo-viec summary { cursor: pointer; font: 600 .95rem var(--sans); }
details.theo-viec dt { font: 600 .9rem var(--sans); margin-top: 10px; }
details.theo-viec dd { margin: 2px 0 0; font-family: var(--serif); }
.ls-viec { display: inline-block; font: 600 .75rem var(--sans); color: var(--accent); margin-right: 6px; }
.mien-tru { margin-top: 14px; }
.hoi-nhanh { margin-top: 22px; padding: 16px 18px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.hoi-nhanh h2 { margin: 0 0 4px; font-size: 1.2rem; }
.hoi-nhanh p { margin: 0 0 12px; color: var(--ink-2); }
.tv-ds dt { font: 600 .92rem var(--sans); margin-top: 10px; }
.tv-ds dt a { color: var(--accent); }
.tv-ds dd { margin: 2px 0 0; }

/* ===== Hội viên ===== */
.icon { width: 1.2em; height: 1.2em; flex: none; }
.toc a.toc-hv::after { content: ' ★'; color: var(--gold); }
.khoa-hop { margin: 1.2em 0; padding: 18px 20px; border-radius: 16px; border: 1px solid var(--gold); background: linear-gradient(180deg, var(--card), var(--bg-2)); font-family: var(--sans); }
.khoa-hop p { margin: .5em 0; }
.khoa-hop ul { margin: .6em 0; padding-left: 1.2em; font-size: .95rem; }
.khoa-hop .cta-row { margin: 1em 0 .2em; }
.khoa-nhan { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--gold); margin-top: 0 !important; }
.hv-mo-dau { position: relative; max-height: 9em; overflow: hidden; }
.hv-mo-dau::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4em; background: linear-gradient(transparent, var(--bg)); }
.hv-noi-dung.dang-tai .khoa-hop { opacity: .5; }
.th-phan h3 { font-size: 1.15rem; color: var(--accent); margin-top: 1.4em; }
.ban-dich { font-size: .97rem; }
.ban-dich h3 { font-size: 1.05rem; margin-top: 1.6em; color: var(--gold); font-family: var(--sans); }
.ban-dich h4, .ban-dich h5 { font-size: 1rem; margin-top: 1.2em; }
.ban-dich-nguon { font: .85rem var(--sans); color: var(--muted); padding: 10px 12px; border-radius: 10px; background: var(--bg-2); }
.chu-thich { font-size: .88rem; color: var(--ink-2); border-top: 1px solid var(--line); margin-top: 2em; padding-top: 1em; }
.chu-thich a { text-decoration: none; }

.bao-thu { margin: 14px 0; padding: 10px 14px; border-radius: 12px; background: #fdf0d2; color: #6a4a10; border: 1px dashed #c08a2a; font: .92rem/1.5 var(--sans); }
:root[data-theme="dark"] .bao-thu { background: #3a2e17; color: #f0d79a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bao-thu { background: #3a2e17; color: #f0d79a; } }
.hv-trang-thai { margin: 16px 0; padding: 14px 18px; border-radius: 14px; border: 2px solid #4f8a3a; background: var(--card); font-family: var(--sans); }
.hv-trang-thai.het-han { border-color: var(--hex-dong); }
.hv-trang-thai p { margin: .35em 0; }
.ma-hv { font: 700 1rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; padding: 2px 8px; border-radius: 6px; background: var(--bg-2); }
.ma-hv.lon { font-size: 1.35rem; padding: 6px 14px; }

.bang-gia { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: 8px 0 14px; }
.goi { position: relative; display: flex; flex-direction: column; padding: 22px 20px 20px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); font-family: var(--sans); }
.goi.noi-bat { border: 2px solid var(--accent); }
.goi h3 { margin: 0 0 6px; font-size: 1.15rem; }
.goi-nhan { position: absolute; top: -11px; left: 18px; margin: 0; padding: 2px 10px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 600; }
.goi-gia { margin: 0; }
.goi-gia strong { font-size: 1.7rem; color: var(--ink); }
.goi-gia span { color: var(--muted); margin-left: 4px; }
.goi-gia-sau { margin: 2px 0 0; font-size: .82rem; color: var(--muted); }
.goi-ghi-chu { flex: 1; color: var(--ink-2); font-size: .92rem; }
.goi .btn { width: 100%; }

.so-sanh { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: .92rem; }
.so-sanh th, .so-sanh td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.so-sanh td { text-align: center; white-space: nowrap; color: var(--ink-2); }
.so-sanh tbody th { font-weight: 400; }
.so-sanh thead th:not(:first-child) { text-align: center; }
.form-ma { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-ma .field { flex: 1 1 220px; }
.form-ma input, #form-tt input:not([type="checkbox"]) { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 1rem var(--sans); box-sizing: border-box; }
.form-ma input:focus, #form-tt input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.prose details { margin: .6em 0; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.prose details summary { cursor: pointer; font: 600 .97rem var(--sans); }

.hop-thanh-toan { width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); font-family: var(--sans); }
.hop-thanh-toan::backdrop { background: rgba(20, 14, 8, .55); }
.tt-dau { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.tt-dau h2 { margin: 0; font-size: 1.1rem; }
.tt-dong { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--bg-2); color: var(--ink); font-size: 1.4rem; cursor: pointer; }
#tt-than { padding: 6px 18px 18px; }
.tt-goi { font-size: 1.05rem; }
.qr { width: min(240px, 70vw); margin: 10px auto; padding: 8px; background: #fff; border-radius: 12px; }
.qr svg { display: block; width: 100%; height: auto; }
.qr-thu { opacity: .45; }
.tt-tay { margin: 10px 0; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); }
.tt-tay summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
.tt-dong-tt { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.tt-dong-tt span { color: var(--muted); min-width: 92px; }
.tt-dong-tt strong { flex: 1; word-break: break-all; }
.tt-dong-tt .nut-chu { padding: 4px 0; }
.tt-cho { display: flex; align-items: center; gap: 10px; justify-content: center; color: var(--ink-2); font-size: .92rem; }
.xoay { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: xoay 1s linear infinite; }
@keyframes xoay { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .xoay { animation: none; } }
.tt-xong { text-align: center; }
.tt-xong-dau { width: 56px; height: 56px; margin: 12px auto 0; border-radius: 50%; background: #2f7d4a; color: #fff; font-size: 1.8rem; line-height: 56px; }
.tt-xong .cta-row { justify-content: center; }

.goi-y-sau { margin-top: 18px; padding: 16px 18px; border-radius: 16px; border: 1px solid var(--gold); background: var(--card); }
.goi-y-sau h3 { margin-top: 0; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.goi-y-sau h4 { margin: 1.3em 0 .3em; font: 600 1rem var(--sans); color: var(--accent); }
.goi-y-sau p, .goi-y-sau li { font-family: var(--serif); }
.goi-y-sau .khoa-nhan, .goi-y-sau .cta-row, .goi-y-sau.khoa-hop li { font-family: var(--sans); }
.goi-y-sau a { font: 600 .92rem var(--sans); }
.hv-nhan { padding: 1px 8px; border-radius: 999px; background: var(--gold); color: var(--card); font: 600 .72rem var(--sans); }
.hao-sau { margin: 10px 0; padding: 4px 0 4px 14px; border-left: 3px solid var(--hex-dong); }
.hao-sau ul { margin: .3em 0; padding-left: 1.1em; }
.tu-van li { margin: .3em 0; }
#ghi-chep { width: 100%; box-sizing: border-box; }
.ls-ghi { font-size: .85rem; color: var(--gold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----- Đọc thêm: các thiên chung của cụ Phan ----- */
.ds-doc-them { list-style: none; padding-left: 16px; display: grid; gap: 10px; counter-reset: dt; }
.ds-doc-them li { counter-increment: dt; }
.ds-doc-them a { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: baseline; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); text-decoration: none; color: var(--ink); font-family: var(--sans); }
.ds-doc-them a::before { content: counter(dt); grid-row: span 2; color: var(--gold); font-weight: 700; }
@media (hover: hover) and (pointer: fine) { .ds-doc-them a:hover { border-color: var(--gold); } }
.ds-doc-them .ds-mo-ta { grid-column: 2 / -1; color: var(--ink-2); font-size: .93rem; line-height: 1.5; }
.nhan-mien-phi, .nhan-hv { font-size: .78rem; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.nhan-mien-phi { color: var(--accent); }
.nhan-hv { color: var(--gold); }
.nhan-hv .icon { width: 14px; height: 14px; }
.muc-luc { margin: 1.2em 0; padding: 12px 16px; border-radius: 12px; background: var(--bg-2); font: .93rem/1.5 var(--sans); }
.muc-luc-tieu-de { margin: 0 0 .3em; font-weight: 600; }
.muc-luc ol { margin: 0; padding-left: 1.3em; columns: 2 12em; column-gap: 1.5em; }
.muc-luc li { break-inside: avoid; margin: 2px 0; }
.ban-dich h2 { font-size: 1.2rem; margin-top: 2em; scroll-margin-top: 80px; }
.do-hinh { margin: 1.5em 0; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.do-hinh figcaption { margin-top: 10px; font: .88rem/1.5 var(--sans); color: var(--ink-2); }
.dh-svg { display: block; margin: 0 auto; font-family: var(--sans); }
.dh-ha-do, .dh-bat-quai { width: 100%; max-width: 340px; height: auto; }
.dh-svg text { fill: var(--ink); font-size: 11px; text-anchor: middle; }
.dh-svg .dh-nho { fill: var(--ink-2); font-size: 9.5px; }
.dh-svg .dh-dam { font-weight: 700; font-size: 12px; }
.dh-svg .dh-trai { text-anchor: end; fill: var(--ink-2); font-size: 10px; }
.dh-svg .dh-doc { text-anchor: start; font-size: 10px; }
.cham-duong { fill: #fffaf0; stroke: var(--hex); stroke-width: 1.4; }
.cham-am { fill: #2a2420; stroke: var(--ink); stroke-width: 1; }
.dh-bat-quai .vach rect { fill: var(--hex); }
.dh-tam { fill: none; stroke: var(--line); }
.dh-hoanh { max-width: none; height: auto; }
.dh-hoanh .o-duong { fill: #fffaf0; stroke: var(--ink); stroke-width: .8; }
.dh-hoanh .o-am { fill: #2a2420; stroke: var(--ink); stroke-width: .8; }
.dh-hoanh .dh-tc { fill: none; stroke: var(--line); stroke-dasharray: 3 3; }
.dh-hoanh .chu-duong { fill: #2a2420; font-size: 9.5px; }
.dh-hoanh .chu-am { fill: #fffaf0; font-size: 9.5px; }
.vv { display: grid; grid-template-columns: 1fr; gap: 16px; font-family: var(--sans); }
@media (min-width: 560px) { .vv { grid-template-columns: 1fr 1fr; } }
.vv-nhanh { display: grid; gap: 10px; justify-items: center; }
.vv-con { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; border-top: 1px solid var(--line); padding-top: 10px; }
.vv-quai { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.vv-quai .hex-tri { width: 46px; margin-bottom: 4px; }
.vv-quai span { font-size: .82rem; color: var(--ink-2); }
.doc-them-goi { margin-top: 1.5em; font-size: .97rem; color: var(--ink-2); }
.trang-doc-them { padding-top: 28px; }

/* ===== Chạm và bấm (điện thoại và máy tính) ===== */
/* Không chờ chạm đúp để phóng to khi bấm nhanh (ví dụ nút Gieo). */
button, a, summary, label, input[type="checkbox"], input[type="radio"] { touch-action: manipulation; }
/* Giữ tay lâu trên nút không bôi xanh chữ. Chữ nội dung vẫn chọn được như thường. */
button, .btn, .nut-nho, .chips span, .seg span, a.chip, .tab-bar a, .toc a, .xu {
  -webkit-user-select: none; user-select: none;
}
.tab-bar a { -webkit-touch-callout: none; }
/* Phản hồi ngay khi chạm: nền đậm lên một chút (hoặc thu nhẹ còn 0,98 với thẻ lớn), 120ms. */
.nut-nho, a.chip, .chips span, .seg span, .tabs button, .cd-hang button, .nut-cai-dat, .tt-dong, .len-dau,
.que-grid a, .tiep-tuc, .lich-su li button, .ds-doc-them a, .nen-doc li a, .bcs-hop button, .bcs-hop a,
.bang-tra td a, .toc a, .tab-bar a, .nav a {
  transition: background-color 120ms var(--ease-out);
}
.nut-nho:active, a.chip:active, .chips input:not(:checked) + span:active, .seg input:not(:checked) + span:active,
.tabs button:not([aria-selected="true"]):active, .cd-hang button:not([aria-pressed="true"]):active,
.nut-cai-dat:active, .tt-dong:active, .len-dau:active,
.que-grid a:active, .tiep-tuc:active, .lich-su li button:active, .ds-doc-them a:active, .nen-doc li a:active,
.bcs-hop button:active, .bcs-hop a:active, .bang-tra td a:active, .toc a:active, .tab-bar a:active, .nav a:active {
  background-color: var(--bam);
}
.the-que, .qhn { transition: transform 120ms var(--ease-out); }
.card:active, .the-que:active, .qhn:active { transform: scale(.98); }
