/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Backgrounds */
  --page-bg: #261a12;
  --header-bg: #261a12;
  --card-bg: #342319;
  --screen-bg: #261a12;
  --card-bg-selected: #3a2a1a;
  --card-bg-pressed: #b29e84;

  /* Text */
  --text-primary: #fff6e9;
  --text-muted: #b29e84;
  --text-price: #fff6e9;
  --text-on-header: #261a12;

  /* Card/tile text — separate from global text so light-bg tiles stay readable */
  --card-text: #b29e84;
  --card-text-price: #fff6e9;

  /* Brand */
  --accent: #b29e84;

  /* Section headings — independent of accent so they can be tuned separately */
  --category-heading: #fff6e9; /* HOT FIX, COLD FIX, SNACKS */
  --step-heading: #b29e84;     /* Choose your milk, Add extras, Your Order */

  /* Borders */
  --border: #a89480;
  --border-soft: #a89480;

  /* Card glow / border — shared colour for both the outer glow shadow and the flat border (glow-off mode) */
  --card-glow: #000000;
  --card-border-width: 1px;
  --steps-bar-padding: 45px;

  /* Primary action button (cart bar, sign-in CTAs) */
  --btn-primary-bg: #b29e84;
  --btn-primary-text: #201a14;
  --btn-primary-pressed: #b29e84;

  /* Pay button */
  --btn-pay-bg: #342319;
  --btn-pay-text: #fff6e9;
  --btn-pay-disabled-bg: #3d2e22;
  --btn-pay-disabled-text: #5a4a3a;
  --btn-pay-processing-bg: #5a4a3a;

  /* Header profile button */
  --profile-icon: #fff6e9;
  --profile-icon-border: #fff6e9;
  --profile-icon-active: #fff6e9;
  --profile-icon-active-bg: #342319;

  /* Steps bar */
  --step-active: #fff6e9;
  --step-done: #b29e84;
  --step-pending: #8c7a66;
  --step-num-done-text: #FFFFFF;

  /* Status / feedback */
  --success: #66bb6a;
  --success-strong: #5A9E5A;
  --success-bg: #3A6E3A;
  --warning: #b29e84;
  --error: #e57373;
  --error-strong: #E07A5F;
}

/* Fluid base font-size: scales rem units smoothly between 360px and 600px viewports.
   This keeps proportions consistent across every phone size. */
html {
  font-size: clamp(15px, 4.2vw, 18px);
  -webkit-text-size-adjust: 100%; /* prevent iOS landscape auto-zoom */
  text-size-adjust: 100%;
}

html, body {
  height: 100%;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--page-bg);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior-y: contain; /* stop bounce-scroll exposing background */
}

/* Cross-platform form-control safety net:
   - inherit Montserrat (iOS Safari otherwise falls back to its system font)
   - >=16px font-size so iOS Safari doesn't auto-zoom on focus
   Specific rules below can still override these. */
input, select, textarea, button {
  font-family: inherit;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]):not([type="file"]),
select,
textarea {
  font-size: max(16px, 1rem);
}

/* === APP LAYOUT === */
#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
  box-shadow: 0 0 40px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.15s ease-in;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

#app.theme-ready,
:root.theme-ready #app {
  opacity: 1;
}

/* Hide scrollbar in theme preview iframe */
html:has(#app.theme-ready),
body:has(#app.theme-ready) {
  scrollbar-width: none;
}
html:has(#app.theme-ready)::-webkit-scrollbar,
body:has(#app.theme-ready)::-webkit-scrollbar {
  display: none;
}

/* === HEADER === */
#header {
  padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
  background: var(--header-bg);
  color: var(--text-on-header);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: visible;
}

#header-logo {
  /* Scales from ~60px on narrow phones up to the admin-configured --logo-height (default 120px) */
  height: clamp(60px, 20vw, var(--logo-height, 120px));
  width: auto;
  object-fit: contain;
  border-radius: 6px;
  display: block;
  flex-shrink: 0;
}

#header h1 {
  font-size: 1.3rem;
  font-weight: 700;
}

/* === STEPS BAR === */
#steps-bar {
  counter-reset: step-counter;
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-soft);
  padding-top: var(--steps-bar-padding, 45px);
  background: linear-gradient(to bottom, var(--header-bg) 0%, var(--page-bg) var(--steps-bar-padding, 45px), var(--screen-bg) 100%);
}

