/* Chùa Tâm An – giao diện
   Bảng màu: giấy dó · mực nâu · vàng nghệ · hồng sen · xanh rêu · đỏ sơn son
   Chữ: Be Vietnam Pro (nội dung) · Noto Serif (tiêu đề, kinh văn, con số) */

/* ================================================================ Token */
:root {
  --paper: #f4e9d3;
  --paper-hi: #fcf7ec;
  --paper-lo: #e9dbbf;
  --ink: #3a2a1f;
  --ink-2: #66503e;
  --ink-3: #8f7a65;
  --turmeric: #e3a22a;
  --turmeric-hi: #f3c35a;
  --turmeric-deep: #9a640a;
  --lotus: #e68ea4;
  --lotus-deep: #b14d6a;
  --moss: #6b8247;
  --moss-deep: #4b6030;
  --lacquer: #ad3528;
  --lacquer-deep: #86241a;
  --wood: #7a5235;
  --wood-deep: #4f321f;
  --line: rgba(58, 42, 31, .12);
  --line-2: rgba(58, 42, 31, .22);
  --focus: rgba(196, 128, 14, .95);

  --glass-bg: linear-gradient(180deg, rgba(252, 247, 236, .84), rgba(244, 233, 211, .78));
  --glass-solid: linear-gradient(180deg, #fbf5e8, #f1e4ca);
  --sh-1: 0 1px 2px rgba(62, 38, 14, .10), 0 6px 18px -8px rgba(62, 38, 14, .34);
  --sh-2: 0 2px 6px rgba(62, 38, 14, .10), 0 24px 52px -22px rgba(62, 38, 14, .55);

  /* Thớ giấy dó: hạt li ti (SVG nội tuyến, không tải ngoài) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .24 0 0 0 0 .13 0 0 0 .7 -.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='.6'/%3E%3C/svg%3E");
  /* Vết mực con dấu (mặt nạ lốm đốm) */
  --stamp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='2' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.4 2.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");

  --r-sm: 12px;
  --r: 16px;
  --r-lg: 22px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --serif: 'Noto Serif', Georgia, 'Times New Roman', serif;
  --ease: cubic-bezier(.22, .7, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --gut: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --top: calc(var(--gut) + var(--safe-t));
  --dock-h: 68px;
  --dock-b: calc(12px + var(--safe-b));
}

/* ================================================================ Nền tảng */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #d9c7a6;
}
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}
#labels {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
.sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.ic {
  display: inline-block;
  flex: none;
  width: 1.25em;
  height: 1.25em;
  background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat;
  mask: var(--i) center / contain no-repeat;
  vertical-align: -0.22em;
}

/* Bảng kính mờ trên cảnh 3D */
.glass {
  background: var(--grain), var(--glass-bg);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  backdrop-filter: blur(16px) saturate(1.25);
  border: 1px solid rgba(255, 251, 240, .62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), var(--sh-1);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--grain), var(--glass-solid); }
}
.ui-lite .glass {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: var(--grain), var(--glass-solid);
}

/* Con dấu son */
.seal {
  display: inline-grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  background: var(--lacquer);
  color: #fcefdc;
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1;
  border-radius: 7px;
  box-shadow: inset 0 0 0 3px var(--lacquer), inset 0 0 0 4.5px rgba(252, 239, 220, .9);
  -webkit-mask: var(--stamp) center / 120px 120px;
  mask: var(--stamp) center / 120px 120px;
  rotate: -4deg;
}

kbd {
  display: inline-block;
  font: 600 11.5px/1 var(--font);
  padding: 4px 7px 3px;
  border-radius: 6px;
  background: #fffaf0;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  color: var(--ink-2);
  white-space: nowrap;
}

/* ================================================================ Nút & ô nhập */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(255, 251, 241, .78);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.1;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .12s, color .15s;
}
.btn .ic { width: 18px; height: 18px; }
.btn:hover { background: #fffbf2; border-color: rgba(58, 42, 31, .34); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, #f6c75c, #e5a42c 55%, #d9951c);
  border-color: rgba(140, 88, 8, .45);
  color: #3a240e;
  box-shadow: inset 0 1px 0 rgba(255, 245, 214, .85), 0 6px 16px -8px rgba(160, 100, 10, .85);
}
.btn.primary:hover { background: linear-gradient(180deg, #f9d175, #eaad3a 55%, #de9c24); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn.sm { min-height: 40px; padding: 0 15px; font-size: 14px; }
.btn.big { min-height: 54px; padding: 0 26px; font-size: 17px; }
.btn.big .ic { width: 20px; height: 20px; }

.ibtn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color .15s, color .15s, transform .12s;
}
.ibtn .ic { width: 21px; height: 21px; }
.ibtn:hover { background: rgba(255, 251, 241, .9); color: var(--ink); }
.ibtn:active { transform: scale(.93); }
.ibtn.sm { width: 38px; height: 38px; }
.ibtn.sm .ic { width: 19px; height: 19px; }

/* Chú thích nổi cho nút biểu tượng ở góc trên phải */
.hud-tr [data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  translate: -50% -4px;
  padding: 6px 10px;
  border-radius: 9px;
  background: rgba(42, 30, 21, .92);
  color: #fbf2e0;
  font: 500 12.5px/1.2 var(--font);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, translate .15s;
  z-index: 5;
}
.hud-tr [data-tip]:hover::after,
.hud-tr [data-tip]:focus-visible::after { opacity: 1; translate: -50% 0; transition-delay: .3s; }
.hud-tr .tool-help::after,
.hud-tr .tool-fullscreen::after,
.hud-tr .tool-more::after,
.hud-tr .mm-open::after,
.hud-tr .mm-x::after { left: auto; right: 0; translate: 0 -4px; }
.hud-tr .tool-help:hover::after, .hud-tr .tool-fullscreen:hover::after, .hud-tr .tool-more:hover::after,
.hud-tr .mm-open:hover::after, .hud-tr .mm-x:hover::after,
.hud-tr .tool-help:focus-visible::after, .hud-tr .tool-fullscreen:focus-visible::after,
.hud-tr .mm-open:focus-visible::after, .hud-tr .mm-x:focus-visible::after { translate: 0 0; }
.ui-touch .hud-tr [data-tip]::after { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(255, 251, 241, .7);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, transform .12s;
}
.chip .ic { width: 16px; height: 16px; }
.chip:hover { background: #fffbf2; color: var(--ink); border-color: rgba(58, 42, 31, .32); }
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper-hi); }

.inp {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  background: rgba(255, 253, 247, .9);
  font-size: 16px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.inp::placeholder { color: var(--ink-3); opacity: 1; }
.inp:focus { outline: none; border-color: var(--turmeric-deep); box-shadow: 0 0 0 3px rgba(227, 162, 42, .35); background: #fffdf8; }
.inp:disabled { opacity: .65; }

/* Thẻ (tab) */
.tabs {
  position: relative;
  display: flex;
  gap: 3px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(58, 42, 31, .07);
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  max-width: 220px;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .ic { width: 17px; height: 17px; }
.tab:hover { color: var(--ink); background: rgba(255, 251, 241, .55); }
.tab[aria-selected="true"] { background: var(--paper-hi); color: var(--ink); box-shadow: var(--sh-1); }
.tab[aria-selected="true"] .ic { color: var(--lacquer); }
.tabs.sm .tab { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* Công tắc */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 42px; height: 26px; margin: 0; cursor: pointer; }
.switch-ui {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(58, 42, 31, .22);
  transition: background-color .2s;
}
.switch-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fffaf0;
  box-shadow: 0 1px 3px rgba(40, 20, 0, .3);
  transition: translate .22s var(--ease);
}
.switch input:checked + .switch-ui { background: var(--moss); }
.switch input:checked + .switch-ui::after { translate: 18px 0; }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch:hover .switch-ui { background: rgba(58, 42, 31, .3); }
.switch:hover input:checked + .switch-ui { background: #7a9254; }

/* Thanh trượt */
.range {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 30px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: rgba(58, 42, 31, .17); }
.range::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(58, 42, 31, .17); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  border: 2px solid #fffaf0;
  background: radial-gradient(circle at 35% 30%, #ffe3a2, var(--turmeric) 62%, #c4840f);
  box-shadow: 0 1px 4px rgba(60, 36, 10, .45);
}
.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fffaf0;
  background: var(--turmeric);
  box-shadow: 0 1px 4px rgba(60, 36, 10, .45);
}
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(227, 162, 42, .45), 0 1px 4px rgba(60, 36, 10, .45); }
.range:disabled { opacity: .45; cursor: not-allowed; }

/* Nhóm lựa chọn dạng viên thuốc */
.seg {
  display: flex;
  gap: 3px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(58, 42, 31, .07);
}
.seg-it { position: relative; flex: 1; min-width: 0; }
.seg-it input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg-it span {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s, color .15s, box-shadow .15s;
  pointer-events: none;
}
.seg-it:hover span { color: var(--ink); }
.seg-it input:checked + span { background: var(--paper-hi); color: var(--ink); box-shadow: var(--sh-1); }
.seg-it input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg-it input:disabled { cursor: not-allowed; }

.badge {
  position: absolute;
  top: -7px;
  right: -13px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--lacquer);
  color: #fff7ea;
  font: 700 11px/19px var(--font);
  text-align: center;
  box-shadow: 0 0 0 2px #fbf4e4;
  animation: pop .3s var(--ease-out);
}

