/* RedTools Insights. Dark theme matches the app's guide pages (client/pages/ghost/*) and the
   brand tokens in client/global.css. */
/* Dark is the default. Light follows the plan in the app's redesign notes: warm off-white page,
   red darkened for contrast on light backgrounds. data-theme is set by the script in <head>. */
:root {
  --red: hsl(356 96% 50%);
  --red-dark: hsl(356 86% 42%);
  --radius: 8px;
  --radius-lg: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
  --bg: #000;
  --bg-deep: #030712;
  --header-bg: rgb(0 0 0 / 0.9);
  --surface: #111827;
  --line: #1f2937;
  --line-strong: #374151;
  --heading: #fff;
  --text: #d1d5db;
  --text-soft: #e5e7eb;
  --muted: #9ca3af;
  --faint: #6b7280;
  --fainter: #4b5563;
  --link: hsl(356 96% 68%);
  --hover-bg: #1f2937;
  --button: var(--red);
  --button-hover: var(--red-dark);
  --note-bg: hsl(190 30% 10%);
  --note-line: hsl(186 42% 46%);
  --redflag-bg: hsl(356 55% 9%);
  --redflag-line: hsl(356 80% 52%);
  --tip-bg: hsl(42 30% 9%);
  --tip-line: hsl(40 72% 52%);
  --data-bg: #111827;
  --data-line: hsl(215 14% 58%);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: hsl(30 25% 98%);
    --bg-deep: hsl(30 20% 94.5%);
    --header-bg: hsl(30 25% 98% / 0.92);
    --surface: #fff;
    --line: hsl(30 12% 87%);
    --line-strong: hsl(30 8% 74%);
    --heading: hsl(222 47% 11%);
    --text: hsl(222 18% 26%);
    --text-soft: hsl(222 25% 18%);
    --muted: hsl(215 14% 38%);
    --faint: hsl(215 12% 42%);
    --fainter: hsl(215 10% 48%);
    --link: hsl(356 70% 42%);
    --hover-bg: hsl(30 15% 92%);
    --button: hsl(356 80% 45%);
    --button-hover: hsl(356 80% 38%);
    --note-bg: hsl(190 45% 95%);
    --note-line: hsl(188 55% 34%);
    --redflag-bg: hsl(356 85% 97%);
    --redflag-line: hsl(356 70% 45%);
    --tip-bg: hsl(42 80% 95%);
    --tip-line: hsl(36 80% 40%);
    --data-bg: hsl(215 25% 96%);
    --data-line: hsl(215 16% 42%);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: hsl(30 25% 98%);
  --bg-deep: hsl(30 20% 94.5%);
  --header-bg: hsl(30 25% 98% / 0.92);
  --surface: #fff;
  --line: hsl(30 12% 87%);
  --line-strong: hsl(30 8% 74%);
  --heading: hsl(222 47% 11%);
  --text: hsl(222 18% 26%);
  --text-soft: hsl(222 25% 18%);
  --muted: hsl(215 14% 38%);
  --faint: hsl(215 12% 42%);
  --fainter: hsl(215 10% 48%);
  --link: hsl(356 70% 42%);
  --hover-bg: hsl(30 15% 92%);
  --button: hsl(356 80% 45%);
  --button-hover: hsl(356 80% 38%);
  --note-bg: hsl(190 45% 95%);
  --note-line: hsl(188 55% 34%);
  --redflag-bg: hsl(356 85% 97%);
  --redflag-line: hsl(356 70% 45%);
  --tip-bg: hsl(42 80% 95%);
  --tip-line: hsl(36 80% 40%);
  --data-bg: hsl(215 25% 96%);
  --data-line: hsl(215 16% 42%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 1rem/1.6 var(--font); }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { color: var(--heading); line-height: 1.2; letter-spacing: -0.01em; margin: 0; font-weight: 700; }
svg.icon { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 32px; }
.wrap.narrow { max-width: 768px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--heading); color: var(--bg); padding: 8px 12px; z-index: 60; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* Header, same as the app's Navigation */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 96px; }
.brand { border-radius: var(--radius); }
.brand img { height: 80px; width: auto; }
.site-header nav { display: flex; align-items: center; gap: 32px; }
.site-header nav a { color: var(--text); text-decoration: none; font-size: 0.875rem; font-weight: 500; transition: color 0.15s; }
.site-header nav a:hover { color: var(--heading); }
.site-header nav a.outline, .site-header nav a.pill { border-radius: 999px; padding: 9px 24px; color: var(--heading); }
.site-header nav a.pill, .site-header nav a.pill:hover { color: #fff; }
.site-header nav a.outline { border: 1px solid var(--line-strong); }
.site-header nav a.outline:hover { background: var(--hover-bg); }
.site-header nav a.pill { background: var(--button); }
.site-header nav a.pill:hover { background: var(--button-hover); }
@media (max-width: 860px) {
  .header-row { height: 72px; }
  .brand img { height: 56px; }
  .site-header nav { gap: 10px; }
  .site-header nav a:not(.outline):not(.pill) { display: none; }
  .site-header nav a.outline, .site-header nav a.pill { padding: 7px 16px; }
}

/* Logo per theme: white mark on dark, dark mark on light */
.logo-light { display: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .logo-dark { display: none; } :root:not([data-theme="dark"]) .logo-light { display: block; } }
:root[data-theme="light"] .logo-dark { display: none; }
:root[data-theme="light"] .logo-light { display: block; }

/* Theme menu: Light, Dark or System, stored as redtools-theme like the app's redesign plan */
.theme { position: relative; }
.theme-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--heading); cursor: pointer; }
.theme-button:hover { background: var(--hover-bg); }
.theme-button svg { width: 18px; height: 18px; }
.theme-button .icon-sun { display: none; }
:root[data-resolved-theme="light"] .theme-button .icon-sun { display: block; }
:root[data-resolved-theme="light"] .theme-button .icon-moon { display: none; }
.theme-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 150px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25); z-index: 60; }
.theme-menu[hidden] { display: none; }
.theme-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: 500 0.875rem var(--font); cursor: pointer; text-align: left; }
.theme-menu button:hover { background: var(--hover-bg); color: var(--heading); }
.theme-menu button[aria-checked="true"] { background: var(--hover-bg); color: var(--heading); }
.theme-menu svg { width: 16px; height: 16px; }

