:root {
  --bg: #eef3fb;
  --surface: #ffffff;
  --ink: #0f1b2d;
  --ink-soft: #5b6b84;
  --line: #dbe6f5;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(32, 29, 26, 0.08);
  --header-h: 76px;
  --mobile-bar-h: 64px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font-family: inherit; }

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============ HEADER ============ */
.header {
  height: var(--header-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; flex: none; }
.brand__logo {
  height: 34px;
  width: auto;
  flex: none;
  display: block;
}
.brand__divider { width: 1px; height: 28px; background: var(--line); flex: none; }
.brand__text { display: flex; flex-direction: column; line-height: 1.25; white-space: nowrap; }
.brand__name { font-weight: 800; letter-spacing: 0.04em; font-size: 15px; }
.brand__tag { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

.filters {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-start;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px;
}
.filters::-webkit-scrollbar { display: none; }

.filter-btn {
  flex: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-soft);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--accent); color: var(--ink); }
.filter-btn.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ============ MAIN LAYOUT ============ */
.main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ============ CATALOG ============ */
.catalog-wrap {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
}

.catalog {
  padding: 22px 24px 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  align-content: start;
}

/* ============ SEO TEXT ============ */
.seo-text {
  padding: 24px 24px 40px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.seo-text h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 12px;
  color: var(--ink);
}
.seo-text h3 {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  margin: 16px 0 6px;
}
.seo-text__body {
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.7;
  max-width: 780px;
}
.seo-text__body p { margin: 0 0 12px; }
.seo-text__body a { color: var(--accent); }
.seo-text.is-collapsed h3,
.seo-text.is-collapsed p:not(:first-child) { display: none; }
.seo-text.is-collapsed .seo-text__body p:first-child {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0;
}
.seo-text__toggle {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.seo-text__toggle:hover { border-color: var(--accent); background: var(--bg); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.card:hover { box-shadow: var(--shadow); }
.card.is-in-cart { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.card__media {
  position: relative;
  height: 152px;
  margin: -16px -16px 0;
  background: linear-gradient(160deg, #f6f8fb, #ffffff);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card__img {
  height: 90%;
  width: auto;
  max-width: 86%;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(20, 30, 50, .14));
}
.card__badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(2px);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.card__name {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.3;
}
.card__note {
  font-size: 12px;
  color: var(--ink-soft);
  min-height: 15px;
  line-height: 1.3;
}

.card__bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card__price { font-size: 15px; font-weight: 800; }
.card__price small { font-weight: 500; color: var(--ink-soft); font-size: 11.5px; }

.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg);
}
.stepper button {
  width: 30px; height: 30px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.stepper button:hover { background: var(--line); }
.stepper button:disabled { opacity: .35; cursor: default; background: none; }
.stepper__qty {
  min-width: 22px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}
.stepper--add {
  width: 30px; height: 30px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  border: none;
  font-size: 17px;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.stepper--add:hover { background: var(--accent); }
.stepper--add:active { transform: scale(.93); }

/* ============ CART ============ */
.cart {
  flex: none;
  width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cart__header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.cart__header h2 { margin: 0; font-size: 16px; font-weight: 800; }
.cart__collapse { display: none; border: none; background: none; cursor: pointer; color: var(--ink-soft); padding: 6px; }

.cart__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cart__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink-soft);
  gap: 10px;
  padding: 30px 10px;
}
.cart__empty-icon { font-size: 34px; }
.cart__empty p { margin: 0; font-size: 13.5px; line-height: 1.5; }

.cart__list { list-style: none; margin: 0; padding: 0; display: none; flex-direction: column; gap: 10px; }

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.cart-item__glyph {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: #f4f6fa;
  border: 1px solid #eef1f6;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex: none;
}
.cart-item__glyph img { height: 100%; width: auto; max-width: 100%; object-fit: contain; }
.cart-item__info { flex: 1 1 auto; min-width: 0; }
.cart-item__name { font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.cart-item__price { font-size: 12px; color: var(--ink-soft); }
.cart-item__controls { display: flex; align-items: center; gap: 8px; flex: none; }
.cart-item__remove {
  border: none; background: none; color: var(--ink-soft); cursor: pointer;
  padding: 4px; line-height: 0; transition: color .15s ease;
}
.cart-item__remove:hover { color: var(--danger); }

.cart__summary { display: none; flex-direction: column; gap: 12px; flex: none; }
.cart__row { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; color: var(--ink-soft); }
.cart__row--total { font-size: 17px; font-weight: 800; color: var(--ink); }

.btn {
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, opacity .15s ease;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn--full { width: 100%; }
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: var(--accent); }
.btn--primary:active { transform: scale(.98); }
.btn--primary:disabled { opacity: .5; cursor: default; transform: none; }
.btn--secondary { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.btn--secondary:hover { border-color: var(--accent); }

.btn__spinner {
  display: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn.is-loading .btn__label { display: none; }
.btn.is-loading .btn__spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ CHECKOUT FORM ============ */
.checkout { display: none; flex-direction: column; gap: 14px; }
.checkout__back {
  display: flex; align-items: center; gap: 6px;
  border: none; background: none; color: var(--ink-soft);
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 2px 0; align-self: flex-start;
}
.checkout__back:hover { color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field em { font-weight: 400; color: var(--ink-soft); font-style: normal; }
.field input, .field textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--bg);
  resize: none;
  transition: border-color .15s ease;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.field.has-error input, .field.has-error textarea { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: 11.5px; font-weight: 600; min-height: 14px; }

.checkout__summary {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 800;
  padding-top: 6px; border-top: 1px dashed var(--line);
}
.checkout__note { font-size: 11px; color: var(--ink-soft); text-align: center; line-height: 1.4; margin: -4px 0 0; }

/* ============ SUCCESS ============ */
.success { display: none; flex: 1; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 30px 10px; }
.success__icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--success); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800;
}
.success h3 { margin: 0; font-size: 17px; }
.success p { margin: 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; }

/* ============ PAYMENT ============ */
.pay {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  text-align: left;
}

.pay__sum { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; font-weight: 700; color: var(--ink-soft); }
.pay__sum strong { font-size: 19px; font-weight: 800; color: var(--ink); }

.pay__tabs {
  position: relative;
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.pay__tabs-glider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  background: var(--ink);
  border-radius: 999px;
  transition: transform .34s cubic-bezier(.65,0,.35,1), width .34s cubic-bezier(.65,0,.35,1);
  z-index: 0;
}

.pay__tab {
  position: relative;
  z-index: 1;
  flex: 1;
  border: none;
  background: none;
  padding: 9px 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 999px;
  white-space: nowrap;
  transition: color .3s ease;
}
.pay__tab.is-active { color: #fff; }

.pay__panes { position: relative; }
.pay__pane {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding-top: 6px;
}
.pay__pane.is-active { display: flex; animation: payPaneIn .4s cubic-bezier(.2,.9,.3,1); }
@keyframes payPaneIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pay__qr {
  width: 176px;
  height: auto;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.pay__hint { margin: 0; font-size: 12px; color: var(--ink-soft); line-height: 1.55; padding: 0 4px; }

.pay__copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .2s ease, transform .1s ease;
}
.pay__copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.pay__copy-btn:active { transform: scale(.96); }
.pay__copy-btn.is-copied { border-color: var(--success); color: var(--success); background: #f0fdf4; }

.req {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.req__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
}
.req__row:not(:last-child) { border-bottom: 1px solid var(--line); }
.req__row span { color: var(--ink-soft); flex: none; }
.req__row b { font-weight: 700; text-align: right; }

/* ============ STATE SWITCHES ============ */
.cart.has-items .cart__empty { display: none; }
.cart.has-items .cart__list { display: flex; }
.cart.has-items .cart__summary { display: flex; }

.cart.is-checkout .cart__list { display: none; }
.cart.is-checkout .cart__summary { display: none; }
.cart.is-checkout .checkout { display: flex; }
.cart.is-success .cart__summary,
.cart.is-success .checkout,
.cart.is-success .cart__list,
.cart.is-success .cart__empty { display: none; }
.cart.is-success .success { display: flex; }

/* ============ MOBILE BAR ============ */
.mobile-bar { display: none; }
.scrim { display: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .header {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 0;
    border-bottom: none;
  }
  .brand { padding: 12px 16px; gap: 10px; border-bottom: 1px solid var(--line); }
  .brand__logo { height: 24px; }
  .brand__divider { display: none; }
  .brand__tag { display: none; }
  .brand__name { font-size: 13px; }

  .filters {
    background: var(--bg);
    padding: 10px 16px;
    margin: 0;
    border-bottom: 1px solid var(--line);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
  }
  .filters .filter-btn { background: var(--surface); }
  .filters .filter-btn.is-active { background: var(--ink); }

  .catalog { padding: 16px 14px 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .card { padding: 12px; }
  .card__media { height: 128px; margin: -12px -12px 0; }
  .seo-text { padding: 20px 14px calc(var(--mobile-bar-h) + 30px); }

  .main { position: relative; }

  .cart {
    position: fixed;
    inset: auto 0 0 0;
    width: auto;
    height: auto;
    max-height: min(86dvh, 640px);
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,.15);
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.32,.72,0,1);
    z-index: 60;
  }
  .cart.is-open { transform: translateY(0); }
  .cart__collapse { display: block; }

  .mobile-bar {
    display: flex;
    position: fixed;
    left: 12px; right: 12px; bottom: 12px;
    height: var(--mobile-bar-h);
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 999px;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    z-index: 50;
    cursor: pointer;
    transition: transform .2s ease, opacity .2s ease;
  }
  .mobile-bar.is-hidden { transform: translateY(140%); opacity: 0; pointer-events: none; }
  .mobile-bar__info { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
  .mobile-bar__count {
    background: var(--accent);
    color: #fff;
    min-width: 22px; height: 22px;
    border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800;
  }
  .mobile-bar__total {
    background: rgba(255,255,255,.12);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 14px;
  }

  .scrim {
    display: block;
    position: fixed; inset: 0;
    background: rgba(20,17,14,.4);
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
    z-index: 55;
  }
  .scrim.is-visible { opacity: 1; pointer-events: auto; }
}

@media (max-width: 420px) {
  .catalog { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
}
