:root {
  color-scheme: light;
  --paper: #f6f1e6;
  --surface: #fffdf8;
  --ink: #252a23;
  --muted: #686f64;
  --forest: #1e4435;
  --forest-contrast: #fffdf8;
  --olive: #7a8466;
  --saffron: #b3873f;
  --line: #ded8c9;
  --image-bed: #ebe5d8;
  --error: #a43f35;
  --bottomnav-height: 68px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #17251f;
  --surface: #21332a;
  --ink: #f2ecdf;
  --muted: #c1c4b8;
  --forest: #b6cbb5;
  --forest-contrast: #17251f;
  --olive: #c3c99e;
  --saffron: #e2be76;
  --line: #415348;
  --image-bed: #2b3d33;
  --error: #ffb4a8;
}

* { box-sizing: border-box; }

html, body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; min-height: 100dvh; }

button, input { font: inherit; }
button { color: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--saffron);
  outline-offset: 3px;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--bottomnav-height) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 10px max(20px, calc((100vw - 1200px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--forest);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--saffron);
  border-radius: 50%;
  font: 600 18px/1 Georgia, "Times New Roman", serif;
}

.brand-name {
  font: 600 23px/1 Georgia, "Times New Roman", serif;
  letter-spacing: -0.035em;
}

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

.language-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.language-option, .theme-button {
  min-width: 37px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.language-option { color: var(--muted); font-size: 12px; font-weight: 700; }
.language-option[aria-pressed="true"] { background: var(--forest); color: var(--forest-contrast); }

.theme-button {
  display: grid;
  width: 38px;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--forest);
}

.theme-button svg, .search-icon, .navbtn svg, .telegram-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#content {
  width: min(1200px, 100%);
  min-height: calc(100vh - 136px);
  margin: 0 auto;
  padding: 30px 24px calc(112px + env(safe-area-inset-bottom));
}

.catalog-intro { margin: 0 0 26px; }
.catalog-intro h1, .destination-title, .product-detail h1 {
  margin: 0;
  color: var(--forest);
  font: 500 clamp(30px, 5vw, 44px)/1.08 Georgia, "Times New Roman", serif;
  letter-spacing: -0.035em;
}

.catalog-intro p, .destination-copy, .product-description {
  max-width: 58ch;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.catalog-tools { display: grid; gap: 16px; margin-bottom: 20px; }

.search-wrap { position: relative; width: min(100%, 560px); }

.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.catalog-search {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px 11px 43px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
}

.catalog-search::placeholder { color: var(--muted); opacity: 1; }

.category-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 5px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.category-button {
  flex: 0 0 auto;
  min-height: 39px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.category-button[aria-pressed="true"] { border-color: var(--forest); background: var(--forest); color: var(--forest-contrast); }

.results-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 14px;
}

.results-heading h2, .detail-section-title {
  margin: 0;
  font: 500 21px/1.2 Georgia, "Times New Roman", serif;
}

.result-count { color: var(--muted); font-size: 13px; }

.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }

