:root {
  /* Biến cục bộ của trang trỏ về token MONO của brand */
  --accent: var(--brand-ink);
  --bg: var(--brand-bg);
  --surface: var(--brand-surface);
  --ink: var(--brand-ink);
  --ink-2: var(--brand-ink-2);
  --muted: var(--brand-muted);
  --line: rgba(40, 40, 47, 0.14);
  --line-2: rgba(40, 40, 47, 0.24);
  --shadow-sm: var(--brand-shadow-sm);
  --shadow-md: var(--brand-shadow-md);
  --shadow-lg: var(--brand-shadow-lg);
  --serif: var(--brand-font-display);
  --mono: ui-monospace, monospace;
  --sans: var(--brand-font);
}
/* box-sizing: border-box global đã được khai báo ở src/web/brand-ratio/views/layout.ejs (single source of truth)
   — không khai báo lặp ở đây để tránh override scope không cần thiết. */
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===== TOP NAV ===== */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250,247,242,0.92);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1440px; margin: 0 auto;
  height: 64px; padding: 0 24px;
  display: flex; align-items: center; gap: 32px;
}
.brand {
  font-family: var(--serif);
  font-size: 24px; font-weight: 500;
  letter-spacing: -0.02em;
}
.brand sup { font-size: 11px; vertical-align: super; color: var(--accent); margin-left: 2px; font-family: var(--mono); }
.nav-links { display: flex; gap: 28px; flex: 1; }
.nav-links a {
  font-size: 14px; color: var(--ink-2);
  padding: 8px 2px; position: relative;
  transition: color .15s;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--ink); font-weight: 500; }
.nav-links a.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -22px;
  height: 2px; background: var(--ink);
}
.nav-actions { display: flex; align-items: center; gap: 12px; }
.nav-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  color: var(--ink-2); transition: all .15s;
}
.nav-icon:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }

/* ===== BREADCRUMB + HEADER ===== */
.page-head {
  max-width: 1496px; margin: 0 auto;
  padding: 32px 24px 28px;
}
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  margin-bottom: 16px;
  font-family: var(--mono);
}
.breadcrumb a { color: var(--muted); transition: color .15s; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { opacity: 0.4; }
.breadcrumb .current { color: var(--ink); }

.page-head-row {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 32px;
}
/* Title block grow lấp space-between gap (tránh content "co cụm" 2 mép trên container 1440px).
   Subagent root-cause: child div đầu không có flex-grow → co bằng content ~720px → empty gap ~360px. */
.page-head-row > div:first-child { flex: 1; min-width: 0; }
.page-title {
  font-family: var(--serif);
  font-size: clamp(40px, 5vw, 64px);
  line-height: 1.0;
  letter-spacing: -0.03em;
  font-weight: 400;
  margin: 0 0 12px;
}
.page-title .italic { font-style: normal; font-weight: 250; } /* mảnh thay nghiêng — đồng hệ đậm/mảnh */
.page-sub {
  font-size: 16px; color: var(--ink-2);
  max-width: 560px; line-height: 1.5;
  margin: 0;
}

.head-stats {
  display: flex; gap: 32px;
  padding: 16px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  flex-shrink: 0;
}
.stat-item { display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-family: var(--serif); font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.stat-label { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* ===== LAYOUT ===== */
.layout {
  max-width: 1496px;
  margin: 0 auto;
  padding: 0 24px 64px;
  position: relative;
}

/* ===== FLOATING SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 288px;
  left: max(8px, calc((100vw - 1496px) / 2 + 24px));
  width: 56px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  z-index: 40;
  transition: width .25s cubic-bezier(.2,.8,.2,1), box-shadow .2s;
  user-select: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 152px);
}
.sidebar.expanded { width: 296px; box-shadow: var(--shadow-lg); }
.sidebar.dragging { transition: none; box-shadow: var(--shadow-lg); cursor: grabbing; }

/* Grab handle — top, narrow, blocks expand */
.sb-grab {
  height: 44px;
  padding: 14px 0;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  background: linear-gradient(to bottom, rgba(232,227,217,0.6), transparent);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.sb-grab:active { cursor: grabbing; }
.sb-grab-dots {
  display: flex; gap: 3px;
}
.sb-grab-dots span {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--line-2);
}
.sidebar.dragging .sb-grab-dots span { background: var(--accent); }

.sb-body {
  flex: 1; overflow-y: auto;
  padding: 8px 0;
}
.sb-body::-webkit-scrollbar { width: 0; }

.sb-section {
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
}
.sb-section:last-child { border-bottom: none; }

.sb-section-head {
  display: flex; align-items: center;
  height: 44px;
  padding: 0 16px;
  gap: 14px;
  position: relative;
}
.sb-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2);
  flex-shrink: 0;
}
.sb-section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s;
  flex: 1;
}
.sidebar.expanded .sb-section-title { opacity: 1; transition-delay: .1s; }

