:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sarabun", "Noto Sans Thai", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 20px; font-weight: 800; background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; }
.search-box { margin-left: auto; display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 14px; box-shadow: var(--shadow); }
.search-box input { border: none; outline: none; font-size: 14px; width: min(46vw, 280px); background: transparent; }
.search-box button { border: none; cursor: pointer; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; width: 34px; height: 34px; border-radius: 999px; font-size: 14px; }

.container { max-width: 1080px; margin: 0 auto; padding: 22px 16px 60px; }

.loading, .empty { text-align: center; color: var(--muted); padding: 60px 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.post-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; cursor: pointer; }
.post-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(16,24,40,.12); }
.post-card .cover { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #eef0f5; display: block; }
.post-card .cover.placeholder { display: flex; align-items: center; justify-content: center; color: #9aa1ad; font-size: 13px; }
.post-card .body { padding: 12px 14px 14px; }
.post-card .badge-new { display: inline-block; font-size: 11px; font-weight: 700; color: var(--brand); background: #eef2ff; padding: 2px 8px; border-radius: 999px; margin-bottom: 6px; }
.post-card .title { font-size: 15px; font-weight: 700; margin: 0 0 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .sub { font-size: 12px; color: var(--muted); }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 26px; color: var(--muted); font-size: 14px; }
.pager button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* detail */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.detail { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.detail .hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; }
.detail .gallery { background: #0b1020; }
.detail .gallery .main-img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: #0b1020; display: block; }
.detail .thumbs { display: flex; gap: 8px; padding: 10px; flex-wrap: wrap; background: #0b1020; }
.detail .thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; opacity: .7; }
.detail .thumbs img.active { border-color: #818cf8; opacity: 1; }
.detail .info { padding: 24px 26px; }
.detail .badge-new { display: inline-block; font-size: 12px; font-weight: 700; color: var(--brand); background: #eef2ff; padding: 3px 10px; border-radius: 999px; margin-bottom: 10px; }
.detail h1 { font-size: 24px; margin: 0 0 6px; }
.detail .code { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.detail .desc { white-space: pre-wrap; word-break: break-word; color: #374151; margin: 8px 0 0; }

.variants { margin-top: 22px; }
.variants h3 { font-size: 15px; margin: 0 0 10px; }
.variant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.variant { border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; background: #fafafe; }
.variant img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 6px; background: #eef0f5; margin-bottom: 6px; }
.variant .v-size { font-weight: 700; font-size: 13px; }
.variant .v-name { font-size: 11px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.caption-box { margin: 22px 26px; border: 1px dashed #c7cdd6; border-radius: 12px; padding: 14px 16px; background: #fbfbfe; }
.caption-box .ct-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.caption-box .ct-head b { font-size: 13px; }
.caption-box .copy-btn { border: none; cursor: pointer; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-radius: 8px; padding: 6px 12px; font-size: 12px; }
.caption-box pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 13px; color: #374151; margin: 0; }

.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  .detail .hero { grid-template-columns: 1fr; }
  .brand { font-size: 17px; }
}
