:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e2db;
  --accent: #e4572e;
  --accent-dark: #c4421d;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --err: #b91c1c;
  --err-bg: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 4px 16px rgba(28, 25, 23, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110f;
    --surface: #1e1a17;
    --ink: #f5f1ec;
    --muted: #a8a29e;
    --line: #34302c;
    --ok-bg: #0f2a1a;
    --err-bg: #2d1414;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
p { margin: 0 0 1em; }

.container { width: min(1180px, 100% - 32px); margin-inline: auto; }
.section { padding: 40px 0; }
.muted { color: var(--muted); }
.price { font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--accent); color: #fff; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-outline:hover { background: var(--surface); border-color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); padding: 6px 10px; }
.btn-ghost:hover { background: transparent; color: var(--err); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-row { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.logo { font-weight: 800; font-size: 1.35rem; text-decoration: none; letter-spacing: -.02em; }
.logo span { color: var(--accent); }

.search { flex: 1; max-width: 420px; position: relative; }
.search input { width: 100%; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a, .nav button.linklike { padding: 8px 12px; border-radius: 8px; text-decoration: none; font-weight: 500; background: none; border: 0; font: inherit; font-weight: 500; color: inherit; cursor: pointer; }
.nav a:hover, .nav a.active, .nav button.linklike:hover { background: var(--bg); }
.nav .user { color: var(--muted); padding: 0 8px; }
.cart-link { position: relative; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 20px; }

.menu-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font: inherit; color: inherit; cursor: pointer; }

.cat-bar { border-top: 1px solid var(--line); background: var(--surface); }
.cat-bar .container { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.cat-bar a { white-space: nowrap; padding: 6px 14px; border-radius: 999px; text-decoration: none; font-size: .92rem; color: var(--muted); }
.cat-bar a:hover, .cat-bar a.active { background: var(--bg); color: var(--ink); }

@media (max-width: 860px) {
  .menu-toggle { display: inline-block; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .header-row { flex-wrap: wrap; padding: 10px 0; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; margin: 0; order: 4; }
  .nav.open { display: flex; }
  /* the 3-row header would eat a fifth of a phone screen, so it scrolls away */
  .site-header { position: static; }
  /* show every category instead of hiding some behind a sideways scroll */
  .cat-bar .container { flex-wrap: wrap; overflow-x: visible; }
}

/* ---------- messages ---------- */
.messages { padding-top: 16px; }
.message { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 8px; border: 1px solid; }
.message.success { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.message.error { background: var(--err-bg); border-color: var(--err); color: var(--err); }

/* ---------- hero ---------- */
.hero { background: linear-gradient(135deg, #fff1ea, #ffe0d1); border-radius: 20px; padding: clamp(28px, 6vw, 64px); margin-top: 24px; color: #1c1917; }
.hero p { font-size: 1.15rem; max-width: 52ch; color: #44403c; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.hero .btn-outline { color: #1c1917; border-color: #1c1917; }
@media (prefers-color-scheme: dark) { .hero { background: linear-gradient(135deg, #3a1f14, #2b1a12); color: var(--ink); } .hero p { color: var(--muted); } .hero .btn-outline { color: var(--ink); border-color: var(--muted); } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section-head h2 { margin: 0; }

/* ---------- category tiles ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.cat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 12px; text-align: center; text-decoration: none; font-weight: 600; transition: box-shadow .15s, transform .15s; }
.cat-tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.cat-tile .icon { font-size: 2rem; display: block; margin-bottom: 6px; }

/* ---------- product grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-media { text-decoration: none; aspect-ratio: 1 / 1; background: var(--bg); display: block; position: relative; overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.placeholder { text-decoration: none; width: 100%; height: 100%; display: grid; place-items: center; font-size: 3rem; font-weight: 800; color: var(--muted); background: repeating-linear-gradient(45deg, var(--bg), var(--bg) 12px, var(--surface) 12px, var(--surface) 24px); }
.tag { position: absolute; top: 10px; left: 10px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--ink); color: var(--bg); }
.tag.out { background: var(--err); color: #fff; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-cat { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.card-title { font-weight: 600; text-decoration: none; margin: 0; font-size: 1rem; }
.card-title:hover { color: var(--accent); }
.card-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-foot .price { font-size: 1.1rem; }
.card-foot form { margin: 0; }
.card-foot .btn { padding: 7px 14px; font-size: .9rem; }

/* ---------- toolbar / pagination ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.toolbar select { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 32px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; background: var(--surface); }
.pagination .current { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.empty { text-align: center; padding: 64px 16px; color: var(--muted); }
.empty .icon { font-size: 3rem; display: block; margin-bottom: 8px; }

.breadcrumb { font-size: .9rem; color: var(--muted); margin: 20px 0 8px; }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

/* ---------- product detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; margin-top: 12px; }
.detail-media { aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.detail-media img { width: 100%; height: 100%; object-fit: cover; }
.detail-price { font-size: 2rem; font-weight: 800; margin: 8px 0 16px; }
.stock { display: inline-block; font-weight: 600; margin-bottom: 16px; }
.stock.in { color: var(--ok); }
.stock.out { color: var(--err); }
.meta { color: var(--muted); font-size: .9rem; margin-top: 20px; }
@media (max-width: 760px) { .detail { grid-template-columns: 1fr; gap: 20px; } }

/* ---------- cart / checkout ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.line-item { display: grid; grid-template-columns: 84px 1fr auto; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); align-items: center; }
.line-item:last-child { border-bottom: 0; }
.line-thumb { text-decoration: none; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--bg); }
.line-thumb img { width: 100%; height: 100%; object-fit: cover; }
.line-thumb .placeholder { font-size: 1.6rem; }
.line-title { font-weight: 600; text-decoration: none; }
.line-title:hover { color: var(--accent); }
.line-side { text-align: right; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; margin-top: 6px; }
.qty form { margin: 0; }
.qty button { width: 34px; height: 34px; border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--ink); border-radius: 999px; }
.qty button:hover:not([disabled]) { background: var(--bg); }
.qty button[disabled] { opacity: .35; cursor: not-allowed; }
.qty strong { min-width: 28px; text-align: center; }
.summary-row { display: flex; justify-content: space-between; padding: 6px 0; }
.summary-total { font-size: 1.3rem; font-weight: 800; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; }
.sticky { position: sticky; top: 90px; }

/* ---------- forms ---------- */
.form-card { max-width: 440px; margin: 40px auto; }
.form-card.wide { max-width: 640px; }
.form-card p { margin-bottom: 14px; }
.field label, .form-card label, .panel label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=tel], textarea {
  width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 110px; resize: vertical; }
[hidden] { display: none !important; }

/* ---------- checkout: delivery choice ---------- */
fieldset.choice-group { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.choice-group legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
/* "До офис / автомат / адрес": one option per line */
#type-group .choices { grid-template-columns: 1fr; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-body { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); transition: border-color .15s, box-shadow .15s; }
.choice-body small { color: var(--muted); font-weight: 400; }
.choice:hover .choice-body { border-color: var(--muted); }
.choice input:checked + .choice-body { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; background: var(--surface); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--accent); outline-offset: 2px; }
.combo { position: relative; }
#city-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 15; margin: 4px 0 0; padding: 4px; list-style: none; max-height: 280px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
#city-list li { padding: 9px 12px; border-radius: 8px; cursor: pointer; }
#city-list li[aria-selected="true"], #city-list li:hover { background: var(--bg); }
#city-list li small { color: var(--muted); }
#city-list li.empty { color: var(--muted); cursor: default; }
.field { margin-bottom: 16px; }
.office-list { display: grid; gap: 8px; max-height: 380px; overflow: auto; margin-top: 8px; padding: 2px; }
.office-list .choice-body { padding: 10px 14px; }
#office-filter { margin-top: 6px; }
.message ul { margin: 6px 0 0; padding-left: 20px; }

label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer; }
label.check input { width: auto; margin-top: 4px; flex: none; }
.helptext { display: block; color: var(--muted); font-size: .82rem; margin-top: 4px; }
.helptext ul { padding-left: 18px; margin: 4px 0 0; }
.errorlist { list-style: none; padding: 0; margin: 0 0 6px; color: var(--err); font-size: .88rem; }

/* ---------- success ---------- */
.success-box { text-align: center; max-width: 520px; margin: 60px auto; }
.success-box .icon { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; font-size: 2.2rem; margin: 0 auto 16px; }

/* ---------- orders ---------- */
.order { margin-bottom: 16px; }
.order-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.order ul { list-style: none; padding: 0; margin: 0; }
.order li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--bg); border: 1px solid var(--line); }
.pill.paid { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }

/* ---------- blog ---------- */
.post-card .card-media { aspect-ratio: 16 / 9; }
.post-date { font-size: .85rem; color: var(--muted); }
.post-excerpt { color: var(--muted); }
.article { max-width: 760px; margin: 0 auto; }
.article-cover { border-radius: var(--radius); margin: 20px 0; width: 100%; max-height: 420px; object-fit: cover; }
.article-body { font-size: 1.08rem; }
.article-body img { height: auto; border-radius: 8px; }

/* ---------- footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 48px; padding: 32px 0; color: var(--muted); font-size: .92rem; }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; }
.footer-row a { text-decoration: none; }
.footer-row a:hover { color: var(--accent); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
