:root {
  --ink: #112a2a;
  --surface: #f8faf7;
  --panel: #ffffff;
  --brand: #0f8a64;
  --brand-2: #16b07a;
  --accent: #f2c14e;
  --muted: #6b7b7b;
  --line: #d9e6df;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #e8f7ef 0%, #f6f5eb 45%, #eef6f8 100%);
  min-height: 100vh;
  min-height: 100dvh;
}

body.modal-open {
  overflow: hidden;
}

.bg-shape {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(50px);
  opacity: 0.45;
}
.shape-1 { width: 320px; height: 320px; background: #6ad4ad; top: -60px; left: -40px; }
.shape-2 { width: 300px; height: 300px; background: #ffd97a; bottom: -80px; right: -40px; }

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 34px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(17, 42, 42, 0.08);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(17, 42, 42, 0.08);
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.small-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 14px;
}

.cart-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ff6b57;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  padding: 0 6px;
  border: 2px solid #fff;
}

.cart-badge.is-empty {
  display: none;
}

.user-menu-wrap {
  position: relative;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(280px, calc(100vw - 32px));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(17, 42, 42, 0.08);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(17, 42, 42, 0.14);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.menu-action {
  width: 100%;
  text-align: left;
}

.menu-action.danger {
  color: #8f1f1f;
}

.menu-select-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.menu-select-label select {
  color: var(--ink);
  font-weight: 600;
  background: #fff;
}

.hidden {
  display: none !important;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 10px 35px rgba(17, 42, 42, 0.08);
  margin-bottom: 14px;
  animation: rise 320ms ease;
}

@keyframes rise {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.step { display: none; }
.step.active { display: block; }
.chat-layout.step.active {
  display: flex;
  flex: 1;
  min-height: 0;
}

h2 { margin-top: 0; font-size: 20px; }

.chat-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chat-tools {
  display: flex;
  gap: 8px;
}

.chat-version-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eef7f3;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.chat-version-toggle span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-version-toggle select {
  min-width: 72px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.chat-title-row h2 {
  margin-bottom: 0;
}

.row, .grid-2 { display: grid; gap: 10px; }
.row { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

input, select, button {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 12px;
  font-size: 14px;
}

button {
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  border: 0;
  font-weight: 700;
}

button.ghost {
  background: #eef7f3;
  color: var(--ink);
  border: 1px solid var(--line);
}

.store-list {
  display: grid;
  gap: 10px;
}
.store-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-layout {
  min-height: 0;
}

.chat-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
}

.messages {
  height: auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fbfdfb;
}
.msg {
  max-width: 85%;
  padding: 10px 12px;
  margin: 8px 0;
  border-radius: 14px;
}
.msg.user { margin-left: auto; background: #d7f3e7; }
.msg.assistant { background: #f2f7f4; }
.msg.assistant.with-carousel {
  max-width: 100%;
  overflow: hidden;
}
.selection-msg,
.payment-msg,
.cart-msg {
  max-width: 100%;
}

.selection-msg {
  width: 100%;
  min-width: 0;
}

.panel-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}

.selection-panel-title {
  color: #0f8a64;
}

.ingredient-section-title {
  margin-top: 20px;
}

.ingredient-group-label {
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-top: 12px;
  margin-bottom: 4px;
}

.assistant-paragraph {
  margin: 0;
  white-space: pre-line;
}

.assistant-paragraph + .assistant-paragraph {
  margin-top: 8px;
}

.assistant-list {
  margin: 0;
  padding-left: 20px;
}

.assistant-list + .assistant-list,
.assistant-paragraph + .assistant-list,
.assistant-list + .assistant-paragraph {
  margin-top: 8px;
}

.assistant-list li {
  margin: 4px 0;
}

.assistant-product-carousel {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: thin;
  padding: 4px 2px 8px;
  scroll-snap-type: x mandatory;
}

.assistant-carousel-shell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.assistant-carousel-shell .assistant-product-carousel {
  flex: 1;
  min-width: 0;
}

.assistant-carousel-nav {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #1b2d2a;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
}

.assistant-product-card {
  min-width: 220px;
  max-width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(17, 42, 42, 0.12);
  scroll-snap-align: start;
}

.assistant-product-card-large {
  min-width: min(100%, 720px);
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
}

.assistant-product-image {
  width: 100%;
  height: 150px;
  object-fit: contain;
  display: block;
  background: linear-gradient(180deg, #f9fcfb 0%, #eef5f1 100%);
}

.assistant-product-image-large {
  height: 280px;
}

.assistant-product-image-placeholder {
  width: 100%;
  height: 150px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  background: linear-gradient(180deg, #f9fcfb 0%, #eef5f1 100%);
}

.assistant-product-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.assistant-product-body-large {
  align-content: start;
  padding: 18px;
  gap: 12px;
}

.assistant-product-rank {
  width: fit-content;
  font-size: 11px;
  font-weight: 800;
  color: #0b5b43;
  border-radius: 999px;
  border: 1px solid #bce8d6;
  background: #d7f3e7;
  padding: 2px 8px;
}

.assistant-product-meta {
  width: fit-content;
  font-size: 11px;
  font-weight: 700;
  color: #355a54;
  background: #eef7f3;
  border: 1px solid #d9e6df;
  border-radius: 999px;
  padding: 2px 8px;
}

.assistant-product-title {
  font-size: 13px;
  line-height: 1.25;
  max-height: 3.8em;
  overflow: hidden;
}

.assistant-product-title-large {
  font-size: 20px;
  max-height: none;
}

.assistant-product-price {
  font-size: 13px;
  font-weight: 800;
  color: #0f8a64;
}

.assistant-product-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.assistant-product-price-old {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: line-through;
}

.assistant-product-pick {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.assistant-product-controls {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  gap: 8px;
  align-items: center;
}

.assistant-product-step {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  padding: 0;
}

.assistant-product-qty {
  text-align: center;
  font-weight: 800;
  color: #0f8a64;
  font-size: 16px;
}

.assistant-link {
  color: #0f8a64;
  text-decoration: underline;
  word-break: break-all;
}

.assistant-image-preview {
  display: block;
  margin-top: 8px;
  max-width: min(320px, 100%);
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.chat-composer {
  position: sticky;
  bottom: 0;
  margin-top: 10px;
  padding: 10px 0 calc(env(safe-area-inset-bottom, 0px) + 2px);
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.92) 18%, rgba(255,255,255,0.98) 100%);
}

.chat-input {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(17, 42, 42, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(17, 42, 42, 0.12);
}

.voice-btn {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  padding: 12px;
}

.voice-btn svg {
  width: 20px;
  height: 20px;
}

.voice-btn.is-listening {
  background: linear-gradient(135deg, #c85f38, #df7b55);
  color: #fff;
  border-color: rgba(200, 95, 56, 0.35);
}

.voice-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.cart-summary {
  display: grid;
  gap: 12px;
}

.cart-summary-overlay {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.cart-summary-panel {
  background: linear-gradient(180deg, #fffef9 0%, #f4fbf8 100%);
  border: 1px solid #dce9e0;
  border-radius: 20px;
  padding: 16px;
}

.cart-summary-panel-chat {
  background: linear-gradient(180deg, #fff8ea 0%, #fffdf7 100%);
}

.cart-panel-title {
  color: #9d5a00;
}

.cart-items {
  display: grid;
  gap: 10px;
  max-height: min(65vh, 700px);
  overflow-y: auto;
  padding-right: 2px;
}

.cart-items-chat {
  max-height: none;
}

.cart-product-card {
  min-width: 0;
  max-width: none;
}

.cart-product-card .assistant-product-image,
.cart-product-card .assistant-product-image-placeholder {
  height: 120px;
}

.cart-line-total {
  font-size: 12px;
  font-weight: 700;
  color: #1f5f4b;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

.cart-subtotal {
  font-size: 15px;
  font-weight: 800;
  color: #0f8a64;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 8px;
}

.cart-summary-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.cart-summary-row:last-of-type {
  font-size: 17px;
}

.cart-shipping-hint {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff7df;
  color: #7c5307;
  font-size: 13px;
  font-weight: 700;
}

.checkout-order-button,
.stripe-pay-button {
  width: 100%;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 800;
}

.checkout-order-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  background: #c9d8d1;
  color: #375048;
}

.payment-panel-title {
  color: #125ea8;
}

.payment-summary-card {
  padding: 14px;
  border: 1px solid #d8e4f4;
  border-radius: 16px;
  background: linear-gradient(180deg, #f7fbff 0%, #eef6ff 100%);
}

.stripe-pay-button {
  background: linear-gradient(135deg, #635bff, #0a2540);
}

.assistant-single-product-stage {
  display: grid;
  gap: 10px;
}

.cart-empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  background: #f8fcfa;
}

.cart-msg {
  max-width: 100%;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 18, 0.42);
  backdrop-filter: blur(10px);
}

.overlay-panel {
  position: relative;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #f8faf7 0%, #eef6f1 100%);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 18px;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.overlay-header h2 {
  margin: 0;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 8px 0 12px;
    margin-bottom: 10px;
    background: linear-gradient(180deg, rgba(246,245,235,0.98) 0%, rgba(246,245,235,0.92) 72%, rgba(246,245,235,0) 100%);
    backdrop-filter: blur(12px);
  }

  .row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .chat-layout.step.active {
    flex: 1;
  }
  .chat-card {
    border-radius: 24px;
  }
  .messages {
    padding: 12px;
  }
  .assistant-carousel-nav {
    width: 26px;
    height: 26px;
    font-size: 16px;
  }
  .assistant-product-card-large {
    grid-template-columns: 1fr;
  }
  .assistant-product-image-large {
    height: 220px;
  }
  .assistant-product-card {
    min-width: min(78vw, 220px);
    max-width: min(78vw, 220px);
  }

  .chat-input {
    grid-template-columns: 1fr auto auto;
    align-items: center;
  }

  .chat-input input {
    min-width: 0;
  }

  .overlay-panel {
    padding: 14px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  }

  .user-menu-panel {
    width: min(300px, calc(100vw - 24px));
  }
}
