:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  color: #1b1d1a;
  background: #fafaf8;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  padding: max(24px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
}

.reader {
  width: min(100%, 540px);
  min-width: 0;
  min-height: 190px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-target {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  color: #31352f;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .28s ease .1s, visibility 0s linear 0s;
}

.upload-square {
  width: 156px;
  height: 156px;
  display: grid;
  place-items: center;
  border: 1px solid #e3e5df;
  border-radius: 32px;
  background: #f2f3ef;
  transition: border-color .2s ease, background-color .2s ease, transform .22s ease;
}

.upload-target:hover .upload-square, .reader.is-dragging .upload-square { background: #e9ece6; border-color: #bdc6b9; }
.upload-target:active .upload-square { transform: scale(.965); }
.upload-target:focus-visible { outline: none; }
.upload-target:focus-visible .upload-square { outline: 3px solid #7c9380; outline-offset: 4px; }
.qr-symbol { width: 76px; height: 76px; transition: opacity .2s ease, transform .24s ease; }
.upload-caption { color: #6e746d; font-size: 13px; font-weight: 520; letter-spacing: -.01em; line-height: 1.25; }

.reader.has-result .upload-target { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .4s ease, visibility 0s linear .4s; }

.result {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  max-width: 100%;
  width: 100%;
  text-align: center;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: clamp(17px, 3.6vw, 23px);
  font-weight: 520;
  letter-spacing: -.025em;
  line-height: 1.55;
  max-height: min(66vh, 560px);
  max-height: min(66dvh, 560px);
  overflow-y: auto;
  scrollbar-width: thin;
  user-select: text;
  -webkit-user-select: text;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility 0s linear .2s;
}
.result a { color: inherit; text-decoration: underline; text-decoration-color: #b8beb4; text-underline-offset: 5px; }
.result a:hover { text-decoration-color: currentColor; }
.reader.has-result .result { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .48s ease .34s, visibility 0s linear .34s; }

.rescan {
  position: fixed;
  left: 50%;
  bottom: max(54px, calc(env(safe-area-inset-bottom) + 44px));
  transform: translateX(-50%);
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: #7f857e;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .22s ease, color .18s ease, visibility 0s linear .22s;
}
.rescan svg { width: 21px; height: 21px; }
.rescan:hover { color: #394039; }
.rescan:focus-visible { outline: 2px solid #869b88; outline-offset: 2px; }
.reader.has-result .rescan { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .3s ease .48s, color .18s ease, visibility 0s linear .48s; }

.feedback {
  margin: 22px 0 0;
  max-width: 100%;
  text-align: center;
  color: #7a7770;
  font-size: 13px;
  line-height: 1.5;
}
.feedback:not([hidden]) { animation: feedback-appear .3s ease-out both; }

.reader.is-reading .upload-square { border-color: #bcc7bb; background: #edf1eb; }
.reader.is-reading .qr-symbol { opacity: .53; transform: scale(.94); }

@keyframes feedback-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 420px) {
  .screen { padding-left: 20px; padding-right: 20px; }
  .upload-square { width: 142px; height: 142px; border-radius: 30px; }
  .qr-symbol { width: 72px; height: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .upload-target, .reader.has-result .upload-target, .upload-square, .qr-symbol,
  .result, .reader.has-result .result, .rescan, .reader.has-result .rescan { transition: none; }
  .feedback:not([hidden]) { animation: none; }
}
