:root {
  --ink: #1c2926;
  --muted: #71817b;
  --paper: #f7f5ed;
  --card: #fffdf8;
  --line: #dfe6de;
  --mint: #dff3e6;
  --mint-strong: #98d6b0;
  --green: #32885b;
  --orange: #ef9e4f;
  --orange-soft: #fff0d7;
  --red: #d9675c;
  --shadow: 0 18px 55px rgba(41, 61, 50, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 10% -10%, #e8f6e7 0, transparent 34%),
    radial-gradient(circle at 100% 6%, #fff0d7 0, transparent 28%),
    var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(50, 136, 91, 0.35);
  outline-offset: 3px;
}

.app-shell {
  width: min(100% - 32px, 560px);
  margin: 0 auto;
  padding: 25px 0 36px;
}

.topbar,
.brand,
.status-pill,
.card-heading,
.camera-actions,
.capture-actions,
.preview-actions,
.status-message,
.result-main,
.meter-labels,
.manual-form,
.footer-note {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
}

.brand {
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 13px;
  background: var(--mint-strong);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 20px;
  font-weight: 900;
  transform: rotate(-7deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.status-pill {
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid #cde6d5;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(50, 136, 91, 0.13);
}

.intro {
  padding: 64px 4px 31px;
}

.eyebrow,
.step-label,
.result-kicker {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.intro h1 {
  max-width: 480px;
  margin: 12px 0 13px;
  font-size: clamp(42px, 12vw, 70px);
  line-height: 0.98;
  letter-spacing: -0.075em;
}

.intro h1 em {
  color: var(--orange);
  font-style: normal;
}

.intro p {
  max-width: 400px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.scanner-card,
.result-card,
.manual-card {
  border: 1px solid rgba(199, 211, 202, 0.7);
  border-radius: 28px;
  background: rgba(255, 253, 248, 0.93);
  box-shadow: var(--shadow);
}

.scanner-card {
  padding: 23px;
}

.card-heading {
  justify-content: space-between;
  gap: 16px;
}

.card-heading h2,
.manual-card h2 {
  margin: 5px 0 0;
  font-size: 22px;
  letter-spacing: -0.045em;
}

.camera-badge,
.result-check {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border-radius: 13px;
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 25px;
  font-weight: 800;
}

.camera-stage {
  position: relative;
  display: grid;
  min-height: 287px;
  margin-top: 20px;
  overflow: hidden;
  place-items: center;
  border: 1.5px dashed #b6cabd;
  border-radius: 20px;
  background:
    linear-gradient(rgba(216, 237, 223, 0.6), rgba(216, 237, 223, 0.6)),
    repeating-linear-gradient(0deg, transparent 0, transparent 38px, rgba(123, 157, 134, 0.08) 39px),
    repeating-linear-gradient(90deg, transparent 0, transparent 38px, rgba(123, 157, 134, 0.08) 39px),
    #eaf7eb;
}

.camera-stage video,
.camera-stage img {
  width: 100%;
  height: 100%;
  min-height: 287px;
  object-fit: cover;
}

.camera-stage img {
  display: block;
}

.empty-state {
  display: grid;
  padding: 26px 20px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  margin-top: 17px;
  color: var(--ink);
  font-size: 13px;
}

.empty-state > span:last-child {
  margin-top: 7px;
  font-size: 11px;
}

.scan-frame {
  position: relative;
  display: grid;
  width: 148px;
  height: 116px;
  place-items: center;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.26);
}

.scan-icon {
  display: grid;
  width: 47px;
  height: 47px;
  place-items: center;
  border: 2px solid var(--green);
  border-radius: 15px;
  color: var(--green);
  font-size: 34px;
  font-weight: 400;
  line-height: 1;
  transform: rotate(90deg);
}

.corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--green);
  border-style: solid;
}

.corner-tl { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 9px 0 0; }
.corner-tr { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 9px 0 0; }
.corner-bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 9px; }
.corner-br { right: 0; bottom: 0; border-width: 0 3px 3px 0; border-radius: 0 0 9px; }

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 15px;
  color: white;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.35), transparent 30%, transparent 68%, rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.live-indicator {
  align-self: flex-start;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(31, 39, 35, 0.7);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.09em;
}

.live-indicator i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: #ff765e;
  box-shadow: 0 0 0 3px rgba(255, 118, 94, 0.25);
}

.overlay-hint {
  align-self: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(31, 39, 35, 0.67);
  font-size: 11px;
  text-align: center;
}

.target-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(84%, 410px);
  height: 29%;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 13px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.1), 0 0 0 4px rgba(31, 39, 35, 0.2);
  transform: translate(-50%, -50%);
}

.target-guide::before,
.target-guide::after,
.target-line {
  position: absolute;
  display: block;
  background: rgba(255, 255, 255, 0.72);
  content: "";
}

.target-guide::before {
  top: 50%;
  left: 12%;
  width: 76%;
  height: 1px;
}

.target-guide::after {
  top: 14%;
  left: 50%;
  width: 1px;
  height: 72%;
}

