/* quest.css (B7 + V4 khoá ux) — hội thoại NPC, nhận/trả nhiệm vụ, theo dõi + chỉ đường, nhật ký, nhặt đồ, pill tương tác, gợi ý dạy học.
   CHỈ token (tokens.css); nút/✕/chip liên kết dùng chung ở kit.css (q-btn = bí danh k-btn). Kích thước HUD bằng rem (đã nhân --ui-scale);
   vùng chạm cảm ứng ≥ 44 px. Bảng = mặt ĐẶC --sf-panel (UX-24); khung HUD có chữ = --sf-hud; chữ trên cảnh = dải --sf-scene.
   Không backdrop-filter; bóng chỉ desktop. Chuyển động chỉ transform/opacity, không vòng vô hạn trên HUD. */

[class^="q-"].hidden, [class*=" q-"].hidden { display: none !important; }

/* ---------- ẩn cụm điều khiển khi sheet cảm ứng mở (§2.2.5, §3.4) ---------- */
html[data-sheet] #hud .l-controls,
html[data-sheet] [data-zone="cluster"],
html[data-sheet] [data-zone="joystick"],
html[data-sheet] [data-zone="actionbar"].touch,
html[data-sheet] .q-pill.touch { visibility: hidden !important; pointer-events: none !important; }
html[data-sheet] #hud > .l-hint { visibility: hidden; }

