* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 32px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fffff2;
  color: #111;
}

main {
  width: min(420px, 100%);
  padding: clamp(20px, 6vw, 32px);
  border-radius: clamp(16px, 4vw, 20px);
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  text-align: center;
}

h1 {
  margin: 0 0 clamp(14px, 4vw, 16px);
  font-size: clamp(22px, 6vw, 24px);
  line-height: 1.15;
}

.qr-form {
  display: flex;
  gap: 8px;
  margin-top: clamp(18px, 5vw, 20px);
}

.qr-form input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #ccd2d8;
  border-radius: 10px;
  font: inherit;
  font-size: 16px;
}

.qr-form input:focus {
  outline: 2px solid rgba(19, 46, 82, 0.25);
  outline-offset: 2px;
  border-color: #132e52;
}

button {
  padding: 11px 14px;
  border: 0;
  border-radius: 10px;
  background: #132e52;
  color: #fffff2;
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.15s ease;
}

button:hover {
  background: #0c1c32;
  color: #fdd000;
}

button:active {
  transform: translateY(1px);
}

#qr {
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  transition:
    max-height 0.3s ease,
    opacity 0.3s ease,
    transform 0.3s ease,
    margin 0.3s ease;
}

#qr.is-visible {
  max-height: 280px;
  opacity: 1;
  margin-top: clamp(18px, 6vw, 24px);
  margin-bottom: clamp(18px, 6vw, 24px);
}

#qr canvas,
#qr img,
#qr svg {
  display: block;
  width: min(256px, 70vw);
  height: auto;
  max-width: 100%;
}

.download-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

.download-actions[hidden],
.download-btn[hidden] {
  display: none;
}

.url {
  margin: 16px 0 0;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-size: clamp(13px, 3.5vw, 14px);
  line-height: 1.4;
  color: #555;
}

.error {
  color: #b00020;
  font-weight: 600;
}

@media (max-width: 520px) {
  body {
    align-items: flex-start;
  }

  main {
    margin-top: clamp(24px, 10vh, 72px);
  }

  .qr-form,
  .download-actions {
    flex-direction: column;
  }

  .qr-form button,
  .download-btn {
    width: 100%;
  }
}

@media (max-width: 340px) {
  main {
    padding: 18px;
  }

  #qr.is-visible {
    max-height: 240px;
  }

  #qr canvas,
  #qr img,
  #qr svg {
    width: min(220px, 68vw);
  }
}