#steps-bar .step {
  counter-increment: step-counter;
}

/* ── Gradient feature flags ───────────────────────────────── */
/* Steps bar fade OFF — hard fill: header-bg for the top padding area, card-bg below */
.grad-steps-bar-off #steps-bar {
  background: linear-gradient(to bottom, var(--header-bg) var(--steps-bar-padding, 45px), var(--screen-bg) var(--steps-bar-padding, 45px));
}

/* Page top tint ON */
.grad-page-tint body,
.grad-page-tint #app {
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--header-bg) 50%, var(--page-bg)) 0%,
    var(--page-bg) 35%);
}

/* Card inner highlight ON */
.grad-cards .item-card:not(.selected) {
  background: linear-gradient(150deg,
    color-mix(in srgb, var(--card-bg) 70%, white) 0%,
    var(--card-bg) 100%);
}
.grad-cards .item-card.selected {
  background: linear-gradient(150deg,
    color-mix(in srgb, var(--card-bg-selected) 70%, white) 0%,
    var(--card-bg-selected) 100%);
}

/* Cart bar fade ON — ghost-gradient bleeds up above the bar */
.grad-cart-bar .cart-bar {
  background: transparent;
}
.grad-cart-bar .cart-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  top: -56px;
  background: linear-gradient(to bottom, transparent 0%, var(--card-bg) 56px);
  pointer-events: none;
  z-index: -1;
}

/* Card glow OFF — replace outer glow with a subtle border so cards stay defined */
.grad-card-glow-off .item-card {
  box-shadow: none;
  border: var(--card-border-width, 1px) solid var(--card-glow);
}
.grad-card-glow-off .item-card.selected {
  border-color: var(--accent);
}
/* ────────────────────────────────────────────────────────── */

#steps-bar .step {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--step-pending);
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

#steps-bar .step.active {
  color: var(--step-active);
  border-bottom-color: var(--step-active);
}

#steps-bar .step.done {
  color: var(--step-done);
  border-bottom-color: var(--step-done);
}

.step-num {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid color-mix(in srgb, var(--step-pending) 60%, transparent);
  vertical-align: middle;
  margin-right: 3px;
  margin-bottom: 1px;
}

.step.active .step-num { border-left-color: var(--step-active); }
.step.done   .step-num { border-left-color: var(--step-done); }

/* === Numbers mode === */
.step-numbers .step-num {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--step-pending) 30%, transparent);
  line-height: 18px;
  font-size: 0.65rem;
  text-align: center;
  color: var(--step-pending);
  margin-bottom: 0;
}
.step-numbers .step-num::before {
  content: counter(step-counter);
}
.step-numbers .step.active .step-num { background: var(--step-active); color: var(--card-bg); }
.step-numbers .step.done   .step-num { background: var(--step-done);   color: var(--card-bg); }

/* === MAIN === */
#main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* === STEP PANELS === */
.step-panel {
  display: none;
  padding: 20px;
}

.step-panel.active {
  display: block;
}

.step-panel h2 {
  font-size: 1.15rem;
  color: var(--step-heading);
  margin-bottom: 16px;
}

.optional {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* === STORE CLOSED BANNER === */
.store-closed-banner {
  background: color-mix(in srgb, var(--error) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--error) 30%, transparent);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.store-closed-banner p {
  margin: 0;
  color: var(--error);
  font-weight: 700;
  font-size: 1.05rem;
}

.store-closed-hours {
  font-weight: 400 !important;
  font-size: 0.85rem !important;
  color: var(--text-muted) !important;
  margin-top: 6px !important;
}

.store-closed-preorder {
  font-weight: 500 !important;
  font-size: 0.9rem !important;
  color: var(--accent) !important;
  margin-top: 8px !important;
}

/* Store closed with no pre-order slots: hide the entire ordering flow so the
   only thing shown is the "We're closed" message. */
.orders-disabled #steps-bar,
.orders-disabled #step-menu > h2,
.orders-disabled #reorder-section,
.orders-disabled .menu-type-section,
.orders-disabled #cart-bar {
  display: none !important;
}
.orders-disabled .store-closed-banner {
  margin-top: 32px;
  padding: 28px 20px;
}
.orders-disabled .store-closed-banner p {
  font-size: 1.2rem;
}

