.ab-app {
  color: #4c2b23;
  font-family: Inter, Arial, sans-serif;
}

/*
 * Buy button + stock/city slot injected into legacy Tilda zero-blocks
 * (tools/legacy_site/integrate.py `_attach_stock_slot`). Elsewhere (the
 * generic ab-shop embed fixture, the static /catalog cards rendered by
 * `render_catalog`) `[data-ab-stock-slot]` is a plain flow element and must
 * keep its normal block layout, so every rule below is scoped under
 * `.ab-buy-group` — the wrapper only `_attach_stock_slot` creates.
 *
 * `.ab-buy-group` renders as `display: contents`: it has no box of its own,
 * so the buy button inside it keeps resolving its Tilda-authored absolute
 * position/size against the original `.t396`/`.t396__elem` ancestor exactly
 * as before wrapping. Only `[data-ab-stock-slot]` gets a real box, and it is
 * always `position: absolute` so its content can never grow, clip inside, or
 * push any sibling Tilda atom (button, price, "Купить на OZON", ...).
 */
.ab-buy-group {
  display: contents;
}

.ab-buy-group [data-ab-stock-slot] {
  display: none;
}

.ab-buy-group [data-ab-stock-slot]:not(:empty) {
  display: block;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  max-width: 18rem;
  max-height: 6rem;
  overflow-y: auto;
  box-sizing: border-box;
  border-radius: 8px;
  background: #f5e7d3;
  color: #4c2b23;
  font-family: Inter, Arial, sans-serif;
  font-size: 0.75rem;
  line-height: 1.35;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  /* The Tilda zero-block packs unrelated atoms (other buttons, the "Купить
   * на OZON" link, ...) tightly below the buy button; the slot's own
   * variable-height content can visually land on top of them. Only the
   * slot's own interactive controls should intercept clicks, so anything
   * else (its background, status text) lets clicks fall through to
   * whatever legacy control sits underneath. */
  pointer-events: none;
}

/* /api/stock failed: one short fixed line ("Наличие уточняется."). It sizes to
 * its text, is never clipped or scrolled, and stays out of flow like the rest of
 * the slot, so no neighbouring Tilda atom moves. */
.ab-buy-group [data-ab-stock-slot][data-ab-stock-state="unknown"]:not(:empty) {
  width: max-content;
  max-height: none;
  overflow: visible;
  white-space: normal;
}

.ab-buy-group [data-ab-stock-slot] .ab-stock-unknown {
  margin: 0;
}

.ab-buy-group [data-ab-stock-slot] button,
.ab-buy-group [data-ab-stock-slot] input,
.ab-buy-group [data-ab-stock-slot] a {
  pointer-events: auto;
}

.ab-drawer {
  box-sizing: border-box;
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  border: 0;
  border-radius: 16px;
  background: #f5e7d3;
  color: #4c2b23;
  padding: 1rem;
}

.ab-drawer::backdrop {
  background: rgb(76 43 35 / 55%);
}

.ab-drawer-header,
.ab-drawer-quantity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ab-drawer-title,
.ab-drawer-line-title,
.ab-drawer-line-qty,
.ab-drawer-line-total,
.ab-drawer-summary p {
  margin: 0;
}

.ab-drawer-content {
  display: grid;
  gap: 0.75rem;
  margin-block: 1rem;
}

.ab-drawer-line,
.ab-drawer-summary {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: #fffaf3;
}

.ab-drawer-control {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #4c2b23;
  border-radius: 8px;
  background: #f5e7d3;
  color: #4c2b23;
  cursor: pointer;
}

.ab-drawer-checkout {
  width: 100%;
  background: #ae5036;
  color: #fff;
}

.ab-drawer-control:focus-visible {
  outline: 3px solid #ae5036;
  outline-offset: 2px;
}

.ab-drawer-error {
  color: #8b1e12;
}

.ab-stock-status,
.ab-stock-error,
.ab-city-feedback,
.ab-restock-status,
.ab-restock-error {
  margin: 0.5rem 0;
}

.ab-stock-error,
.ab-restock-error {
  color: #8b1e12;
}

.ab-city-chooser,
.ab-restock-form,
.ab-city-suggestions {
  display: grid;
  gap: 0.5rem;
}

.ab-city-chooser,
.ab-restock-form {
  margin-block: 0.75rem;
}

.ab-city-label,
.ab-restock-label {
  display: grid;
  gap: 0.25rem;
}

.ab-city-query,
.ab-restock-email {
  box-sizing: border-box;
  min-height: 44px;
  width: 100%;
  border: 1px solid #4c2b23;
  border-radius: 8px;
  background: #fffaf3;
  color: #4c2b23;
  font: inherit;
  padding: 0.5rem 0.75rem;
}

.ab-city-option,
.ab-restock-submit {
  min-height: 44px;
  border: 1px solid #4c2b23;
  border-radius: 8px;
  background: #f5e7d3;
  color: #4c2b23;
  font: inherit;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.ab-restock-submit {
  background: #ae5036;
  color: #fff;
}

.ab-city-query:focus-visible,
.ab-restock-email:focus-visible,
.ab-city-option:focus-visible,
.ab-restock-submit:focus-visible,
.ab-checkout-control:focus-visible,
.ab-checkout-input:focus-visible,
.ab-checkout-submit:focus-visible,
.ab-cdek-point:focus-visible {
  outline: 3px solid #ae5036;
  outline-offset: 2px;
}

.ab-checkout-form,
.ab-delivery-options,
.ab-payment-options,
.ab-checkout-dynamic,
.ab-checkout-summary,
.ab-cdek-selector,
.ab-cdek-points {
  display: grid;
  gap: 0.75rem;
}

.ab-checkout-form {
  box-sizing: border-box;
  width: min(42rem, 100%);
  margin-inline: auto;
  padding: 1rem;
}

.ab-checkout-label,
.ab-consent-label {
  display: grid;
  gap: 0.25rem;
}

.ab-checkout-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  border: 1px solid #4c2b23;
  border-radius: 8px;
  background: #fffaf3;
  color: #4c2b23;
  padding: 0.5rem 0.75rem;
}

.ab-checkout-control,
.ab-cdek-point,
.ab-checkout-submit {
  min-height: 44px;
  border: 1px solid #4c2b23;
  border-radius: 8px;
  background: #f5e7d3;
  color: #4c2b23;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.ab-checkout-control[aria-pressed="true"] {
  border-width: 3px;
  background: #fffaf3;
}

.ab-checkout-submit {
  background: #ae5036;
  color: #fff;
  text-align: center;
}

.ab-checkout-submit:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ab-app [data-ab-min-target],
.ab-drawer [data-ab-min-target] {
  box-sizing: border-box;
  min-width: 44px;
  min-height: 44px;
}

.ab-consent {
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  margin: 0;
}

.ab-order-retry:focus-visible,
.ab-consent:focus-visible {
  outline: 3px solid #ae5036;
  outline-offset: 2px;
}

.ab-checkout-field-error,
.ab-checkout-error,
.ab-cdek-error {
  min-height: 1.25rem;
  margin: 0;
  color: #8b1e12;
}

@media (max-width: 600px) {
  .ab-drawer {
    width: 100vw;
    max-width: none;
    min-height: 100vh;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }
}
