:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #17201b;
  --muted: #66736b;
  --line: #dce4dd;
  --accent: #1f8a62;
  --accent-dark: #136748;
  --warn: #b9472b;
  --soft: #edf6f1;
  --gold: #f0b84d;
  --shadow: 0 18px 60px rgba(21, 33, 27, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(31, 138, 98, 0.11), transparent 34%),
    linear-gradient(315deg, rgba(240, 184, 77, 0.16), transparent 36%),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 2px;
}

.eyebrow,
.section-label,
.empty-kicker {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(310px, 0.82fr) minmax(420px, 1.18fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(220, 228, 221, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-panel {
  padding: 18px;
}

.upload-form {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.dropzone {
  position: relative;
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 164px;
  padding: 22px;
  border: 1px dashed #9bb9aa;
  border-radius: 8px;
  background: var(--soft);
  cursor: pointer;
  text-align: center;
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 34px;
  line-height: 1;
}

.dropzone-title {
  font-size: 20px;
  font-weight: 800;
}

.dropzone-name {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.preview-wrap {
  position: relative;
  min-height: 320px;
  border-radius: 8px;
  overflow: hidden;
  background: #dfe8e2;
  border: 1px solid var(--line);
}

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

.preview-wrap span {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(23, 32, 27, 0.76);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.preview-wrap.is-empty {
  display: grid;
  place-items: center;
}

.preview-wrap.is-empty img {
  display: none;
}

.preview-wrap.is-empty span {
  position: static;
  background: transparent;
  color: var(--muted);
}

.primary-button,
.secondary-button,
.option-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.primary-button {
  min-height: 52px;
  background: var(--accent);
  color: white;
}

.secondary-button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: #17201b;
  color: white;
}

.primary-button:hover,
.secondary-button:hover,
.option-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
}

.result-panel {
  min-height: 560px;
  padding: 22px;
  display: flex;
}

.empty-state,
.loading-state,
.question-state,
.result-state,
.error-state {
  width: 100%;
}

.empty-state,
.loading-state {
  min-height: 100%;
  display: grid;
  place-content: center;
  gap: 18px;
  text-align: center;
}

.empty-meter {
  width: min(340px, 70vw);
  height: 12px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent) 0 38%, var(--gold) 38% 66%, #d7e1da 66% 100%);
}

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border: 4px solid #d7e1da;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

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

.option-list {
  display: grid;
  gap: 10px;
  margin: 18px 0 14px;
}

.option-button {
  min-height: 48px;
  padding: 12px 14px;
  background: #17201b;
  color: white;
  text-align: left;
}

.question-textarea {
  width: 100%;
  min-height: 104px;
  padding: 12px 14px;
  resize: vertical;
}

.muted {
  color: var(--muted);
}

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

.total-strip {
  display: grid;
  grid-template-columns: 1.35fr repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.token-usage-card {
  margin: -6px 0 16px;
  padding: 10px 12px;
  border: 1px solid #b9d8c8;
  border-radius: 8px;
  background: #edf6f1;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.calorie-box,
.macro {
  min-height: 100px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.calorie-box {
  background: #17201b;
  color: white;
}

.calorie-box span,
.macro span {
  display: block;
  margin-bottom: 8px;
  color: inherit;
  opacity: 0.72;
  font-size: 13px;
  font-weight: 800;
}

.calorie-box strong,
.macro strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.calorie-box small {
  display: block;
  margin-top: 8px;
  opacity: 0.76;
}

.items-list {
  display: grid;
  gap: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: 52px 1.2fr repeat(5, minmax(70px, 0.5fr));
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.item-icon-wrap {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.item-icon-wrap.is-empty {
  visibility: hidden;
}

.food-icon {
  display: block;
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.item-name strong {
  display: block;
  margin-bottom: 4px;
}

.item-name span,
.item-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.item-cell strong {
  display: block;
  margin-top: 4px;
}

.assumptions {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.assumptions ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.feedback-box {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.feedback-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.feedback-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.feedback-head .muted {
  margin-bottom: 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.feedback-status {
  min-height: 18px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.feedback-status.is-error {
  color: var(--warn);
}

.feedback-note {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  line-height: 1.4;
}

.feedback-note:focus {
  outline: 2px solid rgba(31, 138, 98, 0.24);
  border-color: var(--accent);
}

.error-state h2 {
  color: var(--warn);
}

.hidden {
  display: none;
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 720px);
    padding: 18px 0;
  }

  .workspace {
    min-height: auto;
  }

  .topbar {
    align-items: flex-start;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .result-panel {
    min-height: 430px;
  }

  .total-strip,
  .item-row,
  .feedback-actions {
    grid-template-columns: 1fr 1fr;
  }

  .calorie-box {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 32px;
  }

  h2 {
    font-size: 22px;
  }

  .topbar,
  .result-head {
    flex-direction: column;
  }

  .total-strip,
  .feedback-actions {
    grid-template-columns: 1fr;
  }

  .item-row {
    grid-template-columns: 52px 1fr;
  }

  .item-cell {
    min-width: 0;
  }
}
