/* ── Design tokens (Toss-inspired) ───────────────────────────────── */
:root {
  --blue: #3182F6;
  --blue-dark: #1B64DA;
  --blue-light: #EAF2FF;
  --bg: #F2F4F6;
  --white: #FFFFFF;
  --gray-900: #191F28;
  --gray-700: #4E5968;
  --gray-500: #8B95A1;
  --gray-300: #E5E8EB;
  --gray-100: #F2F4F6;
  --red: #F04452;
  --red-light: #FFF1F1;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.06);
  --shadow-card-hover: 0 8px 24px rgba(15, 23, 42, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--gray-900);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ── Nav ──────────────────────────────────────────────────────────── */
.nav {
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
}
.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--gray-900);
}
.logo span { color: var(--blue); }
.nav-links { display: flex; gap: 24px; }
.nav-links a {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
}
.nav-links a:hover { color: var(--blue); }
.logout-form { margin: 0; }
.logout-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
  font-family: inherit;
}
.logout-btn:hover { color: var(--blue); }

/* ── Demo banner ──────────────────────────────────────────────────── */
.demo-banner {
  background: var(--blue-light);
  color: var(--blue-dark);
  font-size: 14px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.demo-banner .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}
.demo-banner code {
  background: rgba(255,255,255,0.6);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 13px;
}

/* ── Hero / search ────────────────────────────────────────────────── */
.hero { text-align: center; padding: 20px 0 48px; }
.eyebrow {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--blue);
  margin: 0 0 12px;
}
.hero h1 {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.35;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}
.hero-desc {
  font-size: 17px;
  color: var(--gray-700);
  margin: 0 auto 36px;
  max-width: 520px;
  line-height: 1.6;
}

.search-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
  max-width: 520px;
  margin: 0 auto;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.skip-link {
  display: inline-block;
  margin-top: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
}
.skip-link:hover { color: var(--blue); }

/* ── Forms ────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field label {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
}
.field input,
.field select,
.field textarea {
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s ease;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--blue); }
.field input::placeholder,
.field textarea::placeholder { color: var(--gray-500); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  font-weight: 700;
  font-size: 16px;
  padding: 16px 24px;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: var(--white); color: var(--gray-900); border: 1.5px solid var(--gray-300); }
.btn-ghost:hover { border-color: var(--gray-500); }
.btn-lg { width: 100%; padding: 18px 24px; font-size: 17px; }
.btn-sm { padding: 10px 16px; font-size: 14px; border-radius: 10px; }

/* ── Steps ────────────────────────────────────────────────────────── */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 8px;
}
.step-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
}
.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 16px;
}
.step-card h3 { font-size: 17px; font-weight: 800; margin: 0 0 8px; }
.step-card p { font-size: 14px; color: var(--gray-700); line-height: 1.55; margin: 0; }

/* ── Page header ──────────────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.back-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-500);
  margin-bottom: 12px;
}
.back-link:hover { color: var(--blue); }
.page-header h1 { font-size: 28px; font-weight: 800; margin: 0 0 8px; letter-spacing: -0.01em; }
.muted { color: var(--gray-500); font-size: 15px; margin: 0; }

.alert-error {
  background: var(--red-light);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  max-width: 520px;
  margin: 0 auto 20px;
}

/* ── Ad cards / grid ──────────────────────────────────────────────── */
.ad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.ad-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.ad-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.ad-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  margin-bottom: 4px;
}
.ad-card-top { display: flex; gap: 8px; }
.ad-page-name { font-size: 15px; font-weight: 700; color: var(--gray-500); margin: 0; }
.ad-title { font-size: 17px; font-weight: 800; margin: 0; line-height: 1.4; }
.ad-body {
  font-size: 14px;
  color: var(--gray-700);
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-card-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.badge-blue { background: var(--blue-light); color: var(--blue-dark); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

.empty-state {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--gray-700);
}

/* ── Generate layout ──────────────────────────────────────────────── */
.generate-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}
.ref-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 24px;
  border-left: 4px solid var(--blue);
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ref-card-empty { border-left-color: var(--gray-300); }
.ref-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  margin-bottom: 4px;
}
.ref-label { font-size: 12px; font-weight: 800; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
.ref-card h3 { font-size: 16px; font-weight: 800; margin: 4px 0 0; }

.form-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Loading overlay ──────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}
.loading-overlay.active { display: flex; }
.loading-overlay p { font-size: 15px; font-weight: 700; color: var(--gray-700); }
.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid var(--blue-light);
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result layout ────────────────────────────────────────────────── */
.result-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.result-image-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.result-image-card img { border-radius: var(--radius-md); width: 100%; }
.result-copy-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
}
.copy-block { margin-bottom: 24px; }
.copy-block:last-of-type { margin-bottom: 0; }
.copy-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
}
.copy-headline { font-size: 26px; font-weight: 800; margin: 0; line-height: 1.4; }
.copy-primary { font-size: 16px; line-height: 1.7; color: var(--gray-900); margin: 0; white-space: pre-line; }
.copy-desc { font-size: 14px; color: var(--gray-700); margin: 0; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }

/* ── History ──────────────────────────────────────────────────────── */
.section-title { font-size: 18px; font-weight: 800; margin: 32px 0 14px; }
.section-title:first-of-type { margin-top: 0; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background 0.15s ease;
}
.history-row:hover { background: var(--blue-light); }
.hr-title { font-size: 15px; font-weight: 700; }
.hr-meta { font-size: 13px; color: var(--gray-500); flex-shrink: 0; }

/* ── Footer ───────────────────────────────────────────────────────── */
.footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  border-top: 1px solid var(--gray-300);
}
.footer p { font-size: 13px; color: var(--gray-500); line-height: 1.6; margin: 24px 0 0; }

/* ── Login ────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo {
  font-size: 18px;
  font-weight: 800;
  color: var(--gray-900);
  margin: 0 0 28px;
}
.login-logo span { color: var(--blue); }
.login-card h1 { font-size: 22px; font-weight: 800; margin: 0 0 8px; letter-spacing: -0.01em; }
.login-card .muted { margin-bottom: 24px; }
.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: left;
}
.nav-user { font-size: 14px; font-weight: 600; color: var(--gray-500); }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert-success {
  background: var(--blue-light);
  color: var(--blue-dark);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 20px;
}

/* ── Admin settings ───────────────────────────────────────────────── */
.settings-card { max-width: 720px; }
.field textarea.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  min-height: 180px;
}
.field-hint { font-size: 13px; color: var(--gray-500); margin: -2px 0 0; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .hero h1 { font-size: 30px; }
  .steps { grid-template-columns: 1fr; }
  .generate-layout { grid-template-columns: 1fr; }
  .ref-card { position: static; }
  .result-layout { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .search-card, .form-card { padding: 24px; }
}