/* === REORDER SECTION === */
.reorder-section {
  margin-bottom: 20px;
  text-align: center;
}

.reorder-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px 0;
}

.reorder-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 10px;
  justify-content: center;
}

/* Allow scrolling left when cards overflow */
.reorder-list:has(.reorder-card:nth-child(3)) {
  justify-content: flex-start;
}

.reorder-list::-webkit-scrollbar {
  height: 4px;
}
.reorder-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

.reorder-card {
  flex: 0 0 auto;
  scroll-snap-align: center;
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 16px 20px 14px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  min-width: 160px;
  max-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s;
}

.reorder-card:active {
  border-color: var(--accent);
  transform: scale(0.97);
}

.reorder-card-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reorder-item {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.reorder-detail {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 1px;
}

.reorder-btn-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* === MENU TYPE SECTIONS === */
.menu-type-section {
  margin-bottom: 24px;
}

.menu-type-section h3 {
  font-size: 1.2rem;
  margin-bottom: 10px;
  color: var(--category-heading);
}

/* === ITEM GRID === */
/* Fluid grid: tiles always sit between ~120px and ~160px wide and fill the row.
   Result: same visual button size across iPhone SE through Pro Max. */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
  gap: 12px;
}

.item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 10px;
  background: var(--card-bg);
  border: none;
  /* Large border-radius rounds the channel intersections, breaking the
     geometric condition required for the Hermann grid illusion. */
  border-radius: 28px;
  box-shadow: 0 0 12px 6px color-mix(in srgb, var(--card-glow) 45%, transparent);
  cursor: pointer;
  transition: transform 0.15s;
  min-height: 80px;
  text-align: center;
  user-select: none;
}

.item-card:active,
.item-card.pressed {
  opacity: 0.7;
}

.item-card.selected {
  background: var(--card-bg-selected);
  /* Pressed-in look: inset dark shadow on top edge + accent ring,
     no outer glow, drop the resting drop-shadow. */
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.55),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04),
    inset 0 0 0 2px var(--accent);
  transform: translateY(1px);
}

.item-card.selected .item-name {
  color: var(--card-text-selected, var(--accent));
}

.item-card.selected .item-price {
  color: var(--card-text-price-selected, #f5e6c8);
}

.item-card .item-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--card-text);
  margin-bottom: 4px;
}

.item-card .item-desc {
  font-size: 0.75rem;
  color: var(--card-text-price);
  opacity: 0.8;
  margin-bottom: 4px;
  line-height: 1.3;
}

.item-card {
  position: relative;
}

.item-info-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--card-text-price);
  background: transparent;
  color: var(--card-text-price);
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.7;
  padding: 0;
  transition: opacity 0.15s, background 0.15s;
}

