/* v37: hop nhac viec 3 tieng + dua top thang (public/app-nhac.js, docs/SPEC-v37-nhac-viec-dua-top.md).
   Dau hop la dai gradient tim -> hong (cung tong voi nen bang Trello cua cong ty), chu trang tren nen dam nen doc ro
   o CA giao dien toi lan sang; phan than dung bien mau chung (--panel, --ink...) nen tu doi theo giao dien. */

.sheet.nhac-sheet { max-width: 560px; padding: 0; overflow: hidden; border: 0; animation: nhac-vao .34s cubic-bezier(.2, .8, .2, 1); }
.nhac { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---------- dai dau ---------- */
.nhac-hero {
  position: relative; flex: none; padding: 18px 20px 16px; color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, .2) 0, transparent 55%),
    linear-gradient(135deg, #4c1d95 0%, #7e22ce 45%, #db2777 100%);
}
.nhac-x {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.nhac-x:hover, .nhac-x:focus-visible { background: rgba(255, 255, 255, .3); }
.nhac-kicker { font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; opacity: .88; padding-right: 36px; }
.nhac-title { margin: 6px 0 4px; font-size: 22px; line-height: 1.25; color: #fff; padding-right: 30px; }
.nhac-lead { margin: 0; font-size: 14px; line-height: 1.5; color: rgba(255, 255, 255, .94); }
.nhac-lead b { color: #fff; }
.nhac-rank {
  display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 10px 12px; border-radius: 12px;
  background: rgba(0, 0, 0, .22); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.nhac-rank-medal { font-size: 34px; line-height: 1; animation: nhac-lac 2.4s ease-in-out 2; }
.nhac-rank-n { display: block; font-size: 22px; line-height: 1.1; color: #fff; }
.nhac-rank-n small { font-size: 14px; font-weight: 600; opacity: .8; }
.nhac-rank span { font-size: 12.5px; color: rgba(255, 255, 255, .9); }
.nhac-rank .nhac-rank-delta {
  margin-left: auto; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap;
  background: rgba(255, 255, 255, .2); color: #fff;
}
.nhac-rank .nhac-rank-delta.up { background: #4bce97; color: #12261c; }
/* v42 (giam doc nghiem thu): nguoi 0 diem - o to ghi «Chưa có mẫu hợp lệ · tháng M», khong huy chuong, chu nho hon. */
.nhac-rank.khong-diem .nhac-rank-n { font-size: 18px; }
.nhac-rank .nhac-rank-delta.down { background: #f5cd47; color: #3d2e00; white-space: normal; text-align: right; }

/* ---------- than ---------- */
.nhac-body { padding: 14px 16px 8px; overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; background: var(--panel); }
.nhac-task {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 12px 12px 10px; border-radius: 12px;
  border: 1px solid var(--line); border-left-width: 4px; background: var(--panel-2);
}
.nhac-task.todo { border-left-color: var(--warn); }
.nhac-task.done { border-left-color: var(--ok); }
.nhac-ico { font-size: 22px; line-height: 1.2; flex: none; }
.nhac-task-main { flex: 1; min-width: 0; }
.nhac-task-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nhac-task-head b { color: var(--ink-strong); font-size: 14px; }
.nhac-count {
  min-width: 26px; padding: 1px 8px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums;
}
.nhac-task.done .nhac-count { background: var(--ok); color: #12261c; }
.nhac-task p { margin: 4px 0 0; font-size: 13px; line-height: 1.45; color: var(--ink); }
.nhac-task p b { color: var(--ink-strong); }
.nhac-task .nhac-goal { font-weight: 700; color: var(--accent-text); }
.nhac-delta { font-size: 11.5px; font-weight: 800; color: var(--ok); }
.nhac-cta { flex: none; align-self: center; white-space: nowrap; text-decoration: none; }
.nhac-items { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.nhac-items li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 13px; min-width: 0; }
.nhac-items a { color: var(--accent-text); font-weight: 600; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nhac-items a:hover { text-decoration: underline; }
.nhac-items code { font-size: 11px; padding: 1px 5px; border-radius: 4px; background: var(--subtle-2); color: var(--ink-soft); }
.nhac-miss { font-size: 11.5px; font-weight: 700; color: var(--danger); }
.nhac-note { font-size: 11.5px; color: var(--ink-faint); }
.nhac-more, .nhac-rule { margin: 6px 0 0; font-size: 12px; color: var(--ink-faint); }
.nhac-rule a { color: var(--accent-text); font-weight: 600; white-space: nowrap; }

/* ---------- dua top ---------- */
.nhac-race {
  padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--camp-soft), transparent 70%), var(--panel-2);
}
.nhac-race-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; }
.nhac-race-head b { font-size: 14px; color: var(--ink-strong); }
.nhac-days { font-size: 12px; font-weight: 700; color: var(--camp-text); }
.nhac-prize {
  margin: 8px 0 10px; padding: 7px 10px; border-radius: 8px; background: var(--camp-bg); color: var(--camp-ink);
  box-shadow: inset 0 0 0 1px var(--camp-edge); font-size: 13px; font-weight: 800; line-height: 1.4;
}
.nhac-board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.nhac-row {
  display: grid; grid-template-columns: 28px 24px minmax(0, 1fr) minmax(56px, 32%) 38px; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 8px; font-size: 13px;
}
.nhac-row.me { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.nhac-pos { text-align: center; font-size: 15px; font-weight: 800; color: var(--ink-soft); }
.nhac-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-strong); }
.nhac-row:not(.me) .nhac-name { font-weight: 500; }
.nhac-bar { height: 8px; border-radius: 999px; background: var(--subtle-2); overflow: hidden; }
.nhac-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #a855f7, #db2777); }
.nhac-row.me .nhac-bar i { background: linear-gradient(90deg, var(--accent), #22d3ee); }
.nhac-score { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-strong); }
/* v42: bo `.nhac-av-an` (avatar «?» cua dong an danh) - bang dua luon co ten (SPEC-v42 §3). */
.nhac-push { margin: 10px 0 0; font-size: 13.5px; font-weight: 800; color: var(--ink-strong); }

/* ---------- v42: khoi dong vien nhom cuoi bang (nhac-co-len) ----------
   Dat o DAU than hop, ngay duoi dai dau. Mau am (camp) chu khong do / vang canh bao: day la tiep suc, khong phai bao loi. */
.nhac-colen {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--camp-edge);
  background: linear-gradient(135deg, var(--camp-soft), transparent 85%), var(--panel-2);
}
.nhac-colen p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.nhac-colen p + p { margin-top: 6px; }
.nhac-colen b { color: var(--ink-strong); }
.nhac-colen .nhac-colen-mo { font-weight: 700; color: var(--ink-strong); }

/* ---------- vinh danh thang truoc ---------- */
.nhac-honor { padding: 12px; border-radius: 12px; border: 1px dashed var(--camp-edge); background: var(--panel-2); }
.nhac-honor-head { font-size: 14px; font-weight: 700; color: var(--ink-strong); margin-bottom: 10px; }
.nhac-podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; }
.nhac-pod {
  flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px;
  border-radius: 10px; background: var(--subtle-2); text-align: center; min-width: 0;
}
.nhac-pod b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-strong); font-size: 13px; }
.nhac-pod span { font-size: 11.5px; color: var(--ink-soft); }
.nhac-pod-huy { font-size: 24px; line-height: 1.1; }
.nhac-pod.p1 { order: 2; padding-top: 16px; background: var(--camp-bg); box-shadow: inset 0 0 0 1px var(--camp-edge); }
.nhac-pod.p1 b, .nhac-pod.p1 span { color: var(--camp-ink); }
.nhac-pod.p2 { order: 1; }
.nhac-pod.p3 { order: 3; }

/* ---------- chan ---------- */
.nhac-foot {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; border-top: 1px solid var(--line); background: var(--panel);
}
.nhac-next { font-size: 12.5px; color: var(--ink-soft); }
.btn.nhac-go { margin-left: auto; padding: 9px 20px; border: 0; font-weight: 800; color: #fff; background: linear-gradient(135deg, #7e22ce, #db2777); box-shadow: 0 4px 14px rgba(219, 39, 119, .35); }
.btn.nhac-go:hover, .btn.nhac-go:focus-visible { color: #fff; background: linear-gradient(135deg, #7e22ce, #db2777); filter: brightness(1.1); }

/* ---------- Cài đặt ---------- */
.nhac-chot-h { margin: 14px 0 6px; }
.nhac-chot { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--panel-2); }
.nhac-chot summary { cursor: pointer; font-size: 13px; }
.nhac-chot .tbl-wrap { margin-top: 8px; }

/* Man rong: HAI COT - viec can lam ben trai, cuoc dua ben phai - de bang xep hang (phan tao dong luc) hien ngay
   ma khong phai cuon. Mot cot thi bang dua bi day xuong duoi mep man hinh 800px (do tren anh chup e2e). */
@media (min-width: 860px) {
  .sheet.nhac-sheet { max-width: 820px; }
  /* v42 (vong phan bien 20/10): hang CUOI ma bang dua trum qua la `1fr`. Theo thuat toan luoi CSS, phan bang dua cao
     hon cot trai CHI do vao hang co do dai linh hoat - truoc day ba hang deu `auto` nen phan du chia deu cho ca hai
     hang ben trai -> khoang trong lon giua «Cần link mua» va «Mẫu chưa hợp lệ» (thay ro khi hai the deu 0). */
  .nhac-body {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start;
    grid-template-areas: "link dua" "hople dua" "vinh vinh";
    grid-template-rows: auto 1fr auto;
  }
  .nhac-o-link { grid-area: link; }
  .nhac-o-hople { grid-area: hople; }
  .nhac-o-dua { grid-area: dua; }
  .nhac-o-vinh { grid-area: vinh; }
  /* v42: co khoi dong vien thi no la o DAU COT TRAI, bang dua van bat dau tu DINH cot phai - khoi moi KHONG duoc day
     bang dua (va dong «Bạn» cua nguoi cuoi bang) xuong duoi mep hop. Chi doi khi CO khoi (class `co-len`): hang rong
     trong luoi van an mot khoang `gap` - nguoi khac khong duoc bi lech bo cuc. */
  .nhac-body.co-len { grid-template-areas: "colen dua" "link dua" "hople dua" "vinh vinh"; grid-template-rows: auto auto 1fr auto; }
  .nhac-o-colen { grid-area: colen; }
  .nhac-o-link .nhac-task-main { min-width: 0; }
  .nhac-task.nhac-o-link { flex-wrap: wrap; }
  .nhac-o-link .nhac-cta { width: 100%; text-align: center; }
}

@keyframes nhac-vao { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes nhac-lac { 0%, 100% { transform: rotate(0) scale(1); } 50% { transform: rotate(-10deg) scale(1.1); } }
@media (prefers-reduced-motion: reduce) {
  .sheet.nhac-sheet, .nhac-rank-medal { animation: none; }
}
/* Dien thoai: app.css bo tran chieu cao cua hop o man hep (`.ovl.center .sheet { max-height: none }`) nen ca hop
   dai hon man hinh va nut «Làm ngay» (co autofocus) keo khung cuon xuong day - mo ra la mat dai dau. Giu tran o
   day de than hop tu cuon ben trong, dai dau va chan hop luon trong tam mat. */
@media (max-width: 640px) {
  .ovl.center .sheet.nhac-sheet { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); margin: auto 8px; }
}
@media (max-width: 560px) {
  .nhac-hero { padding: 16px 14px 14px; }
  .nhac-title { font-size: 19px; }
  .nhac-body { padding: 12px 10px 6px; }
  .nhac-task { flex-wrap: wrap; }
  .nhac-cta { width: 100%; text-align: center; }
  .nhac-row { grid-template-columns: 26px 24px minmax(0, 1fr) 56px 34px; gap: 6px; }
  .nhac-foot { padding: 10px 12px; }
}
