:root {
  --green: #0B5D3B;
  --green-dark: #08452c;
  --green-light: #e7f2ec;
  --ink: #12201a;
  --muted: #55635c;
  --warn: #8a4b00;
  --error: #a3111b;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #f4f7f5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
.top {
  background: var(--green);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  text-align: center;
}
.top h1 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: .01em; }
main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.view { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }
.hint { margin: 4px 0 0; text-align: center; color: var(--muted); font-size: 1.05rem; line-height: 1.4; }

.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 14px 18px;
  border: 0; border-radius: var(--radius);
  font: inherit; font-size: 1.2rem; font-weight: 700;
  text-decoration: none; text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.985); }
.btn:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
.btn-big { min-height: 72px; font-size: 1.45rem; }
.btn-huge { min-height: 104px; font-size: 1.9rem; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:active { background: var(--green-dark); }
.btn-secondary { background: #fff; color: var(--green); border: 2px solid var(--green); }
.btn-copy { background: #f2b705; color: #1d1600; }
.btn-copy.copied { background: var(--green-light); color: var(--green); border: 2px solid var(--green); }
.btn-stock { background: #fff; color: var(--green); border: 3px solid var(--green); }

.camera {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 58vh;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.guide {
  position: absolute; left: 7%; right: 7%; top: 32%; bottom: 32%;
  border: 3px solid rgba(255,255,255,.9);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
}
.laser { position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: #ff3b30; box-shadow: 0 0 6px #ff3b30; }
.scan-status {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0;
  padding: 10px 12px; text-align: center;
  color: #fff; background: rgba(0,0,0,.55); font-size: 1rem;
}

.result-format { margin: 6px 0 0; text-align: center; color: var(--muted); font-size: 1rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.result-code {
  display: block;
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(1.6rem, 9.4vw, 4rem);
  line-height: 1.1;
  letter-spacing: 0;
  white-space: nowrap;
  overflow-x: auto;
  background: #fff;
  border: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 18px 8px;
  user-select: all; -webkit-user-select: all;
}
.copy-status { margin: -4px 0 0; min-height: 1.4em; text-align: center; font-weight: 600; color: var(--green); }
.copy-status.fail { color: var(--warn); }
.warn { margin: 0; text-align: center; color: var(--warn); font-weight: 600; }
.message { margin: 0; padding: 12px 14px; border-radius: 12px; background: #fdecee; color: var(--error); font-weight: 600; line-height: 1.4; }

.manual { background: #fff; border-radius: var(--radius); padding: 4px 14px; border: 1px solid #d5e0da; }
.manual summary { padding: 12px 0; font-weight: 600; color: var(--green); cursor: pointer; font-size: 1.05rem; }
.manual-form { display: flex; gap: 10px; padding-bottom: 14px; }
.manual-form input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 1.3rem;
  padding: 12px; border: 2px solid #b9c9c0; border-radius: 12px;
  font-variant-numeric: tabular-nums;
}
.manual-form input:focus { outline: none; border-color: var(--green); }
.manual-form .btn { width: auto; min-width: 88px; }

.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 12px); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
