/* Gọn nút (02/11): nạp SAU cùng để thắng các lớp ghi đè cũ (admin.css, play.css). Gỡ = xoá dòng <link> trong index.html. */

/* ---- Header: 1 nút ⚙ thay EN/đèn/nhạc/kiểu nền/màu ---- */
.app-header .set-hid { display: none !important; }
.app-header .hdr-music:not(.is-on) { display: none !important; } /* nhạc đang phát mới hiện để tắt nhanh */
.app-header .set-btn { min-width: 44px; min-height: 44px; }
.app-header .set-btn .icon { width: 22px; height: 22px; }
@media (max-width: 760px) {
  /* đã có tab "Tài khoản" ở thanh đáy → bỏ nút trùng trên header */
  body:is([data-view="page"], [data-view="play"]) .app-header .header-actions > button.btn-icon[aria-label="Tài khoản"] { display: none !important; }
}
.tabbar .tab.tab-off { display: none !important; }

/* ---- Soạn bài ---- */
details.ed-more { border: 1px solid var(--c-line); border-radius: 12px; padding: 0 .8rem; }
details.ed-more > summary { min-height: 44px; display: flex; align-items: center; gap: .4rem; cursor: pointer; font-weight: 700; font-size: .92rem; color: var(--c-muted); list-style: none; }
details.ed-more > summary::-webkit-details-marker { display: none; }
details.ed-more > summary::before { content: '＋'; font-weight: 800; }
details.ed-more[open] > summary::before { content: '－'; }
details.ed-more[open] { padding-bottom: .8rem; }

.ai-bar.ai-bar-gon { padding: .6rem; gap: 0; }
.ai-bar.ai-bar-gon .ai-bar-btns { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; }
.ai-bar.ai-bar-gon .ai-bar-btns > .btn { width: auto; min-width: 0; min-height: 44px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 .7em; font-size: .95rem; }
.ai-bar.ai-bar-gon .ai-bar-btns > .btn-primary { grid-column: auto; }
.ai-bar.ai-bar-gon .ai-more { gap: .3rem; }
@media (max-width: 520px) {
  .ai-bar.ai-bar-gon .ai-bar-btns { grid-template-columns: 1fr auto; }
  .ai-bar.ai-bar-gon .ai-bar-btns > .ai-gen { grid-column: 1 / -1; }
}

/* ô nhập: chỉ còn 1 mic (đọc chính tả) trong ô; nút âm thanh ở dòng nhãn */
.item-row .cap { display: flex !important; align-items: center; gap: .3rem; min-height: 32px; }
.item-row .cap .mic-btn { position: static; transform: none; width: 32px; height: 32px; min-width: 32px; min-height: 32px; margin-left: auto; opacity: .75; filter: none; font-size: .95rem; }
.item-row .cap .mic-btn::after { content: ''; position: absolute; inset: -6px; } /* vùng chạm 44px */
.item-row .cap .mic-btn { position: relative; }
.item-row .cap .aud-ctl { order: 3; }
.item-row .cap .aud-ctl .aud-btn { position: relative; }
.item-row .cap .aud-ctl .aud-btn::after { content: ''; position: absolute; inset: -9px; }
.item-row .inp-mic > .dict-btn.in-row { right: .3rem; width: 40px; height: 40px; }
.item-row .inp-mic:has(> .dict-btn) > .input { padding-right: 2.9rem; }