/* ================================================================ Màn chờ */
.loading {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  background: var(--grain), radial-gradient(120% 90% at 50% 38%, #faf2e1, #ecdcbc 62%, #dcc59c);
  color: var(--ink);
  transition: opacity .6s ease;
}
.loading.out { opacity: 0; pointer-events: none; }
.ld-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #fffaf0 0, #fbefd8 58%, rgba(251, 239, 216, 0) 70%);
}
.ld-mark::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(227, 162, 42, .22);
  border-top-color: var(--turmeric);
  animation: spin 1.8s linear infinite;
}
.ld-mark .ic {
  width: 58px;
  height: 58px;
  color: var(--lotus-deep);
  animation: breathe 3.4s ease-in-out infinite;
}
.ld-lotus { --i: url("/icons/lotus.svg"); }
.ld-name { margin: 0; font: 700 32px/1.15 var(--serif); letter-spacing: -.01em; }
.ld-text { margin: 0; font-size: 15px; color: var(--ink-2); }
.ld-bar { width: 168px; height: 3px; margin-top: 14px; border-radius: 3px; background: rgba(58, 42, 31, .12); overflow: hidden; }
.ld-bar span { display: block; width: 42%; height: 100%; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--turmeric), transparent); animation: slide 1.5s ease-in-out infinite; }

/* ================================================================ Màn chào */
.welcome {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s ease;
}
.welcome.on { opacity: 1; }
.welcome.out { opacity: 0; }
.w-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 90% at 0% 50%, rgba(246, 236, 214, .78), rgba(246, 236, 214, 0) 70%),
    linear-gradient(90deg, rgba(246, 236, 214, .9) 0%, rgba(246, 236, 214, .72) 28%, rgba(246, 236, 214, .22) 50%, rgba(246, 236, 214, 0) 66%);
}
.w-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(470px, calc(100% - 48px));
  max-height: 100%;
  margin-left: clamp(24px, 7.5vw, 128px);
  padding: 28px 2px;
  overflow-y: auto;
  scrollbar-width: none;
  pointer-events: auto;
}
.w-inner::-webkit-scrollbar { display: none; }
.w-head { padding: 0 2px; }
.eyebrow {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--lacquer);
}
.w-title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0;
  font: 700 clamp(42px, 4.3vw, 60px)/1.02 var(--serif);
  letter-spacing: -.02em;
  white-space: nowrap;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 250, 238, .6);
}
.w-seal { width: 54px; height: 54px; font-size: 16px; letter-spacing: .02em; translate: 0 -6px; }
.w-card { max-width: 452px; }
.w-lede {
  margin: 12px 0 0;
  max-width: 38ch;
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--ink-2);
}
.w-card {
  display: grid;
  gap: 18px;
  padding: 22px 22px 18px;
  border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), var(--sh-2);
}
.fld { display: grid; gap: 9px; min-width: 0; margin: 0; padding: 0; border: 0; }
.fld-lb { padding: 0; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.inp-wrap { position: relative; }
.inp-wrap .inp { padding-right: 58px; }
.inp-count {
  position: absolute;
  right: 14px;
  top: 50%;
  translate: 0 -50%;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.sw {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 4px 0 2px;
  border-radius: 14px;
  cursor: pointer;
}
.sw input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.sw-dot {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%), var(--c);
  box-shadow: inset 0 0 0 1px rgba(58, 42, 31, .22), 0 2px 6px -1px rgba(58, 36, 18, .3);
  transition: transform .15s var(--ease), box-shadow .15s;
  pointer-events: none;
}
.sw-dot .ic { width: 20px; height: 20px; color: #fff; opacity: 0; scale: .5; transition: opacity .15s, scale .2s var(--ease-out); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.sw input[value="trang"] + .sw-dot .ic, .sw input[value="vang"] + .sw-dot .ic { color: var(--ink); filter: none; }
.sw:hover .sw-dot { transform: translateY(-2px); }
.sw input:checked + .sw-dot { box-shadow: inset 0 0 0 1px rgba(58, 42, 31, .22), 0 0 0 3px var(--paper-hi), 0 0 0 5.5px var(--turmeric-deep); }
.sw input:checked + .sw-dot .ic { opacity: 1; scale: 1; }
.sw input:focus-visible + .sw-dot { outline: 3px solid var(--focus); outline-offset: 6px; }
.sw-lb { font-size: 12.5px; font-weight: 500; line-height: 1.2; text-align: center; color: var(--ink-2); pointer-events: none; }
.sw input:checked ~ .sw-lb { color: var(--ink); font-weight: 700; }
.w-go { width: 100%; margin-top: 2px; }
.w-go .spin {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(58, 36, 14, .22);
  border-top-color: #3a240e;
  animation: spin .8s linear infinite;
}
.w-card.busy .w-go .spin { display: inline-block; }
.w-card.busy .w-go-ic { display: none; }
.w-card.busy .w-go:disabled { opacity: .85; cursor: progress; }
.w-msg { display: flex; align-items: center; gap: 7px; margin: -4px 2px 0; font-size: 14px; color: var(--ink-2); }
.w-msg:empty { display: none; }
.w-msg .ic { width: 17px; height: 17px; }
.w-msg.err { color: var(--lacquer); font-weight: 600; }
.w-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 4px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.w-hint .ic { width: 18px; height: 18px; color: var(--turmeric-deep); }

/* ================================================================ HUD */
.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s ease;
  -webkit-user-select: none;
  user-select: none;
}
.hud.on { opacity: 1; }

/* --- Thẻ nơi chốn */
.place {
  position: absolute;
  top: var(--top);
  left: calc(var(--gut) + var(--safe-l));
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(330px, calc(100vw - 2 * var(--gut)));
  padding: 9px 20px 9px 9px;
  border-radius: 24px;
  pointer-events: auto;
}
.place-logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #fff8e8, #f8e1c6 64%, #f0cdb0);
  box-shadow: inset 0 0 0 1px rgba(177, 77, 106, .22), 0 2px 6px -2px rgba(120, 50, 40, .35);
  color: var(--lotus-deep);
}
.place-logo .ic { width: 30px; height: 30px; }
.place-tx { min-width: 0; }
.place-tx p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place-name { font: 700 16px/1.2 var(--serif); color: var(--ink); }
.place-zone { display: flex; align-items: center; gap: 5px; margin-top: 3px !important; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.place-zone .ic { width: 14px; height: 14px; color: var(--lacquer); }
.place-zone span { overflow: hidden; text-overflow: ellipsis; }
.place-zone.flip span { animation: zoneIn .5s var(--ease-out); }
.place-online { display: flex; align-items: center; gap: 7px; margin-top: 2px !important; font-size: 12.5px; color: var(--ink-2); }
.live-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5c9a3b;
  box-shadow: 0 0 0 0 rgba(92, 154, 59, .55);
  animation: live 2.6s ease-out infinite;
}
.place-n { display: none; }

