:root {
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --bg: #faf8f5;
  --card: #ffffff;
  --line: #ece7e0;
  --accent: #b8894f;
  --accent-soft: #f4ece1;
  --sale: #b4412f;
  --ok: #2f6f4f;
  --radius: 14px;
  --top-h: 56px;
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1, h2 { font-family: var(--serif); letter-spacing: -0.01em; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 8px 0;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  background: rgba(250, 248, 245, .92);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { justify-self: center; display: flex; align-items: center; height: 100%; grid-column: 2; }
.brand img { height: 30px; width: auto; }
.brand-text { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.icon-btn:active { background: var(--line); }
.topbar .back { grid-column: 1; grid-row: 1; }
.topbar > a.icon-btn { grid-column: 3; grid-row: 1; }

/* ---------- Main view ---------- */
main {
  max-width: 680px; margin: 0 auto;
  padding: 0 0 calc(var(--nav-h) + var(--safe-b) + 24px);
  outline: none;
  min-height: 70vh;
}
main.with-buybar { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 96px); }
.pad { padding: 0 16px; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 16px; margin-bottom: 12px; }
.section-head h2 { font-size: 21px; }
.section-head a { font-size: 14px; color: var(--accent); font-weight: 600; }
.page-title { padding: 20px 16px 4px; font-size: 26px; }
.page-sub { padding: 0 16px; color: var(--muted); margin: 0; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 500; color: var(--muted);
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--ink); }
.tabbar a.active svg { color: var(--accent); }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}

/* ---------- Hero ---------- */
.hero {
  margin: 16px 16px 0; padding: 26px 22px 24px;
  border-radius: 20px;
  background: var(--ink); color: #fff;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px;
  width: 170px; height: 170px; border-radius: 50%;
  background: radial-gradient(circle, rgba(184,137,79,.55), rgba(184,137,79,0) 70%);
}
.hero small { color: #d6c3a6; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 11px; }
.hero h1 { font-size: 27px; line-height: 1.2; margin: 8px 0 10px; position: relative; z-index: 1; }
.hero p { margin: 0 0 18px; color: #cbd2dc; font-size: 14px; position: relative; z-index: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border-radius: 999px;
  font-weight: 600; font-size: 15px;
  background: var(--ink); color: #fff;
}
.btn:active { transform: scale(.98); }
.btn-light { background: #fff; color: var(--ink); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- Install banner ---------- */
.install {
  margin: 16px 16px 0; padding: 14px 14px 14px 16px;
  display: flex; align-items: center; gap: 12px;
  background: var(--accent-soft); border-radius: var(--radius);
}
.install img { width: 42px; height: 42px; border-radius: 10px; }
.install div { flex: 1; font-size: 13px; color: var(--ink-2); }
.install strong { display: block; font-size: 14px; color: var(--ink); }
.install .btn { height: 36px; padding: 0 14px; font-size: 13px; }
.install .x { width: 28px; height: 28px; color: var(--muted); font-size: 20px; line-height: 1; }

/* ---------- Department tiles ---------- */
.dept-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 0 16px; }
.dept {
  position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden;
  background: var(--line);
}
.dept img { width: 100%; height: 100%; object-fit: cover; }
.dept span {
  position: absolute; inset: auto 0 0 0; padding: 30px 12px 11px;
  background: linear-gradient(transparent, rgba(17,24,39,.78));
  color: #fff; font-weight: 600; font-size: 15px;
}
.dept.wide { grid-column: span 2; aspect-ratio: 2.2 / 1; }

/* ---------- Product rail & grid ---------- */
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: 44%;
  gap: 12px; overflow-x: auto; padding: 0 16px 4px;
  scroll-snap-type: x mandatory; scrollbar-width: none;
  scroll-padding-inline: 16px;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 12px; padding: 0 16px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } .rail { grid-auto-columns: 30%; } }

