:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --ink: #1d2a1f;
  --muted: #66736a;
  --line: #e3e7dd;
  --green: #1f7a3f;
  --green-soft: #e6f2e8;
  --red: #d92b2b;
  --amber-soft: #fff4dc;
  --amber-ink: #8a5a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 20, 0.06), 0 4px 14px rgba(20, 40, 20, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121612;
    --surface: #1a201b;
    --ink: #e8efe8;
    --muted: #9aa79d;
    --line: #2a332c;
    --green: #4cc777;
    --green-soft: #1f3324;
    --red: #ff6464;
    --amber-soft: #3a2f14;
    --amber-ink: #f3c86b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans Thai', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; }
button { font: inherit; cursor: pointer; }

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1360px; margin: 0 auto;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; flex-shrink: 0; }
.brand-mark { font-size: 26px; }
.brand-text { font-size: 22px; font-weight: 500; letter-spacing: -0.3px; }
.brand-text b { color: var(--green); font-weight: 700; }

.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 4px 4px 16px;
}
.search:focus-within { border-color: var(--green); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex-shrink: 0; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--ink); padding: 8px 0;
}
.search button {
  border: 0; border-radius: 999px; background: var(--green); color: #fff;
  padding: 8px 20px; font-weight: 600;
}

/* Layout */
.layout {
  max-width: 1360px; margin: 0 auto;
  display: grid; grid-template-columns: 250px 1fr; gap: 24px;
  padding: 20px;
}

/* Sidebar */
.sidebar {
  position: sticky; top: 84px; align-self: start;
  max-height: calc(100vh - 104px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px;
}
.side-title { font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px; text-transform: uppercase; letter-spacing: .4px; }
.side-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  padding: 6px 10px; border-radius: 10px; font-size: 14.5px;
}
.side-item:hover { background: var(--bg); }
.side-item.active { background: var(--green-soft); color: var(--green); font-weight: 600; }
.side-item .ico {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
  object-fit: cover; background: var(--green-soft);
}
.side-item .ico-emoji { display: grid; place-items: center; font-size: 18px; }
.side-item .lbl { flex: 1; line-height: 1.3; }

