/* ─────────────────────────────────────────────────────────────
   Kastyl Shop — тёмно-красная тема
   ───────────────────────────────────────────────────────────── */
:root {
  --bg: #120709;
  --bg-soft: #1a0b0e;
  --card: #231015;
  --card-2: #2e161b;
  --line: #3d1a21;
  --text: #f6e9ea;
  --muted: #9b8188;
  --accent: #b02a37;
  --accent-2: #8c1f2b;
  --accent-light: #e9737f;
  --radius: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

[hidden] { display: none !important; }

button {
  font-family: inherit;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

img { display: block; }

/* ── Интро: рукописная подпись (порт Morphine Intro) ───────── */
html.intro-locked { overflow: hidden; }

#intro {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition:
    opacity 0.7s var(--ease),
    transform 0.85s var(--ease),
    background-color 0.8s ease;
}

/* Подпись улетела в шапку — фон интро гаснет, оверлей пропускает клики */
#intro.intro-transparent {
  background: transparent;
  pointer-events: none;
}

#intro.intro-hidden {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.intro-svg {
  width: min(880px, 92vw);
  height: auto;
  overflow: visible;
}

.hw-path {
  fill: none;
  stroke: #f7e9e9;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 14px rgba(233, 115, 127, 0.55));
}

#pen-tip {
  filter:
    drop-shadow(0 0 18px rgba(233, 115, 127, 0.9))
    drop-shadow(0 0 32px rgba(233, 115, 127, 0.5));
  transition: opacity 0.2s ease;
}

