/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #fafafa;
  color: #111;
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 900px;
  margin: 0 auto;
}

/* Header */
.header {
  background: #fff;
  border-bottom: 2px solid #111;
  padding: 30px 20px;
  text-align: center;
}

.header h1 {
  font-size: 36px;
  margin-bottom: 8px;
  font-weight: 900;
}

.header p {
  font-size: 15px;
  opacity: 0.7;
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 25px;
  gap: 20px;
}

/* Search Section */
.search-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.search-panel {
  background: #fff;
  border: 2px solid #ddd;
  border-radius: 12px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.search-panel h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #111;
}

/* Name Search */
.name-search-container {
  position: relative;
}

.name-search-input {
  width: 100%;
  padding: 15px 18px;
  border: 2px solid #111;
  background: #fff;
  color: #111;
  border-radius: 10px;
  font-size: 16px;
  transition: all 0.3s ease;
}

.name-search-input::placeholder {
  color: rgba(0, 0, 0, 0.4);
}

.name-search-input:focus {
  outline: none;
  background: #f5f5f5;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12);
}

.name-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 420px;
  overflow-y: auto;
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 10px;
  z-index: 20;
  display: none;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.name-search-results.visible {
  display: block;
}

.name-search-results::-webkit-scrollbar {
  width: 8px;
}

.name-search-results::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 4px;
}

.name-search-group {
  border-bottom: 1px solid #eee;
}

.name-search-group:last-child {
  border-bottom: none;
}

.name-search-group-title {
  position: sticky;
  top: 0;
  padding: 10px 16px;
  background: #f0f0f0;
  font-weight: 700;
  font-size: 13px;
  color: #111;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.name-search-group-count {
  font-weight: 400;
  opacity: 0.6;
  font-size: 11px;
}

.name-search-item {
  padding: 10px 16px 10px 26px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s ease;
}

.name-search-item:last-child {
  border-bottom: none;
}

.name-search-item:hover {
  background: #f0f0f0;
}

.name-search-item-name {
  font-weight: 700;
  font-size: 14px;
  color: #111;
}

.name-search-item-meta {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 2px;
}

.name-search-more {
  padding: 8px 16px 8px 26px;
  font-size: 12px;
  opacity: 0.5;
  font-style: italic;
}

.name-search-empty {
  padding: 14px 16px;
  opacity: 0.5;
  font-size: 13px;
  font-style: italic;
}

.or-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: rgba(0, 0, 0, 0.4);
  font-size: 12px;
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #ddd;
}

.or-divider span {
  padding: 0 12px;
  white-space: nowrap;
}

/* Condition Toggle */
.condition-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.condition-toggle-label {
  font-size: 16px;
  font-weight: 700;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider-ui {
  position: absolute;
  inset: 0;
  background: #e5e5e5;
  border: 2px solid #ccc;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.toggle-slider-ui::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider-ui {
  background: #111;
  border-color: #111;
}

.toggle-switch input:checked + .toggle-slider-ui::before {
  background: #fff;
  border-color: #111;
  transform: translateX(22px);
}

/* Condition Panel (disabled state) */
.condition-panel {
  display: flex;
  flex-direction: column;
  gap: 28px;
  transition: opacity 0.3s ease;
}

.condition-panel.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.search-panel h2 small {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.5;
  margin-left: 6px;
}

/* Dual Range Slider */
.range-slider-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.range-slider {
  position: relative;
  height: 24px;
}

.range-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 5px;
  background: #e0e0e0;
}

.range-progress {
  position: absolute;
  top: 50%;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 5px;
  background: #111;
}

.range-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.range-input::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  background: transparent;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #111;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #111;
  pointer-events: all;
  position: relative;
  z-index: 2;
}

.range-input::-moz-range-track {
  background: transparent;
  border: none;
}

.range-input::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #111;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #111;
  pointer-events: all;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.6);
}

