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

:root {
  --maroon: #6B1A2A;
  --maroon-dark: #4f1220;
  --gold: #C9A96E;
  --gold-light: #e2c99a;
  --bg: #f5f4f1;
  --surface: #ffffff;
  --border: #e2e0da;
  --text: #1a1a1a;
  --text-muted: #7a7672;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #4f1220 0%, #6B1A2A 50%, #8B2A3A 100%);
  background-size: 200% 200%;
  animation: headerShift 8s ease infinite;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
}

@keyframes headerShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.header-brand { display: flex; align-items: center; gap: 12px; }

.header-logo {
  width: 38px;
  height: 38px;
  background: var(--gold);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: var(--maroon-dark);
  letter-spacing: 0.5px;
  animation: logoPulse 3s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(201,169,110,0.4);
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,169,110,0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(201,169,110,0); }
}

.header-title { font-size: 16px; font-weight: 700; color: #fff; }
.header-sub   { font-size: 11px; color: rgba(255,255,255,0.5); }

.header-badge {
  font-size: 11px;
  color: var(--gold);
  background: rgba(201,169,110,0.15);
  border: 1px solid rgba(201,169,110,0.3);
  padding: 4px 12px;
  border-radius: 20px;
  animation: badgeFade 2s ease-in-out infinite alternate;
}

@keyframes badgeFade {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}

/* ─── Mode tab bar ───────────────────────────────────────────────────────── */
.mode-bar {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 60px;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.mode-btn {
  padding: 14px 24px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}

.mode-btn:hover { color: var(--text); }

.mode-btn.active {
  color: var(--maroon);
  border-bottom-color: var(--maroon);
}

/* ─── Mode panels ────────────────────────────────────────────────────────── */
.mode-panel { display: none; }
.mode-panel.active { display: block; }

/* ─── Page ───────────────────────────────────────────────────────────────── */
.page { max-width: 880px; margin: 0 auto; padding: 28px 20px 60px; }

/* ─── Blog bar ───────────────────────────────────────────────────────────── */
.blog-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.blog-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-blog-toggle {
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
}

.btn-blog-toggle:hover { border-color: var(--maroon); color: var(--maroon); }

.blog-post-card {
  display: flex;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s;
  margin-bottom: 6px;
  background: var(--bg);
}

.blog-post-card:hover { border-color: var(--gold); background: #fdfcf9; }
.blog-post-card.selected { border-color: var(--maroon); background: rgba(107,26,42,0.04); }

.blog-post-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.blog-post-thumb-placeholder {
  width: 64px;
  height: 64px;
  background: var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.blog-post-info { flex: 1; min-width: 0; }

.blog-post-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.blog-post-excerpt {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 4px;
}

.blog-post-date {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ─── Info banner ────────────────────────────────────────────────────────── */
.info-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeSlideDown 0.5s ease both;
}

/* ─── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.card:hover { box-shadow: var(--shadow-lg); }

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 20px; }

/* ─── Form elements ──────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.form-group { display: flex; flex-direction: column; gap: 4px; }

label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

select, input[type="text"] {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a7672' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(107,26,42,0.1);
}

/* ─── Platform toggles ───────────────────────────────────────────────────── */
.platforms-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

.platform-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: 20px;
  border: 2px solid;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.platform-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.2);
  opacity: 0;
  transition: opacity 0.2s;
}

.platform-btn:hover::after { opacity: 1; }

.platform-btn:not(.off):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.platform-btn.off {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
  opacity: 0.45;
  transform: none !important;
  box-shadow: none !important;
}

.platform-btn.just-activated {
  animation: platformPop 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes platformPop {
  0%   { transform: scale(0.9); }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ─── Generate button ────────────────────────────────────────────────────── */
.btn-generate {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
  background-size: 200% 200%;
  color: var(--maroon-dark);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
  animation: shimmerBtn 3s ease infinite;
  box-shadow: 0 4px 20px rgba(201,169,110,0.4);
}

@keyframes shimmerBtn {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.btn-generate::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -75%;
  width: 50%;
  height: 200%;
  background: rgba(255,255,255,0.25);
  transform: skewX(-20deg);
  animation: btnSweep 3s ease infinite;
}

@keyframes btnSweep {
  0%   { left: -75%; }
  40%, 100% { left: 125%; }
}

.btn-generate:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(201,169,110,0.5);
}

.btn-generate:active:not(:disabled) { transform: scale(0.98); }
.btn-generate:disabled { opacity: 0.6; cursor: not-allowed; animation: none; }
.btn-generate:disabled::before { display: none; }

/* ─── Loading state ──────────────────────────────────────────────────────── */
.loading-wrap {
  text-align: center;
  padding: 48px 24px;
}

.loading-orbs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.orb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--maroon);
  animation: orbBounce 1.2s ease-in-out infinite;
}

.orb:nth-child(1) { animation-delay: 0s;    background: var(--maroon); }
.orb:nth-child(2) { animation-delay: 0.15s; background: var(--gold); }
.orb:nth-child(3) { animation-delay: 0.3s;  background: var(--maroon); }
.orb:nth-child(4) { animation-delay: 0.45s; background: var(--gold); }
.orb:nth-child(5) { animation-delay: 0.6s;  background: var(--maroon); }

@keyframes orbBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%            { transform: scale(1.2); opacity: 1; }
}

