:root {
  --bg:          #F4F1EC;
  --surface:     #FFFFFF;
  --surface-2:   #F8F6F2;
  --border:      #E5E0D8;
  --text:        #1A1714;
  --text-muted:  #8A837A;
  --accent:      #E84040;
  --accent-dark: #C93535;
  --accent-bg:   #FEF0F0;
  --fav:         #E84040;
  --shadow-sm:   0 2px 8px  rgba(0,0,0,.07);
  --shadow-md:   0 6px 24px rgba(0,0,0,.10);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.13);
  --radius:      14px;
  --radius-sm:   8px;
  --radius-pill: 999px;
  --speed:       .2s;
}

[data-theme="dark"] {
  --bg:          #141210;
  --surface:     #1E1B18;
  --surface-2:   #252220;
  --border:      #332E28;
  --text:        #F0EAE2;
  --text-muted:  #8A8078;
  --accent:      #F05050;
  --accent-dark: #D44040;
  --accent-bg:   #2A1515;
  --shadow-sm:   0 2px 8px  rgba(0,0,0,.30);
  --shadow-md:   0 6px 24px rgba(0,0,0,.40);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.50);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--speed), color var(--speed);
  -webkit-font-smoothing: antialiased;
}

a      { text-decoration: none; color: inherit; }
button { cursor: pointer; }
img    { display: block; }

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background var(--speed), border-color var(--speed);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
}

.logo-icon {
  font-size: 1.4rem;
  color: var(--accent);
  line-height: 1;
}

.nav-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
  transition: background var(--speed), border-color var(--speed), transform .15s;
}
.icon-btn:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  transform: scale(1.04);
}

.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.hero {
  background: var(--text);
  color: #fff;
  text-align: center;
  padding: 60px 24px 52px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60px; left: 50%;
  transform: translateX(-50%);
  width: 500px; height: 280px;
  background: var(--accent);
  border-radius: 50%;
  opacity: .10;
  filter: blur(60px);
}

.hero-title {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: 12px;
  position: relative;
}

.hero-subtitle {
  font-size: 1.05rem;
  opacity: .65;
  position: relative;
}

.controls-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 66px;
  z-index: 90;
  transition: background var(--speed), border-color var(--speed);
}

.controls-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .95rem;
  pointer-events: none;
  opacity: .55;
}

.search-input {
  width: 100%;
  padding: 10px 38px 10px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  outline: none;
  transition: border-color var(--speed), box-shadow var(--speed), background var(--speed);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
  background: var(--surface);
}
.search-input::placeholder { color: var(--text-muted); }

.clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .78rem;
  display: none;
  line-height: 1;
  padding: 2px 4px;
}
.clear-btn:hover { color: var(--accent); }

.control-select {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color var(--speed), background var(--speed);
}
.control-select:focus { border-color: var(--accent); }

.toggle-btn {
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: .85rem;
  font-weight: 500;
  transition: all var(--speed);
  white-space: nowrap;
}
.toggle-btn:hover { border-color: var(--fav); color: var(--fav); }
.toggle-btn.active { background: var(--fav); border-color: var(--fav); color: #fff; }

.results-bar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 24px 2px;
}
.results-text { font-size: .82rem; font-weight: 500; color: var(--text-muted); }

.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 90px 24px;
  color: var(--text-muted);
  font-size: .9rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-wrap {
  display: flex;
  justify-content: center;
  padding: 60px 24px;
}

.error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.error-icon { font-size: 2.5rem; margin-bottom: 12px; }
.error-card h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.error-card p  { color: var(--text-muted); font-size: .9rem; line-height: 1.6; margin-bottom: 20px; }

.product-grid {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 24px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform var(--speed), box-shadow var(--speed), border-color var(--speed);
  animation: cardIn .38s ease both;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.card:nth-child(1) { animation-delay: .03s; }
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .09s; }
.card:nth-child(4) { animation-delay: .12s; }
.card:nth-child(5) { animation-delay: .15s; }
.card:nth-child(6) { animation-delay: .18s; }
.card:nth-child(7) { animation-delay: .21s; }
.card:nth-child(8) { animation-delay: .24s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-img-wrap {
  position: relative;
  background: var(--surface-2);
  height: 205px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  transition: background var(--speed);
}

.card-img {
  max-height: 160px;
  max-width: 100%;
  object-fit: contain;
  transition: transform .35s ease;
}
.card:hover .card-img { transform: scale(1.06); }

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  text-transform: capitalize;
  letter-spacing: .04em;
}

