/*
 * Components — dùng chung cho mọi trang.
 * Phụ thuộc: tokens.css, base.css
 * Trang tổng hợp để duyệt: _component.html
 * Subagent dựng trang KHÔNG sửa file này; cần component mới thì báo lại.
 */

/* =========================================================
   Icon
   ========================================================= */
.tg-icon {
  flex: none;
  width: var(--icon-size, 20px);
  height: var(--icon-size, 20px);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke, 2);
  overflow: visible;
}

.tg-icon--fill {
  fill: currentColor;
  stroke: none;
}

.tg-icon--brand {
  fill: initial;
  stroke: none;
}

/* =========================================================
   Nút
   ========================================================= */
.tg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-5);
  border: 1.5px solid transparent;
  border-radius: var(--radius-lg);
  background: none;
  font-size: var(--text-15);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);
}

.tg-btn:disabled,
.tg-btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Quy ước: .tg-btn, .tg-chip, .tg-link-more là flex có gap để chừa chỗ giữa icon và chữ.
   Chữ có xen thẻ con (số đếm, giá, chữ chỉ hiện ở desktop) phải bọc trong MỘT <span>,
   nếu không mỗi đoạn chữ thành một phần tử flex và bị chèn thêm gap, trông như thừa dấu cách.
   Đúng: <button class="tg-btn"><svg…/><span>Xem <span data-count>4</span> sản phẩm</span></button> */

/* Hành động chính: đỏ đặc. Mỗi màn một nút (ngoại lệ ở README). */
.tg-btn--primary {
  background: var(--color-red);
  color: var(--color-text-on-dark);
  font-weight: var(--weight-bold);
}

.tg-btn--primary:hover,
.tg-btn--primary:active {
  background: var(--color-red-strong);
  color: var(--color-text-on-dark);
}

.tg-btn--primary.tg-btn--glow {
  box-shadow: var(--shadow-cta);
}

/* Hành động phụ: viền xanh */
.tg-btn--outline {
  border-color: var(--color-brand);
  background: var(--color-surface);
  color: var(--color-brand);
}

.tg-btn--outline:hover {
  background: var(--color-brand-tint);
  color: var(--color-brand-strong);
}

/* Viền xanh trên nền xanh nhạt (D14, thẻ đang chọn) */
.tg-btn--soft {
  border-color: var(--color-brand);
  background: var(--color-brand-tint);
  color: var(--color-brand);
}

/* Nút trung tính: viền xám */
.tg-btn--ghost {
  border-color: var(--color-border-input);
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: var(--weight-regular);
}

.tg-btn--ghost:hover {
  border-color: var(--color-brand);
  color: var(--color-text);
}

/* Nút sáng trên nền xanh đậm (banner đại lý) */
.tg-btn--cream {
  background: var(--color-bg);
  color: var(--color-brand-strong);
  font-weight: var(--weight-bold);
}

.tg-btn--cream:hover {
  background: var(--color-surface);
  color: var(--color-brand-strong);
}

/* Nút kính mờ trên ảnh nền tối (khối mở đầu) */
.tg-btn--glass {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--color-text-on-dark);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.tg-btn--glass:hover {
  background: var(--glass-bg-strong);
  color: var(--color-text-on-dark);
}

/* Hỏi kỹ sư qua Zalo */
.tg-btn--zalo {
  border-color: var(--color-zalo);
  background: var(--color-surface);
  color: var(--color-zalo-text);
}

.tg-btn--zalo:hover {
  background: var(--color-zalo-soft);
  color: var(--color-zalo-text);
}

.tg-btn--zalo-solid {
  background: var(--color-zalo);
  color: var(--color-text-on-dark);   /* 4,75:1 */
}

.tg-btn--zalo-solid:hover {
  background: var(--color-zalo-text);
  color: var(--color-text-on-dark);
}

.tg-btn--freeship {
  background: var(--color-freeship);
  color: var(--color-text-on-dark);
  box-shadow: var(--shadow-btn-freeship);
}

.tg-btn--freeship:hover {
  background: var(--color-freeship-strong);
  color: var(--color-text-on-dark);
}

.tg-btn--sm {
  min-height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-meta);
}

.tg-btn--lg {
  min-height: 48px;
  padding: 0 var(--space-6);
  font-size: var(--text-15);
}

.tg-btn--xl {
  min-height: 54px;
  padding: 0 var(--space-7);
  font-size: var(--text-16);
}

.tg-btn--block {
  width: 100%;
}

.tg-btn--pill {
  border-radius: var(--radius-pill);
}

/* Trên mobile nút nhỏ vẫn phải có vùng bấm 44px: mở rộng vùng bấm bằng pseudo-element */
@media (max-width: 1023px) {
  .tg-btn--sm {
    position: relative;
  }

  .tg-btn--sm::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -4px;
    left: -4px;
    height: var(--tap-min);
    transform: translateY(-50%);
  }
}

/* Nút đang xử lý: khóa lại, hiện vòng quay */
.tg-btn.is-loading {
  position: relative;
  pointer-events: none;
}

.tg-btn.is-loading .tg-icon--spin {
  animation: tg-spin 0.8s linear infinite;
}

@keyframes tg-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Nút chỉ có icon, vùng bấm 44px */
.tg-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--tap-min);
  height: var(--tap-min);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: none;
  color: var(--color-brand);
  --icon-size: 24px;
}

.tg-icon-btn:hover {
  background: var(--color-brand-hover-bg);
}

.tg-icon-btn--on-image::after {
  content: "";
  position: absolute;
  inset: -2px;                        /* hộp 40px như wireframe, vùng bấm 44px */
}

.tg-icon-btn--on-image {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-round);
  background: var(--color-on-image);
  color: var(--color-text);
  box-shadow: var(--shadow-card);
  --icon-size: 20px;
}

/* Số đếm trên icon giỏ hàng */
.tg-count-badge {
  position: absolute;
  top: 4px;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  color: var(--color-text-on-dark);
  font-size: var(--text-label);
  font-weight: var(--weight-bold);
  line-height: 1;
}

/* Link có mũi tên "Xem tất cả ›" */
.tg-link-more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-min);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-brand);
  --icon-size: 16px;
}

@media (min-width: 1024px) {
  .tg-link-more {
    min-height: 0;
    font-size: var(--text-15);
  }
}

/* =========================================================
   Nhãn, tag, chip
   ========================================================= */
/* Tag nhỏ in đậm trên nền màu (11px được phép theo README) */
.tg-tag {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--space-1);
  padding: 2px 6px;
  border-radius: var(--radius-md);
  background: var(--color-brand-soft);
  color: var(--color-brand-strong);
  font-size: var(--text-label);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  white-space: nowrap;
}

.tg-tag--solid {
  background: var(--color-brand);
  color: var(--color-text-on-dark);
  font-weight: var(--weight-bold);
}

.tg-tag--neutral {
  background: var(--color-surface-alt);
  color: var(--color-text-secondary);
  font-weight: var(--weight-regular);
  font-size: var(--text-12);
}

.tg-tag--pill {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-12);
}

/* Nhãn viên thuốc phía trên tiêu đề ("Về Tomato Global", "Câu chuyện", "Hợp tác") */
.tg-eyebrow {
  align-self: flex-start;
  padding: var(--space-1) var(--space-2-5);
  border-radius: var(--radius-pill);
  background: var(--color-brand-soft);
  color: var(--color-brand);
  font-size: var(--text-12);
  font-weight: var(--weight-bold);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

/* Trên nền xanh đậm: nền kính mờ, chữ theo màu khối. Mobile 11px (nhãn in đậm trên nền màu). */
.tg-eyebrow--on-dark {
  background: var(--glass-bg);
  color: inherit;
  font-size: var(--text-label);
}

@media (min-width: 1024px) {
  .tg-eyebrow {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-13);
  }
}

/* Huy hiệu đè lên ảnh sản phẩm (Bán chạy, Mới...) */
.tg-badge-overlay {
  position: absolute;
  top: var(--space-1-5);
  left: var(--space-1-5);
  z-index: 1;
  padding: 4px 7px;
  border-radius: var(--radius-pill);
  background: var(--badge-bg, var(--color-red));
  color: var(--color-text-on-dark);
  font-size: var(--text-label);
  font-weight: var(--weight-bold);
  line-height: 1;
  box-shadow: var(--shadow-badge);
}

/* Chip chọn (lọc nhanh, vấn đề vườn) */
.tg-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  min-height: 32px;                   /* mobile theo M02b: 32px, chữ 12px, bo 6px, viền nhạt */
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-meta);
  white-space: nowrap;
  cursor: pointer;
}

@media (min-width: 1024px) {
  .tg-chip {
    min-height: 36px;                 /* desktop theo D02b: 36px, chữ 14px, bo 8px */
    border-color: var(--color-border-input);
    border-radius: var(--radius-md);
    font-size: var(--text-14);
  }
}

.tg-chip:hover {
  border-color: var(--color-brand);
  color: var(--color-text);
}

.tg-chip.is-active,
.tg-chip[aria-pressed="true"] {
  border-color: var(--color-brand);
  background: var(--color-brand-tint);
  color: var(--color-brand-strong);
  box-shadow: inset 0 0 0 1px var(--color-brand);
}

