:root {
  --affux-dock-gap: 0.5rem;
  --affux-dock-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  --affux-fab-clearance: 3.25rem;
}

.affux-toolbar {
  position: fixed;
  right: 1rem;
  bottom: var(--affux-dock-bottom);
  z-index: 999990;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--affux-dock-gap);
  max-width: min(22rem, calc(100% - 2rem));
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

body.affux-cookie-fab-visible .affux-toolbar {
  bottom: calc(var(--affux-dock-bottom) + var(--affux-fab-clearance));
}

body.product-sticky-active .affux-toolbar {
  bottom: calc(var(--product-sticky-h, 3.85rem) + 0.65rem + env(safe-area-inset-bottom, 0px));
}

body.product-sticky-active.affux-cookie-fab-visible .affux-toolbar {
  bottom: calc(var(--product-sticky-h, 3.85rem) + 0.65rem + var(--affux-fab-clearance) + env(safe-area-inset-bottom, 0px));
}

body.affux-cookie-open .affux-toolbar {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(0.5rem);
}

body.has-affux-dock {
  padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
}

body.has-affux-dock.affux-cookie-fab-visible {
  padding-bottom: calc(7.5rem + env(safe-area-inset-bottom, 0px));
}

.affux-toolbar__link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(15, 23, 42, 0.12));
  border-radius: 999px;
  box-shadow: var(--shadow, 0 4px 12px rgba(0, 0, 0, 0.08));
  text-decoration: none;
  font-size: 0.85rem;
  color: var(--text, #0f172a);
  white-space: nowrap;
}

.affux-toolbar__link:hover,
.affux-toolbar__link:focus-visible {
  color: var(--text, #0f172a);
  text-decoration: none;
}

.affux-badge {
  display: inline-flex;
  min-width: 1.25rem;
  justify-content: center;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--accent, #2563eb);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}

.affux-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--affux-dock-bottom) + 3.5rem);
  transform: translateX(-50%);
  z-index: 999991;
  max-width: min(92vw, 24rem);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 0.82rem;
  text-align: center;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
  pointer-events: none;
}

body.affux-cookie-fab-visible .affux-toast {
  bottom: calc(var(--affux-dock-bottom) + var(--affux-fab-clearance) + 3.5rem);
}

body.affux-cookie-open .affux-toast {
  bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
}

