:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  color: #152033;
  background: #f3f7ff;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 7%, #d9e8ff 0, transparent 28rem),
    radial-gradient(circle at 90% 98%, #d9f6ed 0, transparent 26rem),
    #f7f9fc;
}

button { font: inherit; }

.app-shell {
  display: grid;
  min-height: 100vh;
  padding: 36px 20px;
  place-items: center;
}

.scanner-card {
  width: min(100%, 720px);
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid rgba(213, 224, 241, .9);
  border-radius: 28px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 22px 70px rgba(31, 69, 124, .14);
  backdrop-filter: blur(16px);
}

.hero { display: flex; align-items: center; gap: 16px; margin-bottom: 27px; }

.icon-badge {
  display: grid;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #0d6efd, #635bff);
  box-shadow: 0 10px 20px rgba(55, 101, 232, .24);
  place-items: center;
}

.icon-badge svg { width: 31px; height: 31px; }
.eyebrow { margin: 0 0 3px; color: #3779d9; font-size: .7rem; font-weight: 800; letter-spacing: .12em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(1.45rem, 4vw, 1.85rem); letter-spacing: -.03em; }
.subtitle { margin-bottom: 0; color: #617087; font-size: .93rem; }

.camera-frame {
  position: relative;
  overflow: hidden;
  display: grid;
  min-height: 330px;
  border-radius: 20px;
  background: #152033;
  place-items: center;
}

#camera { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }

.camera-empty {
  z-index: 1;
  display: grid;
  max-width: 280px;
  gap: 12px;
  color: #d9e5f7;
  text-align: center;
  place-items: center;
}

.camera-empty svg { width: 46px; height: 46px; opacity: .85; }
.camera-empty p { margin: 0; line-height: 1.6; font-size: .92rem; }

.scan-guide {
  position: relative;
  z-index: 2;
  display: none;
  width: min(57vw, 210px);
  aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(5, 16, 37, .25);
  pointer-events: none;
}

.scan-guide::before, .scan-guide::after, .scan-guide span::before, .scan-guide span::after {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: #52e7b1;
  border-style: solid;
  content: "";
}
.scan-guide::before { top: -3px; left: -3px; border-width: 4px 0 0 4px; border-radius: 6px 0 0; }
.scan-guide::after { top: -3px; right: -3px; border-width: 4px 4px 0 0; border-radius: 0 6px 0 0; }
.scan-guide span::before { bottom: -3px; left: -3px; border-width: 0 0 4px 4px; border-radius: 0 0 0 6px; }
.scan-guide span::after { right: -3px; bottom: -3px; border-width: 0 4px 4px 0; border-radius: 0 0 6px; }

.camera-frame.is-active .camera-empty { display: none; }
.camera-frame.is-active .scan-guide { display: block; }

.scan-success {
  position: absolute;
  z-index: 3;
  bottom: 20px;
  padding: 8px 13px;
  border-radius: 999px;
  color: #064c35;
  background: #c9f6df;
  box-shadow: 0 5px 14px rgba(0,0,0,.18);
  font-size: .82rem;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  transition: .25s ease;
}
.scan-success.is-visible { opacity: 1; transform: translateY(0); }

.camera-controls { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 14px 0 29px; }
.secure-note { margin: 0; color: #7c899b; font-size: .76rem; text-align: right; }

.result-section { padding-top: 1px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
h2 { margin-bottom: 0; font-size: .95rem; }
.result-state { padding: 4px 9px; border-radius: 999px; color: #63728a; background: #eef2f7; font-size: .73rem; font-weight: 700; }
.result-state.is-ready { color: #087b55; background: #def8ea; }

.result-box {
  display: block;
  min-height: 78px;
  padding: 14px;
  overflow-wrap: anywhere;
  border: 1px solid #dae3f0;
  border-radius: 13px;
  color: #758398;
  background: #f9fbfe;
  line-height: 1.5;
  white-space: pre-wrap;
}
.result-box.has-result { color: #18243a; background: #fff; }

.action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 750;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.primary-button svg, .secondary-button svg { width: 18px; height: 18px; }
.primary-button { color: #fff; background: #0d68f5; box-shadow: 0 8px 14px rgba(13,104,245,.2); }
.secondary-button { border-color: #d8e2ef; color: #2a405e; background: #fff; }
.primary-button:not(:disabled):hover, .secondary-button:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 7px 15px rgba(39,68,109,.13); }
button:focus-visible { outline: 3px solid #91bfff; outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .45; }

@media (max-width: 520px) {
  .app-shell { padding: 0; }
  .scanner-card { min-height: 100vh; padding: 27px 20px; border: 0; border-radius: 0; }
  .camera-frame { min-height: 280px; }
  .camera-controls { align-items: flex-start; flex-direction: column; }
  .secure-note { text-align: left; }
}