.sb-active-dot {
  position: absolute;
  left: 32px; top: 12px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  opacity: 0;
  transition: opacity .15s;
}
.sb-section.has-active .sb-active-dot { opacity: 1; }
.sidebar.expanded .sb-active-dot { opacity: 0; }

.sb-options {
  display: none;
  padding: 0 16px 12px;
  flex-direction: column; gap: 6px;
}
.sidebar.expanded .sb-options { display: flex; }

.sb-check {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.sb-check:hover { background: var(--bg); color: var(--ink); }
.sb-check input { display: none; }
.sb-box {
  width: 16px; height: 16px;
  border: 1.5px solid var(--line-2);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
  background: var(--surface);
}
.sb-check input:checked + .sb-box {
  background: var(--ink); border-color: var(--ink);
}
.sb-check input:checked + .sb-box::after {
  content: ''; width: 8px; height: 5px;
  border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}
.sb-check-label { flex: 1; }
.sb-check-count {
  font-size: 11px; color: var(--muted);
  font-family: var(--mono);
}

/* Price slider */
.sb-price {
  padding: 8px 4px 4px;
  display: flex; flex-direction: column; gap: 12px;
}
.sb-price-row { display: flex; gap: 8px; }
.sb-price-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font: inherit; font-size: 13px;
  background: var(--surface);
  color: var(--ink);
}
.sb-price-input:focus { outline: none; border-color: var(--ink); }

.sb-foot {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: none;
  gap: 8px;
}
.sidebar.expanded .sb-foot { display: flex; }
/* Nút chân bảng lọc: Xoá tất cả (viền, .btn-sweep-out) · Áp dụng (đen, .btn-sweep) — hover ở components.css */
.sb-clear, .sb-apply {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
}
.sb-clear .btn-sweep-label, .sb-apply .btn-sweep-label { padding: 0 12px; }

/* Active filter count badge on collapsed sidebar */
.sb-count-badge {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  display: none;
}
.sb-section.has-active .sb-count-badge { display: flex; }
.sidebar.expanded .sb-count-badge { display: none; }

/* ===== MAIN CONTENT ===== */
.main {
  margin-left: 104px; /* sidebar width 56 + 32 left + 16 gap */
  transition: margin-left .25s cubic-bezier(.2,.8,.2,1);
}
.main.sb-floating { margin-left: 0; padding-left: 0; }

