:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1b2024;
  --muted: #6b7178;
  --line: #e4e0d7;
  --accent: #23853f;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(20 24 28 / 6%), 0 6px 18px rgb(20 24 28 / 6%);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ---- header ---- */
.top { max-width: 1320px; margin: 0 auto; padding: 28px 20px 8px; text-align: center; }
.brand img { height: 26px; width: auto; margin: 0 auto 18px; }
.top h1 { margin: 0; font-size: clamp(26px, 4.4vw, 40px); font-weight: 700; letter-spacing: -0.01em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; min-height: 21px; }

/* ---- product rail ---- */
.rail {
  max-width: 1320px; margin: 18px auto 0; padding: 4px 20px 10px;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px;
}
.prod {
  position: relative; display: flex; flex-direction: column; align-items: stretch;
  padding: 8px 8px 10px; border: 1.5px solid transparent; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); text-align: center;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.prod:hover { transform: translateY(-2px); }
.prod:focus-visible { outline: 3px solid color-mix(in srgb, var(--c) 45%, transparent); outline-offset: 2px; }
.prod.on { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 16%, transparent), var(--shadow); }
.tile {
  display: grid; place-items: center; aspect-ratio: 1 / 1; border-radius: 12px;
  background: var(--t); overflow: hidden;
}
.tile .pack { width: 84%; height: 84%; object-fit: contain; mix-blend-mode: multiply; filter: drop-shadow(0 6px 8px rgb(0 0 0 / 12%)); }
.prod[data-p="xircle"] .tile, .prod[data-p="routinex"] .tile { box-shadow: inset 0 0 0 1px var(--line); }
.prod[data-p="xircle"] .tile .pack, .prod[data-p="routinex"] .tile .pack { width: 100%; height: 100%; object-fit: cover; mix-blend-mode: normal; filter: none; }
.tile .mark { display: grid; gap: 10px; padding: 0 14%; }
.tile .mark img { width: 100%; height: auto; }
.label { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 40px; margin-top: 8px; line-height: 1.2; }
.label b { font-size: 14.5px; font-weight: 700; color: var(--c); }
.label small { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.label .wordmark { height: 15px; width: auto; max-width: 92%; }
.count {
  position: absolute; top: 12px; right: 12px; min-width: 26px; padding: 1px 7px; border-radius: 99px;
  background: rgb(255 255 255 / 92%); color: var(--c); font-size: 12px; font-weight: 600;
  box-shadow: 0 1px 3px rgb(0 0 0 / 10%);
}
.prod.on .count { background: var(--c); color: #fff; }

/* ---- filters ---- */
.bar {
  position: sticky; top: 0; z-index: 5; max-width: 1320px; margin: 6px auto 0; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--card); font-size: 14px;
}
.chip svg { width: 15px; height: 15px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.sorts { display: flex; gap: 6px; flex-shrink: 0; }
.sorts .chip.on { background: var(--accent); border-color: var(--accent); }

/* ---- grid ---- */
main { max-width: 1320px; margin: 0 auto; padding: 6px 20px 40px; }
.grid { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.loading, .empty { grid-column: 1 / -1; padding: 60px 0; text-align: center; color: var(--muted); }
.card {
  display: block; width: 100%; padding: 0; border: 0; border-radius: var(--radius); overflow: hidden;
  background: var(--card); box-shadow: var(--shadow); text-align: left;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgb(20 24 28 / 8%), 0 12px 28px rgb(20 24 28 / 10%); }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cover { position: relative; display: block; aspect-ratio: 9 / 16; background: #dcd8cf; }
.card.wide .cover { aspect-ratio: 16 / 9; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover.noimg img { display: none; }
.cover::after { content: ''; position: absolute; inset: auto 0 0; height: 30%; background: linear-gradient(transparent, rgb(0 0 0 / 28%)); pointer-events: none; }
.ch {
  position: absolute; top: 10px; left: 10px; z-index: 1; display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 9px; background: rgb(0 0 0 / 55%); color: #fff; backdrop-filter: blur(4px);
}
.ch svg { width: 16px; height: 16px; }
.ch.youtube { background: #e1251b; }
.ch.instagram { background: linear-gradient(45deg, #f9a03f, #d62976 55%, #7c3aed); }
.ch.facebook { background: #1877f2; }
.badges { position: absolute; top: 10px; right: 10px; z-index: 1; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.off, .pin { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; line-height: 1.6; }
.off { background: rgb(255 255 255 / 92%); color: var(--accent); }
.pin { background: #f2b705; color: #2b2100; box-shadow: 0 1px 4px rgb(0 0 0 / 18%); }
.playbtn {
  position: absolute; left: 50%; top: 50%; z-index: 1; display: grid; place-items: center; width: 52px; height: 52px;
  margin: -26px 0 0 -26px; border-radius: 50%; background: rgb(255 255 255 / 88%); color: var(--ink);
  opacity: 0; transform: scale(.9); transition: opacity .15s ease, transform .15s ease;
}
.playbtn svg { width: 24px; height: 24px; margin-left: 3px; }
.card:hover .playbtn, .card:focus-visible .playbtn { opacity: 1; transform: none; }
.body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; line-height: 1.6;
  color: var(--c); background: color-mix(in srgb, var(--c) 11%, white);
}
.body .cap { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; line-height: 1.45; }
.who { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.who .name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; color: #3d4349; }
.stats { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.stats svg { width: 12px; height: 12px; margin-right: -3px; }
.more {
  display: block; margin: 26px auto 0; padding: 10px 28px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--card); font-weight: 600;
}

.foot {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 20px 40px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; text-align: center;
}
.foot img { height: 18px; width: auto; opacity: .7; }

/* ---- player ---- */
.player {
  width: min(420px, 94vw); max-height: 94vh; padding: 0; border: 0; border-radius: 20px;
  background: var(--card); box-shadow: 0 30px 80px rgb(0 0 0 / 40%); overflow: auto;
}
.player.wide { width: min(880px, 94vw); }
.player::backdrop { background: rgb(12 14 16 / 72%); backdrop-filter: blur(3px); }
.player-box { position: relative; }
.close {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgb(0 0 0 / 55%); color: #fff; font-size: 22px; line-height: 1;
}
.stage { background: #000; }
.frame { position: relative; aspect-ratio: 9 / 16; max-height: 74vh; margin: 0 auto; background: #000; }
.player.wide .frame { aspect-ratio: 16 / 9; max-height: none; }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.meta { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 18px; }
.meta p { margin: 0; }
.meta .cap { font-size: 15px; }
.meta .who { font-size: 13px; }
.src { display: inline-flex; align-self: flex-start; align-items: center; gap: 6px; margin-top: 4px; padding: 7px 14px; border-radius: 99px; background: var(--ink); color: #fff; text-decoration: none; font-size: 13.5px; font-weight: 600; }
.src svg { width: 15px; height: 15px; }

/* ---- small screens ---- */
@media (max-width: 900px) {
  .rail { display: flex; overflow-x: auto; scroll-snap-type: x proximity; scroll-padding: 0 20px; scrollbar-width: none; padding-bottom: 12px; }
  .rail::-webkit-scrollbar { display: none; }
  .prod { flex: 0 0 108px; scroll-snap-align: start; }
  .label .wordmark { height: 12px; }
  .label b { font-size: 13px; }
}
@media (max-width: 560px) {
  .top { padding-top: 20px; }
  .rail, .bar, main { padding-left: 14px; padding-right: 14px; }
  .grid, .col { gap: 10px; }
  .body { padding: 8px 10px 10px; }
  .body .cap { font-size: 13px; }
  .rail { scroll-padding: 0 14px; }
  .chips { flex-wrap: nowrap; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { padding: 5px 11px; font-size: 13px; white-space: nowrap; }
  .bar { flex-wrap: wrap; row-gap: 8px; }
  .chips { flex-basis: 100%; }
  .sorts .chip { padding: 5px 11px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