.item-info-btn:hover,
.item-info-btn:active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.item-card.selected .item-info-btn {
  border-color: var(--card-text-price-selected, #f5e6c8);
  color: var(--card-text-price-selected, #f5e6c8);
}

.gf-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #ffffff;
  background-color: #2e8b57;
  border: 1.5px solid #2e8b57;
  border-radius: 4px;
  padding: 1px 4px;
  line-height: 1.4;
  pointer-events: none;
}

.item-card.selected .gf-badge {
  color: #ffffff;
  background-color: #2e8b57;
  border-color: #2e8b57;
}

.item-info-card {
  text-align: center;
  max-width: 380px;
}

.item-info-name {
  margin: 0 0 12px 0;
  color: var(--accent);
}

.item-info-desc {
  margin: 0;
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
}

.item-card .item-price {
  font-size: 0.82rem;
  color: var(--card-text-price);
  font-weight: 600;
}

.item-card .item-price.free {
  color: var(--card-text-price);
  opacity: 0.6;
}

/* === BUTTONS === */
.btn-primary {
  padding: 14px 28px;
  background: var(--card-bg);
  color: var(--accent);
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  text-align: center;
}

.btn-primary:active { background: var(--card-bg-pressed); }

.btn-back {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 20px;
  background: var(--card-bg) !important;
  border: 2px solid var(--card-bg) !important;
  border-radius: 8px;
  color: var(--accent) !important;
  -webkit-text-fill-color: var(--accent) !important;
  opacity: 1 !important;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}

.btn-skip {
  padding: 14px 28px;
  background: var(--card-bg) !important;
  border: 2px dashed var(--accent) !important;
  border-radius: 10px;
  color: var(--accent) !important;
  -webkit-text-fill-color: var(--accent) !important;
  opacity: 1 !important;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}

.step-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.step-actions .btn-back { margin-top: 0; flex: 1; }
.step-actions .btn-skip { flex: 1; }
.step-actions .btn-primary { flex: 1 1 100%; }

.btn-add-more {
  display: block;
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  margin: 16px 0;
  min-height: 44px;
}

.btn-add-more:active { border-color: var(--accent); color: var(--accent); }

/* === CART ITEMS === */
.cart-item {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
  border: 1px solid var(--border);
}

.cart-item-actions {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-item-edit,
.cart-item-remove {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.cart-item-edit {
  color: var(--accent);
}

.cart-item-remove {
  color: var(--text-muted);
}

.cart-item-edit:active { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.cart-item-remove:active { color: var(--error); background: color-mix(in srgb, var(--error) 15%, transparent); }

.cart-item-row {
  padding-right: 70px;
}

/* Quantity steppers (Extras step + cart lines) — themed to match the buttons */
.qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid var(--accent) !important;
  background: var(--card-bg) !important;
  color: var(--accent) !important;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  -webkit-text-fill-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
}
.qty-btn:active { background: var(--card-bg-pressed); color: var(--btn-primary-text); -webkit-text-fill-color: var(--btn-primary-text); }
.qty-val {
  min-width: 28px;
  text-align: center;
  font-weight: 800;
  font-size: 18px;
  color: var(--text-primary);
}
.extras-qty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 14px 0 4px;
}
.extras-qty-label {
  font-weight: 700;
  color: var(--text-primary);
  margin-right: 4px;
}
.cart-qty {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.cart-qty .qty-btn { width: 36px; height: 36px; font-size: 20px; }
.cart-qty .qty-val { min-width: 22px; }

.cart-item-name {
  font-weight: 700;
  color: var(--text-primary);
}

.cart-item-price {
  font-weight: 700;
  color: var(--text-price);
  font-size: 0.95rem;
  margin-top: 2px;
}

.cart-item-details {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.cart-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-primary);
}

/* === CHECKOUT === */
#checkout-section {
  margin-top: 8px;
  border-top: 2px solid var(--border);
  padding-top: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  /* >=16px keeps iOS Safari from auto-zooming on focus */
  font-size: max(16px, 1rem);
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text-primary);
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23c9a96e' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-group input:focus,
.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--text-price);
}

.form-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 6px;
}

#order-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 16px 0;
  border-top: 2px solid var(--border);
  margin-bottom: 16px;
}

#total-amount {
  color: var(--accent);
}

.square-payment-note {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary, #888);
  margin-bottom: 12px;
  padding: 8px;
}

/* Wallet Pay (Apple Pay / Google Pay) */
#wallet-pay-section {
  margin-bottom: 12px;
}

.wallet-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.wallet-divider::before,
.wallet-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

#apple-pay-btn {
  -apple-pay-button-style: white;
  -apple-pay-button-type: plain;
  display: block;
  width: 100%;
  height: 48px;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 8px;
  appearance: -apple-pay-button;
  -webkit-appearance: -apple-pay-button;
}

#google-pay-btn {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
}

#google-pay-btn button {
  border-radius: 12px !important;
}

.btn-pay {
  width: 100%;
  padding: 18px;
  background: var(--btn-pay-bg);
  color: var(--btn-pay-text);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 56px;
  transition: background 0.15s, border-color 0.15s;
}

.btn-pay:disabled,
.btn-pay.processing {
  border-color: transparent;
}

.btn-pay:disabled {
  background: var(--btn-pay-disabled-bg);
  color: var(--btn-pay-disabled-text);
  cursor: not-allowed;
}

.btn-pay:not(:disabled):active {
  background: var(--card-bg-pressed);
}

.btn-pay.processing {
  background: var(--btn-pay-processing-bg);
  cursor: wait;
}

.error-msg {
  color: var(--error-strong);
  text-align: center;
  padding: 10px;
  font-size: 0.9rem;
  margin-top: 8px;
}

.error-msg.hidden { display: none; }

