:root {
  --ink: #102434;
  --ink-soft: #24383d;
  --paper: #f4f7f6;
  --white: #ffffff;
  --route: #0c7c86;
  --route-bright: #16a0a4;
  --mist: #dce9e7;
  --coral: #e45d4c;
  --line: rgba(16, 36, 52, 0.13);
  --display: "Avenir Next Condensed", "DIN Alternate", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --body: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 18%, rgba(12, 124, 134, 0.12), transparent 30rem),
    linear-gradient(155deg, #f9fbfa 0%, var(--paper) 55%, #eaf1ef 100%);
  font-family: var(--body);
  overflow-x: hidden;
}

button {
  font: inherit;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 3.75rem 3.75rem;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

.site-mark {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: min(100% - 2rem, 68rem);
  margin: 0 auto;
  padding: 1.4rem 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.mark-symbol {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  width: 1.35rem;
  height: 1.1rem;
}

.mark-symbol i {
  display: block;
  width: 4px;
  border-radius: 3px;
  background: var(--route);
}

.mark-symbol i:nth-child(1) { height: 45%; }
.mark-symbol i:nth-child(2) { height: 100%; }
.mark-symbol i:nth-child(3) { height: 70%; }

.scan-page {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: calc(100vh - 8.5rem);
  place-items: center;
  padding: 0.5rem 1.25rem 4rem;
}

.scan-stage {
  width: min(100%, 31rem);
  text-align: center;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--route);
  font: 700 0.74rem/1 var(--body);
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  font: 700 clamp(2.45rem, 11vw, 4.1rem)/0.98 var(--display);
  letter-spacing: -0.055em;
}

.intro {
  margin: 1rem auto 0;
  color: rgba(36, 56, 61, 0.72);
  font-size: 0.92rem;
}

.qr-orbit {
  position: relative;
  width: min(78vw, 20rem);
  aspect-ratio: 1;
  margin: 2.3rem auto 1.8rem;
}

.qr-orbit::before,
.qr-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.qr-orbit::before {
  inset: -1.05rem;
  border: 1px solid rgba(12, 124, 134, 0.22);
}

.qr-orbit::after {
  inset: -1.6rem;
  border: 1px dashed rgba(16, 36, 52, 0.16);
  animation: orbit 30s linear infinite;
}

.orbit-segment {
  position: absolute;
  z-index: 2;
  width: 0.58rem;
  height: 0.58rem;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--route);
  box-shadow: 0 0 0 1px var(--route);
}

.segment-one { top: -1.32rem; left: 48%; }
.segment-two { right: -1.3rem; bottom: 29%; background: var(--route-bright); }
.segment-three { bottom: -1.32rem; left: 24%; background: var(--ink); }

.qr-frame {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  padding: 1.15rem;
  overflow: hidden;
  background: var(--white);
  box-shadow: 0 1.25rem 4rem rgba(16, 36, 52, 0.16);
}

.qr-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(12, 124, 134, 0.08),
    transparent
  );
  transform: translateX(-100%);
  animation: scan 1.7s ease-in-out infinite;
}

.is-ready .qr-frame::before,
.has-error .qr-frame::before {
  display: none;
}

.corner {
  position: absolute;
  z-index: 3;
  width: 1.4rem;
  height: 1.4rem;
  border-color: var(--route);
  border-style: solid;
}

.corner-tl { top: 0.65rem; left: 0.65rem; border-width: 2px 0 0 2px; }
.corner-tr { top: 0.65rem; right: 0.65rem; border-width: 2px 2px 0 0; }
.corner-bl { bottom: 0.65rem; left: 0.65rem; border-width: 0 0 2px 2px; }
.corner-br { right: 0.65rem; bottom: 0.65rem; border-width: 0 2px 2px 0; }

#qr-image {
  display: block;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  align-self: center;
  justify-self: center;
  object-fit: contain;
  object-position: center;
  animation: reveal 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.qr-loading {
  display: grid;
  gap: 0.45rem;
  justify-items: center;
  color: var(--ink-soft);
}

.qr-loading strong {
  margin-top: 0.8rem;
  font-size: 0.95rem;
}

.qr-loading small {
  color: rgba(36, 56, 61, 0.55);
}

.loading-pulse {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--route);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(12, 124, 134, 0.28);
  animation: pulse 1.25s ease-out infinite;
}

.qr-error {
  width: 80%;
}

.qr-error strong {
  display: block;
  font: 700 1.35rem var(--display);
}

.qr-error p {
  margin: 0.6rem 0 1.1rem;
  color: rgba(36, 56, 61, 0.65);
  font-size: 0.86rem;
}

.qr-error button {
  min-height: 2.6rem;
  padding: 0 1.2rem;
  border: 0;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  cursor: pointer;
}

.instruction {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.25rem;
  text-align: left;
}

.instruction-index {
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  border: 1px solid var(--route);
  border-radius: 50%;
  color: var(--route);
  font: 700 0.75rem var(--display);
}

.instruction p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
}

.retention-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.3rem 0 0;
  color: rgba(36, 56, 61, 0.55);
  font-size: 0.74rem;
}

.retention-note span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--route);
}

footer {
  position: relative;
  z-index: 1;
  padding: 0 1rem 1.4rem;
  color: rgba(36, 56, 61, 0.45);
  text-align: center;
  font-size: 0.7rem;
}

[hidden] {
  display: none !important;
}

button:focus-visible {
  outline: 3px solid rgba(12, 124, 134, 0.3);
  outline-offset: 3px;
}

@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes scan {
  50%, 100% { transform: translateX(100%); }
}
@keyframes pulse {
  80%, 100% { box-shadow: 0 0 0 1rem rgba(12, 124, 134, 0); }
}
@keyframes reveal {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-height: 760px) {
  .scan-page { place-items: start center; }
  .qr-orbit { margin-top: 1.75rem; width: min(66vw, 17rem); }
  h1 { font-size: clamp(2.2rem, 9vw, 3.4rem); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
