:root {
  --bg: #ffffff; --fg: #15171c; --muted: #5f6673; --line: #e5e7ec; --card: #f6f7f9;
  --accent: #6d28d9; --accent-fg: #ffffff; --ok: #15803d; --order: #b45309; --out: #9ca3af; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111318; --fg: #eef0f4; --muted: #a2a9b6; --line: #262a33; --card: #1a1d24; --accent: #a78bfa; --accent-fg: #111318; --ok: #4ade80; --order: #fbbf24; --out: #6b7280; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); }
img { max-width: 100%; height: auto; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.2; margin: .6em 0 .4em; }
h2 { font-size: 1.25rem; margin: 1.6em 0 .6em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.top { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 1.35rem; color: var(--fg); text-decoration: none; letter-spacing: -.02em; }
.top-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.top-nav a { color: var(--fg); text-decoration: none; }
.top-nav a:hover { color: var(--accent); }
.cart-count { display: inline-block; min-width: 1.5em; padding: 0 .4em; border-radius: 999px; background: var(--accent); color: var(--accent-fg); font-size: .8rem; text-align: center; }

.hero { padding: 28px 0 8px; }
.hero p { color: var(--muted); max-width: 640px; }

.cats { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.cats a { display: flex; flex-direction: column; gap: 2px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--fg); text-decoration: none; height: 100%; }
.cats a:hover { border-color: var(--accent); }
.cats small { color: var(--muted); }

.grid { list-style: none; padding: 0; margin: 0 0 32px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.card-out { opacity: .7; }
.card-link { color: var(--fg); text-decoration: none; display: flex; flex-direction: column; gap: 8px; }
.card-img { display: block; aspect-ratio: 1; background: #fff; border-radius: 8px; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.card-name { font-size: .95rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-price, .price { font-weight: 700; font-size: 1.1rem; }
.card-price s, .price s { color: var(--muted); font-weight: 400; font-size: .9em; margin-right: 4px; }
.card .btn { margin-top: auto; }

.badge { display: inline-block; font-size: .85rem; margin: 0; }
.badge.ok { color: var(--ok); } .badge.order { color: var(--order); } .badge.out { color: var(--out); }

.btn { appearance: none; border: 0; border-radius: 10px; padding: 10px 16px; background: var(--accent); color: var(--accent-fg); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-big { padding: 14px 22px; font-size: 1.05rem; }
.btn-link { background: none; color: var(--muted); padding: 4px 8px; font-weight: 400; }

.crumbs { font-size: .9rem; color: var(--muted); margin-top: 16px; }
.crumbs a { color: var(--muted); }

.product { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
.gallery { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; grid-template-columns: repeat(4, 1fr); }
.gallery li { background: #fff; border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.gallery li:first-child { grid-column: 1 / -1; }
.gallery li:not(:first-child) { cursor: pointer; }
.gallery li.active { outline: 2px solid var(--accent); }
.gallery img { width: 100%; height: 100%; object-fit: contain; }
.buy h1 { margin-top: 0; }
.vendor { color: var(--muted); margin: 0 0 8px; }
.qty-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin: 16px 0; }
.qty-row input { width: 80px; }
.specs { border-collapse: collapse; width: 100%; max-width: 760px; }
.specs th, .specs td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.specs th { color: var(--muted); font-weight: 400; width: 45%; }
.desc { max-width: 820px; overflow-wrap: anywhere; }

input, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; margin: 0 0 12px; }
.radio { display: flex; gap: 8px; align-items: center; }
.radio input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 8px 12px; }
.order { max-width: 560px; margin: 24px 0 40px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.form-msg { min-height: 1.5em; }
.form-msg.err { color: #dc2626; }

.cart-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.cart-table th, .cart-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.cart-table td:first-child { display: flex; gap: 10px; align-items: center; }
.cart-table img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 6px; flex: none; }
.cart-table input { width: 72px; }
.total { font-size: 1.25rem; font-weight: 700; }
.done { padding: 24px; border: 1px solid var(--ok); border-radius: var(--radius); margin: 24px 0; }

.foot { border-top: 1px solid var(--line); margin-top: 48px; padding: 24px 0; color: var(--muted); font-size: .9rem; }
.foot-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

@media (max-width: 760px) {
  .product { grid-template-columns: 1fr; }
  .cart-table thead { display: none; }
  .cart-table tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .cart-table td { border: 0; padding: 2px 0; }
  .cart-table td:first-child { grid-column: 1 / -1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}