.card { display: flex; flex-direction: column; min-width: 0; }
.card-img {
  position: relative; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden;
  background: #fff; border: 1px solid var(--line);
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.noimg { width: 100%; height: 100%; background: linear-gradient(135deg, #f1ece5, #e6ddd1); }
.card-title {
  font-family: var(--sans); font-size: 14px; font-weight: 500; line-height: 1.35;
  margin: 8px 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; gap: 6px; }
.price { font-weight: 600; font-size: 14px; }
.price small { font-weight: 400; color: var(--muted); font-size: 12px; }
.price s, .pp-price s { color: var(--muted); font-weight: 400; margin-left: 4px; font-size: .9em; }
.quick {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--ink); color: #fff; font-size: 20px; line-height: 1;
}
.quick:active { background: var(--accent); }
.tag {
  position: absolute; top: 8px; left: 8px;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.tag-out { background: rgba(255,255,255,.92); color: var(--ink-2); }
.tag-sale { background: var(--sale); color: #fff; }

/* ---------- Chips & toolbar ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; height: 36px; padding: 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center;
  background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.toolbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; color: var(--muted); font-size: 13px; }
.select {
  height: 36px; padding: 0 30px 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23111827' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 10px center;
  font: inherit; font-size: 14px; color: var(--ink); appearance: none; -webkit-appearance: none;
}
.more-wrap { padding: 22px 16px 0; text-align: center; }

/* ---------- Search ---------- */
.searchbox { position: sticky; top: calc(var(--top-h) + var(--safe-t)); z-index: 10; background: var(--bg); padding: 14px 16px 10px; }
.searchbox input {
  width: 100%; height: 48px; padding: 0 16px 0 44px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7' fill='none' stroke='%236b7280' stroke-width='2'/%3E%3Cpath d='M20 20l-4-4' stroke='%236b7280' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 14px center;
  font: inherit; font-size: 16px; color: var(--ink); outline: none;
}
.searchbox input:focus { border-color: var(--accent); }

/* ---------- Product page ---------- */
.gallery { position: relative; background: #fff; }
.gallery-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  aspect-ratio: 1 / 1;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; background: #fff; }
.dots { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(17,24,39,.22); }
.dots i.on { background: var(--ink); width: 18px; border-radius: 4px; }
.pp { padding: 18px 16px 0; }
.pp h1 { font-size: 24px; line-height: 1.25; }
.pp-price { font-size: 20px; font-weight: 600; margin-top: 8px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stock { font-size: 13px; font-weight: 500; }
.stock.in { color: var(--ok); }
.stock.out { color: var(--sale); }
.opt { margin-top: 20px; }
.opt-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.opt-label b { color: var(--ink); font-weight: 600; }
.opt-values { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-values button {
  min-height: 40px; padding: 6px 14px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card); font-size: 14px; font-weight: 500;
}
.opt-values button.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.opt-values button.na { color: #b1b5bd; text-decoration: line-through; }
.opt-values button.na.on { color: #fff; background: #6b7280; border-color: #6b7280; }
.desc { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 15px; }
.desc h2, .desc h3, .desc h4 { font-family: var(--sans); font-size: 16px; color: var(--ink); margin: 18px 0 6px; }
.desc p { margin: 0 0 12px; }
.desc ul, .desc ol { padding-left: 20px; margin: 0 0 12px; }
.desc a { color: var(--accent); text-decoration: underline; }
.desc table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 12px; }
.desc td, .desc th { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.desc img { border-radius: 10px; margin: 8px 0; height: auto; }
.visit-note {
  margin-top: 22px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--accent-soft); font-size: 13px; color: var(--ink-2);
}
.visit-note b { color: var(--ink); }

.buybar {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--nav-h) + var(--safe-b));
  padding: 10px 16px;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center;
}
.buybar-inner { max-width: 648px; margin: 0 auto; width: 100%; display: flex; gap: 10px; align-items: center; }
.buybar .btn { flex: 1; }
.stepper {
  display: inline-flex; align-items: center; height: 48px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--card);
}
.stepper button { width: 40px; height: 100%; font-size: 20px; color: var(--ink-2); }
.stepper span { min-width: 22px; text-align: center; font-weight: 600; }
.stepper.sm { height: 34px; }
.stepper.sm button { width: 32px; font-size: 17px; }

/* ---------- Cart ---------- */
.lines { padding: 6px 16px 0; }
.line { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.line img, .line .noimg { width: 76px; height: 76px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); background: #fff; }
.line h3 { font-family: var(--sans); font-size: 14px; font-weight: 600; line-height: 1.3; }
.line .variant { font-size: 13px; color: var(--muted); }
.line-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.remove { font-size: 13px; color: var(--muted); text-decoration: underline; padding: 4px 0; }
.summary { margin: 18px 16px 0; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.summary-row { display: flex; justify-content: space-between; font-size: 15px; }
.summary-row.total { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.summary p { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }
.cart-busy { opacity: .5; pointer-events: none; }

/* ---------- Lists (Shop / More) ---------- */
.list { margin: 14px 16px 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list a, .list button.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.list > :last-child { border-bottom: 0; }
.list .grow { flex: 1; }
.list small { display: block; color: var(--muted); font-size: 13px; }
.list .chev { color: #b1b5bd; }
.list-title { padding: 24px 16px 0; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.store-card { margin: 16px 16px 0; padding: 20px; border-radius: var(--radius); background: var(--ink); color: #fff; }
.store-card h2 { font-size: 20px; margin-bottom: 6px; }
.store-card p { margin: 0 0 4px; color: #cbd2dc; font-size: 14px; }
.store-card .btn { margin-top: 14px; height: 42px; font-size: 14px; }

/* ---------- States ---------- */
.empty { text-align: center; padding: 56px 28px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); font-size: 21px; margin-bottom: 6px; }
.empty .btn { margin-top: 18px; }
.sk { background: linear-gradient(90deg, #efebe5 25%, #f7f4ef 50%, #efebe5 75%); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
.sk-card .sk-img { aspect-ratio: 1 / 1; }
.sk-card .sk-line { height: 12px; margin-top: 10px; width: 80%; }
.sk-card .sk-line.short { width: 40%; }

/* ---------- Toast & sheet ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; z-index: 50;
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  max-width: 520px; margin: 0 auto;
  padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: transform .22s ease, opacity .22s ease;
}
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast.lift { bottom: calc(var(--nav-h) + var(--safe-b) + 86px); }
.toast a { color: #e7c99c; font-weight: 600; white-space: nowrap; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(17,24,39,.45); display: flex; align-items: flex-end; }
.sheet {
  width: 100%; max-width: 560px; margin: 0 auto;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(22px + var(--safe-b));
}
.sheet h2 { font-size: 21px; margin-bottom: 12px; }
.sheet ol { padding-left: 20px; margin: 0 0 18px; color: var(--ink-2); }
.sheet li { margin-bottom: 8px; }
