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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f4f0;
  color: #333;
  min-height: 100vh;
}

.app {
  max-width: 700px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ===== Header ===== */
.header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.header h1 {
  font-size: 1.8rem;
  color: #2e7d32;
}

.subtitle {
  color: #666;
  margin-top: 0.3rem;
  font-size: 0.95rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #4caf50;
  color: #fff;
}

.btn-primary:hover {
  background: #388e3c;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #bdbdbd;
}

.btn-danger {
  background: #ef5350;
  color: #fff;
}

.btn-danger:hover {
  background: #c62828;
}

.btn-capture {
  background: #fff;
  color: #e53935;
  border: 3px solid #e53935;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 1.4rem;
  padding: 0;
}

.btn-capture:hover {
  background: #ffebee;
}

/* ===== Controls ===== */
.controls {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

/* ===== Camera ===== */
.camera-view {
  margin-bottom: 1.5rem;
}

.camera-view video {
  width: 100%;
  border-radius: 12px;
  background: #000;
}

.camera-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 0.8rem;
}

/* ===== Preview ===== */
.preview-section {
  margin-bottom: 1.5rem;
}

.preview-container {
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #e0e0e0;
  background: #fff;
}

.preview-container img {
  width: 100%;
  display: block;
}

.preview-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  margin-top: 1rem;
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 3rem 1rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e0e0;
  border-top-color: #4caf50;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.loading p {
  color: #666;
  font-size: 1rem;
}

/* ===== Results ===== */
.results-section h2 {
  text-align: center;
  color: #2e7d32;
  margin-bottom: 1rem;
}

.result-image-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #e0e0e0;
  background: #000;
  margin-bottom: 1.5rem;
}

.result-image-container img {
  width: 100%;
  display: block;
}

/* ===== Food Markers on Image ===== */
.food-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 10;
}

.food-marker-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.9);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #fff;
  font-weight: 700;
  transition: transform 0.2s;
}

.food-marker:hover .food-marker-dot {
  transform: scale(1.2);
}

.food-marker-label {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  margin-top: 4px;
  pointer-events: none;
}

/* Kiwi marker */
.food-marker.kiwi .food-marker-dot {
  background: rgba(255, 193, 7, 0.95);
  border-color: #ff9800;
  animation: kiwiPulse 1.5s ease-in-out infinite;
  width: 34px;
  height: 34px;
}

.food-marker.kiwi .food-marker-label {
  background: rgba(255, 152, 0, 0.95);
  font-weight: 700;
}

@keyframes kiwiPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(255, 193, 7, 0); }
}

/* ===== Food List Cards ===== */
.food-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.food-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-left: 4px solid #4caf50;
  transition: box-shadow 0.2s;
}

.food-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.food-card.kiwi-card {
  border-left-color: #ff9800;
  background: linear-gradient(135deg, #fff8e1 0%, #fff 40%);
}

.food-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.food-card-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #4caf50;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.kiwi-card .food-card-number {
  background: #ff9800;
}

.food-card-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #333;
}

.per-100g-label {
  font-size: 0.78rem;
  color: #888;
  margin-bottom: 0.5rem;
  padding-left: 0.1rem;
}

.kiwi-badge {
  background: #ff9800;
  color: #fff;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
  margin-left: auto;
  white-space: nowrap;
}

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

.nutrient-item {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}

.nutrient-item .label {
  font-size: 0.75rem;
  color: #888;
}

.nutrient-item .value {
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
}

.nutrient-vitamins {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid #eee;
}

.nutrient-vitamins h4 {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.3rem;
}

.vitamin-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.vitamin-tag {
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.mineral-tag {
  background: #e3f2fd;
  color: #1565c0;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

/* ===== Error ===== */
.error-msg {
  text-align: center;
  background: #ffebee;
  border: 1px solid #ef5350;
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1rem;
}

.error-msg p {
  color: #c62828;
  margin-bottom: 0.8rem;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .header h1 {
    font-size: 1.4rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .nutrient-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
