:root { --bg:#fff; --fg:#000; --muted:#6b6b6b; --line:#e6e6e6; --tile:#f1f1f1; --accent:#000; --hdr:64px; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html[lang=fa] body { font-family: 'Vazirmatn', system-ui, sans-serif; }
html[lang=en] body { font-family: 'Inter', system-ui, sans-serif; }
html[lang=fa] .display, html[lang=fa] .logo { font-family: 'Vazirmatn', sans-serif; font-weight: 800; }
.display, .logo { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; }
body { background: var(--bg); color: var(--fg); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }

.top { position: fixed; inset: 0 0 auto 0; z-index: 30; height: var(--hdr); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); }
.nav, .tools { display: flex; gap: 20px; align-items: center; flex: 1; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; }
.tools { justify-content: flex-end; }
.logo { position: absolute; inset-inline: 0; margin: auto; width: max-content; font-size: 36px; line-height: 1; }
.txt:hover, .nav a:hover { opacity: .6; }
main { padding-top: var(--hdr); min-height: 80vh; }

.page-title { font-size: clamp(56px, 11vw, 150px); line-height: .95; padding: 70px 20px 60px; letter-spacing: -.02em; }
html[lang=fa] .page-title { font-size: clamp(44px, 8vw, 110px); line-height: 1.2; }
.tabs { display: flex; gap: 8px; padding: 0 20px 24px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { padding: 6px 10px; font-size: 12px; text-transform: uppercase; border: 1px solid transparent; border-radius: 3px; }
.tab.on { border-color: var(--fg); }
.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); font-size: 13px; }
.bar > :last-child { justify-self: end; }
.bar select { border: 0; background: none; font: inherit; cursor: pointer; }
.seg { display: flex; gap: 14px; align-items: center; }
.seg button { color: var(--muted); } .seg button.on { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.gridbtn { width: 22px; height: 22px; opacity: .4; } .gridbtn.on { opacity: 1; }
.gridbtn i { display: grid; gap: 2px; width: 100%; height: 100%; } .gridbtn i b { background: currentColor; }

.grid { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.card { background: var(--tile); position: relative; aspect-ratio: 4 / 5; overflow: hidden; display: block; content-visibility: auto; contain-intrinsic-size: auto 400px; contain: layout paint; }
.card img { width: 100%; height: 100%; object-fit: cover; }
.card img.alt { position: absolute; inset: 0; visibility: hidden; }
.card img.alt:not([src]) { display: none; }
@media (hover: hover) { .card:hover img.alt { visibility: visible; } }
.card .meta { position: absolute; inset: auto 0 0 0; padding: 10px 12px; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; opacity: 0; background: linear-gradient(transparent, rgba(255,255,255,.85)); }
.card:hover .meta, .grid.dense .card .meta { opacity: 1; }
.badge { position: absolute; top: 10px; inset-inline-start: 10px; background: #fff; padding: 2px 8px; font-size: 11px; border-radius: 2px; }
.empty { padding: 80px 20px; text-align: center; color: var(--muted); }

.pdp { display: grid; grid-template-columns: 1fr 400px; }
.pdp .gallery img { width: 100%; background: var(--tile); }
.pdp .info { position: sticky; top: var(--hdr); align-self: start; height: calc(100vh - var(--hdr)); padding: 56px 28px 24px; overflow-y: auto; display: flex; flex-direction: column; }
.crumbs { font-size: 11px; color: var(--muted); margin-bottom: 14px; } .crumbs a:hover { text-decoration: underline; }
.pdp h1 { font-size: 46px; line-height: 1; margin-bottom: 22px; }
html[lang=fa] .pdp h1 { font-size: 34px; line-height: 1.3; }
.buy { display: flex; gap: 8px; margin-top: 18px; }
.sizebtn { flex: 1; border: 1px solid var(--fg); padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; text-align: start; }
.addbtn { flex: 1; background: var(--fg); color: #fff; padding: 12px 14px; display: flex; justify-content: space-between; font-size: 11px; text-transform: uppercase; font-weight: 600; }
.addbtn:disabled { opacity: .35; cursor: not-allowed; }
.price-old { text-decoration: line-through; opacity: .6; margin-inline-end: 8px; }
.desc { margin-top: 20px; line-height: 1.8; font-size: 13px; color: #333; white-space: pre-line; }
.acc { margin-top: auto; border-top: 1px solid var(--fg); }
.acc details { border-bottom: 1px solid var(--fg); }
.acc summary { list-style: none; padding: 10px 0; font-weight: 600; font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; }
.acc summary::after { content: '⌄'; } .acc details[open] summary::after { content: '⌃'; }
.acc .body { padding: 0 0 14px; line-height: 1.8; white-space: pre-line; color: #333; font-size: 13px; }
.thumbs { display: none; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40; }
.overlay.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(100vw, 576px); background: #fff; z-index: 50; transform: translateX(100%); transition: transform .3s; display: flex; flex-direction: column; }
[dir=rtl] .drawer { transform: translateX(-100%); }
.drawer.on { transform: none !important; }
.dh { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); font-size: 13px; }
.db { flex: 1; overflow-y: auto; }
.row { display: flex; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); font-size: 13px; width: 100%; text-align: start; }
button.row:hover:not(:disabled) { background: #f6f6f6; } .row:disabled { color: var(--muted); } .row:disabled .n { text-decoration: line-through; }
.df { padding: 16px 20px; border-top: 1px solid var(--line); font-size: 12px; display: grid; gap: 6px; }
.btn { background: var(--fg); color: #fff; padding: 14px; text-align: center; font-weight: 600; font-size: 12px; text-transform: uppercase; width: 100%; margin-top: 8px; }
.btn.ghost { background: none; color: var(--fg); border: 1px solid var(--fg); }
.line { display: flex; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.line img { width: 96px; height: 120px; object-fit: cover; background: var(--tile); }
.line .lc { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.line .top2 { display: flex; justify-content: space-between; font-weight: 500; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); margin-top: auto; align-self: flex-start; }
.qty button { width: 28px; height: 26px; } .qty span { min-width: 28px; text-align: center; }
.link { text-decoration: underline; font-size: 11px; }
.form { padding: 20px; display: grid; gap: 14px; align-content: start; }
.form label { display: grid; gap: 6px; font-size: 12px; }
.form input, .form textarea { border: 1px solid var(--fg); padding: 11px; font: inherit; border-radius: 0; width: 100%; background: #fff; }
.err { color: #c00; font-size: 12px; min-height: 1em; }
.done { padding: 60px 24px; text-align: center; line-height: 2; }
.done h2 { font-size: 24px; margin-bottom: 8px; }

.toast { position: fixed; bottom: 24px; inset-inline-start: 24px; background: #000; color: #fff; padding: 12px 18px; font-size: 13px; z-index: 60; opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; }
.toast.on { opacity: 1; transform: none; }
.static { padding: 60px 20px 100px; max-width: 720px; line-height: 2; } .static h1 { font-size: 64px; margin-bottom: 20px; }
.foot { display: flex; justify-content: space-between; padding: 40px 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 0; }

body.lock { overflow: hidden; }
.colors { margin-top: 18px; } .clabel { font-size: 12px; color: var(--muted); margin-bottom: 8px; } .clabel b { color: var(--fg); font-weight: 600; }
.sw-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 48px; height: 60px; border: 1px solid var(--line); outline: 2px solid transparent; outline-offset: 2px; overflow: hidden; background: var(--tile); position: relative; }
.swatch img { width: 100%; height: 100%; object-fit: cover; } .swatch.on { outline-color: var(--fg); } .swatch.out { opacity: .45; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; } .chip { min-width: 36px; padding: 5px 9px; border: 1px solid var(--line); font-size: 12px; text-align: center; } .chip.out { color: var(--muted); text-decoration: line-through; background: #fafafa; }
.props { margin: 4px 0 14px; font-size: 13px; } .props > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); } .props dt { color: var(--muted); } .props dd { text-align: end; }
.pn { display: flex; justify-content: space-between; padding: 14px 0 0; font-size: 12px; text-transform: uppercase; } .pn a:hover { opacity: .6; }
.related { border-top: 1px solid var(--line); padding: 36px 0 20px; } .related h2 { font-size: 22px; padding: 0 20px 16px; font-weight: 600; }
.rrow { display: flex; gap: 1px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; padding: 0 20px; } .rrow::-webkit-scrollbar { display: none; }
.rcard { flex: 0 0 clamp(150px, 20vw, 260px); display: grid; gap: 4px; padding-inline-end: 12px; scroll-snap-align: start; font-size: 12px; }
.rimg { aspect-ratio: 4 / 5; background: var(--tile); overflow: hidden; display: block; } .rimg img { width: 100%; height: 100%; object-fit: cover; }
.rn { margin-top: 6px; } .rp { color: var(--muted); }
.menubtn { display: none; font-size: 22px; line-height: 1; padding: 8px; margin-inline-start: -8px; }
.row.sub { padding-inline-start: 36px; color: var(--muted); }
.gdots { display: none; }
.drawer { height: 100dvh; }
.tab, .gridbtn, .seg button, .txt { -webkit-tap-highlight-color: transparent; }

@media (max-width: 900px) {
  :root { --hdr: 56px; }
  .top { padding: 0 14px; }
  .menubtn { display: block; }
  .nav a { display: none; }
  .logo { font-size: 28px; }
  .tools { gap: 12px; }
  .page-title { padding: 32px 16px 22px; font-size: clamp(44px, 16vw, 90px); }
  html[lang=fa] .page-title { font-size: clamp(38px, 13vw, 76px); }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding: 0 16px 16px; gap: 6px; scrollbar-width: none; scroll-snap-type: x proximity; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; padding: 9px 14px; scroll-snap-align: start; border-color: var(--line); }
  .tab.on { border-color: var(--fg); background: var(--fg); color: #fff; }
  .bar { display: flex; justify-content: space-between; gap: 10px; padding: 8px 14px; position: sticky; top: var(--hdr); background: #fff; z-index: 20; }
  .bar .count { display: none; }
  .bar select { min-height: 40px; max-width: 42vw; }
  .seg { gap: 8px; } .seg button { min-height: 40px; padding: 0 4px; }
  .gridbtn { width: 28px; height: 28px; padding: 3px; }
  .grid { --cols: 2 !important; } .grid.dense { --cols: 3 !important; }
  .badge { top: 6px; font-size: 10px; padding: 1px 6px; }

  .pdp { display: block; }
  .gwrap { position: relative; }
  .pdp .gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
  .pdp .gallery::-webkit-scrollbar { display: none; }
  .pdp .gallery img { flex: 0 0 100%; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; scroll-snap-align: start; }
  .gdots { display: flex; position: absolute; bottom: 12px; inset-inline: 0; justify-content: center; gap: 6px; pointer-events: none; }
  .gdots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(0,0,0,.25); } .gdots i.on { background: #000; }
  .pdp .info { position: static; height: auto; padding: 22px 16px calc(96px + env(safe-area-inset-bottom)); }
  .pdp h1, html[lang=fa] .pdp h1 { font-size: 30px; margin-bottom: 14px; }
  .buy { position: fixed; inset: auto 0 0 0; z-index: 25; margin: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
  .sizebtn, .addbtn { min-height: 48px; font-size: 12px; }
  .swatch { width: 56px; height: 70px; } .related h2 { padding: 0 16px 14px; } .rrow { padding: 0 16px; } .related { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .pdp .info { padding-bottom: 24px; }

  .drawer { width: 100vw; }
  .drawer.bottom { top: auto; height: auto; max-height: 75dvh; border-radius: 14px 14px 0 0; transform: translateY(100%); padding-bottom: env(safe-area-inset-bottom); }
  [dir=rtl] .drawer.bottom { transform: translateY(100%); }
  .row { padding: 16px 20px; font-size: 15px; }
  .dh { padding: 14px 20px; } .dh button { font-size: 20px; padding: 6px 10px; margin: -6px -10px; }
  .line img { width: 80px; height: 100px; }
  .qty button { width: 40px; height: 36px; } .link { padding: 8px 0; font-size: 12px; }
  .df { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .form input, .form textarea { font-size: 16px; padding: 13px; }
  .btn { padding: 16px; font-size: 13px; }
  .toast { inset-inline: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); text-align: center; }
  .static { padding: 36px 16px 70px; } .static h1 { font-size: 44px; }
  .foot { padding: 28px 16px; flex-direction: column; gap: 6px; }
}
@media (max-width: 380px) { .logo { font-size: 24px; } .seg button { font-size: 12px; } }

/* ---- v2: sale, sub-tabs, coupon/summary, account ---- */
.badge.sale { inset-inline-start: auto; inset-inline-end: 10px; background: #c0272d; color: #fff; font-weight: 600; }
.tabs.sub { padding-top: 10px; border-bottom: 1px solid var(--line); background: #fafafa; } .tabs.sub .tab { font-size: 11px; text-transform: none; color: var(--muted); } .tabs.sub .tab.on { color: var(--fg); }
.salebar { display: inline-block; background: #fdecec; color: #c0272d; padding: 4px 10px; font-size: 12px; margin: -10px 0 12px; } .salebar b { margin-inline-end: 4px; }
.price-old { text-decoration: line-through; opacity: .55; margin-inline-end: 8px; }
.coupon { display: flex; gap: 8px; } .coupon input { flex: 1; min-width: 0; border: 1px solid var(--fg); padding: 10px; font: inherit; border-radius: 0; text-transform: uppercase; } .coupon .btn { width: auto; margin: 0; padding: 10px 16px; }
.sumrow { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 2px 0; } .sumrow.total { font-size: 15px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-size: 12px; line-height: 1.6; } .check input { width: auto !important; margin-top: 3px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.8; }
.acct { max-width: 760px; margin: 0 auto; padding: 48px 20px 80px; } .acct h1 { font-size: 56px; margin-bottom: 24px; } .acct h2 { font-size: 16px; font-weight: 600; margin: 28px 0 12px; text-transform: uppercase; }
.prof { padding: 0; border: 1px solid var(--line); padding: 18px; }
.ord { border: 1px solid var(--line); margin-bottom: 12px; padding: 14px 16px; display: grid; gap: 6px; font-size: 13px; }
.ord .oh { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .ord .oh span:nth-child(2) { color: var(--muted); } .stb { margin-inline-start: auto; background: #111; color: #fff; padding: 2px 10px; font-size: 11px; } .stb.bad { background: #c0272d; }
.steps { display: flex; gap: 4px; margin: 6px 0; } .steps span { flex: 1; text-align: center; font-size: 11px; padding-top: 8px; border-top: 3px solid var(--line); color: var(--muted); } .steps span.on { border-color: #111; color: var(--fg); font-weight: 600; }
.oi { display: flex; justify-content: space-between; gap: 12px; } .oi.tot { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; } .oa { display: flex; gap: 16px; }
@media (max-width: 900px) { .acct { padding: 28px 16px 90px; } .acct h1 { font-size: 40px; } #acctBtn { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .coupon input, .check { font-size: 16px; } }

/* ---- v3: unified product options (color + size share one pattern; chips are the real selector) ---- */
.og { margin-top: 20px; } .og + .og { margin-top: 16px; }
.olabel { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 8px; } .olabel b { color: var(--fg); font-weight: 600; }
.low { margin-inline-start: auto; color: #c0272d; font-size: 11px; }
.cdot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); display: inline-block; }
.chips { margin-top: 0; gap: 8px; }
.chip { min-width: 48px; height: 44px; padding: 0 14px; border: 1px solid var(--line); background: #fff; font-size: 13px; cursor: pointer; transition: border-color .12s, background .12s, color .12s; }
.chip:hover { border-color: var(--fg); } .chip.on { background: var(--fg); color: #fff; border-color: var(--fg); }
.chip.out { color: var(--muted); text-decoration: line-through; background: #fafafa; } .chip.out:hover { border-color: var(--line); }
.chip:focus-visible, .swatch:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.chips.need { animation: shake .4s; outline: 1px solid #c0272d; outline-offset: 5px; }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.notifybox { margin-top: 10px; padding: 10px 12px; background: #fafafa; border: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; } .notifybox[hidden] { display: none; }
.buy { margin-top: 22px; }
.addbtn { width: 100%; min-height: 52px; align-items: center; justify-content: space-between; transition: background .15s, color .15s; }
.addbtn.needs { background: #fff; color: var(--fg); border: 1px solid var(--fg); }
.addbtn:disabled { background: #eee; color: var(--muted); border-color: #eee; opacity: 1; }
@media (max-width: 900px) { .chip { height: 48px; min-width: 52px; } }

/* ---- v3: desktop gallery — 2-column grid, capped width, natural image ratio ---- */
@media (min-width: 901px) {
  .pdp { max-width: 1840px; margin: 0 auto; grid-template-columns: minmax(0, 1fr) clamp(380px, 28vw, 480px); }
  .pdp .gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; align-content: start; }
  .pdp .gallery img { width: 100%; height: auto; }
  .pdp .gallery img:only-child { grid-column: 1 / -1; max-width: 760px; margin: 0 auto; }
  .pdp .info { padding-inline: clamp(24px, 2.4vw, 44px); }
}

[hidden] { display: none !important; }
