:root {
  color-scheme: light;
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #171717;
  --muted: #5f6762;
  --line: #e6e6e2;
  --accent: #dff25a;
  --accent-ink: #17200a;
  --ok: #166534;
  --warn: #9a3412;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: Manrope, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
}

button, input, select, textarea { font: inherit; color: inherit; }
/* iOS zooms the page when a focused field is under 16px. */
input, select, textarea { font-size: 16px; }
button { cursor: pointer; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.top.plain { grid-template-columns: auto; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.logo {
  display: block;
  height: 42px;
  width: auto;
}

.search input, select {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  outline: none;
}
.search input:focus, select:focus { border-color: var(--accent); }

.cart-btn {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  padding: 12px 16px;
}
.cart-btn span {
  display: inline-grid;
  place-items: center;
  min-width: 1.4em;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-ink);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.banner {
  margin: 16px 24px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff4e8;
  color: var(--warn);
}
.banner.ok { background: #edf7ef; color: var(--ok); }
.banner.test { background: #f4f8d4; color: var(--accent-ink); }

.toolbar { padding: 18px 24px 0; }
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.chip-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
}
.chip.is-on {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
  font-weight: 700;
}
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 14px;
}
.toolbar-row select { width: auto; min-width: 220px; border-radius: 12px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.count { margin: 0 0 0 auto; color: var(--muted); }

.status { padding: 32px 24px; color: var(--muted); }
.status[hidden] { display: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
  padding: 12px 16px 24px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  min-width: 0;
}
.card.is-out { opacity: 0.72; }
.card-open {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 4px;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0 0 12px;
  color: inherit;
  text-decoration: none;
}
.product-seo { padding: 8px 16px 0; }
.product-seo h1 {
  margin: 4px 0;
  font-family: var(--display);
  font-size: 36px;
  line-height: 0.95;
  letter-spacing: 0.02em;
}
.thumb {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: #f4f4f2;
  margin-bottom: 8px;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 16px;
}
.no-image { color: var(--muted); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.card .brand, .card .meta, .card .stock { margin: 0 14px; }
.card .brand, .detail .brand {
  color: #3f6212;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.name {
  margin: 0 14px;
  font-size: 16px;
  line-height: 1.3;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta, .stock { color: var(--muted); font-size: 12px; }
.sku { font-family: ui-monospace, "Cascadia Mono", monospace; }
.price {
  margin: 8px 14px 0;
  font-family: var(--display);
  font-size: 28px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.add, .primary {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  padding: 10px 14px;
}
.add { margin: 0 14px 14px; }
.add:disabled, .primary:disabled { background: #ececea; color: #8d9488; cursor: not-allowed; }

.note {
  margin: 0;
  padding: 8px 24px 20px;
  color: var(--muted);
  font-size: 13px;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tabbar .tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar .tab.is-current { color: var(--ink); }

.orders-page { padding: 8px 24px 24px; max-width: 760px; }
.orders-page h1 {
  margin: 8px 0 4px;
  font-family: var(--display);
  font-size: 40px;
  letter-spacing: 0.03em;
}
.orders-page .lead { margin: 0 0 16px; color: var(--muted); }
.mine { display: grid; gap: 10px; }
.mine-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.mine-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.mine-card h2 { margin: 0; font-size: 16px; }
.mine-card .meta { margin: 4px 0 0; }
.mine-total {
  font-family: var(--display);
  font-size: 28px;
  line-height: 1;
}
.mine-lines { margin: 10px 0 0; color: var(--muted); }
.badge {
  display: inline-block;
  margin-top: 8px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #f4f4f2;
  color: var(--muted);
}
.badge.paid { background: #edf7ef; color: var(--ok); }
.badge.wait { background: #fff4e8; color: var(--warn); }
.badge.prep { background: #eef2ff; color: #1e3a8a; }
.badge.ship { background: #edf7ef; color: var(--ok); }

dialog {
  width: min(920px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: inherit;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.66); }
.detail {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.detail-copy { padding: 22px; }
.detail .thumb { margin: 0; min-height: 320px; aspect-ratio: auto; }
.detail .name {
  margin: 6px 0 0;
  font-family: var(--display);
  font-size: 36px;
  line-height: 0.95;
  font-weight: 700;
  -webkit-line-clamp: unset;
  display: block;
}
.detail .brand, .detail .meta, .detail .price { margin-left: 0; margin-right: 0; }
.specs { margin: 16px 0; display: grid; gap: 8px; }
.spec { display: grid; grid-template-columns: 110px 1fr; gap: 10px; font-size: 14px; }
.spec dt { color: var(--muted); }
.spec dd { margin: 0; }
.buy-row { display: flex; gap: 10px; align-items: center; }
.qty {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.qty button {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.qty span { min-width: 1.5em; text-align: center; font-variant-numeric: tabular-nums; }
.text-btn { background: transparent; border: 0; color: var(--muted); }

.cart-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr min(420px, 100%);
}
.cart-layer[hidden] { display: none; }
.backdrop { border: 0; background: rgba(0, 0, 0, 0.55); }
.cart {
  background: #ffffff;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-height: 100vh;
}
.cart-head, .cart-summary { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; }
.cart-head { border-bottom: 1px solid var(--line); }
.cart-head h2 { margin: 0; font-family: var(--display); font-size: 32px; letter-spacing: 0.03em; }
.cart-lines { overflow: auto; flex: 1; padding: 8px 18px 18px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line h3 { margin: 0; font-size: 14px; font-weight: 600; }
.line .meta { margin: 4px 0 0; }
.cart-summary { display: block; border-top: 1px solid var(--line); }
.totals { display: grid; gap: 6px; margin-bottom: 12px; }
.totals div { display: flex; justify-content: space-between; color: var(--muted); }
.totals .grand { color: var(--ink); font-size: 18px; font-weight: 700; }
.cart-summary .primary { width: 100%; }
.cart-error { color: var(--warn); min-height: 1.2em; margin: 8px 0 0; }
.empty { color: var(--muted); }

@media (max-width: 720px) {
  .top {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand cart"
      "search search";
    padding: 12px;
  }
  .brand { grid-area: brand; justify-self: start; }
  .search { grid-area: search; }
  .cart-btn { grid-area: cart; justify-self: end; }
  .grid, .toolbar, .note, .orders-page, .banner { padding-left: 10px; padding-right: 10px; }
  .grid { gap: 8px; padding-top: 8px; }
  .card { border-radius: 12px; }
  .thumb img { padding: 8px; }
  .card .brand, .card .meta, .card .stock { margin-left: 8px; margin-right: 8px; }
  .name { margin-left: 8px; margin-right: 8px; font-size: 14px; -webkit-line-clamp: 2; }
  .price { margin: 4px 8px 0; font-size: 22px; }
  .add { margin: 0 8px 8px; padding: 8px 10px; }
  .card-open { padding-bottom: 8px; }
  .banner { margin-left: 10px; margin-right: 10px; }
  .detail { grid-template-columns: 1fr; }
  .detail .name { font-size: 30px; }
  .count { margin-left: 0; width: 100%; }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
