/* Purchase flow: styles are scoped to the existing product and picker screens. */
:root {
  --purchase-navy: #061f37;
  --purchase-paper: #faf6ef;
  --purchase-green: #006322;
  --purchase-soft-green: #edf5e5;
  --purchase-line: #e1ded6;
}

/* Product detail: full-width artwork and a rounded information sheet. */
body:has(.detail) #main { padding-bottom: calc(98px + env(safe-area-inset-bottom)); }
body:has(.detail) .mobile-nav { display: none; }
#backCatalog {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 12px;
  margin: 0 0 6px;
  border: 0;
  background: transparent;
  color: #122c22;
  font-weight: 650;
}
.detail { margin-top: 0; }
.detail .detailart {
  width: calc(100% + 28px);
  height: 300px;
  margin: 0 -14px;
  border-radius: 0;
  background-position: center;
}
.detail .panel {
  position: relative;
  margin: -20px -14px 0;
  padding: 24px 20px 20px;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--purchase-paper);
}
.detail .panel .eyebrow { display: none; }
.detail .panel h1 {
  margin: 0 0 8px;
  color: #111b17;
  font-size: 25px;
  line-height: 1.28;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.detail .product-description { margin: 4px 0 12px; color: #4e5650; }
.detail .panel > .muted:first-of-type { margin: 12px 0 0; }
.detail .price {
  margin: 3px 0 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff0d3;
  color: #005b22;
  font-size: 27px;
  font-weight: 800;
}
.detail .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; border-top: 0; }
.detail .stats strong { color: #111b17; overflow-wrap: anywhere; }
.detail #detailBuy {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 358px);
  min-height: 52px;
  border: 0;
  border-radius: 26px;
  background: var(--purchase-green);
  color: white;
  font-size: 17px;
  font-weight: 750;
  box-shadow: 0 2px 10px #062f181c;
}

/* The top-layer dialog is a page-like surface with persistent back navigation. */
#picker {
  background: var(--purchase-paper);
  color: #111b17;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
  overscroll-behavior: contain;
}
#picker .flow-head {
  min-height: calc(60px + env(safe-area-inset-top));
  margin-bottom: 0;
  color: #173b2a;
  font-size: 19px;
  font-weight: 750;
}
#picker .flow-head button {
  min-width: 44px;
  min-height: 44px;
  line-height: 1;
  color: #173b2a;
}
#picker .flow-step { padding: 16px 0 12px; }
#picker .flow-step[hidden] { display: none; }
#picker #pickTitle {
  margin: 0 0 3px;
  color: #101a15;
  font-size: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
#picker #pickTitle + p { margin: 2px 0 14px; font-size: 12px; }
#picker h3 { margin: 18px 0 10px; color: #101a15; font-size: 17px; }
#picker .mode-tabs { margin: 0 0 14px; border-color: #dedbd5; border-radius: 13px; }
#picker .mode-tabs button { min-height: 44px; padding: 8px 6px; line-height: 1.3; overflow-wrap: anywhere; }
#picker .mode-tabs button.active { border-radius: 10px; background: var(--purchase-green); }
#picker .toolbar { display: flex; flex-wrap: nowrap; gap: 8px; align-items: end; margin: 10px 0; }
#picker .toolbar label { flex: 1 1 0; min-width: 0; margin: 0; }
#picker .toolbar input, #picker .toolbar select { min-height: 44px; margin-top: 4px; padding: 8px 10px; }
#picker .toolbar button { min-width: 44px; min-height: 44px; padding: 8px 10px; }
#picker #singlePanel > .muted { color: #46534a; font-size: 12px; line-height: 1.5; }
#picker .numbers { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; margin: 12px 0 22px; }
#picker .numbers button {
  min-width: 0;
  min-height: 44px;
  padding: 5px 1px;
  border: 1px solid #b5d3a8;
  border-radius: 8px;
  background: #f0f8e9;
  color: #142117;
  font-size: clamp(10px, 3.1vw, 13px);
  font-weight: 650;
}
#picker .numbers button.selected { background: var(--purchase-green); border-color: var(--purchase-green); color: white; }
#picker .numbers button.sold:disabled { background: #e3e4e2; border-color: #d9dbd9; color: #626963; opacity: 1; }
#picker .numbers button.reserved:disabled { background: #ffebbd; border-color: #f1d79d; color: #755000; opacity: 1; }

