/* @trusearch/widgets — Base styles using --tws-* custom properties */

/* Healthcare-demo reference styles — opt-in, scoped under .tws-hc-panel.
   Lives in a separate file so consumers who don't need the demo styling
   can drop the @import (or remove the cp from package.json's build) and
   ship a smaller bundle. */
@import './healthcare-demo.css';

/* ===== Root ===== */
.tws-root {
  font-family: var(
    --tws-font-family,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    sans-serif
  );
  color: var(--tws-text, #1a1a1a);
  line-height: 1.5;
  box-sizing: border-box;
  padding: var(--tws-root-padding, 15px);
}

.tws-root *,
.tws-root *::before,
.tws-root *::after {
  box-sizing: inherit;
}

/* ===== Envelope ===== */
.tws-envelope {
  width: 100%;
}

/* ===== Grid Layout ===== */
.tws-grid {
  display: grid;
  gap: calc(var(--tws-spacing, 8px) * 2);
  grid-template-columns: 1fr;
}

.tws-grid--with-sidebar {
  grid-template-columns: 1fr;
}

.tws-grid__sidebar {
  display: flex;
  flex-direction: column;
  gap: calc(var(--tws-spacing, 8px) * 2);
}

.tws-grid__main {
  display: flex;
  flex-direction: column;
  gap: calc(var(--tws-spacing, 8px) * 2);
}

@media (min-width: 768px) {
  .tws-grid--with-sidebar {
    grid-template-columns: 240px 1fr;
  }

  .tws-grid--2col .tws-grid__main {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .tws-grid--3col .tws-grid__main {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .tws-grid--4col .tws-grid__main {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1024px) {
  .tws-grid--with-sidebar {
    grid-template-columns: 280px 1fr;
  }
}

/* ===== Widget wrapper ===== */
.tws-widget__subtitle {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--tws-text-muted, #6b7280);
  margin-bottom: calc(var(--tws-spacing, 8px) / 2);
}

.tws-widget__title {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 calc(var(--tws-spacing, 8px));
  color: var(--tws-text, #1a1a1a);
}

/* ===== Search Box ===== */
.tws-search-box {
  position: relative;
  width: 100%;
}

.tws-search-box__input-wrapper {
  position: relative;
}

.tws-search-box__label {
  display: contents;
}

.tws-search-box__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tws-text-muted, #6b7280);
  pointer-events: none;
}

.tws-search-box__input {
  width: 100%;
  padding: 8px 16px 8px 36px;
  font-size: 0.875rem;
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  color: var(--tws-text, #1a1a1a);
  outline: none;
  font-family: inherit;
}

.tws-search-box__input:focus {
  border-color: var(--tws-primary, #2563eb);
  box-shadow: 0 0 0 2px
    color-mix(in srgb, var(--tws-primary, #2563eb) 20%, transparent);
}

.tws-search-box__dropdown {
  position: absolute;
  z-index: 50;
  width: 100%;
  margin-top: 4px;
  background: var(--tws-bg, #fff);
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  list-style: none;
  padding: 4px 0;
  margin-left: 0;
}

.tws-search-box__suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--tws-text, #1a1a1a);
}

.tws-search-box__suggestion:hover,
.tws-search-box__suggestion--active {
  background: var(--tws-bg-accent, #f3f4f6);
}

.tws-search-box__suggestion-icon {
  color: var(--tws-text-muted, #6b7280);
  flex-shrink: 0;
}

/* ===== Results List ===== */
.tws-results-list {
  display: flex;
  flex-direction: column;
  gap: var(--tws-spacing, 8px);
}

.tws-results-list--prompt {
  text-align: center;
  padding: 48px 16px;
  font-size: 0.9375rem;
  color: var(--tws-text-muted, #6b7280);
}

.tws-results-list--empty {
  padding: calc(var(--tws-spacing, 8px) * 4);
  text-align: center;
  color: var(--tws-text-muted, #6b7280);
  font-size: 0.875rem;
}

.tws-results-list--loading {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.tws-results-list__body {
  position: relative;
}

.tws-results-list--refetching .tws-results-list__body {
  pointer-events: none;
}

.tws-results-list__loading-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--tws-bg, #fff) 70%, transparent);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Skeleton Loading ===== */
@keyframes tws-shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

.tws-skeleton {
  background: linear-gradient(
    90deg,
    var(--tws-skeleton-base, #e5e7eb) 25%,
    var(--tws-skeleton-shine, #f3f4f6) 50%,
    var(--tws-skeleton-base, #e5e7eb) 75%
  );
  background-size: 200% 100%;
  animation: tws-shimmer 1.5s infinite ease-in-out;
  border-radius: 4px;
}

.tws-skeleton-card {
  border: none;
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, transparent);
  width: 80%;
  display: flex;
  height: 120px;
}

.tws-skeleton-card__content {
  height: 16px;
  min-height: 100%;
  flex: 1;
  width: 60%;
}

.tws-results-list--no-results {
  padding: calc(var(--tws-spacing, 8px) * 6) calc(var(--tws-spacing, 8px) * 3);
  border: 1px dashed var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg-accent, #f9fafb);
}

.tws-results-list__no-results-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--tws-text, #1a1a1a);
}

.tws-results-list__item {
  padding: calc(var(--tws-spacing, 8px) * 2);
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  cursor: default;
}

.tws-results-list__item[role='button'] {
  cursor: pointer;
}

.tws-results-list__item[role='button']:hover {
  border-color: var(--tws-primary, #2563eb);
}

.tws-results-list__item-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.tws-results-list__item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--tws-text, #1a1a1a);
}

.tws-results-list__item-link {
  color: var(--tws-primary, #2563eb);
  text-decoration: none;
}

.tws-results-list__item-link:hover {
  text-decoration: underline;
}

.tws-results-list__badge {
  display: inline-block;
  padding: 1px 8px;
  font-size: 0.75rem;
  border-radius: 9999px;
  background: var(--tws-bg-accent, #f3f4f6);
  color: var(--tws-text-muted, #6b7280);
}

.tws-results-list__snippet {
  font-size: 0.875rem;
  color: var(--tws-text-muted, #6b7280);
  margin: 0;
  line-height: 1.6;
}

.tws-results-list__snippet em,
.tws-results-list__snippet mark {
  background-color: var(--tws-highlight, #fef08a);
  font-style: normal;
  font-weight: 500;
}

/* ===== Dynamic Result Card ===== */

/* Results grid container for grid/list/compact view modes */
.tws-results-grid {
  display: flex;
  flex-direction: column;
  gap: var(--tws-spacing, 8px);
}

.tws-results-grid--grid {
  display: grid;
  gap: calc(var(--tws-spacing, 8px) * 2);
}

.tws-results-grid--grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.tws-results-grid--grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.tws-results-grid--grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
  .tws-results-grid--grid-2,
  .tws-results-grid--grid-3,
  .tws-results-grid--grid-4 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .tws-results-grid--grid-3,
  .tws-results-grid--grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Base card */
.tws-result-card {
  display: flex;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  overflow: hidden;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.tws-result-card[role='button'],
.tws-result-card[role='link'] {
  cursor: pointer;
}

.tws-result-card[role='button']:hover,
.tws-result-card[role='link']:hover {
  border-color: var(--tws-primary, #2563eb);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.tws-result-card[role='button']:hover .tws-result-card__title,
.tws-result-card[role='link']:hover .tws-result-card__title {
  color: var(--tws-primary, #2563eb);
  text-decoration: underline;
}

/* List view: horizontal layout */
.tws-result-card--list {
  flex-direction: row;
  align-items: stretch;
}

.tws-result-card--list .tws-result-card__image-container {
  width: 180px;
  height: 140px;
  flex-shrink: 0;
  border-radius: var(--tws-border-radius, 8px) 0 0 var(--tws-border-radius, 8px);
}

.tws-result-card--list .tws-result-card__content {
  flex: 1;
  padding: calc(var(--tws-spacing, 8px) * 2);
  min-width: 0;
}

.tws-result-card--list .tws-result-card__actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: calc(var(--tws-spacing, 8px) * 2);
  border-inline-start: 1px solid var(--tws-border, #e5e7eb);
}

/* Grid view: vertical card */
.tws-result-card--grid {
  flex-direction: column;
}

.tws-result-card--grid .tws-result-card__image-container {
  width: 100%;
  height: 180px;
}

.tws-result-card--grid .tws-result-card__content {
  padding: calc(var(--tws-spacing, 8px) * 2);
  flex: 1;
}

.tws-result-card--grid .tws-result-card__actions {
  display: flex;
  gap: 8px;
  padding: 0 calc(var(--tws-spacing, 8px) * 2) calc(var(--tws-spacing, 8px) * 2);
  flex-wrap: wrap;
}

/* Compact view: single row */
.tws-result-card--compact {
  flex-direction: row;
  align-items: center;
  padding: var(--tws-spacing, 8px) calc(var(--tws-spacing, 8px) * 2);
  gap: calc(var(--tws-spacing, 8px) * 2);
}

.tws-result-card--compact .tws-result-card__image-container {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
}

.tws-result-card--compact .tws-result-card__content {
  flex: 1;
  min-width: 0;
}

.tws-result-card--compact .tws-result-card__snippet,
.tws-result-card--compact .tws-result-card__extras {
  display: none;
}

.tws-result-card--compact .tws-result-card__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Image */
.tws-result-card__image-container {
  overflow: hidden;
  background: var(--tws-bg-accent, #f9fafb);
}

.tws-result-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Content */
.tws-result-card__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tws-result-card__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tws-result-card__badge {
  display: inline-block;
  width: fit-content;
  padding: 1px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
  background: var(--tws-primary, #2563eb);
  color: #fff;
}

.tws-result-card__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tws-text, #1a1a1a);
  margin: 0;
  line-height: 1.4;
}

.tws-result-card__subtitle {
  font-size: 0.85rem;
  color: var(--tws-text-muted, #6b7280);
  margin: 0;
  line-height: 1.5;
}

.tws-result-card__snippet {
  font-size: 0.85rem;
  color: var(--tws-text-muted, #6b7280);
  margin: 0;
  line-height: 1.6;
}

/* Clamped text wrapper with expand/collapse */
.tws-result-card__clamped-wrapper {
  position: relative;
}

.tws-result-card__expand-btn {
  display: inline-block;
  margin-top: 4px;
  padding: 0;
  border: none;
  background: none;
  color: var(--tws-primary, #2563eb);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
}

.tws-result-card__expand-btn:hover {
  text-decoration: underline;
}

.tws-result-card__snippet em,
.tws-result-card__snippet mark {
  background-color: var(--tws-highlight, #fef08a);
  font-style: normal;
  font-weight: 500;
}

/* Meta row */
.tws-result-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--tws-text-muted, #6b7280);
  margin-top: 4px;
}

.tws-result-card__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tws-result-card__meta-item--distance {
  font-weight: 500;
  color: var(--tws-primary, #2563eb);
}

.tws-result-card__meta-item--distance::before {
  content: '📍';
  font-size: 0.85em;
}

.tws-result-card__meta-item--price {
  font-weight: 600;
  color: var(--tws-text, #1a1a1a);
}

.tws-result-card__meta-item--rating {
  color: #f59e0b;
}

.tws-result-card__rating-value {
  color: var(--tws-text-muted, #6b7280);
  font-size: 0.75rem;
  margin-inline-start: 2px;
}

/* Extra fields */
.tws-result-card__extras {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.tws-result-card__extra {
  font-size: 0.8rem;
  color: var(--tws-text-muted, #6b7280);
}

.tws-result-card__extra--badge {
  padding: 1px 8px;
  border-radius: 9999px;
  background: var(--tws-bg-accent, #f3f4f6);
  font-size: 0.75rem;
}

.tws-result-card__extra-label {
  font-weight: 500;
  margin-inline-end: 4px;
}

/* CTA buttons */
.tws-result-card__actions {
  flex-shrink: 0;
}

.tws-result-card__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--tws-border-radius, 8px);
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.15s,
    border-color 0.15s;
  cursor: pointer;
}

.tws-result-card__cta--primary {
  background: var(--tws-primary, #2563eb);
  color: #fff;
  border: 1px solid var(--tws-primary, #2563eb);
}

.tws-result-card__cta--primary:hover {
  opacity: 0.9;
}

.tws-result-card__cta--secondary {
  background: var(--tws-bg-accent, #f3f4f6);
  color: var(--tws-text, #1a1a1a);
  border: 1px solid var(--tws-border, #e5e7eb);
}

.tws-result-card__cta--secondary:hover {
  background: var(--tws-border, #e5e7eb);
}

.tws-result-card__cta--outline {
  background: transparent;
  color: var(--tws-primary, #2563eb);
  border: 1px solid var(--tws-primary, #2563eb);
}

.tws-result-card__cta--outline:hover {
  background: var(--tws-primary, #2563eb);
  color: #fff;
}

.tws-result-card__cta--ghost {
  background: transparent;
  color: var(--tws-primary, #2563eb);
  border: 1px solid transparent;
}

.tws-result-card__cta--ghost:hover {
  background: var(--tws-bg-accent, #f3f4f6);
}

.tws-result-alpha-group {
  margin: 10px 0;
}

.tws-result-group__glossary-letter {
  margin-bottom: 5px;
}

/* View switcher */
.tws-results-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.tws-results-list__view-all {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--tws-primary, #2563eb);
  text-decoration: none;
  transition: color 0.15s;
}

.tws-results-list__view-all:hover {
  text-decoration: underline;
}

.tws-view-switcher {
  display: inline-flex;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  overflow: hidden;
}

.tws-view-switcher__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: none;
  background: var(--tws-bg, #fff);
  color: var(--tws-text-muted, #6b7280);
  cursor: pointer;
  font-size: 0.8rem;
  gap: 4px;
  transition:
    background-color 0.15s,
    color 0.15s;
}

.tws-view-switcher__button:not(:last-child) {
  border-inline-end: 1px solid var(--tws-border, #e5e7eb);
}

.tws-view-switcher__button--active {
  background: var(--tws-primary, #2563eb);
  color: #fff;
}

.tws-view-switcher__button:hover:not(.tws-view-switcher__button--active) {
  background: var(--tws-bg-accent, #f3f4f6);
}

/* ===== Map Layout ===== */

/* Shared height for both layouts. The Google Maps SDK paints tiles into a
 * chain of `height: 100%` divs — percentages need a *definite* height on an
 * ancestor to resolve (min-height alone isn't enough), so we set a concrete
 * height here and let everything inside inherit it. */
.tws-results-map-layout {
  height: 600px;
  max-height: 80vh;
}

.tws-results-map-layout--side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--tws-spacing, 8px) * 2);
}

.tws-results-map-layout__map {
  height: 100%;
  border-radius: var(--tws-border-radius, 8px);
  overflow: hidden;
}

.tws-results-map-layout__list {
  height: 100%;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .tws-results-map-layout--side-by-side {
    grid-template-columns: 1fr;
  }

  .tws-results-map-layout {
    height: auto;
    max-height: none;
  }

  .tws-results-map-layout__map {
    height: 400px;
  }

  .tws-results-map-layout__list {
    height: auto;
    max-height: 400px;
  }
}

/* Highlighted card when marker is clicked */
.tws-result-card--highlighted {
  border-color: var(--tws-primary, #2563eb);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Google Maps component */
.tws-google-map {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 400px;
}

.tws-google-map--missing-key {
  align-items: center;
  justify-content: center;
}

.tws-google-map__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--tws-bg, #fff);
  border-bottom: 1px solid var(--tws-border, #e5e7eb);
  flex-wrap: wrap;
}

.tws-google-map__places-input {
  flex: 1;
  min-width: 200px;
  padding: 6px 12px;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  font-size: 0.85rem;
  outline: none;
}

.tws-google-map__places-input:focus {
  border-color: var(--tws-primary, #2563eb);
}

.tws-google-map__radius-select {
  padding: 6px 8px;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.tws-google-map__radius-select:hover {
  border-color: var(--tws-primary, #2563eb);
}

.tws-google-map__location-btn,
.tws-google-map__clear-btn {
  padding: 6px 12px;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s;
}

.tws-google-map__location-btn:hover,
.tws-google-map__clear-btn:hover {
  border-color: var(--tws-primary, #2563eb);
}

.tws-google-map__location-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tws-google-map__error {
  padding: 6px 12px;
  font-size: 13px;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  margin: 0 8px 8px;
}

.tws-google-map__canvas {
  flex: 1;
  min-height: 300px;
  position: relative;
}

.tws-google-map__canvas > div {
  height: 100%;
  width: 100%;
}

/* Ensure Google Places Autocomplete dropdown renders above the map. */
.pac-container {
  z-index: 10000;
}

/* Marker info popup */
.tws-google-map__info {
  display: flex;
  gap: 10px;
  min-width: 200px;
  max-width: 280px;
  font-family: var(--tws-font-family, inherit);
}

.tws-google-map__info-thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--tws-border-radius, 8px);
  object-fit: cover;
  background: var(--tws-bg-accent, #f3f4f6);
}

.tws-google-map__info-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.tws-google-map__info-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--tws-text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.tws-google-map__info-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--tws-text, #1f2937);
  line-height: 1.3;
}

.tws-google-map__info-desc {
  font-size: 12px;
  color: var(--tws-text-muted, #6b7280);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tws-google-map__info-link {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--tws-primary, #2563eb);
  text-decoration: none;
  align-self: flex-start;
}

.tws-google-map__info-link:hover {
  text-decoration: underline;
}

/* Multiple markers at same location - carousel view */
.tws-google-map__info-carousel {
  min-width: 200px;
  max-width: 280px;
  font-family: var(--tws-font-family, inherit);
}

.tws-google-map__info-carousel-content {
  /* Empty — client can add MarkerInfo styles */
}

.tws-google-map__info-carousel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--tws-border, #e5e7eb);
}

.tws-google-map__info-carousel-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--tws-text-muted, #6b7280);
}

.tws-google-map__info-carousel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 6px);
  background: var(--tws-bg, #ffffff);
  color: var(--tws-text, #1f2937);
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.tws-google-map__info-carousel-btn:hover:not(:disabled) {
  background: var(--tws-bg-accent, #f3f4f6);
  border-color: var(--tws-border-hover, #d1d5db);
}

.tws-google-map__info-carousel-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Geo Distance Facet ===== */
.tws-facet-panel__geo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 4px;
}

.tws-facet-panel__geo-warning {
  padding: 6px 10px;
  font-size: 12px;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 6px;
}

.tws-facet-panel__geo-address-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  transition: border-color 0.15s;
}

.tws-facet-panel__geo-address-wrapper:focus-within {
  border-color: var(--tws-primary, #2563eb);
}

.tws-facet-panel__geo-address {
  flex: 1;
  min-width: 0;
  padding: 6px 56px 6px 10px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tws-facet-panel__geo-locate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 100%;
  padding: 0;
  border: none;
  border-left: 1px solid var(--tws-border, #e5e7eb);
  background: var(--tws-bg-accent, transparent);
  color: var(--tws-text-muted, #6b7280);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background-color 0.15s,
    color 0.15s;
}

.tws-facet-panel__geo-locate-btn:hover:not(:disabled) {
  background: var(--tws-bg, #fff);
  color: var(--tws-primary, #2563eb);
}

.tws-facet-panel__geo-locate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tws-facet-panel__geo-address-clear {
  position: absolute;
  right: 38px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--tws-text-muted, #6b7280);
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.tws-facet-panel__geo-address-clear:hover {
  opacity: 1;
}

@keyframes tws-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.tws-spin {
  animation: tws-spin 1s linear infinite;
}

.tws-facet-panel__geo-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tws-facet-panel__geo-radius-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tws-facet-panel__geo-label {
  font-size: 12px;
  color: var(--tws-text-muted, #6b7280);
}

.tws-facet-panel__geo-radius {
  padding: 4px 8px;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  font-size: 0.8rem;
  cursor: pointer;
}

.tws-facet-panel__geo-btn {
  padding: 5px 10px;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  font-size: 0.8rem;
  cursor: pointer;
}

.tws-facet-panel__geo-btn:hover {
  border-color: var(--tws-primary, #2563eb);
}

.tws-facet-panel__geo-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tws-facet-panel__geo-btn--clear {
  color: #dc2626;
}

.tws-facet-panel__geo-error {
  padding: 5px 10px;
  font-size: 12px;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
}

.tws-facet-panel__geo-active {
  padding: 4px 0;
  font-size: 12px;
  color: var(--tws-text-muted, #6b7280);
}

/* ===== Facet Panel ===== */
.tws-facet-panel {
  display: flex;
  flex-direction: column;
  gap: calc(var(--tws-spacing, 8px) * 2);
}

.tws-facet-panel__active {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.tws-facet-panel__active-label {
  font-size: 0.75rem;
  margin-right: 5px;
}

.tws-facet-panel__active-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.tws-facet-panel__active-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 9999px;
  background: var(--tws-primary, #2563eb);
  color: #fff;
  margin: 2px;
  max-width: 200px;
}

.tws-facet-panel__active-badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tws-facet-panel__remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 0;
  display: flex;
  align-items: center;
}

.tws-facet-panel__clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
  padding: 2px 8px;
}

.tws-facet-panel__clear-btn:hover {
  color: var(--tws-text, #1a1a1a);
}

.tws-facet-panel__section {
  display: flex;
  flex-direction: column;
  gap: calc(var(--tws-spacing, 8px) * 1.5);
  padding-bottom: calc(var(--tws-spacing, 8px) * 1.5);
  border-bottom: 1px solid var(--tws-border, #e5e7eb);
}

.tws-facet-panel__section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.tws-facet-panel__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--tws-text, #1a1a1a);
}

.tws-facet-panel__section-header:hover {
  opacity: 0.7;
}

.tws-facet-panel__section-title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tws-text, #1a1a1a);
}

.tws-facet-panel__section-body {
  display: flex;
  flex-direction: column;
  gap: calc(var(--tws-spacing, 8px) * 1.25);
  padding-inline-start: calc(var(--tws-spacing, 8px) * 1.5);
}

.tws-facet-panel__facet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 0;
  margin-bottom: 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--tws-text, #1a1a1a);
}

.tws-facet-panel__facet-header:hover {
  opacity: 0.7;
}

.tws-facet-panel__facet-title {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tws-text-muted, #6b7280);
}

.tws-facet-panel__facet-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tws-facet-panel__facet-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

.tws-facet-panel__checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--tws-primary, #2563eb);
}

.tws-facet-panel__label {
  flex: 1;
  cursor: pointer;
  color: var(--tws-text, #1a1a1a);
}

.tws-facet-panel__radio-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 8px;
  margin: -4px -8px;
  border: none;
  background: none;
  font-size: 0.875rem;
  text-align: start;
  cursor: pointer;
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  transition: background-color 0.15s;
}

.tws-facet-panel__radio-btn:hover {
  background: var(--tws-bg-accent, #f3f4f6);
}

.tws-facet-panel__radio-btn:focus {
  outline: none;
}

.tws-facet-panel__radio-btn--selected {
  background: color-mix(in srgb, var(--tws-primary, #2563eb) 10%, transparent);
}

.tws-facet-panel__radio-btn--selected:hover {
  background: color-mix(in srgb, var(--tws-primary, #2563eb) 15%, transparent);
}

.tws-facet-panel__radio-btn .tws-facet-panel__label {
  cursor: inherit;
}

.tws-facet-panel__count {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
}

.tws-facet-panel__expand-btn {
  margin-top: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--tws-primary, #2563eb);
  padding: 0;
}

.tws-facet-panel__expand-btn:hover {
  text-decoration: underline;
}

.tws-facet-panel__glossary {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tws-facet-panel__glossary-group {
  border-top: 1px solid var(--tws-border, #e5e7eb);
}

.tws-facet-panel__glossary-group:last-child {
  border-bottom: 1px solid var(--tws-border, #e5e7eb);
}

.tws-facet-panel__glossary-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--tws-text, #1a1a1a);
}

.tws-facet-panel__glossary-header:hover {
  opacity: 0.8;
}

.tws-facet-panel__glossary-letter {
  font-size: 0.875rem;
  font-weight: 600;
  min-width: 1.25rem;
  color: var(--tws-text, #1a1a1a);
}

.tws-facet-panel__glossary-count {
  flex: 1;
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
}

.tws-facet-panel__glossary-group .tws-facet-panel__facet-list {
  padding-block: 4px 8px;
  padding-inline-start: calc(var(--tws-spacing, 8px) * 1.5);
}

.tws-facet-panel__range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tws-facet-panel__range-input {
  width: 80px;
  padding: 4px 8px;
  font-size: 0.75rem;
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  background: var(--tws-bg, #fff);
  color: var(--tws-text, #1a1a1a);
  font-family: inherit;
}

.tws-facet-panel__range-sep {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
}

.tws-facet-panel__apply-btn {
  padding: 4px 12px;
  font-size: 0.75rem;
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  background: var(--tws-bg-accent, #f3f4f6);
  cursor: pointer;
  color: var(--tws-text, #1a1a1a);
  font-family: inherit;
}

.tws-facet-panel__apply-btn:hover {
  background: var(--tws-border, #d1d5db);
}

/* Numeric range slider */
.tws-facet-panel__slider {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.tws-facet-panel__slider-input {
  flex: 1;
  height: 4px;
  appearance: none;
  background: var(--tws-border, #d1d5db);
  border-radius: 2px;
  outline: none;
}

.tws-facet-panel__slider-input::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tws-primary, #2563eb);
  cursor: pointer;
}

.tws-facet-panel__range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tws-facet-panel__range-unit {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
  font-weight: 500;
}

/* Date range */
.tws-facet-panel__date-range {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tws-facet-panel__date-inputs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tws-facet-panel__date-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tws-facet-panel__date-label-text {
  font-size: 0.7rem;
  color: var(--tws-text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tws-facet-panel__date-input {
  padding: 6px 8px;
  font-size: 0.8rem;
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  background: var(--tws-bg, #fff);
  color: var(--tws-text, #1a1a1a);
  font-family: inherit;
  width: 100%;
}

.tws-facet-panel__date-input:focus {
  outline: none;
  border-color: var(--tws-primary, #2563eb);
}

/* Single date */
.tws-facet-panel__date-single {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tws-facet-panel__clear-date-btn {
  padding: 4px 8px;
  font-size: 0.7rem;
  border: none;
  background: none;
  color: var(--tws-primary, #2563eb);
  cursor: pointer;
  text-decoration: underline;
}

/* Date grouped dropdown */
.tws-facet-panel__date-grouped {
  margin-top: 4px;
}

.tws-facet-panel__date-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 0.8rem;
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  background: var(--tws-bg, #fff);
  color: var(--tws-text, #1a1a1a);
  font-family: inherit;
  cursor: pointer;
}

.tws-facet-panel__date-select:focus {
  outline: none;
  border-color: var(--tws-primary, #2563eb);
}

/* ===== Facet Panel Disabled State ===== */

.tws-facet-panel--empty {
  color: var(--tws-text-muted, #6b7280);
}

.tws-facet-panel__section--disabled {
  opacity: 0.5;
  pointer-events: none;
}

.tws-facet-panel__section--disabled .tws-facet-panel__section-header {
  cursor: not-allowed;
}

.tws-facet-panel__facet--disabled {
  opacity: 0.5;
  pointer-events: none;
}

.tws-facet-panel__facet-header--disabled {
  cursor: not-allowed;
  background: var(--tws-bg-muted, #f3f4f6);
}

/* ===== Facet Dropdown ===== */

.tws-facet-panel__facet--dropdown {
  display: flex;
  flex-direction: column;
}

.tws-facet-dropdown {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tws-facet-dropdown__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--tws-text, #1a1a1a);
  text-align: start;
}

.tws-facet-dropdown__trigger:hover {
  opacity: 0.7;
}

.tws-facet-dropdown__trigger-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tws-text-muted, #6b7280);
}

.tws-facet-dropdown__trigger-value {
  flex: 1;
  font-size: 0.875rem;
  color: var(--tws-text, #1a1a1a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tws-facet-dropdown__menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--tws-bg, #fff);
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
  max-height: 240px;
  overflow-y: auto;
  padding: 5px;
}

.tws-facet-dropdown__menu .tws-facet-panel__radio-btn {
  margin: 0;
}

.tws-facet-dropdown__menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--tws-text, #1a1a1a);
  list-style: none;
}

.tws-facet-dropdown__menu-item:hover,
.tws-facet-dropdown__menu-item--focused {
  background: var(--tws-hover-bg, #f3f4f6);
}

.tws-facet-dropdown__menu-item--selected {
  font-weight: 500;
}

.tws-facet-dropdown__checkbox {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--tws-primary, #2563eb);
}

.tws-facet-dropdown__menu-item-label {
  flex: 1;
}

.tws-facet-dropdown__menu-item-count {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
}

/* ===== Pagination ===== */
.tws-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  margin-top: 10px;
}

.tws-pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: 0.875rem;
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  background: var(--tws-bg, #fff);
  color: var(--tws-text, #1a1a1a);
  cursor: pointer;
  font-family: inherit;
}

.tws-pagination__btn:hover:not(:disabled) {
  background: var(--tws-bg-accent, #f3f4f6);
}

.tws-pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tws-pagination__btn--active {
  background: var(--tws-primary, #2563eb);
  color: #fff;
  border-color: var(--tws-primary, #2563eb);
}

.tws-pagination__ellipsis {
  padding: 0 4px;
  color: var(--tws-text-muted, #6b7280);
}

/* ===== Stats Bar ===== */
.tws-stats-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--tws-text-muted, #6b7280);
  margin-bottom: 5px;
}

.tws-stats-bar__count {
  font-weight: 600;
  color: var(--tws-text, #1a1a1a);
}

.tws-stats-bar__query {
  font-weight: 500;
}

.tws-stats-bar__duration {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tws-stats-bar__icon {
  flex-shrink: 0;
}

.tws-stats-bar__mode {
  text-transform: capitalize;
}

.tws-stats-bar__ai-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 4px;
  background: var(--tws-primary, #2563eb);
  color: #fff;
}

/* ===== AI Answer Card =====
 *
 * Two visual presentations driven by config — same markup, different
 * CSS variables / config knobs:
 *
 *   • Default: padded card on white. Header with text label, single-line
 *     answer body, citation chips inline.
 *
 *   • "Beacon" presentation (set `headerLabel` to a non-default string and
 *     `showHeaderDot: true` on the slot, optionally override the CSS
 *     variables below): cream-tinted card with a navy accent bar on the
 *     left, mono uppercase header label with a pulsing sage dot, serif
 *     body, dark navy numbered chip citations, sources list with dotted
 *     dividers and right-aligned uppercase type tags.
 *
 * The visual switch is driven entirely by the per-tenant theme variables.
 * Tenants override variables in their host page (`--tws-ai-answer-...`) to
 * skin the card without touching CSS files.
 */
.tws-ai-answer {
  position: relative;
  padding: var(--tws-ai-answer-padding, 28px 32px);
  background: var(--tws-ai-answer-bg, #fff);
  border: 1px solid var(--tws-ai-answer-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  font-family: var(--tws-ai-answer-font, var(--tws-font, inherit));
}

.tws-ai-answer::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--tws-ai-answer-accent-width, 2px);
  background: var(--tws-ai-answer-accent, transparent);
  border-top-left-radius: inherit;
  border-bottom-left-radius: inherit;
}

.tws-ai-answer__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.tws-ai-answer__header-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tws-ai-answer-dot, #7a9b7e);
  animation: tws-ai-answer-pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes tws-ai-answer-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.tws-ai-answer__header-label {
  font-family: var(
    --tws-ai-answer-label-font,
    var(--tws-font-mono, ui-monospace, SFMono-Regular, monospace)
  );
  font-size: var(--tws-ai-answer-label-size, 10px);
  letter-spacing: var(--tws-ai-answer-label-tracking, 0.12em);
  text-transform: uppercase;
  color: var(--tws-ai-answer-label-color, var(--tws-text-muted, #6b7280));
}

.tws-ai-answer__subtitle {
  margin-bottom: 16px;
}

.tws-ai-answer__subtitle-label {
  font-family: var(
    --tws-ai-answer-label-font,
    var(--tws-font-mono, ui-monospace, SFMono-Regular, monospace)
  );
  font-size: var(--tws-ai-answer-label-size, 10px);
  letter-spacing: var(--tws-ai-answer-label-tracking, 0.12em);
  text-transform: uppercase;
  color: var(--tws-ai-answer-label-color, var(--tws-text-muted, #6b7280));
}

/* Backwards-compat: any existing host CSS targeting `__title` still works,
 * routed to the same visual treatment as the new `__header-label`.
 */
.tws-ai-answer__title {
  font-size: 0.875rem;
  font-weight: 500;
}

.tws-ai-answer__model {
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 9999px;
  background: var(--tws-bg-accent, #f3f4f6);
  color: var(--tws-text-muted, #6b7280);
}

.tws-ai-answer__body {
  font-family: var(--tws-ai-answer-body-font, inherit);
  font-size: var(--tws-ai-answer-body-size, 17px);
  line-height: var(--tws-ai-answer-body-line-height, 1.65);
  color: var(--tws-ai-answer-body-color, var(--tws-text, #1a1a1a));
  font-weight: 400;
  letter-spacing: -0.005em;
}

.tws-ai-answer__paragraph {
  margin: 0;
}

.tws-ai-answer__paragraph + .tws-ai-answer__paragraph {
  margin-top: 14px;
}

.tws-ai-answer__strong {
  font-weight: 600;
}

/* Legacy single-line answer text — retained so existing consumers of
 * `tws-ai-answer__text` continue to render. The new structure uses
 * `__body` + `__paragraph` instead.
 */
.tws-ai-answer__text {
  font-size: 0.875rem;
  line-height: 1.7;
  margin: 0;
  color: var(--tws-text, #1a1a1a);
}

/* Inline numbered citation chip — the dark badge with a white number that
 * sits at the end of a phrase in the answer body. Click scrolls the matched
 * result card into view via `data-doc-id`.
 */
.tws-ai-answer__cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin: 0 2px;
  background: var(--tws-ai-answer-cite-bg, var(--tws-primary, #1f2937));
  color: var(--tws-ai-answer-cite-color, #fff);
  font-family: var(
    --tws-ai-answer-cite-font,
    var(--tws-font-mono, ui-monospace, SFMono-Regular, monospace)
  );
  font-size: 10px;
  font-weight: 500;
  border: none;
  border-radius: 2px;
  vertical-align: 2px;
  cursor: pointer;
  transition: background 0.12s;
}

.tws-ai-answer__cite:hover {
  background: var(--tws-ai-answer-cite-hover-bg, var(--tws-accent, #3b8a82));
}

/* Sources block — the numbered list under the body with right-aligned
 * type tags. Each row is `[num] [title] ... [type]` separated by dotted
 * dividers.
 */
.tws-ai-answer__sources {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--tws-ai-answer-rule, var(--tws-border, #e5e7eb));
}

.tws-ai-answer__sources-label {
  font-family: var(
    --tws-ai-answer-label-font,
    var(--tws-font-mono, ui-monospace, SFMono-Regular, monospace)
  );
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tws-ai-answer-label-color, var(--tws-text-muted, #6b7280));
  margin-bottom: 12px;
}

.tws-ai-answer__source-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.tws-ai-answer__source-item {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px dotted
    var(--tws-ai-answer-rule, var(--tws-border, #e5e7eb));
}

.tws-ai-answer__source-item:last-child {
  border-bottom: none;
}

.tws-ai-answer__source-num {
  font-family: var(
    --tws-ai-answer-label-font,
    var(--tws-font-mono, ui-monospace, SFMono-Regular, monospace)
  );
  font-size: 11px;
  color: var(--tws-ai-answer-label-color, var(--tws-text-muted, #6b7280));
  width: 20px;
  flex-shrink: 0;
}

.tws-ai-answer__source-title {
  color: var(--tws-text, #1a1a1a);
  font-weight: 500;
  flex: 1;
  text-decoration: none;
}

.tws-ai-answer__source-title:hover {
  color: var(--tws-accent, var(--tws-primary, #2563eb));
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tws-ai-answer__source-type {
  font-family: var(
    --tws-ai-answer-label-font,
    var(--tws-font-mono, ui-monospace, SFMono-Regular, monospace)
  );
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tws-ai-answer-label-color, var(--tws-text-muted, #6b7280));
}

/* Legacy "all citations as inline chips" — used by the standalone
 * AiAnswerCard widget. Retained for back-compat; the new sources block
 * supersedes this for the search-page integration.
 */
.tws-ai-answer__citations {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
}

.tws-ai-answer__citations-label {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
}

/* Highlight pulse when a citation scrolls to its referenced result card */
.tws-result-card--highlighted {
  outline: 2px solid var(--tws-primary, #2563eb);
  outline-offset: 2px;
  animation: tws-card-highlight 2s ease-out;
}

@keyframes tws-card-highlight {
  0% {
    background-color: color-mix(
      in srgb,
      var(--tws-primary, #2563eb) 15%,
      transparent
    );
  }

  100% {
    background-color: transparent;
  }
}

/* ===== Ranking modification indicators ===== */

/* Pinned result — subtle left border accent */
.tws-result-card--pinned {
  border-left: 3px solid var(--tws-primary, #2563eb);
}

/* Promoted result (injected, wasn't in natural results) — distinct left border */
.tws-result-card--promoted {
  border-left: 3px solid #8b5cf6;
}

/* Boosted result — business rule boost */
.tws-result-card--boosted {
  border-left: 3px solid #f59e0b;
}

/* Editorial boost — manually curated for this query */
.tws-result-card--editorial {
  border-left: 3px solid #10b981;
}

/* Buried result — pushed to bottom */
.tws-result-card--buried {
  opacity: 0.6;
}

/* Ranking badge — small pill shown before the title */
.tws-result-card__ranking-badge {
  display: inline-block;
  padding: 1px 8px;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 9999px;
  white-space: nowrap;
  line-height: 1.5;
}

.tws-result-card__ranking-badge--pinned {
  background: color-mix(in srgb, var(--tws-primary, #2563eb) 12%, transparent);
  color: var(--tws-primary, #2563eb);
}

.tws-result-card__ranking-badge--promoted {
  background: color-mix(in srgb, #8b5cf6 12%, transparent);
  color: #7c3aed;
}

.tws-result-card__ranking-badge--boosted {
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  color: #b45309;
}

.tws-result-card__ranking-badge--featured {
  background: color-mix(in srgb, #10b981 12%, transparent);
  color: #047857;
}

.tws-ai-answer__feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--tws-border, #d1d5db);
}

.tws-ai-answer__feedback-label {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
}

.tws-ai-answer__feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  background: var(--tws-bg, #fff);
  cursor: pointer;
  color: var(--tws-text-muted, #6b7280);
}

.tws-ai-answer__feedback-btn:hover {
  background: var(--tws-bg-accent, #f3f4f6);
}

.tws-ai-answer__feedback-btn--active {
  background: var(--tws-primary, #2563eb);
  border-color: var(--tws-primary, #2563eb);
  color: #fff;
}

.tws-ai-answer__cursor {
  display: inline-block;
  margin-left: 2px;
  color: var(--tws-primary, #2563eb);
  animation: tws-ai-blink 1s steps(2, start) infinite;
}

.tws-ai-answer__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--tws-border, #e5e7eb);
}

.tws-ai-answer__powered-by {
  font-size: 0.6875rem;
  color: var(--tws-text-muted, #9ca3af);
  font-style: italic;
}

@keyframes tws-ai-blink {
  to {
    visibility: hidden;
  }
}

.tws-ai-answer__text--error {
  color: var(--tws-destructive, #dc2626);
}

/* ===== Steps Card ===== */
.tws-steps__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tws-steps__item {
  display: flex;
  gap: 12px;
  padding: calc(var(--tws-spacing, 8px) * 1.5) 0;
  border-bottom: 1px solid var(--tws-border, #d1d5db);
}

.tws-steps__item:last-child {
  border-bottom: none;
}

.tws-steps__number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--tws-primary, #2563eb);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
}

.tws-steps__content {
  flex: 1;
}

.tws-steps__title {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--tws-text, #1a1a1a);
}

.tws-steps__description {
  font-size: 0.8125rem;
  color: var(--tws-text-muted, #6b7280);
  margin: 0;
  line-height: 1.5;
}

/* ===== Knowledge Card ===== */
.tws-knowledge {
  padding: calc(var(--tws-spacing, 8px) * 2);
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
}

.tws-knowledge__image {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  margin-bottom: 12px;
}

.tws-knowledge__title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--tws-text, #1a1a1a);
}

.tws-knowledge__summary {
  font-size: 0.875rem;
  color: var(--tws-text-muted, #6b7280);
  margin: 0 0 12px;
  line-height: 1.6;
}

.tws-knowledge__facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  margin: 0;
}

.tws-knowledge__fact {
  display: contents;
}

.tws-knowledge__fact-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--tws-text-muted, #6b7280);
}

.tws-knowledge__fact-value {
  font-size: 0.8125rem;
  color: var(--tws-text, #1a1a1a);
  margin: 0;
}

.tws-knowledge__source {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--tws-primary, #2563eb);
  text-decoration: none;
}

.tws-knowledge__source:hover {
  text-decoration: underline;
}

/* ===== Comparison Table ===== */
.tws-comparison__scroll {
  overflow-x: auto;
}

.tws-comparison__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.tws-comparison__th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  border-bottom: 2px solid var(--tws-border, #d1d5db);
  color: var(--tws-text, #1a1a1a);
  white-space: nowrap;
}

.tws-comparison__tr {
  border-bottom: 1px solid var(--tws-border, #d1d5db);
}

.tws-comparison__tr[role='button'] {
  cursor: pointer;
}

.tws-comparison__tr[role='button']:hover {
  background: var(--tws-bg-accent, #f3f4f6);
}

.tws-comparison__td {
  padding: 8px 12px;
  color: var(--tws-text, #1a1a1a);
}

/* ===== Ranked List ===== */
.tws-ranked-list__items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tws-ranked-list__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--tws-spacing, 8px) * 1.5) 0;
  border-bottom: 1px solid var(--tws-border, #d1d5db);
}

.tws-ranked-list__item:last-child {
  border-bottom: none;
}

.tws-ranked-list__item[role='button'] {
  cursor: pointer;
}

.tws-ranked-list__rank {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--tws-primary, #2563eb);
  min-width: 28px;
  text-align: center;
}

.tws-ranked-list__thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
}

.tws-ranked-list__content {
  flex: 1;
  min-width: 0;
}

.tws-ranked-list__title {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--tws-text, #1a1a1a);
}

.tws-ranked-list__desc {
  display: block;
  font-size: 0.8125rem;
  color: var(--tws-text-muted, #6b7280);
  margin-top: 2px;
}

.tws-ranked-list__score-bar {
  height: 4px;
  width: 100%;
  background: var(--tws-bg-accent, #f3f4f6);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.tws-ranked-list__score-fill {
  height: 100%;
  background: var(--tws-primary, #2563eb);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ===== Chart Widget ===== */
.tws-chart {
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  padding: calc(var(--tws-spacing, 8px) * 2);
  background: var(--tws-bg, #fff);
}

.tws-chart--empty {
  text-align: center;
  color: var(--tws-text-muted, #6b7280);
  font-size: 0.875rem;
  padding: calc(var(--tws-spacing, 8px) * 4);
}

.tws-chart__container {
  width: 100%;
}

.tws-chart__fallback-title {
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0 0 12px;
  color: var(--tws-text, #1a1a1a);
}

/* ===== Recommendation Carousel ===== */
.tws-carousel {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tws-carousel__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: 50%;
  background: var(--tws-bg, #fff);
  cursor: pointer;
  color: var(--tws-text, #1a1a1a);
  flex-shrink: 0;
}

.tws-carousel__nav:hover {
  background: var(--tws-bg-accent, #f3f4f6);
}

.tws-carousel__track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex: 1;
}

.tws-carousel__track::-webkit-scrollbar {
  display: none;
}

.tws-carousel__card {
  scroll-snap-align: start;
  flex: 0 0 200px;
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  overflow: hidden;
}

.tws-carousel__card[role='button'] {
  cursor: pointer;
}

.tws-carousel__card[role='button']:hover {
  border-color: var(--tws-primary, #2563eb);
}

.tws-carousel__image {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.tws-carousel__card-body {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tws-carousel__card-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--tws-text, #1a1a1a);
}

.tws-carousel__card-desc {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tws-carousel__card-price {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tws-text, #1a1a1a);
}

/* ===== Map Widget ===== */
.tws-map {
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  overflow: hidden;
  background: var(--tws-bg, #fff);
}

.tws-map--fallback {
  padding: calc(var(--tws-spacing, 8px) * 2);
}

.tws-map__pin-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
  color: var(--tws-primary, #2563eb);
}

/* ===== Calendar Card ===== */
.tws-calendar {
  display: flex;
  flex-direction: column;
  gap: calc(var(--tws-spacing, 8px) * 2);
}

.tws-calendar__month {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--tws-text, #1a1a1a);
}

.tws-calendar__events {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tws-calendar__event {
  display: flex;
  gap: 8px;
  padding: calc(var(--tws-spacing, 8px) * 1.5);
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
}

.tws-calendar__event[role='button'] {
  cursor: pointer;
}

.tws-calendar__event[role='button']:hover {
  border-color: var(--tws-primary, #2563eb);
}

.tws-calendar__icon {
  color: var(--tws-primary, #2563eb);
  flex-shrink: 0;
  margin-top: 2px;
}

.tws-calendar__event-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tws-calendar__event-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tws-primary, #2563eb);
}

.tws-calendar__event-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--tws-text, #1a1a1a);
}

.tws-calendar__event-desc {
  font-size: 0.8125rem;
  color: var(--tws-text-muted, #6b7280);
}

.tws-calendar__event-location {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
  font-style: italic;
}

/* ===== Quick Links ===== */
.tws-quick-links {
  padding: calc(var(--tws-spacing, 8px) * 2);
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
}

.tws-quick-links__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
}

.tws-quick-links__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: calc(var(--tws-border-radius, 8px) / 1.5);
  text-decoration: none;
  color: var(--tws-text, #1a1a1a);
  transition:
    background-color 0.15s,
    box-shadow 0.15s;
  cursor: pointer;
}

.tws-quick-links__link:hover {
  background: var(--tws-bg-accent, #f3f4f6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tws-quick-links__icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 4px;
}

.tws-quick-links__icon-default {
  flex-shrink: 0;
  color: var(--tws-primary, #2563eb);
  opacity: 0.7;
}

.tws-quick-links__label {
  font-size: 0.875rem;
  font-weight: 500;
  flex-shrink: 0;
}

.tws-quick-links__description {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #6b7280);
  margin-inline-start: auto;
  text-align: end;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Suggestions Widget ===== */

.tws-suggestions {
  padding: calc(var(--tws-spacing, 8px) * 1.5);
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
}

.tws-suggestions__title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tws-text-muted, #6b7280);
  margin-bottom: 8px;
}

.tws-suggestions__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 8px;
}

.tws-suggestions--horizontal .tws-suggestions__list {
  flex-direction: row;
  flex-wrap: wrap;
}

.tws-suggestions--vertical .tws-suggestions__list {
  flex-direction: column;
}

.tws-suggestions__item {
  display: flex;
}

.tws-suggestions--vertical .tws-suggestions__item {
  width: 100%;
}

.tws-suggestions__button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: 999px;
  background: var(--tws-bg, #fff);
  color: var(--tws-text, #1a1a1a);
  font-size: 0.875rem;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
}

.tws-suggestions--vertical .tws-suggestions__button {
  width: 100%;
  justify-content: flex-start;
  border-radius: calc(var(--tws-border-radius, 8px) / 1.5);
}

.tws-suggestions__button:hover {
  background: var(--tws-bg-accent, #f3f4f6);
  border-color: var(--tws-primary, #2563eb);
}

.tws-suggestions__button svg {
  flex-shrink: 0;
  color: var(--tws-text-muted, #9ca3af);
}

.tws-suggestions__text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tws-suggestions__empty {
  font-size: 0.875rem;
  color: var(--tws-text-muted, #6b7280);
  padding: 8px 4px;
}

/* ===== Autocomplete Panel ===== */
/*
 * ============================================
 * TruSearch Autocomplete Panel — CSS API
 * ============================================
 *
 * CSS Custom Properties (set on .tws-autocomplete-panel or any ancestor):
 *
 *   --tws-ac-width            Panel width (default: 860px)
 *   --tws-ac-max-height       Panel max height (default: 480px)
 *   --tws-ac-columns          Grid column count (default: 4)
 *   --tws-ac-gap              Gap between columns (default: 24px)
 *   --tws-ac-bg               Panel background color (default: #fff)
 *   --tws-ac-input-bg         Search input background color (default: panel bg)
 *   --tws-ac-border-radius    Panel border radius (default: 12px)
 *   --tws-ac-shadow           Panel box shadow (default: 0 8px 30px rgba(0,0,0,0.12))
 *   --tws-ac-header-color     Section title color (default: #6b7280)
 *   --tws-ac-hover-bg         Item hover background (default: #f3f4f6)
 *
 *   Per-section overrides (set on section wrapper, fall back to panel vars):
 *   --tws-ac-section-bg            Section background (default: transparent)
 *   --tws-ac-section-header-color  Section title color (default: panel header color)
 *   --tws-ac-section-hover-bg      Section item hover bg (default: panel hover bg)
 *
 *   --tws-ac-item-radius      Item border radius (default: 8px)
 *   --tws-ac-item-gap         Gap between icon/image and text (default: 10px)
 *   --tws-ac-title-size       Item title font size (default: 0.875rem)
 *   --tws-ac-title-weight     Item title font weight (default: 500)
 *   --tws-ac-subtitle-size    Subtitle font size (default: 0.75rem)
 *   --tws-ac-section-gap      Gap between items in a section (default: 2px)
 *   --tws-ac-column-gap       Gap between sections in a column (default: 16px)
 *   --tws-border              Panel border color (default: #d1d5db)
 *   --tws-text                Primary text color (default: #1a1a1a)
 *   --tws-text-muted          Muted text color (default: #9ca3af)
 *   --tws-font-family         Font family (default: system fonts)
 *   --tws-spacing             Base spacing unit (default: 8px)
 *
 * Data Attributes (for targeted styling):
 *
 *   [data-section-type]       "recent" | "popular" | "entity"
 *   [data-entity-type]        e.g. "service", "provider_profile", "blog_article"
 *   [data-section-key]        Unique section identifier
 *   [data-column]             Column number (1-4)
 *   [data-display-style]      "list" | "card" | "compact"
 *   [data-doc-id]             Document ID on each result item
 *
 * Example custom styling:
 *
 *   // Style all provider items differently
 *   [data-entity-type="provider_profile"] .tws-autocomplete-panel__item { ... }
 *
 *   // Style column 2 specifically
 *   [data-column="2"] .tws-autocomplete-panel__section-title { color: blue; }
 *
 *   // Style recent searches section
 *   [data-section-type="recent"] .tws-autocomplete-panel__search-term { ... }
 *
 *   // Override image size for a specific entity type
 *   [data-entity-type="blog_article"] .tws-autocomplete-panel__image { width: 100px; height: 60px; }
 */

.tws-autocomplete-panel {
  position: absolute;
  z-index: 50;
  width: var(--tws-ac-width, 860px);
  font-family: var(
    --tws-font-family,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    sans-serif
  );
  color: var(--tws-text, #1a1a1a);
}

.tws-autocomplete-panel__content {
  position: relative;
  max-height: var(--tws-ac-max-height, 480px);
  overflow-y: auto;
  background: var(--tws-ac-bg, #fff);
  border: 1px solid var(--tws-border, #d1d5db);
  border-radius: var(--tws-ac-border-radius, 12px);
  box-shadow: var(--tws-ac-shadow, 0 8px 30px rgba(0, 0, 0, 0.12));
  padding: calc(var(--tws-spacing, 8px) * 2.5);
  scrollbar-width: thin;
}

.tws-autocomplete-panel__content::-webkit-scrollbar {
  width: 3px;
}

.tws-autocomplete-panel__content::-webkit-scrollbar-track {
  background: transparent;
}

.tws-autocomplete-panel__content::-webkit-scrollbar-thumb {
  border-radius: 2px;
}

.tws-autocomplete-panel__loading-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--tws-ac-primary-color, #3b82f6) 0%,
    var(--tws-ac-primary-color, #3b82f6) 30%,
    transparent 30%
  );
  background-size: 200% 100%;
  animation: tws-ac-loading-bar 1.2s ease-in-out infinite;
  border-radius: var(--tws-ac-border-radius, 12px)
    var(--tws-ac-border-radius, 12px) 0 0;
  z-index: 2;
}

@keyframes tws-ac-loading-bar {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

.tws-autocomplete-panel__close {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--tws-ac-header-color, #6b7280);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  z-index: 1;
}

.tws-autocomplete-panel__close:hover {
  background: var(--tws-ac-hover-bg, #f3f4f6);
  color: var(--tws-text, #1a1a1a);
}

.tws-autocomplete-panel--inline {
  position: static;
  width: 100%;
  box-shadow: none;
  margin-top: 8px;
}

.tws-autocomplete-panel__grid {
  display: grid;
  grid-template-columns: repeat(var(--tws-ac-columns, 4), 1fr);
  gap: var(--tws-ac-gap, 24px);
}

.tws-autocomplete-panel__column {
  display: flex;
  flex-direction: column;
  gap: var(--tws-ac-column-gap, calc(var(--tws-spacing, 8px) * 2));
}

.tws-autocomplete-panel__section {
  display: flex;
  flex-direction: column;
  gap: var(--tws-ac-section-gap, 2px);
}

/* Section wrapper for per-section theme overrides */
.tws-autocomplete-panel__section-wrapper {
  background: var(--tws-ac-section-bg, transparent);
}

.tws-autocomplete-panel__section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(
    --tws-ac-section-header-color,
    var(--tws-ac-header-color, #6b7280)
  );
  margin-bottom: 6px;
  /* Defensive — host stylesheets sometimes default to underlined text on
     small caps / labels. We never want an underline on the section title. */
  text-decoration: none;
}

.tws-autocomplete-panel__section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.tws-autocomplete-panel__section-header .tws-autocomplete-panel__section-title {
  margin-bottom: 0;
}

.tws-autocomplete-panel__section-note {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--tws-ac-header-color, #9ca3af);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.tws-autocomplete-panel__search-term {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: start;
  font-size: 0.875rem;
  color: var(--tws-text, #1a1a1a);
  width: 100%;
  transition: background-color 0.15s;
}

.tws-autocomplete-panel__search-term:hover {
  background: var(--tws-ac-section-hover-bg, var(--tws-ac-hover-bg, #f3f4f6));
}

.tws-autocomplete-panel__search-term svg {
  flex-shrink: 0;
  color: var(--tws-text-muted, #9ca3af);
}

.tws-autocomplete-panel__search-term-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--tws-text-muted, #9ca3af);
}

.tws-autocomplete-panel__search-term-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* List container — wraps items within a section */
.tws-autocomplete-panel__list {
  display: flex;
  flex-direction: column;
}

/* Suggestions section (horizontal pills or vertical list) */
.tws-autocomplete-panel__suggestions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 6px;
}

/* Horizontal: inline pills that wrap onto new rows when they don't fit. */
.tws-autocomplete-panel__suggestions-list--horizontal {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

/* Vertical: stacked rows, each filling the column. */
.tws-autocomplete-panel__suggestions-list--vertical {
  flex-direction: column;
  align-items: stretch;
}

.tws-autocomplete-panel__suggestion {
  display: flex;
  min-width: 0;
}

.tws-autocomplete-panel__suggestions-list--horizontal
  .tws-autocomplete-panel__suggestion {
  flex: 0 0 auto;
}

.tws-autocomplete-panel__suggestions-list--vertical
  .tws-autocomplete-panel__suggestion {
  width: 100%;
}

.tws-autocomplete-panel__suggestion-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: transparent;
  color: var(--tws-text, #1a1a1a);
  font-size: 0.875rem;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s;
}

/* Pill-shaped chips for horizontal mode. */
.tws-autocomplete-panel__suggestions-list--horizontal
  .tws-autocomplete-panel__suggestion-button {
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: 999px;
  white-space: nowrap;
}

/* Full-width list rows for vertical mode. */
.tws-autocomplete-panel__suggestions-list--vertical
  .tws-autocomplete-panel__suggestion-button {
  width: 100%;
  justify-content: flex-start;
  border: 1px solid transparent;
  border-radius: var(--tws-ac-item-radius, 8px);
}

.tws-autocomplete-panel__suggestion-button:hover {
  background: var(--tws-ac-section-hover-bg, var(--tws-ac-hover-bg, #f3f4f6));
}

.tws-autocomplete-panel__suggestions-list--horizontal
  .tws-autocomplete-panel__suggestion-button:hover {
  border-color: var(--tws-primary, #2563eb);
}

.tws-autocomplete-panel__suggestion-button svg {
  flex-shrink: 0;
  color: var(--tws-text-muted, #9ca3af);
}

.tws-autocomplete-panel__suggestion-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tws-autocomplete-panel__suggestions-list--vertical
  .tws-autocomplete-panel__suggestion-text {
  white-space: nowrap;
}

/* Quick link styles */
.tws-autocomplete-panel__link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--tws-ac-item-radius, 8px);
  cursor: pointer;
  text-decoration: none;
  color: var(--tws-text, #1a1a1a);
  transition: background-color 0.15s;
}

.tws-autocomplete-panel__link:hover {
  background: var(--tws-ac-section-hover-bg, var(--tws-ac-hover-bg, #f3f4f6));
}

.tws-autocomplete-panel__link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--tws-text-muted, #9ca3af);
}

.tws-autocomplete-panel__link-icon svg {
  flex-shrink: 0;
}

.tws-autocomplete-panel__link-label {
  font-size: var(--tws-ac-title-size, 0.875rem);
  font-weight: var(--tws-ac-title-weight, 500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Item styles */
.tws-autocomplete-panel__item {
  display: flex;
  align-items: flex-start;
  gap: var(--tws-ac-item-gap, 10px);
  padding: 8px;
  border: none;
  background: none;
  border-radius: var(--tws-ac-item-radius, 8px);
  cursor: pointer;
  text-align: start;
  width: 100%;
  transition: background-color 0.15s;
}

.tws-autocomplete-panel__item:hover {
  background: var(--tws-ac-section-hover-bg, var(--tws-ac-hover-bg, #f3f4f6));
}

/* Pinned items — distinct styling for promoted/pinned results */
.tws-autocomplete-panel__item--pinned {
  background: var(--tws-ac-pinned-bg, #eff6ff);
  border-inline-start: 3px solid
    var(--tws-ac-pinned-accent, var(--tws-primary, #2563eb));
  padding-inline-start: calc(8px - 3px);
}

.tws-autocomplete-panel__item--pinned:hover {
  background: var(--tws-ac-pinned-hover-bg, #dbeafe);
}

.tws-autocomplete-panel__item--list {
  padding: 6px 8px;
}

.tws-autocomplete-panel__item--card {
  flex-direction: row;
  align-items: flex-start;
  text-align: start;
  padding: 10px;
}

.tws-autocomplete-panel__item--compact {
  padding: 4px 8px;
  gap: 8px;
}

.tws-autocomplete-panel__item-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.tws-autocomplete-panel__item-title {
  font-size: var(--tws-ac-title-size, 0.875rem);
  font-weight: var(--tws-ac-title-weight, 500);
  color: var(--tws-text, #1a1a1a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tws-autocomplete-panel__item-subtitle {
  font-size: var(--tws-ac-subtitle-size, 0.75rem);
  color: var(--tws-text-muted, #9ca3af);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tws-autocomplete-panel__item-date {
  font-size: 0.7rem;
  color: var(--tws-text-muted, #9ca3af);
}

.tws-autocomplete-panel__item-snippet {
  font-size: 0.75rem;
  color: var(--tws-text-muted, #9ca3af);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Item image wrapper */
.tws-autocomplete-panel__item-image {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
}

/* Item meta row (date, etc.) */
.tws-autocomplete-panel__item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Images */
.tws-autocomplete-panel__image {
  width: 48px;
  height: 48px;
  object-fit: cover;
  flex-shrink: 0;
}

.tws-autocomplete-panel__item--card .tws-autocomplete-panel__image {
  width: 64px;
  height: 64px;
  margin-bottom: 4px;
}

.tws-autocomplete-panel__image--circle {
  border-radius: 50%;
}

.tws-autocomplete-panel__image--rounded {
  border-radius: 8px;
}

.tws-autocomplete-panel__image--square {
  border-radius: 0;
}

/* Image sizes */
.tws-autocomplete-panel__image--small {
  width: 32px;
  height: 32px;
}

.tws-autocomplete-panel__image--medium {
  width: 48px;
  height: 48px;
}

.tws-autocomplete-panel__image--large {
  width: 64px;
  height: 64px;
}

.tws-autocomplete-panel__item--card .tws-autocomplete-panel__image--small {
  width: 40px;
  height: 40px;
}

.tws-autocomplete-panel__item--card .tws-autocomplete-panel__image--medium {
  width: 64px;
  height: 64px;
}

.tws-autocomplete-panel__item--card .tws-autocomplete-panel__image--large {
  width: 80px;
  height: 80px;
}

/* Section header with link */
.tws-autocomplete-panel__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.tws-autocomplete-panel__section-header .tws-autocomplete-panel__section-title {
  margin-bottom: 0;
}

.tws-autocomplete-panel__section-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--tws-ac-header-color, #6b7280);
  transition:
    background-color 0.15s,
    color 0.15s;
  text-decoration: none;
  flex-shrink: 0;
}

.tws-autocomplete-panel__section-link:hover {
  background: var(--tws-ac-section-hover-bg, var(--tws-ac-hover-bg, #f3f4f6));
  color: var(--tws-text, #1a1a1a);
}

/* Search input */
.tws-autocomplete-panel__search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 999px;
  border: 2px solid var(--tws-ac-header-color, #6b7280);
  background: var(--tws-ac-input-bg, var(--tws-ac-bg, #fff));
}

.tws-autocomplete-panel__search-input svg {
  flex-shrink: 0;
  color: var(--tws-text-muted, #9ca3af);
}

.tws-autocomplete-panel__search-label {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.tws-autocomplete-panel__search-label-text {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--tws-text-muted, #6b7280);
  line-height: 1.2;
  margin-bottom: 2px;
}

.tws-autocomplete-panel__search-field-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.tws-autocomplete-panel__search-input-row {
  /*
   * Wraps just the <input> + ghost overlay so position: relative anchors
   * the ghost to the input row only, not the label text above it.
   */
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.tws-autocomplete-panel__search-field {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: var(--tws-text, #1a1a1a);
  font-family: inherit;
  /* Anchor the input so the ghost-text overlay can sit at the same coords. */
  position: relative;
  z-index: 1;
}

.tws-autocomplete-panel__search-field::placeholder {
  color: var(--tws-text-muted, #9ca3af);
}

.tws-autocomplete-panel__ghost {
  /*
   * Ghost-text inline completion overlay. The prefix span renders
   * transparently, taking the same pixel width as what the user typed; the
   * suffix renders in muted color, appearing right after the caret.
   * pointer-events: none lets clicks pass through to the input.
   */
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  pointer-events: none;
  font-size: 1rem;
  font-family: inherit;
  white-space: pre;
  z-index: 0;
  user-select: none;
}

.tws-autocomplete-panel__ghost-prefix {
  color: transparent;
}

.tws-autocomplete-panel__ghost-suffix {
  color: var(--tws-text-muted, #9ca3af);
  opacity: 0.85;
}

.tws-autocomplete-panel__search-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: 999px;
  border: none;
  background: var(--tws-ac-header-color, #6b7280);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}

.tws-autocomplete-panel__search-button:hover {
  opacity: 0.9;
}

/* Typeahead suggestions wrapper */
.tws-autocomplete-panel__search-wrapper {
  position: relative;
  margin-bottom: 12px;
}

.tws-autocomplete-panel__search-wrapper .tws-autocomplete-panel__search-input {
  margin-bottom: 0;
}

/* Loading spinner */
.tws-autocomplete-panel__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.tws-autocomplete-panel__spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--tws-ac-hover-bg, #f3f4f6);
  border-top-color: var(--tws-ac-header-color, #6b7280);
  border-radius: 50%;
  animation: tws-spin 0.6s linear infinite;
}

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

/* Section type separators — add a top border between sections in the same column */
.tws-autocomplete-panel__column > * + * {
  padding-top: var(--tws-ac-section-separator-spacing, 0);
  border-top: var(--tws-ac-section-separator, none);
}

/* Active/highlighted item (keyboard navigation) */
.tws-autocomplete-panel__item--active,
.tws-autocomplete-panel__search-term--active {
  background: var(--tws-ac-hover-bg, #f3f4f6);
  outline: 2px solid var(--tws-ac-focus-ring, rgba(59, 130, 246, 0.3));
  outline-offset: -2px;
}

/* Empty state placeholder */
.tws-autocomplete-panel__empty {
  padding: 12px 8px;
  font-size: 0.8rem;
  color: var(--tws-text-muted, #9ca3af);
  font-style: italic;
  text-align: center;
}

/* Skeleton loading states */
.tws-autocomplete-panel__skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tws-autocomplete-panel__skeleton-list--cards {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
}

.tws-autocomplete-panel__skeleton-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}

.tws-autocomplete-panel__skeleton-icon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}

.tws-autocomplete-panel__skeleton-text {
  height: 14px;
  width: 120px;
  border-radius: 4px;
}

.tws-autocomplete-panel__skeleton-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-ac-hover-bg, #f9fafb);
  min-width: 140px;
  flex: 1;
  max-width: 200px;
}

.tws-autocomplete-panel__skeleton-card-image {
  width: 100%;
  height: 80px;
  border-radius: 6px;
}

.tws-autocomplete-panel__skeleton-card-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tws-autocomplete-panel__skeleton-card-title {
  height: 14px;
  width: 80%;
  border-radius: 4px;
}

.tws-autocomplete-panel__skeleton-card-subtitle {
  height: 12px;
  width: 60%;
  border-radius: 4px;
}

/* ===== Sort Selector ===== */
.tws-sort-selector {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.tws-sort-selector__label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--tws-text-muted, #6b7280);
  white-space: nowrap;
}

.tws-sort-selector__select {
  padding: 6px 28px 6px 10px;
  font-size: 0.8rem;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  color: var(--tws-text, #1a1a1a);
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.tws-sort-selector__select:focus {
  outline: none;
  border-color: var(--tws-primary, #2563eb);
}

/* ===== Alpha Filter (Glossary A-Z) ===== */
.tws-alpha-filter {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tws-alpha-filter__label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--tws-text-muted, #6b7280);
}

.tws-alpha-filter__letters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tws-alpha-filter__letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--tws-border, #e5e7eb);
  border-radius: calc(var(--tws-border-radius, 8px) / 2);
  background: var(--tws-bg, #fff);
  color: var(--tws-text, #1a1a1a);
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.tws-alpha-filter__letter:hover {
  border-color: var(--tws-primary, #2563eb);
  color: var(--tws-primary, #2563eb);
}

.tws-alpha-filter__letter--active {
  background: var(--tws-primary, #2563eb);
  border-color: var(--tws-primary, #2563eb);
  color: #fff;
}

.tws-alpha-filter__letter--active:hover {
  opacity: 0.9;
}

.tws-alpha-filter__letter--disabled {
  border-color: var(--tws-text-muted, #9ca3af);
  background-color: var(--tws-text-muted, #9ca3af);
  color: var(--tws-bg-accent, #374151);
}

.tws-alpha-filter__letter--disabled:hover {
  border-color: transparent;
  cursor: default;
  background-color: var(--tws-text-muted, #9ca3af);
  color: var(--tws-bg-accent, #374151);
}

.tws-alpha-filter__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== Content Block ===== */
.tws-content-block {
  border: 1px dashed var(--tws-border, #e5e7eb);
  border-radius: var(--tws-border-radius, 8px);
  background: var(--tws-bg, #fff);
  overflow: hidden;
}

.tws-content-block__placeholder {
  /* Empty — client injects content */
}

.tws-content-block__fallback {
  padding: calc(var(--tws-spacing, 8px) * 2);
}

/* Responsive */
@media (max-width: 768px) {
  .tws-autocomplete-panel {
    width: 100%;
    max-width: 100vw;
  }

  .tws-autocomplete-panel__grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Dark Mode ===== */
/* Use class-based dark mode so the host app controls it (e.g. next-themes).
   Supports both .dark on a parent element and the OS media query as fallback
   only when .tws-auto-dark is present on the root. */
.dark .tws-root,
.tws-root.tws-dark {
  --tws-text: #f0f0f0;
  --tws-text-muted: #9ca3af;
  --tws-bg: #1f2937;
  --tws-bg-accent: #374151;
  --tws-border: #4b5563;
  --tws-highlight: #854d0e;
}

@media (prefers-color-scheme: dark) {
  .tws-root.tws-auto-dark {
    --tws-text: #f0f0f0;
    --tws-text-muted: #9ca3af;
    --tws-bg: #1f2937;
    --tws-bg-accent: #374151;
    --tws-border: #4b5563;
    --tws-highlight: #854d0e;
  }
}
