:root {
  --bg: var(--tg-theme-secondary-bg-color, #f4f2ef);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1d1b19);
  --muted: var(--tg-theme-hint-color, #8a847d);
  --line: color-mix(in srgb, var(--muted) 22%, transparent);
  --accent: #b5532f;
  --accent-text: #ffffff;
  --ok: #2f8f5b; --warn: #c48a1c; --bad: #c0392b;
  --radius: 16px;
  --nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 20px; margin: 22px 0 12px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; }
.stack > * + * { margin-top: 12px; }

/* header */
.header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.logo { width: 46px; height: 46px; border-radius: 14px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 700; font-size: 20px; font-family: Georgia, serif; }
.header h1 { font-size: 20px; font-family: Georgia, "Times New Roman", serif; }
.iconbtn { position: relative; width: 46px; height: 46px; border-radius: 14px; background: var(--card);
  display: grid; place-items: center; border: 1px solid var(--line); }
.iconbtn svg { width: 22px; height: 22px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 700; display: grid; place-items: center; }

/* chips + search */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 9px 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.search { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 0 14px; }
.search svg { width: 18px; height: 18px; color: var(--muted); }
.search input { flex: 1; border: 0; background: none; padding: 13px 0; font: inherit; color: inherit; outline: none; }

/* art cards */
.carousel { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.carousel .art { flex: 0 0 62%; scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } .carousel .art { flex-basis: 38%; } }
.art { background: var(--card); border-radius: var(--radius); overflow: hidden; display: block; }
.art .img { aspect-ratio: 4 / 5; background: color-mix(in srgb, var(--muted) 15%, var(--card)); position: relative; }
.art .img img { width: 100%; height: 100%; object-fit: cover; }
.art .meta { padding: 10px 12px 12px; }
.art .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art .price { margin-top: 2px; }
.art .price b { font-weight: 700; }
.tag { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px;
  padding: 3px 8px; border-radius: 8px; font-weight: 600; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* product */
.hero { margin: -16px -16px 0; background: color-mix(in srgb, var(--muted) 15%, var(--card)); }
.hero img { width: 100%; max-height: 70vh; object-fit: contain; margin: 0 auto; }
.product h1 { font-size: 24px; font-family: Georgia, serif; margin-top: 16px; }
.sizes { display: grid; gap: 8px; }
.size { display: flex; align-items: center; justify-content: space-between; padding: 14px; border-radius: 14px;
  background: var(--card); border: 1.5px solid var(--line); text-align: left; width: 100%; }
.size.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.size[disabled] { opacity: .45; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.stepper button { width: 38px; height: 38px; font-size: 20px; }
.stepper span { min-width: 28px; text-align: center; font-weight: 600; }

/* buttons */
.btn { display: block; width: 100%; padding: 15px; border-radius: 14px; background: var(--accent); color: var(--accent-text);
  font-weight: 600; text-align: center; font-size: 16px; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.sm { display: inline-block; width: auto; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; }
.sticky { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 12px 16px;
  background: linear-gradient(transparent, var(--bg) 30%); z-index: 5; }
.sticky > * { max-width: 688px; margin: 0 auto; }
body.tg-main .sticky { display: none; }
main:has(.sticky) { padding-bottom: calc(var(--nav-h) + 100px + env(safe-area-inset-bottom)); }

/* cart & orders */
.line { display: flex; gap: 12px; align-items: center; }
.line + .line { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.thumb { width: 64px; height: 80px; border-radius: 10px; object-fit: cover; background: var(--line); flex: none; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-weight: 700; font-size: 17px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.status { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.status.awaiting_payment { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.status.paid { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.status.shipped { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.status.cancelled, .status.expired { background: var(--line); color: var(--muted); }

/* forms */
label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px 2px; }
input, textarea, select { width: 100%; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.variant-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 36px; gap: 8px; align-items: center; }
.variant-row input { padding: 10px; }
.upload { aspect-ratio: 4/5; max-width: 200px; border-radius: 14px; border: 2px dashed var(--line); display: grid; place-items: center;
  overflow: hidden; color: var(--muted); position: relative; }
.upload img { width: 100%; height: 100%; object-fit: cover; }
.upload input { position: absolute; inset: 0; opacity: 0; }
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 4px; border: 1px solid var(--line); }
.seg a { flex: 1; text-align: center; padding: 8px; border-radius: 9px; font-weight: 600; font-size: 14px; }
.seg a.on { background: var(--accent); color: var(--accent-text); }

/* nav */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--card); border-top: 1px solid var(--line); z-index: 10; }
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 12px; font-weight: 600; position: relative; }
#tabs a svg { width: 24px; height: 24px; }
#tabs a.on { color: var(--accent); }
#tabs .badge { top: 6px; right: calc(50% - 22px); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 80px); background: rgba(20,20,20,.9);
  color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 20; max-width: 90%; text-align: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
[hidden] { display: none !important; }
.carousel { scroll-padding: 0 16px; }
