:root {
  --bg: #0b0c0f;
  --surface: #14161b;
  --surface-2: #1b1e25;
  --border: #252933;
  --text: #eceef2;
  --muted: #8a909c;
  --accent: #b9f25b;
  --accent-ink: #11140a;
  --ok: #4ade80;
  --mid: #facc15;
  --low: #fb7185;
  --radius: 16px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e3e6eb;
    --text: #14161b; --muted: #687080; --accent: #3f6d00; --accent-ink: #ffffff;
    --ok: #16a34a; --mid: #b45309; --low: #e11d48; --shadow: 0 10px 30px -16px rgba(20, 30, 50, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 68px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; text-decoration: none; white-space: nowrap; }
.logo-mark { color: var(--accent); font-size: 20px; }
.contact { color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.contact:hover { color: var(--accent); }

.search { flex: 1; position: relative; max-width: 620px; margin: 0 auto; }
.search svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search input {
  width: 100%; height: 44px; padding: 0 44px 0 42px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font: 600 12px/1 inherit; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 4px 7px; }
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { display: none; }

/* ---------- chips & toolbar ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 22px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  transition: color .15s, border-color .15s, background .15s;
}
.chip span { font-size: 12px; opacity: .7; }
.chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0 18px; flex-wrap: wrap; }
.found { color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.found b { color: var(--text); }
.filter-pill { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); text-decoration: none; color: var(--text); }
.sort { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.sort select {
  appearance: none; font: inherit; font-weight: 600; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 34px 8px 12px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}

/* ---------- grid & cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; transition: opacity .15s; }
.grid.loading { opacity: .45; pointer-events: none; }
.card {
  display: flex; flex-direction: column; gap: 12px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .18s, border-color .18s, box-shadow .18s;
  animation: rise .3s ease both;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: var(--shadow); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 4px 10px;
  border-radius: 8px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.badge:hover { color: var(--text); }
.stock { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ok); white-space: nowrap; }
.stock i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.stock-mid { color: var(--mid); }
.stock-low { color: var(--low); }

.card-title { margin: 0; font-size: 17px; line-height: 1.35; font-weight: 700; overflow-wrap: anywhere; }

.seller { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); text-decoration: none; width: fit-content; }
.seller:hover { color: var(--text); }
.avatar { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font-size: 10px; font-weight: 800;
  color: hsl(var(--h) 80% 85%); background: hsl(var(--h) 45% 28%); }
@media (prefers-color-scheme: light) { .avatar { color: hsl(var(--h) 60% 28%); background: hsl(var(--h) 70% 90%); } }

.desc { font-size: 14px; color: var(--muted); }
.desc-body { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.desc.open .desc-body { display: block; }
.desc-body a { color: var(--accent); text-decoration: none; }
.desc-body a:hover { text-decoration: underline; }
.desc-toggle { margin-top: 6px; padding: 0; border: 0; background: none; color: var(--text); font: 600 13px/1 inherit; cursor: pointer; }
.desc-toggle:hover { color: var(--accent); }

.card-bottom { margin-top: auto; padding-top: 14px; border-top: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.price { display: flex; align-items: center; gap: 8px; }
.price-value { font-size: 22px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }

/* ---------- tooltip ---------- */
.hint { position: relative; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 800; cursor: help; outline: none; flex: none; }
.hint:hover, .hint:focus { color: var(--text); border-color: var(--muted); }
.hint-bubble {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translate(-50%, 4px);
  width: 230px; padding: 10px 12px; border-radius: 10px; background: var(--text); color: var(--bg);
  font-size: 13px; font-weight: 500; line-height: 1.4; text-align: left;
  opacity: 0; visibility: hidden; transition: opacity .15s, transform .15s; z-index: 5; pointer-events: none;
}
.hint-bubble::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--text); }
.hint:hover .hint-bubble, .hint:focus .hint-bubble { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.hint.edge-left .hint-bubble { left: -10px; transform: translate(0, 4px); }
.hint.edge-left:hover .hint-bubble, .hint.edge-left:focus .hint-bubble { transform: translate(0, 0); }
.hint.edge-left .hint-bubble::after { left: 20px; }

/* ---------- buttons ---------- */
.btn-buy {
  display: inline-flex; align-items: center; justify-content: center; height: 42px; padding: 0 20px;
  border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  font: 700 15px/1 inherit; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .1s, filter .15s;
}
.btn-buy:hover { filter: brightness(1.08); }
.btn-buy:active { transform: scale(.97); }
.btn-ghost {
  height: 42px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: 600 15px/1 inherit; cursor: pointer; transition: border-color .15s;
}
.btn-ghost:hover { border-color: var(--muted); }
.more { display: flex; justify-content: center; padding: 28px 0 8px; }

/* ---------- empty / footer ---------- */
.empty { text-align: center; padding: 70px 16px; color: var(--muted); }
.empty-icon { font-size: 44px; line-height: 1; margin-bottom: 8px; }
.empty p { margin: 0 0 4px; color: var(--text); font-size: 18px; font-weight: 700; }
.footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 32px; padding-bottom: 32px;
  margin-top: 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.footer a { color: var(--accent); text-decoration: none; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); animation: fade .2s ease; }
.modal-box {
  position: relative; width: 100%; max-width: 440px; padding: 28px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); text-align: center;
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.2);
}
.modal-box h2 { margin: 6px 0 8px; font-size: 20px; }
.modal-box p { margin: 0; color: var(--muted); }
.modal-box p b { color: var(--text); }
.modal-icon { width: 56px; height: 56px; margin: 0 auto 6px; border-radius: 16px; display: grid; place-items: center;
  font-size: 26px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.modal-product { margin: 16px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.modal-actions { display: grid; gap: 10px; margin-top: 20px; }
.modal-x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 10px; border: 0;
  background: transparent; color: var(--muted); font-size: 15px; cursor: pointer; }
.modal-x:hover { background: var(--surface-2); color: var(--text); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
body.modal-open { overflow: hidden; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 12px 0; gap: 10px 16px; }
  .logo { order: 1; }
  .contact { order: 2; margin-left: auto; font-size: 14px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .grid { grid-template-columns: 1fr; }
  .sort span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
