:root {
  --color-bg: #b9b8b2;
  --color-page: #8f8e88;
  --color-surface: #fffcf6;
  --color-ink: #2c2721;
  --color-muted: #6e665c;
  --color-line: #d8d0c3;
  --color-accent: #4d3f31;
  --color-accent-strong: #221b15;
  --color-gold: #b69667;
  --radius-sm: 8px;
  --radius-md: 14px;
  --space-sm: 12px;
  --space-md: 18px;
  --space-lg: 28px;
  --space-xl: 44px;
  --font-display: "Times New Roman", Georgia, serif;
  --font-body: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 8%, rgba(185, 184, 178, 0.46), transparent 38%),
    linear-gradient(180deg, #77766f 0%, var(--color-page) 42%, #6d6c66 100%);
  background-color: var(--color-page);
  color: var(--color-ink);
  font-family: var(--font-body);
  overflow-x: hidden;
}

button,
a,
textarea,
input {
  font: inherit;
}

button,
.file-button,
.preview-action,
.preview-link,
.result__actions a {
  min-height: 54px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: rgba(255, 252, 246, 0.86);
  color: var(--color-ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover,
.file-button:hover,
.result__actions a:hover {
  border-color: var(--color-gold);
  transform: translateY(-1px);
}

button:focus-visible,
.file-button:focus-within,
.result__actions a:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(182, 150, 103, 0.46);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.ambient-shelf {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  perspective: 900px;
}

.ambient-shelf::before,
.ambient-shelf::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
}

.ambient-shelf::before {
  background: linear-gradient(90deg, rgba(109, 108, 102, 0.98) 0%, rgba(109, 108, 102, 0.36) 24%, rgba(109, 108, 102, 0.18) 76%, rgba(109, 108, 102, 0.98) 100%);
}

.ambient-shelf::after {
  background: linear-gradient(180deg, rgba(109, 108, 102, 0.94) 0%, rgba(109, 108, 102, 0.24) 32%, rgba(109, 108, 102, 0.32) 70%, rgba(109, 108, 102, 0.96) 100%);
}

.ambient-row {
  position: absolute;
  left: 50%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 118px;
  gap: 14px;
  transform-style: preserve-3d;
  opacity: 0.24;
  filter: saturate(0.78) contrast(0.92);
  animation: shelfDrift 22s linear infinite;
}

.ambient-row img {
  width: 118px;
  height: 76px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.32);
  transform: rotateY(-24deg) rotateX(8deg);
}

.ambient-row--one {
  top: 12%;
  animation-duration: 24s;
}

.ambient-row--two {
  top: 45%;
  animation-duration: 28s;
  animation-direction: reverse;
}

.ambient-row--three {
  top: 76%;
  animation-duration: 26s;
}

.app-shell {
  position: relative;
  z-index: 3;
  width: min(440px, calc(100% - 34px));
  margin: 0 auto;
  padding: 18px 0 34px;
}

.app-card {
  background: var(--color-bg);
  border: 1px solid rgba(216, 208, 195, 0.9);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(34, 27, 21, 0.18);
}

.app-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.language-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  color: var(--color-muted);
  font-size: 0;
}

.language-picker select {
  min-height: 38px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: rgba(255, 252, 246, 0.9);
  color: var(--color-ink);
  padding: 0 28px 0 10px;
  font-size: 14px;
}

.language-picker select:focus-visible {
  outline: 3px solid rgba(182, 150, 103, 0.46);
  outline-offset: 3px;
}

.brand {
  width: 128px;
  display: block;
  margin-bottom: 0;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: clamp(28px, 8vw, 40px);
  line-height: 0.98;
  max-width: 390px;
}

h2 {
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1;
}

p {
  color: var(--color-muted);
  line-height: 1.55;
  margin: 0;
}

.hero-copy p {
  max-width: 390px;
  margin-top: 5px;
  font-size: 15px;
}

.steps {
  display: flex;
  gap: 8px;
  padding: 0;
  margin: 10px 0 12px;
  list-style: none;
  border-top: 1px solid rgba(44, 39, 33, 0.12);
  border-bottom: 1px solid rgba(44, 39, 33, 0.12);
}

.steps li {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  color: var(--color-ink);
  padding: 8px 0;
}

.steps span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-accent-strong);
  color: #fff8ed;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.steps strong {
  font-size: 13px;
  line-height: 1;
  font-weight: 600;
}