/* ---------- nút (kiểu ở kit.css — đây chỉ phần bố cục riêng), chip, dấu chung ---------- */
.q-btn { flex-shrink: 0; }
.q-btn.big { flex: 1 1 auto; }
.q-icon-btn {
  flex: none; display: inline-grid; place-items: center; width: max(28px, 2rem); height: max(28px, 2rem); padding: 0; border-radius: var(--r-s);
  border: 1px solid transparent; background: transparent; color: var(--tx-2); font: 600 var(--fs-lg)/1 var(--font); cursor: pointer; touch-action: manipulation;
}
.q-icon-btn .k-ico { width: 1.125rem; height: 1.125rem; }
.q-icon-btn:active { transform: scale(.94); }
.q-chip {
  display: inline-block; padding: 1px var(--sp-2); border-radius: var(--r-pill); font-size: var(--fs-xs); line-height: 1.5;
  background: var(--sf-raised); color: var(--tx-2); white-space: nowrap;
}
.q-chip.ok, .q-chip.finish { background: rgba(90, 210, 90, .16); color: #9cf09c; }
.q-chip.accept { background: rgba(255, 210, 0, .14); color: #ffe27a; }
.q-chip.warn { background: rgba(230, 162, 60, .16); color: #ffd99a; }
.q-dim { color: var(--tx-2); }
.q-ok { color: var(--st-ok); font-weight: 600; }
.q-empty { padding: var(--sp-3); color: var(--tx-2); font-size: var(--fs-sm); text-align: center; }
.q-empty.big { padding: var(--sp-4) var(--sp-3); font-size: var(--fs-md); }
.q-mark {
  flex: none; display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%;
  font: 800 var(--fs-sm)/1 var(--font); color: #1b1404; background: var(--q-gray); box-shadow: 0 0 0 1px rgba(0, 0, 0, .5);
}
.q-mark.sm { width: 1rem; height: 1rem; min-width: 1rem; font-size: var(--fs-2xs); }
.q-mark.yellow { background: var(--q-yellow); } .q-mark.blue { background: var(--q-blue); }
.q-mark.orange { background: var(--q-orange); } .q-mark.green { background: var(--q-green); }
.q-mark.gray { background: var(--q-gray); } .q-mark.guide { background: var(--ac-2); color: #06140f; }
.q-mark.none { visibility: hidden; }
.q-tick { color: var(--st-ok); font-weight: 800; margin-left: var(--sp-1); }
.q-gap { display: block; }
.q-self { color: var(--ac); font-weight: 600; }
.q-money { color: #f3d58c; }
/* LinkChip trong lời thoại (kit .k-chip): có xử lý = chip vàng bấm được; chưa có = chip viền đứt + lý do khi chạm */
.q-link, .q-link-off { font-size: inherit; line-height: 1.3; vertical-align: baseline; }

/* ---------- toast dự phòng (khi chưa nối notice B5) ---------- */
.q-toasts { position: fixed; top: calc(var(--st) + 3.5rem); left: 50%; transform: translateX(-50%); z-index: var(--z-feed); display: grid; gap: 6px; justify-items: center; pointer-events: none; width: min(36rem, calc(100vw - 32px)); }
.q-toast { padding: 6px 14px; border-radius: var(--r-m); background: var(--sf-hud); border: 1px solid var(--ln-1); border-left: 3px solid var(--ac-2); color: var(--tx-1); font-size: var(--fs-md); transition: opacity .3s, transform .3s; }
.q-toast.error { border-left-color: var(--st-danger); }
.q-toast.warn { border-left-color: var(--st-warn); }
.q-toast.ok { border-left-color: var(--st-ok); }
.q-toast.out { opacity: 0; transform: translateY(-6px); }

/* ---------- xác nhận trong bảng (dự phòng — có msgbox thì dùng kit.confirm) ---------- */
.q-confirm { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: var(--sf-backdrop); border-radius: inherit; }
.q-confirm-box { width: min(26.25rem, 92%); padding: var(--sp-4); border-radius: var(--r-l); background: var(--sf-panel); border: 1px solid var(--ln-1); }
html[data-ui="desktop"] .q-confirm-box { box-shadow: var(--elev-3); }
.q-confirm-title { font: 600 var(--fs-xl)/1.25 var(--font-title); color: var(--ac); margin-bottom: var(--sp-2); }
.q-confirm-text { font-size: var(--fs-md); color: var(--tx-1); margin-bottom: var(--sp-4); }
.q-confirm-btns { display: flex; gap: var(--sp-2); justify-content: flex-end; }
.q-confirm-btns .q-btn { min-height: var(--k-h-lg); }

/* ---------- bảng chung: hội thoại / nhật ký (mặt ĐẶC) ---------- */
.q-dlg, .q-log {
  pointer-events: auto; position: relative; display: flex; flex-direction: column; box-sizing: border-box;
  background: var(--sf-panel); border: 1px solid var(--ln-1); border-radius: var(--r-m); color: var(--tx-1);
  font: var(--fs-md)/1.5 var(--font); contain: layout paint style; overflow: hidden;
}
.q-dlg { width: 27.5rem; max-width: calc(100vw - 24px); max-height: min(35rem, calc(100vh - 12rem)); }
html[data-ui="desktop"] :is(.q-dlg, .q-log) { box-shadow: var(--elev-2); }
.q-dlg::before, .q-log::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--ac), transparent); opacity: .7; }
.q-dlg-head, .q-log-head { flex: none; display: flex; align-items: center; gap: var(--sp-2); min-height: max(36px, 2.5rem); padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-3); border-bottom: 1px solid var(--ln-2); touch-action: pan-y; }
.q-dlg-title, .q-log-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--sp-2); }
.q-dlg-name, .q-log-title > span:first-child { font: 600 var(--fs-xl)/1.25 var(--font-title); color: var(--ac); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-dlg.touch .q-dlg-name { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.q-dlg-sub { font-size: var(--fs-sm); color: var(--tx-2); white-space: nowrap; }
.q-dlg-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); -webkit-overflow-scrolling: touch; }
.q-dlg-text { white-space: normal; overflow-wrap: anywhere; color: var(--tx-1); font-size: var(--fs-md); line-height: 1.6; }
.q-dlg-foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) var(--sp-3); border-top: 1px solid var(--ln-2); }
.q-dlg-foot .q-btn:not(.big) { flex: 0 0 auto; }
/* lý do khoá (UX-08) — 1 dòng trọn bề ngang ngay TRÊN nút */
.q-foot-reason { flex: 1 0 100%; order: -1; margin: 0; }
.q-dlg.busy .q-opt { opacity: .55; pointer-events: none; }
.q-dlg.busy .q-opt.chosen { opacity: 1; }
.q-dlg.busy .q-opt.chosen .q-opt-bullet { animation: k-spin .8s linear infinite; }
.q-dlg-quests, .q-dlg-opts { display: flex; flex-direction: column; gap: var(--sp-1); }
.q-opt {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: max(32px, 2.5rem); padding: var(--sp-1) var(--sp-3);
  text-align: left; border-radius: var(--r-s); border: 1px solid var(--ln-1); background: var(--sf-raised);
  color: var(--tx-1); font: var(--fs-md)/1.35 var(--font); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.q-opt:active { transform: scale(.98); background: var(--sf-selected); }
.q-opt-bullet { flex: none; display: inline-grid; place-items: center; color: var(--ac); font-weight: 800; min-width: .75rem; text-align: center; }
.q-opt-bullet .k-ico { width: 1.125rem; height: 1.125rem; }
.q-opt-text { flex: 1 1 auto; min-width: 0; }
.q-opt-reason { display: block; color: var(--tx-2); font-size: var(--fs-sm); font-weight: 400; }
.q-opt.is-off { border-style: dashed; cursor: help; }
.q-opt.is-off .q-opt-bullet { color: var(--tx-3); }
.q-opt.q-opt-quest.finish { border-color: rgba(255, 210, 0, .55); background: rgba(255, 210, 0, .07); }
.q-opt.q-opt-quest.accept { border-color: rgba(255, 210, 0, .35); }
.q-opt.q-opt-shop:not(.is-off) { border-color: var(--ln-ac); }
.q-opt.confirm .q-opt-bullet { color: var(--st-warn); }
.q-opt.armed { border-color: var(--st-warn); background: rgba(230, 162, 60, .14); }
.q-opt:focus-visible, .q-trk-item:focus-visible, .q-log-row:focus-visible, .q-loot-item:focus-visible, .q-rw-item:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }
@media (hover: hover) {
  .q-opt:hover:not(.is-off) { border-color: var(--ac-lo); background: var(--sf-hover); }
  .q-icon-btn:hover { color: var(--tx-1); background: var(--sf-hover); }
  .q-trk-item:hover { background: var(--sf-hud); border-left-color: var(--ln-ac); }
  .q-log-row:hover { background: var(--sf-hover); }
  .q-loot-item:hover { background: var(--sf-hover); }
}
/* [V6 quest] NV đang làm trong hội thoại: tiến độ + "Bước kế" + Chỉ đường, thụt dưới dòng nhiệm vụ */
.q-opt.q-opt-quest.doing { border-color: var(--ln-1); }
.q-dlg-doing { display: flex; flex-direction: column; gap: 2px; margin: -2px 0 var(--sp-1); padding: var(--sp-1) var(--sp-3) var(--sp-2);
  border: 1px solid var(--ln-1); border-top: 0; border-radius: 0 0 var(--r-s) var(--r-s); background: rgba(0, 0, 0, .18);
  font-size: var(--fs-sm); color: var(--tx-2); }