.card-fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: .95rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--speed);
}
.card-fav-btn:hover { border-color: var(--fav); color: var(--fav); transform: scale(1.1); }
.card-fav-btn.saved { color: var(--fav); border-color: var(--fav); background: var(--accent-bg); }

.card-body {
  padding: 14px 16px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-category {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
}

.card-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  margin-top: auto;
  padding-top: 2px;
}

.card-footer {
  padding: 12px 16px 16px;
  display: flex;
  gap: 8px;
}

.btn-cart {
  flex: 1;
  padding: 9px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: .82rem;
  font-weight: 700;
  transition: background var(--speed), transform .12s;
}
.btn-cart:hover  { background: var(--accent-dark); }
.btn-cart:active { transform: scale(.97); }

.btn-view {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: .82rem;
  font-weight: 500;
  transition: all var(--speed);
}
.btn-view:hover { border-color: var(--accent); color: var(--accent); }

.empty-wrap { text-align: center; padding: 70px 24px; }
.empty-icon { font-size: 2.8rem; margin-bottom: 12px; }
.empty-wrap h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.empty-wrap p  { color: var(--text-muted); margin-bottom: 20px; font-size: .9rem; }

.pagination {
  max-width: 1280px;
  margin: 16px auto 8px;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--speed);
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn.active   { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .35; cursor: default; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, .6);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .22s ease;
}
.modal-overlay[style*="display:none"] { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: popIn .3s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.88); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .82rem;
  display: grid;
  place-items: center;
  z-index: 2;
  transition: background var(--speed);
}
.modal-close:hover { background: var(--accent-bg); color: var(--accent); }

.modal-body { padding: 28px; display: flex; flex-direction: column; gap: 16px; }

.modal-img-wrap {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 28px;
  display: flex;
  justify-content: center;
}
.modal-img { max-height: 220px; object-fit: contain; }

.modal-category {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
}
.modal-title { font-size: 1.15rem; font-weight: 700; line-height: 1.4; }
.modal-price { font-size: 1.5rem; font-weight: 800; }
.modal-desc  { font-size: .875rem; line-height: 1.7; color: var(--text-muted); }

.modal-actions { display: flex; gap: 10px; }

.modal-fav-btn {
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: .88rem;
  font-weight: 600;
  transition: all var(--speed);
  flex-shrink: 0;
}
.modal-fav-btn:hover,
.modal-fav-btn.saved {
  background: var(--accent-bg);
  border-color: var(--fav);
  color: var(--fav);
}

.footer {
  text-align: center;
  padding: 28px 24px;
  margin-top: 32px;
  border-top: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-muted);
}

.btn-primary {
  display: inline-block;
  padding: 11px 26px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--speed), transform .12s;
}
.btn-primary:hover  { background: var(--accent-dark); }
.btn-primary:active { transform: scale(.97); }

@media (max-width: 768px) {
  .nav-inner       { padding: 0 16px; }
  .controls-inner  { padding: 10px 16px; }
  .product-grid    { padding: 16px; gap: 14px; }
  .hero            { padding: 44px 16px 38px; }
  .results-bar     { padding: 8px 16px 0; }
  .pagination      { padding: 0 16px; }
}

@media (max-width: 520px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card-img-wrap { height: 160px; }
  .card-body     { padding: 10px 12px 0; }
  .card-footer   { padding: 10px 12px 12px; }
  .card-title    { font-size: .82rem; }
  .card-price    { font-size: 1rem; }
  .card-badge    { display: none; }
  .logo-text     { display: none; }
  .controls-inner { flex-direction: column; align-items: stretch; }
  .control-select, .toggle-btn { width: 100%; }
}

::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }