:root {
  --bg: #f3f4f8;
  --bg-dot: #dde1ee;
  --ink: #14172b;
  --ink-soft: #5b6079;
  --ink-faint: #8b90a6;
  --card: #ffffff;
  --border: #e4e6f0;
  --accent: #3653ff;
  --accent-ink: #ffffff;
  --accent-soft: #ecefff;
  --good: #1c9a6c;
  --good-soft: #e6f6ef;
  --bad: #e5484d;
  --bad-soft: #fdecec;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px rgba(20, 23, 43, 0.08);
  --shadow-sm: 0 6px 16px rgba(20, 23, 43, 0.06);
  --font-serif: "Fraunces", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--bg-dot) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

/* ---------- Header ---------- */

.site-header {
  background: rgba(243, 244, 248, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
}

.topbar {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--ink);
}

.logo-mark-img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
}

.site-nav {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--accent);
}

/* ---------- Layout helpers ---------- */

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}

.eyebrow .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.eyebrow.center,
.section-title.center,
.section-sub.center {
  display: flex;
  justify-content: center;
  text-align: center;
}

.section-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.8rem, 3.2vw, 2.4rem);
  margin: 0 0 12px;
  line-height: 1.15;
}

.section-sub {
  color: var(--ink-soft);
  font-size: 1.02rem;
  max-width: 640px;
  margin: 0 auto 40px;
  line-height: 1.6;
}

section {
  padding: 72px 0;
}

/* ---------- Hero ---------- */

.hero {
  padding-top: 80px;
  padding-bottom: 40px;
}

.hero-inner {
  max-width: 760px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1.05;
  margin: 0 0 22px;
  letter-spacing: -0.01em;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero-sub {
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: 620px;
  line-height: 1.6;
  margin: 0;
}

/* ---------- Calculator card ---------- */

.calculator-section {
  padding-top: 20px;
}

.calc-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.calc-card-header h2 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--good-soft);
  color: var(--good);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
}

.live-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
}

.calc-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.calc-inputs {
  padding: 28px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field input,
.field select {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fbfbfd;
  color: var(--ink);
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: #fff;
}

.field-hint {
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin: 2px 0 0;
  line-height: 1.5;
}

.field-highlight {
  background: var(--accent-soft);
  border: 1px solid #d7deff;
  border-radius: var(--radius-sm);
  padding: 14px;
}

.field-highlight label {
  color: var(--ink);
}

.field-required {
  font-weight: 400;
  color: var(--accent);
}

.calc-divider {
  margin: 4px 0 -6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.calc-results {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.result-banner {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid #d7deff;
}

.result-banner p {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.result-banner.good {
  background: var(--good-soft);
  border-color: #bfe9d5;
}

.result-banner.bad {
  background: var(--bad-soft);
  border-color: #f6c8ca;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.result-stat {
  background: #fbfbfd;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.result-value {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
}

.result-stat-primary {
  grid-column: 1 / -1;
  background: var(--ink);
  border-color: var(--ink);
}

.result-stat-primary .result-label {
  color: #a7acc4;
}

.result-stat-primary .result-value {
  color: #fff;
  font-size: 2.1rem;
}

/* ---------- Campaign table ---------- */

.table-section {
  padding-top: 20px;
}

.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}

.table-card.compact {
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.target-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.target-field label {
  white-space: nowrap;
}

.target-field input {
  width: 90px;
  padding: 8px 10px;
  font-size: 0.95rem;
}

.target-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-faint);
  flex: 1;
  min-width: 220px;
}

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

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover {
  color: var(--accent);
}

.sort-arrow::after {
  content: "\21C5";
  display: inline-block;
  margin-left: 5px;
  font-size: 0.75em;
  opacity: 0.4;
}

th.sort-asc .sort-arrow::after {
  content: "\2191";
  opacity: 1;
  color: var(--accent);
}

th.sort-desc .sort-arrow::after {
  content: "\2193";
  opacity: 1;
  color: var(--accent);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.pill-good {
  background: var(--good-soft);
  color: var(--good);
}

.pill-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.pill-neutral {
  background: #f0f1f6;
  color: var(--ink-faint);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 720px;
}

.compare-table {
  min-width: 0;
}

th, td {
  text-align: left;
  padding: 10px 12px;
}

thead th {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 2px solid var(--border);
}

#campaign-rows tr {
  border-bottom: 1px solid var(--border);
}

#campaign-rows td input {
  width: 100%;
  min-width: 78px;
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  padding: 8px;
  border-radius: 8px;
  color: var(--ink);
}

#campaign-rows td input:focus {
  border-color: var(--accent);
  background: #fff;
  outline: none;
}

