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

* {
  font-family: "Inter", sans-serif;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  --color-base: #f0eee9;
  --color-line: rgba(53, 46, 47, 0.1);
  --color-bg: rgb(233, 231, 226);
  --color-textinput-placeholder: rgba(0, 0, 0, 0.4);
  --color-textinput-border: rgb(230, 230, 225);
  --color-textinput-border-focus: rgba(0, 0, 0, 1);
  --color-blue: #0600ff;
  --color-black25: rgba(0, 0, 0, 0.25);
  --color-black5: rgba(0, 0, 0, 0.05);
  --color-element-secondary: #d9d9d9;
  --borderradius-small: 4px;
  --header-height: 57px;
  --max-width: 1600px;
}

/* Prototype banner */
.proto-banner {
  background: #000;
  color: var(--color-base);
  text-align: center;
  padding: 6px 16px;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-family: "JetBrains Mono", monospace;
}

body {
  background-color: var(--color-base);
  color: #000;
  min-height: 100vh;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--color-line);
  background: var(--color-base);
  position: sticky;
  top: 0;
  z-index: 10;
}

header .title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 22px;
  font-weight: 400;
  white-space: nowrap;
}

header .badge {
  font-size: 10px;
  font-family: "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 8px;
  border: 1px dashed var(--color-black25);
  border-radius: var(--borderradius-small);
  color: var(--color-textinput-placeholder);
  white-space: nowrap;
}

/* Search form */
.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-form input {
  font-size: 14px;
  padding: 10px 16px;
  border: 1px solid var(--color-textinput-border);
  border-radius: var(--borderradius-small);
  background: var(--color-base);
  outline: none;
  width: 320px;
  height: 40px;
  min-width: 0;
  flex: 1;
}

.search-form input::placeholder {
  color: var(--color-textinput-placeholder);
}

.search-form input:focus {
  border-color: var(--color-textinput-border-focus);
}

.search-form button {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 20px;
  height: 40px;
  border: 1px solid #000;
  border-radius: var(--borderradius-small);
  background: transparent;
  cursor: pointer;
}

.search-form button:hover {
  background: #000;
  /* color: var(--color-base); */
}

.search-area button:hover {
  background: #000;
  color: var(--color-base);
}

/* Results grid */
.results-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 32px;
  padding-bottom: 96px!important;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

/* Product card */
.product-card {
  display: flex;
  flex-direction: column;
}

.product-card .image-wrapper {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--color-bg);
  overflow: hidden;
  margin-bottom: 12px;
}

.product-card .image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-card .image-wrapper .placeholder {
  width: 100%;
  height: 100%;
  background: var(--color-bg);
}

