:root {
  --bg: #f6f2ea;
  --bg-2: #e9e1d3;
  --panel: rgba(255, 251, 245, 0.9);
  --line: rgba(166, 145, 121, 0.35);
  --line-strong: rgba(138, 119, 99, 0.55);
  --text: #2e2a25;
  --muted: #6f6358;
  --accent: #5f7357;
  --accent-soft: #7f946f;
  --accent-ink: #f8f5ef;
  --good: #45623f;
  --warn: #a06a43;
  --shadow: rgba(72, 49, 28, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at -10% -12%, #f1e9dd 0%, transparent 52%),
    radial-gradient(1100px 740px at 115% -10%, #e6dccd 0%, transparent 48%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
}

.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    linear-gradient(rgba(170, 146, 120, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(170, 146, 120, 0.08) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(circle at 52% 30%, #000 0%, transparent 76%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 20px clamp(16px, 3vw, 34px) 12px;
}

.brand-block {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-block h1 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  font-size: clamp(1.35rem, 2.5vw, 2.1rem);
  letter-spacing: 0.01em;
  font-weight: 600;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.layout {
  display: block;
  padding: 0 clamp(16px, 3vw, 34px) 18px;
  padding-right: calc(clamp(16px, 3vw, 34px) + clamp(280px, 32vw, 410px) + 18px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 26px var(--shadow);
}

.catalog {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-head h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  font-size: 1.12rem;
  font-weight: 600;
}

.search-wrap input {
  width: min(240px, 46vw);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font: inherit;
}

.search-wrap input::placeholder {
  color: var(--muted);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.86);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.product-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 10px;
}

.product-card {
  border: 1px solid rgba(167, 147, 123, 0.28);
  border-radius: 12px;
  padding: 10px;
  background: #fffdf9;
  display: grid;
  gap: 10px;
  overflow: hidden;
}

.product-image-wrap {
  margin: -10px -10px 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-bottom: 1px solid rgba(167, 147, 123, 0.2);
  background: linear-gradient(180deg, #f3ecdf 0%, #ece2d2 100%);
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.product-card:hover .product-image {
  transform: scale(1.045);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.product-category {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.product-name {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.3;
}

.product-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  min-height: 30px;
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.price {
  margin: 0;
  font-weight: 700;
}

.add-btn,
.primary-btn,
.ghost-btn,
.qty-btn,
.pill-action {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.add-btn:disabled,
.primary-btn:disabled,
.ghost-btn:disabled,
.qty-btn:disabled,
.pill-action:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.add-btn,
.primary-btn,
.pill-action {
  border: 1px solid var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-soft) 100%);
}

.add-btn:hover,
.primary-btn:hover,
.pill-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(95, 115, 87, 0.24);
}

.add-btn,
.pill-action {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.primary-btn {
  width: 100%;
  padding: 12px 14px;
}

.ghost-btn,
.qty-btn {
  background: rgba(255, 251, 245, 0.84);
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost-btn:hover,
.qty-btn:hover {
  border-color: var(--line-strong);
}

.ghost-btn {
  padding: 6px 12px;
}

.basket {
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto minmax(140px, 1fr) auto auto;
  gap: 12px;
  position: fixed;
  top: 84px;
  right: clamp(16px, 3vw, 34px);
  width: clamp(280px, 32vw, 410px);
  bottom: 84px;
  height: auto;
  max-height: none;
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.25s ease;
  z-index: 6;
}

.basket-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.basket-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.basket-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.basket-item {
  border: 1px solid rgba(166, 145, 121, 0.32);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  background: #fffdf8;
}

.item-name {
  margin: 0;
  font-size: 0.9rem;
}

.item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.item-price {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.qty-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qty-btn {
  width: 26px;
  height: 26px;
  padding: 0;
}

.qty-number {
  min-width: 18px;
  text-align: center;
  font-size: 0.86rem;
}

.suggestions h3 {
  margin: 0 0 8px;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  font-size: 0.94rem;
  font-weight: 600;
}

.suggestions-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.suggestion-pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--muted);
}

.totals {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: grid;
  gap: 8px;
}

.line-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
}

.line-item strong {
  color: var(--text);
}

.grand-total {
  font-size: 1.07rem;
}

.grand-total strong {
  color: var(--accent);
}

.empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.ai-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  z-index: 18;
}

.ai-backdrop.is-open {
  opacity: 0;
  pointer-events: none;
}

.ai-builder {
  position: fixed;
  right: 14px;
  bottom: 72px;
  width: min(500px, calc(100vw - 28px));
  max-height: calc(100dvh - 92px);
  padding: 14px;
  display: grid;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.ai-builder.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ai-builder-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.ai-builder-head h2 {
  margin: 2px 0 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  font-size: 1.12rem;
}

.ai-close-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 251, 245, 0.84);
  color: var(--text);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-close-btn:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.ai-close-btn:focus-visible {
  outline: 2px solid rgba(95, 115, 87, 0.35);
  outline-offset: 2px;
}

.ai-helper {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.ai-chat-log {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  min-height: 220px;
  max-height: min(45vh, 360px);
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.ai-msg {
  margin: 0;
  max-width: 88%;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 0.86rem;
  line-height: 1.4;
}

.ai-msg-user {
  justify-self: end;
  background: rgba(95, 115, 87, 0.16);
  border: 1px solid rgba(95, 115, 87, 0.35);
}

.ai-msg-bot {
  justify-self: start;
  background: rgba(166, 145, 121, 0.14);
  border: 1px solid rgba(166, 145, 121, 0.35);
}

.ai-rec-wrap {
  display: grid;
  gap: 7px;
}

.ai-rec-title {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ai-rec-item {
  display: grid;
  gap: 2px;
  text-align: left;
  border: 1px solid rgba(166, 145, 121, 0.4);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.ai-rec-item:hover {
  border-color: rgba(95, 115, 87, 0.5);
  transform: translateY(-1px);
}

.ai-rec-name {
  font-size: 0.84rem;
  font-weight: 700;
}

.ai-rec-reason {
  font-size: 0.77rem;
  color: var(--muted);
}

.ai-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.ai-chat-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.85);
}

.ai-chat-form input::placeholder {
  color: var(--muted);
}

.ai-chat-form input:focus {
  outline: 2px solid rgba(95, 115, 87, 0.35);
  outline-offset: 1px;
}

.ai-chat-form .primary-btn {
  width: auto;
  padding-inline: 18px;
}

body.awaiting-ai .basket {
  opacity: 0.82;
  transform: scale(0.992);
}

body.awaiting-ai .basket-caption {
  color: var(--warn);
}

.basket.ai-updated {
  box-shadow:
    0 0 0 2px rgba(95, 115, 87, 0.24),
    0 12px 26px var(--shadow);
}

.orb {
  position: fixed;
  right: clamp(16px, 3vw, 34px);
  bottom: 18px;
  border: 1px solid rgba(166, 145, 121, 0.45);
  border-radius: 50%;
  background: rgba(255, 249, 239, 0.92);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  cursor: pointer;
  z-index: 9;
  box-shadow: 0 10px 22px rgba(89, 70, 50, 0.18);
}

.orb.active {
  border-color: rgba(95, 115, 87, 0.6);
  box-shadow:
    0 0 0 2px rgba(95, 115, 87, 0.24),
    0 10px 22px rgba(89, 70, 50, 0.2);
}

.orb-core {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #fdf1d6 0%, #e8cfa5 44%, #c8a477 100%);
  box-shadow: 0 0 0 1px rgba(118, 94, 69, 0.28) inset;
  animation: pulse 3.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

@media (max-width: 960px) {
  .layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    padding-right: clamp(16px, 3vw, 34px);
  }

  .basket {
    position: static;
    width: auto;
    height: auto;
    max-height: none;
  }
}

@media (max-width: 680px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-wrap input {
    width: 100%;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .ai-builder {
    left: 10px;
    right: 10px;
    width: auto;
  }

}
