/* ═══ Endo Blog Header Generator ═══ */

:root {
  --wine: #960F37;
  --wine-deep: #6e0a28;
  --wine-glow: #b8134580;
  --rose: #F5E0E7;
  --rose-pale: #faf3f6;
  --rose-mid: #edd0da;
  --cream: #fefbfc;
  --ink: #2a1520;
  --ink-soft: #5e4454;
  --ink-muted: #9a8591;
  --white: #ffffff;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

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

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Screens ─── */
.screen { display: none; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ─── Auth Screen ─── */
#auth-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--cream) 0%, var(--rose-pale) 40%, var(--rose) 100%);
}

.auth-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .45;
}

.auth-orb--1 {
  width: 500px; height: 500px;
  background: var(--rose);
  top: -120px; right: -80px;
  animation: drift 14s ease-in-out infinite alternate;
}

.auth-orb--2 {
  width: 350px; height: 350px;
  background: var(--wine-glow);
  bottom: -60px; left: -40px;
  animation: drift 18s ease-in-out infinite alternate-reverse;
}

.auth-orb--3 {
  width: 250px; height: 250px;
  background: var(--rose-mid);
  top: 40%; left: 50%;
  animation: drift 12s ease-in-out infinite alternate;
}

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -20px) scale(1.08); }
}

.auth-card {
  position: relative;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,.6);
  padding: 52px 44px 44px;
  border-radius: var(--radius-lg);
  width: min(420px, 90vw);
  text-align: center;
  box-shadow:
    0 1px 2px rgba(150,15,55,.04),
    0 8px 32px rgba(150,15,55,.06),
    0 24px 60px rgba(150,15,55,.04);
  animation: cardIn .6s var(--ease) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
}

.auth-brand { margin-bottom: 28px; }

.brand-dot {
  display: inline-block;
  width: 10px; height: 10px;
  background: var(--wine);
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.brand-dot--sm { width: 7px; height: 7px; margin-right: 5px; }

.brand-name {
  font-family: 'Comfortaa', sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--wine);
  letter-spacing: -.5px;
}

.brand-name--sm { font-size: 1.1rem; }

.auth-title {
  font-family: 'Comfortaa', sans-serif;
  font-weight: 700;
  font-size: 1.55rem;
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 10px;
}

.auth-desc {
  font-size: .85rem;
  color: var(--ink-muted);
  margin-bottom: 32px;
  line-height: 1.5;
}

.input-group {
  display: flex;
  gap: 0;
  border: 2px solid var(--rose-mid);
  border-radius: 50px;
  overflow: hidden;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
  background: var(--white);
}

.input-group:focus-within {
  border-color: var(--wine);
  box-shadow: 0 0 0 4px var(--wine-glow);
}

.input-group input {
  flex: 1;
  border: none;
  padding: 14px 22px;
  font-family: inherit;
  font-size: .92rem;
  outline: none;
  background: transparent;
  color: var(--ink);
}

.input-group input::placeholder { color: var(--ink-muted); }

.auth-submit {
  display: grid;
  place-items: center;
  width: 52px;
  border: none;
  background: var(--wine);
  color: var(--white);
  cursor: pointer;
  transition: background .2s var(--ease);
  flex-shrink: 0;
}

.auth-submit:hover { background: var(--wine-deep); }

/* ─── Top Bar ─── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(254,251,252,.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--rose-mid);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-sep {
  width: 1px;
  height: 18px;
  background: var(--rose-mid);
}

.topbar-label {
  font-size: .82rem;
  color: var(--ink-muted);
  font-weight: 400;
  letter-spacing: .2px;
}

/* ─── Main ─── */
#app-screen { flex-direction: column; min-height: 100vh; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 28px 80px;
  width: 100%;
}

/* ─── Section Header ─── */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

h2 {
  font-family: 'Comfortaa', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
}

.hint {
  font-size: .78rem;
  color: var(--ink-muted);
  margin-top: 3px;
}

.title-count {
  font-size: .72rem;
  font-weight: 500;
  color: var(--wine);
  background: var(--rose);
  padding: 4px 12px;
  border-radius: 50px;
  letter-spacing: .3px;
  white-space: nowrap;
}

/* ─── Textarea ─── */
.textarea-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(0,0,0,.03),
    0 4px 16px rgba(150,15,55,.04);
}

textarea {
  width: 100%;
  padding: 20px 22px;
  border: 2px solid var(--rose-mid);
  border-radius: var(--radius);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: .88rem;
  line-height: 1.85;
  color: var(--ink);
  background: var(--white);
  resize: vertical;
  outline: none;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}

