:root { color-scheme: light dark; --green: #16a34a; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0; min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: Canvas; color: CanvasText;
  padding: max(16px, env(safe-area-inset-top)) 16px 24px;
}

header { display: flex; align-items: center; margin-bottom: 24px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: inherit; text-decoration: none; border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}
.brand:active { opacity: .6; }
.logo { width: 40px; height: 40px; border-radius: 10px; }
h1 { font-size: 1.4rem; margin: 0; }

main { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
section { display: flex; flex-direction: column; gap: 16px; }

button {
  font: inherit; font-weight: 600; padding: 14px 18px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, CanvasText 20%, transparent);
  background: transparent; color: inherit;
}
button.primary { background: var(--green); color: #fff; border: none; font-size: 1.1rem; padding: 18px; }

.manual label { display: block; font-size: .9rem; opacity: .7; margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
.row input {
  flex: 1; font: inherit; font-size: 1.1rem; padding: 12px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, CanvasText 25%, transparent);
  background: transparent; color: inherit; min-width: 0;
}

.viewfinder { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame {
  position: absolute; left: 10%; right: 10%; top: 35%; bottom: 35%;
  border: 3px solid var(--green); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35);
}

.note { margin: 0; opacity: .75; text-align: center; }
.code { margin: 0; font-size: 2rem; font-weight: 700; text-align: center; letter-spacing: .05em; }
.error { color: #dc2626; text-align: center; margin: 0; }

.small { font-size: .85rem; }

.product { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.product img { max-width: 160px; max-height: 160px; border-radius: 12px; object-fit: contain; background: #fff; }
.product h2 { font-size: 1.3rem; margin: 6px 0 0; }
.product p { margin: 0; }
.kcal { font-size: 1.6rem; font-weight: 700; margin-top: 6px !important; }

.ingr { align-self: stretch; text-align: left; margin-top: 10px; padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, CanvasText 6%, transparent); }
.ingr h3 { font-size: 1rem; margin: 0 0 6px; }
.ingr p { font-size: .95rem; line-height: 1.45; }

.per { font-weight: 400; opacity: .7; font-size: .9rem; }
.nutr { width: 100%; border-collapse: collapse; font-size: .95rem; }
.nutr td { padding: 6px 0; border-top: 1px solid color-mix(in srgb, CanvasText 12%, transparent); }
.nutr tr:first-child td { border-top: none; }
.nutr td:last-child { text-align: right; font-weight: 600; }

.message { text-align: center; }
.message p { margin: 0 0 6px; }
.message button { margin-top: 8px; }

.source { margin: 0; text-align: center; font-size: .8rem; opacity: .7; }
.source a { color: inherit; }

.torch {
  position: absolute; top: 12px; right: 12px; padding: 8px 14px;
  border-radius: 999px; border: 2px solid rgba(255, 255, 255, .7);
  font-size: 1rem; font-weight: 700; line-height: 1; letter-spacing: .03em;
  background: rgba(0, 0, 0, .6); color: #fff;
}
.torch[aria-pressed="true"] { background: #facc15; border-color: #facc15; color: #000; }