.capture-panel,
.result,
.history {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.preview {
  aspect-ratio: 1 / 1;
  background: #ded4c5;
  border-radius: 14px;
  border: 1px solid rgba(44, 39, 33, 0.1);
  overflow: hidden;
  position: relative;
}

.preview video,
.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview__empty {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  place-items: center;
  gap: 10px;
  color: var(--color-muted);
  padding: 24px;
  text-align: center;
}

.preview-action,
.preview-link {
  width: min(252px, 100%);
  background: #fffcf6;
}

.preview-link {
  min-height: 46px;
  background: transparent;
}

.preview-action input,
.preview-link input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.capture-overlay {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: min(252px, calc(100% - 32px));
  transform: translateX(-50%);
  background: #fffcf6;
}

.controls {
  display: none;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: var(--space-md);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.native-camera {
  display: none;
}

.file-button.is-disabled {
  opacity: 0.48;
  pointer-events: none;
}

.primary {
  width: 100%;
  margin-top: 8px;
  background: var(--color-accent-strong);
  border-color: var(--color-accent-strong);
  color: #fff8ed;
}

.time-note {
  margin-top: var(--space-md);
  text-align: center;
  font-size: 14px;
}

.status {
  min-height: 24px;
  margin-top: 10px;
  font-size: 14px;
  text-align: center;
}

.generation-panel {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto auto;
  background: #fbf8f1;
}

.scan-art {
  display: grid;
  place-items: center;
  padding: 18px 18px 0;
}

.scan-art svg {
  width: min(72%, 250px);
  display: block;
}

.mark-face {
  stroke-dasharray: 360;
  animation: drawFace 3s ease-in-out infinite;
}

.mark-scan {
  transform-origin: center;
  animation: scanMove 2.4s ease-in-out infinite;
}

.mark-glasses {
  animation: framePulse 2.4s ease-in-out infinite;
}

.mark-nose,
.mark-mouth {
  opacity: 0.9;
}

.generation-copy {
  display: grid;
  gap: 4px;
  padding: 0 14px 16px;
  text-align: center;
}

.generation-copy strong {
  color: var(--color-ink);
  font-size: 15px;
}

.generation-copy span {
  color: var(--color-muted);
  font-size: 14px;
}

.progress-rail {
  height: 5px;
  background: rgba(216, 208, 195, 0.74);
}

.progress-rail span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-gold));
  transition: width 420ms ease;
}

.result__head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-md);
}

.glasses-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.glasses-card {
  aspect-ratio: 1;
  background: #fff;
  border: 1px solid rgba(216, 208, 195, 0.86);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.glasses-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.glasses-card span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(255, 252, 246, 0.82);
  border: 1px solid rgba(216, 208, 195, 0.72);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}

.result {
  width: min(460px, calc(100% - 18px));
  margin: 14px auto 0;
  background: rgba(255, 252, 246, 0.86);
  border: 1px solid rgba(216, 208, 195, 0.9);
  border-radius: 16px;
  padding: 14px;
}

.result__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result img {
  width: 100%;
  max-height: 82vh;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius-sm);
  display: block;
}

.result p {
  margin-top: 10px;
}

.history {
  width: min(460px, calc(100% - 18px));
  margin: 18px auto 0;
}

.collection-note {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: var(--space-md);
}

.history-list a {
  display: block;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.history-list img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

@media (max-width: 360px) {
  .brand {
    width: 132px;
  }

  .app-shell {
    width: min(100% - 22px, 440px);
    padding-top: 12px;
  }

  .app-card {
    padding: 14px;
  }

  .language-picker span {
    display: none;
  }

  .glasses-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shelf-head,
  .result__head {
    align-items: flex-start;
    flex-direction: column;
  }
}

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

  .ambient-row {
    animation: none;
  }
}

@keyframes shelfDrift {
  0% {
    transform: translateX(-42%) rotateZ(-5deg) rotateX(24deg);
  }
  100% {
    transform: translateX(-58%) rotateZ(-5deg) rotateX(24deg);
  }
}

@keyframes scanMove {
  0% {
    transform: translateY(-26px) scaleX(0.7);
    opacity: 0.35;
  }
  50% {
    transform: translateY(14px) scaleX(1);
    opacity: 1;
  }
  100% {
    transform: translateY(54px) scaleX(0.7);
    opacity: 0.35;
  }
}

@keyframes drawFace {
  0% {
    stroke-dashoffset: 320;
  }
  45%,
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes framePulse {
  0%,
  100% {
    opacity: 0.62;
    transform: translateY(2px);
  }
  50% {
    opacity: 1;
    transform: translateY(0);
  }
}
