:root {
  --green: #1f4d3a;
  --green-dark: #163829;
  --green-soft: #e7efe9;
  --red: #a4262c;
  --red-soft: #f8e9e9;
  --cream: #fbf8f2;
  --card: #ffffff;
  --ink: #1f2421;
  --muted: #5f6b64;
  --line: #e3ddd2;
  --gold: #c9a227;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 14px rgba(0, 0, 0, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
}

[hidden] { display: none !important; }

.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}
.wrap.narrow { max-width: 640px; }

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; }
h2 { font-size: 1.5rem; margin: 1.5rem 0 0.75rem; }

a { color: var(--green); }

/* ---------- Header ---------- */
.site-header {
  background: var(--green);
  color: #fff;
  padding: 28px 0 24px;
  border-bottom: 4px solid var(--red);
}
.site-header h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 2.6rem); }
.shop-name {
  margin: 0 0 4px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #cfe2d6;
}

.test-banner {
  background: #fff4cc;
  border-bottom: 1px solid #e8d48a;
  color: #5c4a00;
  padding: 10px 16px;
  text-align: center;
  font-size: 0.9rem;
}

/* ---------- Info card ---------- */
.info-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 20px 0 12px;
}
@media (min-width: 640px) {
  .info-card { grid-template-columns: repeat(3, 1fr); }
}
.info-item { display: flex; flex-direction: column; }
.info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--red);
  font-weight: 700;
}
.info-value { font-weight: 600; }

.how-it-works {
  list-style: none;
  counter-reset: step;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
}
@media (min-width: 640px) {
  .how-it-works { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.how-it-works li {
  counter-increment: step;
  position: relative;
  padding: 10px 12px 10px 44px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}
.how-it-works li::before {
  content: counter(step);
  position: absolute;
  left: 12px;
  top: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 22px;
  text-align: center;
}
.how-it-works strong { display: block; }

.pending-notice {
  background: #fff4cc;
  border: 1px solid #e8d48a;
  color: #5c4a00;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0;
  font-size: 0.95rem;
  text-align: left;
}
.done-card .pending-notice { margin-top: 12px; }

.weight-explainer {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 12px;
}

.closed-notice {
  background: var(--red-soft);
  border: 1px solid #e6c3c3;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.closed-notice h2 { margin-top: 0; color: var(--red); }

/* ---------- Category nav ---------- */
.category-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0;
  background: var(--cream);
}
.category-nav a {
  flex: none;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
}
.category-nav a:hover { border-color: var(--green); color: var(--green); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding-bottom: 32px;
}
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .basket { position: sticky; top: 64px; }
}

.category-section { scroll-margin-top: 64px; }
.category-section h2 {
  border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
}

.product-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Product card ---------- */
.product-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.product-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.product-name { margin: 0; font-size: 1.1rem; font-family: var(--font); font-weight: 700; }
.product-price { font-weight: 700; color: var(--green); white-space: nowrap; text-align: right; }
.product-price small { display: block; font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.product-note { margin: -6px 0 0; color: var(--muted); font-size: 0.9rem; }
.product-single-variant { margin: -6px 0 0; color: var(--muted); font-size: 0.9rem; }
.by-weight-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }

select, input, textarea {
  font: inherit;
  color: var(--ink);
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #cfc8bb;
  border-radius: 8px;
  background: #fff;
}
select:focus, input:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(31, 77, 58, 0.3);
  outline-offset: 1px;
  border-color: var(--green);
}
select.invalid { border-color: var(--red); background: var(--red-soft); }

.product-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: auto;
}

/* ---------- Quantity stepper ---------- */
.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cfc8bb;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  flex: none;
}
.qty button {
  border: 0;
  background: transparent;
  width: 36px;
  height: 38px;
  font-size: 1.15rem;
  cursor: pointer;
  color: var(--green);
}
.qty button:hover { background: var(--green-soft); }
.qty span { min-width: 28px; text-align: center; font-weight: 700; }
.qty.small button { width: 30px; height: 30px; font-size: 1rem; }
.qty.small span { min-width: 22px; font-size: 0.9rem; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:disabled { background: #a9b8af; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--green); border-color: var(--green); }
.btn-secondary:hover { background: var(--green-soft); }
.btn-add { flex: 1; }
.btn-add.added { background: var(--red); }
.btn-block { width: 100%; }
.btn-small { padding: 7px 14px; font-size: 0.92rem; }

.link-back {
  background: none;
  border: 0;
  padding: 0;
  margin-top: 20px;
  font: inherit;
  color: var(--green);
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Basket ---------- */
.basket-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border-top: 4px solid var(--red);
}
.basket-card h2 { margin-top: 0; }
@media (min-width: 960px) {
  .basket-card { max-height: calc(100vh - 88px); overflow-y: auto; }
}
.basket-empty { color: var(--muted); }
.basket-lines { list-style: none; margin: 0; padding: 0; }
.basket-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.basket-line-name { font-weight: 600; }
.basket-line-detail { color: var(--muted); font-size: 0.85rem; }
.basket-line-price { font-weight: 700; text-align: right; white-space: nowrap; }
.basket-line-controls { display: flex; align-items: center; gap: 10px; }
.basket-remove {
  background: none;
  border: 0;
  padding: 0;
  color: var(--red);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}
.basket-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0 4px;
  font-size: 1.1rem;
}
.basket-estimate-note { color: var(--muted); font-size: 0.85rem; margin: 0 0 12px; }
#toCheckout { margin-top: 12px; }

.est { color: var(--muted); font-weight: 500; }

/* Mobile sticky bar */
.basket-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}
@media (min-width: 960px) {
  .basket-bar { display: none !important; }
}
body.has-bar { padding-bottom: 72px; }
@media (min-width: 960px) { body.has-bar { padding-bottom: 0; } }

/* ---------- Checkout ---------- */
.summary-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 16px 14px;
}
.summary-table { width: 100%; border-collapse: collapse; }
.summary-table td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.summary-table td.num { text-align: right; white-space: nowrap; padding-left: 12px; font-weight: 600; }
.summary-table .detail { color: var(--muted); font-size: 0.85rem; display: block; }
.summary-table tfoot td { border-bottom: 0; font-size: 1.1rem; font-weight: 700; padding-top: 12px; }

.details-form { display: flex; flex-direction: column; gap: 14px; padding-bottom: 32px; }
.details-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.details-form input.invalid, .details-form textarea.invalid { border-color: var(--red); background: var(--red-soft); }
.hint, .optional { font-weight: 400; color: var(--muted); font-size: 0.85rem; }

.collect-reminder {
  background: var(--green-soft);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.95rem;
}
.collect-reminder p { margin: 0.2em 0; }

.form-error {
  background: var(--red-soft);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0;
  font-weight: 600;
}

/* ---------- Done ---------- */
.done-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  margin: 24px 0 16px;
  text-align: center;
}
.done-card h2 { margin-top: 8px; }
.done-card .collect-reminder { text-align: left; margin-top: 16px; }
.done-tick {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 30px;
  line-height: 56px;
}
.reference {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--red);
  margin: 0 0 12px;
}
.done-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0 32px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 16px 0 24px;
}

/* ---------- Print ---------- */
@media print {
  .site-header { background: none; color: #000; border-bottom: 2px solid #000; padding: 0 0 8px; }
  .shop-name { color: #000; }
  .test-banner, .done-actions, .site-footer, .basket-bar, .link-back { display: none !important; }
  .done-card, .summary-card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; padding: 0 !important; }
}
