:root {
  --bg: #04141f;
  --line: rgba(255, 255, 255, 0.12);
  --text: #effdf9;
  --muted: #bad7d0;
  --green: #8ef40b;
  --green-strong: #48d76d;
  --blue: #23adff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --stage-width: min(100%, 420px);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Outfit", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(80, 229, 132, 0.28), transparent 22%),
    radial-gradient(circle at top right, rgba(35, 173, 255, 0.2), transparent 24%),
    linear-gradient(180deg, #03111a 0%, #071a26 52%, #020f17 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.glow {
  position: absolute;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.7;
}

.glow-one {
  top: 12%;
  left: -5%;
  width: 280px;
  height: 280px;
  background: rgba(92, 255, 129, 0.22);
  animation: floatGlow 12s ease-in-out infinite;
}

.glow-two {
  right: -3%;
  bottom: 15%;
  width: 320px;
  height: 320px;
  background: rgba(35, 173, 255, 0.2);
  animation: floatGlow 14s ease-in-out infinite reverse;
}

.dot-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 78%);
  opacity: 0.24;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 18px 24px;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.08));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero {
  padding: 18px 20px;
  animation: riseIn 700ms ease;
}

.hero-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-logo {
  width: 82px;
  height: 82px;
  object-fit: contain;
  filter: drop-shadow(0 16px 26px rgba(0, 0, 0, 0.3));
  flex-shrink: 0;
}

.hero-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--green);
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

h1,
h2,
strong {
  font-family: "Poppins", sans-serif;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 3.6vw, 3.8rem);
  line-height: 0.88;
  letter-spacing: 0.04em;
  font-family: "Bebas Neue", sans-serif;
}

.hero-subtitle,
.export-copy,
.preview-placeholder p,
.upload-note {
  color: var(--muted);
}

.hero-subtitle {
  margin: 8px 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
  max-width: 100%;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(340px, 0.98fr);
  gap: 20px;
  margin-top: 18px;
}

.studio-column,
.editor-column {
  display: grid;
  gap: 20px;
}

.uploader-panel,
.template-panel,
.editor-panel,
.export-panel {
  padding: 20px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.26rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.82rem;
}

.upload-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.select-photo-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(72, 215, 109, 0.18), rgba(35, 173, 255, 0.2));
  color: var(--text);
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 180ms ease, filter 180ms ease;
}

.select-photo-btn:hover,
.select-photo-btn:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.08);
  outline: none;
}

.upload-note {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.upload-preview {
  margin-top: 14px;
}

.preview-placeholder,
.preview-ready {
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-placeholder {
  gap: 10px;
  min-height: 200px;
  padding: 20px;
}

.preview-ready {
  overflow: hidden;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.05);
}

.preview-ready img {
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: 18px;
}

.preview-icon {
  display: inline-grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(142, 244, 11, 0.15), rgba(35, 173, 255, 0.15));
  color: var(--text);
}

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

.template-card {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  text-align: left;
  padding: 0;
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.template-card:hover,
.template-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(35, 173, 255, 0.42);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
  outline: none;
}

.template-card.is-selected {
  border-color: rgba(142, 244, 11, 0.68);
  box-shadow: 0 0 0 1px rgba(142, 244, 11, 0.26), 0 18px 44px rgba(72, 215, 109, 0.18);
}

.template-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 9 / 16;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.template-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 16px;
}

.template-meta {
  padding: 10px 12px 12px;
}

.template-meta strong {
  display: block;
  font-size: 0.98rem;
}

.template-meta p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.editor-stage-shell {
  display: grid;
  gap: 10px;
}

.stage-container {
  position: relative;
  width: var(--stage-width);
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  border-radius: 30px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(142, 244, 11, 0.08), rgba(35, 173, 255, 0.12)),
    rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.stage-container canvas {
  display: block;
}

.gesture-hint {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.control-btn,
.download-btn,
.share-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  border: 0;
  color: var(--text);
  transition: transform 180ms ease, filter 180ms ease;
}

.control-btn {
  min-height: 46px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.control-btn:hover,
.control-btn:focus-visible,
.download-btn:hover,
.download-btn:focus-visible,
.share-btn:hover,
.share-btn:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.08);
  outline: none;
}

.download-btn,
.share-btn {
  width: 100%;
  min-height: 52px;
  border-radius: 18px;
  font-weight: 700;
}

.download-btn {
  background: linear-gradient(135deg, var(--green-strong), var(--blue));
  color: #04131d;
  margin-top: 2px;
}

.share-btn {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 18px 18px 30px;
  color: var(--muted);
}

.footer a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 20;
}

.toast {
  min-width: 240px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(6, 24, 33, 0.92);
  border: 1px solid rgba(142, 244, 11, 0.22);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
  animation: toastIn 260ms ease;
}

.loader-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 11, 17, 0.65);
  backdrop-filter: blur(16px);
  z-index: 30;
}

.hidden {
  display: none !important;
}

.loader-card {
  width: min(92vw, 360px);
  padding: 24px;
  border-radius: 28px;
  background: rgba(6, 24, 33, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-align: center;
}

.loader-spinner {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--green);
  border-right-color: var(--blue);
  animation: spin 860ms linear infinite;
}

.loader-title {
  margin: 0 0 14px;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
}

.loader-progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.loader-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--green), var(--blue));
  transition: width 180ms ease;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 25;
}

.confetti-piece {
  position: absolute;
  top: -40px;
  width: 10px;
  height: 18px;
  border-radius: 999px;
  opacity: 0.9;
  animation: fallDown 1000ms linear forwards;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatGlow {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(18px, -20px, 0) scale(1.08);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes fallDown {
  to {
    transform: translate3d(var(--travel-x), 105vh, 0) rotate(540deg);
    opacity: 0;
  }
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .app {
    padding: 18px 14px 18px;
  }

  .hero,
  .uploader-panel,
  .template-panel,
  .editor-panel,
  .export-panel {
    padding: 18px;
    border-radius: 26px;
  }

  .hero-logo {
    width: 72px;
    height: 72px;
  }

  .upload-actions {
    flex-direction: column;
    align-items: flex-start;
  }

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

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

@media (max-width: 480px) {
  h1 {
    font-size: 2.25rem;
    line-height: 0.9;
    letter-spacing: 0.03em;
  }

  .hero-header {
    align-items: center;
    gap: 10px;
  }

  .hero-logo {
    width: 64px;
    height: 64px;
  }

  .hero-copy {
    gap: 0;
  }

  .eyebrow {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
  }

  .template-grid {
    grid-template-columns: 1fr;
  }

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

  .hero-subtitle {
    font-size: 0.9rem;
    margin-top: 6px;
  }
}