/* --- Góc trên phải: công cụ + bản đồ */
.hud-tr {
  position: absolute;
  top: var(--top);
  right: calc(var(--gut) + var(--safe-r));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.tools {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  pointer-events: auto;
}
.tools .ibtn { color: var(--ink-2); }
.tools .ibtn.is-off { color: var(--lacquer); }
.tool-more { display: none !important; }
.tools-menu {
  position: absolute;
  top: 58px;
  right: 0;
  z-index: 6;
  display: grid;
  gap: 2px;
  min-width: 220px;
  padding: 6px;
  border-radius: 18px;
  pointer-events: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), var(--sh-2);
  animation: menuIn .2s var(--ease-out);
}
.menu-it {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.menu-it .ic { width: 20px; height: 20px; color: var(--ink-2); }
.menu-it:hover, .menu-it:focus-visible { background: rgba(255, 251, 241, .95); }

/* --- Bản đồ nhỏ */
.mm { position: relative; display: flex; flex-direction: column; align-items: flex-end; pointer-events: none; }
.mm-card {
  position: relative;
  width: 214px;
  padding: 6px;
  border-radius: 20px;
  pointer-events: auto;
  animation: menuIn .25s var(--ease-out);
}
.mm-body { position: relative; aspect-ratio: 1; border-radius: 15px; overflow: hidden; background: #bcc08f; }
.mm-cv { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: manipulation; }
.mm-hd {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(251, 246, 233, .86);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  pointer-events: none;
}
.mm-x { position: absolute !important; top: 9px; right: 9px; z-index: 2; background: rgba(251, 246, 233, .88); }
.mm-x:hover { background: #fffbf2; }
.mm-n {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(251, 246, 233, .88);
  color: var(--lacquer);
  font-size: 10.5px;
  pointer-events: none;
}
.mm-n { align-content: center; gap: 1px; font-weight: 700; }
.mm-n::before { content: ''; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 6px solid currentColor; }
.mm-n b { line-height: 1; }
.mm-me { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.mm-me::before {
  content: '';
  position: absolute;
  left: -12px;
  top: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(179, 55, 42, .75);
  animation: ping 2.2s ease-out infinite;
}
.mm-rip {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.mm-rip::before {
  content: '';
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff6dc;
  animation: ping .7s ease-out forwards;
}
.mm-open { pointer-events: auto; width: 48px !important; height: 48px !important; color: var(--ink); }
.mm-open .ic { width: 23px; height: 23px; }

/* --- Cột nút hành động (nhãn bên trái nút tròn).
   Chiều cao bị giới hạn bởi đáy cụm trên phải (--tr-b, đo bằng JS); thừa nút thì tràn sang cột bên trái. */
.actions {
  --act-b: calc(var(--dock-b) + var(--dock-h) + 52px);
  position: absolute;
  right: calc(var(--gut) + var(--safe-r));
  bottom: var(--act-b);
  max-height: calc(100vh - var(--tr-b, 300px) - 14px - var(--act-b));
  max-height: calc(100dvh - var(--tr-b, 300px) - 14px - var(--act-b));
  display: flex;
  flex-direction: column;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  align-content: flex-start;
  align-items: flex-start;
  gap: 10px 16px;
  pointer-events: none;
}
.act {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  animation: actIn .35s var(--ease-out) both;
}
.act-orb {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: var(--ink);
  background: radial-gradient(circle at 50% 28%, #fffbf2, #f3e5c8 72%, #e7d3ad);
  border: 1px solid rgba(255, 251, 240, .9);
  box-shadow: inset 0 -3px 7px rgba(120, 84, 40, .2), var(--sh-1);
  transition: transform .15s var(--ease), box-shadow .2s;
}
.act-orb .ic { width: 26px; height: 26px; }
.act-lb {
  max-width: 180px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(252, 247, 236, .92);
  box-shadow: 0 1px 4px rgba(62, 38, 14, .22);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color .15s;
}
.act:hover .act-lb { background: #fffaf0; }
.act:hover .act-orb { transform: translateY(-2px); }
.act:active .act-orb { transform: scale(.94); }
.act:focus-visible { outline: none; }
.act:focus-visible .act-orb { outline: 3px solid var(--focus); outline-offset: 3px; }
.act.primary .act-orb {
  background: radial-gradient(circle at 50% 26%, #ffeab0, #f0b744 56%, #d8921c);
  border-color: rgba(255, 241, 205, .95);
  color: #3a240e;
  box-shadow: inset 0 -3px 7px rgba(140, 80, 0, .28), 0 0 0 4px rgba(243, 195, 90, .3), 0 10px 24px -8px rgba(170, 105, 10, .8);
}
.act.primary .act-orb::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(243, 195, 90, .7);
  animation: halo 2.4s ease-out infinite;
}
.act.primary .act-lb { background: #fbe7b3; }
.act.active .act-orb {
  box-shadow: 0 0 0 3px #fff6dc, 0 0 0 6px var(--turmeric), 0 0 26px 6px rgba(243, 195, 90, .6);
}
.act.active .act-lb { background: var(--ink); color: var(--paper-hi); }
.act:disabled { cursor: not-allowed; }
.act:disabled .act-orb { opacity: .5; filter: grayscale(.5); transform: none; }
.act:disabled .act-lb { opacity: .7; }
.act.leave { animation: actOut .2s forwards; pointer-events: none; }
.act-side .act-lb { display: none; }

/* --- Giữa dưới: các bảng tu tập + trạng thái */
.hud-bc {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dock-b) + var(--dock-h) + 10px);
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(640px, calc(100vw - 2 * var(--gut)));
  pointer-events: none;
}
.stage { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 38px;
  padding: 6px 16px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}
.status.on { animation: rise .35s var(--ease-out); }
.status-ic .ic { width: 18px; height: 18px; color: var(--turmeric-deep); }
.status-tx { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Dock */
.dock {
  position: absolute;
  left: 50%;
  bottom: var(--dock-b);
  translate: -50% 0;
  width: max-content;
  max-width: calc(100vw - 2 * var(--gut));
  padding: 6px;
  border-radius: 26px;
  pointer-events: auto;
}
.dock-row { display: flex; gap: 2px; }
.dock-it {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  width: 74px;
  height: 56px;
  padding: 0 2px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color .15s, color .15s, transform .12s;
}
.dock-ic { position: relative; display: grid; place-items: center; }
.dock-ic .ic { width: 23px; height: 23px; }
.dock-lb { font-size: 12px; font-weight: 600; letter-spacing: -.005em; white-space: nowrap; }
.dock-it:hover { background: rgba(255, 251, 241, .82); color: var(--ink); }
.dock-it:active { transform: scale(.95); }
.dock-it.on { background: rgba(255, 251, 241, .96); color: var(--lacquer-deep); box-shadow: inset 0 0 0 1px rgba(173, 53, 40, .16), 0 1px 3px rgba(62, 38, 14, .14); }
.dock-it.on::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 50%;
  width: 16px;
  height: 3px;
  translate: -50% 0;
  border-radius: 2px;
  background: var(--lacquer);
}
.dock-it:focus-visible { outline-offset: -2px; }

/* --- Trò chuyện */
.chatbox {
  position: absolute;
  z-index: 4;
  left: calc(var(--gut) + var(--safe-l));
  bottom: var(--dock-b);
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 8px;
  width: 340px;
  pointer-events: none;
}
.chat {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: min(440px, calc(100vh - 340px));
  min-height: 250px;
  border-radius: 22px;
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(12px) scale(.98);
  transform-origin: 0 100%;
  transition: opacity .22s ease, transform .26s var(--ease-out);
}
.chat.on { opacity: 1; transform: none; }
.chat-hd {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 6px 6px 6px 16px;
  border-bottom: 1px solid var(--line);
}
.chat-hd > .ic { width: 18px; height: 18px; color: var(--lacquer); }
.chat-hd h2 { flex: 1; margin: 0; font: 700 16px/1.2 var(--serif); }
.chat-grip { display: none; }
.chat-mid { position: relative; flex: 1; min-height: 0; }
.chat-log {
  height: 100%;
  padding: 12px 12px 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(58, 42, 31, .25) transparent;
  -webkit-user-select: text;
  user-select: text;
}
.chat-log:focus-visible { outline-offset: -3px; }
.chat-empty { margin: 30px 16px; text-align: center; font-size: 13.5px; color: var(--ink-3); }
.msg { max-width: 88%; margin: 0 0 9px; animation: msgIn .25s var(--ease-out); }
.msg.cont { margin-top: -5px; }
.msg-hd { display: flex; align-items: baseline; gap: 6px; margin: 0 0 3px 3px; font-size: 12.5px; line-height: 1.2; }
.msg-nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.msg-lv {
  flex: none;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(173, 53, 40, .1);
  color: var(--lacquer-deep);
  font-size: 10.5px;
  font-weight: 700;
}
.msg-t { flex: none; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.msg-tx {
  margin: 0;
  padding: 7px 12px;
  border-radius: 5px 16px 16px 16px;
  background: rgba(255, 253, 247, .94);
  box-shadow: 0 1px 2px rgba(58, 36, 18, .1);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.cont .msg-tx { border-radius: 16px; }
.msg.me { margin-left: auto; }
.msg.me .msg-hd { justify-content: flex-end; margin-right: 3px; }
.msg.me .msg-tx { background: #f8dfa4; border-radius: 16px 5px 16px 16px; }
.msg.me.cont .msg-tx { border-radius: 16px; }
.msg.sys {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 7px;
  max-width: 100%;
  margin: 2px 0 9px;
  text-align: center;
}
.msg.sys .msg-tx { padding: 0; background: none; box-shadow: none; font-size: 12.5px; font-style: italic; color: var(--ink-3); }
.msg.sys .msg-t { font-size: 10.5px; opacity: .85; }
.chat-jump {
  position: absolute;
  left: 50%;
  bottom: 8px;
  translate: -50% 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 12px 0 8px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-hi);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--sh-1);
  animation: rise .25s var(--ease-out);
}
.chat-jump .ic { width: 16px; height: 16px; }
.chat-chips {
  display: flex;
  flex: none;
  gap: 6px;
  padding: 8px 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid var(--line);
  -webkit-mask: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
  mask: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
  padding-right: 36px;
}
.chat-chips::-webkit-scrollbar { display: none; }
.chat-chips .chip { min-height: 32px; padding: 0 11px; font-size: 13px; }
.chat-form { display: flex; flex: none; align-items: center; gap: 6px; padding: 8px 8px 10px 12px; }
.chat-inp { position: relative; flex: 1; min-width: 0; }
.chat-in { min-height: 44px; padding: 0 16px; border-radius: 999px; font-size: 15px; }
.chat-count {
  position: absolute;
  right: 14px;
  top: 50%;
  translate: 0 -50%;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.chat-count.full { color: var(--lacquer); font-weight: 700; }
.chat-send { background: var(--turmeric); color: #3a240e; }
.chat-send:hover { background: var(--turmeric-hi); color: #3a240e; }
.chat-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px 0 15px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  transition: transform .12s;
}
.chat-pill .ic { width: 20px; height: 20px; color: var(--lacquer); }
.chat-pill:hover { background: var(--grain), linear-gradient(180deg, rgba(255, 252, 244, .92), rgba(248, 238, 218, .86)); }
.chat-pill:active { transform: scale(.97); }
.chat-pill .badge { position: static; margin-left: 2px; }
.chatbox.open .chat-pill { display: none; }
.chat-peek {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 300px;
  padding: 8px 13px;
  border: 0;
  border-radius: 16px 16px 16px 5px;
  background: rgba(255, 253, 247, .95);
  box-shadow: var(--sh-1);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0;
  translate: 0 6px;
  transition: opacity .3s, translate .3s var(--ease-out);
}
.chat-peek.on { opacity: 1; translate: 0 0; }
.chat-peek b { font-weight: 700; }

/* ================================================================ Bảng tu tập (thiền, kinh, chuỗi) */
.pp {
  position: relative;
  width: 100%;
  padding: 12px 14px 14px;
  border-radius: 24px;
  pointer-events: auto;
  opacity: 0;
  translate: 0 12px;
  transition: opacity .25s ease, translate .3s var(--ease-out);
}
.pp.on, .medi.on { opacity: 1; translate: 0 0; }
.pp-hd { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: -2px 0 8px; }
.pp-ic { display: grid; place-items: center; flex: none; color: var(--lacquer); }
.pp-ic .ic { width: 20px; height: 20px; }
.pp-title { flex: none; margin: 0; font: 700 16.5px/1.2 var(--serif); }
.pp-hd > .ibtn { margin-left: auto; }

/* --- Thiền */
.medi {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(560px, 100%);
  padding: 10px 14px 10px 10px;
  border-radius: 999px;
  pointer-events: auto;
  opacity: 0;
  translate: 0 12px;
  transition: opacity .25s ease, translate .3s var(--ease-out);
}
.breath { position: relative; display: grid; place-items: center; flex: none; width: 100px; height: 100px; }
.medi-ring { position: absolute; inset: 0; width: 100%; height: 100%; rotate: -90deg; }
.medi-track { fill: none; stroke: rgba(58, 42, 31, .1); stroke-width: 3; }
.medi-prog { fill: none; stroke: var(--turmeric); stroke-width: 3.5; stroke-linecap: round; opacity: 0; transition: stroke-dashoffset .9s linear, opacity .3s; }
.medi.timed .medi-prog { opacity: 1; }
.medi.done .medi-prog { stroke: var(--moss); }
.breath-orb {
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 36%, rgba(255, 251, 238, .98), rgba(248, 214, 206, .92) 52%, rgba(230, 142, 164, .82));
  box-shadow: 0 0 26px rgba(230, 142, 164, .5), inset 0 -5px 12px rgba(177, 77, 106, .25);
  scale: .74;
}
.breath-orb.run { animation: breath 10s infinite; }
.breath-tx { position: relative; font-size: 12.5px; font-weight: 700; color: var(--ink); text-align: center; line-height: 1.1; }
.medi.no-breath .breath-orb { scale: .86; opacity: .55; box-shadow: none; }
.medi.no-breath .breath-tx { color: var(--ink-2); font-weight: 600; }
.medi-main { display: grid; gap: 8px; flex: 1; min-width: 0; }
.medi-top { display: flex; align-items: center; gap: 8px; }
.medi-time { display: grid; flex: 1; min-width: 0; }
.medi-lb { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.medi.done .medi-lb { color: var(--moss-deep); }
.medi-clock { font: 700 30px/1.05 var(--serif); font-variant-numeric: tabular-nums; color: var(--ink); }
.medi-bt[aria-pressed="false"] { color: var(--ink-3); }
.medi-bt[aria-pressed="true"] { background: rgba(230, 142, 164, .18); border-color: rgba(177, 77, 106, .35); color: var(--lotus-deep); }
.medi-end { min-height: 42px; padding: 0 16px; }
.medi-end .ic { color: var(--turmeric-deep); }
.medi-pres { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.medi-pres::-webkit-scrollbar { display: none; }
.medi-pre { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* --- Tụng kinh */
.chant { width: min(640px, 100%); }
.chant-tabs { flex: 1; min-width: 0; display: flex; justify-content: flex-end; }
.chant-body { display: flex; align-items: stretch; gap: 12px; }
.chant-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.chant-head { padding: 0 4px 6px; }
.chant-title { margin: 0; font: 700 18px/1.25 var(--serif); color: var(--ink); }
.chant-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.chant-lines {
  position: relative;
  height: 160px;
  padding: 52px 6px 78px;
  overflow-y: auto;
  scrollbar-width: none;
  border-radius: 14px;
  background: rgba(255, 253, 247, .5);
  box-shadow: inset 0 0 0 1px var(--line);
  -webkit-mask: linear-gradient(transparent 0, #000 26%, #000 70%, transparent 100%);
  mask: linear-gradient(transparent 0, #000 26%, #000 70%, transparent 100%);
}
.chant-lines::-webkit-scrollbar { display: none; }
.chant-lines:focus { outline: none; }
.ln {
  position: relative;
  margin: 0;
  padding: 4px 10px 4px 24px;
  border-radius: 9px;
  font: 500 16.5px/1.5 var(--serif);
  color: rgba(58, 42, 31, .66);
  transition: color .3s, opacity .3s, background-color .3s;
}
.ln.done { opacity: .4; }
.ln.now {
  color: var(--ink);
  font-weight: 700;
  background: linear-gradient(90deg, rgba(243, 195, 90, .32), rgba(243, 195, 90, 0) 90%);
}
.ln.now::before {
  content: '';
  position: absolute;
  left: 9px;
  top: calc(.75em + 1px);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lacquer);
}
.chant-err { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 12px; font-size: 14px; color: var(--lacquer); }
.chant-side { display: grid; justify-items: center; align-content: center; gap: 8px; flex: none; width: 118px; }
.mo-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 106px;
  height: 106px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 28%, #c58b58, #8c5732 52%, #5c3419);
  box-shadow: inset 0 3px 6px rgba(255, 222, 172, .35), inset 0 -9px 16px rgba(40, 20, 8, .45), 0 12px 24px -10px rgba(60, 30, 10, .85);
  color: #f8e6c4;
  cursor: pointer;
  transition: transform .1s, filter .15s;
}
.mo-btn:hover { filter: brightness(1.06); }
.mo-btn:active { transform: scale(.95); }
.mo-btn:disabled { opacity: .5; cursor: not-allowed; }
.mo-btn:focus-visible { outline-offset: 4px; }
.mo-face { display: grid; place-items: center; }
.mo-face .ic { width: 62px; height: 62px; filter: drop-shadow(0 1px 0 rgba(60, 30, 10, .5)); }
.mo-btn.hit { animation: moHit .2s ease-out; }
.mo-wave { position: absolute; inset: -5px; border-radius: 50%; border: 2.5px solid rgba(243, 195, 90, .85); opacity: 0; pointer-events: none; }
.mo-btn.hit .mo-wave { animation: moWave .7s ease-out; }
.mo-hint { display: grid; justify-items: center; gap: 5px; font-size: 13px; color: var(--ink-2); }
.chant-ft { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-top: 8px; padding: 0 4px; }
.chant-prog { display: flex; align-items: center; gap: 10px; flex: 1 1 100%; min-height: 26px; }
.bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(58, 42, 31, .12); overflow: hidden; }
.bar-fill { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--turmeric), var(--lotus)); transition: width .35s var(--ease); }
.chant-count { font-size: 12.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tempo { display: flex; align-items: center; gap: 10px; flex: 1 1 240px; min-width: 0; font-size: 13px; color: var(--ink-2); }
.tempo-lb { font-weight: 600; }
.tempo-u { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tempo-v { display: inline-block; min-width: 2.2ch; text-align: right; font-weight: 700; color: var(--ink); }
.chant:not(.auto) .tempo .range { opacity: .7; }
.chant-note {
  position: absolute;
  top: -16px;
  left: 50%;
  translate: -50% 0;
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-hi);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.chant-note.on { opacity: 1; animation: rise .4s var(--ease-out); }

/* --- Lần chuỗi */
.beads { width: min(500px, 100%); }
.beads-body { display: flex; align-items: center; gap: 18px; }
.mala {
  position: relative;
  flex: none;
  width: 190px;
  height: 200px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.mala:focus-visible { outline-offset: 0; }
.mala-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mala-cord { fill: none; stroke: rgba(122, 82, 53, .35); stroke-width: 1; }
.mala-beads circle { transition: fill .35s; }
.mala-beads circle.on { fill: url(#bead-on); }
.mala-guru { stroke: rgba(60, 30, 10, .35); stroke-width: .6; }
.mala-tassel { fill: var(--lacquer); }
.mala-cur { transform-origin: 110px 104px; transition: transform .3s var(--ease-out); }
.mala-halo { fill: rgba(243, 195, 90, .38); }
.mala-dot { stroke: #fff6dc; stroke-width: 1.3; }
.mala-cur.rest .mala-halo { animation: blink 2s ease-in-out infinite; }
.mala-c {
  position: absolute;
  left: 50%;
  top: 44.8%;
  translate: -50% -50%;
  display: grid;
  justify-items: center;
  pointer-events: none;
}
.mala-n { font: 700 42px/1 var(--serif); font-variant-numeric: tabular-nums; color: var(--ink); }
.mala-of { margin-top: 2px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.mala.tap .mala-n { animation: tick .25s var(--ease-out); }
.mala:hover .mala-cord { stroke: rgba(122, 82, 53, .6); }
.beads.full .mala-svg { animation: glow 1.8s ease-out; }
.beads-side { display: grid; justify-items: start; gap: 10px; flex: 1; min-width: 0; }
.beads-phrase { margin: 0; font: 700 20px/1.35 var(--serif); color: var(--lacquer-deep); }
.beads-phrase.say { animation: say 1.1s var(--ease-out); }
.beads-meta { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.beads-act { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ================================================================ Hiệu ứng nổi */
.fx { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.toasts {
  position: absolute;
  top: calc(var(--top) + 4px);
  left: 50%;
  translate: -50% 0;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(460px, calc(100vw - 2 * var(--gut)));
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 18px 8px 8px;
  border-radius: 18px;
  background: var(--grain), linear-gradient(180deg, rgba(253, 249, 240, .97), rgba(246, 237, 219, .95));
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--sh-2);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.4;
  pointer-events: auto;
  cursor: pointer;
  animation: toastIn .38s var(--ease-out);
}
.toast.out { animation: toastOut .26s ease forwards; }
.toast.bump { animation: bump .32s var(--ease-out); }
.toast-ic { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: rgba(58, 42, 31, .08); color: var(--ink-2); }
.toast-ic .ic { width: 18px; height: 18px; }
.k-ok .toast-ic { background: rgba(107, 130, 71, .17); color: var(--moss-deep); }
.k-warn .toast-ic { background: rgba(173, 53, 40, .13); color: var(--lacquer); }
.k-merit .toast-ic { background: linear-gradient(140deg, #ffe7a8, #f7bccb); color: var(--lacquer-deep); }
.k-merit { box-shadow: var(--sh-2), 0 0 0 1px rgba(243, 195, 90, .45); }

.tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 45;
  max-width: 260px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(40, 28, 20, .93);
  color: #fbf2e0;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .55);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s, visibility 0s .12s;
  will-change: transform;
}
.tooltip.on { opacity: 1; visibility: visible; transition: opacity .12s; }
.tooltip b { display: block; font-size: 13.5px; font-weight: 700; }
.tooltip span { display: block; margin-top: 1px; font-size: 12.5px; color: #ead8b6; }

.merit-fly {
  position: absolute;
  translate: -50% -50%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px 7px 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 249, 232, .96), rgba(251, 233, 190, .94));
  border: 1.5px solid rgba(227, 162, 42, .75);
  box-shadow: 0 0 22px rgba(255, 214, 120, .65), 0 6px 16px -8px rgba(120, 70, 0, .6);
  font: 700 18px/1 var(--serif);
  color: #7c4500;
  white-space: nowrap;
  animation: meritUp 1.9s var(--ease-out) forwards;
}
.merit-fly .ic { width: 18px; height: 18px; color: var(--turmeric-deep); }

.lvup {
  position: absolute;
  top: 21%;
  left: 50%;
  translate: -50% 0;
  width: max-content;
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: calc(100vw - 32px);
  padding: 16px 28px 16px 16px;
  border-radius: 26px;
  background: var(--grain), linear-gradient(180deg, rgba(253, 249, 239, .97), rgba(245, 233, 208, .95));
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--sh-2), 0 0 60px -10px rgba(243, 195, 90, .55);
  animation: lvIn .55s var(--ease-out) both;
}
.lvup.out { animation: lvOut .6s ease forwards; }
.lvup-seal { width: 76px; height: 76px; flex: none; animation: stamp .6s .12s cubic-bezier(.2, 1.3, .4, 1) both; }
.lvup-k { font: 700 11px/1 var(--font); letter-spacing: .12em; text-transform: uppercase; }
.lvup-n { font-size: 34px; line-height: 1; }
.lvup-t { margin: 0; font: 700 23px/1.2 var(--serif); color: var(--ink); }
.lvup-s { margin: 4px 0 0; font-size: 14.5px; color: var(--ink-2); }

.shutter { position: fixed; inset: 0; background: #fffaf0; opacity: 0; pointer-events: none; animation: shutter .55s ease-out; }

/* ================================================================ Sheet */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}
.sheet-bg {
  position: absolute;
  inset: 0;
  background: rgba(46, 30, 16, .34);
  opacity: 0;
  transition: opacity .22s ease;
}
.sheet-wrap.on .sheet-bg { opacity: 1; }
.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(540px, 100%);
  max-height: min(84vh, 780px);
  max-height: min(84dvh, 780px);
  border-radius: 26px;
  overflow: hidden;
  background: var(--grain), linear-gradient(180deg, rgba(252, 247, 236, .95), rgba(244, 234, 213, .93));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), var(--sh-2);
  opacity: 0;
  translate: 0 14px;
  scale: .985;
  transition: opacity .22s ease, translate .3s var(--ease-out), scale .3s var(--ease-out);
}
.sheet.wide { width: min(800px, 100%); }
.sheet-wrap.on .sheet { opacity: 1; translate: 0 0; scale: 1; }
.sheet:focus { outline: none; }
.sheet-hd {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 14px 12px 12px 26px;
  border-bottom: 1px solid var(--line);
}
.sheet-grip { display: none; }
.sheet-title { flex: 1; min-width: 0; margin: 0; font: 700 22px/1.25 var(--serif); letter-spacing: -.01em; }
.sheet-body {
  padding: 18px 26px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(58, 42, 31, .25) transparent;
  -webkit-user-select: text;
  user-select: text;
}
.sheet-lede { margin: 0 0 12px; font-size: 14px; color: var(--ink-2); }
.sheet-foot { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 13px; color: var(--ink-3); }
.sheet-foot .ic { width: 16px; height: 16px; }
.empty {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px dashed var(--line-2);
  background: rgba(255, 253, 247, .55);
  font-size: 14px;
  color: var(--ink-2);
}
.empty .ic { width: 20px; height: 20px; color: var(--moss); }
.lv-chip {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(173, 53, 40, .1);
  color: var(--lacquer-deep);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

/* --- Đi đến */
.places { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.place-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  gap: 2px 14px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, .7);
  transition: background-color .15s, box-shadow .15s, border-color .15s;
}
.place-card:hover { background: #fffdf7; box-shadow: var(--sh-1); }
.pc-ic {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: linear-gradient(160deg, #fbe9c4, #f1d29a);
  color: var(--wood-deep);
}
.pc-ic .ic { width: 27px; height: 27px; }
.pc-tx h3 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.3; }
.pc-tx p { margin: 2px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.place-card .btn { grid-column: 2; justify-self: start; margin-top: 10px; }
.btn.go { background: #fffaf0; border-color: rgba(154, 100, 10, .35); color: var(--ink); }
.btn.go .ic { color: var(--turmeric-deep); }
.btn.go:hover, .place-card:hover .btn.go { background: linear-gradient(180deg, #f6c75c, #e5a42c 55%, #d9951c); border-color: rgba(140, 88, 8, .45); color: #3a240e; }
.btn.go:hover .ic, .place-card:hover .btn.go .ic { color: #3a240e; }
.place-card.here { border-color: rgba(173, 53, 40, .28); background: rgba(255, 247, 233, .92); }
.place-card.here .pc-ic { background: linear-gradient(160deg, #f9d3c8, #eba79a); color: var(--lacquer-deep); }

/* --- Đạo hữu */
.people-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px 9px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, .7);
}
.person.me { background: rgba(248, 223, 164, .38); border-color: rgba(154, 100, 10, .3); }
.robe-dot {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%), var(--c, #888);
  box-shadow: inset 0 0 0 1px rgba(58, 42, 31, .22);
}
.person-tx { flex: 1; min-width: 0; }
.person-nm { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 700; }
.person-nm > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-at { margin: 1px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.me-tag { flex: none; padding: 0 12px; font-size: 12.5px; font-weight: 700; color: var(--turmeric-deep); }

/* --- Công phu */
.prac-head { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; padding: 2px 2px 18px; border-bottom: 1px solid var(--line); }
.prac-seal { width: 80px; height: 80px; flex: none; font-size: 12px; }
.prac-seal span { font-family: var(--font); letter-spacing: .1em; text-transform: uppercase; font-size: 11px; }
.prac-seal b { font-size: 34px; }
.prac-merit { flex: 1; min-width: 0; }
.prac-k { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.prac-v { margin: 0; font: 700 34px/1.1 var(--serif); font-variant-numeric: tabular-nums; color: var(--ink); }
.meter { height: 10px; margin: 9px 0 6px; border-radius: 6px; background: rgba(58, 42, 31, .1); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--turmeric), #eda15c 60%, var(--lotus)); }
.prac-next { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "ic v" "ic k";
  align-items: center;
  column-gap: 11px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, .72);
}
.stat.wide { grid-column: span 2; }
.stat-ic {
  grid-area: ic;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: rgba(227, 162, 42, .16);
  color: var(--turmeric-deep);
}
.stat-ic .ic { width: 22px; height: 22px; }
.stat.wide .stat-ic { background: rgba(107, 130, 71, .15); color: var(--moss-deep); }
.stat-v { grid-area: v; margin: 0; font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-k { grid-area: k; margin: 0; font-size: 12.5px; line-height: 1.3; color: var(--ink-2); }
.how { margin-top: 14px; font-size: 13.5px; color: var(--ink-2); }
.how summary { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 600; cursor: pointer; list-style: none; border-radius: 10px; }
.how summary::-webkit-details-marker { display: none; }
.how summary .ic { width: 18px; height: 18px; color: var(--turmeric-deep); }
.how p { margin: 4px 0 0; padding: 12px 14px; border-radius: 14px; background: rgba(255, 253, 247, .65); line-height: 1.6; }

/* --- Bảng tinh tấn */
.board .tabs { margin-bottom: 14px; }
.rank { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.rank-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, .66);
}
.rank-no {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(58, 42, 31, .07);
  color: var(--ink-2);
  font: 700 14px/1 var(--serif);
  font-variant-numeric: tabular-nums;
}
.top1 .rank-no { background: linear-gradient(160deg, #ffe08c, #e3a22a); color: #4a2c00; }
.top2 .rank-no { background: linear-gradient(160deg, #f3efe6, #c9c1b0); color: #3d362c; }
.top3 .rank-no { background: linear-gradient(160deg, #f2cda8, #c2834f); color: #3f2310; }
.rank-nm { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.rank-nm > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-v { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.rank-row.me { background: rgba(248, 223, 164, .42); border-color: rgba(154, 100, 10, .34); }

/* --- Hướng dẫn */
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.help-it {
  display: flex;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, .66);
}
.help-ic { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 13px; background: rgba(107, 130, 71, .15); color: var(--moss-deep); }
.help-ic .ic { width: 23px; height: 23px; }
.help-it h3 { margin: 0 0 3px; font-size: 15.5px; font-weight: 700; }
.help-it p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.dock-key { margin-top: 16px; padding: 14px 16px; border-radius: 18px; background: rgba(58, 42, 31, .05); }
.dock-key h3, .keys h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; }
.dock-key h3 .ic, .keys h3 .ic { width: 19px; height: 19px; color: var(--ink-2); }
.dock-key ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px 12px; margin: 0; padding: 0; list-style: none; }
.dock-key li { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.dock-key li .ic { width: 20px; height: 20px; color: var(--ink); }
.keys { margin-top: 12px; padding: 14px 16px; border-radius: 18px; background: rgba(58, 42, 31, .05); }
.keys ul { display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 0; padding: 0; list-style: none; }
.keys li { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }

/* --- Cài đặt */
.settings { display: grid; }
.set-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.set-row:first-child { padding-top: 2px; }
.set-row:last-child { border-bottom: 0; padding-bottom: 0; }
.set-lb { flex: 1 1 200px; min-width: 0; }
.set-lb h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.set-lb p { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.seg-q { flex: 0 1 260px; }
.vol { display: flex; align-items: center; gap: 10px; flex: 0 1 260px; min-width: 200px; }
.vol .ic { width: 20px; height: 20px; color: var(--ink-2); }
.vol-v { width: 44px; text-align: right; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ================================================================ Nhãn tên & bong bóng chat (CSS2D) */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 4px 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .65);
  background: rgba(252, 246, 233, .86);
  box-shadow: 0 1px 4px rgba(40, 24, 10, .28);
  color: var(--ink);
  font: 700 12px/1.2 var(--font);
  white-space: nowrap;
  pointer-events: none !important;
  -webkit-user-select: none;
  user-select: none;
}
.tag .nm { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.tag .lv {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(173, 53, 40, .12);
  color: var(--lacquer-deep);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}
.tag.me {
  border: 1.5px solid var(--turmeric);
  background: rgba(255, 248, 228, .94);
  box-shadow: 0 0 0 2.5px rgba(243, 195, 90, .38), 0 1px 4px rgba(40, 24, 10, .28);
}
.tag.me .lv { background: rgba(227, 162, 42, .22); color: #7a4c00; }
.bubble {
  position: relative;
  width: max-content;
  max-width: 220px;
  padding: 7px 12px;
  border-radius: 15px;
  background: #fffefb;
  box-shadow: 0 6px 16px -6px rgba(40, 24, 10, .45), 0 0 0 1px rgba(58, 42, 31, .06);
  color: var(--ink);
  font: 500 13px/1.4 var(--font);
  text-align: center;
  overflow-wrap: anywhere;
  pointer-events: none !important;
  -webkit-user-select: none;
  user-select: none;
  animation: bubbleIn .3s var(--ease-out);
}
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 11px;
  height: 11px;
  translate: -50% 0;
  rotate: 45deg;
  border-radius: 0 0 3px 0;
  background: #fffefb;
}

/* ================================================================ Màn hình vừa */
@media (max-width: 1239px) {
  /* Khung chat nằm trên dock cho khỏi đè; nút thu gọn đã có trên dock */
  .chatbox { bottom: calc(var(--dock-b) + var(--dock-h) + 12px); width: 330px; }
  .chat { height: min(400px, calc(100vh - 420px)); }
  .chat-pill { display: none; }
}
@media (max-width: 960px) and (min-width: 761px) {
  .dock-it { width: 66px; }
  .dock-lb { font-size: 11.5px; }
}

/* ================================================================ Điện thoại */
@media (max-width: 760px) {
  :root { --gut: 12px; --dock-h: 60px; --dock-b: calc(8px + var(--safe-b)); }

  /* Màn chào: thẻ ở dưới, cảnh chùa phía trên */
  .welcome { align-items: flex-end; }
  .w-scrim { background: linear-gradient(0deg, rgba(246, 236, 214, .97) 0%, rgba(246, 236, 214, .92) 52%, rgba(246, 236, 214, .45) 74%, rgba(246, 236, 214, 0) 90%); }
  .w-inner { width: 100%; margin: 0; gap: 12px; padding: 20px 14px calc(14px + var(--safe-b)); }
  .eyebrow { margin-bottom: 4px; font-size: 11.5px; }
  .w-title { gap: 12px; font-size: clamp(36px, 10.5vw, 46px); }
  .w-seal { width: 46px; height: 46px; font-size: 14px; }
  .w-lede { margin-top: 8px; font-size: 15px; line-height: 1.5; }
  .w-card { gap: 14px; padding: 16px 16px 14px; border-radius: 22px; }
  .sw-dot { width: 40px; height: 40px; }
  .sw-lb { font-size: 11.5px; white-space: nowrap; }
  .seg-it span { min-height: 42px; padding: 0 8px; }
  .w-hint { font-size: 12.5px; }

  /* Thẻ nơi chốn gọn: ẩn tên chùa, rút gọn số người */
  .place { gap: 10px; padding: 6px 16px 6px 6px; max-width: calc(100vw - 2 * var(--gut) - 172px); }
  .place-nl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .place-n { display: inline; }
  .place-logo { width: 40px; height: 40px; }
  .place-logo .ic { width: 25px; height: 25px; }
  .place-name { display: none; }
  .place-zone { margin-top: 0 !important; font-size: 14px; color: var(--ink); }
  .place-online { font-size: 12px; }

  /* Công cụ: chỉ giữ loa + nút "Thêm" */
  .tools .tool-screenshot, .tools .tool-settings, .tools .tool-help, .tools .tool-fullscreen { display: none; }
  .tool-more { display: inline-grid !important; }
  .hud-tr { flex-direction: row; align-items: flex-start; gap: 8px; }
  .mm { position: static; order: -1; }
  .mm-open { width: 52px !important; height: 52px !important; }
  .mm-card { position: absolute; top: 60px; right: 0; width: 176px; padding: 5px; border-radius: 18px; }
  .mm-body { border-radius: 13px; }
  .mm-hd { display: none; }

  /* Cột hành động */
  .actions { --act-b: calc(var(--dock-b) + var(--dock-h) + 18px); gap: 8px 12px; }
  .act { gap: 8px; }
  .act-orb { width: 54px; height: 54px; }
  .act-orb .ic { width: 25px; height: 25px; }
  .act-lb { font-size: 12.5px; padding: 5px 10px; max-width: 150px; }

  /* Dock: chỉ còn biểu tượng */
  .dock { left: var(--gut); right: var(--gut); width: auto; translate: none; max-width: none; padding: 5px; border-radius: 24px; }
  .dock-row { justify-content: space-between; }
  .dock-it { flex: 1 1 0; width: auto; min-width: 44px; max-width: 64px; height: 50px; border-radius: 18px; }
  .dock-lb { display: none; }
  .dock-ic .ic { width: 25px; height: 25px; }
  .badge { top: -8px; right: -12px; }

  .hud-bc { width: calc(100vw - 2 * var(--gut)); bottom: calc(var(--dock-b) + var(--dock-h) + 8px); gap: 8px; }
  .status { font-size: 13.5px; min-height: 36px; }

  /* Chat: tấm trượt đáy */
  .chatbox { left: 0; right: 0; bottom: var(--kb, 0px); width: auto; gap: 0; }
  .chat {
    height: min(64vh, 560px);
    height: min(64dvh, 560px);
    max-height: calc(100vh - var(--kb, 0px) - 70px);
    max-height: calc(100dvh - var(--kb, 0px) - 70px);
    min-height: 0;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    padding-bottom: var(--safe-b);
    opacity: 1;
    transform: translateY(104%);
    transition: transform .32s var(--ease-out);
    box-shadow: 0 -10px 40px -12px rgba(62, 38, 14, .45);
  }
  .chat.on { transform: none; }
  .chat-hd { padding: 14px 6px 6px 18px; }
  .chat-grip { display: block; position: absolute; top: 6px; left: 50%; translate: -50% 0; width: 42px; height: 4px; border-radius: 2px; background: rgba(58, 42, 31, .22); }
  .chat-chips .chip { min-height: 38px; }
  .chat-pill, .chat-peek { display: none !important; }

  /* Bảng tu tập */
  .pp { padding: 10px 12px 12px; border-radius: 22px; }
  .medi {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "orb top" "pres pres";
    gap: 8px 12px;
    border-radius: 26px;
    padding: 10px 12px 12px;
  }
  .medi-main { display: contents; }
  .breath { grid-area: orb; }
  .medi-top { grid-area: top; }
  .medi-pres { grid-area: pres; }
  .medi-pre { flex: 1 1 0; min-width: 0; padding: 0 4px; }
  .breath { width: 84px; height: 84px; }
  .breath-orb { inset: 11px; }
  .breath-tx { font-size: 11.5px; }
  .medi-main { gap: 6px; }
  .medi-top { flex-wrap: wrap; }
  .medi-time { min-width: max-content; }
  .medi-clock { font-size: 26px; }
  .medi-bt span { display: none; }
  .medi-bt { padding: 0; width: 42px; min-height: 42px; }
  .medi-end { min-height: 42px; padding: 0 14px; }


  .pp-hd { flex-wrap: wrap; }
  .chant-tabs { order: 4; flex: 1 1 100%; justify-content: flex-start; }
  .chant {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "hd hd" "text text" "prog prog" "mo sw" "mo tempo";
    column-gap: 14px;
  }
  .chant > .pp-hd { grid-area: hd; }
  .chant-body, .chant-ft { display: contents; }
  .chant-text { grid-area: text; }
  .chant-prog { grid-area: prog; margin: 6px 0 2px; }
  .chant-side { grid-area: mo; align-self: center; }
  .chant .switch { grid-area: sw; min-height: 40px; }
  .chant .tempo { grid-area: tempo; }
  .chant-lines { height: 132px; padding: 40px 4px 60px; }
  .ln { font-size: 15.5px; padding-left: 22px; }
  .chant-head { display: flex; align-items: baseline; gap: 8px; padding-bottom: 4px; }
  .chant-sub { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chant-title { font-size: 16px; white-space: nowrap; }
  .chant-side { width: auto; gap: 4px; }
  .mo-btn { width: 76px; height: 76px; }
  .mo-face .ic { width: 44px; height: 44px; }
  .mo-hint { font-size: 12px; }

  .beads-body { gap: 12px; }
  .mala { width: 146px; height: 154px; }
  .mala-n { font-size: 34px; }
  .beads-phrase { font-size: 15.5px; }
  .beads-meta { font-size: 12.5px; }
  .beads-act kbd { display: none; }

  /* Hiệu ứng nổi */
  .toasts { top: calc(var(--top) + 60px); }
  .lvup { top: 18%; gap: 14px; padding: 14px 20px 14px 14px; }
  .lvup-seal { width: 64px; height: 64px; }
  .lvup-n { font-size: 28px; }
  .lvup-t { font-size: 20px; }
  .lvup-s { font-size: 13.5px; }

  /* Sheet → tấm trượt đáy */
  .sheet-wrap { place-items: end center; padding: 48px 0 0; }
  .sheet, .sheet.wide { width: 100%; max-height: 90vh; max-height: 90dvh; border-radius: 26px 26px 0 0; translate: 0 40px; scale: 1; padding-bottom: var(--safe-b); }
  .sheet-grip { display: block; position: absolute; top: 7px; left: 50%; translate: -50% 0; width: 42px; height: 4px; border-radius: 2px; background: rgba(58, 42, 31, .22); }
  .sheet-hd { padding: 18px 8px 10px 18px; }
  .sheet-title { font-size: 20px; }
  .sheet-body { padding: 14px 16px 22px; }
  .places, .help-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .prac-head { gap: 14px; }
  .prac-seal { width: 68px; height: 68px; }
  .prac-seal b { font-size: 28px; }
  .prac-v { font-size: 28px; }
  .stat { padding: 10px; column-gap: 9px; }
  .stat-ic { width: 36px; height: 36px; }
  .stat-v { font-size: 16.5px; }
  .seg-q, .vol { flex: 1 1 100%; }
}
@media (max-width: 380px) {
  .w-title { font-size: 34px; }
  .place { gap: 8px; padding-right: 12px; }
  .place-logo { width: 36px; height: 36px; }
  .place-logo .ic { width: 22px; height: 22px; }
  .place-zone .ic { display: none; }
  .medi-clock { font-size: 24px; }
  .medi-end { padding: 0 12px; }
  .medi-end .ic { display: none; }
  .sw-lb { font-size: 11.5px; }
  .sw-dot { width: 36px; height: 36px; }
  .medi-pre { padding: 0 10px; }
  .mala { width: 128px; height: 136px; }
  .mala-n { font-size: 30px; }
  .beads-phrase { font-size: 15.5px; }
}
/* Màn hình thấp (điện thoại xoay ngang) */
@media (max-height: 560px) {
  :root { --dock-h: 58px; --dock-b: calc(6px + var(--safe-b)); --gut: 10px; }
  .dock-it { height: 48px; }
  .dock-lb { display: none; }
  .actions { gap: 6px 10px; }
  .act-orb { width: 48px; height: 48px; }
  .act-lb { font-size: 12px; padding: 4px 10px; }
  .chant-lines { height: 110px; padding: 32px 4px 50px; }
  .mala { width: 120px; height: 128px; }
  .w-inner { padding-top: 14px; padding-bottom: 14px; }
  .w-lede { display: none; }
  .chat { height: calc(100vh - 110px); min-height: 0; }
  .toasts { top: calc(var(--top) + 64px); }
  /* Bảng tu tập gọn lại cho màn thấp */
  .pp { padding: 8px 12px 10px; }
  .pp-hd { min-height: 36px; margin-bottom: 4px; }
  .chant-head { display: none; }
  .chant-lines { height: 92px; padding: 30px 4px 40px; }
  .chant-side { width: 92px; }
  .mo-btn { width: 76px; height: 76px; }
  .mo-face .ic { width: 44px; height: 44px; }
  .mo-hint { display: none; }
  .chant-ft { margin-top: 4px; }
  .chant-prog { flex: 1 1 160px; }
  .medi { padding-block: 6px; }
  .breath { width: 80px; height: 80px; }
  .breath-orb { inset: 10px; }
}
/* Máy chạm: không có bàn phím → ẩn gợi ý phím; vùng bấm tối thiểu 44 px */
.ui-touch kbd { display: none !important; }
.ui-touch .chip, .ui-touch .tab, .ui-touch .btn.sm, .ui-touch .ibtn.sm, .ui-touch .medi-pre { min-height: 44px; }
.ui-touch .ibtn.sm { width: 44px; height: 44px; }

/* ================================================================ Chuyển động */
@keyframes spin { to { rotate: 360deg; } }
@keyframes breathe { 0%, 100% { scale: .92; opacity: .85; } 50% { scale: 1.04; opacity: 1; } }
@keyframes slide { 0% { translate: -110% 0; } 100% { translate: 260% 0; } }
@keyframes pop { 0% { scale: .4; } 70% { scale: 1.15; } 100% { scale: 1; } }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(92, 154, 59, .55); } 70%, 100% { box-shadow: 0 0 0 7px rgba(92, 154, 59, 0); } }
@keyframes zoneIn { from { opacity: 0; translate: 0 4px; } to { opacity: 1; translate: 0 0; } }
@keyframes menuIn { from { opacity: 0; translate: 0 -6px; } to { opacity: 1; translate: 0 0; } }
@keyframes ping { 0% { scale: .4; opacity: 1; } 100% { scale: 1.6; opacity: 0; } }
@keyframes actIn { from { opacity: 0; translate: 16px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes actOut { to { opacity: 0; translate: 16px 0; } }
@keyframes halo { 0% { scale: 1; opacity: .9; } 100% { scale: 1.35; opacity: 0; } }
@keyframes rise { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }
@keyframes msgIn { from { opacity: 0; translate: 0 4px; } to { opacity: 1; translate: 0 0; } }
@keyframes toastIn { from { opacity: 0; translate: 0 -10px; scale: .97; } to { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes toastOut { to { opacity: 0; translate: 0 -8px; } }
@keyframes bump { 0% { scale: 1; } 40% { scale: 1.04; } 100% { scale: 1; } }
@keyframes meritUp {
  0% { opacity: 0; translate: calc(-50% + var(--dx, 0px)) -30%; scale: .8; }
  14% { opacity: 1; translate: calc(-50% + var(--dx, 0px)) -55%; scale: 1.08; }
  28% { scale: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; translate: calc(-50% + var(--dx, 0px)) calc(-50% - 74px); scale: 1; }
}
@keyframes lvIn { from { opacity: 0; translate: -50% -14px; scale: .96; } to { opacity: 1; translate: -50% 0; scale: 1; } }
@keyframes lvOut { to { opacity: 0; translate: -50% -10px; } }
@keyframes stamp { 0% { opacity: 0; scale: 1.9; rotate: -14deg; } 55% { opacity: 1; scale: .92; rotate: -3deg; } 100% { opacity: 1; scale: 1; rotate: -4deg; } }
@keyframes shutter { 0% { opacity: .75; } 100% { opacity: 0; } }
@keyframes breath {
  0% { scale: .7; animation-timing-function: cubic-bezier(.42, 0, .58, 1); }
  40% { scale: 1; animation-timing-function: cubic-bezier(.42, 0, .58, 1); }
  100% { scale: .7; }
}
@keyframes moHit { 0% { scale: 1; } 35% { scale: .92; } 100% { scale: 1; } }
@keyframes moWave { 0% { opacity: .95; scale: 1; } 100% { opacity: 0; scale: 1.45; } }
@keyframes tick { 0% { scale: 1; } 40% { scale: 1.12; } 100% { scale: 1; } }
@keyframes glow {
  0% { filter: drop-shadow(0 0 0 rgba(243, 195, 90, 0)); }
  30% { filter: drop-shadow(0 0 12px rgba(243, 195, 90, .95)); }
  100% { filter: drop-shadow(0 0 0 rgba(243, 195, 90, 0)); }
}
@keyframes say { 0% { opacity: .35; translate: 0 5px; } 35% { opacity: 1; translate: 0 0; } 100% { opacity: 1; } }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: .9; } }
@keyframes bubbleIn { from { opacity: 0; scale: .75; } to { opacity: 1; scale: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  /* Vòng hơi thở vẫn cần nhịp: chỉ đổi độ sáng chậm, không phóng to thu nhỏ */
  .breath-orb.run { animation: breathSoft 10s infinite !important; animation-duration: 10s !important; animation-iteration-count: infinite !important; scale: .86; }
  .ld-mark::before, .ld-bar span { animation: none !important; }
}
@keyframes breathSoft { 0% { opacity: .45; } 40% { opacity: 1; } 100% { opacity: .45; } }

/* ------------------------------------------------------------ Mở trên điện thoại (mã QR) */
.share { display: grid; gap: 14px; }
.share-lead { margin: 0; color: var(--ink-2); line-height: 1.55; }
.share-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.share-card {
  margin: 0; display: grid; justify-items: center; gap: 10px; padding: 16px 14px 14px;
  background: var(--paper-hi); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1);
}
.share-qr { width: 168px; height: 168px; border-radius: 10px; background: #fffaf0; image-rendering: pixelated; }
.share-card figcaption { display: grid; gap: 4px; text-align: center; }
.share-card strong { font-family: var(--serif); font-size: 1.02rem; color: var(--ink); }
.share-note { font-size: .82rem; color: var(--ink-3); }
.share-url {
  font-size: .8rem; color: var(--wood-deep); background: var(--paper-lo); padding: 4px 8px; border-radius: 8px;
  word-break: break-all; user-select: all;
}
.share-tip { margin: 0; font-size: .86rem; color: var(--ink-2); background: rgba(227, 162, 42, .14); padding: 10px 12px; border-radius: var(--r-sm); }

/* ------------------------------------------------------------ Nhân vật đã lưu & mã số bí mật */
.w-back {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 4px;
  background: linear-gradient(180deg, rgba(227, 162, 42, .16), rgba(227, 162, 42, .08));
  border: 1px solid rgba(154, 100, 10, .25); border-radius: var(--r);
}
.w-back[hidden] { display: none; }
.w-back-dot {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .55), transparent 55%), var(--c, #7d8fa6);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .18), 0 1px 3px rgba(62, 38, 14, .25);
}
.w-back-tx { display: grid; gap: 1px; min-width: 0; flex: 1; }
.w-back-hi { font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--turmeric-deep); font-weight: 600; }
.w-back-name { font-family: var(--serif); font-size: 1.08rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-back-meta { font-size: .8rem; color: var(--ink-2); }
.w-new {
  flex: none; border: 1px solid var(--line-2); background: var(--paper-hi); color: var(--ink-2);
  font: 500 .8rem/1.2 var(--font); padding: 7px 10px; border-radius: 999px; cursor: pointer; min-height: 34px;
}
.w-new:hover { color: var(--ink); border-color: var(--turmeric-deep); }
.w-new:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fld-help { margin: 6px 2px 0; font-size: .78rem; line-height: 1.45; color: var(--ink-3); }
#w-pin { letter-spacing: .3em; }
#w-pin::placeholder { letter-spacing: normal; }

.share-pin { display: grid; gap: 8px; padding: 14px; background: var(--paper-hi); border: 1px dashed var(--line-2); border-radius: var(--r); }
.share-pin p { margin: 0; color: var(--ink-2); line-height: 1.5; font-size: .9rem; }
.share-pin-title { margin: 0; font-family: var(--serif); font-size: 1.02rem; color: var(--ink); }
.share-pin-form { display: flex; gap: 8px; flex-wrap: wrap; }
.share-pin-in { flex: 1 1 140px; min-width: 0; letter-spacing: .3em; }
.share-pin-in::placeholder { letter-spacing: normal; }
.share-pin-btn { flex: none; }
.share-pin-note { min-height: 1em; font-size: .82rem !important; color: var(--lacquer-deep) !important; }
@media (max-width: 380px) { .w-back { flex-wrap: wrap; } .w-new { margin-left: 50px; } }
.w-rename { color: var(--moss-deep); font-weight: 500; }
.share-name-in { flex: 1 1 160px; min-width: 0; }
