/* ws-search: default styles of the search popup (WebsiteSpirit) — docs/plans/WS-COMPONENTS.md.
 * Injected with the component unless its root says data-style="none". Every rule is wrapped in
 * :where() (specificity 0), so any theme rule wins; most themes only set the variables below on
 * :root (and again for their dark mode) — the defaults below are in :where(:root), so a theme's
 * :root wins whichever stylesheet loads first. */
:where(:root) {
  --ws-search-accent: #2563eb;
  --ws-search-accent-soft: rgba(37, 99, 235, 0.12);
  --ws-search-bg: #fff;
  --ws-search-fg: #1f2328;
  --ws-search-muted: #6b7280;
  --ws-search-line: #e5e7eb;
  --ws-search-field: #f3f4f6;
  --ws-search-hover: #f3f4f6;
  --ws-search-backdrop: rgba(15, 23, 42, 0.45);
  --ws-search-radius: 12px;
  --ws-search-width: 640px;
  --ws-search-top: 12vh;
  --ws-search-z: 2000;
  --ws-search-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  --ws-search-font: inherit;
}

/* Hidden means hidden, whatever display a theme gives these elements. */
[data-ws-search][hidden],
[data-ws-search] [hidden] {
  display: none !important;
}
:where(html.ws-search-open),
:where(html.ws-search-open body) {
  overflow: hidden;
}

/* ---- the dialog (the theme's markup) ---- */
:where([data-ws-search]) {
  position: fixed;
  inset: 0;
  z-index: var(--ws-search-z);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--ws-search-top) 16px 16px;
  font-family: var(--ws-search-font);
  color: var(--ws-search-fg);
}
:where([data-ws-search-backdrop]) {
  position: absolute;
  inset: 0;
  background: var(--ws-search-backdrop);
  backdrop-filter: blur(2px);
}
:where([data-ws-search] [role="dialog"]) {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: var(--ws-search-width);
  padding: 14px;
  background: var(--ws-search-bg);
  border: 1px solid var(--ws-search-line);
  border-radius: var(--ws-search-radius);
  box-shadow: var(--ws-search-shadow);
}
:where([data-ws-search] form) {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  margin: 0;
  padding: 0 10px 0 16px;
  background: var(--ws-search-field);
  border: 1px solid var(--ws-search-line);
  border-radius: 999px;
}
:where([data-ws-search] form:focus-within) {
  border-color: var(--ws-search-accent);
  box-shadow: 0 0 0 3px var(--ws-search-accent-soft);
}
:where([data-ws-search-input]) {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  outline: 0;
  font: inherit;
  font-size: 16px;
  color: var(--ws-search-fg);
}
:where([data-ws-search-input])::placeholder {
  color: var(--ws-search-muted);
}
:where([data-ws-search-clear]) {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ws-search-line);
  color: var(--ws-search-muted);
  font-size: 11px;
  cursor: pointer;
}
:where([data-ws-search-close]) {
  flex-shrink: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}
:where([data-ws-search] kbd) {
  display: inline-block;
  min-width: 18px;
  margin-right: 2px;
  padding: 0 5px;
  font:
    11px/18px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  text-align: center;
  color: var(--ws-search-muted);
  background: var(--ws-search-bg);
  border: 1px solid var(--ws-search-line);
  border-radius: 4px;
}

/* ---- what the component renders into [data-ws-search-results] ---- */
:where([data-ws-search-results]) {
  max-height: min(60vh, 540px);
  margin-top: 12px;
  overflow-y: auto;
  border-top: 1px solid var(--ws-search-line);
}
:where(.ws-search-filters) {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 2px;
}
:where(.ws-search-filter) {
  padding: 3px 12px;
  border: 1px solid var(--ws-search-line);
  border-radius: 999px;
  background: var(--ws-search-bg);
  font: inherit;
  font-size: 13px;
  color: var(--ws-search-muted);
  cursor: pointer;
}
:where(.ws-search-filter.is-active) {
  background: var(--ws-search-accent);
  border-color: var(--ws-search-accent);
  color: #fff;
}
:where(.ws-search-note) {
  margin: 0 2px 6px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--ws-search-muted);
  background: var(--ws-search-field);
  border-radius: 8px;
}
:where(.ws-search-message) {
  padding: 22px 12px;
  text-align: center;
  font-size: 14px;
  color: var(--ws-search-muted);
}
:where(.ws-search-list) {
  margin: 0;
  padding: 0;
  list-style: none;
}
:where(.ws-search-item) {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}
:where(.ws-search-item.is-active) {
  background: var(--ws-search-hover);
  box-shadow: inset 3px 0 0 var(--ws-search-accent);
}
:where(.ws-search-item a) {
  color: inherit;
  text-decoration: none;
}
:where(.ws-search-thumb) {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--ws-search-field);
}
:where(.ws-search-thumb img) {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
:where(.ws-search-body) {
  flex: 1;
  min-width: 0;
}
:where(.ws-search-title) {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ws-search-fg);
}
:where(.ws-search-desc) {
  display: -webkit-box;
  margin-top: 2px;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ws-search-muted);
}
:where(.ws-search-meta) {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ws-search-muted);
}
:where(.ws-search-category) {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--ws-search-accent-soft);
  color: var(--ws-search-accent);
}
:where(.ws-search-price) {
  font-size: 14px;
  font-weight: 700;
  color: #e0301e;
}
:where(.ws-search-price:not(:empty))::before {
  content: "¥";
  margin-right: 1px;
  font-size: 0.75em;
}
:where(.ws-search-mark) {
  padding: 0 1px;
  border-radius: 2px;
  background: var(--ws-search-accent-soft);
  color: var(--ws-search-accent);
}
:where(.ws-search-history-head) {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 4px;
  font-size: 12px;
  color: var(--ws-search-muted);
}
:where(.ws-search-history-clear) {
  border: 0;
  background: none;
  font: inherit;
  color: var(--ws-search-muted);
  cursor: pointer;
}
:where(.ws-search-history-item) {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--ws-search-fg);
}
:where(.ws-search-history-text) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Removes one entry. Always there on touch screens; with a mouse, on the hovered / chosen entry. */
:where(.ws-search-history-remove) {
  flex: none;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 4px;
  background: none;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  color: var(--ws-search-muted);
  cursor: pointer;
}
:where(.ws-search-history-remove:hover) {
  background: var(--ws-search-hover);
  color: var(--ws-search-fg);
}
@media (hover: hover) {
  :where(.ws-search-history-item:not(:hover, .is-active) .ws-search-history-remove) {
    visibility: hidden;
  }
}
@media (hover: hover) {
  :where(.ws-search-item:hover) {
    background: var(--ws-search-hover);
  }
  :where(.ws-search-filter:hover) {
    border-color: var(--ws-search-accent);
    color: var(--ws-search-accent);
  }
  :where(.ws-search-filter.is-active:hover) {
    color: #fff;
  }
}
/* Phones: the panel fills the top of the screen. */
@media (max-width: 599px) {
  :where([data-ws-search]) {
    padding: 8px;
  }
}