/* Banner for signed-in RedTools users who aren't subscribed */
.member-banner { background: var(--surface); border-bottom: 1px solid var(--line); }
.member-row { display: flex; align-items: center; justify-content: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; text-align: center; }
.member-row p { margin: 0; color: var(--heading); font-weight: 500; }
.member-row button { background: var(--button); color: #fff; border: 0; border-radius: 999px; padding: 7px 18px; font: 600 0.875rem var(--font); cursor: pointer; }
.member-row button:hover { background: var(--button-hover); }
.member-row button[hidden] { display: none; }

/* Footer, same as the app's Footer */
.site-footer { background: var(--bg); border-top: 1px solid var(--line); padding: 64px 0 16px; margin-top: 96px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.footer-brand img { height: 80px; width: auto; margin-bottom: 24px; }
.footer-brand p { color: var(--muted); font-size: 1.125rem; max-width: 28rem; margin: 0; }
.site-footer h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 24px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; color: var(--muted); }
.site-footer ul.small { color: var(--faint); font-size: 0.875rem; }
.site-footer ul a { text-decoration: none; transition: color 0.15s; }
.site-footer ul a:hover { color: var(--heading); }
.footer-bottom { border-top: 1px solid var(--line); margin-top: 48px; padding-top: 32px; text-align: center; color: var(--faint); font-size: 0.875rem; }
.footer-bottom p, .footer-bottom address { margin: 0; }
.footer-bottom .fine { margin-top: 8px; font-size: 11px; color: var(--fainter); font-style: normal; }
.footer-bottom .fine + .fine { margin-top: 4px; }
.footer-bottom a { text-decoration: none; }
.footer-bottom a:hover { color: var(--muted); }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1 / -1; } }

