:root {
  --bg-1: #6a5cff;
  --bg-2: #9d6bff;
  --bg-3: #ff7eb3;
  --card: #ffffff;
  --ink: #1f2233;
  --ink-soft: #6b7088;
  --line: #e9eaf3;
  --accent: #6a5cff;
  --accent-soft: #efeaff;
  --accent-ink: #4b3df0;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(60, 40, 120, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI",
    system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  padding: 28px 16px 48px;
}

.app {
  width: 100%;
  max-width: 920px;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  color: #fff;
  margin-bottom: 22px;
}
.hero__title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
}
.hero__emoji { filter: drop-shadow(0 3px 6px rgba(0,0,0,.2)); }
.hero__subtitle {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.92;
  font-weight: 500;
}

/* ---------- Panel ---------- */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  margin-bottom: 20px;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.preset {
  border: 1px solid var(--line);
  background: #fafafe;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.preset:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

.field { margin-bottom: 20px; }
.field__label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

/* ---------- Combo ---------- */
.combo {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.select-wrap { flex: 1; min-width: 0; }
.select-wrap__hint {
  display: block;
  font-size: 0.7rem;
  color: var(--ink-soft);
  margin-bottom: 4px;
  padding-left: 2px;
}
.select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7088' d='M6 8 0 0h12z'/%3E%3C/svg%3E") no-repeat right 12px center;
  padding: 12px 32px 12px 13px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s;
}
.select:focus { outline: none; border-color: var(--accent); }

.swap {
  flex: 0 0 auto;
  width: 42px;
  height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fafafe;
  color: var(--accent-ink);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.15s;
}
.swap:hover { background: var(--accent-soft); border-color: var(--accent); transform: rotate(180deg); }

/* ---------- Lengths ---------- */
.lengths {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.len-btn {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
}
.len-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.len-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 6px 14px rgba(106, 92, 255, 0.35);
}
.len-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  text-decoration: line-through;
}
.length-hint {
  margin: 9px 2px 0;
  font-size: 0.76rem;
  color: var(--ink-soft);
  min-height: 1em;
}

/* ---------- Generate ---------- */
.generate {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 1.08rem;
  font-weight: 800;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #6a5cff, #9d6bff);
  box-shadow: 0 10px 24px rgba(106, 92, 255, 0.4);
  transition: transform 0.1s, box-shadow 0.15s;
}
.generate:hover { box-shadow: 0 14px 30px rgba(106, 92, 255, 0.5); }
.generate:active { transform: scale(0.985); }

/* ---------- Results ---------- */
.results-section { text-align: center; }
.results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-content: center;
  min-height: 200px;
  padding: 16px;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
}
.results__empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #fff;
  margin: 0;
  padding: 8px;
}
.results__empty-title {
  margin: 0 0 6px;
  font-size: 1.02rem;
  font-weight: 700;
}
.results__empty-sub {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.85;
  font-weight: 500;
}
.nick {
  background: var(--card);
  border: none;
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(60, 40, 120, 0.12);
  transition: transform 0.12s, box-shadow 0.15s;
  font-family: inherit;
  animation: pop 0.32s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  word-break: keep-all;
  min-width: 0;
}
.nick:hover { transform: translateY(-3px); box-shadow: 0 14px 26px rgba(60, 40, 120, 0.2); }
.nick:active { transform: translateY(0) scale(0.97); }
.nick__copy { display: block; font-size: 0.66rem; color: var(--ink-soft); margin-top: 4px; font-weight: 600; }

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

.error-card {
  grid-column: 1 / -1;
  background: #fff;
  border-radius: 14px;
  padding: 22px 18px;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.error-card b { color: var(--accent-ink); }

.footer {
  text-align: center;
  color: #fff;
  margin-top: 28px;
}
.footer p { margin: 0; }
.footer__hint {
  font-size: 0.78rem;
  opacity: 0.82;
}
.footer__version {
  margin-top: 6px !important;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.6;
}

.hidden { display: none !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31, 34, 51, 0.95);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 380px) {
  .hero__title { font-size: 1.7rem; }
  .lengths { gap: 4px; }
  .len-btn { padding: 9px 0; font-size: 0.88rem; }
}

/* ---------- 히어로 예시 ---------- */
.hero__examples {
  margin: 12px 0 0;
  font-size: 0.82rem;
  color: #fff;
  opacity: 0.88;
  font-weight: 600;
}
.hero__examples b { font-weight: 800; }

