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

:root {
  --primary: #2d7a4f;
  --primary-light: #e8f5ee;
  --primary-dark: #1e5535;
  --accent: #f0a500;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e0e0e0;
  --bg: #f7f9f7;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

body {
  font-family: 'Noto Sans KR', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  padding: 2rem 1rem 2.5rem;
  text-align: center;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

header p {
  font-size: 0.95rem;
  opacity: 0.85;
}

/* ── Search Box ── */
.search-wrapper {
  max-width: 680px;
  margin: -1.5rem auto 0;
  padding: 0 1rem;
  position: relative;
  z-index: 10;
}

.search-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.search-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab-btn {
  flex: 1;
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.tab-btn:hover:not(.active) {
  border-color: var(--primary);
  color: var(--primary);
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.input-row input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-row input:focus {
  border-color: var(--primary);
}

.input-row input::placeholder {
  color: #aaa;
}

.btn-search {
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-search:hover {
  background: var(--primary-dark);
}

.btn-search:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.search-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  text-align: center;
}

/* ── Main Content ── */
main {
  max-width: 680px;
  margin: 2rem auto;
  padding: 0 1rem 3rem;
}

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

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.loading p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ── Error / Empty ── */
.message-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  display: none;
}

.message-box.error {
  border-left: 4px solid #e74c3c;
}

.message-box.empty {
  border-left: 4px solid var(--accent);
}

.message-box .icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.message-box h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.message-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Result Cards ── */
.result-section {
  display: none;
}

.food-name-header {
  margin-bottom: 1.25rem;
}

.food-name-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.food-name-header .source-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  margin-top: 0.3rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
}

.card-header .card-icon {
  font-size: 1.2rem;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.card-body {
  padding: 1.25rem;
}

/* ── Nutrition Grid ── */
.calorie-highlight {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  margin-bottom: 1rem;
}

.calorie-highlight .cal-value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}

.calorie-highlight .cal-label {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.2rem;
}

.nutrition-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.nutrition-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nutrition-item .nut-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.nut-label-en {
  font-size: 0.72rem;
  color: #aaa;
  font-style: italic;
}

.nutrition-item .nut-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.nutrition-toggle {
  text-align: center;
  margin-top: 0.75rem;
}

.btn-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.nutrition-detail {
  display: none;
  margin-top: 0.75rem;
}

.nutrition-detail.open {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* ── Ingredients ── */
.ingredients-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ingredient-tag {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 20px;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.ingredients-raw {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── Recipe Steps ── */
.recipe-steps {
  list-style: none;
  counter-reset: step;
}

.recipe-steps li {
  counter-increment: step;
  display: flex;
  gap: 0.9rem;
  margin-bottom: 1rem;
  align-items: flex-start;
}

.recipe-steps li::before {
  content: counter(step);
  min-width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.recipe-steps li span {
  font-size: 0.92rem;
  line-height: 1.6;
  padding-top: 0.2rem;
}

.recipe-image {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 1rem;
  object-fit: cover;
  max-height: 200px;
}

.no-data {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-style: italic;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

/* ── Bilingual Recipe Display ── */
.recipe-title-en {
  font-size: 0.78em;
  font-weight: 400;
  color: var(--text-muted);
}

.ingredient-tag-bi {
  display: inline-flex;
  flex-direction: column;
  background: var(--primary-light);
  border-radius: 8px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
  line-height: 1.35;
}

.ingredient-tag-bi .ing-en {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
}

.step-ko {
  display: block;
  font-size: 0.93rem;
  line-height: 1.65;
  color: var(--text);
}

.step-en {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.25rem;
  line-height: 1.5;
  border-top: 1px dashed var(--border);
  padding-top: 0.2rem;
}

.translate-loading {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Cuisine & Category Chips (공용) ── */
.cuisine-chips,
.category-chips {
  display: none;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.cuisine-chips.visible,
.category-chips.visible { display: flex; }

/* 분류 라벨 */
.chip-label {
  width: 100%;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.1rem;
}

/* 선택된 음식 분류 칩은 색상 강조 */
.cuisine-chip.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.cuisine-chip,
.category-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}

.cuisine-chip:hover,
.category-chip:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-light);
}

.category-chip.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  font-weight: 600;
}

/* ── Related Meals Grid ── */
.related-meals-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.meal-thumb-card {
  background: none;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s;
  text-align: center;
  font-family: inherit;
}

.meal-thumb-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.meal-thumb-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.meal-thumb-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.meal-thumb-card span {
  display: block;
  font-size: 0.72rem;
  color: var(--text);
  padding: 0.35rem 0.3rem;
  line-height: 1.3;
}

.meal-thumb-card.loading-thumb {
  background: var(--bg);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ── Recipe Fallback (레시피 없을 때 외부 링크) ── */
.recipe-fallback-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.external-recipe-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.external-recipe-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  transition: all 0.2s;
}

.external-recipe-link:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.raw-badge {
  display: inline-block;
  background: #fff3cd;
  color: #856404;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  header h1 { font-size: 1.4rem; }
  .search-tabs { flex-direction: row; flex-wrap: wrap; }
  .tab-btn { font-size: 0.72rem; padding: 0.4rem 0.25rem; flex: 1 1 calc(50% - 0.25rem); }
  .btn-search { padding: 0.75rem 1rem; font-size: 0.9rem; }
  .nutrition-grid { grid-template-columns: 1fr; }
  .nutrition-detail.open { grid-template-columns: 1fr; }
  .calorie-highlight .cal-value { font-size: 1.8rem; }
}