.product-card .info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.product-card .info .brand {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-card .info .vendor {
  font-size: 13px;
  color: var(--color-textinput-placeholder);
  line-height: 1.4;
}

.product-card .info .product-title {
  font-size: 13px;
  color: rgba(0, 0, 0, 0.6);
  line-height: 1.4;
}

.product-card .info .score-breakdown {
  font-size: 10px;
  font-family: "JetBrains Mono", monospace;
  color: var(--color-textinput-placeholder);
  margin-top: 6px;
  background: var(--color-black5);
  border-radius: 4px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.score-breakdown .score-final {
  font-size: 11px;
  font-weight: 500;
  color: #000;
  padding-bottom: 4px;
  margin-bottom: 2px;
}

.score-breakdown .score-signals {
  display: flex;
  gap: 6px;
}

.score-breakdown .signal-card {
  flex: 1;
  background: var(--color-base);
  border-radius: 4px;
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.score-breakdown .signal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-breakdown .signal-name {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 9px;
}

.score-breakdown .signal-rank {
  font-size: 9px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.4);
}

.score-breakdown .signal-raw {
  font-size: 13px;
  font-weight: 500;
  color: #000;
  letter-spacing: -0.3px;
}

.score-breakdown .score-bar-track {
  height: 3px;
  background: var(--color-line);
  border-radius: 2px;
  overflow: hidden;
}

.score-breakdown .score-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.score-breakdown .score-bar-fill.vector {
  background: #0600ff;
}

.score-breakdown .score-bar-fill.bm25 {
  background: #000;
}

.score-breakdown .score-calc {
  font-size: 9px;
  color: rgba(0, 0, 0, 0.3);
  padding-top: 3px;
  margin-top: 2px;
  line-height: 1.5;
}

/* Spinner */
.spinner {
  display: flex;
  justify-content: center;
  padding: 80px 0;
  width: 100%;
}

.spinner-ring {
  width: 32px;
  height: 32px;
  border: 2px solid var(--color-line);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--color-textinput-placeholder);
  font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
  header {
    padding: 12px 16px;
  }
  .results-container {
    padding: 16px;
  }
  .results-grid {
    gap: 16px;
  }
  .search-form input {
    width: 180px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  header h1 {
    font-size: 18px;
  }
  .search-form {
    width: 100%;
  }
  .search-form input {
    width: 100%;
    flex: 1;
    font-size: 16px;
  }
  .results-container {
    padding: 12px;
  }
  .results-grid {
    gap: 12px;
  }
  .product-card .info {
    min-width: 0;
  }
  .product-card .info .brand {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
  }
  .product-card .info .vendor,
  .product-card .info .product-title {
    font-size: 11px;
  }
}

/* Search mode toggle */
.search-mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid #000;
  border-radius: var(--borderradius-small);
  overflow: hidden;
  height: 40px;
  flex-shrink: 0;
}
.search-mode-toggle button {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 14px;
  height: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transition:
    background var(--transition-duration),
    color var(--transition-duration);
  font-family: "JetBrains Mono", monospace;
}
.search-mode-toggle button.active {
  background: #000;
  color: var(--color-base);
}
.search-mode-toggle button:not(.active):hover {
  background: var(--color-black5);
}

/* Search area */
.search-area {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  min-width: 0;
  flex: 1;
}
.search-area.active {
  display: flex;
}

/* Upload dropzone */
.upload-dropzone {
  border: 2px dashed var(--color-black25);
  border-radius: var(--borderradius-small);
  padding: 8px 20px;
  font-size: 13px;
  color: var(--color-textinput-placeholder);
  cursor: pointer;
  transition:
    border-color var(--transition-duration),
    background var(--transition-duration);
  position: relative;
  min-width: 0;
  flex: 1;
  text-align: center;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--color-textinput-border-focus);
  background: var(--color-black5);
}
.upload-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Upload preview */
.upload-preview {
  display: none;
  align-items: center;
  gap: 10px;
}
.upload-preview img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--borderradius-small);
  border: 1px solid var(--color-line);
}
.upload-preview .file-name {
  font-size: 13px;
  color: var(--color-textinput-placeholder);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-preview .clear-btn {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 10px;
  height: 40px;
  border: 1px solid var(--color-black25);
  border-radius: var(--borderradius-small);
  background: transparent;
  cursor: pointer;
  color: var(--color-textinput-placeholder);
}
.upload-preview .clear-btn:hover {
  border-color: #000;
  background: #000;
  color: var(--color-base);
}

/* BM25 Modal */
.bm25-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  justify-content: center;
  align-items: center;
}
.bm25-modal-overlay.open {
  display: flex;
}
.bm25-modal {
  background: var(--color-base);
  border-radius: 8px;
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
.bm25-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-line);
}
.bm25-modal-header h2 {
  font-size: 15px;
  font-weight: 500;
}
.bm25-modal-header button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-textinput-placeholder);
  line-height: 1;
}
.bm25-modal-header button:hover {
  color: #000;
}
.bm25-modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  color: rgba(0, 0, 0, 0.7);
  white-space: pre-wrap;
  word-break: break-word;
}
.bm25-modal-body mark {
  background: rgba(6, 0, 255, 0.15);
  color: #0600ff;
  border-radius: 2px;
  padding: 1px 2px;
  font-weight: 500;
}
.bm25-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--color-line);
  font-size: 11px;
  line-height: 1.6;
  color: var(--color-textinput-placeholder);
}
.bm25-modal-footer strong {
  color: rgba(0, 0, 0, 0.6);
}

