.ai {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(var(--s-5), env(safe-area-inset-top)) var(--gutter) max(var(--s-6), env(safe-area-inset-bottom));
  color: #f3efe2;
  background: linear-gradient(180deg, #1d3528 0%, #0f1f17 100%);
}

.ai__head {
  width: min(100%, 22rem);
  text-align: center;
  margin-bottom: var(--s-5);
}

.ai__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
}

.ai__sub {
  margin: var(--s-2) 0 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: rgba(243, 239, 226, 0.72);
}

.ai__panel {
  width: min(100%, 22rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-3) var(--s-5);
  border: 1px solid rgba(243, 239, 226, 0.12);
  border-radius: var(--r-md);
  background: rgba(8, 18, 14, 0.55);
}

.ai__traits {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  position: relative;
  z-index: 1;
}

.trait {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--s-2) var(--s-1);
  border-radius: var(--r-sm);
  opacity: 0.45;
  transition: opacity 0.35s ease, background 0.35s ease;
}

.trait.active,
.trait.done {
  opacity: 1;
}

.trait.active {
  background: rgba(95, 214, 138, 0.08);
}

.trait__ic {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(243, 239, 226, 0.2);
  color: rgba(243, 239, 226, 0.55);
  background: rgba(15, 31, 23, 0.8);
  transition: border-color 0.35s ease, color 0.35s ease, background 0.35s ease, box-shadow 0.35s ease;
}

.trait.active .trait__ic {
  color: #fff;
  border-color: #5fd68a;
  background: rgba(30, 68, 52, 0.95);
  box-shadow: 0 0 0 3px rgba(95, 214, 138, 0.2);
}

.trait.done .trait__ic {
  color: #fff;
  border-color: #5fd68a;
  background: rgba(30, 68, 52, 0.95);
}

.trait__check {
  position: absolute;
  top: 4px;
  right: calc(50% - 30px);
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #5fd68a;
  color: #0f1f17;
}

.trait__check[hidden] {
  display: none;
}

.trait__label {
  font-size: 0.68rem;
  line-height: 1.25;
  text-align: center;
  color: rgba(243, 239, 226, 0.78);
}

.ai__visual {
  position: relative;
  width: min(68vw, 268px);
  height: calc(min(68vw, 268px) * 4 / 3);
  aspect-ratio: 3 / 4;
  flex: none;
  overflow: visible;
  border-radius: 50% / 42%;
  background: #0e1f17;
  isolation: isolate;
}

.ai__frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  border-radius: inherit;
}

.ai__frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.ai__frame img[src] {
  opacity: 1;
}

.ai__scan {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  overflow: visible;
}

.ai__scan-beam {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 8%;
  height: 4px;
  z-index: 32;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent 0%, #5fd68a 18%, #d4ffe0 50%, #5fd68a 82%, transparent 100%);
  box-shadow:
    0 0 10px rgba(95, 214, 138, 1),
    0 0 24px rgba(95, 214, 138, 0.7),
    0 0 48px rgba(95, 214, 138, 0.35);
  opacity: 0;
  will-change: top;
}

.ai__scan.is-running .ai__scan-beam {
  opacity: 1;
  animation: ai-scan-beam var(--scan-pass-duration, 2.8s) linear infinite;
}

.ai__scan-beam::after {
  content: "";
  position: absolute;
  left: -4%;
  right: -4%;
  top: 4px;
  height: 56px;
  background: linear-gradient(180deg, rgba(95, 214, 138, 0.45) 0%, rgba(95, 214, 138, 0.12) 55%, transparent 100%);
  filter: blur(0.5px);
}

.ai__scan-beam::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  height: 8px;
  background: linear-gradient(180deg, transparent, rgba(184, 245, 200, 0.55));
}

.ai__corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: rgba(95, 214, 138, 0.9);
  border-style: solid;
  z-index: 31;
  opacity: 0.95;
  filter: drop-shadow(0 0 6px rgba(95, 214, 138, 0.45));
}

.ai__corner--tl {
  top: 8%;
  left: 12%;
  border-width: 2.5px 0 0 2.5px;
  border-radius: 5px 0 0 0;
}

.ai__corner--tr {
  top: 8%;
  right: 12%;
  border-width: 2.5px 2.5px 0 0;
  border-radius: 0 5px 0 0;
}

.ai__corner--bl {
  bottom: 8%;
  left: 12%;
  border-width: 0 0 2.5px 2.5px;
  border-radius: 0 0 0 5px;
}

.ai__corner--br {
  bottom: 8%;
  right: 12%;
  border-width: 0 2.5px 2.5px 0;
  border-radius: 0 0 5px 0;
}

.ai__status {
  margin: 0;
  min-height: 1.25em;
  color: rgba(243, 239, 226, 0.65);
  letter-spacing: 0.02em;
}

@keyframes ai-scan-beam {
  0% {
    top: 8%;
  }
  100% {
    top: 92%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .trait,
  .trait__ic,
  .ai__frame img {
    transition-duration: 0.15s;
  }

  .ai__scan.is-running .ai__scan-beam {
    animation-duration: 1.5s;
    animation-iteration-count: infinite;
  }
}