.tg-chip--pill {
  min-height: 36px;
  font-size: var(--text-14);
  border-color: var(--color-border-control);
  border-width: 1.5px;
  border-radius: var(--radius-pill);
}

/* Chip lịch sử tìm kiếm: nền xám, không viền */
.tg-chip--soft {
  min-height: 32px;
  padding: 0 var(--space-3-5);
  border: 0;
  border-radius: var(--radius-3xl);
  background: var(--color-chip-bg);
  font-size: var(--text-meta);
}

/* Chip kính mờ trên nền tối */
.tg-chip--glass {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  color: var(--color-text-on-dark);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.tg-chip--glass:hover {
  border-color: var(--glass-border-strong);
  color: var(--color-text-on-dark);
}

@media (max-width: 1023px) {
  .tg-chip {
    position: relative;
  }

  /* Lớp phủ cao đúng 44px, căn giữa: không phụ thuộc độ dày viền của chip */
  .tg-chip::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 0;
    left: 0;
    height: var(--tap-min);
    transform: translateY(-50%);
  }
}

/* =========================================================
   Giá
   ========================================================= */
/* relative: chữ ẩn "Giá gốc" (tg-sr-only, absolute) nằm trong thẻ của dải cuộn ngang sẽ thoát vùng cắt
   và làm trang mobile tràn ngang nếu không có cha định vị. */
.tg-price {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--space-1-5);
  row-gap: 1px;
  min-width: 0;
}

.tg-price__sale {
  color: var(--color-red);
  font-size: var(--price-size, var(--text-16));
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tg-price__meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

/* Giá gốc: xám, nhỏ hơn giá bán, gạch ngang */
.tg-price__original {
  color: var(--price-original-color, var(--color-text-subtle));
  font-size: var(--text-meta);
  text-decoration: line-through;
}

/* Trên nền kem, #6B736C không đủ tương phản */
.tg-price--on-cream {
  --price-original-color: var(--color-text-muted);
}

.tg-price__discount {
  flex: none;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  background: var(--color-red-soft);
  color: var(--color-red);
  font-size: var(--text-label);
  font-weight: var(--weight-bold);
}

.tg-price--lg {
  --price-size: var(--text-22);
}

@media (min-width: 1024px) {
  .tg-price__original {
    font-size: var(--text-meta);
  }
}

/* =========================================================
   Sao đánh giá
   ========================================================= */
.tg-rating {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-meta);
  color: var(--color-text);
  --icon-size: 1em;
}

.tg-rating .tg-icon {
  color: var(--color-star);
}

.tg-stars {
  display: inline-flex;
  gap: 1px;
  color: var(--color-star);
  --icon-size: 1em;
}

.tg-stars .is-empty {
  color: var(--color-border-strong);
}

/* =========================================================
   Thẻ (khung chung)
   ========================================================= */
.tg-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-warm);
  border-radius: var(--radius-xl);
}

/* Khối trắng full-width trên mobile, bo góc trong khung trên desktop */
.tg-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
}

.tg-section--plain {
  background: none;
  padding-block: var(--space-1-5) 0;
}

@media (min-width: 1024px) {
  .tg-section {
    gap: var(--space-4);
    padding: var(--space-6);
    border: 1px solid var(--color-border-warm);
    border-radius: var(--radius-xl);
  }

  .tg-section--plain {
    padding: 0;
    border: 0;
  }
}

/* Tiêu đề khối + link Xem tất cả */
.tg-section-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.tg-section-head > .tg-link-more {
  margin-left: auto;
}

.tg-section-title {
  color: var(--color-brand-strong);
  font-size: var(--text-section-title);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
}

.tg-section-title--sm {
  font-size: var(--text-17);
}

/* =========================================================
   Thẻ sản phẩm (dọc)
   ========================================================= */
.tg-product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--color-text);
  font-size: var(--text-meta);
}

.tg-product-card:hover {
  color: var(--color-text);
  border-color: var(--color-border-control);
  box-shadow: var(--shadow-card);
}

.tg-product-card__media {
  position: relative;
  aspect-ratio: var(--product-img-ratio, 1 / 1);
  background: var(--color-surface-alt);
}

.tg-product-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tg-product-card__body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: var(--space-2-5);
}

.tg-product-card__name {
  min-height: calc(2 * 1.4em);
  font-size: var(--text-body-sm);
  line-height: 1.4;
}

.tg-product-card__name a {
  color: inherit;
}

/* Cả thẻ bấm được: link tên phủ toàn thẻ */
.tg-product-card__name a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.tg-product-card__foot {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.tg-product-card__sold {
  margin-left: auto;
  color: var(--color-text-muted);
}

/* Dải Flash Sale dưới giá (chốt 04/11/2026): số tiền giảm nhờ Flash Sale + thời gian còn lại */
.tg-product-card__flash {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--space-1);
  max-width: 100%;
  padding: 2px var(--space-1-5);
  border: 1px solid var(--color-red);
  border-radius: var(--radius-sm);
  background: var(--color-red-soft);
  color: var(--color-red-strong);
  font-size: var(--text-label);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  --icon-size: 12px;
}

/* Thẻ sản phẩm ngang nhỏ (gợi ý tìm kiếm, có thể bạn đang tìm) */
.tg-product-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  padding: var(--space-2-5) 0;
  color: var(--color-text);
  font-size: var(--text-14);
}

.tg-product-row + .tg-product-row {
  border-top: 1px solid var(--color-divider);
}

.tg-product-row__img {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  background: var(--color-surface-alt);
}

.tg-product-row__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

/* Tên là <h3>: đặt cỡ chữ để không nhận cỡ mặc định của trình duyệt (1.17em) */
.tg-product-row__name {
  font-size: var(--text-14);
  font-weight: var(--weight-semibold);
}

.tg-product-row__name a {
  color: inherit;
}

.tg-product-row__name a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.tg-product-row .tg-price {
  --price-size: var(--text-14);
  flex-wrap: nowrap;
}

/* =========================================================
   Vé voucher kiểu Shopee
   ========================================================= */
.tg-ticket {
  --ticket-stub-w: 80px;
  --ticket-h: 100px;
  --ticket-notch: 16px;
  --ticket-bg: var(--gradient-ticket-red);
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;                       /* cho phép co trong lưới/flex; chữ dài cắt bằng dấu … */
  min-height: var(--ticket-h);
  background: var(--color-surface);
  border: 1px solid var(--color-border-warm);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-ticket);
}

.tg-ticket--freeship {
  --ticket-bg: var(--gradient-ticket-freeship);
}

.tg-ticket__stub {
  position: relative;
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  width: var(--ticket-stub-w);
  margin: -1px 0 -1px -1px;
  padding: 0 var(--space-1-5);
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  background: var(--ticket-bg);
  color: var(--color-text-on-dark);
  text-align: center;
  --icon-size: 15px;
}

/* Mép răng cưa bên trái cuống vé */
.tg-ticket__stub::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 5px;
  background: radial-gradient(circle at 0 5px, var(--color-surface) 3px, transparent 3.6px) 0 0 / 5px 10px repeat-y;
}

.tg-ticket__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-round);
  background: var(--glass-bg-strong);
}

.tg-ticket__value {
  font-size: var(--text-17);
  font-weight: var(--weight-bold);
  line-height: 1.05;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.tg-ticket--freeship .tg-ticket__value {
  font-size: var(--text-meta);
}

.tg-ticket__scope {
  max-width: 100%;
  overflow: hidden;
  font-size: var(--text-meta);
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Đường cắt nét đứt + hai khuyết tròn trên dưới */
.tg-ticket__cut {
  position: relative;
  flex: none;
  width: 0;
  margin: var(--space-2-5) 0;
  border-left: 1.5px dashed var(--color-ticket-dash);
}

.tg-ticket__cut::before,
.tg-ticket__cut::after {
  content: "";
  position: absolute;
  left: calc(var(--ticket-notch) / -2);
  width: var(--ticket-notch);
  height: var(--ticket-notch);
  border: 1px solid var(--color-border-warm);
  border-radius: var(--radius-round);
  background: var(--ticket-page-bg, var(--color-surface));
}

.tg-ticket__cut::before {
  top: calc(var(--space-2-5) * -1 - var(--ticket-notch) / 2 - 1px);
  clip-path: inset(50% 0 0 0);
}

.tg-ticket__cut::after {
  bottom: calc(var(--space-2-5) * -1 - var(--ticket-notch) / 2 - 1px);
  clip-path: inset(0 0 50% 0);
}

.tg-ticket__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
  padding: 0 var(--space-2-5) 0 var(--space-3);
}

.tg-ticket__title {
  overflow: hidden;
  color: var(--color-text);
  font-size: var(--text-14);
  font-weight: var(--weight-bold);
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tg-ticket__desc {
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: var(--text-meta);
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tg-ticket__expiry {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  min-width: 0;
  overflow: hidden;
  color: var(--color-text-subtle);
  font-size: var(--text-meta);
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tg-ticket__expiry a {
  font-weight: var(--weight-semibold);
}

.tg-ticket__action {
  display: flex;
  flex: none;
  align-items: center;
  padding-right: var(--space-2-5);
}

@media (min-width: 1024px) {
  .tg-ticket {
    --ticket-stub-w: 100px;
    --ticket-h: 116px;
    --ticket-notch: 18px;
  }

  .tg-ticket__value {
    font-size: var(--text-20);
  }

  .tg-ticket--freeship .tg-ticket__value {
    font-size: var(--text-15);
  }

  .tg-ticket__title {
    font-size: var(--text-15);
  }

  .tg-ticket__desc,
  .tg-ticket__scope,
  .tg-ticket__expiry {
    font-size: var(--text-meta);
  }

  .tg-ticket__body {
    padding: 0 var(--space-3) 0 var(--space-4);
  }

  .tg-ticket__action {
    padding-right: var(--space-3-5);
  }
}

/* =========================================================
   Thẻ nội dung
   ========================================================= */
/* Ô danh mục: ảnh tròn + tên */
.tg-category-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1-5);
  color: var(--color-text);
  font-size: var(--text-meta);
  line-height: var(--leading-snug);
  text-align: center;
}

.tg-category-tile:hover {
  color: var(--color-brand-strong);
}

.tg-category-tile img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-round);
  object-fit: cover;
  background: var(--color-image-bg);
}