/* Shared bits */
.eyebrow { display: inline-block; margin: 0 0 10px; color: var(--link); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em; text-decoration: none; }
a.eyebrow:hover { text-decoration: underline; }
.meta { color: var(--faint); font-size: 0.875rem; margin: 0; }
.crumbs { margin: 0 0 14px; font-size: 0.8125rem; font-weight: 600; color: var(--faint); }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.crumbs li + li::before { content: "/"; margin-right: 8px; color: var(--line-strong); }
.crumbs a { color: var(--link); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* Index and tag pages */
.page-intro { background: linear-gradient(to bottom, var(--bg), var(--bg-deep)); border-bottom: 1px solid var(--line); padding: 72px 0 56px; margin-bottom: 56px; }
.page-intro h1 { font-size: clamp(2.25rem, 5vw, 3rem); }
.page-intro p { margin: 14px 0 0; max-width: 640px; color: var(--text); font-size: 1.125rem; }
.lead { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; padding: 24px; margin-bottom: 56px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.lead-image img, .card-image img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius); background: var(--line); }
.lead h2 { font-size: clamp(1.5rem, 3vw, 2.125rem); }
.lead h2 a, .card h2 a { text-decoration: none; }
.lead h2 a:hover, .card h2 a:hover { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.lead-body > p:not(.eyebrow):not(.meta) { margin: 14px 0 16px; font-size: 1.0625rem; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; transition: border-color 0.15s; }
.card:hover { border-color: var(--line-strong); }
.card-image img { border-radius: 0; }
.card-body { padding: 20px 22px 24px; display: flex; flex-direction: column; flex: 1; }
.card h2 { font-size: 1.1875rem; }
.card-body > p:not(.meta) { margin: 10px 0 14px; font-size: 0.9375rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-body .meta { margin-top: auto; }
@media (max-width: 1000px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) {
  .lead { grid-template-columns: 1fr; gap: 20px; padding: 16px; }
  .grid { grid-template-columns: 1fr; }
}
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 56px; font-size: 0.9375rem; color: var(--faint); }
.pager a { color: var(--heading); font-weight: 600; text-decoration: none; }
.pager a:hover { color: var(--link); }

/* Post */
.post-top { background: linear-gradient(to bottom, var(--bg), var(--bg-deep)); border-bottom: 1px solid var(--line); padding-bottom: 48px; }
.post-header { padding-top: 64px; }
.post-header h1 { font-size: clamp(2.25rem, 5vw, 3rem); }
.dek { font-size: 1.25rem; color: var(--text); margin: 18px 0 22px; line-height: 1.55; }
.cover { max-width: 1024px; margin-top: 40px; }
.cover img { width: 100%; border-radius: var(--radius-lg); background: var(--line); }
.cover figcaption { margin-top: 10px; font-size: 0.8125rem; color: var(--faint); text-align: center; }
.cover figcaption a { color: var(--faint); }
.post-body { padding-top: 48px; }

.summary { border: 2px solid var(--link); background: var(--surface); border-radius: var(--radius-lg); padding: 18px 22px; margin-bottom: 40px; }
.summary h2 { font-size: 0.8125rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--link); margin-bottom: 6px; }
.summary p { margin: 0; color: var(--text-soft); font-size: 1.0625rem; line-height: 1.65; }

.prose { font-size: 1.125rem; line-height: 1.75; }
.prose > * + * { margin-top: 1.25em; }
.prose p, .prose ul, .prose ol { margin-bottom: 0; }
.prose h2 { font-size: 1.75rem; margin-top: 2em; }
.prose h3 { font-size: 1.3125rem; margin-top: 1.75em; }
.prose h2 + *, .prose h3 + * { margin-top: 0.75em; }
.prose a { color: var(--link); text-underline-offset: 3px; }
.prose a:hover { color: var(--heading); }
.prose strong { color: var(--heading); }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.5em; }
.prose li::marker { color: var(--faint); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose blockquote { margin-left: 0; padding-left: 20px; border-left: 3px solid var(--line-strong); color: var(--text-soft); font-style: italic; }
.prose pre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow-x: auto; font-size: 0.875rem; white-space: pre-wrap; }
.prose code { font-size: 0.9em; }
.prose img { border-radius: var(--radius); }
.prose table { width: 100%; border-collapse: collapse; font-size: 1rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.prose th { color: var(--heading); border-bottom-color: var(--line-strong); }
.cta { text-align: center; }
.prose .button { display: inline-block; background: var(--button); color: #fff; border-radius: 999px; padding: 12px 28px; font-weight: 600; text-decoration: none; }
.prose .button:hover { background: var(--button-hover); color: #fff; }

/* Callouts. The four kinds and their labels are fixed in build.ts so they stay consistent. */
.callout { border-radius: var(--radius-lg); padding: 20px 24px; font-size: 1.0625rem; line-height: 1.65; border: 2px solid var(--callout-line); background: var(--callout-bg); }
.callout-label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 700; font-size: 1rem; color: var(--heading); }
.callout-label svg { color: var(--callout-line); }
.callout-title { margin: 4px 0 0; font-style: italic; color: var(--text-soft); }
.callout-body { margin-top: 10px; }
.callout-body > * + * { margin-top: 0.75em; }
.callout-body p, .callout-body ul, .callout-body ol { margin-bottom: 0; margin-top: 0; }
.callout-body > :first-child { margin-top: 0; }
.callout-note { --callout-bg: var(--note-bg); --callout-line: var(--note-line); }
.callout-redflag { --callout-bg: var(--redflag-bg); --callout-line: var(--redflag-line); }
.callout-tip { --callout-bg: var(--tip-bg); --callout-line: var(--tip-line); }
.callout-data { --callout-bg: var(--data-bg); --callout-line: var(--data-line); }

/* Series: box at the top of each part, pager at the end, and the series page */
.series-box { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-lg); padding: 18px 22px; margin-bottom: 32px; }
.series-box-label { margin: 0 0 10px; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.series-box-label a { color: var(--link); text-decoration: none; }
.series-box-label a:hover { text-decoration: underline; }
.series-box ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.series-box li { display: flex; gap: 12px; align-items: baseline; padding: 6px 8px; border-radius: var(--radius); font-size: 0.9375rem; line-height: 1.45; color: var(--text); }
.series-box li span { flex: none; width: 1.5em; font-weight: 700; color: var(--faint); font-variant-numeric: tabular-nums; }
.series-box li a { text-decoration: none; }
.series-box li a:hover { color: var(--heading); text-decoration: underline; }
.series-box li[aria-current] { background: var(--hover-bg); color: var(--heading); font-weight: 600; }
.series-box li[aria-current] span { color: var(--link); }
.series-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 48px; }
.series-pager a { display: block; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); text-decoration: none; color: var(--heading); font-weight: 600; line-height: 1.4; transition: border-color 0.15s; }
.series-pager a:hover { border-color: var(--line-strong); }
.series-pager span { display: block; margin-bottom: 4px; font-size: 0.8125rem; font-weight: 600; color: var(--link); }
.series-pager-next { text-align: right; grid-column: 2; }
@media (max-width: 560px) { .series-pager { grid-template-columns: 1fr; } .series-pager-next { grid-column: 1; text-align: left; } }
.series-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 24px; }
.series-item { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.series-item-image img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius); background: var(--line); }
.series-item h2 { font-size: 1.25rem; }
.series-item h2 a { text-decoration: none; }
.series-item h2 a:hover { text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 4px; }
.series-item p:not(.eyebrow):not(.meta) { margin: 8px 0 10px; color: var(--muted); font-size: 0.9375rem; }
.series-item .eyebrow { margin-bottom: 6px; }
@media (max-width: 640px) { .series-item { grid-template-columns: 1fr; } }