.product-card {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.product-card:hover { border-color: var(--olive); }

.product-media {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 0.92;
  object-fit: cover;
  background: var(--image-bed);
}

.image-placeholder {
  display: grid;
  min-height: 150px;
  aspect-ratio: 1 / 0.92;
  place-items: center;
  padding: 18px;
  background: var(--image-bed);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.image-placeholder::before {
  display: block;
  width: 28px;
  height: 22px;
  margin-bottom: 9px;
  border: 1px solid var(--olive);
  border-radius: 3px;
  content: "";
}

.product-copy { display: grid; gap: 7px; padding: 12px 13px 14px; }
.product-name { overflow-wrap: anywhere; font-size: 15px; font-weight: 600; line-height: 1.35; }
.product-price { color: var(--forest); font-size: 15px; font-weight: 700; }

.catalog-status, .empty-state, .error-state, .private-state {
  padding: 24px 0;
  color: var(--muted);
  line-height: 1.55;
}

.empty-state h2, .error-state h2, .private-state h2 {
  margin: 0 0 7px;
  color: var(--ink);
  font: 500 24px/1.2 Georgia, "Times New Roman", serif;
}

.error-state { color: var(--error); }
.error-state h2 { color: var(--error); }
.state-action { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; }

.primary-button, .telegram-link {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 18px;
  border: 1px solid var(--forest);
  border-radius: 9px;
  background: var(--forest);
  color: var(--forest-contrast);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.primary-button:hover, .telegram-link:hover { filter: brightness(1.08); }
.primary-button:disabled { cursor: not-allowed; opacity: .55; }

.load-more-wrap { display: flex; justify-content: center; padding: 24px 0 4px; }
.secondary-button {
  min-height: 44px;
  padding: 10px 17px;
  border: 1px solid var(--forest);
  border-radius: 9px;
  background: transparent;
  color: var(--forest);
  font-weight: 650;
  cursor: pointer;
}

.product-detail { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr); gap: clamp(24px, 5vw, 62px); align-items: start; }
.product-detail-media { min-height: 300px; aspect-ratio: 1.18 / 1; border-radius: 14px; }
.product-detail .image-placeholder { min-height: 300px; aspect-ratio: 1.18 / 1; border-radius: 14px; }
.product-detail .image-placeholder::before { width: 38px; height: 30px; }
.product-detail-info { padding-top: 6px; }
.product-detail h1 { font-size: clamp(28px, 4vw, 38px); }
.product-description { margin-top: 14px; }
.price-stock-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 18px; margin: 22px 0; }
.detail-price { color: var(--forest); font-size: 22px; font-weight: 700; }
.stock-label { color: var(--muted); font-size: 13px; }
.detail-section-title { margin: 25px 0 10px; font-size: 18px; }
.variant-list { display: grid; gap: 8px; }
.variant-option {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
}

.variant-option:has(input:checked) { border-color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); }
.variant-label-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.variant-option input { width: 17px; height: 17px; accent-color: var(--forest); }
.variant-label { overflow-wrap: anywhere; font-weight: 600; }
.variant-stock { color: var(--muted); font-size: 12px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 18px; }
.quantity-control { display: flex; min-height: 46px; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.quantity-control button { width: 42px; min-height: 44px; border: 0; background: transparent; color: var(--forest); font-size: 20px; cursor: pointer; }
.quantity-value { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; }
.detail-actions .primary-button { flex: 1 1 180px; }
.inline-feedback { min-height: 24px; margin: 11px 0 0; color: var(--muted); font-size: 13px; }

/* Shared foundations for customer order and profile views. */
.customer-view, .orders-view, .profile-view { display: grid; gap: 18px; }
.order-list, .order-items { display: grid; gap: 10px; }
.order-row, .order-summary, .order-detail, .payment-instructions {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.order-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px 14px; color: inherit; text-decoration: none; }
.order-row:hover { border-color: var(--olive); }
.order-summary { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; }
.order-detail { display: grid; gap: 18px; }
.order-detail-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px 14px; }
.order-detail-header h2 { margin: 0; color: var(--forest); font: 500 24px/1.2 Georgia, "Times New Roman", serif; }
.order-detail-header .order-meta, .order-detail-header .order-total, .order-detail-header .order-state-line { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 13px; }
.order-items-section, .order-payment { display: grid; gap: 12px; }
.order-items { margin: 0; padding: 0; list-style: none; }
.order-items li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.order-item-copy { display: grid; gap: 4px; min-width: 0; }
.order-item-name { overflow-wrap: anywhere; font-weight: 650; }
.order-item-description { color: var(--muted); font-size: 13px; }
.order-item-price { display: grid; justify-items: end; gap: 3px; white-space: nowrap; }
.order-item-unit-price { color: var(--muted); font-size: 12px; }
.order-item-total { color: var(--forest); }
.payment-instructions { display: grid; gap: 10px; border-color: color-mix(in srgb, var(--saffron) 55%, var(--line)); }
.payment-instructions p { margin: 0; }
.payment-detail-list { display: grid; grid-template-columns: minmax(105px, .55fr) minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.payment-detail-list dt { color: var(--muted); font-size: 13px; }
.payment-detail-list dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }
.payment-card-number { letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.status-pill { display: inline-flex; min-height: 25px; align-items: center; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--forest); font-size: 12px; font-weight: 650; }
.refund-note, .proof-review-note { padding: 11px 13px; border-left: 3px solid var(--saffron); background: color-mix(in srgb, var(--saffron) 12%, var(--surface)); color: var(--ink); }
.proof-actions, .proof-upload, .proof-preview { display: grid; gap: 11px; }
.proof-file { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.proof-file-label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.proof-file-hint, .proof-manual-guidance { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.proof-review-note { margin: 0; }
.proof-file input, .profile-field input, .profile-field textarea, .profile-field select {
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.proof-preview img { display: block; width: min(100%, 520px); max-height: 420px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: var(--image-bed); }
.profile-form { display: grid; gap: 15px; max-width: 640px; }
.profile-courier-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.profile-support { display: grid; gap: 7px; width: fit-content; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.profile-support h2, .profile-support p { margin: 0; }
.profile-support p { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-support-label { color: var(--muted); }
.profile-support-value { color: var(--forest); }
.profile-field { display: grid; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 600; }
.profile-field textarea { min-height: 100px; resize: vertical; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-error { color: var(--error); font-size: 13px; }
.form-success { color: var(--forest); font-size: 13px; }
.form-error:empty, .form-success:empty { display: none; }
.reorder-result { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.reorder-result p { margin: 0; }
.reorder-items { display: grid; gap: 7px; margin: 0; padding-left: 18px; }
.reorder-items li { display: flex; justify-content: space-between; gap: 14px; }
.reorder-item-price, .reorder-total { color: var(--forest); font-weight: 650; }
.cart-view, .checkout-view { display: grid; gap: 18px; }
.cart-list { display: grid; gap: 11px; }
.cart-line { display: grid; grid-template-columns: 104px minmax(0, 1fr) auto; align-items: center; gap: 15px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.cart-image, .cart-image-placeholder { display: grid; width: 100%; min-height: 88px; aspect-ratio: 1; place-items: center; border-radius: 8px; object-fit: cover; background: var(--image-bed); }
.cart-image-placeholder { padding: 6px; font-size: 11px; }
.cart-image-placeholder::before { width: 21px; height: 17px; margin-bottom: 5px; }
.cart-product { display: grid; min-width: 0; gap: 5px; }
.cart-product-name { margin: 0; overflow-wrap: anywhere; font-size: 15px; font-weight: 650; line-height: 1.35; }
.cart-package, .cart-unit-price { margin: 0; color: var(--muted); font-size: 13px; }
.cart-line-total { color: var(--forest); font-size: 15px; }
.cart-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.quantity-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--forest); font-size: 19px; cursor: pointer; }
.quantity-button:disabled, .cart-remove:disabled { cursor: progress; opacity: .55; }
.cart-quantity { min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; }
.cart-remove { min-height: 36px; padding: 6px 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.cart-summary { position: sticky; bottom: calc(var(--bottomnav-height) + env(safe-area-inset-bottom) + 10px); display: grid; gap: 13px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 4px 20px color-mix(in srgb, var(--ink) 8%, transparent); }
.cart-total-row, .checkout-total-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: baseline; }
.cart-total-row strong, .checkout-total-row strong { color: var(--forest); font-size: 18px; }
.sales-closed-note { margin: 0; padding: 12px 14px; border-left: 3px solid var(--saffron); background: color-mix(in srgb, var(--saffron) 12%, var(--surface)); color: var(--ink); }
.checkout-history-note { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 18px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 13px; }
.checkout-history-note p { margin: 0; }
.checkout-existing-order { color: var(--forest); font-weight: 650; }
.checkout-summary { display: grid; gap: 10px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.checkout-lines { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.checkout-lines li { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.checkout-courier-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.checkout-form { display: grid; gap: 14px; max-width: 640px; }
.checkout-field { display: grid; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 600; }
.checkout-field input, .checkout-field textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 400; }
.checkout-field textarea { min-height: 96px; resize: vertical; }
.checkout-form .primary-button { width: fit-content; min-width: min(100%, 240px); }

.bottomnav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  height: calc(var(--bottomnav-height) + env(safe-area-inset-bottom));
  justify-content: center;
  padding: 0 max(8px, calc((100vw - 700px) / 2)) env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.navbtn {
  display: flex;
  width: min(25%, 150px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: var(--bottomnav-height);
  padding: 7px 3px 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1.2;
}

.navbtn svg { width: 21px; height: 21px; }
.navbtn[aria-current="page"] { color: var(--forest); font-weight: 700; }
.navbtn[aria-current="page"] svg { stroke-width: 2.2; }

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

@media (min-width: 700px) {
  .topbar { min-height: 76px; padding-right: max(32px, calc((100vw - 1200px) / 2)); padding-left: max(32px, calc((100vw - 1200px) / 2)); }
  #content { padding: 44px 32px calc(124px + env(safe-area-inset-bottom)); }
  .catalog-intro { margin-bottom: 30px; }
  .catalog-tools { gap: 18px; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  .product-copy { padding: 15px 16px 17px; }
  .product-name, .product-price { font-size: 16px; }
  .order-row, .order-summary, .order-detail, .payment-instructions { padding: 15px; }
  .cart-line { grid-template-columns: 78px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .cart-controls { grid-column: 1 / -1; justify-content: flex-start; }
  .cart-image, .cart-image-placeholder { min-height: 72px; }
  .checkout-history-note { grid-template-columns: 1fr; }
  .checkout-lines li { flex-direction: column; gap: 4px; }
  .checkout-form .primary-button { width: 100%; }
}

@media (min-width: 1050px) {
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
}

@media (max-width: 480px) {
  .topbar { min-height: 62px; padding: 8px 15px; }
  .brand-name { font-size: 21px; }
  #content { min-height: calc(100vh - 124px); padding: 23px 16px calc(112px + env(safe-area-inset-bottom)); }
  .catalog-intro { margin-bottom: 21px; }
  .catalog-intro p { font-size: 14px; }
  .product-grid { gap: 10px; }
  .product-copy { gap: 6px; padding: 10px 10px 12px; }
  .product-name { font-size: 14px; }
  .product-price { font-size: 14px; }
  .product-detail { grid-template-columns: 1fr; gap: 22px; }
  .product-detail-media, .product-detail .image-placeholder { min-height: 245px; max-height: 350px; }
  .detail-actions { gap: 9px; }
  .detail-actions .primary-button { flex-basis: 100%; }
  .order-row { grid-template-columns: 1fr; }
  .order-items li { flex-direction: column; gap: 4px; }
  .navbtn { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .product-card, .category-button, .variant-option, .catalog-search { border: 1px solid CanvasText; }
  .primary-button, .telegram-link { border: 1px solid ButtonText; }
}
