:root {
  --ink: #1c2430;
  --paper: #f3faf7;
  --mint: #b8e8dc;
  --sea: #2a9d8f;
  --coral: #e76f51;
  --sun: #f4a261;
  --ink-soft: #5a6575;
  --panel: rgba(255, 255, 255, 0.72);
  --line: rgba(28, 36, 48, 0.12);
  --stage: 280px;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(28, 36, 48, 0.12);
  --font-display: "Baloo 2", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dff7f0 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #ffe3d4 0%, transparent 50%),
    linear-gradient(160deg, #eefbf6 0%, #f7f3ea 45%, #e8f4ff 100%);
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.screen.active { display: block; }

.splash {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.1rem;
  padding: 2rem;
  text-align: center;
  animation: rise 0.7s ease both;
}

.splash.narrow { gap: 1.4rem; }

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.4rem, 12vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.brand.mini { font-size: clamp(1.8rem, 5vw, 2.4rem); }

.brand-pick { color: var(--sea); }
.brand-face { color: var(--coral); }
.brand-net {
  color: var(--sun);
  font-size: 0.42em;
  vertical-align: super;
  margin-left: 0.08em;
}

.tagline {
  margin: 0;
  max-width: 22rem;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.gender-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.splash .btn.primary { margin-top: 0.5rem; }

.btn {
  appearance: none;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 0.85rem 1.4rem;
  font: 600 1rem/1 var(--font-body);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn.ghost {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  backdrop-filter: blur(8px);
}

.btn.primary {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 10px 24px rgba(231, 111, 81, 0.28);
}

.btn.gender {
  min-width: 9rem;
  background: #fff;
  border-color: var(--line);
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.btn.gender:hover { border-color: var(--sea); }
.btn.small { padding: 0.55rem 1rem; font-size: 0.92rem; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.top-actions { display: flex; gap: 0.5rem; }

.editor {
  display: grid;
  grid-template-columns: auto minmax(260px, var(--stage)) minmax(220px, 1fr);
  gap: 1rem;
  padding: 0 1.25rem 1.5rem;
  align-items: start;
}

.nav-rail {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.4rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.nav-btn {
  width: 3.1rem;
  height: 3.1rem;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink-soft);
  font: 700 0.72rem/1.1 var(--font-display);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.nav-btn:hover { background: rgba(42, 157, 143, 0.12); color: var(--ink); }
.nav-btn.active {
  background: var(--sea);
  color: #fff;
  transform: scale(1.04);
}

.stage-wrap {
  display: grid;
  justify-items: center;
  gap: 0.7rem;
}

.stage {
  width: var(--stage);
  height: var(--stage);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: #fff;
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.3, 1) both;
}

#avatar {
  width: 100%;
  height: 100%;
  display: block;
}

.hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.tray {
  min-height: var(--stage);
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  animation: slide 0.4s ease both;
}

.tray-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  min-height: 1.6rem;
}

.swatch {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  padding: 0;
}

.swatch.active { outline: 2px solid var(--ink); outline-offset: 1px; }

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  background: #fff;
  color: var(--ink);
  font: 600 0.78rem/1 var(--font-body);
  cursor: pointer;
}

.chip.active {
  background: var(--sea);
  border-color: var(--sea);
  color: #fff;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.45rem;
  max-height: min(58vh, 480px);
  overflow: auto;
  padding-right: 0.2rem;
}

.thumb {
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #fff;
  padding: 0.25rem;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.thumb:hover { transform: translateY(-2px); }
.thumb.active { border-color: var(--coral); }

.thumb.none {
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 600;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: none; }
}

@keyframes slide {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 900px) {
  .editor {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .nav-rail {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }

  .tray { width: 100%; }
}
