:root {
  --paper: #f3ead9;
  --paper-deep: #e9dcc3;
  --card: #fffdf6;
  --ink: #261b11;
  --ink-soft: #5f503d;
  --muted: #8b7a62;
  --line: #d9c8a9;
  --brand: #e04a26;
  --brand-deep: #b73517;
  --teal: #0f766e;
  --teal-deep: #0b5b55;
  --gold: #d99a2b;
  --danger: #b3372a;
  --shadow: 0 18px 50px rgba(74, 54, 26, .14);
  --radius: 18px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(224, 74, 38, .10), transparent 32%),
    radial-gradient(circle at 88% 20%, rgba(15, 118, 110, .10), transparent 30%),
    var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.serif {
  font-family: Georgia, "Songti SC", "STSong", "Noto Serif SC", serif;
}

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  font-weight: 700;
  font-size: 15px;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px) scale(.99);
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(224, 74, 38, .28);
}

.btn-primary:hover {
  background: var(--brand-deep);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, .7);
}

.btn-teal {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 118, 110, .22);
}

.btn-teal:hover {
  background: var(--teal-deep);
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: .55;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}

.badge-warm {
  background: rgba(224, 74, 38, .12);
  color: var(--brand-deep);
}

.badge-teal {
  background: rgba(15, 118, 110, .12);
  color: var(--teal-deep);
}

.badge-ink {
  background: rgba(38, 27, 17, .08);
  color: var(--ink-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  outline: none;
  transition: border .15s, box-shadow .15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(224, 74, 38, .14);
}

.card {
  background: var(--card);
  border: 1px solid rgba(217, 200, 169, .7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 1000;
  max-width: 90vw;
  font-size: 14px;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ============ Landing page ============ */
.landing {
  min-height: 100vh;
  padding-bottom: 92px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .02em;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  box-shadow: 0 6px 16px rgba(224, 74, 38, .3);
}

.hero {
  text-align: center;
  padding: 54px 0 40px;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: 30px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: repeating-linear-gradient(45deg, rgba(217, 154, 43, .18) 0 8px, transparent 8px 18px);
  pointer-events: none;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 246, .75);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-deep);
  margin-bottom: 24px;
}

.hero h1 {
  font-size: clamp(34px, 8vw, 64px);
  line-height: 1.15;
  letter-spacing: -.02em;
  max-width: 760px;
  margin: 0 auto 18px;
}

.hero h1 em {
  font-style: normal;
  color: var(--brand);
}

.hero-sub {
  max-width: 560px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 17px;
}

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 30px 0 6px;
}

.trust-strip span {
  background: rgba(255, 253, 246, .8);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.lead-grid {
  display: grid;
  gap: 18px;
  margin-top: 46px;
}

.lead-card {
  padding: 24px;
}

.lead-card .type-chip {
  font-size: 12px;
  font-weight: 800;
  color: var(--brand-deep);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.lead-card h3 {
  font-size: 21px;
  line-height: 1.35;
  margin: 10px 0 8px;
}

.lead-card p {
  color: var(--ink-soft);
  font-size: 14px;
}

.lead-card .free {
  display: inline-block;
  margin-top: 14px;
  font-weight: 800;
  color: var(--teal-deep);
  font-size: 14px;
}

.form-card {
  padding: 26px 22px;
  position: relative;
  overflow: hidden;
}

.form-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--gold), var(--teal));
}

.form-card h2 {
  font-size: 26px;
  line-height: 1.3;
  margin-bottom: 6px;
}

.form-card .form-sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 20px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  text-align: center;
}

.submit-wrap {
  margin-top: 18px;
}

.submit-wrap .btn {
  width: 100%;
  padding: 15px;
  font-size: 16px;
}

.success-box {
  text-align: center;
  padding: 26px 8px;
}

.success-box .ok {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 30px;
}

.success-box h3 {
  font-size: 22px;
  margin-bottom: 8px;
}

.success-box p {
  color: var(--ink-soft);
  font-size: 14px;
}

.landing-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 26px 0 10px;
}

.sticky-cta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(243, 234, 217, .92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.sticky-cta .btn {
  width: 100%;
  padding: 14px;
}

@media (min-width: 860px) {
  .landing {
    padding-bottom: 40px;
  }

  .hero {
    padding: 84px 0 56px;
  }

  .lead-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .form-card {
    padding: 34px;
  }

  .sticky-cta {
    display: none;
  }
}

/* ============ Console ============ */
.console {
  min-height: 100vh;
}

.console-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(243, 234, 217, .9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.console-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 0;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  margin-left: auto;
  background: rgba(255, 253, 246, .75);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.nav-tab {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.nav-tab.active {
  background: var(--ink);
  color: #fff;
}

.console-main {
  padding: 26px 0 60px;
}

.page {
  display: none;
  animation: fadeUp .35s ease both;
}

.page.active {
  display: block;
}

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

.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 22px;
}

.page-title h2 {
  font-size: 30px;
  line-height: 1.2;
}

.page-title p {
  color: var(--ink-soft);
  font-size: 14px;
  max-width: 640px;
}

.generator {
  padding: 24px;
  margin-bottom: 26px;
}

.gen-form {
  display: grid;
  gap: 14px;
}

.gen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}

.gen-actions .btn {
  flex: 1;
  min-width: 170px;
}

.prompt-preview {
  margin-top: 16px;
  border: 1px dashed var(--line);
  background: rgba(255, 253, 246, .6);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--ink-soft);
  white-space: pre-wrap;
  display: none;
}

