.detected-items {
  margin-top: 1.5rem;
}

.detected-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.detected-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.detected-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.detected-label em {
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
}

.item-remove-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
  cursor: pointer;
  font-size: 0.9rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: all 0.18s ease;
}

.item-remove-btn:hover {
  background: rgba(255, 95, 95, 0.12);
  border-color: var(--danger);
}

.detected-item select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
}

.detected-item select:focus {
  outline: none;
  border-color: var(--accent);
}

.detected-item input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 100px;
  background: var(--surface);
  outline: none;
  cursor: pointer;
}

.detected-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 124, 74, 0.4);
}

.detected-item input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 124, 74, 0.4);
}

.item-macros {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.totals-bar {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 14px;
  margin-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 8px 24px rgba(255, 77, 143, 0.25);
}

.totals-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
}

.totals-macros {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

.totals-macros .macro {
  background: rgba(255, 255, 255, 0.18);
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
  backdrop-filter: blur(6px);
}

.totals-macros strong {
  font-weight: 800;
}

.review-actions {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.review-actions .outline-btn {
  margin-top: 0;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
}
.review-actions .save-btn {
  margin-top: 0;
  flex: 1 1 240px;
  max-width: 320px;
  min-width: 220px;
}
@media (max-width: 480px) {
  .review-actions { justify-content: stretch; }
  .review-actions .outline-btn { flex: 1; }
  .review-actions .save-btn { max-width: none; }
}

.review-photo-row {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: stretch;
  flex-wrap: wrap;
}

.review-photo-row > img {
  width: 200px;
  height: 200px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid var(--border);
}

@media (max-width: 600px) {
  .review-photo-row > img { width: 100%; height: 240px; }
}

.spinner {
  width: 64px;
  height: 64px;
  border: 6px solid var(--surface2);
  border-top-color: var(--accent);
  border-right-color: var(--accent2);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

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

.analyzing-content {
  text-align: center;
  padding: 3rem 1rem;
}

.analyzing-elapsed {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#is-public-input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.add-food-section {
  margin: 1rem 0 0.5rem;
}

.add-food-btn {
  width: 100%;
  background: transparent;
  color: var(--accent);
  border: 1.5px dashed rgba(255, 124, 74, 0.4);
  border-radius: 14px;
  padding: 0.85rem 1.25rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.add-food-btn:hover {
  background: rgba(255, 124, 74, 0.08);
  border-color: var(--accent);
  border-style: solid;
}

.add-food-btn span {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  background: rgba(255, 124, 74, 0.15);
  margin-right: 0.4rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.add-food-panel {
  margin-top: 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.25rem;
}

.add-food-panel input[type="text"] {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
}

.add-food-panel input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.add-food-results {
  margin-top: 0.85rem;
  max-height: 320px;
  overflow-y: auto;
}

.search-result-item {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
  border: 1px solid transparent;
}

.search-result-item:hover {
  background: rgba(255, 124, 74, 0.1);
  border-color: rgba(255, 124, 74, 0.25);
}

.search-result-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.search-result-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.search-loading,
.search-empty {
  padding: 0.85rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* "Can't find it?" link in the search panel */
.custom-food-link {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.custom-food-link:hover {
  color: var(--accent);
  border-color: rgba(255, 124, 74, 0.4);
  background: rgba(255, 124, 74, 0.04);
}

/* ── Custom food modal ── */
.custom-food-modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.custom-food-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.custom-food-content {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.75rem 1.85rem 1.5rem;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.custom-food-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.custom-food-close:hover {
  background: rgba(255, 95, 95, 0.12);
  color: var(--danger);
  border-color: var(--danger);
}
.custom-food-title {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
}
.custom-food-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}
.custom-food-sub strong { color: var(--text); }
.custom-section-title {
  margin-top: 1.1rem;
  margin-bottom: 0.6rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
}
.custom-required { color: var(--accent2); }
.custom-unit {
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.custom-macros-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
.custom-micros-toggle {
  margin-top: 1.1rem;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.025);
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.custom-micros-toggle:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,124,74,0.35);
}
.custom-micros-grid {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}
.custom-micros-grid .field label {
  font-size: 0.65rem;
}
.custom-actions {
  display: flex;
  gap: 0.85rem;
  margin-top: 1.5rem;
  align-items: center;
}
.custom-actions .outline-btn {
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
}
.custom-actions .save-btn {
  flex: 1 1 240px;
  min-width: 200px;
}
@media (max-width: 540px) {
  .custom-macros-grid { grid-template-columns: repeat(2, 1fr); }
  .custom-micros-grid { grid-template-columns: repeat(2, 1fr); }
  .custom-actions { flex-direction: column-reverse; align-items: stretch; }
}
