:root {
  --bg: #FAFAFA;
  --pink: #FFB6C1;
  --lavender: #B19CD9;
  --ink: #2C2C2C;
  --ink-soft: #6b6b6b;
  --line: #ececec;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(44, 44, 44, .04), 0 8px 24px rgba(44, 44, 44, .06);
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
button { font-family: inherit; }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 24px 96px;
}

/* Hero */
.hero { text-align: center; margin-bottom: 36px; }
.hero-tag {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--lavender);
  background: rgba(177, 156, 217, .10);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.hero-title {
  margin: 0 0 14px;
  font-size: 40px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero-sub {
  margin: 0 auto;
  color: var(--ink-soft);
  max-width: 520px;
  font-size: 15px;
}

/* Card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* Composer */
.composer { margin-bottom: 32px; }
.composer-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 10px;
  letter-spacing: .01em;
}
.composer-row {
  display: flex;
  gap: 10px;
}
.composer-row input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.composer-row input:focus {
  border-color: var(--lavender);
  box-shadow: 0 0 0 4px rgba(177, 156, 217, .15);
}
.composer-row input:disabled { background: #fafafa; color: var(--ink-soft); }

.btn {
  font-size: 15px;
  font-weight: 600;
  padding: 14px 22px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  transition: transform .12s ease, opacity .15s ease, background .15s ease, color .15s ease, filter .15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--lavender));
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(177, 156, 217, .35);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.04); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #f3f3f3; }
.btn-danger-ghost {
  background: transparent;
  color: #c54a5e;
  border: 1px solid #f3d6dc;
}
.btn-danger-ghost:hover { background: #fdf2f5; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.chip {
  background: #f5f3fb;
  color: var(--lavender);
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: #ece6f8; }
.chip:active { transform: translateY(1px); }

/* Stage */
.stage {
  margin-bottom: 56px;
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage-empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 20px;
}
.stage-empty-art {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, var(--pink) 0%, transparent 55%),
    radial-gradient(circle at 70% 65%, var(--lavender) 0%, transparent 60%),
    #ffffff;
  opacity: .6;
  box-shadow: 0 8px 24px rgba(177, 156, 217, .15);
}
.stage-loading { text-align: center; }
.stage-loading p { color: var(--ink-soft); margin-top: 20px; }
.stage-loading-sub { font-size: 13px; color: var(--ink-soft); margin-top: 6px !important; opacity: .7; }
.pulse {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle, var(--pink) 0%, var(--lavender) 70%);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.88); opacity: 0.55; }
  50%      { transform: scale(1.06); opacity: 0.95; }
}

.stage-result {
  margin: 0;
  text-align: center;
  animation: fadeIn .6s ease both;
  width: 100%;
}
.stage-result img {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  box-shadow: var(--shadow);
  object-fit: cover;
  background: linear-gradient(135deg, #f5e8f0, #ece6f8);
  display: block;
  margin: 0 auto;
}
.stage-result figcaption {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.result-name { font-size: 20px; font-weight: 600; }
.result-hint { font-size: 13px; color: var(--lavender); }

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

/* Gallery */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.gallery-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}
.muted {
  color: var(--ink-soft);
  font-weight: 400;
  font-size: 15px;
  margin-left: 6px;
}
.gallery-empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 48px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}
.gallery-item {
  position: relative;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .22s ease, box-shadow .22s ease;
  animation: fadeIn .45s ease both;
}
.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 8px rgba(44, 44, 44, .06), 0 18px 36px rgba(177, 156, 217, .22);
}
.gallery-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #f5e8f0, #ece6f8);
}
.gallery-item .name {
  padding: 10px 12px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-item .del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .95);
  color: var(--ink);
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s, transform .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(44, 44, 44, .12);
}
.gallery-item:hover .del,
.gallery-item:focus-within .del { opacity: 1; }
.gallery-item .del:hover { background: #c54a5e; color: #fff; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .2s ease both;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(44, 44, 44, .55);
  backdrop-filter: blur(2px);
}
.modal-body {
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 22px;
  max-width: 620px;
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(44, 44, 44, .25);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, .95);
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(44, 44, 44, .12);
  z-index: 2;
}
.modal-close:hover { background: #f0f0f0; }
.modal-body img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 18px;
  background: linear-gradient(135deg, #f5e8f0, #ece6f8);
  display: block;
}
.modal-meta {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.modal-name { font-size: 18px; font-weight: 600; }
.modal-actions { display: flex; gap: 8px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
  animation: fadeIn .2s ease both;
  box-shadow: 0 8px 24px rgba(44, 44, 44, .2);
  max-width: 90vw;
  text-align: center;
}

@media (max-width: 640px) {
  .page { padding: 32px 16px 80px; }
  .hero-title { font-size: 30px; }
  .hero-sub { font-size: 14px; }
  .composer-row { flex-direction: column; }
  .composer-row .btn { width: 100%; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .stage { min-height: 280px; margin-bottom: 40px; }
  .stage-result img { max-width: 420px; }
}