@media (min-width: 1024px) {
  .tg-category-tile {
    font-size: var(--text-14);
  }

  .tg-category-tile img {
    width: 72px;
    height: 72px;
  }
}

/* Thẻ vấn đề vườn: triệu chứng → sản phẩm → việc theo mùa */
.tg-problem-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  color: var(--color-text);
}

.tg-problem-card:hover {
  border-color: var(--color-brand);
  color: var(--color-text);
}

.tg-problem-card__title {
  font-size: var(--text-14);
  font-weight: var(--weight-bold);
}

.tg-problem-card__products {
  color: var(--color-brand);
  font-size: var(--text-meta);
  font-weight: var(--weight-semibold);
}

.tg-problem-card__season {
  margin-top: var(--space-1-5);
  padding-top: var(--space-1-5);
  border-top: 1px dashed var(--color-border-warm);
  color: var(--color-text-secondary);
  font-size: var(--text-meta);
}

.tg-problem-card .tg-tag {
  margin-bottom: 2px;
}

@media (min-width: 1024px) {
  .tg-problem-card {
    padding: var(--space-4);
  }

  .tg-problem-card__title {
    font-size: var(--text-15);
  }

  .tg-problem-card__products,
  .tg-problem-card__season {
    font-size: var(--text-meta);
  }
}

/* Thẻ nhà vườn nói gì: ảnh trước–sau + lời kể */
.tg-testimonial {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tg-testimonial__photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}

.tg-testimonial__photo {
  position: relative;
  margin: 0;
}

.tg-testimonial__photo img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  background: var(--color-image-bg);
}

.tg-testimonial__photo figcaption {
  position: absolute;
  left: var(--space-1-5);
  bottom: var(--space-1-5);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-photo-label);
  color: var(--color-text-on-dark);
  font-size: var(--text-label);
  font-weight: var(--weight-bold);
}

.tg-testimonial__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
  padding: var(--space-3);
  font-size: var(--text-meta);
}

.tg-testimonial__quote {
  margin: 0;
  line-height: var(--leading-normal);
}

.tg-testimonial__author {
  font-size: var(--text-meta);
}

.tg-testimonial__used {
  color: var(--color-brand);
  font-size: var(--text-meta);
  font-weight: var(--weight-semibold);
}

@media (min-width: 1024px) {
  .tg-testimonial__photo img {
    height: 150px;
  }

  .tg-testimonial__author,
  .tg-testimonial__used {
    font-size: var(--text-meta);
  }
}

/* Thẻ bài viết: dọc (desktop) và ngang (mobile) */
.tg-article-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--color-text);
}

.tg-article-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--color-image-bg);
}

.tg-article-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
  padding: var(--space-3-5) var(--space-4);
}

.tg-article-card__title {
  font-size: var(--text-16);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
}

.tg-article-card__title a {
  color: inherit;
}

.tg-article-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.tg-article-card--row {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2-5);
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: none;
}

.tg-article-card--row img {
  flex: none;
  width: 100px;
  height: 64px;
  aspect-ratio: auto;
  border-radius: var(--radius-md);
}

.tg-article-card--row .tg-article-card__body {
  gap: 2px;
  padding: 0;
}

.tg-article-card--row .tg-article-card__title {
  font-size: var(--text-meta);
}

/* Ngang trên mobile (như --row), dọc có khung thẻ trên desktop: trang chủ, kiến thức.
   Cỡ ảnh nhỏ, khoảng cách riêng của từng trang ghi đè trong CSS trang. */
@media (max-width: 1023px) {
  .tg-article-card--responsive {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2-5);
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .tg-article-card--responsive img {
    flex: none;
    width: 100px;
    height: 64px;
    aspect-ratio: auto;
    border-radius: var(--radius-md);
  }

  .tg-article-card--responsive .tg-article-card__body {
    gap: 2px;
    padding: 0;
  }

  .tg-article-card--responsive .tg-article-card__title {
    font-size: var(--text-meta);
  }
}

@media (min-width: 1024px) {
  .tg-article-card--responsive {
    border: 1px solid var(--color-border-warm);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
  }

  .tg-article-card--responsive:hover {
    border-color: var(--color-border-control);
  }
}

/* Thẻ "Đến kỳ dùng lại" */
.tg-rebuy-card {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  padding: var(--space-3) var(--space-4);
}

.tg-rebuy-card__img {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--color-surface-alt);
}

.tg-rebuy-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  font-size: var(--text-meta);
}

.tg-rebuy-card__name {
  font-size: var(--text-14);
  font-weight: var(--weight-semibold);
}

@media (min-width: 1024px) {
  .tg-rebuy-card {
    gap: var(--space-3-5);
    box-shadow: var(--shadow-card);
  }

  .tg-rebuy-card__img {
    width: 64px;
    height: 64px;
  }

  .tg-rebuy-card__name {
    font-size: var(--text-15);
  }
}

/* Icon tròn nền xanh nhạt: dòng cam kết, thẻ liên hệ, về Tomato.
   Mặc định 40px (icon 20px). Cỡ khác theo màn hình (ví dụ desktop lớn hơn) ghi đè trong CSS trang
   bằng .tg-<trang> .tg-icon-circle. */
.tg-icon-circle {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-round);
  background: var(--color-brand-soft);
  color: var(--color-brand);
  --icon-size: 20px;
}

.tg-icon-circle--sm {
  width: 32px;
  height: 32px;
  --icon-size: 16px;
}

.tg-icon-circle--md {
  width: var(--tap-min);
  height: var(--tap-min);
  --icon-size: 22px;
}

.tg-icon-circle--lg {
  width: 52px;
  height: 52px;
  --icon-size: 24px;
}

/* Trên nền xanh đậm */
.tg-icon-circle--on-dark {
  background: var(--glass-bg);
  color: var(--color-text-on-dark);
}

/* Dòng cam kết: icon tròn (.tg-icon-circle--sm) + 2 dòng chữ */
.tg-trust-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-meta);
  line-height: var(--leading-snug);
}

.tg-trust-item__text {
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .tg-trust-item {
    font-size: var(--text-14);
  }

  .tg-trust-item .tg-icon-circle {
    width: 44px;
    height: 44px;
  }
}

/* =========================================================
   Điều hướng trong trang
   ========================================================= */
.tg-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-14);
}

.tg-breadcrumb ol {
  display: contents;
}

.tg-breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.tg-breadcrumb li + li::before {
  content: "›";
  color: var(--color-text-muted);
}

.tg-breadcrumb [aria-current="page"] {
  color: var(--color-text-muted);
}

/* Tab gạch chân (sắp xếp, trạng thái) */
.tg-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  scrollbar-width: none;
}

.tg-tabs::-webkit-scrollbar {
  display: none;
}

.tg-tab {
  flex: 1;
  min-height: var(--tap-min);
  padding: var(--space-3) var(--space-2-5);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-text);
  font-size: var(--text-14);
  text-align: center;
  white-space: nowrap;
}

.tg-tab:hover {
  color: var(--color-brand);
}

.tg-tab.is-active,
.tg-tab[aria-selected="true"] {
  border-bottom-color: var(--color-brand);
  color: var(--color-brand);
  font-weight: var(--weight-semibold);
}

@media (min-width: 1024px) {
  .tg-tab {
    flex: none;
    padding: var(--space-4) var(--space-4);
    font-size: var(--text-15);
  }
}

/* Mục lục cuộn ngang dạng viên thuốc (M3c, chính sách) */
.tg-toc-pills {
  display: flex;
  gap: var(--space-1-5);
  padding-block: var(--space-1);      /* chỗ cho vùng bấm nới ra, không bị overflow cắt */
  overflow-x: auto;
  scrollbar-width: none;
}

.tg-toc-pills::-webkit-scrollbar {
  display: none;
}

.tg-toc-pills a::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: var(--tap-min);             /* hộp 36px, vùng bấm 44px */
  transform: translateY(-50%);
}

.tg-toc-pills a {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-meta);
  white-space: nowrap;
}