#campaign-rows .roas-cell,
.total-roas-cell {
  font-weight: 700;
}

#campaign-rows .roas-good {
  color: var(--good);
}

#campaign-rows .roas-bad {
  color: var(--bad);
}

.col-remove {
  width: 36px;
}

.remove-row-btn {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 6px;
  border-radius: 6px;
}

.remove-row-btn:hover {
  color: var(--bad);
  background: var(--bad-soft);
}

tfoot th, tfoot td {
  border-top: 2px solid var(--border);
  font-weight: 700;
  padding-top: 14px;
}

.compare-table thead th {
  border-bottom: 1px solid var(--border);
}

.compare-table tbody th,
.compare-table tbody td {
  border-bottom: 1px solid var(--border);
}

.compare-table tbody tr:last-child th,
.compare-table tbody tr:last-child td {
  border-bottom: none;
}

.table-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.table-note {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.85rem;
  margin-top: 16px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #2843e0;
  color: #fff;
}

.btn-ghost {
  background: none;
  border-color: transparent;
  color: var(--ink-faint);
}

.btn-ghost:hover {
  color: var(--bad);
  border-color: transparent;
}

/* ---------- Explainer ---------- */

.explainer-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: start;
}

.explainer p {
  color: var(--ink-soft);
  line-height: 1.7;
  font-size: 1rem;
}

.formula-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.formula-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

.formula {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Benchmarks ---------- */

.benchmark-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.benchmark-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.benchmark-platform {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.benchmark-value {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--accent);
}

.benchmark-detail {
  font-size: 0.85rem;
  color: var(--ink-faint);
  line-height: 1.5;
}

.benchmark-footnote {
  text-align: center;
  max-width: 680px;
  margin: 0 auto;
  color: var(--ink-faint);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ---------- FAQ ---------- */

.faq-list {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  text-align: left;
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  padding: 18px 20px;
  cursor: pointer;
}

.faq-icon {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--accent);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.faq-question[aria-expanded="true"] .faq-icon {
  transform: rotate(45deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.faq-answer p {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--ink-soft);
  line-height: 1.65;
  font-size: 0.95rem;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 24px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 32px;
}

.footer-col h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
}

.footer-col a {
  display: block;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.9rem;
  padding: 4px 0;
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-tagline {
  color: var(--ink-faint);
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 320px;
  margin: 0;
}

.footer-bottom {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--border);
}

.footer-copy,
.footer-legal {
  color: var(--ink-faint);
  font-size: 0.82rem;
  margin: 0;
}

.footer-legal a {
  text-decoration: none;
  color: var(--ink-faint);
}

.footer-legal a:hover {
  color: var(--accent);
}

.footer-legal-sep {
  margin: 0 8px;
}

/* ---------- Static content pages ---------- */

.static-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 24px 60px;
}

.static-page h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.static-page .updated {
  color: var(--ink-faint);
  font-size: 0.85rem;
  margin-bottom: 32px;
}

.static-page h2 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin-top: 36px;
}

.static-page p, .static-page li {
  color: var(--ink-soft);
  line-height: 1.7;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .calc-body {
    grid-template-columns: 1fr;
  }
  .calc-inputs {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .explainer-grid {
    grid-template-columns: 1fr;
  }
  .benchmark-grid {
    grid-template-columns: 1fr;
  }
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .result-grid {
    grid-template-columns: 1fr;
  }
  .site-nav {
    display: none;
  }
  .footer-inner {
    grid-template-columns: 1fr;
  }
  section {
    padding: 52px 0;
  }
}