/* === CONFIRMATION === */
.confirmation-card {
  text-align: center;
  padding: 40px 20px;
}

.confirmation-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.confirmation-icon.processing {
  width: 44px;
  height: 44px;
  margin: 0 auto 24px;
  border: 4px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: payment-spin 0.8s linear infinite;
}

@keyframes payment-spin {
  to { transform: rotate(360deg); }
}

/* === WALLET PAYMENT GUARD ===
   Covers the complete Apple Pay handoff, including the period after the
   native sheet closes but before Square returns the payment token. */
body.wallet-finishing-active {
  overflow: hidden;
}

.wallet-finishing-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    calc(28px + env(safe-area-inset-top))
    calc(24px + env(safe-area-inset-right))
    calc(28px + env(safe-area-inset-bottom))
    calc(24px + env(safe-area-inset-left));
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--card-bg) 82%, transparent), transparent 58%),
    var(--page-bg);
  color: var(--text-primary);
  text-align: center;
}

.wallet-finishing-card {
  width: min(100%, 430px);
}

.wallet-finishing-brand {
  margin-bottom: clamp(42px, 10vh, 80px);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.wallet-finishing-spinner {
  width: 54px;
  height: 54px;
  margin: 0 auto 30px;
  border: 5px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: payment-spin 0.8s linear infinite;
}

.wallet-finishing-overlay h2 {
  color: var(--text-primary);
  font-size: clamp(1.45rem, 6.4vw, 1.9rem);
  line-height: 1.18;
}

.wallet-finishing-stay {
  margin-top: 14px;
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 800;
}

#wallet-finishing-message {
  max-width: 340px;
  margin: 14px auto 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  .wallet-finishing-spinner {
    animation-duration: 1.8s;
  }
}

.confirm-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  margin: 12px 0;
}

.confirm-details {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.6;
}

/* === FLOATING CART BAR === */
.cart-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--card-bg);
  border-top: 2px solid var(--accent);
  z-index: 1000;
  animation: cartBarSlideUp 0.25s ease-out;
}

@keyframes cartBarSlideUp {
  from { transform: translateX(-50%) translateY(100%); }
  to { transform: translateX(-50%) translateY(0); }
}

.cart-bar-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 18px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.cart-bar-btn:active {
  background: var(--btn-primary-pressed);
}

.cart-bar-icon {
  font-size: 1.2rem;
}

.cart-bar-summary {
  flex: 1;
  text-align: center;
}

.cart-bar-arrow {
  font-size: 0.9rem;
  opacity: 0.7;
}

.item-card.added {
  background: var(--card-bg-selected);
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.55),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04),
    inset 0 0 0 2px var(--accent);
  transform: translateY(1px);
  transition: all 0.15s;
}

.item-card.added .item-name {
  color: var(--card-text-selected, var(--accent));
}

.item-card.added .item-price {
  color: var(--card-text-price-selected, #f5e6c8);
}

/* Add bottom padding to main when cart bar is visible */
#main.has-cart-bar {
  padding-bottom: 90px;
}

/* === HIDDEN === */
.hidden { display: none !important; }

/* === TOAST === */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg);
  color: var(--accent);
  padding: 12px 24px;
  border-radius: 28px;
  box-shadow: 0 0 12px 6px color-mix(in srgb, var(--card-glow) 45%, transparent);
  font-weight: 600;
  text-align: center;
  max-width: calc(100% - 40px);
  width: max-content;
  word-wrap: break-word;
  overflow-wrap: break-word;
  z-index: 9999;
  animation: toastIn 0.3s;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === RESPONSIVE === */
/* Item grid is fully fluid via auto-fill; no breakpoint override needed. */

/* === HEADER ACCOUNT BUTTON === */
.header-account-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 2px solid var(--profile-icon-border);
  border-radius: 50%;
  /* Scales from 32px (minimum touch target) up to 44px */
  width: clamp(32px, 7vw, 44px);
  height: clamp(32px, 7vw, 44px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--profile-icon);
  transition: all 0.15s;
}

.header-account-btn svg {
  width: clamp(16px, 3.8vw, 24px);
  height: clamp(16px, 3.8vw, 24px);
}

.header-account-btn:active {
  background: color-mix(in srgb, var(--profile-icon) 10%, transparent);
}