/* Content */
.content { min-width: 0; }
.crumbs { font-size: 13px; color: var(--muted); min-height: 20px; }
.crumbs a { color: var(--green); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
h1 { margin: 2px 0 2px; font-size: 26px; letter-spacing: -0.3px; }
.meta { margin: 0; color: var(--muted); font-size: 14px; }


.notice {
  margin: 12px 0; padding: 10px 14px; border-radius: 10px;
  background: var(--amber-soft); color: var(--amber-ink); font-size: 14px;
}

.grid {
  display: grid; gap: 14px; margin-top: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.card {
  display: flex; flex-direction: column; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
  cursor: pointer; color: inherit;
}
.card:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.card:hover { transform: translateY(-2px); border-color: var(--green); }
.thumb { position: relative; aspect-ratio: 1; background: #fff; display: grid; place-items: center; }
.thumb img { width: 86%; height: 86%; object-fit: contain; }
.badge-off {
  position: absolute; top: 10px; left: 10px;
  background: var(--red); color: #fff; font-weight: 700; font-size: 13px;
  padding: 2px 8px; border-radius: 6px;
}
.body { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.promo {
  align-self: flex-start; font-size: 11.5px; line-height: 1.35;
  background: var(--amber-soft); color: var(--amber-ink);
  padding: 2px 8px; border-radius: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.title {
  margin: 0; font-size: 15px; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.8em;
}
.brandline { font-size: 12.5px; color: var(--muted); }

.skeleton .thumb, .skeleton .sk {
  background: linear-gradient(90deg, var(--line) 0%, var(--bg) 50%, var(--line) 100%);
  background-size: 200% 100%; animation: sk 1.2s infinite linear;
}
.skeleton .sk { height: 14px; border-radius: 6px; }
@keyframes sk { to { background-position: -200% 0; } }

.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); }
.more-wrap { display: flex; justify-content: center; margin: 24px 0 8px; }
.more {
  border: 1px solid var(--green); background: var(--surface); color: var(--green);
  border-radius: 999px; padding: 10px 32px; font-weight: 600;
}
.more:disabled { opacity: .5; cursor: default; }
.foot { margin: 28px 0 10px; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.7; }

/* Price comparison lines on a card */
.cmp { list-style: none; margin: auto 0 0; padding: 8px 0 0; display: flex; flex-direction: column; gap: 4px; }
.cmp-row {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  padding: 3px 6px; border-radius: 8px; font-variant-numeric: tabular-nums;
}
.cmp-row .logo { width: 52px; height: 20px; object-fit: contain; object-position: left center; align-self: center; flex-shrink: 0; }
/* Lotus's wordmark is white, so it sits on Lotus's own header colour. */
.cmp-row .logo[src*="lotuss"], .buy-logo[src*="lotuss"] {
  background: linear-gradient(90deg, rgb(0, 174, 167), rgb(20, 121, 117));
  border-radius: 4px; padding: 3px 5px; object-position: center;
}
.cmp-row .p { font-weight: 700; font-size: 15px; }
.cmp-row[data-store="makro"] .p { color: var(--red); font-size: 18px; }
.cmp-row .u { font-size: 12px; color: var(--muted); }
.cmp-row .was { font-size: 12px; color: var(--muted); }
.cmp-row.pending .p, .cmp-row.none .p { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.cmp-row.none .logo { opacity: .45; }
.cmp-row.best { background: var(--green-soft); }
.cmp-row.best::after { content: 'ถูกสุด'; margin-left: auto; font-size: 11px; font-weight: 700; color: var(--green); }

/* "Where to buy" dialog */
.buy {
  width: min(520px, calc(100vw - 32px)); border: 0; border-radius: 18px; padding: 20px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.buy::backdrop { background: rgba(10, 20, 10, .45); }
.buy-close { position: absolute; top: 10px; right: 10px; margin: 0; }
.buy-close button { border: 0; background: var(--bg); color: var(--ink); width: 34px; height: 34px; border-radius: 50%; font-size: 15px; }
.buy-head { display: flex; gap: 14px; align-items: center; padding-right: 36px; }
.buy-head img { width: 76px; height: 76px; object-fit: contain; background: #fff; border-radius: 12px; border: 1px solid var(--line); flex-shrink: 0; }
.buy-kicker { font-size: 12.5px; color: var(--muted); }
.buy-head h2 { margin: 2px 0 0; font-size: 17px; line-height: 1.4; }
.buy-list { list-style: none; margin: 16px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.buy-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.buy-item.disabled { opacity: .65; }
.buy-logo { width: 64px; height: 24px; object-fit: contain; flex-shrink: 0; }
.buy-info { flex: 1; min-width: 0; }
.buy-name { font-size: 13.5px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.buy-name.muted { color: var(--muted); }
.buy-price { font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.buy-hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.buy-best { margin-left: 8px; font-size: 11.5px; font-weight: 700; color: var(--green); background: var(--green-soft); padding: 1px 8px; border-radius: 999px; }
.buy-go {
  flex-shrink: 0; text-decoration: none; background: var(--green); color: #fff;
  padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.buy-go:hover { filter: brightness(1.1); }
.buy-note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* Sections (Makro flexi-page components) */
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-title { margin: 0 0 12px; font-size: 19px; font-weight: 600; }
.see-more { color: var(--green); text-decoration: none; font-weight: 500; white-space: nowrap; font-size: 14.5px; }
.see-more:hover { text-decoration: underline; }

.tiles {
  display: grid; grid-auto-flow: column; grid-auto-columns: 104px; gap: 12px;
  overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity;
}
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; scroll-snap-align: start; }
.tile-img {
  width: 92px; height: 92px; border-radius: 50%; overflow: hidden;
  background: var(--green-soft); display: block; transition: transform .12s ease;
}
.tile:hover .tile-img { transform: scale(1.05); }
.tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-label { font-size: 14px; text-align: center; line-height: 1.35; }
.tiles-image { grid-auto-columns: 150px; }
.tiles-image .tile-img { width: 150px; height: auto; aspect-ratio: .9; border-radius: 12px; background: var(--surface); }

.row-wrap { position: relative; }
.row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 200px; gap: 14px;
  overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 2px 10px;
  scrollbar-width: thin;
}
.row > .card { scroll-snap-align: start; }
.row-btn {
  position: absolute; top: 38%; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 22px; line-height: 1; box-shadow: var(--shadow);
}
.row-btn.prev { left: -14px; }
.row-btn.next { right: -14px; }
.row-error { padding: 20px; color: var(--muted); }

/* Mobile: sidebar becomes a horizontal strip of category chips */
@media (max-width: 820px) {
  .topbar-inner { gap: 12px; padding: 10px 16px; }
  .brand-text { display: none; }
  .search button { padding: 8px 14px; }
  .layout { grid-template-columns: 1fr; gap: 12px; padding: 12px 16px; }
  .sidebar {
    position: static; max-height: none; overflow-x: auto; overflow-y: hidden;
    display: flex; gap: 6px; padding: 8px; border-radius: 12px;
  }
  .side-title { display: none; }
  .side-item { width: auto; white-space: nowrap; flex-shrink: 0; padding: 4px 12px 4px 4px; font-size: 14px; }
  .side-item .ico { width: 28px; height: 28px; }
  .row { grid-auto-columns: 160px; gap: 10px; }
  .row-btn { display: none; }
  .cmp-row .logo { width: 44px; height: 18px; }
  .cmp-row[data-store="makro"] .p { font-size: 16px; }
  .buy-item { flex-wrap: wrap; }
  .buy-go { width: 100%; text-align: center; }
  .tiles { grid-auto-columns: 84px; }
  .tile-img { width: 76px; height: 76px; }
  .tiles-image { grid-auto-columns: 120px; }
  .tiles-image .tile-img { width: 120px; height: auto; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  h1 { font-size: 22px; }
}

@media (prefers-color-scheme: dark) {
  .cmp-row .logo:not([src*="lotuss"]), .buy-logo:not([src*="lotuss"]) { background: #fff; border-radius: 4px; padding: 1px 3px; }
}