#bust-value,
#height-value {
  color: #111;
  font-weight: 700;
  font-size: 14px;
}

/* Cup Buttons */
.cup-buttons {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.cup-btn {
  padding: 12px 8px;
  background: #f5f5f5;
  color: #111;
  border: 2px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.cup-btn:hover {
  background: #ececec;
  border-color: #999;
}

.cup-btn.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

/* Search Button */
.search-btn {
  padding: 18px 24px;
  background: #111;
  color: #fff;
  border: 2px solid #111;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
}

.search-btn:hover {
  background: #fff;
  color: #111;
}

.search-btn:active {
  transform: scale(0.98);
}

.result-count {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.5);
  min-height: 20px;
}

/* Results Section */
.results-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.results-section::-webkit-scrollbar {
  width: 8px;
}

.results-section::-webkit-scrollbar-track {
  background: #eee;
}

.results-section::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 4px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.results-header h2 {
  font-size: 24px;
  font-weight: 900;
}

.back-btn {
  padding: 12px 20px;
  background: #f5f5f5;
  color: #111;
  border: 2px solid #ccc;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.back-btn:hover {
  background: #111;
  color: #fff;
  border-color: #111;
}

/* Search Summary */
.search-summary {
  background: #fff;
  border: 2px solid #111;
  border-radius: 10px;
  padding: 18px 20px;
}

.search-summary-title {
  font-size: 12px;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.search-summary-char-name {
  font-size: 20px;
  font-weight: 900;
  color: #111;
  margin-bottom: 4px;
}

.search-summary-char-title {
  font-size: 13px;
  opacity: 0.7;
  margin-bottom: 12px;
}

.search-summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  font-size: 14px;
}

.search-summary-stats span {
  font-weight: 700;
  color: #111;
}

.search-summary-stats .stat-label {
  opacity: 0.6;
  font-weight: 400;
  margin-right: 4px;
}

/* Type Tabs */
.results-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  background: #f5f5f5;
  color: #111;
  border: 2px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: #ececec;
  border-color: #999;
}

.tab-btn.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.tab-btn-count {
  margin-left: 6px;
  font-weight: 400;
  opacity: 0.7;
  font-size: 12px;
}

.results-tab-panel[hidden] {
  display: none;
}

/* Results */
.results {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.result-group {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #ddd;
}

.result-label {
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.result-label.almost {
  background: #111;
  color: #fff;
}

.result-label.close {
  background: #777;
  color: #fff;
}

.result-label.somewhat {
  background: #e0e0e0;
  color: #111;
}

.result-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.result-item {
  padding: 14px;
  background: #f7f7f7;
  border-radius: 6px;
  border-left: 4px solid #111;
  font-size: 13px;
  line-height: 1.7;
}

.result-item-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 5px;
  color: #111;
}

.result-item-stats {
  font-size: 13px;
  opacity: 0.75;
}

.result-distance {
  font-size: 12px;
  color: #111;
  font-weight: 700;
  margin-top: 4px;
}

.result-empty {
  padding: 20px;
  text-align: center;
  opacity: 0.5;
  font-style: italic;
}

.product-list {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #ddd;
  overflow-x: auto;
}

.product-card {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: 96px;
  color: inherit;
  text-decoration: none;
}

.product-card-thumb {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 4px;
  background: #eee;
}

.product-card-title {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.3;
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
  .main {
    padding: 18px;
  }

  .search-panel {
    padding: 20px;
  }

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

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 20px 15px;
  }

  .header h1 {
    font-size: 26px;
  }

  .main {
    padding: 15px;
    gap: 15px;
  }

  .search-panel {
    padding: 18px;
    gap: 22px;
  }

  .cup-buttons {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .cup-btn {
    padding: 10px 6px;
    font-size: 12px;
  }

  .search-btn {
    padding: 16px 20px;
    font-size: 15px;
  }

  .results-header h2 {
    font-size: 20px;
  }
}