/* ---- Màn chơi: ⋯ gom công cụ phụ trên màn hẹp ---- */
.gt-more { display: contents; }
.game-tools > .gt-more-btn { display: none !important; }
@media (max-width: 700px) {
  .game-tools { position: relative; }
  .game-tools > .gt-more-btn { display: inline-grid !important; }
  .game-tools > .gt-more { display: none; }
  .game-tools > .gt-more.open { display: flex; position: absolute; top: calc(100% + 6px); right: 0; z-index: 80; gap: 6px; padding: 6px; border-radius: 16px; background: var(--c-surface, #fff); box-shadow: 0 12px 30px -10px rgba(16, 24, 40, .45); border: 1px solid var(--c-line, #e3e7ee); }
  .game-tools > .gt-more > .btn-icon { width: 44px !important; min-height: 44px !important; display: inline-grid; place-items: center; }
  .game-tools > .btn-icon { width: 44px !important; min-height: 44px !important; }
  body[data-playmode="window"] .game-tools > .gt-more > .style-btn { display: none; }
  /* chỉ còn 1 nút (âm thanh) thì hiện thẳng, không cần ⋯ */
  body[data-playmode="window"] .game-tools:not(:has(> .gt-more > .say-toggle, > .gt-more > .switch-icon)) > .gt-more { display: contents !important; }
  body[data-playmode="window"] .game-tools:not(:has(> .gt-more > .say-toggle, > .gt-more > .switch-icon)) > .gt-more-btn { display: none !important; }
  .game-tools > .btn-icon[aria-label^="Toàn màn"] { display: inline-grid !important; }

  /* thẻ thông tin: Chia sẻ · Sửa · Giao bài · ⋯ (In, Nhúng) trên 1 hàng */
  .play-actions { display: grid !important; grid-template-columns: 1fr 1fr 1fr 44px; gap: 6px; }
  .play-actions > .pa-rare { display: none !important; }
  .play-actions > .btn { padding: 0 .4em; font-size: .9rem; white-space: nowrap; justify-content: center; }
}
@media (min-width: 701px) { .play-actions > .pa-more { display: none !important; } }

/* ===== Vùng chạm ≥44px trên điện thoại (03/11): trình soạn + engine + nút ⚙. Gỡ = xoá từ dòng này tới hết file. ===== */
@media (max-width: 760px) {
  /* nút ⚙ (admin.css ép .btn-icon 32px, độ ưu tiên 0,2,1) */
  body[data-view] .app-header .set-btn, body[data-view] .app-header .btn-icon.set-btn { width: 44px !important; height: 44px !important; min-width: 44px !important; min-height: 44px !important; }

  /* --- Trình soạn (body có .editor-foot) --- */
  body[data-view]:has(.editor-foot) .input,
  body[data-view]:has(.editor-foot) input:not([type=checkbox]):not([type=radio]),
  body[data-view]:has(.editor-foot) select { min-height: 44px; }
  body[data-view]:has(.editor-foot) .btn,
  body[data-view]:has(.editor-foot) .btn-block,
  body[data-view]:has(.editor-foot) .btn-lg,
  body[data-view]:has(.editor-foot) .kind-tabs button,
  body[data-view]:has(.editor-foot) .back-link,
  body[data-view]:has(.editor-foot) .switch,
  body[data-view]:has(.editor-foot) summary { min-height: 44px; }
  body[data-view]:has(.editor-foot) .btn-icon { width: 44px; min-width: 44px; }
  body[data-view]:has(.editor-foot) .swatch { width: 44px; height: 44px; }
  body[data-view]:has(.editor-foot) .item-row,
  body[data-view]:has(.editor-foot) .item-row.pairs { grid-template-columns: 44px 1fr 44px; }
  body[data-view]:has(.editor-foot) .item-row .img-slot { width: 44px; height: 44px; }
  body[data-view]:has(.editor-foot) .item-row .inp-mic > .dict-btn.in-row { width: 44px; height: 44px; right: 0; }
  body[data-view]:has(.editor-foot) .item-row .inp-mic:has(> .dict-btn) > .input { padding-right: 3rem; }
  /* nút 🔊/🎤/▶/✕ cạnh nhãn: thân 44px thật, hình tròn nhỏ vẽ bằng ::before; bù margin dọc để hàng nhãn không cao thêm */
  body[data-view]:has(.editor-foot) .item-row .cap .mic-btn,
  body[data-view]:has(.editor-foot) .item-row .cap .aud-ctl .aud-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; margin-top: -6px; margin-bottom: -6px; }
  body[data-view]:has(.editor-foot) .item-row .cap .mic-btn::after,
  body[data-view]:has(.editor-foot) .item-row .cap .aud-ctl .aud-btn::after { content: none; }
  body[data-view]:has(.editor-foot) .item-row .cap .aud-ctl { gap: 0; }
  body[data-view]:has(.editor-foot) .item-row .cap .aud-ctl .aud-btn { margin-left: 0; padding: 0; background: none; box-shadow: none; position: relative; isolation: isolate; }
  body[data-view]:has(.editor-foot) .item-row .cap .aud-ctl .aud-btn::before { content: ''; position: absolute; z-index: -1; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; background: var(--c-accent); }
  body[data-view]:has(.editor-foot) .item-row .cap .aud-ctl .aud-btn.aud-del { color: var(--c-muted); }
  body[data-view]:has(.editor-foot) .item-row .cap .aud-ctl .aud-btn.aud-del::before { background: var(--c-surface); box-shadow: inset 0 0 0 1px var(--c-line); }

  /* --- Engine (Học / Toán / mọi trò) --- */
  body .th-kb { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
  /* engine tự thu nhỏ (zoom ≤1, core.js fitStage) khi nội dung cao hơn khung → đặt 48px để sau zoom ≈ vẫn ≥44 */
  body .th-board .th-k, body .th-k { min-height: 54px; min-width: 44px; }
  body .th-hint img { max-height: 10vh; }
  body .th-scene { min-height: clamp(96px, 14vh, 200px); }
  body .th-hint { padding-block: 8px; }
  body .ta-area { --ts: clamp(44px, min(9vw, 14vh, calc(82vw / (var(--n, 8) + 1))), 120px) !important; }
  body .tl .tl-dot { width: 44px; }
  body .tl .tl-slot { min-height: 44px; }
  body .mw-gap { min-height: 44px; }
  body .wz-acts .btn { min-height: 44px; }
}

/* === UI-fix 03/11 (ui-critic) === */
/* (2) Quiz desktop/tablet: bong bóng linh vật không đè ô đáp án (chỉ rộng bằng linh vật, xuống dòng, neo mép phải) */
@media (min-width: 761px) {
  .qz .fxc-say { right: -6px; width: max-content; max-width: 100%; white-space: normal; text-align: center; line-height: 1.2; pointer-events: none; }
  .qz .fxc-say::after { right: 24px; }
}
/* (1) /hoc điện thoại: màn chơi phủ trọn màn hình như /toan (ẩn thanh đầu trang; logo + cài đặt không lọt dưới khung) */
@media (max-width: 760px) {
  body.hoc-play[data-view="play"] .app-header { display: none; }
  body.hoc-play[data-view="play"] .app-main { padding: 0; }
  body.hoc-play[data-view="play"][data-playmode] .game { position: fixed; inset: 0; z-index: 60; height: auto; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
}
/* (3) /hoc điện thoại: mỗi hàng lọc cuộn ngang 1 dòng (không xuống nhiều dòng), bộ từ đầu tiên hiện ngay màn đầu */
@media (max-width: 760px) {
  body .hoc-f { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none; gap: 6px; padding: 2px 0 6px; -webkit-overflow-scrolling: touch; }
  body .hoc-f::-webkit-scrollbar { display: none; }
  body .hoc-f a { scroll-snap-align: start; white-space: nowrap; }
  body .hoc-f a[aria-current] { order: -1; }
}
/* Toán: nút "Chơi tiếp: <bài>" xuống dòng thay vì cắt chữ */
body .mt .btn.mt-go { height: auto; white-space: normal; padding-block: 8px; justify-content: flex-start; text-align: left; }
body .mt .btn.mt-go span { flex: 1 1 0; min-width: 0; max-height: none; white-space: normal; overflow: visible; }
body .mt .btn.mt-go .icon { flex: 0 0 auto; }

/* ===== App-shell mobile (03/11): thanh tab đáy + header kiểu app + trang "Tôi". Khai báo tab: js/appnav.js. Chỉ ≤760px; desktop giữ nguyên. ===== */
.hdr-title { display: none; }
.me-page { display: grid; gap: 14px; max-width: 720px; margin: 0 auto; padding: 4px 0 8px; }
.me-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: var(--c-surface); border: 1px solid var(--c-line); }
.me-avatar { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--c-primary); color: #fff; font-weight: 800; font-size: 1.2rem; }
.me-who { display: grid; min-width: 0; flex: 1; } .me-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .me-who small { color: var(--c-muted); }
.me-cards:empty { display: none; } .me-cards { display: grid; gap: 12px; }
.me-sec h2 { margin: 0 0 6px 4px; font-size: .78rem; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: .04em; }
.me-list { border-radius: 16px; overflow: hidden; background: var(--c-surface); border: 1px solid var(--c-line); }
.me-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 14px; color: inherit; text-decoration: none; font-weight: 600; -webkit-tap-highlight-color: transparent; }
.me-row + .me-row { border-top: 1px solid var(--c-line); }
.me-row:active { background: var(--c-surface-2); }
.me-ic { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--c-primary) 12%, transparent); color: var(--c-primary); }
.me-ic svg { width: 18px; height: 18px; } .me-t { flex: 1; min-width: 0; } .me-row small { color: var(--c-muted); font-weight: 700; } .me-go { color: var(--c-muted); font-size: 1.3rem; }
@media (prefers-reduced-motion: no-preference) { .app-main.route-in { animation: appRouteIn .18s ease-out; } @keyframes appRouteIn { from { opacity: 0; } to { opacity: 1; } } }
@media (max-width: 760px) {
  :root { --tabbar-h: calc(58px + env(safe-area-inset-bottom)); }
  body:not([data-view="play"]):has(.tabbar.app-tabs) { padding-bottom: var(--tabbar-h) !important; }
  body:not([data-view="play"]) .app-main { padding-bottom: 20px; }
  body:not([data-view="play"]) .tabbar.app-tabs { display: grid !important; grid-auto-flow: column; grid-auto-columns: 1fr; left: 0; right: 0; bottom: 0; max-width: none; gap: 0; padding: 0 4px env(safe-area-inset-bottom); z-index: 50; background: color-mix(in srgb, var(--c-surface, #fff) 96%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--c-line); box-shadow: 0 -4px 14px -8px rgba(20,30,60,.25); }
  body:not([data-view="play"]) .tabbar.app-tabs .tab { position: relative; min-height: 58px; min-width: 0; padding: 7px 2px 6px; gap: 3px; border-radius: 0; background: none; font-size: .68rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #5f6b85; }
  body:not([data-view="play"]) .tabbar.app-tabs .tab .tab-ic { display: grid; place-items: center; width: 44px; height: 28px; border-radius: 14px; transition: background .2s, color .2s; }
  body:not([data-view="play"]) .tabbar.app-tabs .tab .tab-ic svg { width: 22px; height: 22px; }
  body:not([data-view="play"]) .tabbar.app-tabs .tab .tab-t { max-width: 100%; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; }
  body:not([data-view="play"]) .tabbar.app-tabs .tab[aria-current="page"] { background: none; color: var(--c-primary); font-weight: 800; }
  body:not([data-view="play"]) .tabbar.app-tabs .tab[aria-current="page"] .tab-ic { background: color-mix(in srgb, var(--c-primary) 16%, transparent); }
  body:not([data-view="play"]) .tabbar.app-tabs .tab[aria-current="page"]::before { content: none; }
  body:not([data-view="play"]) .tabbar.app-tabs .tab-main .tab-ic { width: 44px; height: 32px; margin-top: -2px; border-radius: 16px; background: var(--c-primary); color: #fff; }
  body:not([data-view="play"]) .tabbar.app-tabs .tab-main .tab-ic svg { width: 20px; height: 20px; }
  body:not([data-view="play"]) .tabbar.app-tabs .tab-main[aria-current="page"] .tab-ic { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 28%, transparent); background: var(--c-primary); }
  /* ẩn khi vào màn chơi toàn màn / bàn phím mở */
  body.hoc-play .tabbar.app-tabs, body.kb-open .tabbar.app-tabs { display: none !important; }
  body.hoc-play:has(.tabbar.app-tabs), body.kb-open:has(.tabbar.app-tabs) { padding-bottom: 0 !important; }
  /* header gọn kiểu app: logo nhỏ + tiêu đề trang + nút phụ (⚙) */
  .app-header { height: 52px; padding: 0 8px 0 12px; gap: 8px; }
  .app-header .brand-logo { width: auto; max-width: 74px; max-height: 30px; }
  .app-header .hdr-title { display: block; flex: 1; min-width: 0; font-weight: 800; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 10px; border-left: 1px solid var(--c-line); line-height: 1.2; }
  .app-header .header-spacer, .app-header .header-actions > .badge { display: none !important; }
  .app-header .header-actions { margin-left: auto; }
  .app-header .header-actions > button.btn-icon[aria-label="Tài khoản"] { display: none !important; }
}
/* vùng chạm ≥40px trên điện thoại (admin.css thu nút còn 32px) */
@media (max-width: 760px) {
  body:not([data-view="play"]) .chip, body:not([data-view="play"]) .btn, body:not([data-view="play"]) .btn-icon, body:not([data-view="play"]) .back-link,
  body:not([data-view="play"]) .act-actions .btn { min-height: 40px; }
  body:not([data-view="play"]) .btn-icon { min-width: 40px; }
  body:not([data-view="play"]) .app-main .input, body:not([data-view="play"]) .app-main select, body:not([data-view="play"]) .app-main input:not([type=checkbox]):not([type=radio]):not([type=range]) { min-height: 40px; }
  .back-link { display: inline-flex; align-items: center; }
}
@media (max-width: 760px) {
  body:not([data-view="play"]) .act-title { display: flex; align-items: center; min-height: 40px; }
}
@media (max-width: 520px) { body:not([data-view="play"]) .grid-cards { grid-template-columns: minmax(0, 1fr); } } /* thẻ bài 1 cột: đủ chỗ cho 3 nút ≥40px */

/* Cụm đầu trang Bài của tôi gập/mở +/− (views/collapse.js) */
.cl-box { position: relative; margin: 0 0 1rem; }
.cl-box .cl-body > :last-child { margin-bottom: 0; }
.cl-box .qk-card-head { padding-right: 48px; }
.cl-tog { position: absolute; top: 6px; right: 6px; z-index: 2; width: 44px; height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--c-line); border-radius: 999px; background: var(--c-surface); color: var(--c-ink); font-size: 1.4rem; font-weight: 700; line-height: 1; cursor: pointer; box-shadow: var(--shadow-card); }
.cl-tog:hover, .cl-tog:focus-visible { border-color: var(--c-primary); color: var(--c-primary); }
.cl-line { display: none; width: 100%; min-height: 56px; padding: .5rem 60px .5rem 1rem; border: 0; border-radius: var(--r-lg); background: linear-gradient(135deg, var(--c-primary-soft), var(--c-accent-soft)); color: var(--c-ink); font: inherit; font-weight: 700; font-size: 1.05rem; text-align: left; cursor: pointer; box-shadow: var(--shadow-card); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-box.cl-off .cl-line { display: block; }
.home-hub .hub-embed { max-width: none; padding-top: 0; }
/* /points: thẻ trong cùng hàng cao bằng nhau */
.pts-grid { align-items: stretch; }
.pts-grid > .panel { margin: 0; height: 100%; }
.pts-kpi2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.pts-kpi2 > .panel { margin: 0; padding: 1rem; min-width: 0; }
.pts-kpi2 small { overflow-wrap: anywhere; }

/* ===== Logo header thống nhất (03/11): HVSC + thương hiệu GV, mọi màn (kể cả lúc chơi). Ảnh 4:1, không méo, không tràn khung ===== */
html body .app-header { --brand-h: 40px; padding-left: max(14px, var(--page-pad, 14px)); overflow: hidden; }
html body[data-view="play"] .app-header { --brand-h: 32px; }
html body .app-header .brand { align-self: center; display: inline-flex; align-items: center; gap: 10px; height: var(--brand-h); min-height: 0; padding: 0; line-height: 0; }
html body .app-header .brand .brand-logo { height: var(--brand-h) !important; width: auto !important; max-height: none !important; max-width: none !important; aspect-ratio: 4 / 1 !important; object-fit: contain; image-rendering: auto; }
html body .app-header .brand .brand-user-logo { width: calc(var(--brand-h) - 4px) !important; height: calc(var(--brand-h) - 4px) !important; min-width: 0; border-radius: 50%; object-fit: cover; flex: none; }
html body .app-header .brand .brand-user-name { font-size: 1.05rem; line-height: 1.15; }
@media (max-width: 760px) { html body .app-header { --brand-h: 32px; } html body[data-view="play"] .app-header { --brand-h: 28px; } html body .app-header .brand .brand-user-name { font-size: .95rem; max-width: 40vw !important; } }
@media (max-width: 380px) { html body .app-header { --brand-h: 28px; } html body[data-view="play"] .app-header { --brand-h: 26px; } }
