* { box-sizing: border-box; }

:root {
  --primary: #f43f5e;
  --primary-dark: #be123c;
  --secondary: #6d28d9;
  --accent: #f59e0b;
  --ink: #18181b;
  --muted: #6b7280;
  --bg: #fff8f1;
  --surface: #ffffff;
  --surface-soft: #fffaf5;
  --border: rgba(24, 24, 27, 0.28);
  --border-strong: rgba(24, 24, 27, 0.24);
  --shadow-soft: 0 10px 30px rgba(24, 24, 27, 0.08);
  --shadow-card: 0 12px 34px rgba(24, 24, 27, 0.11);
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(95% 70% at 10% -14%, rgba(245, 158, 11, 0.4), transparent 62%),
    radial-gradient(86% 65% at 96% -10%, rgba(109, 40, 217, 0.3), rgba(0, 0, 0, 0.04) 74%),
    var(--bg);
}

.site-header, .site-footer, .container {
  width: min(980px, 94vw);
  margin: 0 auto;
}

.site-header { padding: .5rem 0 .4rem; }
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .48rem .56rem;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 16px rgba(24, 24, 27, 0.06);
}
.brand-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.brand {
  color: #4c1d95;
  font-weight: 900;
  text-decoration: none;
  font-size: 1.06rem;
  letter-spacing: -.01em;
}
.tagline {
  color: var(--muted);
  margin-top: .2rem;
  font-size: .78rem;
  line-height: 1.2;
}
.user-nav {
  display: flex;
  gap: .34rem;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.user-nav::-webkit-scrollbar { display: none; }
.user-nav a,
.user-nav .nav-inline-form button {
  text-decoration: none;
  white-space: nowrap;
  font-size: .77rem;
  font-weight: 700;
  color: #3f3f46;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: .34rem .6rem;
  font-family: inherit;
  cursor: pointer;
}
.user-nav .nav-inline-form { margin: 0; }
.user-nav a[href="/upgrade"] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.container { padding-bottom: 1.6rem; }

.hero, .builder, .news-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: .92rem;
  margin-bottom: .72rem;
}

.home-layout {
  display: grid;
  gap: .62rem;
}

.home-hero {
  margin-bottom: 0;
}

.home-hero-copy {
  max-width: 60ch;
}

.home-hero-lead {
  margin-bottom: .42rem;
}

.home-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .36rem;
  align-items: center;
}
.home-hero-meta .creator-pill {
  margin: 0;
}

.home-builder {
  margin-bottom: 0;
}

.hero {
  background:
    radial-gradient(110% 100% at 0 0, rgba(245, 158, 11, 0.08), transparent 60%),
    var(--surface);
  padding: 1.08rem 1rem;
}

h1, h2, h3 {
  margin: 0 0 .52rem;
  line-height: 1.12;
  color: #111113;
  letter-spacing: -.01em;
}
h1 { font-size: clamp(1.38rem, 6.4vw, 2.1rem); font-weight: 900; }
h2 { font-size: clamp(1.18rem, 5vw, 1.6rem); font-weight: 850; }
h3 { font-size: 1rem; font-weight: 800; }
p { margin: 0 0 .66rem; line-height: 1.48; }

.hero h1 {
  font-size: clamp(1.55rem, 8.8vw, 2.35rem);
  margin-bottom: .42rem;
}
.hero p {
  font-size: .93rem;
  margin-bottom: .5rem;
}

.creator-pill {
  display: inline-block;
  padding: .38rem .65rem;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.32);
  background: rgba(245, 158, 11, 0.12);
  color: #78350f;
  font-size: .84rem;
}

.news-card-main { position: relative; }
.prompt-debug-link {
  position: absolute;
  top: .8rem;
  right: .92rem;
  background: transparent;
  border: 0;
  color: #4c1d95;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-size: .86rem;
}

.builder-actions-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: .52rem;
  margin-bottom: .54rem;
}

.slot-row {
  margin: .5rem 0;
  padding: .56rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}
