/* Light theme (default for every visitor). Every color in the product is one of these tokens. */
:root {
  --bg: #FCFDFC;
  --surface: #F4F7F5;
  --card: #FFFFFF;
  --alt: #E9F0ED;
  --ink: #142A2E;
  --body: #3C4B4F;
  --muted: #556468;
  --border: #DDE6E3;
  --primary: #235E73;
  --primary-hover: #143C4A;
  --on-primary: #FFFFFF;
  --accent: #3C8C6E;
  --accent-text: #2A6E56;
  --accent-tint: #E1F0E8;
  --blue-tint: #DBEAF0;
  --warm: #B85C38;
  --warm-text: #9E4425;
  --warm-tint: #F7E9E1;
  --focus: #235E73;
  --logo-inbound: #235E73;
  --logo-square: #3C8C6E;
  --hairline: rgba(20, 42, 46, 0.06);
  --card-shadow: 0 6px 20px rgba(20, 42, 46, 0.06);
  color-scheme: light;
}

/* Dark theme, set by the theme switch. */
:root[data-theme="dark"] {
  --bg: #0E2B33;
  --surface: #12343D;
  --card: #163A44;
  --alt: #1C4551;
  --ink: #E4EDEA;
  --body: #C7D6D2;
  --muted: #9DB5AE;
  --border: #2C5560;
  --primary: #8CC3D6;
  --primary-hover: #B1D8E5;
  --on-primary: #0E2B33;
  --accent: #4E9E85;
  --accent-text: #7CC4AC;
  --accent-tint: #17463F;
  --blue-tint: #1B4959;
  --warm: #E0936C;
  --warm-text: #F0B999;
  --warm-tint: #42312A;
  --focus: #8CC3D6;
  --logo-inbound: #E4EDEA;
  --logo-square: #4E9E85;
  --hairline: rgba(228, 237, 234, 0.08);
  --card-shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font: 400 16px/1.6 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.shell { max-width: 760px; margin: 0 auto; padding: 0 16px; }
main.shell { padding-top: 24px; padding-bottom: 64px; }

/* Header */
.site-header { border-bottom: 1px solid var(--hairline); }
.site-header .shell { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: inline-flex; align-items: center; min-height: 44px; }
.brand svg { display: block; height: 24px; width: auto; }
.wm-inbound { fill: var(--logo-inbound); }
.wm-square { fill: var(--logo-square); }
.product { color: var(--muted); font-size: 14px; }
.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.balance-pill {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}

/* Type */
h1, h2, h3 { margin: 0; color: var(--ink); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h1.hero { font-size: clamp(1.75rem, 6vw, 2.5rem); }
h2 { font-size: 1.1rem; }
p { margin: 0; }
.eyebrow {
  margin: 0 0 12px; color: var(--muted); font-size: 13px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.eyebrow::after { content: ''; display: block; width: 32px; height: 3px; margin-top: 8px; border-radius: 2px; background: var(--warm); }
.eyebrow.operator { color: var(--warm-text); }
.lead { margin-top: 12px; font-size: 1.0625rem; max-width: 60ch; }
.small { font-size: 0.875rem; }
.muted { color: var(--muted); }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* Layout helpers */
.section { margin-top: 32px; }
.section > h2 { margin-bottom: 12px; }
.gap { margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.row > input { flex: 1 1 140px; }

/* Cards and panels */
.card, .panel { padding: 16px; border: 1px solid var(--border); border-radius: 14px; }
.card { background: var(--card); box-shadow: var(--card-shadow); }
.panel { background: var(--surface); }
.card > :first-child, .panel > :first-child { margin-top: 0; }
.stat-label { color: var(--muted); font-size: 0.875rem; font-weight: 600; margin-top: 8px; }
.figure { margin-top: 4px; color: var(--ink); font-size: 2rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.note { margin-top: 16px; padding: 12px 16px; background: var(--blue-tint); color: var(--ink); border-radius: 10px; font-size: 0.9rem; font-weight: 600; }
.warn {
  margin-top: 12px; padding: 12px 16px; background: var(--warm-tint); color: var(--warm-text);
  border-left: 4px solid var(--warm); border-radius: 10px; font-size: 0.9rem; font-weight: 600;
}
.account-number {
  display: block; margin: 8px 0 12px; padding: 12px 16px; overflow-x: auto; white-space: nowrap;
  background: var(--bg); color: var(--ink); border: 1px dashed var(--border); border-radius: 14px;
  font-size: clamp(1.2rem, 5.6vw, 2rem); font-weight: 600; letter-spacing: 0.06em; word-spacing: 0.15em;
  font-variant-numeric: tabular-nums;
}

/* Forms */
label { display: block; margin: 16px 0 8px; color: var(--ink); font-size: 0.9rem; font-weight: 600; }
form > label:first-child, .card > label:first-child, .panel > label:first-child { margin-top: 0; }
input {
  width: 100%; min-width: 0; min-height: 44px; padding: 8px 12px; font: inherit;
  color: var(--ink); background: var(--card); border: 1px solid var(--border); border-radius: 10px;
}
input::placeholder { color: var(--muted); opacity: 1; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 24px;
  font: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2; text-align: center; text-decoration: none;
  color: var(--on-primary); background: var(--primary); border: 1px solid var(--primary); border-radius: 14px; cursor: pointer;
}
button:hover, .button:hover { color: var(--on-primary); background: var(--primary-hover); border-color: var(--primary-hover); }
button.secondary, .button.secondary { color: var(--primary); background: transparent; border-color: var(--border); }
button.secondary:hover, .button.secondary:hover { color: var(--primary-hover); background: var(--surface); border-color: var(--border); }
button.small, .button.small { padding: 8px 16px; font-size: 0.875rem; }
button:disabled { color: var(--muted); background: var(--alt); border-color: var(--border); cursor: not-allowed; }
button.block { display: flex; width: 100%; margin-top: 16px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[role="status"] { margin-top: 8px; font-size: 0.9rem; font-weight: 600; }
[role="status"]:empty { height: 0; margin: 0; overflow: hidden; }
[role="status"][data-state="ok"] { color: var(--accent-text); }
[role="status"][data-state="error"] { padding: 8px 12px; color: var(--warm-text); background: var(--warm-tint); border-radius: 8px; }
.hint { margin-top: 8px; color: var(--muted); font-size: 0.875rem; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 16px; }
.action-row .hint { margin-top: 0; }

/* Disclosure used as a link */
summary { min-height: 44px; display: flex; align-items: center; color: var(--primary); font-weight: 600; font-size: 0.9rem; text-decoration: underline; cursor: pointer; }
details form { margin-top: 4px; }
.fine-print { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; margin-top: 8px; }
.fine-print .hint { margin-top: 0; }
.fine-print details[open] { flex-basis: 100%; }
.fine-print summary { display: inline-flex; }

/* Numbered benefits */
.how { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: how; }
.how li { display: flex; gap: 12px; align-items: flex-start; counter-increment: how; }
.how li::before {
  content: counter(how); flex: none; width: 28px; height: 28px; line-height: 28px; text-align: center;
  color: var(--accent-text); background: var(--accent-tint); border-radius: 50%; font-size: 0.85rem; font-weight: 600;
}
.how strong { color: var(--ink); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
table { width: 100%; min-width: 380px; border-collapse: collapse; font-size: 0.875rem; }
th {
  padding: 8px 12px; text-align: left; white-space: nowrap; color: var(--muted); background: var(--surface);
  border-bottom: 1px solid var(--border); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
td { padding: 8px 12px; vertical-align: top; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
td.code { color: var(--ink); font-weight: 600; }
td.unused { color: var(--accent-text); font-weight: 600; }
tbody tr:nth-child(even) td { background: var(--alt); }

@media (max-width: 520px) {
  table { min-width: 0; }
  th, td { padding: 8px; }
  td.code { white-space: nowrap; }
  td { overflow-wrap: anywhere; }
  .row > button { flex: 1 1 100%; }
}

/* Set up */
.lead.setup-lead { margin-top: 8px; font-weight: 400; overflow-wrap: anywhere; }
.setup-fields { min-width: 0; border: 0; margin: 16px 0 0; padding: 0; }
.setup-fields legend { padding: 0; color: var(--ink); font-size: 0.9rem; font-weight: 600; }
.setup-fields > .muted { margin: 4px 0 8px; }
.setup-phrases { display: flex; flex-wrap: wrap; gap: 8px; }
.setup-phrase {
  display: flex; align-items: center; flex: 1 1 280px; min-width: 0; padding: 0 4px 0 12px;
  background: var(--blue-tint); border: 1px solid var(--border); border-radius: 999px;
}
.setup-phrase input { min-height: 44px; padding: 4px 0; border: 0; background: none; font-weight: 500; border-radius: 999px; }
.setup-phrase:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.setup-phrase input:focus-visible { outline: none; }
.setup-phrase button.setup-remove { flex: none; width: 44px; padding: 0; border: 0; border-radius: 50%; font-size: 1.25rem; }
.setup-add { margin-top: 8px; }
.setup-fields [role="status"]:empty, #setup-run-error:empty { padding: 0; }
.setup-competitors { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 8px; }
.setup-summary {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 24px; padding: 12px 16px; background: var(--alt); color: var(--ink);
  border: 1px solid var(--border); border-radius: 14px;
}

@media (max-width: 520px) {
  .setup-summary button { width: 100%; }
}

/* Report page, share page and past reports (owner: report) */
.report-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.report-head h1 { overflow-wrap: anywhere; }
.gap-small { margin-top: 4px; }
.share-box { margin-top: 12px; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.share-box .row { margin-top: 8px; align-items: center; }
.share-url { flex: 1 1 200px; min-width: 0; color: var(--ink); font-size: 0.875rem; font-weight: 600; overflow-wrap: anywhere; }
.headline {
  margin-top: 4px; color: var(--ink); font-size: clamp(1.5rem, 5.6vw, 2rem); font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums;
}
.card > p.gap { margin-top: 8px; }

/* Engine progress */
.eng { display: grid; grid-template-columns: 130px 1fr 110px; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--hairline); }
.eng b { color: var(--ink); }
.bar { height: 8px; overflow: hidden; background: var(--alt); border-radius: 4px; }
.bar i { display: block; width: var(--w, 0%); height: 100%; background: var(--accent); transition: width 0.5s; }
.bar i.asked { background: var(--primary); }
.bar i.failed { background: var(--warm); }
.st { font-size: 0.8rem; font-weight: 600; text-align: right; }
.st.asked { color: var(--primary); }
.st.answered { color: var(--accent-text); }
.st.failed { color: var(--warm-text); }

/* Trend chart */
.trend-wrap { overflow-x: auto; }
.trend { display: block; width: 100%; height: 120px; }
.trend-grid { stroke: var(--border); stroke-width: 1; }
.trend-axis { fill: var(--muted); font-size: 11px; }
.trend-value { fill: var(--ink); font-size: 11px; font-weight: 600; }
.trend-line { fill: none; stroke: var(--primary); stroke-width: 2; }
.trend-dot { fill: var(--card); stroke: var(--primary); stroke-width: 2; }
.trend-dot.current { fill: var(--accent); }

/* Brands */
.brands { padding: 12px 16px; }
.bh { display: grid; grid-template-columns: minmax(110px, 190px) 1fr 120px; gap: 8px 12px; align-items: center; padding: 4px 0; font-size: 0.9rem; }
.bh b { color: var(--ink); font-weight: 500; }
.bh.you, .bh.competitor { padding: 4px 8px; border-radius: 8px; }
.bh.you { background: var(--accent-tint); }
.bh.competitor { background: var(--warm-tint); }
.bh.you b, .bh.competitor b, .bh.you .count, .bh.competitor .count { color: var(--ink); font-weight: 600; }
.bh .bar { height: 12px; }
.bh .bar i { background: var(--primary); transition: none; }
.bh.you .bar i { background: var(--accent); }
.bh.competitor .bar i { background: var(--warm); }
.bh .count { color: var(--body); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; margin-left: 4px; padding: 1px 8px; border: 1px solid transparent; border-radius: 99px; font-size: 0.72rem; font-weight: 600; }
.tag.you { color: var(--accent-text); background: var(--accent-tint); border-color: var(--accent); }
.tag.competitor { color: var(--warm-text); background: var(--warm-tint); border-color: var(--warm); }

/* Report tables */
.report-table caption { padding: 8px 12px 0; color: var(--muted); font-size: 0.8rem; text-align: left; caption-side: top; }
.report-table tbody tr:nth-child(even) td { background: transparent; }
.report-table td.engine-cell { color: var(--ink); font-weight: 600; white-space: nowrap; }
.report-table td.figure-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-table td.domain-cell { overflow-wrap: anywhere; }
.past-reports td:first-child, .past-reports td:last-child, .past-reports td.figure-cell { white-space: nowrap; overflow-wrap: normal; }
.report-table td.yes { color: var(--accent-text); font-weight: 700; }
.report-table td.no { color: var(--muted); }
.report-table tbody tr.failrow td { color: var(--warm-text); background: var(--warm-tint); font-weight: 600; }
.report-table td.raw-cell { min-width: 120px; }
.report-table tbody tr.failrow td.raw-cell { background: var(--card); }
table.by-question { min-width: 600px; }
.position { display: inline-block; margin-right: 12px; white-space: nowrap; }
.position.failed { color: var(--warm-text); }
.position.not_mentioned { color: var(--muted); }
.rk span { display: inline-block; margin: 1px 2px 1px 0; padding: 0 6px; color: var(--ink); background: var(--alt); border-radius: 6px; }
.rk span.you { background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.rk span.competitor { background: var(--warm-tint); box-shadow: inset 0 0 0 1px var(--warm); }
.rk .tag { margin-left: 2px; padding: 0 6px; }

/* Question sections and raw answers */
details.ev { margin-top: 12px; }
details.ev > summary { display: list-item; list-style-position: inside; min-height: 44px; padding-top: 10px; color: var(--primary); text-decoration: none; font-size: 1rem; }
details.ev > summary .muted { font-weight: 400; }
details.ev > .table-wrap { margin-top: 8px; }
details.raw > summary { min-height: 44px; font-size: 0.85rem; }
details.raw .raw-open, details.raw[open] .raw-closed { display: none; }
details.raw[open] .raw-open { display: inline; }
.raw-body { min-width: 240px; padding: 8px 12px 12px; background: var(--surface); border-radius: 10px; font-size: 0.85rem; }
.raw-title { color: var(--ink); font-weight: 600; }
.raw-text { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.citations { margin: 8px 0 0; padding-left: 20px; overflow-wrap: anywhere; }

@media (max-width: 520px) {
  .eng { grid-template-columns: 1fr 70px; }
  .eng .bar { grid-column: 1 / -1; order: 3; }
  .bh { grid-template-columns: 1fr 110px; }
  .bh .bar { grid-column: 1 / -1; }
  .position { display: block; margin-right: 0; white-space: normal; }
}

/* Credit purchases */
.purchase-packs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(176px, 100%), 1fr));
  gap: 12px;
  margin-top: 10px;
}
#purchase-form { margin-top: 12px; }