.target-line {
  top: 50%;
  left: 6%;
  width: 88%;
  height: 2px;
  background: rgba(255, 192, 111, 0.95);
  box-shadow: 0 0 9px rgba(255, 192, 111, 0.8);
  animation: scan-line 2.3s ease-in-out infinite;
}

@keyframes scan-line {
  0%, 100% { transform: translateY(-28px); opacity: 0.35; }
  50% { transform: translateY(28px); opacity: 1; }
}

.camera-actions,
.capture-actions,
.preview-actions {
  gap: 9px;
  margin-top: 17px;
}

.capture-actions,
.preview-actions {
  flex-wrap: wrap;
}

.button {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 850;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover,
.round-button:hover {
  transform: translateY(-2px);
}

.button:active,
.round-button:active {
  transform: translateY(0);
}

.button-primary {
  flex: 1;
  border: 1px solid var(--ink);
  background: var(--ink);
  box-shadow: 0 5px 0 #91b49f;
  color: white;
}

.button-primary:hover {
  background: #2a3d37;
  box-shadow: 0 7px 0 #91b49f;
}

.button-secondary,
.button-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.button-secondary {
  flex: 1;
}

.button-secondary:hover,
.button-ghost:hover {
  background: #f0f7f1;
}

.button-ghost {
  padding-inline: 18px;
}

.button-icon {
  margin-right: 5px;
  font-size: 15px;
}

.status-message {
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.status-message-icon {
  display: grid;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.status-message.is-error .status-message-icon {
  background: #ffe0db;
  color: var(--red);
}

.status-message.is-error {
  color: #a94d44;
}

.result-card {
  margin-top: 16px;
  padding: 23px;
  animation: rise-in 420ms ease both;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-check {
  background: var(--mint);
  color: var(--green);
  font-size: 19px;
}

.result-main {
  justify-content: space-between;
  gap: 14px;
  margin-top: 28px;
}

.result-kicker {
  font-size: 9px;
}

.result-number {
  margin-top: 4px;
  font-size: clamp(58px, 16vw, 82px);
  font-weight: 900;
  letter-spacing: -0.09em;
  line-height: 0.95;
}

.result-number small {
  margin-left: 8px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.result-serving {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.result-breakdown {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(169, 77, 68, 0.08);
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}

.result-breakdown strong {
  font-weight: 900;
}

.version-line {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(199, 211, 202, 0.4);
  font-size: 11px;
  opacity: 0.75;
}

.level-badge {
  align-self: flex-start;
  padding: 9px 11px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.level-low { background: var(--mint); color: var(--green); }
.level-medium { background: var(--orange-soft); color: #bd7628; }
.level-high { background: #ffe0db; color: var(--red); }

.meter {
  height: 11px;
  margin-top: 23px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #a5dfb5 0 32%, #f5c26f 32% 66%, #ed8878 66%);
}

.meter-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  box-shadow: 0 0 0 2px rgba(255, 253, 248, 0.8);
  transition: width 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.meter-labels {
  justify-content: space-between;
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.result-note {
  margin-top: 20px;
  padding: 12px 13px;
  border-radius: 12px;
  background: #f3f7ef;
  color: #53645b;
  font-size: 11px;
  line-height: 1.5;
}

.ocr-details {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
}

.ocr-details summary {
  cursor: pointer;
  font-weight: 700;
}

.ocr-details pre {
  max-height: 130px;
  margin: 9px 0 0;
  overflow: auto;
  padding: 10px;
  border-radius: 10px;
  background: #f5f4ed;
  color: #516158;
  font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.manual-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 16px;
  padding: 20px 22px;
  box-shadow: none;
}

.manual-card h2 {
  font-size: 16px;
}

.manual-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.manual-form {
  flex: 0 0 162px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  padding: 4px 5px 4px 11px;
}

.manual-form input {
  width: 68px;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.manual-form input::placeholder {
  color: #bdc8c0;
  font-weight: 600;
}

.manual-form > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.round-button {
  display: grid;
  width: 33px;
  height: 33px;
  margin-left: auto;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: var(--mint);
  color: var(--green);
  font-size: 20px;
  font-weight: 900;
  transition: transform 160ms ease;
}

.footer-note {
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 24px 12px 4px;
  color: #84928a;
  font-size: 9px;
  line-height: 1.5;
  text-align: center;
}

.footer-note > span:first-child {
  color: var(--orange);
}

.footer-separator {
  color: #b8c2ba;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

@media (max-width: 480px) {
  .app-shell {
    width: min(100% - 22px, 560px);
    padding-top: 17px;
  }

  .intro {
    padding-top: 52px;
  }

  .scanner-card,
  .result-card {
    padding: 19px;
    border-radius: 23px;
  }

  .camera-stage,
  .camera-stage video,
  .camera-stage img {
    min-height: 252px;
  }

  .manual-card {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 19px;
  }

  .manual-form {
    width: 100%;
    flex: 1 1 auto;
    min-height: 44px;
  }

  .manual-form input {
    flex: 1;
  }
}