.tg-toc-pills a.is-active,
.tg-toc-pills a[aria-current="true"] {
  border-color: var(--color-brand);
  background: var(--color-brand-soft-alt);
  color: var(--color-brand-strong);
  font-weight: var(--weight-semibold);
}

/* Nhóm nút chuyển (Theo số cây / Theo diện tích) */
.tg-segmented {
  display: flex;
  padding: 3px;
  border-radius: var(--radius-lg);
  background: var(--color-segment-bg);
  font-size: var(--text-meta);
}

.tg-segmented button {
  position: relative;
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-lg);
  background: none;
  color: var(--color-text-muted);
}

/* Hộp 36px như wireframe, vùng bấm nới ra 44px (nằm trong đệm 3px của nhóm + 1px) */
.tg-segmented button::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: var(--tap-min);
  transform: translateY(-50%);
}

.tg-segmented button[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-brand-strong);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-segment);
}

/* Phân trang */
.tg-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.tg-pagination a,
.tg-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap-min);
  height: var(--tap-min);
  padding: 0 var(--space-1-5);
  border-radius: var(--radius-lg);
  color: var(--color-text-secondary);
  font-size: var(--text-15);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.tg-pagination a:hover {
  background: var(--color-brand-hover-bg);
  color: var(--color-brand-strong);
}

.tg-pagination [aria-current="page"] {
  background: var(--color-brand);
  color: var(--color-text-on-dark);
  box-shadow: var(--shadow-active-green);
}

.tg-pagination__nav {
  border: 1.5px solid var(--color-border-control);
  background: var(--color-surface);
  color: var(--color-brand) !important;
}

.tg-pagination__nav[aria-disabled="true"] {
  color: var(--color-border-input) !important;
  pointer-events: none;
}

.tg-pagination__dots {
  color: var(--color-text-subtle) !important;
  font-weight: var(--weight-regular) !important;
}

@media (min-width: 1024px) {
  .tg-pagination a,
  .tg-pagination span {
    min-width: 38px;
    height: 38px;
  }
}

/* =========================================================
   Form
   ========================================================= */
.tg-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
  font-size: var(--text-14);
}

.tg-field__label {
  color: var(--color-text-secondary);
  font-weight: var(--weight-semibold);
}

.tg-field__required {
  color: var(--color-red);
}

.tg-field__hint {
  color: var(--color-text-muted);
  font-size: var(--text-meta);
}

.tg-field__error {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-red);
  font-size: var(--text-body-sm);
  --icon-size: 16px;
}

.tg-input,
.tg-select,
.tg-textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 var(--space-3-5);
  border: 1.5px solid var(--color-border-control);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-input);
  color: var(--color-text);
  font-size: var(--text-16);   /* 16px để iOS không tự phóng to khi chạm vào ô */
}

.tg-textarea {
  min-height: 112px;
  padding: var(--space-3) var(--space-3-5);
  line-height: var(--leading-normal);
  resize: vertical;
}

.tg-select {
  appearance: none;
  padding-right: 40px;
}

/* Bọc .tg-select để vẽ mũi tên bằng mask, màu lấy từ token */
.tg-select-wrap {
  position: relative;
  display: block;
}

.tg-select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 16px;
  height: 16px;
  background: var(--color-brand);
  -webkit-mask: url("../icons/chevron-down.svg") center / contain no-repeat;
  mask: url("../icons/chevron-down.svg") center / contain no-repeat;
  transform: translateY(-50%);
  pointer-events: none;
}

.tg-input:focus,
.tg-select:focus,
.tg-textarea:focus {
  border-color: var(--color-brand);
  box-shadow: var(--ring-input-focus);
  outline: none;
}

.tg-input[aria-invalid="true"],
.tg-select[aria-invalid="true"],
.tg-textarea[aria-invalid="true"] {
  border-color: var(--color-red);
}

/* Ô tìm kiếm */
.tg-search {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  min-height: var(--tap-min);
  padding: 0 var(--space-2-5);
  border: 1.5px solid var(--color-brand);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text-muted);
  --icon-size: 16px;
}

.tg-search input {
  flex: 1;
  min-width: 0;
  height: calc(var(--tap-min) - 3px);   /* trừ viền 1,5px trên dưới */
  border: 0;
  background: none;
  color: var(--color-text);
  font-size: var(--text-16);
  outline: none;
}

.tg-search:focus-within {
  box-shadow: var(--ring-input-focus);
}

/* Ô chọn có tick */
.tg-check {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  min-height: var(--tap-min);
  font-size: var(--text-14);
  cursor: pointer;
}

/* Ô tick tự vẽ như wireframe (.cb): ô 18px viền xám, tick thì nền xanh + dấu tick trắng */
.tg-check input {
  position: relative;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--color-text-subtle);
  border-radius: 5px;
  background: var(--color-surface);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.tg-check input::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--color-text-on-dark);
  -webkit-mask: url("../icons/check.svg") center / contain no-repeat;
  mask: url("../icons/check.svg") center / contain no-repeat;
  opacity: 0;
}

.tg-check input:checked {
  border-color: var(--color-brand);
  background: var(--color-brand);
}

.tg-check input:checked::before {
  opacity: 1;
}

.tg-check input:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.tg-check input:disabled {
  border-color: var(--color-border-input);
  background: var(--color-surface-disabled);
  cursor: not-allowed;
}

/* Tăng giảm số lượng: dạng viên thuốc như wireframe (M3d, D3, D4) */
.tg-qty {
  display: inline-flex;
  flex: none;
  align-self: flex-start;
  align-items: center;
  gap: var(--space-1);
  padding: 3px;
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-pill);
  background: var(--color-brand-hover-bg);
}

.tg-qty button {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-round);
  background: var(--color-surface);
  box-shadow: var(--shadow-qty-btn);
  color: var(--color-brand);
  transition: background-color var(--duration-fast), color var(--duration-fast);
  --icon-size: 16px;
}

/* Nút tròn 30px như wireframe, vùng bấm nới ra 44×44 */
.tg-qty button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--tap-min);
  height: var(--tap-min);
  transform: translate(-50%, -50%);
}

.tg-qty button:hover {
  background: var(--color-brand);
  color: var(--color-text-on-dark);
}

/* Nút bị khóa (đang ở số lượng tối thiểu/tối đa): không cần đạt tương phản theo WCAG */
.tg-qty button:disabled {
  background: transparent;
  box-shadow: none;
  color: var(--color-disabled);
  cursor: not-allowed;
}

.tg-qty input {
  width: 34px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-brand-strong);
  font-size: var(--text-16);   /* wireframe 15px; giữ 16px để iOS không tự phóng to khi gõ */
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.tg-qty input:focus-visible {
  border-radius: var(--radius-sm);
  outline-offset: 0;
}

.tg-qty input::-webkit-outer-spin-button,
.tg-qty input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

/* Ô lựa chọn dạng thẻ (phân loại, quy cách) */
.tg-option {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: var(--tap-min);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-meta);
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
}

.tg-option[aria-pressed="true"],
.tg-option.is-active {
  border: 1.5px solid var(--color-brand);
  background: var(--color-brand-soft-alt);
  color: var(--color-brand-strong);
  font-weight: var(--weight-semibold);
}

.tg-option:disabled,
.tg-option[aria-disabled="true"] {
  border-style: dashed;
  background: var(--color-surface-disabled);
  color: var(--color-text-subtle);
  cursor: not-allowed;
}

/* =========================================================
   Thanh hành động dính đáy (mobile) và bottom sheet
   ========================================================= */
.tg-action-bar {
  position: fixed;
  inset: auto 0 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2-5) var(--space-3) calc(var(--space-2-5) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--color-border-strong);
  background: var(--color-surface);
}

/* Nút dọc icon + chữ trong thanh hành động (Hỏi kỹ sư, Thêm vào giỏ) */
.tg-action-bar__stack {
  flex-direction: column;
  gap: 2px;
  min-height: 48px;
  padding: 0 var(--space-2);
  font-size: var(--text-meta);
  --icon-size: 18px;
}

.tg-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: var(--color-backdrop);
}

.tg-sheet {
  position: fixed;
  inset: auto 0 0;
  z-index: var(--z-sheet);
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  border-radius: var(--radius-3xl) var(--radius-3xl) 0 0;
  background: var(--color-surface);
  box-shadow: var(--shadow-sheet);
  transform: translateY(100%);
  /* Khi đóng: ẩn hẳn sau khi trượt xuống, để phím Tab và trình đọc màn hình không vào được bên trong */
  visibility: hidden;
  transition: transform var(--duration-base) var(--ease-out), visibility 0s linear var(--duration-base);
}

.tg-sheet.is-open {
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.tg-sheet__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-16);
  font-weight: var(--weight-bold);
}

.tg-sheet__head .tg-icon-btn {
  margin-left: auto;
  color: var(--color-text);
}

.tg-sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.tg-sheet__foot {
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--color-border);
}

/* Khóa cuộn trang nền khi sheet đang mở (assets/js/sheet.js gắn class vào <html>) */
.tg-sheet-locked,
.tg-sheet-locked body {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

/* =========================================================
   Trạng thái (dùng chung; plan 08 dựng đầy đủ)
   ========================================================= */
.tg-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2-5);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--color-brand-tint);
  color: var(--color-text);
  font-size: var(--text-body-sm);
  line-height: var(--leading-normal);
  --icon-size: 18px;
}