/* Active filter chips bar */
.active-filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
  min-height: 32px;
}
.active-filters:empty { display: none; }
.af-label {
  font-size: 12px; color: var(--muted);
  font-family: var(--mono); letter-spacing: 0.04em;
  text-transform: uppercase;
}
.af-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  padding: 5px 8px 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink);
}
.af-chip button {
  width: 18px; height: 18px;
  border: none; background: transparent;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 14px;
  padding: 0;
  transition: all .12s;
}
.af-chip button:hover { background: var(--ink); color: #fff; }
.af-clear-all {
  background: transparent; border: none;
  font-size: 13px; color: var(--accent);
  text-decoration: underline; padding: 4px 6px;
}

/* Sortbar */
.sortbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.sb-count {
  font-size: 14px; color: var(--muted);
}
.sb-count strong {
  font-family: var(--serif); font-size: 22px; font-weight: 500;
  color: var(--ink); margin-right: 4px;
  letter-spacing: -0.01em;
}
.sb-count em {
  font-style: normal; color: var(--ink); font-weight: 500;
}
.sortbar-right { display: flex; align-items: center; gap: 16px; }

.sort-select {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  font-size: 14px; font-weight: 500;
  color: var(--ink);
  position: relative;
}
.sort-select label { color: var(--muted); font-weight: 400; }
.sort-select select {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: none;
  font: inherit; color: inherit;
  padding: 0 16px 0 0;
  cursor: pointer;
}
.sort-select::after {
  content: ''; position: absolute; right: 14px;
  width: 8px; height: 8px;
  border-right: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  transform: rotate(45deg) translateY(-2px);
  pointer-events: none;
}

/* ===== GRID ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px 24px;
}
.card {
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: transform .25s;
}
.card:hover { transform: translateY(-3px); }
.card-media {
  position: relative;
  aspect-ratio: 4/5; /* khung dọc — ảnh 'card' (1280×1600) khớp khung không cắt */
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
}
.card-media svg { width: 100%; height: 100%; display: block; }
/* Ảnh thumbnail thật (CDN) fill khung card 4:3 — dùng rendition 'card' đúng tỉ lệ nên cover không cắt nội dung */
.card-media .thumb-pic, .card-media .thumb-pic img { width: 100%; height: 100%; display: block; object-fit: cover; }

