:root {
    --cream:         #FEFAE0;
    --cream-dark:    #f5f0cc;
    --text-body:     #2c2c2c;
    --text-muted:    #6b7060;
    --border:        #dde3cc;
    --shadow-sm:     0 2px 8px rgba(40,54,24,0.08);
    --shadow-md:     0 6px 24px rgba(40,54,24,0.12);
    --cal-color:     #e63946;
    --protein-color: #2196f3;
    --fat-color:     #ff9800;
    --carb-color:    #4a7c4a;
    --fiber-color:   #8bc34a;
}


body {
    background-color: var(--cream);
    color: var(--text-body);
    font-family: 'DM Sans', sans-serif;
    min-height: 100vh;
}

/* hero banner */
.page-hero-banner {
    background: var(--green-dark);
    position: relative;
    overflow: hidden;
    padding: 60px 20px 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 160px;
    margin-top: 0;
}

.page-hero-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('https://images.unsplash.com/photo-1490645935967-10de6ba17061?w=1200&q=80') center/cover no-repeat;
    opacity: 0.12;
}

.hero-inner {
    position: relative;
    z-index: 1;
    max-width: 820px;
    margin: 0 auto;
}

.page-title {
    font-family: 'Lora', serif;
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.03em;
    margin-bottom: 10px;
}

.page-subtitle {
    font-size: 1rem;
    color: rgba(255,255,255,0.78);
    font-weight: 400;
    max-width: 480px;
    line-height: 1.6;
}

/* main layout */
.nutrition-main {
    max-width: 820px;
    margin: 0 auto;
    padding: 16px 24px 80px;
    width: 100%;
    display: block;
}

/* search card */
.search-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 28px;
    animation: fadeUp 0.5s 0.1s ease both;
}

.search-label {
    display: block;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--green-dark);
    margin-bottom: 12px;
}

.search-row {
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 13px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    border: 2px solid var(--border);
    border-radius: 10px;
    outline: none;
    background: var(--cream);
    color: var(--text-body);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
    border-color: var(--green-light);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(96,108,56,0.12);
}

.action-btn {
    background-color: var(--green-dark);
    color: var(--white);
    border: none;
    border-radius: 10px;
    padding: 13px 26px;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s;
    width: auto !important;
}

.action-btn:hover { background-color: var(--green-mid); }
.action-btn:active { transform: scale(0.98); }
.action-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* recent searches */
.recent-wrap {
    margin-top: 14px;
    display: none;
}
.recent-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.recent-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.recent-pill {
    background: var(--green-bg);
    color: var(--green-dark);
    border: 1px solid var(--green-pale);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.recent-pill:hover {
    background: var(--green-dark);
    color: white;
    border-color: var(--green-dark);
}
.recent-pill.clear-btn {
    background: none;
    border-color: #fca5a5;
    color: #b91c1c;
}
.recent-pill.clear-btn:hover {
    background: #fef2f2;
    border-color: #b91c1c;
    color: #b91c1c;
}

/* status */
.status {
    margin-top: 10px;
    font-size: 13px;
    font-family: 'DM Mono', monospace;
    color: var(--text-muted);
    min-height: 18px;
}
.status.error { color: #c0392b; }

/* results header */
.results-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.results-count-pill {
    background: var(--green-bg);
    color: var(--green-dark);
    border: 1px solid var(--green-pale);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 700;
    font-family: 'DM Mono', monospace;
}
.results-hint {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

/* result cards */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-card {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-left: 4px solid var(--green-light);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    animation: fadeUp 0.35s ease both;
    color: inherit;
}

.result-card:hover {
    border-left-color: var(--green-dark);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.result-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-body);
    flex: 1;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.tag {
    background: var(--cream-dark);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 3px 8px;
    border-radius: 4px;
}

.result-arrow {
    color: var(--text-muted);
    font-size: 14px;
    transition: color 0.2s, transform 0.2s;
}

.result-card:hover .result-arrow {
    color: var(--green-dark);
    transform: translateX(3px);
}

/* skeleton loader */
.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.skeleton-card {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.skeleton-line {
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}
.skeleton-line.long { width: 65%; }
.skeleton-line.short { width: 20%; }

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* detail panel */
.detail-panel {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 28px;
    box-shadow: var(--shadow-md);
    animation: fadeUp 0.4s ease both;
}

.detail-panel-header {
    background: var(--green-dark);
    color: var(--white);
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.detail-food-name {
    font-family: 'Lora', serif;
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.3;
}

.detail-food-meta {
    font-size: 12px;
    font-family: 'DM Mono', monospace;
    opacity: 0.65;
    margin-top: 5px;
}

.close-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: var(--white);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.close-btn:hover { background: rgba(255,255,255,0.25); }

.detail-panel-body { padding: 28px; }

.nutrients-label {
    font-size: 12px;
    font-family: 'DM Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* nutrient grid */
.nutrients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.nutrient-card {
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    border-top: 3px solid var(--border);
    transition: transform 0.15s, box-shadow 0.15s;
}
.nutrient-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}


.nutrient-card.cal   { border-top-color: var(--cal-color); }
.nutrient-card.prot  { border-top-color: var(--protein-color); }
.nutrient-card.fat   { border-top-color: var(--fat-color); }
.nutrient-card.carb  { border-top-color: var(--carb-color); }
.nutrient-card.fiber { border-top-color: var(--fiber-color); }

.nutrient-name {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    line-height: 1.4;
}

.nutrient-value {
    font-family: 'DM Mono', monospace;
    font-size: 17px;
    font-weight: 500;
    color: var(--green-dark);
}

.nutrient-unit {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 3px;
}

/* empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.8;
    animation: fadeUp 0.5s ease both;
}
.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* animations */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* spinner */
.spinner {
    display: inline-block;
    width: 11px;
    height: 11px;
    border: 2px solid var(--border);
    border-top-color: var(--green-light);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* responsive */
@media (max-width: 768px) {
    .page-hero-banner { padding: 40px 24px 36px; }
    .page-title { font-size: 2rem; }
    .navbar { padding: 14px 20px; }
}

@media (max-width: 600px) {
    .search-card { padding: 20px; }
    .search-row { flex-direction: column; }
    .action-btn { width: 100%; }
    .nutrients-grid { grid-template-columns: 1fr 1fr; }
    .detail-panel-header { padding: 18px 20px; }
    .detail-panel-body { padding: 20px; }
}
.logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
}
/* hide empty containers */
#resultsSection:empty,
#detailPanel:empty {
    display: none;
}