/* BM25 match button */
.bm25-match-btn {
  font-size: 10px;
  font-family: "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border: 1px solid var(--color-black25);
  border-radius: var(--borderradius-small);
  background: transparent;
  cursor: pointer;
  color: var(--color-textinput-placeholder);
  margin-top: 4px;
  align-self: flex-start;
}
.bm25-match-btn:hover {
  border-color: #0600ff;
  color: #0600ff;
}

/* Facet bar */
.facet-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 0 12px;
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(0, 0, 0, 0.5);
}
.facet-bar-label {
  white-space: nowrap;
}
.facet-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.facet-hint {
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(0, 0, 0, 0.3);
}
.facet-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--color-black25);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.4px;
  color: rgba(0, 0, 0, 0.4);
  text-transform: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.facet-chip .facet-field {
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: inherit;
  opacity: 0.7;
}
.facet-chip .facet-value {
  color: inherit;
}
.facet-chip:hover {
  border-color: #000;
  color: #000;
}
.facet-chip.active {
  background: #000;
  border-color: #000;
  color: var(--color-base);
}
.facet-chip.active .facet-field {
  opacity: 0.6;
}

/* Weight slider bar */
.weight-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 0 16px;
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}
.weight-bar .weight-hint {
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(0, 0, 0, 0.3);
  margin-left: 6px;
}
.weight-bar label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.weight-bar .weight-value {
  color: #000;
  min-width: 28px;
  text-align: right;
}
.weight-bar input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 180px;
  height: 4px;
  background: var(--color-black25);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.weight-bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #000;
  cursor: pointer;
}
@media (max-width: 480px) {
  .weight-bar {
    gap: 6px;
    padding: 0 0 12px;
    font-size: 10px;
    flex-wrap: wrap;
  }
  .weight-bar input[type="range"] {
    flex: 1;
    width: auto;
    min-width: 0;
  }
  .weight-bar .weight-hint {
    width: 100%;
    margin-left: 0;
    font-size: 9px;
  }
}

/* Commit card */
#commit-card {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: 16px;
  left: 16px;
  background: var(--color-base);
  border: 1px solid var(--color-line);
  border-radius: var(--borderradius-small);
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
  color: rgba(0, 0, 0, 0.6);
  max-width: 420px;
  width: calc(100% - 32px);
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
#commit-card.open {
  width: min(420px, calc(100% - 32px));
  max-width: 420px;
}
#commit-card strong {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(0, 0, 0, 0.35);
}

.commit-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 32px 8px 12px;
  position: relative;
}
.commit-summary .commit-msg {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.commit-summary .commit-count {
  color: rgba(0, 0, 0, 0.35);
}

.commit-expand {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--color-line);
  border-radius: var(--borderradius-small);
  cursor: pointer;
  color: rgba(0, 0, 0, 0.4);
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  transition: border-color 0.2s, color 0.2s;
}
.commit-expand::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: rotate(-45deg) translate(-1px, 1px);
}
#commit-card.open .commit-expand::before {
  transform: rotate(135deg) translate(-1px, 1px);
}
.commit-expand:hover {
  border-color: rgba(0, 0, 0, 0.4);
  color: #000;
}

.commit-list {
  display: none;
  max-height: 280px;
  overflow-y: auto;
  border-bottom: 1px solid var(--color-line);
}
#commit-card.open .commit-list {
  display: block;
}
.commit-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 12px;
  color: inherit;
}
.commit-item + .commit-item {
  border-top: 1px solid var(--color-line);
}
.commit-item .msg {
  color: rgba(0, 0, 0, 0.85);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.commit-item .meta {
  color: rgba(0, 0, 0, 0.35);
  font-size: 10px;
}
.commit-loading {
  padding: 10px 12px;
  color: rgba(0, 0, 0, 0.4);
  font-size: 11px;
}
