/* Discovery page - standalone stylesheet (ADR-0053 precedent: no reuse of
   wiseman.css). Token values duplicated from wiseman.css for a consistent
   look, not imported - this page is deliberately isolated. */
:root {
  color-scheme: light;
  --background: #ffffff;
  --foreground: #000000;
  --card: #fafafa;
  --card-foreground: #000000;
  --muted: #f0f0f0;
  --muted-foreground: #262626;
  --border: #e0e0e0;
  --primary: #000000;
  --primary-foreground: #ffffff;
  --online: #1a7f4b;
  --offline: #9a9a9a;
  /* drop-discovery-search delta (integration-drop-flag change): accent
     color for an integration-sourced drop's tile border/badge - distinct
     from --primary (black, used for text/links) and --online/--offline
     (status dot), so it reads as a third, unrelated signal. */
  --integration-accent: #6d4de0;
  /* discovery-search-attachments capability (ADR-0239 rework): the
     schema-fit badge nests the online/offline status dot inside itself
     (discovery.js's statusGroupHtml()) - using --online for the badge's
     own background (as it originally did) made an online drop's dot
     nearly invisible against its own matching-green pill. Shared with
     .discovery-tile__badge--content-fit (ADR-0241's route "other"
     counterpart) - the two are mutually exclusive per search (a search
     has exactly one route), so a single accent for "this drop is the
     best fit, however that was judged" reads fine without the two ever
     appearing together to be confused for each other. */
  --content-fit-accent: #0f766e;
  --radius: 0.5rem;
  --font-sans: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Cormorant Garamond", Georgia, serif;
}

/* Sidebar color theme continuity: the theme picked in the main app
   (wiseman.css, sidebar dropdown) is applied here too via data-theme on
   <html> (see discovery.js), so a Drop discovered here keeps the same
   palette. The palettes themselves live in server/static/server/css/themes/
   (loaded via themes/index.css, see discovery/index.html) and are shared
   with wiseman.css/discovery_chat.css rather than duplicated here -
   --integration-accent/--content-fit-accent stay constant across themes,
   same as --online/--offline. */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
}

.discovery-app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.discovery-header {
  display: grid;
  grid-template-columns: 1fr minmax(0, 50rem) 1fr;
  /* start, not center (discovery-search-attachments capability): the
     search box grows downward as it goes multi-line/gains attachment
     chips, so centering each column against the row's tallest cell would
     re-center "Drop Store" and the acting-as picker every time it
     grows - both must stay pinned to the row's top edge instead. */
  align-items: start;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--background);
  z-index: 5;
}

.discovery-header__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
  /* Nudges the title's line down to roughly meet the search box's own
     first-line text, now that the header no longer vertically centers
     each column against the other two. */
  margin-top: 0.3rem;
}

.discovery-header__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--foreground);
  /* Matches the Wiseman logo on the home page (.sidebar__logo + h1 base). */
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
}

.discovery-header__back:hover {
  background: var(--muted);
  color: var(--foreground);
}

.discovery-header__title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  color: inherit;
}

.discovery-header__spacer {
  display: block;
}

.discovery-acting-as {
  justify-self: end;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-family: inherit;
  font-size: 0.8rem;
  background: var(--background);
  color: inherit;
  max-width: 12rem;
  /* See .discovery-header__left's own margin-top note above. */
  margin-top: 0.15rem;
}

.discovery-search {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  max-width: 50rem;
  justify-self: center;
}

.discovery-search__box {
  position: relative;
  width: 100%;
}

.discovery-search__input {
  width: 100%;
  resize: none;
  overflow-y: auto;
  min-height: 2.35rem;
  max-height: 40vh;
  padding: 0.55rem 2.25rem 0.55rem 2.35rem;
  border: 1px solid var(--input, var(--border));
  border-radius: 1.15rem;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.3;
  background: var(--card);
  color: var(--foreground);
}

.discovery-search__input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* Both the attach control and the search icon are embedded inside the
   textarea itself (discovery-search-attachments capability), anchored
   near its first line rather than vertically centered, since the box now
   grows downward with multi-line content. */
.discovery-attach-btn {
  position: absolute;
  left: 0.5rem;
  top: 0.4rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.2rem;
  opacity: 0.65;
}

.discovery-attach-btn:hover {
  opacity: 1;
}

.discovery-search__icon {
  position: absolute;
  right: 0.7rem;
  top: 0.55rem;
  pointer-events: none;
  opacity: 0.6;
}