/* Footer remains in the bottom safe area while the content scrolls behind it. */
#picker .flow-actions {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 390px);
  margin: 0;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-radius: 14px 14px 0 0;
  background: #004822;
  box-shadow: 0 -3px 14px #002d161c;
  gap: 8px;
}
#picker .flow-actions button {
  min-width: 0;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  border-radius: 11px;
  background: #00712a;
  color: white;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
#picker .flow-actions button.quiet { background: #fffaf3; color: #005523; border: 1px solid #d4dfcf; }
#picker .flow-actions button:disabled { opacity: .5; }
#picker .flow-actions strong { flex: 1 1 auto; min-width: 0; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
#picker #clear { flex: 0 1 auto; }

/* Range, selection review and checkout use the same visual language. */
#picker .range-info, #picker #reviewStep .notice {
  margin: 0 0 16px;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: var(--purchase-soft-green);
  color: #123d20;
}
#picker .range-info h3, #picker #reviewStep .notice h2 { margin: 0 0 6px; color: #111b17; font-size: 20px; }
#picker .range-info p, #picker #reviewStep .notice p { margin: 0; line-height: 1.5; }
#picker #rangeHelp { color: #48554b; line-height: 1.5; }
#picker .dual-range { margin: 10px 2px; }
#picker .range-inputs { gap: 10px; }
#picker .range-inputs input { min-height: 44px; }
#picker #previewRange, #picker #addRange { width: 100%; min-height: 48px; margin: 8px 0; border-radius: 12px; background: var(--purchase-green); font-weight: 700; }
#picker #rangeResult:not(:empty) { padding: 14px; color: #174523; background: #eaf3e3; overflow-wrap: anywhere; }
#picker #selectedList { max-height: 38dvh; overflow: auto; margin-top: 14px; word-break: normal; }
#picker .chip { min-height: 42px; border-radius: 24px; background: #dff0d7; color: #00531d; font-weight: 700; }
#picker #reviewStep > h3 { margin-top: 20px; }
#picker #reviewStep > p { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; margin: 0; border-bottom: 1px solid var(--purchase-line); }
#picker #reviewStep > p:last-of-type { display: block; margin-top: 12px; padding: 12px; border: 0; border-radius: 10px; background: var(--purchase-soft-green); }
#picker #checkout > h2 { margin: 0 0 10px; font-size: 21px; }
#picker #checkoutSummary { padding: 12px; margin: 0 0 16px; border: 1px solid var(--purchase-line); border-radius: 10px; background: #fffaf5; line-height: 1.55; }
#picker #checkout .formgrid { display: grid; grid-template-columns: 1fr; gap: 12px; }
#picker #checkout fieldset { min-width: 0; margin: 0; padding: 14px; border: 1px solid #e7e1d8; border-radius: 12px; background: #fffaf5; }
#picker #checkout legend { padding: 0 5px; color: #152019; font-weight: 750; }
#picker #checkout label { font-size: 13px; font-weight: 600; }
#picker #checkout input, #picker #checkout textarea { min-height: 44px; padding: 10px; background: white; font-size: 16px; font-weight: 400; }
#picker #checkout textarea { min-height: 74px; resize: vertical; }
#picker #checkout .conflict-panel { margin-bottom: 16px; }
@media (max-height: 500px) {
  /* On short landscape/keyboard-sized viewports, controls scroll with the form. */
  #picker #checkout:focus-within .flow-actions { position: static; transform: none; width: auto; margin: 18px -15px -12px; }
}
@media (max-width: 340px) {
  #picker .flow-actions { padding-left: 8px; padding-right: 8px; gap: 5px; }
  #picker .flow-actions button { padding-left: 7px; padding-right: 7px; font-size: 12px; }
  #picker .numbers { gap: 5px; }
  .detail .detailart { height: 250px; }
}