.tg-alert .tg-icon {
  color: var(--color-brand);
}

.tg-alert--error {
  background: var(--color-red-soft);
}

.tg-alert--error .tg-icon {
  color: var(--color-red);
}

.tg-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2-5);
  padding: var(--space-6) var(--space-4);
  text-align: center;
}

.tg-empty__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-round);
  background: var(--color-surface-alt);
  color: var(--color-text-subtle);
  --icon-size: 30px;
}

.tg-empty__title {
  font-size: var(--text-17);
  line-height: 1.4;
}

.tg-empty__text {
  max-width: 36ch;
  color: var(--color-text-muted);
  font-size: var(--text-14);
}

.tg-skeleton {
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--color-surface-muted) 25%, var(--color-surface-disabled) 50%, var(--color-surface-muted) 75%) 0 0 / 200% 100%;
  animation: tg-shimmer 1.4s linear infinite;
}

@keyframes tg-shimmer {
  to {
    background-position: -200% 0;
  }
}

/* =========================================================
   Thông báo nổi, dải mất kết nối, khung chờ tải, nút đang xử lý
   (chuyển từ plan 08; JS: assets/js/toast.js, network-status.js, busy-button.js)
   ========================================================= */
/* Khoảng cách từ đáy màn tới toast / dải mất mạng trên mobile.
   Trang có bottom nav hoặc thanh hành động dính đáy thì nổi lên trên thanh đó
   (cùng cách base.css chừa chỗ cuối body). Desktop không có các thanh này. */
body {
  --tg-float-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 1023px) {
  body:has(.tg-bottom-nav) {
    --tg-float-bottom: calc(var(--bottom-nav-height) + var(--space-3) + env(safe-area-inset-bottom, 0px));
  }

  body:has(.tg-action-bar) {
    --tg-float-bottom: calc(var(--action-bar-height) + var(--space-3) + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- Nút đang xử lý ----------
   components.css làm mờ mọi nút aria-disabled xuống 0,55, chữ trắng trên nền đỏ khi đó
   chỉ còn 2,7:1. Nút đang xử lý vẫn phải đọc được chữ "Đang đặt hàng…", nên giữ 0,9 (4,68:1). */
.tg-btn.is-loading,
.tg-btn.is-loading[aria-disabled="true"] {
  opacity: 0.9;
  cursor: progress;
}

/* ---------- Thông báo nổi (toast) ----------
   Mobile: dải tối ở đáy màn, một dòng chữ + link Xem giỏ (M11).
   Desktop: thẻ trắng ngay dưới icon giỏ ở header, có ảnh sản phẩm + nút Xem giỏ hàng (D11).
   Markup do assets/js/toast.js dựng; .tg-toast--static để trình bày tĩnh trên trang duyệt. */
.tg-toast-region {
  position: fixed;
  right: var(--space-2);
  bottom: calc(var(--tg-float-bottom) + var(--tg-offline-bar-h, 0px));
  left: var(--space-2);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.tg-toast-region > .tg-toast {
  pointer-events: auto;
}

.tg-toast {
  display: flex;
  flex-direction: column;
  gap: var(--space-2-5);
  width: 100%;
  max-width: 480px;
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3-5);
  border-radius: var(--radius-lg);
  background: var(--color-text);
  color: var(--color-text-on-dark);
  font-size: var(--text-14);
  line-height: var(--leading-snug);
  box-shadow: var(--shadow-float);
  opacity: 0;
  transform: translateY(var(--space-2));
  transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}

.tg-toast.is-visible {
  opacity: 1;
  transform: none;
}

/* Hai class để thắng .tg-toast trong media query desktop */
.tg-toast.tg-toast--static {
  opacity: 1;
  transform: none;
  box-shadow: none;
  transition: none;
}

.tg-toast__head {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  min-height: var(--tap-min);
}

.tg-toast__check {
  color: var(--color-check-on-dark);
  --icon-size: 20px;
  --icon-stroke: 2.5;
}

.tg-toast__title {
  flex: 1;
  min-width: 0;
}

.tg-toast__link {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-1);
  color: var(--color-link-on-dark);
  font-weight: var(--weight-semibold);
}

.tg-toast__link:hover {
  color: var(--color-text-on-dark);
}

.tg-toast__close {
  color: var(--color-text-on-dark);
  --icon-size: 18px;
}

.tg-toast__close:hover {
  background: var(--glass-bg);
}

.tg-toast__product {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
}

.tg-toast__img {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  object-fit: cover;
}

.tg-toast__info {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-0-5);
  min-width: 0;
  font-size: var(--text-meta);
}

.tg-toast__name {
  font-weight: var(--weight-semibold);
}

.tg-toast__qty {
  color: var(--color-text-muted);
}

.tg-toast__product .tg-price {
  --price-size: var(--text-14);
  flex: none;
  flex-wrap: nowrap;
}

/* Nền tối trên mobile: viền focus vàng như các vùng nền tối khác */
@media (max-width: 1023px) {
  .tg-toast :focus-visible {
    outline: var(--focus-ring-on-dark);
  }
}

@media (min-width: 1024px) {
  .tg-toast-region {
    top: var(--toast-top, var(--space-4));
    right: var(--toast-right, var(--gutter));
    bottom: auto;
    left: auto;
    align-items: flex-end;
  }

  .tg-toast {
    width: 340px;
    max-width: calc(100vw - 2 * var(--gutter));
    padding: var(--space-3-5);
    border: 1px solid var(--color-border-warm);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    color: var(--color-text);
    transform: translateY(calc(var(--space-2) * -1));
  }

  .tg-toast__head {
    gap: var(--space-1-5);
    min-height: 0;
  }

  .tg-toast__check {
    color: var(--color-brand);
    --icon-size: 16px;
    --icon-stroke: 2.6;
  }

  .tg-toast__title {
    color: var(--color-brand);
    font-weight: var(--weight-semibold);
  }

  .tg-toast__close {
    width: var(--space-8);
    height: var(--space-8);
    margin: calc(var(--space-1-5) * -1) calc(var(--space-1-5) * -1) calc(var(--space-1-5) * -1) 0;
    color: var(--color-text-muted);
  }

  .tg-toast__close:hover {
    background: var(--color-brand-hover-bg);
    color: var(--color-text);
  }

  .tg-toast__action {
    min-height: var(--space-10);
  }
}

/* Giảm chuyển động: chỉ mờ dần, không trượt */
@media (prefers-reduced-motion: reduce) {
  .tg-toast,
  .tg-toast.is-visible {
    transform: none;
  }
}

/* Số trên icon giỏ nhảy lên khi vừa thêm hàng (toast.js gắn .is-bumped) */
.tg-count-badge.is-bumped {
  animation: tg-badge-bump var(--duration-base) var(--ease-out);
}

@keyframes tg-badge-bump {
  50% {
    transform: scale(1.35);
  }
}

/* ---------- Dải mất kết nối ----------
   Mobile: nền vàng cảnh báo (M11). Desktop: nền tối, icon vàng, nút Thử lại nền trắng (D11).
   Markup ở trang hoặc do assets/js/network-status.js tự dựng. */
.tg-offline-bar {
  position: fixed;
  right: var(--space-2);
  bottom: var(--tg-float-bottom);
  left: var(--space-2);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-lg);
  background: var(--color-warning-bg-strong);
  color: var(--color-warning-text);
  font-size: var(--text-14);
  line-height: var(--leading-normal);
  box-shadow: var(--shadow-card);
}

.tg-offline-bar--static {
  position: static;
  box-shadow: none;
}

.tg-offline-bar__icon {
  --icon-size: 20px;
}

.tg-offline-bar__text {
  flex: 1;
  min-width: 0;
  padding-block: var(--space-1-5);
}

.tg-offline-bar__retry {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-min);
  padding: 0 var(--space-2-5);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  --icon-size: 16px;
}

.tg-offline-bar__retry:hover {
  background: var(--color-surface);
}

.tg-offline-bar__retry[aria-busy="true"] {
  cursor: progress;
}

.tg-offline-bar__retry[aria-busy="true"] .tg-icon {
  animation: tg-spin 0.8s linear infinite;
}

@media (min-width: 1024px) {
  .tg-offline-bar {
    right: 0;
    bottom: var(--space-6);
    left: 0;
    gap: var(--space-3);
    width: min(640px, calc(100% - 2 * var(--gutter)));
    margin-inline: auto;
    padding: var(--space-3-5) var(--space-4);
    border-color: transparent;
    background: var(--color-text);
    color: var(--color-text-on-dark);
    box-shadow: var(--shadow-float);
  }

  .tg-offline-bar--static {
    width: auto;
    margin: 0;
    box-shadow: none;
  }

  .tg-offline-bar__icon {
    color: var(--color-gold);
  }

  .tg-offline-bar__text {
    padding-block: 0;
  }

  .tg-offline-bar__retry {
    min-height: 36px;
    padding: 0 var(--space-3-5);
    background: var(--color-surface);
    color: var(--color-text);
    --icon-size: 15px;
  }

  .tg-offline-bar__retry:hover {
    background: var(--color-bg);
  }

  .tg-offline-bar :focus-visible {
    outline: var(--focus-ring-on-dark);
  }
}

