:root {
  --bg: #faf8f6;
  --card: #ffffff;
  --ink: #1d1b1a;
  --muted: #6f6a67;
  --line: #eae5e1;
  --accent: #a4386b;      /* raw bites berry */
  --accent-soft: #f7e9f0;
  --fav: #b8860b;
  --fav-soft: #fdf6e3;
  --ok: #2e7d4f;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------- header ---------- */

.top {
  padding: calc(16px + env(safe-area-inset-top)) 16px 0;
}
.top-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
h1 { font-size: 24px; margin: 0; letter-spacing: -0.02em; }
.top-sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- layout ---------- */

.content {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px calc(120px + env(safe-area-inset-bottom));
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.app.blurred { display: none; }

/* ---------- store info ---------- */

.info-card summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.info-card summary::-webkit-details-marker { display: none; }
.summary-hint { color: var(--muted); font-weight: 400; font-size: 13px; }

.info-grid {
  padding: 2px 16px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.info-grid label { display: block; font-size: 13px; color: var(--muted); }
.info-grid input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;      /* iOS: never below 16px or focus zooms */
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.info-grid input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.soft { color: var(--muted); font-weight: 400; font-size: 12px; }

.fulfillment { border: 0; padding: 0; margin: 0; }
.fulfillment legend { font-size: 13px; color: var(--muted); padding: 0 0 4px; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  padding: 10px 8px;
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.seg button.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

#addressWrap { grid-column: 1 / -1; }

@media (max-width: 560px) {
  .info-grid { grid-template-columns: 1fr; }
}

/* ---------- catalog ---------- */

.section-head { padding: 14px 16px 8px; }
.section-head h2 { margin: 0; font-size: 16px; }
.section-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}
.row-main { min-width: 0; }
.row-name { font-weight: 500; font-size: 15px; }
.row-meta { color: var(--muted); font-size: 12.5px; margin-top: 1px; }

.row.is-fav { background: var(--fav-soft); }
.row.is-dnr { opacity: 0.45; }
.tag-dnr {
  font-size: 11px;
  color: #9a3b3b;
  border: 1px solid #e5c9c9;
  border-radius: 5px;
  padding: 1px 5px;
  vertical-align: 1px;
  white-space: nowrap;
}

.row-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.flag {
  width: 38px;
  height: 38px;
  border: 0;
  background: none;
  font-size: 19px;
  line-height: 1;
  color: #c9c2bd;
  cursor: pointer;
  border-radius: 8px;
}
.flag-fav.on { color: var(--fav); }
.flag-dnr.on { color: #9a3b3b; }

.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-left: 4px;
}
.stepper.disabled { visibility: hidden; }
.stepper button {
  width: 38px;
  height: 40px;
  border: 0;
  background: none;
  font-size: 20px;
  color: var(--accent);
  cursor: pointer;
}
.stepper input {
  width: 40px;
  border: 0;
  text-align: center;
  font: inherit;
  font-size: 16px;
  padding: 0;
  background: none;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.footnote { color: var(--muted); font-size: 12.5px; text-align: center; margin: 20px 0 0; }

/* ---------- tally bar ---------- */

.tally {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.tally-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.tally-total { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.tally-detail { color: var(--muted); font-size: 13px; }
.tally-check { font-size: 12.5px; color: #a06010; margin-top: 1px; }
.tally-check.ok { color: var(--ok); }

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { border-color: transparent; background: none; color: var(--accent); padding: 8px 10px; }

/* ---------- review ---------- */

.review {
  min-height: 100vh;
  background: var(--bg);
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.review-inner { max-width: 820px; margin: 0 auto; }
.review-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.review-actions-right { display: flex; gap: 8px; flex-wrap: wrap; }
.review-hint { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
#formPreview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

/* ---------- print (Print / Save as PDF from the review screen) ---------- */

@media print {
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body { background: #fff; }
  .app, .no-print, .toast, .tally { display: none !important; }
  .review { padding: 0; min-height: 0; }
  #formPreview { border: 0; padding: 0; }
}