.q-dlg-doing .q-obj { padding: 0; }
.q-dlg-next { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--sp-2); margin-top: 2px; }
.q-dlg-next-k { flex: none; color: var(--ac-2); font-weight: 700; font-size: var(--fs-xs); letter-spacing: .03em; text-transform: uppercase; }
.q-dlg-next-v { flex: 1 1 10rem; min-width: 0; color: var(--tx-1); overflow-wrap: anywhere; }
.q-dlg-go { margin-left: auto; }
.q-dlg.touch .q-dlg-doing .q-btn { min-height: 44px; min-width: 5.5rem; }
.q-sec { display: flex; flex-direction: column; gap: var(--sp-1); }
.q-sec-title { margin: 0; font: 700 var(--fs-xs)/1.3 var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--ac-2); }
.q-obj { display: flex; align-items: baseline; gap: var(--sp-2); padding: 2px 0; }
.q-obj-text { flex: 1 1 auto; min-width: 0; }
.q-obj-num { flex: none; font-variant-numeric: tabular-nums; color: var(--tx-2); }
.q-obj.done .q-obj-text, .q-obj.done .q-obj-num { color: #9cf09c; }
.q-rw-row { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.q-rw-chip { padding: 2px var(--sp-2); border-radius: var(--r-s); background: var(--sf-raised); font-size: var(--fs-sm); }
.q-rw-group { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-1); }
.q-rw-item { display: flex; align-items: center; gap: var(--sp-2); min-height: max(32px, 2.25rem); padding: 2px var(--sp-2); border-radius: var(--r-s); border: 1px solid var(--ln-2); background: var(--sf-raised); color: var(--tx-1); font: var(--fs-md) var(--font); text-align: left; }
button.q-rw-item { cursor: pointer; touch-action: manipulation; }
.q-rw-item.sel { border-color: var(--ac); background: var(--sf-selected); box-shadow: inset 0 0 0 1px var(--ac-lo); }
.q-rw-group.choose .q-rw-item:not(.sel) { border-style: dashed; border-color: var(--ln-field); }
.q-rw-icon { flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: var(--r-s); background: var(--sf-sunken); border: 1px solid var(--ac-lo); color: var(--ac); font-weight: 700; }
.q-rw-icon.gold { color: #f3d58c; }
.q-rw-name { flex: 1 1 auto; min-width: 0; }
.q-rw-n { color: var(--tx-2); font-variant-numeric: tabular-nums; }

/* trong zone Layout B5: bảng lấp đầy hộp đã neo (dialog: trái 440×≤560 desktop / sheet phải cảm ứng; sheet: cửa sổ VÙNG TRỐNG §5.5) */
.zone.z-dialog > .q-dlg { width: 100%; max-width: none; max-height: 100%; }
.zone.z-dialog > .q-dlg.touch, .zone.z-sheet > .q-log { position: absolute; inset: 0; left: 0; top: 0; width: auto; height: auto; max-height: none; transform: none; }
.zone.z-sheet > .q-log:not(.touch) { border-radius: var(--r-m); }
.zone.z-tracker > .q-trk { width: 100%; }
.zone.z-hint > .q-hint { width: max-content; max-width: 100%; }

/* cảm ứng: hội thoại = side sheet phải 44 % (phone) / 380 px (tablet), cao đủ (§3.4, §5.3) */
.q-dlg.touch, .q-log.touch {
  position: fixed; top: 0; right: 0; bottom: 0; width: 44vw; max-width: none; max-height: none; height: 100%;
  border-radius: 0; border-width: 0 0 0 1px; z-index: 30; box-shadow: none;
  padding-top: var(--st); padding-right: var(--sr); padding-bottom: var(--sb);
}
html[data-ui="tablet"] .q-dlg.touch { width: 380px; }
/* nhật ký cảm ứng = FULL sheet (§5.3) — 2 cột danh sách 40 % + chi tiết 60 % khi đủ rộng */
.zone.z-sheet > .q-log.touch { position: fixed; inset: 0; width: auto; padding-left: var(--sl); border-left: 0; }
.q-log.touch.two .q-log-list { flex: 0 0 40%; border-right: 1px solid var(--ln-1); }
.q-dlg.touch .q-opt, .q-log.touch .q-log-row, .q-log.touch .q-btn, .q-dlg.touch .q-btn, .q-dlg.touch button.q-rw-item { min-height: 44px; }
.q-dlg.touch .q-icon-btn, .q-log.touch .q-icon-btn { width: 44px; height: 44px; font-size: var(--fs-xl); }
.q-dlg.touch .q-dlg-text { font-size: var(--fs-md); }
.q-dlg.touch .q-opt { min-height: 52px; }

/* ---------- nhật ký nhiệm vụ ---------- */
.q-log:not(.touch) {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 40;
  width: min(47.5rem, 92vw); height: min(35rem, 88vh);
}
.q-log-body { flex: 1 1 auto; min-height: 0; display: flex; }
.q-log-list { flex: 0 0 15rem; overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--ln-1); padding: var(--sp-1); display: flex; flex-direction: column; gap: 2px; }
.q-log.touch:not(.two) .q-log-list { flex: 1 1 auto; border-right: 0; }
.q-log-row { display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: max(32px, 2.25rem); padding: 0 var(--sp-2); border: 0; border-radius: var(--r-s); background: transparent; color: var(--tx-1); font: var(--fs-md) var(--font); text-align: left; cursor: pointer; }
.q-log-row.sel { background: var(--sf-selected); box-shadow: inset 3px 0 0 var(--ac); }
.q-log-name { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-log-row .q-dim { white-space: nowrap; font-size: var(--fs-xs); }
.q-log.touch .q-log-head { flex-wrap: wrap; row-gap: var(--sp-1); min-height: 56px; }
.q-log.touch .q-dedupe { order: 9; flex: 1 0 100%; }
.q-log-detail { flex: 1 1 auto; min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.q-log-dtitle { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); font: 600 var(--fs-xl)/1.3 var(--font-title); color: var(--ac); }
.q-place { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.q-place-k { flex: none; width: 4.5rem; color: var(--tx-2); }
.q-place-v { flex: 1 1 auto; min-width: 0; }
/* hành động: chính (Chỉ đường) PHẢI, phá huỷ (Huỷ nhiệm vụ) mép TRÁI, cách nhau ≥ 16u (§3.5 Fitts) */
.q-log-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; padding-top: var(--sp-2); border-top: 1px solid var(--ln-2); }
.q-log-actions > .q-btn.primary { order: 2; margin-left: auto; }
.q-log-actions > .q-btn.danger { order: 1; }

/* ---------- theo dõi nhiệm vụ (bố cục QuestTraceList gốc — tên ≤ 2 dòng không cắt, dòng mục tiêu x/n, dòng nộp ➜,
   dòng chỉ đường [động từ] đích · khoảng cách + nút Đi tới/Huỷ; cập nhật theo khoá, khoảng cách 4 Hz). Mặt --sf-hud (UX-06) ---------- */
.q-trk { pointer-events: auto; width: 18.75rem; max-height: 100%; display: flex; flex-direction: column; color: var(--tx-1); font: var(--fs-sm)/1.4 var(--font); contain: layout paint style; }
.q-trk.touch { width: 100%; max-height: none; }
.q-trk-head { flex: none; display: flex; align-items: center; gap: var(--sp-1); }
.q-trk-toggle { flex: 1 1 auto; display: flex; align-items: center; gap: var(--sp-2); min-width: 0; min-height: max(24px, 1.75rem); padding: 0 var(--sp-2); border: 0; border-radius: var(--r-s); background: var(--sf-hud); color: var(--ac); font: 700 var(--fs-sm) var(--font); cursor: pointer; text-align: left; }
.q-trk-count { color: var(--tx-2); font-weight: 400; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.q-chev { margin-left: auto; color: var(--tx-2); }
.q-trk-log { background: var(--sf-hud); color: var(--ac); width: max(24px, 1.75rem); height: max(24px, 1.75rem); }
/* cảm ứng: bảng trái chỉ cao 120 px dưới tab "Nhiệm vụ" (B5) ⇒ bỏ đầu bảng (số nhiệm vụ lên huy hiệu tab; nhật ký = chạm dòng
   đang chỉ đường / menu ☰) để dòng chỉ đường + nút "Đi tới" luôn thấy không phải cuộn */
.q-trk.touch .q-trk-head { display: none; }
.q-trk.touch .q-trk-item { background: transparent; padding: 4px var(--sp-2) 2px; }
.q-trk.touch .q-trk-name { font-size: var(--fs-sm); }
.q-trk-list { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; margin-top: 2px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.q-trk.touch .q-trk-list { padding-bottom: 6px; }
.q-trk-item { flex: none; padding: 3px var(--sp-2) 4px; border-radius: var(--r-s); background: var(--sf-hud); cursor: pointer; border-left: 2px solid transparent; touch-action: manipulation; }
.q-trk-item.active { border-left-color: var(--ac); background: var(--sf-hud); box-shadow: inset 0 0 0 1px var(--ln-1); }
/* [V5 guide] vừa đủ điều kiện nộp: sáng 1 nhịp (không lặp — V4 ux §2.4); giảm chuyển động ⇒ viền tĩnh */
.q-trk-item.q-trk-flash { animation: q-trk-flash 1.6s var(--ease) 1; }
@keyframes q-trk-flash { 0%, 35% { background: var(--sf-selected); box-shadow: inset 0 0 0 1px var(--ln-ac), 0 0 0 3px var(--sf-selected); } 100% { background: var(--sf-hud); box-shadow: inset 0 0 0 1px var(--ln-1); } }
html.reduce-motion .q-trk-item.q-trk-flash { animation: none; box-shadow: inset 0 0 0 1px var(--ln-ac); }
.q-trk-name { display: flex; align-items: flex-start; gap: var(--sp-1); font-weight: 700; color: #f6e7b8; }
.q-trk-name > .q-mark { margin-top: .15em; }
/* tên ≤ 2 dòng (ảnh user: "…tìm Trương C…" bị cắt 1 dòng) — chữ dài hơn thì xuống dòng thứ 2 rồi mới "…" */
.q-trk-ntext { flex: 1 1 auto; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; line-height: 1.35; }
.q-trk-name > .q-chip { flex: none; margin-top: 1px; }
.q-trk-item.done .q-trk-ntext { color: var(--q-yellow); }
.q-trk-item.stale .q-trk-ntext { color: var(--tx-2); }
.q-trk-item.failed .q-trk-ntext { color: #ffb3a3; }
.q-trk-obj { display: flex; align-items: baseline; gap: var(--sp-1); color: var(--tx-1); font-size: var(--fs-sm); line-height: 1.4; padding-left: calc(1rem + var(--sp-1)); }
.q-trk-otext { flex: 1 1 auto; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
.q-trk-num { flex: none; font-variant-numeric: tabular-nums; color: var(--tx-1); }
.q-trk-obj.done, .q-trk-obj.done .q-trk-num { color: #9cf09c; }
.q-trk-obj.fin { color: var(--q-yellow); }
.q-trk-obj.fail { color: #ffb3a3; }
.q-trk-obj.warn { color: #ffd99a; text-decoration: underline dotted; cursor: pointer; }
.q-trk-obj.dim { color: var(--tx-2); }
.q-trk-arrow { flex: none; color: var(--ac); font-weight: 700; }
.q-trk-obj > .q-tick { flex: none; margin-left: 0; }
/* dòng chỉ đường: [động từ] đích (co, "…") · khoảng cách (cố định, số đều) · nút (cố định) — không phần tử nào đè nhau */
.q-trk-guide { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--sp-1); margin-top: 3px; padding-left: calc(1rem + var(--sp-1)); font-size: var(--fs-sm); min-height: max(24px, 1.75rem); }
/* [V4 ux] hẹp (bảng trái điện thoại ~180 px) ⇒ xuống dòng: "Mua tại: Vương Bà Bà" / "219 m [Đi tới]" — trước: tên NPC bị ép còn 3 px ("\") */
.q-trk-verb { flex: none; color: var(--tx-2); }
.q-trk-verb::after { content: ":"; }
.q-trk-target { flex: 1 1 auto; min-width: min(4em, 100%); color: var(--ac-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* [V6 quest] việc cần làm tại đích ("bấm Châm Lửa, giữ yên 3 giây") — 1 dòng riêng dưới dòng chỉ đường */
.q-trk-how { margin-top: 1px; padding-left: calc(1rem + var(--sp-1)); min-width: 0; color: var(--tx-2); font-size: var(--fs-xs); line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-trk-dist { flex: none; min-width: 3.2em; margin-left: auto; text-align: right; color: var(--ac); font-variant-numeric: tabular-nums; font-weight: 700; }
.q-trk-dist:empty { min-width: 0; }
.q-trk-go { flex: none; position: relative; min-width: 4.25rem; margin-left: auto; }
.q-trk-go.stop { border-color: var(--st-warn); }
.q-trk-guide.going .q-trk-verb { color: #ffd99a; }
.q-trk-guide.going .q-trk-verb::after { content: "…"; }
/* [V4 ux UX-02] "Mua tại: Vương Bà Bà · 219 m [Đi tới]" — động từ vàng cho nổi; dòng "Chưa rõ vị trí" bấm được ⇒ mở nhật ký */
.q-trk-guide.buy .q-trk-verb { color: var(--ac); font-weight: 700; }
.q-trk-guide.is-link { cursor: pointer; }
.q-trk-guide.is-link .q-trk-target { color: var(--tx-2); white-space: normal; text-decoration: underline dotted; text-underline-offset: 2px; }
.q-trk-going { flex: none; display: flex; align-items: center; gap: var(--sp-1); margin-top: 2px; padding: 3px var(--sp-2); border-radius: var(--r-s); background: var(--sf-hud); border-left: 2px solid var(--st-warn); font-size: var(--fs-sm); }
.q-trk-going .q-trk-verb { color: #ffd99a; }
.q-trk-going .q-trk-verb::after { content: "…"; }
.q-trk.touch .q-trk-guide .q-btn, .q-trk.touch .q-trk-going .q-btn { min-height: 2rem; position: relative; }
/* [W2fix] vùng chạm 44 px ("Đi tới"/"Huỷ") — ::after (::before của .q-btn là vòng chờ của kit) */
.q-trk.touch .q-trk-guide .q-btn:not(.wait)::after, .q-trk.touch .q-trk-going .q-btn:not(.wait)::after { content: ""; position: absolute; inset: min(0px, calc(50% - 22px)); }
.q-trk.touch .q-trk-guide { min-height: 2rem; margin-top: 2px; }
.q-trk.touch .q-trk-guide .q-btn { padding: 0 var(--sp-2); min-width: 3.75rem; z-index: 1; }   /* vùng chạm ::after nằm trên dòng kế */
.q-trk.touch .q-trk-guide:not(.going):not(.buy) .q-trk-verb { display: none; }   /* bảng 200 px: nhường chỗ cho TÊN đích (dấu ?/! đã nói việc) */
.q-trk.touch .q-trk-guide.going .q-trk-target { display: none; }       /* đang tự đi: "Đang tự đi… 238 m [Huỷ]" */
/* [V5 guide] cảm ứng: dòng chỉ đường KHÔNG xuống dòng — nút "Đi tới" luôn thấy ngay (trước: tên đích + khoảng cách đẩy nút xuống dòng
   kế, bị mép bảng trái cắt — ảnh m844 sau khi mua Cháo); tên đích co lại "…"; mục tiêu 1 dòng */
.q-trk.touch .q-trk-guide { flex-wrap: nowrap; }
.q-trk.touch .q-trk-guide .q-trk-target, .q-trk.touch .q-trk-guide .q-trk-dist { min-width: 0; }
.q-trk.touch .q-trk-otext { -webkit-line-clamp: 1; line-clamp: 1; }
.q-trk-more { flex: none; border: 0; background: var(--sf-hud); border-radius: var(--r-s); color: var(--tx-2); font: var(--fs-sm) var(--font); text-align: left; padding: 2px var(--sp-2); min-height: 24px; cursor: pointer; }
.q-trk.touch .q-trk-more { min-height: 44px; background: transparent; }

/* mũi tên chỉ đường mép màn (Overlay3D — Navigator.lua): tâm = điểm bám mép; khoảng cách bên dưới trên dải --sf-scene (chữ trắng) */
.q-nav { position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; will-change: transform; contain: layout style; }
.q-nav-tip { position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; overflow: visible; filter: drop-shadow(0 0 5px rgba(255, 210, 106, .55)); }
.q-nav-tip path { fill: var(--ac); stroke: rgba(10, 10, 10, .9); stroke-width: 2; stroke-linejoin: round; }
.q-nav-d { position: absolute; left: 0; top: 17px; transform: translateX(-50%); padding: 0 .3125rem; border-radius: var(--r-xs); background: var(--sf-scene);
  text-align: center; color: var(--tx-1); font: 700 var(--fs-sm)/1.3 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; }
.q-nav-d:empty { display: none; }

/* ---------- pill tương tác ---------- */
.q-pill {
  position: fixed; left: 50%; bottom: calc(9.375rem + var(--sb)); transform: translateX(-50%); z-index: 15; pointer-events: auto;
  display: inline-flex; align-items: center; gap: var(--sp-2); height: 2.5rem; max-width: 26rem; padding: 0 var(--sp-4) 0 var(--sp-1);
  border-radius: var(--r-pill); border: 1px solid #f3d58c; background: var(--sf-hud); color: var(--tx-1);
  font: 600 var(--fs-md)/1.25 var(--font); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent;
  animation: q-pop var(--dur) var(--ease);
}
html[data-ui="desktop"] .q-pill { box-shadow: var(--elev-1); }
.q-pill.press { filter: brightness(1.15); }
.q-pill-key { display: grid; place-items: center; min-width: 1.75rem; height: 1.75rem; padding: 0 6px; border-radius: var(--r-pill); background: linear-gradient(180deg, var(--ac-hi), var(--ac-lo)); color: var(--tx-on-ac); font: 800 var(--fs-sm)/1 var(--font); }
.q-pill-icon { color: var(--ac); font-size: var(--fs-lg); }
.q-pill-key:not(.hidden) + .q-pill-icon { display: none; }
.q-pill-verb { color: var(--ac); white-space: nowrap; }
.q-pill-name { color: var(--tx-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-weight: 400; }
.q-pill.far { border-style: dashed; }
.q-pill.touch { left: auto; right: 24%; bottom: 40%; transform: none; justify-content: center; padding: 0 var(--sp-3); box-shadow: none; min-height: 40px; }
/* [W2fix] cảm ứng: 2 dòng (động từ nhỏ / TÊN đậm) — trước: 1 dòng cắt mất tên ("Nói chuyện · …") */
.q-pill.touch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-auto-rows: auto; column-gap: var(--sp-2); row-gap: 1px;
  align-content: center; justify-content: stretch; text-align: left; padding: 0 var(--sp-3) 0 var(--sp-2); }
.q-pill.touch .q-pill-icon { grid-row: 1 / span 2; align-self: center; font-size: var(--fs-xl); }
.q-pill.touch .q-pill-verb { font: 600 var(--fs-xs)/1.2 var(--font); }
.q-pill.touch .q-pill-name { max-width: none; color: #fff3cf; font: 700 var(--fs-md)/1.2 var(--font); }
.q-pill.touch .q-pill-name:empty { display: none; }
.q-pill.touch:has(.q-pill-name:empty) .q-pill-verb { grid-row: 1 / span 2; align-self: center; font-size: var(--fs-md); }
@keyframes q-pop { from { opacity: 0; transform: translateX(-50%) scale(.92); } }
.q-pill.touch { animation-name: q-pop-t; }
@keyframes q-pop-t { from { opacity: 0; transform: scale(.92); } }

/* trong zone 'interact' đã neo (Layout B5): pill nằm giữa hộp, cao = hộp (cảm ứng: geom().pill) */
.q-pill.inzone { position: relative; left: auto; right: auto; bottom: auto; transform: none; margin: 0 auto; max-width: 100%; animation-name: q-pop-t; }
.q-pill.inzone.touch { width: 100%; height: 100%; box-sizing: border-box; }
.z-interact:has(> .q-pill.inzone) { display: flex; align-items: center; }

/* ---------- thanh mở doodad + bảng nhặt ---------- */
.q-prog { position: fixed; left: 50%; bottom: calc(var(--sb) + 10.5rem); transform: translateX(-50%); width: 20rem; z-index: 15; pointer-events: none; }
.q-prog-label { display: flex; justify-content: space-between; gap: var(--sp-2); padding: 0 .375rem; border-radius: var(--r-xs); background: var(--sf-scene);
  font: 600 var(--fs-sm)/1.4 var(--font); color: var(--tx-1); margin-bottom: 3px; }
.q-prog-time { color: var(--tx-1); font-variant-numeric: tabular-nums; }
.q-prog-track { height: .5rem; border-radius: var(--r-pill); background: var(--sf-sunken); border: 1px solid var(--ln-field); overflow: hidden; }
.q-prog-fill { height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, var(--ac-2), var(--cast)); }
.q-loot {
  position: fixed; z-index: 35; width: 15rem; max-height: 21rem; display: flex; flex-direction: column; pointer-events: auto;
  background: var(--sf-panel); border: 1px solid var(--ln-1); border-radius: var(--r-m); color: var(--tx-1);
  font: var(--fs-md)/1.4 var(--font); overflow: hidden;
}
html[data-ui="desktop"] .q-loot { box-shadow: var(--elev-2); }
/* cảm ứng: SIDE SHEET phải (§5.3) — html[data-sheet] ẩn cụm điều khiển; "Nhặt hết" góc dưới-phải */
.q-loot.touch { left: auto !important; top: 0 !important; right: 0; bottom: 0; width: clamp(320px, 44vw, 480px); max-height: none; border-radius: 0; border-width: 0 0 0 1px;
  padding: var(--st) var(--sr) var(--sb) 0; box-sizing: border-box; animation: k-slide var(--dur-slow) var(--ease); }
.q-loot-head { display: flex; align-items: center; gap: var(--sp-2); min-height: max(36px, 2.5rem); padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-3); border-bottom: 1px solid var(--ln-2); }
.q-loot.touch .q-loot-head { min-height: 56px; }
.q-loot-title { flex: 1 1 auto; min-width: 0; font: 600 var(--fs-lg)/1.3 var(--font-title); color: var(--ac); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-loot-list { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-1); display: flex; flex-direction: column; gap: 2px; }
.q-loot-item { display: flex; align-items: center; gap: var(--sp-2); min-height: max(32px, 2.5rem); padding: 0 var(--sp-2); border: 0; border-radius: var(--r-s); background: transparent; color: var(--tx-1); font: var(--fs-md) var(--font); text-align: left; cursor: pointer; touch-action: manipulation; }
.q-loot.touch .q-loot-item { min-height: 52px; }
.q-loot.touch .q-btn, .q-loot.touch .q-icon-btn { min-height: 44px; }
.q-loot.touch .q-icon-btn { width: 44px; height: 44px; }
.q-loot.touch .q-loot-all { min-height: 52px; }
.q-loot-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-loot-foot { display: flex; gap: var(--sp-2); padding: var(--sp-2); border-top: 1px solid var(--ln-2); }
.q-loot-foot > .q-loot-all { margin-left: auto; }

/* ---------- gợi ý dạy học (zone 'hint', lớp z 25 — DƯỚI bảng; ẩn khi có bảng mở) ---------- */
.q-hint {
  pointer-events: auto; display: flex; align-items: center; gap: var(--sp-3); max-width: min(40rem, 92vw); box-sizing: border-box;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3); border-radius: var(--r-m); border: 1px solid var(--ac-lo);
  background: linear-gradient(180deg, rgba(28, 22, 10, .94), rgba(10, 22, 24, .92)); color: var(--tx-1); font: var(--fs-md)/1.55 var(--font);
  margin: 0 auto;
}
html[data-ui="desktop"] .q-hint { box-shadow: var(--elev-1); }
.q-hint.in { animation: q-hint-in 420ms var(--ease); }
@keyframes q-hint-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.q-hint.touch { font-size: var(--fs-md); }
/* [W2fix] cảm ứng: chữ dài thì cuộn trong hộp; nhãn không gãy dòng; ✕ 44 px */
.q-hint.touch .q-hint-body { line-height: 1.5; max-height: calc(4.5em + 3px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.q-hint.touch .q-key { display: inline-block; height: 1.35em; line-height: 1.35em; padding: 0 .45em; margin: 0 .15em; vertical-align: baseline; }
html:not([data-ui="desktop"]):is(.has-sheet, .has-dialog) .q-hint.touch .q-hint-body { max-height: calc(6em + 3px); }   /* cột hẹp cạnh sheet: 4 dòng */
.q-hint .q-close { width: max(28px, 2rem); height: max(28px, 2rem); }
.q-hint.touch .q-close { width: 44px; height: 44px; }
html[data-ui="phone-land"] .q-hint.touch .q-hint-badge { display: none; }   /* điện thoại: nhường bề ngang cho chữ (viền vàng đủ nhận ra) */
.q-key { white-space: nowrap; }
.q-hint-badge { flex: none; align-self: stretch; display: grid; place-items: center; padding: 0 var(--sp-2); border-radius: var(--r-s); background: rgba(224, 184, 98, .16); color: var(--ac); font: 700 var(--fs-xs)/1.2 var(--font); letter-spacing: .05em; text-transform: uppercase; }
.q-hint-body { flex: 1 1 auto; min-width: 0; }
.q-hint-body > * { vertical-align: middle; }
.q-hint-body > span + span, .q-hint-body > span + kbd, .q-hint-body > kbd + span { margin-left: .25em; }
.q-hint-em { color: var(--ac); font-weight: 700; }
.q-hint-nav { display: inline-block; width: 1.35em; height: 1.35em; margin: 0 .2em; vertical-align: -.3em; overflow: visible; transform: rotate(-90deg); filter: drop-shadow(0 0 4px rgba(255, 210, 106, .5)); }
.q-hint-nav path { fill: var(--ac); stroke: rgba(10, 10, 10, .9); stroke-width: 2; stroke-linejoin: round; }
.q-hint-title { font: 600 var(--fs-lg)/1.3 var(--font-title); color: var(--ac); margin-bottom: 2px; }
.q-key { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; padding: 0 .4rem; margin: 0 .2em; border-radius: var(--r-s); background: linear-gradient(180deg, #3a3326, #1e1a12); border: 1px solid var(--ac); border-bottom-width: 3px; color: #fff3cf; font: 800 var(--fs-sm)/1 var(--font); }
.q-key.touch, .q-key.mouse { min-width: 0; padding: 0 .5rem; border-bottom-width: 1px; border-radius: var(--r-pill); background: rgba(95, 184, 162, .18); border-color: var(--ac-2); color: #c9f3e7; font-weight: 700; }

/* fallback zone (trang test / khi layout chưa có zone) */
.q-zone { pointer-events: none; }
.q-zone > * { pointer-events: auto; }
/* [W2fix] cảm ứng: cốt truyện gập dưới mục tiêu/phần thưởng (ui/dialog.js) */
.q-story { border-top: 1px solid var(--ln-2); }
.q-story-sum { display: flex; align-items: center; min-height: 44px; color: var(--ac); font-weight: 700; cursor: pointer; list-style: none; touch-action: manipulation; }
.q-story-sum::-webkit-details-marker { display: none; }
.q-story-sum::before { content: '▸'; margin-right: var(--sp-2); transition: transform var(--dur-fast); }
.q-story[open] > .q-story-sum::before { transform: rotate(90deg); }
.q-story > :not(summary) { margin-top: var(--sp-2); }
/* [W2fix] pill cảm ứng cao 40 (bảng §3.4) ⇒ vùng chạm dọc 44 bằng ::after */
.q-pill.touch::after { content: ""; position: absolute; left: 0; right: 0; top: min(0px, calc(50% - 22px)); bottom: min(0px, calc(50% - 22px)); }