.slot-row.is-generator-hidden {
  display: none;
}
.slot-row label {
  display: block;
  margin-bottom: .28rem;
  color: #4b5563;
  font-size: .84rem;
  font-weight: 700;
}
.slot-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .44rem;
}

select,
.text-input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.2;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: .64rem .7rem;
  background: #fff;
}
select:focus,
.text-input:focus {
  outline: none;
  border-color: rgba(109, 40, 217, 0.58);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.14);
}
select {
  padding-right: 2.1rem;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .5rem center;
  background-size: 1rem;
}

.btn {
  border: 0;
  border-radius: 11px;
  padding: .7rem .9rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 800;
  transition: transform .12s ease, box-shadow .18s ease, filter .16s ease;
}
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  /* box-shadow: 0 9px 20px rgba(190, 18, 60, 0.24); */
}
.btn.ghost {
  background: #fff;
  color: #27272a;
  border: 1px solid var(--border-strong);
}
.btn.mini {
  width: 2.74rem;
  height: 2.74rem;
  border-radius: 999px;
  border: 1px solid rgba(109, 40, 217, 0.3);
  background: linear-gradient(135deg, rgba(109, 40, 217, .14), rgba(245, 158, 11, .2));
  padding: 0;
}
.btn.full { width: 100%; margin-top: .62rem; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.hint { color: var(--muted); font-size: .89rem; line-height: 1.46; margin-top: 1rem;}
.alert {
  padding: .74rem .82rem;
  border-radius: 10px;
  margin-bottom: .7rem;
}
.alert-error {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid rgba(244, 63, 94, 0.27);
}
.alert-ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.news-label {
  display: inline-block;
  margin-bottom: .52rem;
  color: #92400e;
  background: rgba(245, 158, 11, 0.13);
  border: 1px solid rgba(245, 158, 11, 0.32);
  text-transform: uppercase;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .05em;
  border-radius: 999px;
  padding: .22rem .52rem;
}

.news-card-main h1 { font-size: clamp(1.45rem, 8vw, 2.25rem); }
#news-subheadline { line-height: 1.6; margin-bottom: .9rem; }

.image-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  margin: .75rem 0 .85rem;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-soft);
}
.image-wrap img { width: 100%; display: block; }

.news-body-html { line-height: 1.62; }
.news-body-html p { margin: 0 0 .72rem; }
.news-subhead {
  font-size: 1rem;
  font-weight: 800;
  margin: .9rem 0 .45rem;
  color: #27272a;
}

.news-card-main .author {
  margin-top: 1rem;
}
.author { color: #4b5563; font-size: .9rem; }
.author-split {
  margin-top: .92rem;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: .26rem .9rem;
  align-items: start;
}
.author-split .author-name { white-space: nowrap; }
.author-split .author-cta { min-width: 0; }

@media (max-width: 500px) {
  .author-split {
    grid-template-columns: minmax(0, 43%) minmax(0, 1fr);
  }
  .author-split .author-name {
    white-space: normal;
  }
}

.news-card-main.news-card-main-generating {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
}

.share-tools {
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: .72rem;
  margin: .82rem 0;
}
.share-title {
  margin: 0 0 .5rem;
  color: #374151;
  font-weight: 800;
}
.share-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .5rem;
  align-items: stretch;
}
.share-grid .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 2.64rem;
}
.share-icon {
  display: inline-flex;
  width: 1.16rem;
  height: 1.16rem;
  flex: 0 0 1.16rem;
  align-items: center;
  justify-content: center;
}
.share-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chain-box,
.followup-panel,
.editor-panel,
.usage-summary-box,
.plan-card,
.history-item,
.timeline-item {
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  box-shadow: var(--shadow-soft);
}

