/* Bộ chọn màu và cắt ảnh (specs/chon-mau-cat-anh/SPEC.md). Theo docs/thiet-ke/HE-GIAO-DIEN.md: 3 cỡ chữ 16/14/12, chữ 14 và 12 luôn 400,
   bo 999/16/10, một màu nhấn, chỗ chạm từ 44, thẻ không viền không bóng. Nạp sau cùng; màu nền, chữ lấy từ token của app.css. */

/* ---------- khối chọn màu ---------- */
.cmau { display: grid; gap: 12px; min-width: 0; }
.hang-mau { grid-template-columns: 1fr; gap: 24px; }  /* mỗi khối chọn màu có dải xem trước hai nền: một cột */

/* dải xem trước: nền sáng và nền tối cạnh nhau; nút, chip đúng màu đang chọn, chữ tab và link kéo về đủ 4.5:1 trên từng nền */
.cmau-xem { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; pointer-events: none; user-select: none; }
.cmau-nen {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0;
  padding: 10px; border-radius: 10px; font-size: 12px; line-height: 1; box-shadow: inset 0 0 0 1px var(--vien);
}
@media (max-width: 519px) { .cmau-xem { grid-template-columns: 1fr; gap: 6px; } .cmau-nen { flex-wrap: nowrap; gap: 6px; padding: 8px; } .cmau-link { margin-left: auto; } }
.cmau-sang { background: #F2F2F7; color: rgba(60, 60, 67, .6); --m-chu: var(--m-sang); }
.cmau-toi { background: #000000; color: rgba(235, 235, 245, .6); --m-chu: var(--m-toi); }
.cmau-nut, .cmau-chip {
  display: block; flex: none; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--m); color: var(--m-tren, #FFFFFF);
  text-align: center; line-height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cmau-chip { height: 24px; line-height: 24px; }
.cmau-tab { display: flex; align-items: center; gap: 4px; color: var(--m-chu); min-width: 0; white-space: nowrap; }
.cmau-tab svg { width: 16px; height: 16px; }
.cmau-link { color: var(--m-chu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cmau-canh-bao { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; font-size: 12px; line-height: 1.4; color: var(--do); }
.cmau-canh-bao .nut-chu { min-height: 44px; padding: 0 4px; font-size: 14px; }

.cmau-goi-y { display: flex; flex-wrap: wrap; gap: 8px; }
.cmau-cham {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--m); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--vien); transition: transform .12s ease;
}
.cmau-cham:active { transform: scale(.94); }
.cmau-cham[aria-checked="true"] { outline: 2px solid var(--nut-nhan); outline-offset: 2px; }

.cmau-hang { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.cmau-khac { position: relative; display: inline-flex; align-items: center; gap: 8px; overflow: hidden; cursor: pointer; }
.cmau-vong { width: 20px; height: 20px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--vien); }
.cmau-khac input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.cmau-khac:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--nhan) 55%, transparent); }
.cmau-ma { display: grid; gap: 6px; }
.cmau-ma .o-nhap { max-width: 220px; font-variant-numeric: tabular-nums; }
.cmau-loi-ma { margin: 0; font-size: 12px; color: var(--do); }

/* ---------- wizard Mỏ Neo, bước Bộ màu: dải xem trước ghim, thẻ to hai cột ---------- */
.cmau-buoc { display: grid; gap: 12px; }
.cmau-ghim { position: sticky; top: var(--cmau-ghim-top, 0px); z-index: 3; padding: 8px 0; background: var(--mat-1); align-self: start; }
.cmau-luoi { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cmau-the {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 96px; padding: 12px;
  border: 0; border-radius: 16px; background: var(--mat2); color: var(--chu); text-align: left; cursor: pointer;
}
.cmau-the:active { transform: scale(.97); }
.cmau-the-ten { font-size: 14px; font-weight: 400; line-height: 1.3; }
.cmau-the small { color: var(--chu-phu); line-height: 1.35; }
.cmau-the[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--nut-nhan); }
.cmau-dai {
  display: flex; width: 100%; height: 28px; margin-top: auto; padding: 0; border-radius: 10px; overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--vien);
}
.cmau-the > .cmau-the-ten + small + .cmau-dai { margin-top: 8px; }
.cmau-dai > i { flex: 1; }
.cmau-dai-trong { display: grid; place-items: center; box-shadow: none; border: 1.5px dashed var(--vien); color: var(--chu-phu); font-size: 16px; }
.cmau-tich { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; display: none; }
.cmau-tich circle { fill: var(--nut-nhan); }
.cmau-tich path { fill: none; stroke: var(--tren-chinh); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cmau-the[aria-checked="true"] .cmau-tich { display: block; }
.cmau-tu-chon { padding: 12px; border-radius: 16px; background: var(--mat2); }

/* ---------- ô ảnh: thanh tiến độ, lỗi tải ---------- */
.cat-khung { position: relative; }
.cat-tien { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--lap); overflow: hidden; }
.cat-tien > i { display: block; width: 0; height: 100%; background: var(--nut-nhan); transition: width .15s linear; }
.cat-loi { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; font-size: 12px; color: var(--do); }
.cat-loi .nut-chu { min-height: 44px; padding: 0 4px; font-size: 14px; }