/* FAQ */
.faq { margin-top: 64px; padding-top: 40px; border-top: 1px solid var(--line); }
.faq > h2 { font-size: 1.75rem; margin-bottom: 8px; }
.faq-item { border-bottom: 1px solid var(--line); padding: 22px 0; }
.faq-item h3 { font-size: 1.1875rem; }
.faq-item h3 + * { margin-top: 10px; }
.faq-item > * + * { margin-top: 0.75em; }
.faq-item p { margin-bottom: 0; color: var(--text); font-size: 1.0625rem; }

.guides { margin-top: 48px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.guides h2 { font-size: 1.125rem; margin-bottom: 12px; }
.guides ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.guides a { color: var(--link); text-decoration: none; font-weight: 500; }
.guides a:hover { color: var(--heading); text-decoration: underline; }

.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 40px; }
.post-tags a { font-size: 0.875rem; text-decoration: none; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 14px; color: var(--text); }
.post-tags a:hover { background: var(--line); color: var(--heading); }
.related { margin-top: 80px; padding-top: 48px; border-top: 1px solid var(--line); }
.related > h2 { font-size: 1.5rem; margin-bottom: 28px; }

/* Sign-up, styled like the app's red call-to-action band */
.subscribe { margin-top: 64px; padding: 40px; background: linear-gradient(to right, var(--red), var(--red-dark)); border-radius: var(--radius-lg); color: #fff; }
.subscribe h2 { font-size: 1.625rem; }
.subscribe > p { margin: 8px 0 22px; color: hsl(356 100% 94%); max-width: 560px; }
.subscribe form { display: flex; flex-wrap: wrap; gap: 12px; }
.subscribe input[type="email"] { flex: 1 1 260px; min-width: 0; padding: 12px 18px; border: 1px solid rgb(255 255 255 / 0.35); border-radius: 999px; font: 1rem var(--font); color: #fff; background: rgb(0 0 0 / 0.2); }
.subscribe input[type="email"]::placeholder { color: hsl(356 100% 88%); }
.subscribe button { background: #fff; color: var(--red); border: 0; border-radius: 999px; padding: 12px 30px; font: 600 1rem var(--font); cursor: pointer; }
.subscribe button:hover { background: #f3f4f6; }
.subscribe .hp { position: absolute; left: -9999px; }
.subscribe :focus-visible { outline-color: #fff; }
.form-status { flex-basis: 100%; margin: 0; font-size: 0.9375rem; min-height: 1.5em; color: #fff; }
.form-status.error { color: #fff; font-weight: 600; }
@media (max-width: 520px) {
  .subscribe { padding: 28px 20px; }
  .subscribe button { width: 100%; }
}

.not-found { padding: 112px 16px 40px; }
.not-found p { font-size: 1.125rem; }
.not-found a { color: var(--link); }