.chain-box {
  margin-top: .75rem;
  padding: .72rem;
}
.chain-list { margin: .3rem 0 0; padding-left: .95rem; }
.chain-list li { margin: .35rem 0; line-height: 1.5; }
.chain-list a,
.related-create-link { color: #4c1d95; }
.related-create-link {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
}

.followup-panel {
  margin-top: .82rem;
  padding: .8rem;
}
.followup-panel h2 { margin-top: 0; }
.viral-hooks {
  display: grid;
  grid-template-columns: 1fr;
  gap: .5rem;
  margin-top: .8rem;
}

.news-card-editor,
.news-card-saga > .followup-panel:first-child,
.news-card-saga > .chain-box:first-child,
.news-card-saga > .saga-full-link:first-child {
  margin-top: 0;
}

.editor-panel {
  margin-top: .8rem;
  padding: .8rem;
}
.editor-panel h2 { margin-top: 0; }
.editor-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: .5rem;
  margin-top: .7rem;
}
.editor-actions .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.viewer-note {
  margin-top: .86rem;
  color: var(--muted);
  font-size: .89rem;
}
.viewer-note--saga-card {
  padding-top: .7rem;
  border-top: 1px dashed var(--border-strong);
}

.usage-summary-box {
  padding: .86rem .95rem;
  margin-bottom: .78rem;
}
.usage-summary-title {
  margin: 0 0 .48rem;
  font-size: 1rem;
  font-weight: 800;
}
.usage-summary-main {
  margin: 0 0 .45rem;
  line-height: 1.42;
}
.usage-summary-main-secondary {
  margin-top: .3rem;
  margin-bottom: .5rem;
}
.usage-summary-topic {
  display: block;
  margin-bottom: .2rem;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #92400e;
}
.usage-summary-meta {
  margin: 0;
  font-size: .88rem;
  color: #4b5563;
  line-height: 1.42;
}
.usage-summary-meta + .usage-summary-meta { margin-top: .32rem; }
.usage-summary-gift {
  margin: .58rem 0 0;
  padding-top: .58rem;
  border-top: 1px solid var(--border);
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.42;
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .68rem;
}
.plan-card {
  padding: .84rem;
  display: flex;
  flex-direction: column;
}
.plan-card-current {
  border-color: rgba(109, 40, 217, 0.42);
  background: #fff;
}
.plan-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.plan-title-row h3 { margin: 0; }
.plan-current-badge {
  display: inline-block;
  margin-left: auto;
  padding: .16rem .52rem;
  border-radius: 999px;
  background: rgba(109, 40, 217, 0.12);
  color: #4c1d95;
  font-size: .76rem;
  font-weight: 700;
  white-space: nowrap;
}
.plan-tagline { margin: 0; color: #4b5563; }
.plan-features { margin: .46rem 0 0; padding-left: .94rem; color: #374151; }
.plan-card-footer { min-width: 0; margin-top: auto; }
.plan-cta { margin-top: auto; margin-bottom: 0; padding-top: .64rem; }
.plan-cta .btn.full { margin-top: 0; }
.plan-cta-note {
  margin: .35rem 0 0;
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}
.plan-card-highlight {
  border-color: rgba(76, 29, 149, 0.42);
  background: linear-gradient(180deg, rgba(109, 40, 217, 0.08), #fff 58%);
}

.comprar-plan-fallback {
  margin-top: .96rem;
  padding-top: .78rem;
  border-top: 1px solid var(--border);
}
.comprar-plan-fallback summary {
  cursor: pointer;
  color: #4b5563;
  font-size: .9rem;
}

.history-list,
.timeline-list { display: grid; gap: .62rem; }
.history-item,
.timeline-item {
  padding: .58rem;
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: .62rem;
}
.history-item img,
.timeline-item img {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--border);
}
.timeline-item-content > p,
.timeline-item h3 { margin: .18rem 0; }
.timeline-latest {
  border-color: rgba(245, 158, 11, 0.52);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.25), var(--shadow-soft);
}

.site-footer {
  color: var(--muted);
  font-size: .86rem;
  padding: .86rem 0 1.45rem;
}
.site-footer a { color: #4c1d95; }

.generation-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(24, 24, 27, 0.44);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.generation-overlay-card {
  width: min(420px, 92vw);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 18px 34px rgba(24, 24, 27, 0.3);
}

.generation-overlay-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto .62rem;
  border-radius: 999px;
  position: relative;
  --generation-progress: 0;
}
.generation-overlay-spinner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(#fff calc(var(--generation-progress) * 1turn), rgba(255, 255, 255, 0.26) 0turn);
}
.generation-overlay-spinner::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  background: var(--primary-dark);
}
.generation-overlay-spinner.is-finalizing::before {
  background: transparent;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: generation-spin .9s linear infinite;
}
.generation-overlay-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
}
.generation-overlay-subtitle {
  margin: .42rem 0 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: .92rem;
  line-height: 1.38;
}

