:root {
  --bg: #f4f7f5;
  --card-bg: #ffffff;
  --primary: #2fae60;
  --primary-dark: #228c4c;
  --primary-light: #e8f7ee;
  --text: #17231d;
  --muted: #6f7d76;
  --border: #e6ece8;
  --danger: #d64545;

  --calories: #ff7a45;
  --calories-bg: #fff1ea;
  --protein: #3b82f6;
  --protein-bg: #eaf2ff;
  --fat: #f59e0b;
  --fat-bg: #fef6e7;
  --carbs: #8b5cf6;
  --carbs-bg: #f3edfe;

  --font-display: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

.hero {
  background: linear-gradient(160deg, #eafff2 0%, #f4f7f5 60%);
  padding-bottom: 8px;
}

.header {
  text-align: center;
  padding: 40px 16px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.logo-badge {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 4px 14px rgba(47, 174, 96, 0.18);
}

.header h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 4px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 2px 10px rgba(23, 35, 29, 0.05);
  border: 1px solid var(--border);
}

.mode-switch {
  display: flex;
  gap: 6px;
  background: #e9efeb;
  border-radius: 14px;
  padding: 5px;
}

.mode-btn {
  flex: 1;
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-icon {
  font-size: 16px;
}

.mode-btn.active {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(23, 35, 29, 0.08);
}

.upload-label {
  display: block;
  border: 2px dashed #cfe3d7;
  border-radius: 16px;
  cursor: pointer;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 14px;
  background: var(--primary-light);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-label:hover {
  border-color: var(--primary);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  padding: 20px;
}

.upload-icon-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 6px;
  box-shadow: 0 2px 8px rgba(23, 35, 29, 0.08);
}

.upload-title {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
}

.upload-hint {
  font-size: 12.5px;
  color: var(--muted);
}

.preview-img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  display: block;
}

.btn {
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  border: none;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 12px rgba(47, 174, 96, 0.3);
}

.btn-primary:disabled {
  background: #c7d9ce;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-primary:not(:disabled):active {
  transform: scale(0.98);
}

.error-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fdeaea;
  color: var(--danger);
  border-radius: 10px;
  font-size: 14px;
}

.result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.result-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
}

.weight-pill {
  margin: 0;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.calorie-hero {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  background: var(--calories-bg);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 14px;
}

.calorie-value {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 800;
  color: var(--calories);
  line-height: 1;
}

.calorie-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--calories);
  opacity: 0.85;
}

.muted {
  color: var(--muted);
  margin: 0 0 12px;
}

.small {
  font-size: 13px;
}

.confidence-note {
  font-size: 13px;
  color: #b8790f;
  background: var(--fat-bg);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 4px 0 0;
}

.kbju-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.kbju-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-radius: 14px;
  padding: 14px 4px;
}

.kbju-icon {
  font-size: 18px;
  margin-bottom: 2px;
}

.kbju-protein { background: var(--protein-bg); }
.kbju-fat { background: var(--fat-bg); }
.kbju-carbs { background: var(--carbs-bg); }

.kbju-protein .kbju-value { color: var(--protein); }
.kbju-fat .kbju-value { color: var(--fat); }
.kbju-carbs .kbju-value { color: var(--carbs); }

.kbju-value {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
}

.kbju-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.voice-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px 12px;
}

.record-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(47, 174, 96, 0.35);
  transition: transform 0.1s ease;
}

.record-btn:active {
  transform: scale(0.96);
}

.record-icon {
  font-size: 34px;
}

.record-btn.recording {
  background: linear-gradient(135deg, var(--danger), #b83232);
  box-shadow: 0 0 0 0 rgba(214, 69, 69, 0.5);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(214, 69, 69, 0.5); }
  70% { box-shadow: 0 0 0 18px rgba(214, 69, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(214, 69, 69, 0); }
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}

.history-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
}

.totals {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-align: right;
}

.meals-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.meal-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.meal-thumb {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.meal-thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  font-size: 22px;
}

.meal-info {
  flex: 1;
  min-width: 0;
}

.meal-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14.5px;
}

.meal-macros {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.meal-delete {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  flex-shrink: 0;
}

.meal-delete:hover {
  background: var(--bg);
  color: var(--danger);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px 0 4px;
  margin: 0;
  font-size: 14px;
}

.empty-icon {
  font-size: 30px;
}

.footer {
  text-align: center;
  padding: 24px 16px 40px;
  color: var(--muted);
  font-size: 13px;
}

.footer-icon {
  margin-right: 2px;
}

.footer a {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}