/* ---------- Khung chờ tải (ghép từ .tg-skeleton có sẵn) ----------
   Giữ đúng hình dạng thẻ thật để trang không nhảy khi nội dung tải xong. */
.tg-skeleton--text {
  display: block;
  height: var(--space-3);
}

.tg-skeleton--price {
  display: block;
  height: var(--space-4);
}

.tg-skeleton--w-90 { width: 90%; }
.tg-skeleton--w-60 { width: 60%; }
.tg-skeleton--w-45 { width: 45%; }
.tg-skeleton--w-40 { width: 40%; }

/* Thẻ sản phẩm chờ tải: cùng khung .tg-card và tỉ lệ ảnh với .tg-product-card */
.tg-skeleton-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-bottom: var(--space-2-5);
  overflow: hidden;
}

.tg-skeleton-card__media {
  display: block;
  aspect-ratio: var(--product-img-ratio, 1 / 1);
  border-radius: 0;
}

.tg-skeleton-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
  padding: 0 var(--space-2);
}

@media (min-width: 1024px) {
  .tg-skeleton-card {
    padding-bottom: var(--space-3);
  }

  .tg-skeleton-card__body {
    gap: var(--space-2);
    padding: 0 var(--space-2-5);
  }
}

/* Thẻ bài viết chờ tải: dọc (như .tg-article-card) và ngang (như .tg-article-card--row) */
.tg-skeleton-article {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tg-skeleton-article__media {
  display: block;
  aspect-ratio: 16 / 10;
  border-radius: 0;
}

.tg-skeleton-article__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3-5) var(--space-4);
}

.tg-skeleton-article--row {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2-5);
  overflow: visible;
}

.tg-skeleton-article--row .tg-skeleton-article__media {
  flex: none;
  width: 100px;
  height: 64px;
  aspect-ratio: auto;
  border-radius: var(--radius-md);
}

.tg-skeleton-article--row .tg-skeleton-article__body {
  gap: var(--space-1-5);
  padding: 0;
}

/* ---------- Trạng thái trống: hàng nút ---------- */
.tg-empty__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2-5);
  width: 100%;
  max-width: 320px;
  margin-top: var(--space-1-5);
}

@media (min-width: 1024px) {
  .tg-empty__actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    max-width: none;
  }
}

/* ---------- Lỗi dưới ô nhập có link chỉ cách sửa ---------- */
.tg-field__error a {
  color: var(--color-brand);
  font-weight: var(--weight-semibold);
}

.tg-field__error a:hover {
  color: var(--color-brand-strong);
}

/* Báo lỗi tải cả khối: chữ + nút sửa */
.tg-alert__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 0;
}

/* =========================================================
   Ô lựa chọn dạng thẻ có ô tick ẩn (bộ lọc: cây trồng, công dụng, dạng…)
   <label class="tg-check-card"><input type="checkbox"><span class="tg-check-card__text">Sầu riêng</span></label>
   Ô tick trong suốt nhưng vẫn bấm và focus được; chọn thì thẻ tô xanh.
   .tg-check-card--plain-desktop: từ 1024px hiện thành ô tick thường kèm chữ (cột lọc bên trái).
   ========================================================= */
.tg-check-card {
  position: relative;
  display: flex;
  cursor: pointer;
}

.tg-check-card__text {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: var(--tap-min);
  padding: 0 var(--space-1);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-meta);
  line-height: var(--leading-snug);
  text-align: center;
  --icon-size: 1em;
}

.tg-check-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.tg-check-card input:checked + .tg-check-card__text {
  border-color: var(--color-brand);
  background: var(--color-brand-soft-alt);
  color: var(--color-brand-strong);
  font-weight: var(--weight-semibold);
}

.tg-check-card input:focus-visible + .tg-check-card__text {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

@media (min-width: 1024px) {
  .tg-check-card--plain-desktop {
    align-items: center;
    gap: var(--space-2-5);
    padding: var(--space-1) 0;
  }

  /* Desktop: ô tick thường, cùng kiểu với .tg-check (wireframe D2b .cb) */
  .tg-check-card--plain-desktop input {
    position: relative;
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1.5px solid var(--color-text-subtle);
    border-radius: 5px;
    background: var(--color-surface);
    opacity: 1;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
  }

  .tg-check-card--plain-desktop input::before {
    content: "";
    position: absolute;
    inset: 1px;
    background: var(--color-text-on-dark);
    -webkit-mask: url("../icons/check.svg") center / contain no-repeat;
    mask: url("../icons/check.svg") center / contain no-repeat;
    opacity: 0;
  }

  .tg-check-card--plain-desktop input:checked {
    border-color: var(--color-brand);
    background: var(--color-brand);
  }

  .tg-check-card--plain-desktop input:checked::before {
    opacity: 1;
  }

  .tg-check-card--plain-desktop input:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
  }

  .tg-check-card--plain-desktop .tg-check-card__text,
  .tg-check-card--plain-desktop input:checked + .tg-check-card__text {
    justify-content: flex-start;
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-text);
    font-size: var(--text-14);
    font-weight: var(--weight-regular);
    text-align: left;
  }

  .tg-check-card--plain-desktop input:focus-visible + .tg-check-card__text {
    outline: none;
  }
}

/* =========================================================
   Kiểu chữ thân bài (.tg-prose)
   Nội dung sinh từ trình soạn thảo WordPress (the_content()), nên viết kiểu cho thẻ thường bên trong,
   không cần class trên từng thẻ. Bọc <section id> quanh mỗi mục là tùy chọn: mục lục nhảy tới id,
   khi lên WordPress chỉ cần đặt "HTML anchor" cho từng tiêu đề h2.
   Khối riêng: khung Lưu ý .tg-prose__note, khung bảng .tg-prose__table (hoặc figure.wp-block-table).
   - Mặc định: bài viết kiến thức (chữ 16px / 17px desktop, số bước trong vòng tròn xanh đậm).
   - .tg-prose--compact: văn bản dài kiểu chính sách, điều khoản (chữ 14px / 16px, mục có gạch phân cách,
     chấm tròn vẽ bằng ::before, số bước nền xanh nhạt, bảng có cột đầu in đậm).
   ========================================================= */
.tg-prose {
  --prose-flow: var(--space-3-5);
  color: var(--color-text);
  font-size: var(--text-16);
  line-height: 1.7;
}

/* Khoảng cách đều giữa các khối, dù có bọc <section> hay không */
.tg-prose > * + *,
.tg-prose section > * + * {
  margin-top: var(--prose-flow);
}

.tg-prose > * + h2,
.tg-prose > * + h3 {
  margin-top: calc(var(--prose-flow) + var(--space-2-5));
}

/* Nhảy tới mục không bị thanh trên dính (mobile 56px) che mất */
.tg-prose [id] {
  scroll-margin-top: calc(var(--tap-min) + var(--space-6));
}

.tg-prose h2 {
  color: var(--color-brand-strong);
  font-size: var(--text-20);
  line-height: 1.35;
}

.tg-prose h3 {
  color: var(--color-text);
  font-size: var(--text-17);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.tg-prose strong,
.tg-prose b {
  font-weight: var(--weight-bold);
}

/* Link trong chữ (không áp cho nút, thẻ sản phẩm có class riêng) */
.tg-prose a:not([class]) {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tg-prose a:not([class]):hover {
  color: var(--color-brand-strong);
}

/* Danh sách chấm */
.tg-prose ul {
  margin-bottom: 0;
  padding-left: var(--space-5);
}

.tg-prose ul > li + li {
  margin-top: var(--space-1-5);
}

.tg-prose ul > li::marker {
  color: var(--color-brand);
}

/* Danh sách đánh số = các bước: số trong vòng tròn xanh, dòng đầu in đậm là tên bước */
.tg-prose ol {
  margin-bottom: 0;
  padding: 0;
  list-style: none;
  counter-reset: tg-prose-step;
}

.tg-prose ol > li {
  position: relative;
  min-height: 26px;
  padding-left: calc(26px + var(--space-3));
  color: var(--color-text-secondary);
  counter-increment: tg-prose-step;
}

.tg-prose ol > li + li {
  margin-top: var(--space-3);
}

.tg-prose ol > li::before {
  content: counter(tg-prose-step);
  position: absolute;
  top: 0.15em;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-round);
  background: var(--color-brand);
  color: var(--color-text-on-dark);
  font-size: var(--text-meta);
  font-weight: var(--weight-bold);
  line-height: 1;
}

/* Tên bước đứng thành dòng riêng */
.tg-prose ol > li > strong:first-child {
  display: block;
  color: var(--color-text);
}

.tg-prose blockquote {
  padding-left: var(--space-3);
  border-left: 3px solid var(--color-brand);
  color: var(--color-text-secondary);
  font-weight: var(--weight-medium);
}

.tg-prose blockquote cite {
  display: block;
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-meta);
  font-style: normal;
}

.tg-prose figure,
.tg-prose .wp-block-image {
  margin: 0;
}

