:root {
  --bg-0: #e8efe9;
  --bg-1: #d5e4dc;
  --bg-2: #c3d7ce;
  --ink: #1a2420;
  --ink-soft: #4a5c54;
  --ink-faint: #7a8f85;
  --line: rgba(26, 36, 32, 0.12);
  --accent: #1f6f5b;
  --accent-deep: #145344;
  --surface: rgba(255, 255, 255, 0.38);
  --surface-strong: rgba(255, 255, 255, 0.55);
  --danger: #8b3a3a;
  --radius: 18px;
  --font-display: "Syne", sans-serif;
  --font-body: "Outfit", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow-soft: 0 18px 40px rgba(26, 36, 32, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 12% -10%, #f4f8f5 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 8%, #cfe0d6 0%, transparent 50%),
    radial-gradient(ellipse 60% 45% at 50% 110%, #b9d0c4 0%, transparent 55%),
    linear-gradient(165deg, var(--bg-0), var(--bg-1) 48%, var(--bg-2));
  animation: drift 18s ease-in-out infinite alternate;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  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='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: soft-light;
}

@keyframes drift {
  from {
    transform: scale(1) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.04) translate3d(-1.5%, 1%, 0);
  }
}

.app {
  width: min(100%, 440px);
  margin: 0 auto;
  min-height: 100dvh;
  padding:
    calc(28px + var(--safe-top))
    22px
    calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  padding-top: 8px;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.4rem, 14vw, 4.4rem);
  letter-spacing: -0.055em;
  line-height: 0.9;
  color: var(--ink);
}

.brand__tag {
  margin: 10px 0 0;
  font-size: 1.05rem;
  font-weight: 300;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
}

.compose {
  animation: rise 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.06s both;
}

.compose__form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.compose__input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
  padding: 16px 18px;
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.compose__input::placeholder {
  color: var(--ink-faint);
}

.compose__input:focus {
  border-color: rgba(31, 111, 91, 0.45);
  background: var(--surface-strong);
  box-shadow: 0 0 0 4px rgba(31, 111, 91, 0.1);
}

.compose__add {
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 16px;
  background: var(--ink);
  color: #f3f7f4;
  font-size: 1.7rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.compose__add:active {
  transform: scale(0.94);
  background: var(--accent-deep);
}

.pool {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.pool__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.pool__clear {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--danger);
  cursor: pointer;
  opacity: 0.85;
}

.pool__clear:active {
  opacity: 1;
}

.pool__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pool__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.98rem;
  font-weight: 400;
  color: var(--ink);
  animation: pop 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.pool__item.is-leaving {
  animation: leave 0.25s ease forwards;
}

.pool__word {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool__remove {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(26, 36, 32, 0.08);
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.pool__remove:active {
  background: rgba(139, 58, 58, 0.15);
  color: var(--danger);
}

.pool__empty {
  margin: 8px 0 0;
  color: var(--ink-faint);
  font-weight: 300;
  font-size: 0.98rem;
}

.pool__empty[hidden],
.pool__clear[hidden] {
  display: none;
}

.stage {
  text-align: center;
  padding: 18px 8px 6px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  animation: rise 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both;
}

.stage__label {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.stage__word {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 9vw, 2.8rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
  min-height: 1.2em;
  transition: color 0.25s ease;
}

.stage.is-spinning .stage__word {
  color: var(--ink-soft);
}

.stage.is-revealed .stage__word {
  color: var(--accent);
  animation: reveal 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.actions {
  padding-top: 4px;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.18s both;
}

.draft-btn {
  width: 100%;
  border: none;
  border-radius: 22px;
  padding: 20px 24px;
  background: var(--accent);
  color: #f4faf7;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.draft-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  box-shadow: none;
}

.draft-btn:not(:disabled):active {
  transform: scale(0.975);
  background: var(--accent-deep);
}

.draft-btn.is-busy {
  pointer-events: none;
  opacity: 0.85;
}

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

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

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.88) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes leave {
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes reveal {
  0% {
    opacity: 0.4;
    transform: scale(0.92) translateY(8px);
    filter: blur(4px);
  }
  60% {
    opacity: 1;
    transform: scale(1.04) translateY(0);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .atmosphere,
  .brand,
  .compose,
  .pool,
  .stage,
  .actions,
  .pool__item,
  .stage.is-revealed .stage__word {
    animation: none !important;
  }
}
