/* สีกลางๆ ชั่วคราว รอผู้ใช้เลือกโทนแบรนด์ */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b6f76;
  --line: #e3e1dc;
  --accent: #2f6f5e;
  --ph: #e9e7e2;
  --ph-line: #cfccc5;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b; --surface: #1f2226; --text: #eceae6; --muted: #a2a6ad;
    --line: #2e3237; --accent: #6fbfa8; --ph: #2a2e33; --ph-line: #41464d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "IBM Plex Sans Thai", system-ui, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* แถบบน */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.back { text-decoration: none; font-weight: 600; padding: 8px 4px; }

/* ตัวกรอง: มือถือ 2 คอลัมน์ คอม 4 คอลัมน์ */
.filters {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 16px 0 8px;
}
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filters select {
  font: inherit; font-size: 15px; color: var(--text);
  height: 44px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
}
@media (min-width: 720px) { .filters { grid-template-columns: repeat(4, 1fr); } }

.result-bar { display: flex; justify-content: space-between; align-items: center; min-height: 40px; color: var(--muted); font-size: 14px; }
.link-btn { font: inherit; font-size: 14px; background: none; border: 0; color: var(--accent); padding: 8px 0; cursor: pointer; }

/* การ์ด */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; padding-bottom: 32px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none;
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 6px 20px rgb(0 0 0 / .08); transform: translateY(-2px); }
.card-body { padding: 12px 14px 16px; }
.card-title { font-size: 17px; margin: 2px 0 4px; line-height: 1.4; }
.code { font-size: 13px; color: var(--muted); }
.spec { font-size: 14px; color: var(--muted); }
.price { margin-top: 8px; font-weight: 700; font-size: 17px; }
.price small, .price-box small { font-weight: 400; color: var(--muted); font-size: 13px; }
.badge {
  position: absolute; top: 10px; left: 10px; background: var(--surface); color: var(--text);
  font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px;
}

/* กรอบแทนรูป */
.ph {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 4 / 3; width: 100%; background: var(--ph);
  border: 0; padding: 0; overflow: hidden; font: inherit;
  background-image: linear-gradient(135deg, transparent 49.6%, var(--ph-line) 50%, transparent 50.4%),
                    linear-gradient(45deg, transparent 49.6%, var(--ph-line) 50%, transparent 50.4%);
}
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
button.ph { cursor: zoom-in; }
.ph-label {
  background: var(--ph); color: var(--muted); font-size: 13px;
  padding: 2px 10px; border-radius: 6px;
}
.ph-wide { aspect-ratio: 3 / 2; max-width: 520px; border-radius: var(--radius); }
.ph-video { aspect-ratio: 16 / 9; max-width: 720px; border-radius: var(--radius); }

/* หน้ารายละเอียด */
.detail { display: grid; gap: 16px; margin: 16px 0 8px; }
.detail-media .ph-hero { border-radius: var(--radius); }
@media (min-width: 900px) {
  .detail { grid-template-columns: 3fr 2fr; gap: 28px; align-items: start; }
}
.detail h1 { font-size: 24px; line-height: 1.35; margin: 2px 0 8px; }
.status { color: var(--accent); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tags span { font-size: 13px; border: 1px solid var(--line); border-radius: 99px; padding: 1px 10px; background: var(--surface); }
.price-box {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px;
}
.price-box strong { font-size: 24px; }
.specs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.specs div { background: var(--surface); padding: 8px 12px; }
.specs div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.specs dt { font-size: 12px; color: var(--muted); }
.specs dd { margin: 0; font-weight: 600; }

section { margin-top: 28px; }
section h2 { font-size: 19px; margin: 0 0 10px; }
.gallery { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
.gallery .ph { border-radius: 8px; }
@media (min-width: 720px) { .gallery { grid-template-columns: repeat(3, 1fr); } }

.btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px;
  background: var(--accent); color: #fff; border-radius: 10px; text-decoration: none; font-weight: 600;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.video { aspect-ratio: 16 / 9; max-width: 720px; }
.video iframe { width: 100%; height: 100%; border: 0; border-radius: var(--radius); }

.meta { color: var(--muted); font-size: 13px; margin: 28px 0 40px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; grid-column: 1 / -1; }

/* ดูรูปเต็มจอ */
.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
.lightbox::backdrop { background: rgb(0 0 0 / .85); }
.lightbox img { max-width: 100vw; max-height: 90vh; display: block; }
.lb-close { position: fixed; top: 12px; right: 12px; font-size: 22px; background: none; color: #fff; border: 0; padding: 8px; }

/* หน้าอัปโหลด */
.howto { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; margin-top: 16px; font-size: 15px; }
.howto summary { font-weight: 700; cursor: pointer; }
.howto ol, .howto ul { padding-left: 20px; margin: 8px 0; }
.upload-filters input {
  font: inherit; font-size: 15px; color: var(--text); height: 44px; padding: 0 10px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.up-list { display: grid; gap: 12px; padding-bottom: 24px; }
@media (min-width: 720px) { .up-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1040px) { .up-list { grid-template-columns: repeat(3, 1fr); } }
.up-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.up-head { display: flex; justify-content: space-between; gap: 12px; }
.up-name { font-weight: 600; line-height: 1.4; }
.up-thumb { width: 64px; height: 48px; aspect-ratio: auto; object-fit: cover; border-radius: 6px; flex: none; }
.up-stat { display: flex; gap: 12px; font-size: 14px; margin: 6px 0 10px; }
.up-stat .ok { color: var(--accent); }
.up-stat .miss { color: #b4542d; }
.up-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.up-btns .btn { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn-2 { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.warn { color: #b4542d; font-size: 14px; }