.tg-prose figure img,
.tg-prose > img {
  width: 100%;
  border-radius: var(--radius-lg);
  background: var(--color-image-bg);
}

.tg-prose figcaption {
  margin-top: var(--space-1-5);
  color: var(--color-text-muted);
  font-size: var(--text-meta);
  line-height: var(--leading-normal);
}

/* Bộ ảnh (khối Gallery của WordPress): 2 cột */
.tg-prose .wp-block-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.tg-prose .wp-block-gallery img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* Bảng: khối Table của WordPress bọc trong figure.wp-block-table, viết tay thì bọc div.tg-prose__table.
   Khung bọc cuộn ngang khi màn hẹp. */
.tg-prose .wp-block-table,
.tg-prose__table {
  margin: 0;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}

.tg-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-14);
  line-height: var(--leading-normal);
}

.tg-prose th,
.tg-prose td {
  padding: var(--space-2) var(--space-2-5);
  text-align: left;
  vertical-align: top;
}

.tg-prose thead th {
  background: var(--color-brand-hover-bg);
  color: var(--color-brand-strong);
  font-weight: var(--weight-bold);
}

.tg-prose tbody tr {
  border-top: 1px solid var(--color-divider);
}

.tg-prose > table {
  display: block;
  overflow-x: auto;
}

.tg-prose hr {
  height: 1px;
  border: 0;
  background: var(--color-divider);
}

/* Khung "Lưu ý" màu vàng */
.tg-prose__note {
  display: flex;
  gap: var(--space-2-5);
  padding: var(--space-3) var(--space-3-5);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-xl);
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  font-size: var(--text-15);
  line-height: var(--leading-relaxed);
  --icon-size: 18px;
}

.tg-prose__note .tg-icon {
  margin-top: 3px;
  color: var(--color-warning-icon);
}

@media (min-width: 1024px) {
  .tg-prose {
    --prose-flow: var(--space-4);
    font-size: var(--text-17);
    line-height: var(--leading-prose);
  }

  .tg-prose [id] {
    scroll-margin-top: var(--space-4);
  }

  .tg-prose h2 {
    font-size: var(--text-24);
  }

  .tg-prose h3 {
    font-size: var(--text-20);
  }

  .tg-prose ul {
    padding-left: var(--space-6);
  }

  .tg-prose ul > li + li {
    margin-top: var(--space-2);
  }

  .tg-prose ol > li {
    min-height: 30px;
    padding-left: calc(30px + var(--space-3-5));
  }

  .tg-prose ol > li + li {
    margin-top: var(--space-3-5);
  }

  .tg-prose ol > li::before {
    width: 30px;
    height: 30px;
    font-size: var(--text-14);
  }

  .tg-prose blockquote {
    padding-left: var(--space-4);
    border-left-width: 4px;
  }

  .tg-prose .wp-block-gallery {
    gap: var(--space-3);
  }

  .tg-prose figure img,
  .tg-prose > img {
    border-radius: var(--radius-xl);
  }

  .tg-prose__note {
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-16);
    line-height: 1.65;
  }
}

/* ---------- .tg-prose--compact: chính sách, điều khoản ----------
   Viết bằng hai class (.tg-prose.tg-prose--compact) để luôn thắng kiểu mặc định ở trên,
   kể cả các quy tắc desktop của kiểu mặc định. */
.tg-prose.tg-prose--compact {
  --prose-flow: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--text-14);
  line-height: var(--leading-prose);
}

.tg-prose.tg-prose--compact > * + h2,
.tg-prose.tg-prose--compact > section + section {
  margin-top: var(--space-1);
}

.tg-prose.tg-prose--compact > * + h3 {
  margin-top: var(--prose-flow);
}

/* Nhảy tới mục không bị thanh dính phía trên che mất */
.tg-prose.tg-prose--compact [id] {
  scroll-margin-top: calc(var(--header-height) + var(--space-2));
}

/* Mỗi mục mở đầu bằng gạch phân cách */
.tg-prose.tg-prose--compact h2 {
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-18);
}

.tg-prose.tg-prose--compact h3 {
  font-size: var(--text-16);
}

.tg-prose.tg-prose--compact strong,
.tg-prose.tg-prose--compact b {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

/* Danh sách chấm: chấm tròn xanh vẽ bằng ::before, chữ bên trong có thể chứa strong, a */
.tg-prose.tg-prose--compact ul,
.tg-prose.tg-prose--compact ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tg-prose.tg-prose--compact li {
  position: relative;
  line-height: var(--leading-list);
}

.tg-prose.tg-prose--compact li + li {
  margin-top: var(--space-2-5);
}

.tg-prose.tg-prose--compact ul > li {
  padding-left: calc(7px + var(--space-3));
}

.tg-prose.tg-prose--compact ul > li::before {
  content: "";
  position: absolute;
  top: 0.65em;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-round);
  background: var(--color-brand);
}

/* Danh sách đánh số (các bước): số trong vòng tròn xanh nhạt */
.tg-prose.tg-prose--compact ol > li {
  min-height: 26px;
  padding-left: calc(26px + var(--space-3));
  padding-top: var(--space-0-5);
  line-height: var(--leading-relaxed);
}

.tg-prose.tg-prose--compact ol > li + li {
  margin-top: var(--space-3);
}

.tg-prose.tg-prose--compact ol > li::before {
  top: 0;
  background: var(--color-brand-soft);
  color: var(--color-brand-strong);
}

.tg-prose.tg-prose--compact table {
  font-size: var(--text-meta);
}

.tg-prose.tg-prose--compact tbody td {
  color: var(--color-text-secondary);
}

/* Cột đầu là tên trường hợp: in đậm, màu chữ chính */
.tg-prose.tg-prose--compact tbody td:first-child,
.tg-prose.tg-prose--compact tbody th {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.tg-prose.tg-prose--compact .tg-prose__note {
  gap: var(--space-3);
  border: 0;
  font-size: var(--text-meta);
  line-height: var(--leading-list);
}

.tg-prose.tg-prose--compact .tg-prose__note .tg-icon {
  margin-top: var(--space-0-5);
}

.tg-prose.tg-prose--compact .tg-prose__note strong {
  color: inherit;
  font-weight: var(--weight-bold);
}

@media (min-width: 1024px) {
  .tg-prose.tg-prose--compact {
    --prose-flow: var(--space-3-5);
    font-size: var(--text-16);
  }

  .tg-prose.tg-prose--compact [id] {
    scroll-margin-top: var(--space-4);
  }

  .tg-prose.tg-prose--compact h2 {
    padding-top: var(--space-7);
    font-size: var(--text-22);
  }

  .tg-prose.tg-prose--compact h3 {
    font-size: var(--text-18);
  }

  .tg-prose.tg-prose--compact ul > li::before {
    top: 0.62em;
  }

  .tg-prose.tg-prose--compact ol > li {
    min-height: 28px;
    padding-left: calc(28px + var(--space-3));
  }

  .tg-prose.tg-prose--compact ol > li::before {
    width: 28px;
    height: 28px;
  }

  .tg-prose.tg-prose--compact table {
    font-size: var(--text-15);
  }

  .tg-prose.tg-prose--compact th,
  .tg-prose.tg-prose--compact td {
    padding: var(--space-3) var(--space-4);
  }

  .tg-prose.tg-prose--compact .tg-prose__note {
    padding: var(--space-3-5) var(--space-4);
    font-size: var(--text-15);
  }
}

/* =========================================================
   Đánh giá (.tg-review): trang sản phẩm, trang đánh giá; dùng lại ở đơn hàng, viết đánh giá.
   Mobile: avatar + tên một dòng, nội dung bên dưới (dùng order). Desktop: lưới avatar | tên, ngày | nội dung.
   - .tg-review--compact: bản rút gọn trong danh sách ngắn (trang sản phẩm mobile).
   - .tg-review__helpful: nút Hữu ích (aria-pressed="true" khi đã bấm, JS: assets/js/reviews.js).
   - .tg-review__reply: trả lời của kỹ sư; .tg-review__reply--fold là <details> gập một dòng.
   ========================================================= */
.tg-review {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  font-size: var(--text-meta);
}

.tg-review > * {
  flex: 1 1 100%;
  order: 2;
  min-width: 0;
}

.tg-review__avatar {
  display: flex;
  flex: none;
  order: 1;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-round);
  background: var(--color-brand-soft);
  color: var(--color-brand-strong);
  font-size: var(--text-12);
  font-weight: var(--weight-semibold);
}

.tg-review__name {
  flex: 1 1 0;
  order: 1;
  overflow: hidden;
  font-size: var(--text-meta);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tg-review__stars {
  font-size: var(--text-meta);
}

.tg-review__meta,
.tg-review__date {
  color: var(--color-text-muted);
  font-size: var(--text-meta);
}

.tg-review__date {
  order: 3;
}

.tg-review__text {
  line-height: var(--leading-normal);
}

.tg-review__photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1-5);
  margin-top: var(--space-1);
}

.tg-review__photos figure {
  position: relative;
  aspect-ratio: 1 / 1;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-image-bg);
}

