:root {
  --olive: #879e2a;
  --olive-ink: #65761f;
  --olive-dark: #56651a;
  --wash: #f4f6ec;
  --tint: #e4edba;
  --ink: #222222;
  --muted: #5f6655;
  --line: #e3e7d6;
  --field: #cdd4bb;
  --error: #a12a1a;
  --code-bg: #262d12;
  --code-ink: #eef2dd;
  --code-keyword: #c5dc6a;
  --code-string: #f0d9a0;
  --radius: 10px;
  --topbar-height: 3.5rem;
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font: 400 14px/1.5 var(--font);
  color: var(--ink);
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--olive-ink);
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 2px;
}

mark {
  padding: 0 0.1em;
  color: inherit;
  background: var(--tint);
  border-radius: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header: brand, search types and project links in one bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 0 clamp(1rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  justify-self: start;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  border-radius: 7px;
}

.brand strong {
  font-weight: 600;
  color: var(--olive-ink);
}

.modes {
  display: flex;
  gap: 2px;
  max-width: 100%;
  padding: 3px;
  overflow-x: auto;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 9px;
  scrollbar-width: none;
}

.modes button {
  flex: none;
  padding: 0.3125rem 0.75rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.modes button:hover {
  color: var(--ink);
}

.modes button[aria-selected="true"] {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(34, 34, 34, 0.08);
}

.modes button:focus-visible {
  outline-offset: -2px;
}

.topbar-links {
  display: flex;
  gap: 1.25rem;
  justify-self: end;
  font-size: 13px;
}

.topbar-links a {
  color: var(--muted);
  text-decoration: none;
}

.topbar-links a:hover {
  color: var(--ink);
}

/* Query composer */

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2rem) 3rem;
}

.composer {
  padding: 1.5rem 0 1.25rem;
}

.intro {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.75rem;
  align-items: baseline;
  margin-bottom: 0.875rem;
}

.intro h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.intro p {
  margin: 0;
  color: var(--muted);
}

.search {
  display: flex;
  gap: 0.5rem;
  max-width: 52rem;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 2.75rem;
  padding: 0 1rem;
  font-size: 15px;
  background: #ffffff;
  border: 1px solid var(--field);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(34, 34, 34, 0.04);
}

.search input:focus {
  border-color: var(--olive);
  outline: 2px solid var(--olive);
  outline-offset: -1px;
}