/* Holds the attachment chip list and the search-status text on one row
   (discovery-search-attachments capability) - chips wrap onto further
   rows of their own as they overflow (.discovery-attachment-list's own
   flex-wrap below), but discovery-search-status is a fixed-size sibling
   that never joins that wrap: it stays pinned at the row's top-right,
   unaffected by however tall the chip list grows. */
.discovery-search__status-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.discovery-attachment-list {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.25rem;
}

/* Shown for the duration of an Enter-triggered POST search (discovery.js's
   runEnterSearch()) - a status line beside the attachment chips, not an
   overlay over the results grid, so stale results stay visible and
   readable while the new ones are still loading. margin-left: auto keeps
   it pinned to the row's right edge even when there are no chips at all
   (the attachment list is then a zero-width hidden sibling). */
.discovery-search-status {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  padding: 0.25rem 0.25rem 0;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  white-space: nowrap;
}

.discovery-search-status__dots {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.discovery-search-status__dots span {
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background: currentColor;
  animation: discovery-search-status-bounce 1.1s ease-in-out infinite both;
}

.discovery-search-status__dots span:nth-child(1) {
  animation-delay: -0.3s;
}

.discovery-search-status__dots span:nth-child(2) {
  animation-delay: -0.15s;
}

@keyframes discovery-search-status-bounce {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.discovery-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
}

.discovery-attachment-chip__name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discovery-attachment-chip__remove {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--muted-foreground);
}

@media (max-width: 640px) {
  .discovery-header {
    grid-template-columns: 1fr;
  }

  .discovery-header__spacer {
    display: none;
  }

  .discovery-search {
    max-width: none;
  }

  .discovery-acting-as {
    justify-self: stretch;
    max-width: none;
  }
}

.discovery-results {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
}

.discovery-empty-state {
  color: var(--muted-foreground);
  text-align: center;
  padding: 3rem 0;
}

.discovery-domain-group {
  margin-bottom: 2rem;
}

.discovery-domain-group__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.9rem;
}

.discovery-domain-group__header::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.discovery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.discovery-tile {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  background: var(--card);
}

/* drop-discovery-search delta (integration-drop-flag change): visual-only
   accent for a drop whose `integration` field is true - layout, ranking,
   and grouping are otherwise identical to a regular drop's tile. */
.discovery-tile--integration {
  border-color: var(--integration-accent);
  border-width: 2px;
}

.discovery-tile__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition: opacity 0.15s ease;
}

.discovery-tile__face--front {
  opacity: 1;
}

.discovery-tile__thumb {
  flex: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.discovery-tile__band {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  background: var(--background);
  padding: 0.5rem 0.6rem;
}

.discovery-tile__band-text {
  min-width: 0;
  flex: 1;
}

.discovery-tile__title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.discovery-tile__author {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--muted-foreground);
}

.discovery-tile__face--back {
  opacity: 0;
  pointer-events: none;
  background: var(--background);
  /* Top padding cleared for the single-badge case (top offset 0.6rem +
     one badge's ~1.08rem), which covers the vast majority of tiles -
     reserving for the rare case of both the recommendation and schema-fit
     badges showing at once wasted too much space on every other tile.
     .discovery-tile__summary is scrollable below, so that rare case is at
     worst a slightly crowded first line, never content that's impossible
     to reach. */
  padding: 1.75rem 0.75rem 3.25rem;
}

.discovery-tile:hover .discovery-tile__face--front {
  opacity: 0;
}

.discovery-tile:hover .discovery-tile__face--back {
  opacity: 1;
  pointer-events: auto;
}

/* Scrolls instead of truncating with an ellipsis - a clamped summary had
   no way to read the rest of a long one. flex: 1 + min-height: 0 still
   sizes it to whatever space the flipped tile actually has; overflow
   beyond that scrolls internally rather than being cut off. */
.discovery-tile__summary {
  flex: 1;
  min-height: 0;
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  line-height: 1.35;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.discovery-tile__summary::-webkit-scrollbar {
  width: 0.35rem;
}

.discovery-tile__summary::-webkit-scrollbar-track {
  background: transparent;
}

.discovery-tile__summary::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 9999px;
}