.tg-review__photos img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tg-review__photos figcaption {
  position: absolute;
  left: var(--space-1);
  bottom: var(--space-1);
  padding: 1px var(--space-1-5);
  border-radius: var(--radius-sm);
  background: var(--color-photo-label);
  color: var(--color-text-on-dark);
  font-size: var(--text-label);
  font-weight: var(--weight-bold);
}

.tg-review__photos--thumb {
  display: flex;
}

.tg-review__photos--thumb figure {
  flex: none;
  width: 72px;
  height: 64px;
  aspect-ratio: auto;
  border-radius: var(--radius-md);
}

.tg-review__reply {
  order: 4;
  padding: var(--space-2) var(--space-2-5);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  font-size: var(--text-meta);
  line-height: var(--leading-normal);
}

/* Trả lời của kỹ sư ở đánh giá tốt: gập lại một dòng, chạm để mở */
.tg-review__reply--fold {
  padding: 0;
}

.tg-review__reply--fold summary {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  min-height: var(--tap-min);
  padding: var(--space-1) var(--space-2-5);
  list-style: none;
  cursor: pointer;
  --icon-size: 14px;
}

.tg-review__reply--fold summary::-webkit-details-marker {
  display: none;
}

.tg-review__reply--fold summary .tg-icon {
  color: var(--color-text-muted);
  transition: transform var(--duration-fast);
}

.tg-review__reply--fold[open] summary .tg-icon {
  transform: rotate(180deg);
}

.tg-review__reply--fold:not([open]) .tg-review__reply-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tg-review__reply-text {
  flex: 1;
  min-width: 0;
}

.tg-review__actions {
  display: flex;
  flex: none;
  order: 1;
  align-items: center;
  gap: var(--space-0-5);
}

.tg-review__helpful {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-min);
  padding: 0 var(--space-1);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text-muted);
  font-size: var(--text-meta);
  --icon-size: 14px;
}

.tg-review__helpful:hover {
  color: var(--color-brand);
}

.tg-review__helpful[aria-pressed="true"] {
  color: var(--color-brand);
  font-weight: var(--weight-semibold);
}

.tg-review__more {
  position: relative;
}

.tg-review__more summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  list-style: none;
  cursor: pointer;
  --icon-size: 18px;
}

.tg-review__more summary::-webkit-details-marker {
  display: none;
}

.tg-review__more-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 2;
  padding: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
}

.tg-review__more-menu a {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-3);
  color: var(--color-text);
  font-size: var(--text-meta);
  white-space: nowrap;
}

.tg-review__more-menu a:hover {
  background: var(--color-brand-hover-bg);
}

/* Đánh giá rút gọn ở trang sản phẩm mobile */
.tg-review--compact {
  padding-block: var(--space-2-5);
  border-bottom: 1px solid var(--color-border);
}

.tg-review--compact:first-child {
  padding-top: 0;
}

.tg-review--compact:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.tg-review--compact .tg-review__name {
  flex-basis: 100%;
  font-weight: var(--weight-bold);
}

@media (min-width: 1024px) {
  .tg-review {
    display: grid;
    grid-template-columns: 40px auto minmax(0, 1fr);
    align-items: start;
    gap: var(--space-1-5) var(--space-3);
    padding: calc(var(--space-4) + var(--space-0-5)) 0;
    border-top: 1px solid var(--color-divider);
    background: none;
    font-size: var(--text-14);
  }

  .tg-review > * {
    order: 0;
    grid-column: 2 / -1;
  }

  .tg-review__avatar {
    grid-row: 1 / span 2;
    grid-column: 1;
    width: 40px;
    height: 40px;
    font-size: var(--text-13);
  }

  .tg-review__name {
    font-weight: var(--weight-regular);
  }

  .tg-review__stars {
    font-size: var(--text-14);
  }

  .tg-review__date {
    grid-column: 2;
  }

  .tg-review__meta {
    grid-column: 3;
  }

  .tg-review__date,
  .tg-review__meta {
    font-size: var(--text-meta);
  }

  .tg-review__meta::before {
    content: "· ";
  }

  .tg-review__text {
    line-height: var(--leading-relaxed);
  }

  .tg-review__photos {
    display: flex;
    gap: var(--space-2);
  }

  .tg-review__photos figure,
  .tg-review__photos--thumb figure {
    flex: none;
    width: 72px;
    height: 72px;
    aspect-ratio: auto;
    border-radius: var(--radius-sm);
  }

  .tg-review__reply {
    padding: var(--space-2-5) var(--space-3-5);
    border-radius: var(--radius-md);
    font-size: var(--text-meta);
    line-height: var(--leading-relaxed);
  }

  .tg-review__reply--fold {
    padding: 0;
  }

  .tg-review__reply--fold summary {
    min-height: 0;
    padding: var(--space-2-5) var(--space-3-5);
  }

  .tg-review__actions {
    justify-content: flex-start;
  }

  .tg-review__helpful {
    min-height: 32px;
    padding: 0;
    font-size: var(--text-meta);
  }

  .tg-review__more summary {
    width: 36px;
    height: 32px;
  }
}

/* =========================================================
   Thanh sao theo mức (5 sao … 1 sao): nhãn | thanh | số lượng. Độ dài thanh đặt bằng --bar trên __fill.
   ========================================================= */
.tg-rating-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
  padding: 0;
  min-width: 0;
  list-style: none;
}

.tg-rating-bars li {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  color: var(--color-text-muted);
  font-size: var(--text-meta);
}

.tg-rating-bars__label {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 1px;
  width: 22px;
  --icon-size: 1em;
}

.tg-rating-bars__label .tg-icon {
  color: var(--color-star);
}

.tg-rating-bars__track {
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--color-border);
}

.tg-rating-bars__fill {
  display: block;
  width: var(--bar, 0%);
  height: 100%;
  background: var(--color-star);
}

.tg-rating-bars__count {
  flex: none;
  width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   Dải Flash Sale có đếm ngược (đặt ngay trên giá). JS gắn .is-ended khi hết giờ.
   Wireframe chuyển từ đỏ sang cam #F0592A; phần cam không đủ tương phản với chữ trắng 12px
   nên chuyển từ đỏ chính sang đỏ đậm (cùng cách xử lý vé voucher trong tokens.css).
   ========================================================= */
.tg-flash-sale {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(90deg, var(--color-red), var(--color-red-strong));
  color: var(--color-text-on-dark);
}

.tg-flash-sale__brand {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-15);
  font-style: italic;
  font-weight: var(--weight-bold);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  --icon-size: 16px;
}

.tg-flash-sale__timer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  font-size: var(--text-meta);
}

.tg-flash-sale__digits {
  display: flex;
  align-items: center;
  gap: var(--space-0-5);
  font-weight: var(--weight-bold);
}

.tg-flash-sale__sec {
  display: contents;
}

.tg-flash-sale__unit {
  min-width: 2ch;
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--color-text);
  font-size: var(--text-meta);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.tg-flash-sale.is-ended .tg-flash-sale__digits {
  display: none;
}

@media (min-width: 1024px) {
  .tg-flash-sale {
    gap: var(--space-2-5);
    padding: var(--space-2-5) var(--space-5);
  }

  .tg-flash-sale__brand {
    gap: var(--space-1-5);
    font-size: var(--text-20);
    letter-spacing: 0.5px;
    --icon-size: 20px;
  }

  .tg-flash-sale__label {
    font-size: var(--text-meta);
    letter-spacing: 0.3px;
    text-transform: uppercase;
  }

  .tg-flash-sale__digits {
    gap: 3px;
  }

  .tg-flash-sale__unit {
    padding: var(--space-0-5) var(--space-1-5);
    font-size: var(--text-14);
  }
}

/* =========================================================
   Nhãn ưu đãi nhỏ có khuyết hai đầu ("Giảm 30k đơn đầu", "Freeship từ 400k")
   ========================================================= */
.tg-voucher-tag {
  --voucher-tag-bg: var(--color-red-soft);
  padding: 3px var(--space-3);
  border-radius: 3px;
  background:
    radial-gradient(circle at 0 50%, transparent 4px, var(--voucher-tag-bg) 4.5px) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 50%, transparent 4px, var(--voucher-tag-bg) 4.5px) right / 51% 100% no-repeat;
  color: var(--color-red-strong);              /* đỏ chính trên nền hồng chỉ đạt 4,49:1 */
  font-size: var(--text-13);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.tg-voucher-tag--freeship {
  --voucher-tag-bg: color-mix(in srgb, var(--color-freeship) 14%, var(--color-surface));
  color: var(--color-freeship-strong);
}

/* Đến kỳ dùng lại (B10): trang chủ, Tài khoản, Đơn đã mua */
.tg-refill {
  background: var(--color-surface);
  border-radius: 10px;
  padding: 12px 16px;
}
.tg-refill__list {
  display: grid;
  gap: 12px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.tg-refill__item {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 4px 12px;
  align-items: center;
}
.tg-refill__img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}
.tg-refill__name {
  font-weight: 500;
  color: var(--color-text);
}
.tg-refill__actions {
  grid-column: 2;
  display: flex;
  gap: 8px;
}
@media (min-width: 1024px) {
  .tg-refill__item {
    grid-template-columns: 48px 1fr auto;
  }
  .tg-refill__actions {
    grid-column: auto;
  }
}
