/* ─── Design tokens ─────────────────────────────────────────────────
   Mirrors the admin UI's design system (admin/ui/src/App.css). Embedded
   here because this file is loaded both standalone (port 8080) and
   inside the admin's Demo tab iframe; the iframe does not inherit the
   parent's tokens, so we declare them locally for visual parity. */

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

:root {
  color-scheme: light;

  /* Brand — sky-blue ramp */
  --brand-50: #f0f9ff;
  --brand-100: #e0f2fe;
  --brand-200: #b9e6fe;
  --brand-500: #0ba5ec;
  --brand-600: #0086c9;
  --brand-700: #026aa2;

  /* Gray — Untitled UI scale */
  --gray-25: #fcfcfd;
  --gray-50: #f9fafb;
  --gray-100: #f2f4f7;
  --gray-200: #eaecf0;
  --gray-300: #d0d5dd;
  --gray-400: #98a2b3;
  --gray-500: #667085;
  --gray-600: #475467;
  --gray-700: #344054;
  --gray-800: #1d2939;
  --gray-900: #101828;

  /* Status */
  --success-50: #ecfdf3;
  --success-700: #067647;
  --warning-50: #fffaeb;
  --warning-700: #b54708;
  --error-50: #fef3f2;
  --error-100: #fee4e2;
  --error-200: #fecdca;
  --error-600: #d92d20;
  --error-700: #b42318;

  /* Surfaces / text */
  --bg-page: #fafbfe;
  --bg-card: #ffffff;
  --border-subtle: var(--gray-200);
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  --text-tertiary: var(--gray-400);

  /* Shadows + focus */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --focus-ring: 0 0 0 4px rgba(11, 165, 236, 0.18);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-pill: 9999px;

  /* Fonts */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.logo span {
  color: var(--brand-600);
}
.search-bar {
  flex: 1;
  display: flex;
  gap: 8px;
  max-width: 800px;
  position: relative;
}
.search-input-wrapper {
  flex: 1;
  position: relative;
}
.search-bar input {
  width: 100%;
  height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-card);
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.search-bar input::placeholder {
  color: var(--text-tertiary);
}
.search-bar input:focus {
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  margin-top: 4px;
}
.autocomplete-dropdown.active {
  display: block;
}

/* Chip row (brand/facet filter) */
.ac-chips-row {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  border-bottom: 1px solid var(--gray-100);
}
.ac-chips-row::-webkit-scrollbar {
  display: none;
}
.autocomplete-chip {
  background: transparent;
  border: 1px solid var(--brand-500);
  color: var(--brand-700);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s,
    color 0.15s;
}
.search-bar .autocomplete-chip {
  height: auto;
}
.autocomplete-chip:hover {
  background: var(--brand-50);
}

/* Suggestion rows */
.ac-list {
}
.ac-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 52px;
  cursor: pointer;
  transition: background 0.12s;
}
.ac-row:hover {
  background: var(--gray-50, #f9fafb);
}
.ac-row__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.ac-row__icon--history {
  opacity: 0.7;
}
.ac-row__label {
  flex: 1;
  font-size: 15px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-row__label strong {
  font-weight: 600;
}
.ac-row__arrow {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-tertiary, #9ca3af);
}

/* Special suggest entries (AG-80) — redirect rows. No bespoke styling yet. */
.ac-row--special {
}

/* Sub-row (indented category narrowing) */
.ac-subrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 42px;
  cursor: pointer;
  transition: background 0.12s;
}
.ac-subrow:hover {
  background: var(--gray-50, #f9fafb);
}
.ac-subrow__connector {
  font-size: 13px;
  color: var(--brand-500);
  flex-shrink: 0;
  line-height: 1;
}
.ac-subrow__label {
  font-size: 13px;
  color: var(--brand-600);
}
.ac-subrow__label strong {
  font-weight: 600;
}

/* Product suggestion tiles */
.ac-products {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--gray-100);
}
.ac-products-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.ac-product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.ac-product-tile {
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--gray-100);
  transition: box-shadow 0.15s;
  display: block;
}
.ac-product-tile:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--gray-200);
}
.ac-product-tile-img {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--gray-100);
}
.ac-product-tile-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ac-product-tile-name {
  font-size: 11px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 4px 6px 2px;
  color: var(--text-primary);
}
.ac-product-tile-price {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-700);
  padding: 0 6px 6px;
}
@media (max-width: 480px) {
  .ac-product-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
  }
  .ac-product-tile {
    flex: 0 0 130px;
    scroll-snap-align: start;
  }
}

.autocomplete-loading {
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.autocomplete-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.search-bar button {
  height: 36px;
  padding: 10px 18px;
  background: var(--brand-500);
  color: #fff;
  border: 1px solid var(--brand-500);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.1s ease-out;
}
.search-bar button:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
}
.search-bar button:active {
  transform: scale(0.97);
}
.search-bar button:focus-visible {
  box-shadow: var(--focus-ring);
}

