:root {
  --bg-a: #fff7fa;
  --bg-b: #f5ecff;
  --bg-c: #ecfaff;
  --ink: #2d1f34;
  --muted: #735f82;
  --line: rgba(95, 68, 118, 0.18);
  --glass: rgba(255, 255, 255, 0.58);
  --rose: #f97db0;
  --pink: #ff9ec5;
  --mint: #99e7d7;
  --lila: #a181ff;
  --orange: #ffa068;
  --shadow: 0 24px 70px rgba(109, 70, 139, 0.2);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* { box-sizing: border-box; }

html {
  font-size: 95%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Montserrat", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 168, 206, 0.45), transparent 30rem),
    radial-gradient(circle at 90% 12%, rgba(161, 129, 255, 0.36), transparent 32rem),
    radial-gradient(circle at 52% 92%, rgba(153, 231, 215, 0.25), transparent 28rem),
    linear-gradient(145deg, var(--bg-a), var(--bg-b) 55%, var(--bg-c));
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.13) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 78%);
}

.app {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.screen {
  display: none;
  min-height: calc(100vh - 32px);
  padding: 6px 0 18px;
  grid-template-rows: auto;
  gap: 18px;
  align-content: center;
  justify-items: center;
}

.screen.is-active { display: grid; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.36);
  backdrop-filter: blur(24px) saturate(1.2);
  box-shadow: 0 12px 35px rgba(108, 70, 138, 0.11);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--pink), var(--lila));
  box-shadow: 0 10px 24px rgba(161, 129, 255, 0.34);
}

.status-pill {
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12.35px;
  color: #6f50df;
  background: rgba(255, 255, 255, 0.5);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
  align-items: center;
  width: 100%;
}

.copy {
  display: grid;
  gap: 12px;
  justify-items: center;
  align-content: center;
  text-align: center;
}

.copy .topbar {
  width: 100%;
  margin: 26px 0 12px;
}

.copy h1 {
  margin: 0 auto;
  max-width: 620px;
  font-size: clamp(30.4px, 4.94vw, 49.4px);
  line-height: 0.96;
}

.copy p {
  margin: 6px auto 0;
  max-width: 700px;
  color: var(--muted);
  font-size: clamp(16.15px, 2.66vw, 20.9px);
  line-height: 1.45;
}

.upload-card, .panel, .loading-card {
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 30px;
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(1.3);
  box-shadow: var(--shadow);
}

.upload-card {
  position: relative;
  padding: 16px;
  overflow: hidden;
  display: grid;
}

.upload-card::after {
  content: "";
  position: absolute;
  inset: auto -16% -22% 22%;
  height: 170px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(249, 125, 176, 0.34), rgba(161, 129, 255, 0.3));
  filter: blur(20px);
}

.dropzone {
  position: relative;
  z-index: 1;
  min-height: 320px;
  border: 1px dashed rgba(111, 80, 223, 0.34);
  border-radius: 24px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.35);
  transition: transform 180ms var(--ease-out), border-color 180ms ease, background 180ms ease;
}

.dropzone.is-dragging {
  transform: translateY(-3px);
  border-color: rgba(249, 125, 176, 0.88);
  background: rgba(255, 255, 255, 0.62);
}

.drop-icon {
  width: 74px;
  height: 74px;
  margin: 0 auto;
  border-radius: 26px;
  position: relative;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--lila), var(--rose));
  box-shadow:
    0 22px 44px rgba(161, 129, 255, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.28) inset,
    0 0 0 8px rgba(161, 129, 255, 0.08);
  transform-origin: center;
  animation: icon-float 3s ease-in-out infinite;
}

.drop-copy {
  display: grid;
  place-items: center;
  align-content: start;
  gap: 6px;
  padding-top: 0;
  margin-bottom: 20px;
}

.drop-action {
  display: flex;
  justify-content: center;
  align-items: end;
  padding-top: 0;
  margin-top: 0;
}

.dropzone h2 {
  margin: 0;
  font-size: clamp(24.7px, 4.75vw, 34.2px);
}

.dropzone p {
  margin: 8px auto 0;
  max-width: 360px;
  color: var(--muted);
  line-height: 1.45;
}

input[type="file"] { display: none; }

.panel {
  padding: 16px;
  width: min(980px, 100%);
}

.metrics-panel h2 {
  margin: 0;
  font-size: clamp(24.7px, 4.37vw, 36.1px);
  color: #6d47d3;
}

.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(22px) saturate(1.2);
  box-shadow: 0 12px 30px rgba(108, 70, 138, 0.1);
}

.section-bar h2,
.section-bar h3 {
  flex: 1;
  margin: 0;
  color: #6d47d3;
  text-align: left;
}

.section-mark {
  width: 38px;
  height: 38px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(145deg, var(--pink), var(--lila));
  box-shadow: 0 10px 24px rgba(161, 129, 255, 0.3);
}

.external-bar {
  width: min(980px, 100%);
  margin-bottom: -4px;
}

.external-bar h2,
.external-bar h3 {
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

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

.metric {
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.47);
  border: 1px solid rgba(255, 255, 255, 0.68);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12.35px;
  margin-bottom: 7px;
}

.metric strong {
  display: block;
  font-size: clamp(20.9px, 3.8vw, 32.3px);
  line-height: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.actions.centered {
  justify-content: center;
  align-items: center;
}

.actions.big-gap {
  margin: 8px 0 2px;
  gap: 16px;
}

.btn {
  min-height: 48px;
  border: 0;
  border-radius: 18px;
  padding: 13px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.64);
  box-shadow: 0 12px 28px rgba(95, 54, 128, 0.14);
  cursor: pointer;
  transition: transform 140ms var(--ease-out), box-shadow 180ms ease, opacity 180ms ease;
  user-select: none;
}

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--lila));
}