.header-account-btn.logged-in {
  border-color: var(--profile-icon-active);
  color: var(--profile-icon-active);
  background: var(--profile-icon-active-bg);
}

#header {
  position: relative;
}

/* === ACCOUNT MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--screen-bg, #201A14);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  position: relative;
  border: 1px solid var(--border);
}

.modal-card h3 {
  font-size: 1.2rem;
  color: var(--accent);
  margin-bottom: 20px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

.auth-toggle-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.auth-toggle-text a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.account-username {
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.btn-logout {
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 10px;
}

.btn-logout:active {
  border-color: var(--error-strong);
  color: var(--error-strong);
}

.auth-forgot-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.auth-forgot-text a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.reset-info {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

#account-reset-password h3 {
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 12px;
}

#reset-back {
  display: inline-block;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-top: 12px;
  font-family: inherit;
}

/* === MY ORDERS === */
.order-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.order-card-number {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.order-card-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.status-ok {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
}

.status-pending {
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  color: var(--warning);
}

.status-bad {
  background: color-mix(in srgb, var(--error) 15%, transparent);
  color: var(--error);
}

.order-card-items {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.order-card-pickup {
  font-size: 0.8rem;
  color: var(--text-price);
  margin-bottom: 8px;
}

.order-card-refund {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: inline-block;
}

.order-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.order-card-total {
  font-weight: 700;
  color: var(--text-price);
  font-size: 0.95rem;
}

.order-card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.order-cancel-btn {
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  border: 2px solid var(--error);
  border-radius: 8px;
  background: color-mix(in srgb, var(--error) 10%, transparent);
  color: var(--error);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.order-cancel-btn:hover {
  background: color-mix(in srgb, var(--error) 25%, transparent);
}
.order-cancel-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* === PRE-ORDER SIGN-IN PROMPT === */
.preorder-signin {
  text-align: center;
  padding: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

.preorder-signin p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.btn-preorder-signin {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-preorder-signin:active {
  opacity: 0.85;
}

/* === LOGGED-IN BANNER === */
.logged-in-banner {
  background: var(--screen-bg);
  border-bottom: 1px solid var(--border-soft);
  text-align: center;
  padding: 6px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.logged-in-banner strong {
  color: var(--accent);
  font-weight: 700;
}

/* === KEEP CUP SECTION === */
.keepcup-toggle {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.keepcup-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  -webkit-text-fill-color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}

.keepcup-btn.keepcup-active {
  background: var(--card-bg);
  border-color: var(--accent);
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
}

#keepcup-color-group {
  margin-top: 10px;
}

#keepcup-color-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text-primary);
  font-family: inherit;
  /* >=16px keeps iOS Safari from auto-zooming on focus */
  font-size: max(16px, 0.95rem);
}

#keepcup-color-group input:focus {
  outline: none;
  border-color: var(--accent);
}

/* === SIZE MODAL === */
.size-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s;
}

.size-modal.hidden { display: none; }

.size-modal-inner {
  background: var(--card-bg, #201A14);
  border-radius: 16px;
  padding: 32px 24px 24px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--border);
}

.size-modal-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin: 0;
}

.size-options {
  display: flex;
  gap: 16px;
  width: 100%;
}

.size-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.size-btn:hover, .size-btn:active {
  border-color: var(--accent);
  background: rgba(255,255,255,0.1);
}

.size-label {
  font-size: 1rem;
  font-weight: 600;
}

.size-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.cart-item-size {
  font-size: 0.8em;
  opacity: 0.7;
  font-weight: 400;
  text-transform: capitalize;
}

/* === ADD TO HOME SCREEN BANNER === */
.a2hs-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  width: 100%;
  max-width: 600px;
  background: var(--card-bg, #201A14);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 3999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.a2hs-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.a2hs-banner.above-cart {
  bottom: auto;
}

.a2hs-banner.hidden { display: none; }

.a2hs-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.a2hs-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}

.a2hs-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.a2hs-text strong {
  font-size: 0.82rem;
  color: var(--text-primary);
}

.a2hs-text span {
  font-size: 0.72rem;
  color: var(--text-muted, #6b5d4f);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.a2hs-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.a2hs-btn-install {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.a2hs-btn-install.hidden { display: none; }

.a2hs-btn-dismiss {
  background: none;
  border: none;
  color: var(--text-muted, #6b5d4f);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