/* Bottom panels container: timing breakdown + query explainer side by side */
.bottom-panels {
  max-width: 1400px;
  margin: 32px auto 0;
  padding: 0 24px 24px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.bottom-panels > section {
  flex: 1 1 0;
  min-width: 0;
}
.bottom-panels > section[hidden] {
  display: none;
}

/* Timing panel */
.timing-panel {
  margin: 0;
  padding: 0;
}
.timing-panel h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.timing-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 12px;
}
.timing-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
}
.timing-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.timing-table tbody tr:last-child td {
  border-bottom: none;
}
.timing-phase {
  color: var(--gray-700);
  width: 180px;
}
.timing-duration {
  font-family: var(--font-mono);
  color: var(--text-primary);
  width: 90px;
  white-space: nowrap;
}
.timing-detail-cell {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}
.timing-detail-cell code {
  background: var(--gray-100);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.timing-total td {
  font-weight: 700;
  background: var(--gray-50);
  color: var(--text-primary);
}
.timing-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: inherit;
}
.timing-tag-hit {
  background: var(--success-50);
  color: var(--success-700);
}
.timing-tag-miss {
  background: var(--warning-50);
  color: var(--warning-700);
}

/* Query explainer panel: plain-language breakdown of the OpenSearch query */
.query-explainer-panel h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.qx-body {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  font-size: 12px;
  color: var(--text-primary);
}
.qx-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.qx-section:first-child {
  padding-top: 0;
}
.qx-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}
.qx-section h4 {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.qx-section h4 small {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}
.qx-term {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--brand-700, var(--text-primary));
  margin-bottom: 6px;
}
.qx-sub {
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.qx-fields {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.qx-fields li {
  background: var(--gray-50);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
}
.qx-section ul:not(.qx-fields) {
  list-style: none;
  padding-left: 0;
}
.qx-section ul:not(.qx-fields) li {
  padding: 3px 0;
  line-height: 1.5;
}
.qx-section code {
  font-family: var(--font-mono);
  background: var(--gray-100);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
}
.qx-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
}
.qx-settings {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.qx-foot {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.qx-empty {
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}
.qx-raw {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
}
.qx-raw summary {
  cursor: pointer;
}
.qx-raw pre {
  max-height: 200px;
  overflow: auto;
  background: var(--gray-50);
  padding: 8px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.4;
}

/* Layout */
.container {
  display: flex;
  margin: 0 auto;
  padding: 16px;
  gap: 16px;
}

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
}
.facet-group {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border-subtle);
}
.facet-group h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Facet body is capped at 300px by default and scrolls vertically inside the cap.
   When the real content overflows, app.js flags the group with .is-overflowing —
   the header then becomes clickable to toggle .is-expanded, which lifts the cap. */
.facet-body {
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.facet-body::-webkit-scrollbar {
  width: 6px;
}
.facet-body::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: 3px;
}
.facet-body:hover::-webkit-scrollbar-thumb {
  background: var(--gray-300);
}

/* Count badge next to the facet label */
.facet-group h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.facet-group-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-700);
  background: var(--brand-50);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-left: 6px;
  letter-spacing: 0;
  text-transform: none;
}

/* Clickable header + caret, only when content overflows the 300px cap */
.facet-group.is-overflowing > h3 {
  cursor: pointer;
  user-select: none;
}
.facet-group.is-overflowing > h3::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-left: 8px;
  margin-bottom: 3px;
  opacity: 0.6;
  flex-shrink: 0;
}
.facet-group.is-overflowing.is-expanded .facet-body {
  max-height: none;
  overflow: visible;
}
.facet-group.is-overflowing.is-expanded > h3::after {
  transform: rotate(-135deg);
  margin-bottom: 0;
  margin-top: 3px;
}
.facet-value {
  display: flex;
  lign-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.facet-value:hover {
  color: var(--text-primary);
}
.facet-value.active {
  color: var(--brand-700);
  font-weight: 600;
}
.facet-checkbox {
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-300);
  border-radius: 4px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.facet-value.active .facet-checkbox {
  background: var(--brand-500);
  border-color: var(--brand-500);
}
.facet-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 75%;
}
.facet-count {
  color: var(--text-tertiary);
  font-size: 12px;
  margin-left: auto;
}

/* Hierarchy facet — expand/collapse tree. Each level indents via the
   children wrapper; the chevron rotates between collapsed and expanded. */
