/* -- Dark tokens (default) ----------------------------------- */
:root {
  color-scheme: dark;
  --bg: #0F0F13;
  --surface: #17171D;
  --text: #EAE8E3;
  --sub: #78766E;
  --border: #232330;
  --border-hi: #333340;
  --accent: #7BA4F0;
  --accent-dim: #12192E;
  --accent-ink: #FFFFFF;
  --green: #4AD980;
  --red: #E05555;
  --thumb-bg: #1C1C24;
  --r: 8px;
  --rs: 5px;
  --arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2378766E' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* -- Light override ------------------------------------------- */
[data-theme="light"] {
  color-scheme: light;
  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --text: #1C1B18;
  --sub: #706E66;
  --border: #E0DED8;
  --border-hi: #C5C2BA;
  --accent: #2B5EA7;
  --accent-dim: #EBF0FA;
  --accent-ink: #FFFFFF;
  --green: #1D7A45;
  --red: #B33030;
  --thumb-bg: #EDEAE3;
  --arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23706E66' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* -- Reset --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }

/* -- Topbar -------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 52px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.brand-mark {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.topbar-search {
  flex: 1 1 420px;
  max-width: 560px;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-search input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: var(--bg);
  outline: none;
}

.topbar-search input:focus { border-color: var(--accent); }
.topbar-search input::placeholder { color: var(--sub); }

.topbar-search button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: var(--rs);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-meta {
  font-size: 12px;
  color: var(--sub);
  white-space: nowrap;
}

/* -- Theme toggle -------------------------------------------- */
.theme-toggle {
  position: relative;
  width: 58px;
  height: 30px;
  border-radius: 15px;
  border: 1.5px solid var(--border-hi);
  background: var(--accent-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  flex-shrink: 0;
  overflow: hidden;
  transition: background 0.3s, border-color 0.3s;
}

/* sliding thumb */
.theme-toggle::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  transition: left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

[data-theme="light"] .theme-toggle::before {
  left: calc(100% - 25px);
  background: #F59E0B;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.icon-moon,
.icon-sun {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  transition: color 0.3s, opacity 0.3s;
  pointer-events: none;
}

/* dark mode: moon active (left/highlighted), sun dim */
.icon-moon { color: #fff; }
.icon-sun  { color: var(--sub); opacity: 0.5; }

/* light mode: sun active (right/highlighted), moon dim */
[data-theme="light"] .icon-moon { color: var(--sub); opacity: 0.5; }
[data-theme="light"] .icon-sun  { color: #fff; opacity: 1; }

/* -- Shell --------------------------------------------------- */
.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 20px 48px;
}

/* -- Sponsored banner ---------------------------------------- */
.site-ad {
  width: min(2128px, calc(100vw - 32px));
  margin: 16px auto 22px;
  overflow: hidden;
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.20);
}

[data-theme="light"] .site-ad {
  box-shadow: 0 10px 26px rgba(28, 27, 24, 0.12);
}

.site-ad-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.site-ad picture {
  display: block;
}

.site-ad-image {
  width: 100%;
  height: auto;
  background: var(--thumb-bg);
}

/* -- Filter bar ---------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 16px 0 12px;
}

.filter-search {
  display: flex;
  gap: 8px;
  flex: 1 1 260px;
  min-width: 0;
}

.filter-search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}
.filter-search input:focus { border-color: var(--accent); }
.filter-search input::placeholder { color: var(--sub); }

.search-submit {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: var(--rs);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.search-submit:hover { filter: brightness(1.06); }

.filter-select {
  flex: 0 1 auto;
  height: 38px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: var(--surface);
  background-image: var(--arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  white-space: nowrap;
  max-width: 200px;
}
.filter-select:focus { border-color: var(--accent); }

.clear-btn {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: transparent;
  cursor: pointer;
  color: var(--sub);
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.clear-btn:hover { border-color: var(--red); color: var(--red); }

/* -- Toolbar row --------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  font-size: 13px;
}

.result-count { color: var(--sub); }
.result-count strong { color: var(--text); }

/* -- Product grid -------------------------------------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.product-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: box-shadow 0.18s, border-color 0.18s;
}
.product-card:hover {
  border-color: var(--border-hi);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .product-card:hover {
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.08);
}

.thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--thumb-bg);
}

.card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

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

.meta-line {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.price { color: var(--green); font-weight: 700; font-size: 13px; }
.old-price { color: var(--sub); text-decoration: line-through; font-size: 12px; margin-left: 3px; }

/* -- Pills & Tags -------------------------------------------- */
.format-row, .tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-dim);
  color: var(--accent);
  border: none;
}

.tag-link {
  background: var(--border);
  color: var(--sub);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tag-link:hover { background: var(--accent-dim); color: var(--accent); }

/* -- Pagination ---------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 32px;
}

.page-btn {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn:disabled { opacity: 0.32; cursor: default; }

.page-label { font-size: 13px; color: var(--sub); }

/* -- Product detail ------------------------------------------ */
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
  padding-top: 20px;
}

.product-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(220px, 400px) minmax(0, 1fr);
  gap: 22px;
  padding: 20px;
}

.detail-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--rs);
  background: var(--thumb-bg);
}