body.prompt-debug-open { overflow: hidden; }
.prompt-debug-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 27, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1200;
}
.prompt-debug-overlay.is-open { display: flex; }
.prompt-debug-overlay[hidden] { display: none !important; }
.prompt-debug-modal {
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #fff;
  padding: .92rem;
}
.prompt-debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .9rem;
  margin-bottom: .7rem;
}
.prompt-debug-header h2 { margin: 0; font-size: 1.04rem; }
.prompt-debug-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
}
.prompt-debug-section + .prompt-debug-section { margin-top: .82rem; }
.prompt-debug-section-title {
  margin: 0 0 .36rem;
  font-weight: 700;
  color: #4b5563;
}
.prompt-debug-section pre {
  margin: 0;
  padding: .76rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fffbf7;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .84rem;
  line-height: 1.4;
}
.prompt-var-hit { color: #15803d; font-weight: 700; }
.prompt-var-miss { color: #b91c1c; font-weight: 700; }

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

@media (max-width: 470px) {
  .site-header { padding-top: .38rem; }
  .top-nav { border-radius: 10px; padding: .42rem .46rem; display: block;}
  .brand-block { display: block; }
  .tagline { display: inline-block; }
}
@media (max-width: 420px) {
  .site-header { padding-top: .38rem; }
  .hero { padding: .92rem; }
  .hero h1 {
    line-height: 1.02;
  }
  .hero p {
    font-size: .88rem;
    line-height: 1.35;
  }
  .home-layout { gap: .52rem; }
  .home-hero {
    padding: .82rem .86rem;
  }
  .home-hero-lead {
    margin-bottom: .36rem;
    max-width: 40ch;
  }
  .home-hero-meta {
    gap: .3rem;
  }
  .home-hero-meta .creator-pill {
    font-size: .8rem;
    padding: .3rem .56rem;
  }
  .home-builder .slot-row {
    margin: .42rem 0;
    padding: .48rem;
  }
}

@media (max-width: 360px) {
  .tagline { display: none; }
  .user-nav {margin-top: .6rem;}
}

@media (min-width: 640px) {
  .site-header { padding: .62rem 0 .52rem; }
  .top-nav { border-radius: 14px; padding: .6rem .68rem; }
  .brand { font-size: 1.14rem; }
  .user-nav a,
  .user-nav .nav-inline-form button { font-size: .8rem; padding: .38rem .68rem; }
  .container { padding-bottom: 1.8rem; }
  .home-layout { gap: .74rem; }

  .hero, .builder, .news-card {
    padding: 1.08rem;
    margin-bottom: .86rem;
  }
  .builder-actions-top { grid-template-columns: 1fr 1fr; }
  .slot-row { padding: .62rem; }
  .share-grid { grid-template-columns: 1fr 1fr; }
  .viral-hooks { grid-template-columns: 1fr 1fr; }
  .editor-actions { grid-template-columns: 1fr 1fr; }
  .history-item, .timeline-item { grid-template-columns: 92px 1fr; }
  .history-item img, .timeline-item img {
    width: 92px;
    height: 92px;
  }
}

@media (min-width: 768px) {
  .plan-grid { grid-template-columns: repeat(3, 1fr); }
  .share-grid { grid-template-columns: repeat(3, 1fr); }
  .editor-actions { grid-template-columns: repeat(3, 1fr); }
}
