:root {
  --green: #16a34a;
  --red: #dc2626;
  --blue: #2563eb;
  --gray: #6b7280;
  --light: #f9fafb;
  --border: #e5e7eb;
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--light);
  color: #111;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 12px 40px;
}

h1 { font-size: 1.25rem; font-weight: 700; margin-bottom: 12px; }

#search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

#query-input {
  flex: 1;
  padding: 12px;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}
#query-input:focus { border-color: var(--blue); }

#submit-btn {
  padding: 12px 18px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
#submit-btn:disabled { opacity: 0.5; cursor: default; }

#loading {
  display: none;
  text-align: center;
  padding: 20px;
  color: var(--gray);
  font-size: 0.95rem;
}

.card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title { font-size: 0.75rem; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }

.stat-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.stat-box { flex: 1; min-width: 80px; background: var(--light); border-radius: 8px; padding: 10px; text-align: center; }
.stat-box .label { font-size: 0.7rem; color: var(--gray); }
.stat-box .value { font-size: 1.3rem; font-weight: 700; }

.threshold-row { display: flex; gap: 8px; margin-bottom: 10px; }
.threshold-box { flex: 1; border-radius: 8px; padding: 10px; text-align: center; }
.threshold-box.buy { background: #dcfce7; }
.threshold-box.snag { background: #fef9c3; }
.threshold-box .label { font-size: 0.7rem; color: var(--gray); }
.threshold-box .value { font-size: 1.1rem; font-weight: 700; }

.confidence-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 6px;
}
.confidence-high { background: #dcfce7; color: var(--green); }
.confidence-thin { background: #fef9c3; color: #92400e; }
.confidence-insufficient { background: #fee2e2; color: var(--red); }

.cluster-warning {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.sample-list { list-style: none; }
.sample-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.sample-item:last-child { border-bottom: none; }
.sample-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--light);
}
.sample-thumb-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--border);
}
.sample-info { flex: 1; min-width: 0; }
.sample-title { font-size: 0.85rem; line-height: 1.3; margin-bottom: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sample-meta { font-size: 0.75rem; color: var(--gray); }
.sample-price { font-size: 1rem; font-weight: 700; flex-shrink: 0; }

.section-title { font-size: 0.85rem; font-weight: 600; color: var(--gray); margin: 16px 0 8px; }

.recent-list, .pinned-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.recent-item, .pinned-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}
.recent-item:hover, .pinned-item:hover { border-color: var(--blue); }
.pin-btn, .unpin-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
  color: var(--gray);
}
.unpin-btn { color: var(--red); }

#error-msg {
  background: #fee2e2;
  color: var(--red);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  display: none;
  font-size: 0.9rem;
}