.detail-hero .format-row { margin-top: 10px; }

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 14px;
  transition: color 0.12s;
}
.back-link:hover { color: var(--accent); }

.detail-title {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.3px;
  margin-bottom: 10px;
}

.detail-copy {
  font-size: 13px;
  color: var(--sub);
  line-height: 1.7;
  margin-top: 8px;
}

[data-theme="light"] .detail-copy { color: #3C3B36; }

@keyframes cta-shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

@keyframes cta-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 217, 128, 0.55), 0 8px 28px rgba(74, 217, 128, 0.35); }
  60%  { box-shadow: 0 0 0 10px rgba(74, 217, 128, 0),  0 8px 28px rgba(74, 217, 128, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(74, 217, 128, 0),     0 8px 28px rgba(74, 217, 128, 0.35); }
}

.download-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 52px;
  margin-top: 20px;
  padding: 0 24px;
  border-radius: 12px;
  background: linear-gradient(100deg, #d97706 0%, #F59E0B 40%, #fbbf24 55%, #F59E0B 70%, #d97706 100%);
  background-size: 200% auto;
  color: #1c0a00;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  animation: cta-shimmer 3s linear infinite, cta-pulse 2.2s ease-out infinite;
  transition: transform 0.15s ease, filter 0.15s ease;
  position: relative;
  overflow: hidden;
}

@keyframes cta-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55), 0 8px 28px rgba(245, 158, 11, 0.35); }
  60%  { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0),  0 8px 28px rgba(245, 158, 11, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0),     0 8px 28px rgba(245, 158, 11, 0.35); }
}

.download-cta::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 60%);
  border-radius: inherit;
  pointer-events: none;
}

.download-cta:hover {
  filter: brightness(1.08) saturate(1.1);
  transform: translateY(-2px);
  animation-play-state: paused;
}

.download-cta:active {
  transform: translateY(0) scale(0.98);
  filter: brightness(0.97);
}

.cta-note {
  margin-top: 7px;
  color: var(--sub);
  font-size: 11px;
  line-height: 1.45;
}

/* -- Sections ------------------------------------------------ */
.section {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
}

.section h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--sub);
  margin-bottom: 12px;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-heading-row h2 { margin: 0; }

/* -- Sizes table --------------------------------------------- */
.sizes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.sizes-table th,
.sizes-table td {
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.sizes-table th {
  color: var(--sub);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* -- Detail sidebar ------------------------------------------ */
.detail-side {
  position: sticky;
  top: 68px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  display: grid;
  gap: 14px;
}

.detail-side h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--sub);
}

.side-row { display: grid; gap: 2px; }

.side-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--sub);
}

.accent-link { color: var(--accent); }
.accent-link:hover { text-decoration: underline; }

/* -- Tag page ------------------------------------------------ */
.tag-page { display: grid; gap: 16px; padding-top: 20px; }
.not-found-page { display: grid; gap: 16px; padding-top: 20px; }

.tag-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 24px;
}

.not-found-search {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  max-width: 560px;
}

.not-found-search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: var(--bg);
  outline: none;
}

.not-found-search input:focus { border-color: var(--accent); }

.not-found-search button {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: var(--rs);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* -- States -------------------------------------------------- */
.loading, .error {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--sub);
  font-size: 13px;
}
.error { border-color: #5A2020; color: var(--red); }
[data-theme="light"] .error { border-color: #F5C5C5; }

/* -- Related products (outside layout grid) ------------------ */
.detail-related {
  margin-top: 20px;
  padding: 16px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.detail-related h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--sub);
  margin-bottom: 14px;
}

.related-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

/* -- Responsive ---------------------------------------------- */
@media (max-width: 960px) {
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .detail-hero { grid-template-columns: 1fr; }
  .detail-image { max-width: 440px; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 14px; height: 48px; }
  .brand span:not(.brand-mark) { display: none; }
  .topbar { gap: 8px; }
  .topbar-search { flex: 1 1 auto; min-width: 0; }
  .topbar-search button { display: none; }
  .topbar-meta { display: none; }
  .site-ad {
    width: min(450px, calc(100% - 24px));
    margin: 14px auto 14px;
  }
  .app-shell { padding: 0 12px 40px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .related-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-search { flex: 1 1 100%; }
  .search-submit { padding: 0 12px; }
  .filter-select { flex: 1 1 calc(50% - 4px); max-width: none; }
  .clear-btn { width: 100%; }
  .detail-title { font-size: 18px; }
  .detail-hero { padding: 14px; gap: 14px; }
  .section { padding: 14px; }
  .tag-header { padding: 16px; }
  .not-found-search { flex-direction: column; }
}