.button {
  flex: none;
  height: 2.75rem;
  padding: 0 1.25rem;
  font-weight: 500;
  color: #ffffff;
  background: var(--olive-ink);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.button:hover {
  background: var(--olive-dark);
}

.photo-pick {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  color: var(--olive-ink);
  background: #ffffff;
  border: 1px solid var(--field);
  border-radius: 8px;
  cursor: pointer;
}

body[data-mode="image"] .photo-pick {
  display: inline-flex;
}

.photo-pick:hover {
  background: var(--wash);
}

.photo-pick:has(input:focus-visible) {
  outline: 2px solid var(--olive);
  outline-offset: 2px;
}

.photo-preview {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  margin: 0.625rem 0 0;
  font-size: 13px;
  color: var(--muted);
}

.photo-preview img {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

body.is-dragging .composer {
  outline: 2px dashed var(--olive);
  outline-offset: 0.5rem;
  border-radius: var(--radius);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 13px;
}

body[data-mode="chat"] .toggle,
body[data-mode="chat"] .categories {
  display: none;
}

.toggle {
  display: inline-flex;
  gap: 0.375rem;
  align-items: center;
  cursor: pointer;
}

.toggle input {
  width: 0.875rem;
  height: 0.875rem;
  margin: 0;
  accent-color: var(--olive-ink);
}

.toggle:has(input:disabled) {
  color: #9aa08f;
  cursor: not-allowed;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.categories label {
  position: relative;
}

.categories input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.categories span {
  display: inline-flex;
  gap: 0.3125rem;
  padding: 0.1875rem 0.625rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.categories label:hover span {
  color: var(--ink);
}

.categories input:checked + span {
  color: var(--ink);
  background: var(--tint);
  border-color: var(--olive);
}

.categories input:focus-visible + span {
  outline: 2px solid var(--olive);
  outline-offset: 2px;
}

.categories em {
  font-style: normal;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.375rem;
  align-items: center;
  color: var(--muted);
}

.examples button {
  padding: 0.1875rem 0.5rem;
  color: var(--ink);
  background: #ffffff;
  border: 1px dashed var(--field);
  border-radius: 6px;
  cursor: pointer;
}

.examples button:hover {
  border-color: var(--olive);
  border-style: solid;
}

/* Results and inspector */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  gap: 1.75rem;
  align-items: start;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.results {
  position: relative;
  min-height: 20rem;
}

.results #output {
  transition: opacity 0.2s;
}

.results[aria-busy="true"] #output {
  opacity: 0.4;
}

.results[aria-busy="true"]::before {
  content: "";
  position: absolute;
  top: -1.25rem;
  left: 0;
  width: 30%;
  height: 2px;
  background: var(--olive);
  animation: progress 1.2s ease-in-out infinite;
}

@keyframes progress {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  min-height: 1.25rem;
  margin-bottom: 0.75rem;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.corrected {
  color: var(--ink);
}

.corrected strong {
  font-weight: 600;
}

.error {
  color: var(--error);
}

.empty {
  margin: 0;
  padding: 1.5rem 0;
  color: var(--muted);
}

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

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

.card:hover {
  border-color: #c3cf9a;
}

.card:has(.card-open:focus-visible) {
  outline: 2px solid var(--olive);
  outline-offset: 2px;
}

/* A scroll container's minimum height is 0, so tall photos can't stretch the square. */
.card-media {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.rank {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  z-index: 1;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3125rem;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.125rem;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.5rem 0.625rem 0.625rem;
}

.card-category {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-transform: capitalize;
}

.card-title,
.card-features {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
}

.card-open {
  padding: 0;
  font-weight: inherit;
  line-height: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

.card-open::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card-open:focus-visible {
  outline: none;
}

.card-features {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.signal {
  margin: auto 0 0;
  padding-top: 0.375rem;
  font-size: 11px;
  font-weight: 500;
  color: var(--olive-ink);
  font-variant-numeric: tabular-nums;
}

.compare {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.compare-col {
  padding: 0.5rem 0.5rem 0.375rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.compare-col header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.125rem 0.375rem 0.375rem;
}

.compare-col h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.compare-col header span,
.compare-note {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.compare-note {
  margin: 0 0.375rem 0.375rem;
}

.compare-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.compare-item {
  position: relative;
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
  padding: 0.375rem;
  border-radius: 7px;
}

.compare-item.is-hover {
  background: var(--wash);
}

.compare-item:has(.card-open:focus-visible) {
  outline: 2px solid var(--olive);
}

.compare-item img {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.125rem;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.compare-item .card-open {
  font-size: 13px;
  line-height: 1.3;
}

.shared {
  display: block;
  margin-top: 0.0625rem;
  font-size: 11px;
  font-weight: 500;
  color: var(--olive-ink);
}

.turn {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.turn-question {
  margin: 0 0 0.5rem;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.answer {
  max-width: 44rem;
  line-height: 1.65;
}

.answer p {
  margin: 0 0 0.625rem;
}

.ref {
  display: inline-block;
  min-width: 1.125rem;
  height: 1.125rem;
  margin: 0 0.125rem;
  padding: 0 0.25rem;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1rem;
  color: var(--olive-ink);
  vertical-align: 0.15em;
  background: var(--wash);
  border: 1px solid #c3cf9a;
  border-radius: 999px;
  cursor: pointer;
}

.ref:hover {
  background: var(--tint);
}

.turn-search {
  margin: 0 0 0.75rem;
  font-size: 12px;
  color: var(--muted);
}

.turn-search strong {
  font-weight: 500;
  color: var(--ink);
}

.grid--sources {
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
}

.link-button {
  padding: 0;
  font-size: 13px;
  color: var(--olive-ink);
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}

.inspector {
  position: sticky;
  top: calc(var(--topbar-height) + 1rem);
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.inspector h2 {
  margin: 0.625rem 0 0;
  font-size: 12px;
  font-weight: 600;
}

.inspector-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.copy {
  padding: 0.0625rem 0.4375rem;
  font-size: 11px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}

.copy:hover {
  color: var(--ink);
}

.code {
  max-height: 20rem;
  margin: 0;
  padding: 0.75rem 0.875rem;
  overflow: auto;
  font: 12px/1.6 var(--mono);
  color: var(--code-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--code-bg);
  border-radius: 8px;
}

.code--light {
  color: var(--ink);
  background: var(--wash);
  border: 1px solid var(--line);
}

.sql-kw {
  color: var(--code-keyword);
}

.sql-str {
  color: var(--code-string);
}

.code--light .sql-kw {
  color: var(--olive-ink);
}

.code--light .sql-str {
  color: #7a5b12;
}

.explain {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.footer {
  padding: 1.25rem clamp(1rem, 3vw, 2rem);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line);
}

/* Product dialog */

.product {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  color: var(--ink);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(34, 34, 34, 0.25);
}

.product::backdrop {
  background: rgba(38, 45, 18, 0.45);
}

.product-close {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  z-index: 1;
  width: 2rem;
  height: 2rem;
  font-size: 1.125rem;
  line-height: 1;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.product-main {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.25rem;
}

.product-main img {
  width: 100%;
  aspect-ratio: 1;
  padding: 0.5rem;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.product-category {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: capitalize;
}

.product-main h2 {
  margin: 0.125rem 2.5rem 0.5rem 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.product-description {
  margin: 0 0 0.875rem;
  line-height: 1.6;
}

.features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.features li {
  padding: 0.125rem 0.4375rem;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--wash);
  border-radius: 5px;
}

.similar {
  padding: 1rem 1.25rem 1.25rem;
  background: #fafbf6;
  border-top: 1px solid var(--line);
}

.similar h3 {
  margin: 0 0 0.625rem;
  font-size: 14px;
  font-weight: 600;
}

.similar .grid {
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  margin-bottom: 0.75rem;
}

.muted {
  color: var(--muted);
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .inspector {
    position: static;
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr auto;
    gap: 0.5rem 1rem;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }

  .modes {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
  }

  .compare {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .composer {
    padding-top: 1rem;
  }

  .intro h1 {
    font-size: 16px;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .product-main {
    grid-template-columns: minmax(0, 1fr);
    padding: 1rem;
  }

  .product-main img {
    max-height: 14rem;
  }

  .similar {
    padding: 0.875rem 1rem 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  ::before {
    transition: none !important;
  }

  .results[aria-busy="true"]::before {
    width: 100%;
    animation: none;
  }
}