.btn.orange {
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--rose));
  min-height: 52px;
  min-width: min(420px, 88vw);
  font-size: clamp(15.2px, 2.375vw, 20.9px);
  font-weight: 800;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.25),
    0 12px 28px rgba(95, 54, 128, 0.18),
    0 0 18px rgba(255, 160, 104, 0.18);
  animation: border-glow 2.6s ease-in-out infinite;
}

.btn.orange::before {
  content: none;
}

.btn.mini-btn {
  min-height: 40px;
  padding: 10px 14px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  .btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(95, 54, 128, 0.2);
  }
}

.btn:not(:disabled):active { transform: scale(0.97); }

@keyframes icon-float {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 22px 44px rgba(161, 129, 255, 0.42),
      0 0 0 1px rgba(255, 255, 255, 0.28) inset,
      0 0 0 8px rgba(161, 129, 255, 0.08);
  }
  50% {
    transform: translateY(-4px) scale(1.05);
    box-shadow:
      0 30px 60px rgba(161, 129, 255, 0.52),
      0 0 0 1px rgba(255, 255, 255, 0.32) inset,
      0 0 0 14px rgba(161, 129, 255, 0.12);
  }
}

.panel-head {
  display: flex;
  justify-content: flex-end;
  align-items: start;
  gap: 12px;
  margin-bottom: 10px;
}

.panel h3 { margin: 0; }
.panel h3 { color: #ff6aa4; }
.panel small { color: #8d73a0; }

.panel-note {
  display: block;
  margin: -4px 0 12px;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.thumb {
  min-height: 156px;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.thumb img {
  width: 100%;
  height: 156px;
  object-fit: cover;
  display: block;
}

.finish-card {
  max-width: 720px;
  margin: auto;
  text-align: center;
  background: linear-gradient(155deg, rgba(255,255,255,0.72), rgba(246,232,255,0.8), rgba(234,252,255,0.72));
}

.finish-card h2 {
  margin: 0;
  font-size: clamp(28.5px, 5.7vw, 47.5px);
}

.finish-card p {
  margin: 0 0 16px;
  color: #7b6194;
}

.finish-cta {
  min-height: 54px;
  min-width: min(430px, 88vw);
  font-size: clamp(16.15px, 2.565vw, 21.85px);
  font-weight: 900;
  letter-spacing: 0.03em;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
}

.finish-cta::before {
  content: "";
  position: absolute;
  top: 0;
  left: -45%;
  width: 38%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.55), rgba(255,255,255,0));
  transform: skewX(-18deg);
  animation: light-sweep 2.2s linear infinite;
}

.finish-floating {
  display: flex;
  justify-content: center;
  width: min(980px, 100%);
  margin-top: -2px;
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(255, 246, 251, 0.72);
  backdrop-filter: blur(22px);
}

.loading.is-visible { display: grid; }

.loading-card {
  width: min(460px, 100%);
  padding: 28px;
  text-align: center;
}

.loader-stage {
  position: relative;
  width: 128px;
  height: 186px;
  margin: 0 auto 10px;
}

.loader-emoji {
  position: absolute;
  top: 0;
  left: 50%;
  width: 122px;
  height: 122px;
  object-fit: contain;
  transform: translateX(-50%);
  transform-origin: 50% 62%;
  filter: drop-shadow(0 12px 20px rgba(45, 31, 52, 0.2));
  animation: emoji-sway 2.4s var(--ease-in-out) infinite;
  z-index: 2;
}

.liquid-loader {
  position: relative;
  z-index: 1;
  width: 114px;
  height: 114px;
  margin: 72px auto 0;
  border-radius: 34px;
  background: conic-gradient(from 90deg, var(--pink), var(--lila), var(--mint), var(--pink));
  padding: 4px;
  animation: spin 2.8s linear infinite;
}

.liquid-loader::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.82);
}

.progress-shell {
  height: 10px;
  margin: 16px 0 8px;
  border-radius: 999px;
  background: rgba(111, 80, 223, 0.12);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--lila), var(--mint));
  transition: width 260ms var(--ease-out);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  width: min(520px, calc(100% - 28px));
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 18px;
  color: #6f50df;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(24px);
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: transform 220ms var(--ease-out), opacity 220ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes emoji-sway {
  0% { transform: translateX(-50%) rotate(-6deg); }
  50% { transform: translateX(-50%) rotate(6deg); }
  100% { transform: translateX(-50%) rotate(-6deg); }
}

@keyframes light-sweep {
  0% { left: -45%; }
  100% { left: 120%; }
}

@keyframes border-glow {
  0% {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.22),
      0 12px 28px rgba(95, 54, 128, 0.18),
      0 0 10px rgba(255, 160, 104, 0.14);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.5),
      0 14px 32px rgba(95, 54, 128, 0.22),
      0 0 22px rgba(255, 118, 170, 0.34),
      0 0 12px rgba(161, 129, 255, 0.24);
  }
  100% {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.22),
      0 12px 28px rgba(95, 54, 128, 0.18),
      0 0 10px rgba(255, 160, 104, 0.14);
  }
}

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .copy h1 { font-size: clamp(26.6px, 8.74vw, 39.9px); }
  .copy .topbar { width: 100%; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-grid.small { grid-template-columns: 1fr; }
  .panel-head { flex-direction: column; }
  .actions.centered { display: grid; grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .status-pill { display: none; }
  .loader-emoji {
    width: 104px;
    height: 104px;
    top: 0;
  }
  .loader-stage {
    width: 114px;
    height: 166px;
  }
  .liquid-loader {
    margin-top: 64px;
  }
  .screen {
    align-content: center;
    justify-items: stretch;
  }
}

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