.affux-actions,
.affux-card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.affux-actions .affux-btn {
  color: var(--text, #0f172a);
  background: var(--surface, #fff);
  border-color: var(--border-strong, #cbd5e1);
}

.product-card--retail .affux-card-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  margin: 0;
  z-index: 4;
  padding: 0.2rem;
  gap: 0.15rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
}

.product-card--retail {
  position: relative;
}

.affux-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  padding: 0.4rem;
  min-width: 2rem;
  min-height: 2rem;
  line-height: 1;
  color: #475569;
  box-shadow: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.affux-icon-btn__svg {
  display: block;
  flex-shrink: 0;
}

.affux-icon-btn:hover {
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent, #2563eb);
}

.affux-icon-btn.is-active,
.affux-btn.is-active {
  background: var(--accent, #2563eb);
  color: #fff;
}

.affux-icon-btn[data-affux-action="favorite"].is-active .affux-icon-btn__svg {
  fill: currentColor;
}

.affux-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  margin: 0;
}

.affux-grid--compare {
  grid-template-columns: repeat(auto-fill, minmax(220px, 280px));
  justify-content: center;
}

.affux-grid--compare .affux-card--product {
  max-width: 280px;
  width: 100%;
  justify-self: center;
}

.affux-grid--compare .affux-card--product .affux-card__media {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 220px;
  aspect-ratio: 1 / 1;
}

.affux-grid--compare .affux-card--product .affux-card__media img {
  width: auto;
  height: auto;
  max-width: calc(100% - 1.5rem);
  max-height: calc(100% - 1.5rem);
  margin: auto;
  object-fit: contain;
}

.affux-page {
  padding-block: clamp(1.5rem, 4vw, 2.75rem);
}

.affux-page__head {
  max-width: 48rem;
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border, rgba(15, 23, 42, 0.1));
}

.affux-page__lead {
  margin: 0.65rem 0 0;
  color: var(--muted, #64748b);
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 42rem;
}

.affux-loading {
  color: var(--muted, #64748b);
  padding: 2rem 0;
  text-align: center;
}

.affux-compare-layout {
  display: grid;
  gap: 1.75rem;
}

.affux-compare-hint {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--bg-subtle, #f8fafc);
  border: 1px dashed var(--border, #cbd5e1);
  color: var(--muted, #64748b);
  font-size: 0.9rem;
}

.affux-compare-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border, #d5d9d9);
  border-radius: 12px;
  background: var(--surface, #fff);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.affux-card {
  border: 1px solid var(--border, #d5d9d9);
  border-radius: 12px;
  padding: 0;
  background: var(--surface, #fff);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.affux-card--product .affux-card__media {
  display: block;
  aspect-ratio: 1 / 1;
  background: #f8fafc;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.affux-card--product .affux-card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.75rem;
}

.affux-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1rem 1.1rem;
  flex: 1;
}

.affux-card__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 650;
}

.affux-card__title a {
  color: var(--text, #0f172a);
  text-decoration: none;
}

.affux-card__title a:hover {
  color: var(--accent, #2563eb);
}

.affux-card__brand {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent, #2563eb);
}

.affux-card__merchant,
.affux-card__price {
  margin: 0;
  color: var(--muted, #64748b);
  font-size: 0.85rem;
}

.affux-card__merchant a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.affux-card__merchant a:hover,
.affux-card__merchant a:focus-visible {
  color: var(--accent, #2563eb);
  text-decoration: underline;
}

.affux-compare-table a {
  color: var(--accent, #2563eb);
  text-decoration: none;
  font-weight: 600;
}

.affux-compare-table a:hover,
.affux-compare-table a:focus-visible {
  text-decoration: underline;
}

.affux-card__price strong {
  color: var(--text, #0f172a);
  font-size: 1rem;
}

.affux-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
}

.affux-card__btn {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
  text-align: center;
}

.affux-card__btn--shop,
.affux-card__btn--remove {
  color: var(--text, #0f172a) !important;
  background: var(--surface, #fff) !important;
  border-color: var(--border-strong, #cbd5e1) !important;
}

.affux-card__btn--remove:hover {
  border-color: #dc2626 !important;
  color: #dc2626 !important;
  background: #fef2f2 !important;
}

.affux-card img {
  max-width: 100%;
  height: auto;
}

.affux-compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.9rem;
}

@media (min-width: 768px) {
  .affux-compare-table {
    min-width: 520px;
  }
}

.affux-compare-table th,
.affux-compare-table td {
  border-bottom: 1px solid var(--border, #e2e8f0);
  padding: 0.65rem 0.85rem;
  text-align: left;
  vertical-align: top;
  color: var(--text, #0f172a);
}

.affux-compare-table thead th {
  background: var(--bg-subtle, #f8fafc);
  font-weight: 650;
}

.affux-compare-table tbody th {
  width: 8.5rem;
  color: var(--muted, #64748b);
  font-weight: 600;
  background: #fcfdff;
}

.affux-compare-table tr:last-child th,
.affux-compare-table tr:last-child td {
  border-bottom: 0;
}

html[data-theme="dark"] .affux-toolbar__link {
  color: var(--text, #f1f5f9);
  background: var(--surface, #1e293b);
  border-color: var(--border, rgba(248, 250, 252, 0.16));
}

html[data-theme="dark"] .affux-badge {
  color: #fff;
}

html[data-theme="dark"] .affux-toast {
  background: rgba(30, 41, 59, 0.96);
  color: var(--text, #f1f5f9);
}

html[data-theme="dark"] .affux-card,
html[data-theme="dark"] .affux-compare-table-wrap {
  background: var(--surface, #1e293b);
  border-color: var(--border, #334155);
}

html[data-theme="dark"] .affux-card__title a,
html[data-theme="dark"] .affux-card__price strong {
  color: var(--text, #f1f5f9);
}

html[data-theme="dark"] .affux-card--product .affux-card__media {
  background: var(--bg-subtle, #111827);
  border-bottom-color: var(--border, #334155);
}

html[data-theme="dark"] .affux-compare-table thead th {
  background: var(--bg-subtle, #111827);
  color: var(--text, #f1f5f9);
}

html[data-theme="dark"] .affux-compare-table tbody th {
  background: var(--surface-2, #0f172a);
  color: var(--muted, #94a3b8);
}

html[data-theme="dark"] .affux-compare-hint,
html[data-theme="dark"] body.affux-page-body .affux-page .empty-hint {
  background: var(--surface-2, #0f172a);
  border-color: var(--border, #334155);
  color: var(--muted, #94a3b8);
}

html[data-theme="dark"] .affux-page__head {
  border-bottom-color: var(--border, rgba(248, 250, 252, 0.1));
}

html[data-theme="dark"] .affux-card__btn--shop,
html[data-theme="dark"] .affux-card__btn--remove {
  color: var(--text, #f1f5f9) !important;
  background: var(--surface-2, #0f172a) !important;
  border-color: var(--border-strong, rgba(248, 250, 252, 0.16)) !important;
}

html[data-theme="dark"] .affux-actions .affux-btn {
  color: var(--text, #f1f5f9);
  background: var(--surface-2, #0f172a);
  border-color: var(--border-strong, rgba(248, 250, 252, 0.16));
}

html[data-theme="dark"] .product-card--retail .affux-card-actions {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(248, 250, 252, 0.1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .affux-icon-btn {
  background: transparent;
  color: #cbd5e1;
  border-color: transparent;
}

html[data-theme="dark"] .affux-icon-btn:hover {
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
}

html[data-theme="dark"] .affux-icon-btn.is-active,
html[data-theme="dark"] .affux-btn.is-active {
  background: var(--accent, #60a5fa);
  border-color: var(--accent, #60a5fa);
  color: #fff;
}

html[data-theme="dark"] .affux-page h1.page-title {
  color: var(--text, #f1f5f9);
}

html[data-theme="dark"] .affux-card__merchant,
html[data-theme="dark"] .affux-card__price,
html[data-theme="dark"] .affux-loading {
  color: var(--muted, #94a3b8);
}

html[data-theme="dark"] .affux-compare-table td {
  background: var(--surface, #1e293b);
  color: var(--text, #f1f5f9);
}

html[data-theme="dark"] .affux-card__btn--remove:hover {
  border-color: #f87171 !important;
  color: #fca5a5 !important;
  background: rgba(127, 29, 29, 0.35) !important;
}

body.affux-page-body .affux-page .empty-hint {
  border: 1px dashed var(--border, #cbd5e1);
  border-radius: 12px;
  padding: 2rem 1rem;
  background: var(--bg-subtle, #f8fafc);
}

@media (max-width: 767px) {
  .affux-compare-table-wrap {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .affux-compare-table-wrap::after {
    content: "";
    display: block;
    height: 0;
  }

  .affux-compare-hint::before {
    content: "↔ ";
  }

  .affux-compare-table {
    min-width: 0;
    font-size: 0.82rem;
  }

  .affux-compare-table thead th,
  .affux-compare-table tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface, #fff);
    box-shadow: 2px 0 4px rgba(15, 23, 42, 0.06);
  }
}

@media (max-width: 768px) {
  .affux-toolbar {
    left: max(0.5rem, env(safe-area-inset-left, 0px));
    right: max(0.5rem, env(safe-area-inset-right, 0px));
    bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
    max-width: none;
    width: auto;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .affux-toolbar__link {
    font-size: 0.78rem;
    padding: 0.42rem 0.6rem;
  }
}

@media (max-width: 640px) {
  .affux-toolbar {
    left: max(0.5rem, env(safe-area-inset-left, 0px));
    right: max(0.5rem, env(safe-area-inset-right, 0px));
    max-width: none;
    justify-content: center;
  }

  .affux-card--product .affux-card__media {
    max-height: 280px;
  }

  .affux-card--product .affux-card__media img {
    max-height: 260px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .affux-toolbar__link,
  .affux-toolbar,
  .affux-icon-btn {
    transition: none;
  }
}