textarea:focus {
  border-color: var(--wine);
  box-shadow: 0 0 0 4px var(--wine-glow);
}

/* ─── Actions ─── */
.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn-generate {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Comfortaa', sans-serif;
  font-weight: 600;
  font-size: .88rem;
  padding: 14px 32px;
  border: none;
  border-radius: 50px;
  background: var(--wine);
  color: var(--white);
  cursor: pointer;
  transition: all .25s var(--ease);
  box-shadow: 0 2px 8px rgba(150,15,55,.2), 0 8px 24px rgba(150,15,55,.12);
}

.btn-generate:hover:not(:disabled) {
  background: var(--wine-deep);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(150,15,55,.25), 0 12px 32px rgba(150,15,55,.15);
}

.btn-generate:active:not(:disabled) { transform: translateY(0); }

.btn-generate:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.btn-generate .btn-text,
.btn-generate .btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'Comfortaa', sans-serif;
  font-weight: 600;
  font-size: .78rem;
  padding: 10px 20px;
  border: 1.5px solid var(--rose-mid);
  border-radius: 50px;
  background: var(--white);
  color: var(--wine);
  cursor: pointer;
  transition: all .2s var(--ease);
}

.btn-outline:hover {
  background: var(--wine);
  border-color: var(--wine);
  color: var(--white);
}

.btn-outline svg { transition: stroke .2s; }
.btn-outline:hover svg { stroke: var(--white); }

/* ─── Spinner ─── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2.5px solid rgba(255,255,255,.25);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .55s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Progress ─── */
#progress-section { margin-top: 28px; }

.progress-track {
  width: 100%;
  height: 5px;
  background: var(--rose);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--wine), #d44a6e);
  border-radius: 3px;
  transition: width .5s var(--ease);
}

.progress-label {
  font-size: .78rem;
  color: var(--ink-muted);
  text-align: center;
  margin-top: 10px;
}

/* ─── Image Grid ─── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 22px;
}

.image-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--rose-mid);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
  animation: cardUp .5s var(--ease) both;
}

.image-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(150,15,55,.08), 0 2px 8px rgba(0,0,0,.04);
}

@keyframes cardUp {
  from { opacity: 0; transform: translateY(16px); }
}

.image-card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: var(--rose-pale);
}

.card-body { padding: 16px 18px 6px; }

.card-number {
  font-family: 'Comfortaa', sans-serif;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--wine);
  margin-bottom: 5px;
}

.card-title {
  font-size: .8rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.card-actions { padding: 10px 18px 16px; }

.card-actions .btn-outline {
  font-size: .7rem;
  padding: 7px 16px;
}

.card-error {
  aspect-ratio: 16/9;
  display: grid;
  place-items: center;
  background: var(--rose-pale);
  color: var(--wine);
  font-size: .8rem;
  padding: 20px;
  text-align: center;
}

/* ─── Prompt Details ─── */
.prompt-details { margin-top: 36px; }

.prompt-details summary {
  font-family: 'Comfortaa', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 10px 0;
  transition: color .2s;
}

.prompt-details summary:hover { color: var(--wine); }

.prompt-details pre {
  background: var(--white);
  border: 1px solid var(--rose-mid);
  border-radius: var(--radius);
  padding: 20px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: .8rem;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 8px;
}

/* ─── Error ─── */
.error {
  color: var(--wine);
  font-size: .8rem;
  margin-top: 12px;
}

/* ─── Spacing ─── */
section + section { margin-top: 36px; }
#results-section { margin-top: 36px; }

/* ─── Fade In ─── */
.fade-in {
  animation: fadeIn .5s var(--ease) both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
}

/* ─── Rate Limit ─── */
.rate-limit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #fff3f5;
  border: 1px solid var(--rose-mid);
  border-left: 4px solid var(--wine);
  border-radius: var(--radius-sm);
  font-size: .84rem;
  color: var(--ink-soft);
  margin-bottom: 24px;
  animation: fadeIn .3s var(--ease) both;
}

.rate-limit-banner svg { color: var(--wine); flex-shrink: 0; }

.remaining-badge {
  font-size: .72rem;
  font-weight: 500;
  color: var(--ink-muted);
  background: var(--rose-pale);
  padding: 6px 14px;
  border-radius: 50px;
  white-space: nowrap;
  align-self: center;
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .auth-card { padding: 40px 28px 36px; }
  .auth-title { font-size: 1.3rem; }
  main { padding: 28px 18px 60px; }
  .grid { grid-template-columns: 1fr; }
  .actions { justify-content: stretch; }
  .btn-generate { width: 100%; justify-content: center; }
  .section-header { flex-direction: column; align-items: flex-start; }
}