/* ---------- màn cắt toàn màn, nền tối ---------- */
html.cat-mo { overflow: hidden; }
dialog.cat {
  position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0;
  background: #000000; color: #FFFFFF; overscroll-behavior: contain;
}
dialog.cat[open] { display: flex; flex-direction: column; }
dialog.cat::backdrop { background: #000000; }
dialog.cat:focus { outline: none; }
.cat-dau { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0; }
.cat-huy { justify-self: start; min-height: 44px; padding: 0 12px; border: 0; background: none; color: #FFFFFF; font: inherit; font-size: 14px; cursor: pointer; }
.cat-tieu { margin: 0; font-size: 16px; font-weight: 600; color: #FFFFFF; }
.cat-than { position: relative; flex: 1 1 auto; min-height: 0; }
.cat-ve { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; outline-offset: -3px; }
.cat-ve.keo { cursor: grabbing; }
.cat-ve:focus-visible { outline: 2px solid #FFFFFF; }
.cat-cho { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: rgba(235, 235, 245, .6); pointer-events: none; }
.cat-chan { display: grid; gap: 10px; width: min(480px, 100%); margin-inline: auto; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.cat-chan-cat { grid-template-columns: auto 1fr; }
dialog.cat[data-buoc="cat"] .cat-chan-xem, dialog.cat[data-buoc="xem"] .cat-chan-cat { display: none; }
dialog.cat .nut { min-height: 44px; background: rgba(255, 255, 255, .16); color: #FFFFFF; }
dialog.cat .nut-chinh { background: var(--nut-nhan); color: var(--tren-chinh); }
dialog.cat .nut:disabled { opacity: .4; }
.cat-xoay { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.cat-xoay svg { width: 20px; height: 20px; }

/* xem trước: đúng như sẽ thấy trong app */
.cat-xem { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px; }
.cat-xem[hidden] { display: none; }
.cat-xem-hinh { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.cat-xem-chu { margin: 0; max-width: 320px; font-size: 12px; line-height: 1.4; text-align: center; color: rgba(235, 235, 245, .6); }
.cat-xem img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cat-tron { display: block; width: min(60vw, 200px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: #2C2C2E; }
.cat-o { display: grid; place-items: center; width: min(42vw, 160px); aspect-ratio: 1; border-radius: 16px; }
.cat-o-sang { background: #F2F2F7; }
.cat-o-toi { background: #1C1C1E; }
.cat-logo { display: block; width: 64%; aspect-ratio: 1; border-radius: 16px; overflow: hidden; }
.cat-the, .cat-ngang { display: block; padding: 8px; border-radius: 16px; background: #1C1C1E; }
.cat-the { width: min(56vw, 220px); }
.cat-ngang { width: min(88vw, 360px); }
.cat-the img, .cat-ngang img { border-radius: 10px; }
.cat-the img { aspect-ratio: 4 / 5; height: auto; }
.cat-ngang img { aspect-ratio: 16 / 9; height: auto; }

@media (min-width: 600px) {
  .cat-tron { width: 220px; }
  .cat-o { width: 180px; }
  .cat-the { width: 240px; }
}
@media (prefers-reduced-motion: reduce) { .cmau-cham, .cmau-the, .cat-tien > i { transition: none; } }