.hfacet-children {
  padding-left: 14px;
}
.hfacet-children.hidden {
  display: none;
}
.hfacet-row {
  gap: 6px;
}
.hfacet-toggle {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
}
.hfacet-toggle.leaf {
  visibility: hidden;
}
.hfacet-toggle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--text-tertiary);
  border-bottom: 1.5px solid var(--text-tertiary);
  transform: translate(-50%, -60%) rotate(-45deg);
  transition: transform 0.15s;
}
.hfacet-toggle.open::before {
  transform: translate(-50%, -50%) rotate(45deg);
}
.hfacet-row:hover .hfacet-toggle::before {
  border-color: var(--text-primary);
}

/* Slider facet — mirrors the admin's .fb-row look-and-feel: a light
   brand-tinted card with a thin track and a single brand thumb. Two rows
   (von/bis) stacked for min/max range. */
.facet-slider-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}
.facet-slider-row:last-child {
  margin-bottom: 0;
}
.facet-slider-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-700);
}
.facet-slider-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-700);
  text-align: right;
  white-space: nowrap;
}
.facet-slider-row input[type='range'] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--brand-200);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 0;
}
.facet-slider-row input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand-500);
  border: 3px solid #fff;
  box-shadow: 0 1px 3px rgba(11, 165, 236, 0.4);
  cursor: pointer;
}
.facet-slider-row input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand-500);
  border: 3px solid #fff;
  cursor: pointer;
}
.facet-slider-row input[type='range']:focus-visible {
  box-shadow: var(--focus-ring);
}

/* Boost sidebar (right) */
.boost-sidebar {
  width: 280px;
  flex-shrink: 0;
}

.boost-sidebar-header {
  margin-bottom: 16px;
}
.boost-sidebar-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.boost-sidebar-header p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.boost-empty {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--gray-300);
  padding: 24px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Boost value rows reuse .facet-value/.facet-label/.facet-count from the left sidebar.
   Only the checkbox alignment needs a small override for native <input type="checkbox">. */
.boost-sidebar .facet-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.boost-sidebar .facet-group label:hover {
  color: var(--text-primary);
}
.boost-sidebar .facet-group input[type='checkbox'] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--brand-500);
  cursor: pointer;
}

/* Main content */
.main {
  flex: 1;
  min-width: 0;
}
.results-info {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.results-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.results-toolbar select {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: inherit;
}

/* Product grid — fluid: auto-fills 1…5 columns depending on viewport width */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  transition:
    box-shadow 0.2s,
    border-color 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.product-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gray-300);
}
.product-image {
  width: 100%;
  aspect-ratio: 1;
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-image img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}
.product-info {
  padding: 12px 16px;
}
.product-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.product-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.product-price .old-price {
  font-size: 13px;
  color: var(--text-tertiary);
  text-decoration: line-through;
  margin-left: 8px;
  font-weight: 400;
}

/* Score breakdown (preview only — shown when debug.includeBaseScore is set) */
.product-score {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--gray-300);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--text-muted);
}
.product-score .score-base {
  color: var(--text-tertiary);
}
.product-score .score-arrow {
  color: var(--text-tertiary);
}
.product-score .score-final {
  color: var(--text-primary);
  font-weight: 600;
}
.product-score .score-ratio {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 10px;
}
.product-score .score-ratio-neutral {
  background: var(--gray-100);
  color: var(--text-muted);
}
.product-score .score-ratio-up {
  background: #dcfce7;
  color: #166534;
}
.product-score .score-ratio-down {
  background: #fee2e2;
  color: #991b1b;
}

/* Empty state */
.empty-state {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--gray-300);
  padding: 80px 40px;
  text-align: center;
}
.empty-state h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
}

/* Error state */
.error-state {
  background: var(--error-50);
  border-radius: var(--radius-lg);
  border: 1px solid var(--error-200);
  padding: 24px;
  text-align: center;
  color: var(--error-700);
}

/* Pager */
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 24px;
}
.pager button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.pager button:hover:not(:disabled) {
  border-color: var(--brand-500);
  color: var(--brand-700);
}
.pager button.active {
  background: var(--brand-500);
  color: #fff;
  border-color: var(--brand-500);
}
.pager button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Filter debounce bar — full-width progress strip at the viewport bottom while
   waiting for additional user input after a facet change. Resets on each new selection. */
.filter-debounce-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30px;
  background: rgba(11, 165, 236, 0.15);
  overflow: hidden;
  z-index: 2000;
  display: none;
}
.filter-debounce-bar.active {
  display: block;
}
.filter-debounce-bar-fill {
  height: 100%;
  width: 0;
  background: var(--brand-500);
  animation: filter-debounce-fill 1s linear forwards;
}
@keyframes filter-debounce-fill {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------- Responsive: tablet & below ---------------- */
@media (max-width: 900px) {
  .header {
    padding: 12px 16px;
    gap: 12px;
    row-gap: 8px;
  }
  .logo {
    font-size: 18px;
  }
  .search-bar {
    flex-basis: 100%;
    max-width: none;
    order: 10;
  }
  .bottom-panels {
    flex-direction: column;
    padding: 0 16px 16px;
    margin-top: 16px;
    gap: 16px;
  }
  .timing-phase {
    width: auto;
  }
  .timing-table {
    font-size: 11px;
  }

  .container {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
  }
  .sidebar {
    width: 100%;
  }
  .boost-sidebar {
    width: 100%;
  }

  /* Facets on tablet: two-column grid to avoid a long vertical list above results */
  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    align-items: start;
  }
  .facet-group {
    margin-bottom: 0;
  }
}