.card-badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--surface);
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid var(--line);
}
.card-badge.bestseller { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.card-badge.popular { background: var(--accent); color: #fff; border-color: var(--accent); }
.card-badge.premium { background: #1c1917; color: #c8b393; border-color: #1c1917; }
.card-badge.new { background: var(--surface); color: var(--accent); border-color: var(--accent); }

.card-foot { padding: 12px 4px 0; }
.card-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
/* sub row: swatch đổi màu (trái) + đánh giá (phải) cùng 1 dòng */
.card-row.sub { margin-top: 8px; align-items: center; }
.card-name { margin: 0; font-family: var(--serif); font-size: 18px; font-weight: 500; letter-spacing: -0.005em; }
.card-price { font-size: 14px; font-weight: 500; white-space: nowrap; }
/* studio "by X" inline ngay sau tên theme (cùng dòng, không tách dòng riêng) */
.card-studio { font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 5px; white-space: nowrap; }
.card-rating { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 500; color: var(--accent); }
.card-rating .rev { color: var(--muted); font-weight: 400; }
/* swatch đổi màu — inline cùng dòng với đánh giá (trái), dưới khung ảnh */
.card-swatches { display: flex; gap: 5px; align-items: center; }
.sw { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--line); }

/* Empty */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-mark { font-family: var(--serif); font-size: 64px; color: var(--muted); }
.empty h3 { font-family: var(--serif); font-size: 24px; font-weight: 500; margin: 0; }
.empty p { color: var(--muted); margin: 0 0 8px; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; justify-content: center; align-items: center; gap: 6px;
  margin-top: 56px;
}
.pg-btn {
  min-width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  font-size: 14px; font-weight: 500;
  color: var(--ink);
  padding: 0 10px;
  font-family: var(--mono);
}
.pg-btn:hover:not(:disabled) { background: var(--surface); border-color: var(--line-2); }
.pg-btn.current { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pg-btn:disabled { color: var(--muted); cursor: not-allowed; opacity: 0.4; }
.pg-ellipsis { color: var(--muted); padding: 0 4px; font-family: var(--mono); }
.pg-arrow { font-size: 18px; }

/* ---- Layout override (page-sub rộng 720 thay vì 560 mặc định) ---- */
.brand-main .page-sub { max-width: 720px; }

/* ---- Thông báo dùng thử (sau đăng ký/đăng nhập từ nút "Dùng thử miễn phí"): toast cố định đáy màn, không chen
   vào luồng trang (sidebar lọc neo theo đỉnh danh sách) ---- */
.trial-note {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 60;
  width: min(560px, calc(100vw - 32px)); transform: translateX(-50%);
  padding: 14px 14px 14px 18px; display: flex; align-items: center; gap: 14px;
  background: var(--brand-surface); border: 1px solid var(--line-2); border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.brand-main .trial-note[hidden] { display: none; }
.trial-note-ico {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-mint); color: var(--ink);
}
.trial-note-ico svg { width: 17px; height: 17px; display: block; }
.trial-note-text { flex: 1; margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.trial-note-text strong { color: var(--ink); font-weight: 700; }
.trial-note-close {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; border: none; background: transparent; color: var(--ink); cursor: pointer;
}
.trial-note-close:hover { background: var(--brand-strip-2); }
.trial-note-close svg { width: 17px; height: 17px; display: block; }
@media (prefers-reduced-motion: no-preference) {
  .trial-note { transition: transform 320ms var(--brand-ease), opacity 320ms var(--brand-ease); }
  @starting-style { .trial-note { opacity: 0; transform: translate(-50%, 16px); } }
}

/* ---- Mobile / tablet ---- */
.sb-sheet-open { display: none; }
html.sb-sheet-lock { overflow: hidden; }
@media (max-width: 980px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
/* ≤720px: đầu trang xếp dọc, lưới 2 cột sát lề; panel lọc thành bảng trượt từ đáy mở bằng nút "Bộ lọc" */
@media (max-width: 720px) {
  .page-head { padding: 20px 16px 18px; }
  .breadcrumb { flex-wrap: wrap; row-gap: 4px; font-size: 12px; }
  .page-head-row { flex-direction: column; align-items: stretch; gap: 18px; }
  .page-sub { font-size: 15px; }
  .head-stats { justify-content: space-between; gap: 16px; padding: 12px 18px; }
  .layout { padding: 0 16px 56px; }
  .main { margin-left: 0; }
  .sortbar { flex-wrap: wrap; gap: 12px; }
  .sb-count { width: 100%; font-size: 13px; }
  .sb-count strong { font-size: 18px; }
  .sortbar-right { width: 100%; justify-content: space-between; gap: 8px; }
  .sort-select { padding: 8px 12px; font-size: 13px; }
  .sort-select label { display: none; }
  .sb-sheet-open {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    padding: 8px 14px; border-radius: 999px; border: none; cursor: pointer;
    background: var(--ink); color: #fff; font: 600 13px var(--sans);
  }
  .sb-sheet-open svg { width: 16px; height: 16px; display: block; }
  .sb-sheet-count {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--brand-mint); color: var(--ink); font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
  }
  .brand-main .sb-sheet-count[hidden] { display: none; }
  .grid { gap: 22px 12px; }
  .card-name { font-size: 15px; }
  .card-studio { display: block; margin-left: 0; margin-top: 2px; }
  .card-row { flex-wrap: wrap; }

  .sidebar {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 82dvh; z-index: 70;
    border-radius: 18px 18px 0 0; border-bottom: none;
    transform: translateY(105%); transition: transform 300ms var(--brand-ease);
  }
  .sidebar.is-sheet-open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar .sb-grab { display: none; }
  .sidebar .sb-section-title { opacity: 1; }
  .sidebar .sb-options { display: flex; }
  .sidebar .sb-active-dot { display: none; }
  .sidebar .sb-foot { display: flex; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .sb-backdrop { position: fixed; inset: 0; z-index: 69; background: rgba(22, 22, 27, 0.45); }
}
@media (max-width: 720px) and (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
