:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-strong: #f0f4f8;
  --text: #18212f;
  --muted: #667085;
  --line: #d9e1ea;
  --accent: #ee4d2d;
  --accent-dark: #c9361d;
  --accent-soft: #fff0eb;
  --green: #0f8a5f;
  --shadow: 0 18px 50px rgba(21, 35, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Noto Sans Thai", sans-serif;
  line-height: 1.5;
}

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

button,
input,
select {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 56px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 18px;
  color: var(--muted);
  font-size: 14px;
}

.site-nav a:hover {
  color: var(--accent);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: stretch;
  padding: 56px 0 28px;
}

.hero-copy {
  display: grid;
  align-content: center;
  min-height: 360px;
  padding: clamp(28px, 5vw, 52px);
  background:
    linear-gradient(120deg, rgba(24, 33, 47, 0.88), rgba(238, 77, 45, 0.82)),
    url("https://images.unsplash.com/photo-1558981285-6f0c94958bb6?auto=format&fit=crop&w=1400&q=80");
  background-position: center;
  background-size: cover;
  color: #fff;
  border-radius: 8px;
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 10px;
  font-weight: 700;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero p {
  max-width: 720px;
  margin: 16px 0 0;
  font-size: 17px;
}

.primary-action {
  justify-self: start;
  margin-top: 26px;
  padding: 12px 18px;
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 800;
}

.hero-panel {
  display: grid;
  gap: 14px;
}

.hero-panel > div {
  display: grid;
  align-content: center;
  min-height: 104px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel span {
  font-size: 32px;
  font-weight: 850;
}

.hero-panel small {
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px;
  gap: 14px;
  align-items: end;
  padding: 18px;
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-box,
.control-group {
  display: grid;
  gap: 7px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(238, 77, 45, 0.25);
  outline-offset: 2px;
}

.category-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.category-strip[hidden] {
  display: none;
}

.category-chip,
.text-button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
}

.category-chip {
  min-height: 38px;
  padding: 8px 14px;
}

.category-chip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
  color: var(--muted);
}

.text-button {
  padding: 8px 12px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  min-height: 320px;
}

.product-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(20, 34, 50, 0.06);
}

.product-image {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface-strong);
  overflow: hidden;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.product-card:hover .product-image img {
  transform: scale(1.04);
}

.badge {
  position: absolute;
  left: 10px;
  top: 10px;
  max-width: calc(100% - 20px);
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(24, 33, 47, 0.84);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.product-body {
  display: grid;
  gap: 10px;
  padding: 14px;
  flex: 1;
}

.product-title {
  display: -webkit-box;
  min-height: 46px;
  margin: 0;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 15px;
  line-height: 1.45;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.product-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.price {
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 850;
}

.commission {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.shop-button {
  display: grid;
  min-height: 42px;
  place-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
}

.shop-button:hover {
  background: var(--accent-dark);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 36px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 26px 0 42px;
}

.page-button {
  min-width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.page-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 850;
}

.about-band {
  margin: 12px 0 38px;
  padding: 24px;
  background: #18212f;
  color: #fff;
  border-radius: 8px;
}

.about-band h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.about-band p {
  margin: 0;
  color: #d9e1ea;
}

.about-band code {
  color: #fff;
}

.article-hero {
  margin: 38px 0 22px;
  padding: clamp(28px, 5vw, 52px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.article-hero h1,
.article-detail h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.08;
  letter-spacing: 0;
}

.article-hero p {
  max-width: 780px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  min-height: 320px;
}

.article-card {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(20, 34, 50, 0.06);
}

.article-card-link {
  display: grid;
  height: 100%;
}

.article-image {
  aspect-ratio: 16 / 9;
  background: var(--surface-strong);
  overflow: hidden;
}

.article-image img,
.article-detail-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-image img {
  transition: transform 0.2s ease;
}

.article-card:hover .article-image img {
  transform: scale(1.04);
}

.article-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.article-category {
  justify-self: start;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
}

.article-body h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
}

.article-body p {
  display: -webkit-box;
  min-height: 48px;
  margin: 0;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--muted);
}

.article-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.article-detail {
  margin: 34px 0 42px;
  padding: clamp(22px, 4vw, 42px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.article-back {
  display: inline-flex;
  margin-bottom: 22px;
}

.article-detail-image {
  max-height: 520px;
  margin: 22px 0;
  border-radius: 8px;
}

.article-content {
  display: grid;
  gap: 14px;
  max-width: 820px;
  margin-top: 18px;
  font-size: 18px;
}

.article-content p {
  margin: 0;
}

.compact-textarea {
  min-height: 100px !important;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.checkbox-label input {
  width: auto;
  min-height: 0;
}

.site-footer {
  padding: 24px clamp(16px, 4vw, 56px) 34px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line);
}

.admin-main {
  display: grid;
  gap: 18px;
  padding: 34px 0 44px;
}

.admin-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-hero h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.08;
}

.admin-hero p {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
}

.admin-hero-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  min-width: 180px;
}

.admin-hero-actions .primary-action {
  margin-top: 0;
}

.admin-refresh {
  border: 0;
  cursor: pointer;
}

.danger-button {
  min-height: 46px;
  padding: 12px 16px;
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  background: #fff5f5;
  color: #b42318;
  cursor: pointer;
  font-weight: 850;
}

.danger-button:hover {
  border-color: #dc2626;
  background: #dc2626;
  color: #fff;
}

.admin-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.admin-status > div,
.admin-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(20, 34, 50, 0.06);
}

.admin-status > div {
  display: grid;
  gap: 4px;
  min-height: 96px;
  align-content: center;
  padding: 20px;
}

.admin-status span {
  overflow-wrap: anywhere;
  font-size: 24px;
  font-weight: 850;
}

.admin-status small {
  color: var(--muted);
}

.admin-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-editor {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 16px;
}

.admin-panel {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.admin-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.admin-panel h2 {
  margin: 0;
  font-size: 22px;
}

.admin-panel p {
  margin: 0;
  color: var(--muted);
}

.admin-panel textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--text);
  font: 13px/1.45 Consolas, "Courier New", monospace;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-button {
  border: 0;
  cursor: pointer;
}

.admin-message {
  margin: 0;
}

.product-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.product-form label {
  display: grid;
  gap: 7px;
}

.form-wide {
  grid-column: 1 / -1;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
}

.admin-table-title {
  display: grid;
  gap: 3px;
}

.admin-table-title strong {
  line-height: 1.35;
}

.admin-table-title small {
  color: var(--muted);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions button {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: 7px;
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .article-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .site-header,
  .toolbar,
  .result-meta {
    align-items: stretch;
    flex-direction: column;
  }

  .site-header {
    position: static;
  }

  .site-nav {
    justify-content: flex-start;
  }

  main {
    width: min(100% - 24px, 1180px);
  }

  .hero {
    padding-top: 24px;
  }

  .hero-copy {
    min-height: 420px;
  }

  .hero-panel,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .admin-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-hero-actions {
    min-width: 0;
  }

  .admin-status,
  .admin-editor,
  .admin-tools {
    grid-template-columns: 1fr;
  }

  .product-form {
    grid-template-columns: 1fr;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .article-grid {
    grid-template-columns: 1fr;
  }

  .price {
    font-size: 19px;
  }
}

@media (max-width: 420px) {
  .product-grid {
    grid-template-columns: 1fr;
  }
}