.loading-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.loading-sub {
  font-size: 12px;
  color: var(--text-muted);
  animation: loadingSubFade 2s ease-in-out infinite alternate;
}

@keyframes loadingSubFade {
  from { opacity: 0.5; }
  to   { opacity: 1; }
}

/* ─── Results ────────────────────────────────────────────────────────────── */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.results-count { font-size: 13px; font-weight: 600; color: var(--text-muted); }

.btn-regen {
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
}

.btn-regen:hover { border-color: var(--maroon); color: var(--maroon); transform: translateY(-1px); }

/* ─── Ad result card slide-in ────────────────────────────────────────────── */
.ad-card-wrap {
  animation: cardSlideUp 0.45s cubic-bezier(0.22,1,0.36,1) both;
}

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

.ad-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.platform-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}

.platform-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50%       { transform: scale(1.4); opacity: 1; }
}

.ad-type-badge {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.ad-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.btn-copy {
  padding: 5px 13px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-copy:hover { border-color: var(--text-muted); transform: translateY(-1px); }
.btn-copy.copied { border-color: #27ae60; color: #27ae60; }

.btn-open {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: inline-block;
  position: relative;
  overflow: hidden;
}

.btn-open::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: rgba(255,255,255,0.2);
  transition: left 0.3s;
}

.btn-open:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.2); }
.btn-open:hover::after { left: 100%; }

/* ─── Typewriter text ────────────────────────────────────────────────────── */
.ad-textarea {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.65;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  cursor: text;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ad-textarea:focus {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(107,26,42,0.08);
}

.char-count { font-size: 11px; text-align: right; margin-top: 4px; color: var(--text-muted); }
.char-count.over { color: #c0392b; font-weight: 600; }

/* ─── Google Ads structured view ─────────────────────────────────────────── */
.google-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.google-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  transition: background 0.15s;
}

.google-row:hover { background: #eeece8; }
.google-row-num   { color: var(--text-muted); font-size: 11px; min-width: 18px; }
.google-row-text  { flex: 1; }
.google-row-count { font-size: 11px; white-space: nowrap; color: var(--text-muted); }
.google-row-count.over { color: #c0392b; font-weight: 600; }

/* ─── Success flash ──────────────────────────────────────────────────────── */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Error ──────────────────────────────────────────────────────────────── */
.error-msg {
  padding: 14px 16px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 13px;
  animation: fadeSlideDown 0.3s ease;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 32px 0 20px;
  font-size: 11px;
  color: var(--text-muted);
}
