:root {
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #111111;
  --muted: #707072;
  --accent: #fa5400;
  --line: #e5e5e5;
  --photo: #f5f5f5;
  --bad: #111111;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Thai", ui-sans-serif, system-ui, sans-serif;
  min-height: 100%;
}

html { -webkit-text-size-adjust: 100%; }

body {
  padding: 0 0 calc(40px + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
  max-width: 1240px;
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
}

body.sheet-open { overflow: hidden; }

.wrap { min-height: 100%; }

.source-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  padding: 10px 20px 0;
}

header {
  padding: 20px 20px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 0;
  color: #fff;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-serif, Georgia, serif;
  font-size: 18px;
  font-weight: 700;
}

.kicker {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.about {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
  max-width: 36em;
}

.shop-links {
  display: flex;
  gap: 10px;
  max-width: 420px;
}

.shop-links .btn {
  flex: 1;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 13px;
}

.error-box {
  background: #fafafa;
  border: 1px solid var(--line);
  padding: 16px;
  text-align: center;
  margin: 12px 20px;
}

.error-box p {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 10px;
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 48px 12px;
  font-size: 13px;
}

.loading[hidden] { display: none !important; }

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #eee;
  border-top-color: #111;
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

.chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,0.94);
  border-bottom: 1px solid var(--line);
  padding: 8px 20px;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 36px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
}

.chip.is-on {
  color: #111;
  background: transparent;
  box-shadow: inset 0 -2px 0 #111;
}

.chip[hidden] { display: none !important; }

.chip-n {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
}

.sort-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 12px 20px 4px;
}

.sort-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 4px;
  min-width: 0;
  flex: 1 1 220px;
}

.sort-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-right: 8px;
}

.sort-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.sort-btn,
.sort-price select {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  min-height: 34px;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 10px;
}

.sort-btn.is-on,
.sort-price.is-on select {
  color: #111;
  background: transparent;
  box-shadow: inset 0 -2px 0 #111;
}

.sort-price select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 18px;
}

.sort-btn:focus-visible,
.sort-price select:focus-visible,
.chip:focus-visible,
.card:focus-visible,
.btn:focus-visible,
.sheet-close:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.count {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 20px 12px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 12px;
  padding: 8px 12px 24px;
}

.grid[hidden] { display: none !important; }

.card {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.card.is-out { opacity: 0.7; }

.photo {
  position: relative;
  background: var(--photo);
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8%;
  display: block;
  background: var(--photo);
}

.sheet-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8%;
  display: block;
  background: var(--photo);
}

.photo-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-family: ui-serif, Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  background: var(--photo);
}

.sold-tag {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  background: rgba(17,17,17,0.4);
}

.card-body {
  padding: 14px 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.card-kicker {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.3;
}

.card-kicker.is-out { color: var(--muted); }

.card-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: #111;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-sub {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-price {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #111;
  margin-top: 6px;
}

.shop-badge, .card-meta, .card-kind, .pills { display: none; }

.empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 40px 12px;
}

.more {
  text-align: center;
  color: var(--muted);
  padding: 8px 12px 24px;
  font-size: 12px;
}
.more[hidden] { display: none !important; }
.more .spinner { width: 18px; height: 18px; margin-bottom: 8px; }

footer {
  margin-top: 12px;
  padding: 20px 20px 0;
  border-top: 1px solid var(--line);
  text-align: center;
}

footer a {
  color: #111;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

footer a:hover { text-decoration: underline; }

.foot-note {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
  line-height: 1.55;
}

.sheet-root { position: fixed; inset: 0; z-index: 40; }
.sheet-root[hidden] { display: none !important; }

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 10px 20px calc(18px + env(safe-area-inset-bottom));
}

.sheet-root:not([hidden]) .backdrop { animation: fade-in 0.22s ease; }
.sheet-root:not([hidden]) .sheet { animation: sheet-up 0.28s ease; }

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: #ddd;
  margin: 4px auto 8px;
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: #f5f5f5;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  min-height: 36px;
  z-index: 1;
}

.sheet-photo {
  background: var(--photo);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  margin: 8px 0 14px;
  position: relative;
}

.sheet-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.sheet h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.sheet-price {
  font-size: 20px;
  font-weight: 700;
  color: #111;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 12px;
}

.sheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.pill {
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.pill.ok { color: #111; }
.pill.bad { color: var(--muted); }

.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.sheet-actions-row { display: flex; gap: 8px; }
.sheet-actions-row .btn { flex: 1; }

.sheet-note {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  margin-top: 10px;
  line-height: 1.45;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  min-height: 44px;
  border-radius: 0;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid #111;
  background: #fff;
  color: #111;
  cursor: pointer;
}

.btn.primary {
  background: #111;
  color: #fff;
  border-color: #111;
}

.btn:active { transform: scale(0.98); }

@keyframes sheet-up {
  from { transform: translate(-50%, 28px); opacity: 0.6; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 36px 20px;
    padding: 12px 20px 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
  .sheet-root:not([hidden]) .sheet,
  .sheet-root:not([hidden]) .backdrop,
  .spinner { animation: none; }
}