/* ---------- 정보 섹션 (사용법/활용/FAQ) ---------- */
.info { margin-top: 28px; }
.section-title {
  text-align: center;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 14px;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}

/* 사용 방법 — 3단계 카드 */
.steps-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  counter-reset: step;
}
.steps-grid li {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px 11px;
  text-align: center;
}
.steps-grid li::before {
  counter-increment: step;
  content: counter(step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6a5cff, #9d6bff);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 10px;
}
.steps-grid p {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: #43485c;
  line-height: 1.45;
  word-break: keep-all;
}

/* 활용 — 그리드 */
.use-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}
.use-grid li {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(60, 40, 120, 0.1);
  padding: 13px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #43485c;
  word-break: keep-all;
}

/* FAQ — 한 장 카드, 행 구분선 */
.faq {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 18px;
}
.faq details {
  border-bottom: 1px solid var(--line);
  padding: 2px;
}
.faq details:last-child { border-bottom: none; }
.faq summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 24px 14px 0;
  list-style: none;
  position: relative;
  color: var(--ink);
  font-size: 0.92rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 2px;
  top: 12px;
  font-size: 1.2rem;
  color: var(--accent);
}
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 0 14px; color: #43485c; font-weight: 500; line-height: 1.65; }

@media (max-width: 380px) {
  .steps-grid p { font-size: 0.78rem; }
}

/* ---------- 푸터 내비게이션 ---------- */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin: 4px 0 8px;
}
.site-nav a {
  color: #fff;
  opacity: 0.92;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}
.site-nav a:hover { text-decoration: underline; }

/* ---------- 서브페이지 (소개/약관/방침/문의) ---------- */
.subhero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}
.subhero__brand {
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}
.subhero__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.subhero__nav a {
  color: #fff;
  opacity: 0.9;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}
.subhero__nav a:hover,
.subhero__nav a[aria-current="page"] { text-decoration: underline; opacity: 1; }

.doc {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  color: #43485c;
  line-height: 1.75;
  margin-bottom: 20px;
}
.doc h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 16px;
}
.doc h2 {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--ink);
  margin: 22px 0 9px;
}
.doc p { margin: 0 0 12px; }
.doc ul { margin: 0 0 14px; padding-left: 20px; }
.doc li { margin-bottom: 7px; }
.doc a { color: var(--accent-ink); font-weight: 600; }
.doc a:hover { text-decoration: underline; }
.doc strong { color: var(--ink); }
.doc__updated {
  margin-top: 22px !important;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.contact-email {
  font-size: 1.1rem;
  font-weight: 700;
}
.contact-email a { color: var(--accent-ink); }

/* ---------- 반응형 와이드 레이아웃 ---------- */
/* 결과 카드: 가용 폭에 따라 열 수 자동 (모바일 2열, 데스크톱 더 많이) */
.results { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
/* 닉네임이 채워지면 위쪽부터 정렬(스크롤 시 잘림 방지), 비어 있으면 가운데 */
.results:has(.nick) { align-content: start; }

/* 소개·약관 등 문서형 페이지는 읽기 좋은 좁은 폭 유지 */
.subpage .app { max-width: 760px; }

@media (min-width: 800px) {
  /* 입력(도구) + 결과를 좌우 2단으로, 두 박스 높이를 동일하게 맞춤 */
  .workspace {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 18px;
    align-items: stretch;
  }
  .workspace .panel { margin-bottom: 0; }

  /* 결과 박스를 옵션 박스 높이에 맞춤 */
  .results-section { position: relative; min-height: 0; }
  .results {
    position: absolute;
    inset: 0;
    overflow-y: auto;
  }
  /* 생성된 카드는 박스 높이를 균등 분배해 스크롤 없이 딱 맞게 채움 */
  .results:has(.nick) {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 1fr;
    overflow: hidden;
  }

  /* 히어로 설명 문구만 읽기 좋은 폭으로 가운데 정렬 */
  .hero__subtitle { max-width: 600px; margin-left: auto; margin-right: auto; }
  /* 정보 섹션(사용 방법 등)은 닉네임 생성 영역과 같은 폭으로 정렬 */
  .use-grid { grid-template-columns: repeat(3, 1fr); }
}