.prompt-preview.show {
  display: block;
  animation: fadeUp .25s ease both;
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 26px 0 14px;
}

.results-head h3 {
  font-size: 20px;
}

.results-count {
  font-size: 13px;
  color: var(--ink-soft);
}

.template-grid {
  display: grid;
  gap: 16px;
}

.template-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeUp .4s ease both;
}

.tpl-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tpl-type {
  font-size: 12px;
  font-weight: 800;
  color: var(--brand-deep);
  letter-spacing: .05em;
}

.tpl-index {
  font-family: Georgia, serif;
  font-size: 26px;
  color: var(--line);
}

.template-card h4 {
  font-size: 18px;
  line-height: 1.4;
}

.pain-list {
  list-style: none;
  display: grid;
  gap: 7px;
}

.pain-list li {
  display: flex;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.pain-list li::before {
  content: "→";
  color: var(--brand);
  font-weight: 800;
}

.tpl-body {
  font-size: 13.5px;
  color: var(--ink-soft);
  border-left: 3px solid var(--line);
  padding-left: 12px;
  white-space: pre-wrap;
  max-height: 150px;
  overflow: auto;
}

.tpl-ver {
  display: inline-flex;
  gap: 4px;
  background: var(--paper-deep);
  border-radius: 999px;
  padding: 3px;
  align-self: flex-start;
}

.ver-btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: background .15s, color .15s;
}

.ver-btn.active {
  background: var(--ink);
  color: #fff;
}

.tpl-reply {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px dashed rgba(15, 118, 110, .45);
  background: rgba(15, 118, 110, .06);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--teal-deep);
}

.tpl-reply span {
  flex: none;
  font-weight: 800;
}

.tpl-reply p {
  flex: 1;
  min-width: 0;
  word-break: break-all;
}

.tpl-reply .btn {
  flex: none;
  min-width: 64px;
  padding: 6px 10px;
  font-size: 12px;
}

.tpl-cta {
  font-size: 13px;
  font-weight: 800;
  color: var(--teal-deep);
}

.tpl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.tpl-actions .btn {
  flex: 1;
  min-width: 120px;
  padding: 9px 14px;
  font-size: 13px;
}

@media (min-width: 860px) {
  .gen-form {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }

  .gen-actions {
    grid-column: 1 / -1;
  }

  .template-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  padding: 18px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.stat-card .stat-value {
  font-family: Georgia, serif;
  font-size: 34px;
  line-height: 1.2;
  margin-top: 4px;
}

.stat-card .stat-delta {
  font-size: 12px;
  color: var(--teal-deep);
  margin-top: 4px;
}

.dash-grid {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 20px;
}

.panel h3 {
  font-size: 17px;
  margin-bottom: 14px;
}

.source-row {
  display: grid;
  gap: 10px;
}

.source-item {
  display: grid;
  grid-template-columns: 86px 1fr 46px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.source-track {
  height: 10px;
  border-radius: 999px;
  background: var(--paper-deep);
  overflow: hidden;
}

.source-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--gold));
  transition: width .5s ease;
}

.source-item strong {
  text-align: right;
}

.lead-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.lead-table th,
.lead-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.lead-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.source-chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(217, 154, 43, .14);
  color: #8a6116;
}

.source-chip.douyin {
  background: rgba(38, 27, 17, .1);
  color: var(--ink-soft);
}

.source-chip.xiaohongshu {
  background: rgba(224, 74, 38, .12);
  color: var(--brand-deep);
}

.push-feed {
  display: grid;
  gap: 10px;
}

.push-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 246, .7);
}

.push-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  flex: none;
}

.push-item p {
  color: var(--ink-soft);
}

.push-item time {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 30px 10px;
}

@media (min-width: 860px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .dash-grid {
    grid-template-columns: 1fr 1fr;
  }

  .lead-table-wrap {
    overflow-x: auto;
  }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(38, 27, 17, .55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow: auto;
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .3);
  animation: fadeUp .25s ease both;
}

.modal h3 {
  font-size: 20px;
  margin-bottom: 6px;
}

.modal .modal-sub {
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 16px;
}

.poster-canvas {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1;
}

.settings-toggle {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: underline;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 4px;
}

.settings-box {
  margin-top: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px;
  display: none;
  gap: 12px;
}

.settings-box.show {
  display: grid;
}

.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1s infinite ease-in-out;
}

.loading-dots i:nth-child(2) {
  animation-delay: .15s;
}

.loading-dots i:nth-child(3) {
  animation-delay: .3s;
}

@keyframes blink {
  0%, 80%, 100% {
    opacity: .25;
  }
  40% {
    opacity: 1;
  }
}