.discovery-tile__open-link {
  align-self: flex-end;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.discovery-tile__open-link:hover {
  text-decoration: underline;
}

.discovery-tile__checkbox {
  flex: none;
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.discovery-tile__checkbox:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.discovery-next-row {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 1rem 1.5rem;
  background: var(--background);
}

.discovery-next-btn {
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 9999px;
  padding: 0.6rem 2rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Top-right group (discovery.js's statusGroupHtml()): no chip -> the
   online/offline dot alone, direct child of this flex row; one or more
   chips -> each its own pill, with the dot nested *inside* the last one
   rather than as a separate sibling, e.g. "(Best schema fit) (Integration
   ●)". Neither chip hides on hover (unlike the old left-side integration
   badge did) - .discovery-tile__badges/__status both sit above both tile
   faces (z-index 2) regardless of which one the hover-flip is currently
   showing, and a schema-fit chip specifically needs to stay hoverable for
   its title tooltip (the match reason) to appear at all. */
.discovery-tile__status {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  max-width: calc(100% - 2rem);
}

.discovery-tile__status .discovery-tile__badge {
  flex-shrink: 1;
  min-width: 0;
}

/* Nested inside whichever chip statusGroupHtml() (discovery.js) put last,
   e.g. "Integration ●" as one pill - not a separate sibling. Vertical
   centering against the chip's text relies on .discovery-tile__badge
   being a flex row (align-items: center) below, not vertical-align - a
   flex item, unlike an inline dot sized against a text baseline, centers
   reliably regardless of exact font metrics. */
.discovery-tile__status-dot {
  flex: 0 0 auto;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.discovery-tile__badge .discovery-tile__status-dot {
  margin-left: 0.3rem;
}

.discovery-tile__status-dot--online {
  background: var(--online);
}

.discovery-tile__status-dot--offline {
  background: var(--offline);
}

/* Top-left group: the recommendation badge only now (drop-discovery-
   search delta) - the integration/schema-fit chips moved into
   .discovery-tile__status above, alongside the status dot. Still a flex
   container (not just the one badge absolutely positioned on its own) so
   a future second left-side badge still wouldn't overlap this one. */
.discovery-tile__badges {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  max-width: calc(100% - 2rem);
}

.discovery-tile__badge {
  /* inline-flex + align-items: center (not vertical-align) so a nested
     discovery-tile__status-dot centers reliably against the label text -
     the slightly taller vertical padding gives the dot breathing room
     against the pill's rounded top/bottom rather than looking cramped.
     line-height: 1 makes the label text's own flex-item box height exactly
     match its font metrics instead of the browser's "normal" default
     (which varies enough per font to throw off centering against the
     dot's fixed 0.6rem size). */
  display: inline-flex;
  align-items: center;
  line-height: 1;
  padding: 0.22rem 0.5rem;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.discovery-tile__badge--integration {
  background: var(--integration-accent);
}

/* discovery-search-attachments capability (ADR-0239 rework): a distinct
   --content-fit-accent, not --online - this badge nests the status dot
   inside itself, and an online drop's green dot nearly disappeared
   against a same-green background. Shares its accent with
   .discovery-tile__badge--content-fit below (ADR-0241) - the two never
   appear on the same drop, so one "best fit" color for either is fine. */
.discovery-tile__badge--schema-fit {
  background: var(--content-fit-accent);
}

.discovery-tile__badge--content-fit {
  background: var(--content-fit-accent);
}

.discovery-tile__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.discovery-tile__recommend-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}

.discovery-tile__recommend-btn:hover:not(:disabled) {
  text-decoration: underline;
}

.discovery-tile__recommend-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  text-decoration: none;
}

.discovery-tile__recommend-form {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.discovery-tile__recommend-input {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 0.75rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
}

.discovery-tile__recommend-error {
  margin: 0;
  color: #b3261e;
  font-size: 0.7rem;
}

.discovery-tile__recommend-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

.discovery-tile__recommend-cancel,
.discovery-tile__recommend-submit {
  border: none;
  border-radius: 9999px;
  padding: 0.3rem 0.75rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.discovery-tile__recommend-cancel {
  background: var(--muted);
  color: var(--foreground);
}

.discovery-tile__recommend-submit {
  background: var(--primary);
  color: var(--primary-foreground);
}

.discovery-tile__recommend-submit:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* author-expert-recommendation spec (ADR-0247): "Recommended Experts"
   section, always below every drop-domain group (discovery.js's render()
   re-appends this section to the end of #discovery-results on every
   render). Absent (via [hidden]) until its own independent request
   resolves with at least one expert - no reserved space, no skeleton. */
.discovery-experts-section {
  margin-top: 1rem;
}

.discovery-experts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.discovery-expert-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.discovery-expert-card__header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Deterministic initials avatar (discovery.js's authorInitials()/
   authorAvatarColor()) stands in for a real photo - no author image
   exists or is fetched from anywhere. */
.discovery-expert-card__avatar {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.discovery-expert-card__author {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.discovery-expert-card__stats {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted-foreground);
}

.discovery-expert-card__rationale {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  flex: 1;
}

.discovery-expert-card__footer {
  display: flex;
  justify-content: flex-end;
}

.discovery-expert-card__invite {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.discovery-expert-card__invite:hover {
  text-decoration: underline;
}

/* discovery-composition-results spec: dedicated section between the
   Drops domain groups and Recommended Experts (discovery.js's render()
   re-appends this section, then discovery-experts-section, to the end of
   #discovery-results on every render). Absent (via [hidden]) whenever
   there are no compositions - no reserved space, no skeleton, mirroring
   discovery-experts-section's own convention above. */
.discovery-compositions-section {
  margin-top: 1rem;
}

.discovery-compositions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.discovery-composition-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.75rem 0.85rem;
}

.discovery-composition-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.discovery-composition-card__kind {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
}

.discovery-composition-card__compose {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.discovery-composition-card__compose:hover {
  text-decoration: underline;
}

.discovery-composition-card__strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.discovery-composition-member {
  flex: none;
  width: 110px;
}

.discovery-composition-member__thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  background: var(--card);
}

.discovery-composition-member__title {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sequential compositions convey pipeline order with a directional arrow;
   parallel compositions show a plain divider with no order implied
   (design.md: "Sequential vs. parallel compositions are visually
   distinguished"). */
.discovery-composition-connector {
  flex: none;
  color: var(--muted-foreground);
  font-size: 1rem;
}

.discovery-composition-divider {
  flex: none;
  width: 1px;
  align-self: stretch;
  background: var(--border);
}

/* expert-referral spec: "Bring in an expert" entry point + popup. */

.discovery-results__toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.discovery-bring-expert-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.discovery-bring-expert-link:hover {
  text-decoration: underline;
}

.discovery-bring-expert-link__icon {
  flex: none;
}

.expert-referral-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 1rem;
}

.expert-referral-popup {
  width: 100%;
  max-width: 28rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--background);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.expert-referral-popup__title {
  margin: 0 0 0.25rem;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
}

.expert-referral-popup__author {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted-foreground);
}

.expert-referral-domains {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.expert-referral-field {
  margin-bottom: 0.9rem;
}

.expert-referral-field__label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.expert-referral-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: var(--muted);
  color: var(--foreground);
  font-size: 0.72rem;
  font-weight: 600;
}

.expert-referral-chip--domain {
  background: var(--card);
  border: 1px solid var(--border);
}

.expert-referral-chip__remove {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--muted-foreground);
  cursor: pointer;
}

.expert-referral-tag-input {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.4rem;
}

.expert-referral-tag-input__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.expert-referral-tag-input__chips:not(:empty) {
  margin-bottom: 0.35rem;
}

.expert-referral-tag-input__input {
  width: 100%;
  border: none;
  outline: none;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.15rem;
  background: transparent;
  color: inherit;
}

.expert-referral-tag-input__suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 1;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  max-height: 10rem;
  overflow-y: auto;
}

.expert-referral-tag-input__suggestion {
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  border-radius: 0.35rem;
  cursor: pointer;
}

.expert-referral-tag-input__suggestion:hover {
  background: var(--muted);
}

.expert-referral-multiselect {
  position: relative;
}

.expert-referral-multiselect__toggle {
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--background);
  color: inherit;
  cursor: pointer;
}

.expert-referral-multiselect__panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 1;
  padding: 0.5rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  max-height: 12rem;
  overflow-y: auto;
}

.expert-referral-multiselect__option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.2rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.expert-referral-textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.expert-referral-error {
  margin: 0 0 0.75rem;
  color: #b3261e;
  font-size: 0.78rem;
}

.expert-referral-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.expert-referral-cancel,
.expert-referral-submit {
  border: none;
  border-radius: 9999px;
  padding: 0.5rem 1.25rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.expert-referral-cancel {
  background: var(--muted);
  color: var(--foreground);
}

.expert-referral-submit {
  background: var(--primary);
  color: var(--primary-foreground);
}

.expert-referral-submit:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* paginated-discovery-api: per-section scroll sentinel. The element must
   keep a non-zero height while it has more to load so IntersectionObserver
   can see it; the spinner text and the "Load more" retry button are toggled
   inside it. */
.discovery-sentinel {
  min-height: 1px;
  padding: 0.75rem 0;
  text-align: center;
  color: var(--muted-foreground);
}

.discovery-sentinel__retry {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--card-foreground);
  cursor: pointer;
}

.discovery-sentinel__retry:hover,
.discovery-sentinel__retry:focus-visible {
  border-color: var(--primary);
}
