:root {
  --brand: #6767e5;
  --brand-dark: #5252cc;
  --brand-tint: #f0f0fd;
  --ink: #2e2e33;
  --ink-2: #5c5c66;
  --ink-3: #8a8a94;
  --line: #e4e4ec;
  --line-strong: #cfcfda;
  --bg: #ffffff;
  --bg-soft: #f7f7fb;
  --danger: #df1b41;
  --ok: #1a7f4b;
  --warn: #9a5b00;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 40, 0.06);
  --shadow: 0 2px 6px rgba(20, 20, 40, 0.06), 0 8px 24px rgba(20, 20, 40, 0.08);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Poppins', var(--font);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid transparent; font-weight: 600; font-size: 15px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: #b3b3ee; cursor: not-allowed; }
.btn-secondary { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink-3); }
.btn-block { width: 100%; }
.btn-lg { height: 48px; font-size: 16px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 500; cursor: pointer; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(8px); }
.site-header .inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.wordmark { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); }
.wordmark img { height: 40px; width: auto; }
.wordmark span { font-size: 14px; font-weight: 500; color: var(--ink-2); padding-left: 14px; border-left: 1px solid var(--line-strong); line-height: 28px; }
.cart-btn { position: relative; }
.cart-count {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #fff;
}
.cart-count[hidden] { display: none; }