/* ---------------- Responsive: phone ---------------- */
@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .header {
    padding: 10px 12px;
    gap: 8px;
  }
  /* iOS zooms inputs with font-size < 16px on focus — prevent that */
  .search-bar input {
    font-size: 16px;
    height: 44px;
    padding: 10px 14px;
  }
  .search-bar button {
    height: 44px;
    padding: 10px 18px;
    font-size: 15px;
  }

  .autocomplete-dropdown {
    max-height: 60vh;
  }
  .autocomplete-item {
    padding: 10px 14px;
    font-size: 15px;
  }

  .container {
    padding: 12px;
    gap: 12px;
  }

  /* Facets back to single column — avoids cramped split on narrow screens */
  .sidebar {
    grid-template-columns: 1fr;
  }
  .boost-sidebar {
    width: 100%;
  }
  .facet-group {
    padding: 14px;
  }

  /* Product grid: smaller cards on phones */
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
  .product-info {
    padding: 10px 12px;
  }
  .product-title {
    font-size: 13px;
  }
  .product-price {
    font-size: 15px;
  }

  .results-info {
    font-size: 12px;
  }

  .empty-state {
    padding: 48px 20px;
  }
  .empty-state h2 {
    font-size: 16px;
  }

  .pager {
    flex-wrap: wrap;
    gap: 6px;
  }
  .pager button {
    padding: 0 10px;
    font-size: 12px;
  }
}

/* Image-search / audio-search / reset icon buttons.
   Same square 36x36 silhouette as the Suchen button, neutral surface,
   brand hover. */
.search-bar #image-btn,
.search-bar #audio-btn,
.search-bar #reset-btn {
  height: 36px;
  width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}
.search-bar #image-btn:hover,
.search-bar #audio-btn:hover,
.search-bar #reset-btn:hover {
  border-color: var(--brand-500);
  background: var(--brand-50);
}
.search-bar #image-btn:focus-visible,
.search-bar #audio-btn:focus-visible,
.search-bar #reset-btn:focus-visible {
  box-shadow: var(--focus-ring);
}
.search-bar #audio-btn.recording {
  background: var(--error-50);
  border-color: var(--error-600);
  color: var(--error-700);
}

/* Only render the preview row when JS removes [hidden]. Without :not() the
   class's `display: flex` would beat the UA `[hidden] { display: none }`
   rule on equal specificity (source-order wins) — they'd be visible empty. */
.media-preview:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1400px;
  margin: 16px auto 0;
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.media-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
#media-detected {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}
#media-detected strong {
  color: var(--brand-700);
}
#media-detected .image-error {
  color: var(--error-700);
  font-weight: 600;
}

.media-preview button#media-clear {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.media-preview button#media-clear:hover {
  background: var(--error-50);
  border-color: var(--error-200);
  color: var(--error-700);
}

.image-debug {
  max-width: 1400px;
  margin: 8px auto 0;
  padding: 0 24px;
  font-size: 12px;
  color: var(--text-secondary);
}
.image-debug summary {
  cursor: pointer;
  padding: 6px 12px;
  background: var(--warning-50);
  border: 1px solid var(--warning-700);
  border-radius: var(--radius-md);
  font-weight: 600;
  color: var(--warning-700);
  user-select: none;
}
.image-debug summary:hover {
  background: #fef0c7;
}
.image-debug pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-700);
  max-height: 300px;
  overflow-y: auto;
}
.image-debug-sub {
  margin-top: 8px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

/* Audio recording indicator + transcript bubble. Same :not([hidden]) guard
   as .media-preview above — see the comment there. */
.audio-recording:not([hidden]) {
  max-width: 1400px;
  margin: 8px auto 0;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-primary);
}
.audio-rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--error-600);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
#audio-rec-timer {
  font-family: var(--font-mono);
}
.audio-rec-cap {
  color: var(--text-muted);
}
.audio-recording button#audio-stop {
  margin-left: auto;
  height: 32px;
  padding: 0 14px;
  background: var(--error-600);
  color: #fff;
  border: 1px solid var(--error-600);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.audio-recording button#audio-stop:hover {
  background: var(--error-700);
  border-color: var(--error-700);
}

.audio-transcript {
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--gray-700);
  font-style: italic;
  flex-shrink: 0;
  max-width: 60%;
}
