@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,500;14..32,600&display=swap');

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

/* ====== DARK (default) ====== */
:root, [data-theme="dark"] {
  --bg-base:     #0a0a0b;
  --bg-surface:  #101012;
  --bg-raised:   #16161a;
  --bg-overlay:  #1c1c21;
  --bg-hover:    rgba(255,255,255,.04);
  --bg-active:   rgba(255,255,255,.06);

  --border:      rgba(255,255,255,.08);
  --border-focus:rgba(255,255,255,.16);

  --text-primary:   rgba(255,255,255,.92);
  --text-secondary: rgba(255,255,255,.56);
  --text-tertiary:  rgba(255,255,255,.36);
  --text-quaternary:rgba(255,255,255,.20);

  --accent:       #5e6ad2;
  --accent-hover: #7078d9;
  --accent-muted: rgba(94,106,210,.14);
  --accent-text:  #a4adfc;

  --green:        #4cc38a;
  --green-muted:  rgba(76,195,138,.10);
  --red:          #f76e6e;
  --red-muted:    rgba(247,110,110,.10);
  --yellow:       #f2c94c;
  --yellow-muted: rgba(242,201,76,.10);

  --img-bg: rgba(255,255,255,.92);
  --color-scheme: dark;
}

/* ====== LIGHT ====== */
[data-theme="light"] {
  --bg-base:     #ffffff;
  --bg-surface:  #f9f9fb;
  --bg-raised:   #f0f0f3;
  --bg-overlay:  #e8e8ec;
  --bg-hover:    rgba(0,0,0,.03);
  --bg-active:   rgba(0,0,0,.05);

  --border:      rgba(0,0,0,.09);
  --border-focus:rgba(0,0,0,.18);

  --text-primary:   rgba(0,0,0,.88);
  --text-secondary: rgba(0,0,0,.55);
  --text-tertiary:  rgba(0,0,0,.36);
  --text-quaternary:rgba(0,0,0,.20);

  --accent:       #5e6ad2;
  --accent-hover: #4f5bc4;
  --accent-muted: rgba(94,106,210,.10);
  --accent-text:  #5e6ad2;

  --green:        #2d9a63;
  --green-muted:  rgba(45,154,99,.08);
  --red:          #e5484d;
  --red-muted:    rgba(229,72,77,.08);
  --yellow:       #b58407;
  --yellow-muted: rgba(181,132,7,.08);

  --img-bg: #f5f5f7;
  --color-scheme: light;
}

html { font-size: 13px; color-scheme: var(--color-scheme); }

body {
  font-family: 'Inter',system-ui,-apple-system,sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.006em;
  transition: background .2s, color .2s;
}

::selection { background: var(--accent-muted); color: var(--accent-text); }

/* ====== LUCIDE ICONS ====== */
.icon-btn [data-lucide], .action-btn [data-lucide] { width: 15px; height: 15px; }
.search-icon { width: 15px; height: 15px; }

/* ====== THEME TOGGLE ====== */
.icon-sun, .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ====== HEADER ====== */
header {
  height: 44px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0;
  background: var(--bg-base);
  z-index: 50;
  transition: background .2s, border-color .2s;
}

.header-inner {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.logo span { color: var(--accent-text); }

.nav { display: flex; gap: 1px; }

.nav-link {
  font-size: 12px;
  color: var(--text-tertiary);
  text-decoration: none;
  padding: 5px 8px;
  border-radius: 4px;
  transition: all .12s;
  cursor: pointer;
  font-weight: 500;
}

.nav-link:hover { color: var(--text-secondary); background: var(--bg-hover); }
.nav-link.active { color: var(--text-primary); }

.fav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  background: var(--accent-muted);
  color: var(--accent-text);
  border-radius: 7px;
  font-size: 9px;
  font-weight: 600;
  margin-left: 3px;
  vertical-align: middle;
}

.header-actions { margin-left: auto; display: flex; gap: 2px; align-items: center; }

/* ====== LANGUAGE PICKER ====== */
.lang-picker { position: relative; }

.lang-btn {
  width: auto !important;
  padding: 0 6px;
  gap: 4px;
}

.lang-flag { font-size: 13px; line-height: 1; }
.lang-code {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.lang-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 150px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  z-index: 100;
}

[data-theme="light"] .lang-menu { box-shadow: 0 6px 24px rgba(0,0,0,.12); }

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all .1s;
}

.lang-option:hover { background: var(--bg-hover); color: var(--text-primary); }
.lang-option.active { color: var(--text-primary); background: var(--accent-muted); }

.lang-option .check {
  margin-left: auto;
  color: var(--accent-text);
  font-size: 11px;
}

