:root {
  color-scheme: light;
  --ink: #121a1f;
  --muted: #66737b;
  --line: #dfe6e2;
  --paper: #f7f5ef;
  --panel: #ffffff;
  --green: #167251;
  --green-soft: #e7f5ec;
  --gold: #b98521;
  --shadow: 0 18px 45px rgba(18, 26, 31, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

.app {
  width: min(680px, 100%);
  margin: 0 auto;
  padding: 18px 14px 34px;
}

.app-header {
  display: grid;
  gap: 8px;
  padding: 4px 2px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 21px;
}

.brand img {
  width: 38px;
  height: 38px;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.scan-card,
.results {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scan-card {
  padding: 14px;
}

form {
  display: grid;
  gap: 12px;
}

input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-drop {
  min-height: 310px;
  border-radius: 8px;
  border: 1px dashed #9eb9ad;
  background: linear-gradient(180deg, #eff8f2, #ffffff);
  display: grid;
  place-items: center;
  overflow: hidden;
  text-align: center;
  cursor: pointer;
}

.photo-drop:focus-within {
  outline: 3px solid rgba(22, 114, 81, 0.18);
}

.photo-empty {
  display: grid;
  gap: 8px;
  padding: 24px;
}

.photo-empty strong {
  font-size: 26px;
  line-height: 1.05;
}

.photo-empty small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

#photoPreview {
  width: 100%;
  height: 100%;
  max-height: 430px;
  object-fit: cover;
}

.text-fallback {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.text-fallback summary {
  cursor: pointer;
  min-height: 46px;
  padding: 13px 14px;
  color: var(--muted);
  font-weight: 750;
}

.text-fallback textarea {
  width: calc(100% - 24px);
  min-height: 110px;
  margin: 0 12px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  resize: vertical;
  outline: none;
}

.primary-button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
}

.primary-button:disabled {
  opacity: 0.62;
  cursor: progress;
}

.secondary-button,
.app-footer button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.status-message,
.privacy-note,
.estimate-note,
.empty-result {
  min-height: 20px;
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.privacy-note,
.estimate-note {
  min-height: 0;
}

.results {
  margin-top: 16px;
  padding: 16px 14px;
}

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

.estimate-note {
  margin: 0 0 14px;
}

.empty-result {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
}

.eyebrow {
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 900;
}

.results h1,
.ranking-section h2,
.food-card h3 {
  margin: 0;
}

.results h1 {
  font-size: 28px;
  line-height: 1.05;
}

.item-count {
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 750;
}

.ranking-section {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.ranking-section + .ranking-section {
  margin-top: 16px;
}

.ranking-section h2 {
  font-size: 19px;
}

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

.food-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 76px;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.rank-badge {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}

.food-card h3 {
  font-size: 16px;
  line-height: 1.18;
}

.food-card p {
  margin: 5px 0 0;
  color: #465359;
  font-size: 13px;
  line-height: 1.35;
}

.food-meta {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.macro-stack {
  display: grid;
  justify-items: end;
  align-content: start;
  color: var(--muted);
  font-size: 11px;
}

.macro-stack strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.1;
}

@media (min-width: 720px) {
  .app {
    padding-top: 28px;
  }

  .scan-card,
  .results {
    border-radius: 8px;
    padding: 20px;
  }

  .photo-drop {
    min-height: 360px;
  }
}

.brand-link,
.text-link,
.privacy-note a,
.footer-links a,
.footer-links button,
.creator-credit a {
  color: inherit;
  text-decoration: none;
}

.brand-link:focus-visible,
.text-link:focus-visible,
.privacy-note a:focus-visible,
.footer-links a:focus-visible,
.footer-links button:focus-visible,
.creator-credit a:focus-visible,
.privacy-footer summary:focus-visible,
.secondary-button:focus-visible,
.primary-button:focus-visible,
.photo-drop:focus-within {
  outline: 3px solid rgba(22, 114, 81, 0.22);
  outline-offset: 2px;
}

.privacy-note a,
.footer-links a,
.footer-links button,
.text-link {
  color: var(--green);
  font-weight: 800;
}

.privacy-footer {
  max-width: 680px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.footer-topline {
  display: flex;
  flex-wrap: nowrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-links button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}

.creator-credit {
  color: #52615a;
  font-weight: 800;
  text-align: right;
}

.footer-links a,
.footer-links button,
.creator-credit a {
  color: #52615a;
  font-weight: 800;
}

.footer-links a:hover,
.footer-links button:hover,
.creator-credit a:hover,
.privacy-footer summary:hover {
  color: var(--green);
}

.privacy-footer details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.privacy-footer summary {
  width: fit-content;
  cursor: pointer;
  color: #52615a;
  font-weight: 800;
}

.privacy-copy {
  display: grid;
  gap: 8px;
  max-width: 640px;
  margin-top: 8px;
}

.privacy-copy p {
  margin: 0;
  color: #465359;
}

.plain-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.plain-panel h1 {
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.05;
}

.plain-panel p {
  margin: 0 0 12px;
  color: #465359;
  line-height: 1.5;
}