/* ── Каркас приложения ─────────────────────────────────────── */
.app {
  min-height: 100vh;
  padding: 14px 16px 28px;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.app.site-visible {
  opacity: 1;
  transform: none;
}

.topbar {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.brand-row {
  position: relative;
  min-height: 56px;
  display: flex;
  align-items: center;
}

/* Слот, куда «переезжает» подпись из интро и остаётся логотипом */
.brand-sign {
  width: clamp(150px, 42vw, 230px);
  aspect-ratio: 1050 / 260;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.brand-sign.parked { opacity: 1; }
.brand-sign svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  transform-origin: center;
}

.brand {
  margin: 2px 0 0;
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 27px;
  line-height: 1;
  color: #f7e9e9;
}
.brand em { font-style: normal; color: var(--accent-light); }
.brand.ghost { visibility: hidden; }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 5px;
}
.tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 4px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}
.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 18px -8px rgba(176, 42, 55, 0.65);
}
.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
}
.tab:not(.active) .badge { background: var(--accent); color: #fff; }

/* ── Главная ───────────────────────────────────────────────── */
.hero {
  background: linear-gradient(150deg, var(--card) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px 18px;
  box-shadow: 0 18px 44px -26px rgba(0, 0, 0, 0.8);
}
.hero-title {
  margin: 0 0 12px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.2px;
}
.hero-note {
  margin: 0 0 20px;
  font-size: 12.5px;
  color: var(--muted);
}
.hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.12s ease, opacity 0.2s ease;
}
.btn svg { flex: 0 0 auto; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(176, 42, 55, 0.7);
}
.btn-primary:disabled { opacity: 0.6; }
.btn-soft {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-block { width: 100%; }

/* ── Каталог ───────────────────────────────────────────────── */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chip.active {
  background: rgba(176, 42, 55, 0.18);
  border-color: var(--accent);
  color: #f7d5d8;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.pcard {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.2s ease;
}
.pcard:active { transform: scale(0.98); }
.pcard-photo {
  aspect-ratio: 3 / 4;
  background: var(--card-2);
}
.pcard-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pcard-noimg {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}
.pcard-body {
  position: relative;
  padding: 10px 12px 52px;
}
.pcard-price {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-light);
}
.pcard-desc {
  margin: 3px 0 0;
  padding-right: 40px;
  font-size: 12.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.add-fab {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 20px -8px rgba(176, 42, 55, 0.75);
  transition: transform 0.12s ease;
}
.add-fab:active { transform: scale(0.88); }

/* ── Корзина ───────────────────────────────────────────────── */
.cart-list { display: grid; gap: 10px; }
.citem {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
}
.citem-img {
  width: 72px;
  height: 88px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--card-2);
  flex: 0 0 auto;
}
.citem-main {
  flex: 1;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 3px;
}
.citem-name {
  font-size: 13px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.citem-unit { font-size: 12px; color: var(--muted); }
.stepper {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 6px;
  justify-self: start;
}
.stepper button {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--card-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.stepper span {
  min-width: 16px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 700;
}
.citem-side {
  display: grid;
  align-content: space-between;
  justify-items: end;
}
.citem-sum { font-size: 14px; font-weight: 800; color: var(--accent-light); }
.citem-del {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}
.citem-del:active { color: var(--accent-light); }

.cart-foot {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}
.total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
  font-size: 15px;
  color: var(--muted);
}
.total-row b { font-size: 19px; color: var(--text); }

/* ── Пустые состояния ──────────────────────────────────────── */
.empty {
  padding: 56px 20px;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
}
.empty p { margin: 0; font-size: 17px; font-weight: 700; color: var(--text); }
.empty > span { font-size: 13px; }
.empty .btn { margin-top: 8px; }
.empty > :first-child { font-size: 42px; }

/* ── Полноэкранные панели (товар / оформление) ─────────────── */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.sheet.open {
  opacity: 1;
  transform: none;
}
.sheet-close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 14px;
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(18, 7, 9, 0.65);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
}

.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  aspect-ratio: 3 / 4;
  max-height: 56vh;
  background: var(--card-2);
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel img {
  flex: 0 0 100%;
  width: 100%;
  object-fit: cover;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
.dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 10px 0 2px;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.2s ease, width 0.2s ease;
}
.dot.active { background: var(--accent-light); width: 18px; }

.detail-noimg {
  aspect-ratio: 3 / 4;
  max-height: 56vh;
  display: grid;
  place-items: center;
  background: var(--card-2);
  color: var(--muted);
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 16px;
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.detail-cat {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(176, 42, 55, 0.18);
  border: 1px solid var(--line);
  color: #f7d5d8;
  font-size: 12.5px;
  font-weight: 600;
}
.detail-price {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-light);
}
.detail-desc {
  margin: 0;
  font-size: 14.5px;
  color: var(--text);
  white-space: pre-line;
}

.sheet-cta {
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
}

/* ── Оформление заказа ─────────────────────────────────────── */
.checkout-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 10px;
}
.checkout-head h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}
.checkout-head .sheet-close {
  position: static;
  background: var(--card);
}
.checkout-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 10px;
  display: grid;
  align-content: start;
  gap: 14px;
}
.sec-title {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.dopts { display: grid; gap: 8px; }
.dopt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.dopt.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(176, 42, 55, 0.16), rgba(140, 31, 43, 0.05));
}
.dopt-icon { font-size: 20px; }
.dopt-icon svg { display: block; }
.dopt-label { flex: 1; font-size: 14.5px; font-weight: 600; }
.dopt-radio {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 2px solid var(--line);
  transition: border-color 0.2s ease;
}
.dopt.selected .dopt-radio {
  border-color: var(--accent-light);
  background: radial-gradient(circle, var(--accent-light) 0 40%, transparent 46%);
}

.fields { display: grid; gap: 10px; }
.field { display: grid; gap: 6px; }
.field > span {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.input:focus { border-color: var(--accent); outline: none; }
.hint {
  margin: 0;
  padding: 10px 2px;
  color: var(--muted);
  font-size: 13.5px;
}

.order-summary {
  display: grid;
  gap: 7px;
  padding: 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
}
.sum-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}
.sum-row b { color: var(--text); font-weight: 700; }
.sum-row.total {
  border-top: 1px solid var(--line);
  padding-top: 9px;
  font-size: 15px;
  color: var(--text);
}
.sum-row.total b { color: var(--accent-light); font-size: 18px; }

/* ── Успех ─────────────────────────────────────────────────── */
.success {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
}
.success-icon { font-size: 54px; }
.success h3 { margin: 4px 0 0; font-size: 22px; }
.success p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.success .btn { min-width: 220px; }

/* ── Тост ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--card-2);
  border: 1px solid rgba(233, 115, 127, 0.35);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.7);
  font-size: 13.5px;
  font-weight: 600;
  transform: translate(-50%, -18px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.25s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

@media (min-width: 560px) {
  .app { max-width: 620px; margin: 0 auto; }
}

/* Уважение к настройке «меньше анимации» */
@media (prefers-reduced-motion: reduce) {
  .app { transition: none; }
}