.lang-option:not(.active) .check { display: none; }

.icon-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all .12s;
  text-decoration: none;
}

.icon-btn:hover { color: var(--text-secondary); background: var(--bg-hover); }

/* ====== MAIN ====== */
main {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ====== HERO ====== */
.hero {
  padding: 48px 0 36px;
  text-align: center;
}

.hero-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.3;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.hero-title span {
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 14px;
  display: block;
  margin-top: 4px;
  letter-spacing: -0.01em;
}

.search-form {
  display: flex;
  gap: 6px;
  max-width: 480px;
  margin: 0 auto;
}

.search-input-wrap {
  flex: 1;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-quaternary);
  pointer-events: none;
}

.search-input-wrap input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .2s;
}

.search-input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-muted);
}

.search-input-wrap input::placeholder { color: var(--text-quaternary); }

.search-form button {
  height: 32px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s;
  white-space: nowrap;
}

.search-form button:hover { background: var(--accent-hover); }

.search-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-quaternary);
}

.affiliate-disclosure {
  font-size: 10px;
  color: var(--text-quaternary);
  line-height: 1.5;
  margin-bottom: 4px;
}

/* ====== FEATURED ====== */
.featured-section { margin-bottom: 24px; }

.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1px;
  padding: 8px 0;
}

.section-bar h2 {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-tag {
  font-size: 11px;
  color: var(--text-quaternary);
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.featured-card {
  background: var(--bg-surface);
  padding: 14px 12px;
  cursor: pointer;
  transition: background .08s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.featured-card:hover { background: var(--bg-hover); }

.featured-img {
  width: 56px;
  height: 56px;
  background: var(--img-bg);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.featured-img img { max-width: 88%; max-height: 88%; object-fit: contain; }

.featured-img-placeholder {
  width: 100%; height: 100%;
  background: var(--bg-raised);
  border-radius: 4px;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse { 0%,100%{opacity:.3} 50%{opacity:.6} }

.featured-info { min-width: 0; width: 100%; }

.featured-title {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 3px;
}

.featured-meta { display: flex; align-items: center; justify-content: center; gap: 5px; }

.featured-price {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.featured-label {
  font-size: 9px;
  color: var(--text-quaternary);
  background: var(--bg-raised);
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.featured-loading {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.featured-loading .loader { width: 14px; height: 14px; border-width: 1.5px; margin: 0; }

/* ====== LOADING ====== */
.loading-section { text-align: center; padding: 40px 0; }

.loader {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-focus);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: spin .5s linear infinite;
  margin: 0 auto 10px;
}

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

.loading-text { font-size: 12px; color: var(--text-tertiary); }

/* ====== PRODUCT LIST ====== */
.product-list {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color .2s;
}

.product-item {
  background: transparent;
  padding: 8px 12px;
  display: flex;
  gap: 10px;
  cursor: pointer;
  transition: background .06s;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.product-item:last-child { border-bottom: none; }
.product-item:hover { background: var(--bg-hover); }

.product-thumb {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 4px;
  background: var(--img-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-thumb img { max-width: 90%; max-height: 90%; object-fit: contain; }

.product-thumb-placeholder {
  width: 100%; height: 100%;
  background: var(--bg-raised);
  border-radius: 4px;
}

.product-item-info { flex: 1; min-width: 0; }

.product-item-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-item-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 1px;
}

.product-item-asin {
  font-size: 10px;
  color: var(--text-quaternary);
  font-family: 'JetBrains Mono','SF Mono','Fira Code',monospace;
  letter-spacing: 0.02em;
}

.product-item-price {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.product-item-arrow {
  color: var(--text-quaternary);
  align-self: center;
  flex-shrink: 0;
  font-size: 11px;
  transition: transform .1s, color .1s;
}

.product-item:hover .product-item-arrow { transform: translateX(2px); color: var(--text-tertiary); }

/* ====== PRODUCT DETAIL ====== */
.back-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  padding: 10px 0 8px;
  margin-bottom: 8px;
  transition: color .1s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.back-btn:hover { color: var(--text-primary); }

.product-card-detail {
  display: flex;
  gap: 20px;
  margin-bottom: 28px;
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: background .2s, border-color .2s;
}

.product-image-wrap {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  background: var(--img-bg);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-image-wrap img { max-width: 88%; max-height: 88%; object-fit: contain; }

.product-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }

.product-brand {
  font-size: 11px;
  color: var(--accent-text);
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
  letter-spacing: 0.01em;
}

.product-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.product-actions { display: flex; gap: 4px; }

.action-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all .1s;
}

.action-btn:hover { color: var(--text-secondary); background: var(--bg-hover); border-color: var(--border-focus); }

.action-btn.is-fav { color: var(--red); background: var(--red-muted); border-color: transparent; }
.action-btn.is-fav svg { fill: var(--red); }

/* ====== PRICE LIST ====== */
.price-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.price-list-header h3 {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.price-tabs {
  display: flex;
  gap: 1px;
  background: var(--bg-raised);
  border-radius: 4px;
  padding: 2px;
}

.price-tab {
  height: 22px;
  padding: 0 10px;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .1s;
}

.price-tab:hover { color: var(--text-secondary); }
.price-tab.active {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

.price-note-line {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-quaternary);
  text-align: center;
}

.price-list {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color .2s;
}

.price-row {
  background: transparent;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background .06s;
  border-bottom: 1px solid var(--border);
}

.price-row:last-child { border-bottom: none; }
.price-row:hover { background: var(--bg-hover); }

.price-row.cheapest { background: var(--green-muted); }
.price-row.cheapest:hover { background: rgba(76,195,138,.14); }
[data-theme="light"] .price-row.cheapest:hover { background: rgba(45,154,99,.12); }

.price-rank {
  width: 16px;
  font-size: 10px;
  color: var(--text-quaternary);
  font-weight: 500;
  text-align: center;
  flex-shrink: 0;
  font-family: 'JetBrains Mono','SF Mono','Fira Code',monospace;
}

.price-row.cheapest .price-rank { color: var(--green); }

.price-flag { font-size: 15px; flex-shrink: 0; }

.price-store { flex: 1; min-width: 0; }
.price-store-name { font-size: 13px; font-weight: 500; }
.price-store-domain { font-size: 10px; color: var(--text-quaternary); }

.price-amount {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.price-row.cheapest .price-amount { color: var(--green); }

.price-original {
  font-size: 10px;
  color: var(--text-quaternary);
  flex-shrink: 0;
  min-width: 60px;
  text-align: right;
  font-family: 'JetBrains Mono','SF Mono','Fira Code',monospace;
}

.price-saving {
  font-size: 10px;
  color: var(--yellow);
  background: var(--yellow-muted);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
  flex-shrink: 0;
  font-family: 'JetBrains Mono','SF Mono','Fira Code',monospace;
}

.price-arrow {
  color: var(--text-quaternary);
  flex-shrink: 0;
  font-size: 11px;
  transition: transform .1s;
}

.price-row:hover .price-arrow { transform: translateX(2px); }

.price-unavailable { font-size: 11px; color: var(--text-tertiary); }

.disclaimer {
  margin-top: 10px;
  font-size: 10px;
  color: var(--text-quaternary);
  text-align: center;
}

/* ====== EMPTY STATE ====== */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ====== SKELETON ====== */
.skeleton-pulse { animation: pulse 1.8s ease-in-out infinite; }

.skeleton-line {
  height: 12px;
  background: var(--bg-raised);
  border-radius: 3px;
  margin-bottom: 4px;
}

.product-item.enriched .product-thumb img,
.product-item.enriched .product-item-title {
  animation: fadeIn .15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ====== SCROLL SENTINEL ====== */
.scroll-sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

.scroll-sentinel .loader { width: 16px; height: 16px; border-width: 1.5px; margin: 0; }

/* ====== AFF BADGE ====== */
.aff-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 0 4px;
  background: var(--accent-muted);
  color: var(--accent-text);
  font-size: 9px;
  font-weight: 500;
  border-radius: 3px;
  vertical-align: middle;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ====== FOOTER ====== */
footer {
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-quaternary);
  font-size: 10px;
  transition: border-color .2s;
}

.footer-links {
  margin-top: 4px;
}

.footer-links a {
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color .15s;
}

.footer-links a:hover { color: var(--text-secondary); }

/* ====== TOAST ====== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--text-primary);
  color: var(--bg-base);
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 12px;
  opacity: 0;
  transition: opacity .15s, transform .15s;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ====== UTILITY ====== */
.hidden { display: none !important; }

/* ====== RESPONSIVE ====== */
@media (max-width: 640px) {
  .hero { padding: 32px 0 24px; }
  .hero-title { font-size: 18px; }
  .hero-title span { font-size: 13px; }
  .search-form { flex-direction: column; }
  .search-form button { width: 100%; }
  .product-card-detail { flex-direction: column; align-items: center; text-align: center; gap: 14px; }
  .product-image-wrap { width: 100px; height: 100px; }
  .product-actions { justify-content: center; }
  .featured-grid { grid-template-columns: repeat(2, 1fr); }
  .price-original { display: none; }
}