/* Intro band */
.intro { background: var(--brand) linear-gradient(120deg, #6767e5 0%, #7a6ee8 60%, #8b72e6 100%); color: #fff; }
.intro .inner { max-width: 1200px; margin: 0 auto; padding: 36px 16px 32px; display: flex; gap: 32px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.intro h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.intro p { margin: 8px 0 0; color: #e6e6fb; font-size: 16px; max-width: 560px; }
.intro dl { display: flex; gap: 28px; margin: 0; padding: 12px 18px; background: rgba(255,255,255,.12); border-radius: 10px; }
.intro dt { font-size: 13px; color: #d9d9f7; }
.intro dd { margin: 2px 0 0; font-weight: 600; font-size: 15px; }

/* Catalog layout */
.catalog { max-width: 1200px; margin: 0 auto; padding: 28px 16px 56px; display: grid; grid-template-columns: 200px 1fr; gap: 32px; }
.filters h2 { font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 0 0 8px; font-family: var(--font); }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list button {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; margin-bottom: 2px; border: 0; border-radius: 6px; background: none;
  text-align: left; cursor: pointer; color: var(--ink-2); font-size: 14px;
}
.cat-list button:hover { background: var(--bg-soft); color: var(--ink); }
.cat-list button[aria-pressed="true"] { background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; }
.cat-list .n { font-size: 12px; color: var(--ink-3); }
.cat-select { display: none; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.search { position: relative; flex: 1; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 38px; }
.toolbar select { width: auto; }
.result-note { color: var(--ink-2); font-size: 14px; margin: -8px 0 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.card-media { position: relative; aspect-ratio: 1; background: #fff; border: 0; padding: 0; cursor: pointer; display: block; width: 100%; overflow: hidden; }
.card-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.card-media .tag { position: absolute; left: 10px; top: 10px; }
.photo-note { position: absolute; left: 8px; bottom: 8px; font-size: 11px; color: var(--ink-2); background: rgba(255,255,255,.9); padding: 1px 6px; border-radius: 4px; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-title { font-family: var(--font); font-size: 15px; font-weight: 600; line-height: 1.35; }
.card-title button { all: unset; cursor: pointer; }
.card-title button:hover { color: var(--brand-dark); }
.card-condition { font-size: 13px; color: var(--ink-2); }
.card-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-weight: 700; font-size: 18px; }
.stock-note { font-size: 12px; color: var(--ink-3); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: var(--ink); color: #fff; }
.tag-soldout { background: #fff; color: var(--ink-2); border: 1px solid var(--line-strong); }
.card.soldout img { opacity: .45; }

.empty { text-align: center; padding: 56px 16px; color: var(--ink-2); }
.empty h2 { font-size: 18px; color: var(--ink); margin-bottom: 6px; }

/* Policies band */
.policies { background: #ebebf5; }
.policies .inner { max-width: 1200px; margin: 0 auto; padding: 40px 16px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 24px; }
.policies h3 { font-family: var(--font); font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.policies p { margin: 0; font-size: 14px; color: var(--ink-2); }
.site-footer { background: var(--ink); }
.site-footer .inner { max-width: 1200px; margin: 0 auto; padding: 24px 16px; font-size: 14px; color: #c9c9d6; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.site-footer img { height: 36px; width: auto; }
.site-footer a { color: #fff; }

/* Form controls (shared with checkout and admin) */
.field { display: block; }
.field + .field { margin-top: 14px; }
.label { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; height: 44px; padding: 0 12px; background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
select.input { appearance: none; padding-right: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%235c5c66' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(103, 103, 229, 0.2); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(223, 27, 65, 0.15); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.field-error:empty { display: none; }
.hint { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.alert { padding: 12px 14px; border-radius: var(--radius); font-size: 14px; background: #fdecef; color: #8a1029; border: 1px solid #f6c4cf; }
.alert[hidden] { display: none; }

/* Quantity stepper */
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius); height: 36px; background: #fff; }
.qty button { width: 34px; height: 100%; border: 0; background: none; cursor: pointer; font-size: 18px; color: var(--ink-2); }
.qty button:disabled { color: var(--line-strong); cursor: not-allowed; }
.qty output { min-width: 28px; text-align: center; font-weight: 600; font-size: 14px; }

/* Dialog (product details) */
dialog { border: 0; padding: 0; border-radius: 14px; box-shadow: 0 24px 64px rgba(20,20,40,.25); max-width: 880px; width: calc(100% - 32px); color: var(--ink); }
dialog::backdrop { background: rgba(30, 30, 40, .5); }
.pd { display: grid; grid-template-columns: 1.1fr 1fr; }
.pd-media { margin: 0; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; min-height: 360px; }
.pd-media figcaption { font-size: 13px; color: var(--ink-3); text-align: center; }
.pd-media img { max-height: 460px; object-fit: contain; }
.pd-body { padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.pd-body h2 { font-size: 22px; font-weight: 600; padding-right: 32px; }
.pd-cat { font-size: 13px; color: var(--ink-3); }
.pd-price { font-size: 26px; font-weight: 700; }
.pd-cond { font-size: 14px; color: var(--ink-2); }
.pd-cond strong { color: var(--ink); font-weight: 600; }
.pd-desc { margin: 0; color: var(--ink-2); font-size: 14px; }
.pd-features { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.pd-features li + li { margin-top: 3px; }
.pd-buy { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.pd-buy .qty { height: 48px; }
.pd-buy .btn { flex: 1; }
.pd-note { font-size: 13px; color: var(--ink-3); margin: 0; }
.dialog-close { position: absolute; right: 12px; top: 12px; }

/* Cart drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(30, 30, 40, .45); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: #fff; z-index: 41; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; box-shadow: var(--shadow); visibility: hidden; }
.drawer.open { transform: none; visibility: visible; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 20px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 16px 20px 20px; }
.line { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line img { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px; }
.line-title { font-weight: 600; font-size: 14px; line-height: 1.35; }
.line-sub { font-size: 13px; color: var(--ink-2); }
.line-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.line-price { font-weight: 600; font-size: 14px; text-align: right; }
.line-warn { font-size: 13px; color: var(--warn); margin-top: 4px; }
.row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--ink-2); }
.row + .row { margin-top: 6px; }
.row.total { color: var(--ink); font-weight: 600; font-size: 16px; }
.drawer-foot .btn { margin-top: 14px; }
.drawer-foot .fine { font-size: 13px; color: var(--ink-3); text-align: center; margin: 10px 0 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; z-index: 60; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .catalog { grid-template-columns: 1fr; gap: 0; padding-top: 20px; }
  .filters { display: none; }
  .cat-select { display: block; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search { flex-basis: 100%; }
  .toolbar > label:not(.search) { flex: 1; min-width: 0; }
  .toolbar select { width: 100%; }
  .pd { grid-template-columns: 1fr; }
  .pd-media { border-right: 0; border-bottom: 1px solid var(--line); min-height: 0; padding: 16px; }
  .pd-media img { max-height: 300px; }
  .pd-body { padding: 20px; }
  .policies .inner { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 560px) {
  .intro h1 { font-size: 26px; }
  .intro .inner { padding: 24px 16px; gap: 16px; }
  .intro dl { gap: 20px; }
  .wordmark span { display: none; }
  .wordmark img { height: 34px; }
  .intro dl { width: 100%; justify-content: space-between; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-media img { padding: 8px; }
  .card-body { padding: 10px 10px 12px; }
  .card-title { font-size: 14px; }
  .card-foot { flex-direction: column; align-items: stretch; }
  .card-foot .btn { width: 100%; }
  .policies .inner { grid-template-columns: 1fr; gap: 16px; padding: 28px 16px; }
  dialog { width: 100%; max-width: none; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
