/* FreeCharting shared styles: tokens, reset, buttons, site chrome, landing, docs. */

:root {
  /* Light surfaces are soft greys rather than pure white, which was glaring. */
  --bg: #eef0f4;
  --bg-2: #e6e9ef;
  --panel: #f7f8fa;
  --panel-2: #eceef3;
  --chart-bg: #f4f5f8;
  --border: #d8dce5;
  --border-strong: #c2c8d4;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #5b6478;
  --accent: #3f5af0;
  --accent-hover: #3550e0;
  --accent-soft: rgba(63, 90, 240, 0.1);
  --accent-text: #ffffff;
  --up: #089981;
  --down: #f23645;
  /* Pill text: a shade darker than accent/up so it stays readable on the pill's tint. */
  --pill-accent: #3550e0;
  --pill-green: #06705f;
  --pill-red: #c01f2d;
  --pill-gold: #7d5900;
  --warn-bg: #fff7e6;
  --warn-border: #f5d48a;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --radius-sm: 7px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0e14;
  --bg-2: #0f131b;
  --panel: #131722;
  --panel-2: #181d2a;
  --chart-bg: #131722;
  --border: #232838;
  --border-strong: #2f364a;
  --text: #e6e9f0;
  --text-2: #c3c9d6;
  --muted: #8a93a6;
  --accent: #6d85ff;
  --accent-hover: #8298ff;
  --accent-soft: rgba(109, 133, 255, 0.14);
  --accent-text: #0b0e14;
  --pill-accent: var(--accent);
  --pill-green: #22b39a;
  --pill-red: #ff5c69;
  --pill-gold: #f0b429;
  --warn-bg: rgba(245, 180, 60, 0.08);
  --warn-border: rgba(245, 180, 60, 0.35);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
/* Elements hidden with the hidden attribute stay hidden even if a class sets display. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Links inside running text are underlined so they don't rely on colour alone. */
main p a:not([class]) { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
code, kbd { font-family: var(--mono); font-size: 0.88em; }
code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.4em;
  white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.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;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }

/* Theme toggle icons */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text);
  font: 500 14px/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: var(--radius); }
.btn-icon { width: 38px; padding: 0; }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--down); }
.btn-danger-ghost:hover { background: rgba(242, 54, 69, 0.08); }
.link {
  border: 0; background: none; padding: 0; font: inherit;
  color: var(--accent); cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- site header */

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: 1160px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 28px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { color: var(--text-2); font-weight: 500; font-size: 14px; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); text-decoration: none; }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.nav-toggle { display: none; }

@media (max-width: 760px) {
  .nav { gap: 12px; }
  .nav-toggle { display: inline-grid; }
  .nav-links {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border); padding: 8px 20px 16px;
  }
  .nav-links a { padding: 10px 0; font-size: 16px; }
  body.nav-open .nav-links { display: flex; }
  .nav-actions .btn-primary { display: none; }
}

/* ---------------------------------------------------------------- page layout */

.container { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
section { padding: 72px 0; }
.section-head { max-width: 680px; margin: 0 0 36px; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 34px); }
.section-head p { color: var(--muted); font-size: 17px; }
.eyebrow {
  display: inline-block; margin-bottom: 14px;
  color: var(--accent); font-weight: 600; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase;
}
/* A quieter second line under an eyebrow (the home page's cat joke). */
.eyebrow-aside { display: block; margin-top: 4px; color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none; }

/* ---------------------------------------------------------------- hero */

.hero { padding: 64px 0 40px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -30% -10% auto; height: 520px; z-index: -1;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-soft), transparent 65%);
}
.hero-inner { text-align: center; max-width: 820px; margin: 0 auto; }
.hero h1 { font-size: clamp(34px, 6vw, 58px); letter-spacing: -0.035em; margin-bottom: 18px; }
.hero h1 .grad { color: var(--text-2); }
.hero .lede { font-size: clamp(16px, 2.2vw, 19px); color: var(--muted); max-width: 640px; margin: 0 auto 28px; }
.hero-ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-note { margin-top: 16px; font-size: 13px; color: var(--muted); }

.preview {
  margin: 48px auto 0; max-width: 1080px;
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  background: var(--chart-bg); box-shadow: var(--shadow);
}
.preview-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted);
}
.preview-bar b { color: var(--text); font-size: 14px; }
.preview-dots { display: flex; gap: 6px; margin-right: 6px; }
.preview-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.preview-live { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.preview-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--up); }
.preview-live.is-delayed::before { background: var(--muted); }
#preview-chart { height: clamp(280px, 42vw, 440px); }
#preview-chart.is-static { cursor: pointer; }
#preview-chart.is-static > * { pointer-events: none; }
.preview-fallback { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- features */

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature {
  padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel);
}
.feature-icon {
  width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 14px;
}
.feature h3 { font-size: 16px; margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: 14px; margin: 0; }
@media (max-width: 900px) { .features { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 580px) { .features { grid-template-columns: 1fr; } }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; counter-reset: step; }
.step { padding: 22px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--border); }
.step::before {
  counter-increment: step; content: counter(step);
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 14px; margin-bottom: 14px;
}
.step h3 { font-size: 16px; }
.step p { color: var(--muted); font-size: 14px; margin: 0; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }

.alt { background: var(--bg-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
td b { color: var(--text); }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--pill-accent); white-space: nowrap;
}
.pill-green { background: rgba(8, 153, 129, 0.12); color: var(--pill-green); }
.pill-no { background: var(--panel-2); color: var(--muted); }
.broker-matrix td:first-child { white-space: nowrap; }
.broker-matrix td { vertical-align: middle; }
.pill-paid { background: rgba(224, 161, 0, 0.14); color: #7d5900; }
:root[data-theme="dark"] .pill-paid { color: #f0b429; }
a.pill:hover { text-decoration: none; filter: brightness(1.1); }

/* ---------------------------------------------------------------- CTA + footer */

.cta {
  text-align: center; padding: 48px 24px; border-radius: 16px;
  border: 1px solid var(--border); background: linear-gradient(180deg, var(--accent-soft), transparent);
}
.cta h2 { font-size: clamp(24px, 3.2vw, 32px); }
.cta p { color: var(--muted); }

.site-footer { border-top: 1px solid var(--border); padding: 44px 0 44px; color: var(--muted); font-size: 13px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.footer-brand p { margin: 10px 0 0; max-width: 260px; }
.footer-col { display: flex; flex-direction: column; gap: 8px; }
.footer-col h2 { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text); margin: 0 0 4px; }
.footer-col a { color: var(--text-2); }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1 / -1; } }
.disclaimer { margin-top: 20px; max-width: 820px; }

/* ---------------------------------------------------------------- docs (API key guide) */

.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; padding: 48px 20px 80px; max-width: 1160px; margin: 0 auto; }
.toc { position: sticky; top: 84px; align-self: start; font-size: 14px; }
.toc h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 5px 0 5px 14px; margin-left: -1px; color: var(--text-2); border-left: 2px solid transparent; }
.toc a:hover { color: var(--text); border-left-color: var(--border-strong); text-decoration: none; }
.toc .sub a { padding-left: 26px; font-size: 13px; color: var(--muted); }
.prose { max-width: 760px; }
.prose h1 { font-size: clamp(30px, 4.5vw, 42px); letter-spacing: -0.03em; }
.prose .lede { font-size: 18px; color: var(--muted); }
.prose h2 { font-size: 26px; margin-top: 56px; padding-top: 8px; scroll-margin-top: 80px; }
.prose h3 { font-size: 19px; margin-top: 32px; scroll-margin-top: 80px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 1em; }
.prose li { margin-bottom: 6px; }
.prose li::marker { color: var(--muted); }
.callout {
  padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-2); margin: 20px 0; font-size: 14px;
}
.callout p:last-child { margin: 0; }
.callout-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.callout-accent { background: var(--accent-soft); border-color: transparent; }

.provider-card {
  border: 1px solid var(--border); border-radius: 14px; background: var(--panel);
  padding: 24px; margin: 24px 0; scroll-margin-top: 80px;
}
.provider-card h2 { margin-top: 0; padding-top: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin: 16px 0 20px; }
.facts div { background: var(--panel-2); padding: 10px 14px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.facts dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; }
.provider-card ol.signup { counter-reset: s; list-style: none; padding: 0; }
.provider-card ol.signup > li { counter-increment: s; position: relative; padding-left: 36px; margin-bottom: 10px; }
.provider-card ol.signup > li::before {
  content: counter(s); position: absolute; left: 0; top: 1px;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
.provider-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
details { border-bottom: 1px solid var(--border); padding: 14px 0; }
details summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 20px; line-height: 1; }
details[open] summary::after { content: "−"; }
details p { margin: 10px 0 0; color: var(--text-2); }

@media (max-width: 900px) {
  .docs { grid-template-columns: 1fr; gap: 0; padding-top: 32px; }
  .toc { display: none; }
  .facts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .facts { grid-template-columns: 1fr; }
  .provider-card { padding: 18px; }
}

/* ---------------------------------------------------------------- error pages */

.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 40px 20px; }
.error-page .code { font-size: clamp(64px, 14vw, 120px); font-weight: 800; letter-spacing: -0.05em; color: var(--border-strong); line-height: 1; }

/* ---------------------------------------------------------------- SEO landing pages */

.page-hero { padding: 36px 0 24px; }
.page-hero .hero-inner { max-width: 760px; }
.page-hero h1 { font-size: clamp(32px, 5vw, 48px); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); }
.page-hero .preview { margin-top: 32px; }
.page-hero #preview-chart { height: clamp(260px, 36vw, 380px); }
.page-hero #preview-chart[data-panes="2"] { height: clamp(320px, 42vw, 440px); }
.page-hero #preview-chart[data-panes="3"] { height: clamp(360px, 46vw, 500px); }
.article { max-width: 760px; margin: 24px auto 0; }
.article h2 { font-size: 24px; margin-top: 48px; scroll-margin-top: 80px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); font-size: 14px; font-weight: 500;
}
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.toc-inline { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.ind-defs { margin: 0; }
.ind-defs dt { margin-top: 18px; font-size: 16px; scroll-margin-top: 80px; }
.ind-defs dd { margin: 4px 0 0; color: var(--text-2); }
.related { max-width: 760px; margin: 56px auto 0; padding: 0; }
.related h2 { font-size: 20px; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.related-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--panel); color: var(--text-2); font-size: 14px;
}
.related-card b { color: var(--text); font-size: 15px; }
.related-card:hover { border-color: var(--accent); text-decoration: none; }
.page-hero ~ .container .cta { margin: 56px 0 72px; }
@media (max-width: 640px) { .related-grid { grid-template-columns: 1fr; } }

/* Symbol pages: "needs a key" card and the chart hub grid */
.key-card {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px;
  margin-top: 28px; padding: 22px 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow); text-align: left;
}
.key-card > div:first-child { flex: 1 1 380px; }
.key-card b { font-size: 17px; }
.key-card p { margin: 6px 0 0; color: var(--muted); }
.key-card .hero-ctas { margin: 0; }
.sym-hub { padding-bottom: 64px; }
.sym-hub h2 { margin: 36px 0 12px; font-size: 20px; }
.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.sym-grid a {
  display: flex; flex-direction: column; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); text-decoration: none;
}
.sym-grid a:hover { border-color: var(--accent); }
.sym-grid b { font-size: 14px; }
.sym-grid span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Features page */
.feat { padding-bottom: 24px; }
.feat-toc { justify-content: center; margin: 8px 0 12px; }
/* Features page: a sticky section menu beside the content on wide screens; features as an even
   two-column list separated by hairlines rather than boxes of different heights. */
.feat-side { display: none; }
.feat-section { padding: 48px 0 0; scroll-margin-top: 80px; }
.feat-section h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.01em; }
.feat-intro { margin: 0 0 20px; max-width: 640px; color: var(--muted); font-size: 16px; }
.feat-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; border-bottom: 1px solid var(--border); }
.feat-item { padding: 18px 0 20px; border-top: 1px solid var(--border); }
.feat-item h3 { position: relative; margin: 0 0 6px; padding-left: 16px; font-size: 15.5px; line-height: 1.35; }
.feat-item h3::before {
  content: ''; position: absolute; left: 0; top: 0.5em; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.feat-item p { margin: 0; padding-left: 16px; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.feat-item code, .feat-item kbd { font-size: 12.5px; }
@media (max-width: 760px) {
  .feat-list { grid-template-columns: 1fr; }
}
@media (min-width: 1040px) {
  .feat { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 56px; align-items: start; }
  .feat-side { display: block; position: sticky; top: 84px; padding-top: 48px; }
  .feat-toc { display: none; }
  .feat-nav { display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--border); }
  .feat-nav a {
    margin-left: -1px; padding: 7px 0 7px 16px; border-left: 2px solid transparent;
    color: var(--muted); font-size: 14px; line-height: 1.3; text-decoration: none;
  }
  .feat-nav a:hover { color: var(--text); text-decoration: none; }
  .feat-nav a[aria-current="true"] { border-left-color: var(--accent); color: var(--text); font-weight: 600; }
  .feat-main > .feat-section:first-of-type { padding-top: 40px; }
}
.feat .prose { max-width: 760px; }
.section-more { margin: 22px 0 0; text-align: center; font-weight: 600; }
.lang-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 20px 0 0; font-size: 13px; color: var(--muted); }
.lang-links a { color: var(--text-2); }

/* Buy me a coffee popup: the same card, header and buttons as the site's other dialogs.
   The Buy Me a Coffee form itself is a white page, so it sits in an inset panel. */
.coffee-dialog {
  position: fixed; inset: 0; margin: auto;
  width: min(460px, calc(100vw - 24px)); height: fit-content; max-width: none; max-height: calc(100vh - 24px); padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: var(--shadow);
}
.coffee-dialog[open] { display: flex; flex-direction: column; animation: coffee-in 0.18s ease-out; }
.coffee-dialog::backdrop { background: rgba(5, 8, 15, 0.55); backdrop-filter: blur(2px); }
@keyframes coffee-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.coffee-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px 20px; }
.coffee-badge {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent);
}
.coffee-title { flex: 1; min-width: 0; }
.coffee-title h2 { margin: 0; font-size: 18px; }
.coffee-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.coffee-dialog:focus { outline: none; }
.coffee-icon {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px;
  background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; text-decoration: none;
}
a.coffee-icon { font-size: 16px; }
.coffee-icon:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.coffee-frame {
  position: relative; flex: 1; min-height: 0; margin: 0 12px 12px; overflow: hidden auto; overscroll-behavior: contain;
  border: 1px solid var(--border); border-radius: var(--radius); background: #ffffff;
}
/* Buy Me a Coffee's checkout step is about 630px tall. In a shorter frame it scrolls itself to
   centre the Pay button, skipping the (required) email field, so the frame never gets shorter
   than that: on small screens this panel scrolls instead. */
.coffee-frame iframe { display: block; width: 100%; height: 100%; min-height: 640px; border: 0; transition: opacity 0.2s; }
.coffee-frame.is-loading iframe { opacity: 0; }
.coffee-spinner {
  position: absolute; top: 50%; left: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%;
  animation: coffee-spin 0.8s linear infinite;
}
.coffee-frame:not(.is-loading) .coffee-spinner { display: none; }
/* The card form needs its full height; the crypto list sizes to its content. */
.coffee-dialog.is-card { height: min(740px, calc(100vh - 24px)); }
.coffee-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.coffee-card[hidden], .coffee-options[hidden] { display: none; }
.coffee-options { overflow: auto; overscroll-behavior: contain; padding: 4px 20px 20px; }
.donate-section h3 { margin: 4px 0 10px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.donate-section { padding: 0; }
.donate-section + .donate-section { margin-top: 18px; }
.donate-coins { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.donate-coin { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); }
.donate-coin-main { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.donate-code {
  flex: none; min-width: 46px; padding: 4px 6px; border-radius: 6px; text-align: center;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
.donate-coin-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.donate-name { font-size: 14px; font-weight: 600; }
.donate-address {
  font-size: 12px; color: var(--text-2); white-space: normal; overflow-wrap: anywhere; word-break: break-all;
  background: none; border: 0; padding: 0; user-select: all;
}
.donate-actions { flex: none; display: flex; gap: 6px; }
.donate-actions .btn { min-width: 58px; height: 32px; padding: 0 12px; font-size: 13px; }
.donate-qr { padding: 4px 12px 14px; text-align: center; }
.donate-qr img { display: block; width: 180px; height: 180px; margin: 0 auto 8px; padding: 8px; border-radius: 8px; background: #ffffff; image-rendering: pixelated; }
.donate-qr p { margin: 0; font-size: 12px; color: var(--muted); }
.donate-card-btn { width: 100%; justify-content: center; }
@media (max-width: 420px) {
  .donate-coin-main { flex-wrap: wrap; }
  .donate-actions { width: 100%; }
  .donate-actions .btn { flex: 1; }
}
@keyframes coffee-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .coffee-dialog[open] { animation: none; }
  .coffee-spinner { animation-duration: 2s; }
}

/* Analytics consent (visitors in Europe) */
.consent-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  max-width: 720px; margin: 0 auto; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); color: var(--text-2); box-shadow: var(--shadow); font-size: 13.5px;
}
.consent-banner p { flex: 1 1 320px; margin: 0; }
.consent-actions { display: flex; gap: 8px; }
.consent-banner .btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }


/* Learn pages: pattern cards and diagrams */
.lp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin: 14px 0 8px; }
.lp-grid-sm { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.lp-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); scroll-margin-top: 80px; }
.lp-card h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; font-size: 16px; }
.lp-card p { margin: 6px 0; font-size: 14px; color: var(--text-2); }
.lp-card .lp-how { color: var(--muted); font-size: 13px; }
.lp-svg { display: block; width: 100%; height: auto; max-height: 130px; border-radius: 8px; background: var(--bg); }
.lp-svg .lp-neck { stroke: #f0b429; stroke-width: 1.2; stroke-dasharray: 4 3; }
.lp-svg .lp-trend { stroke: #5b7cfa; stroke-width: 1.2; opacity: 0.8; }
.lp-svg .lp-bos { stroke: #089981; stroke-width: 1.2; stroke-dasharray: 4 3; }
.lp-svg .lp-choch { stroke: #f23645; stroke-width: 1.2; }
.lp-svg .lp-t { font: 600 8px var(--font); }
.lp-svg .lp-t.up { fill: #089981; }
.lp-svg .lp-t.down { fill: #f23645; }
.lp-svg .lp-s { font: 600 7px var(--font); fill: var(--muted); }
.lp-svg .lp-gap { fill: rgba(171, 71, 188, 0.18); stroke: rgba(171, 71, 188, 0.6); stroke-width: 0.6; }
.lp-svg .lp-ob { fill: rgba(8, 153, 129, 0.16); stroke: rgba(8, 153, 129, 0.6); stroke-width: 0.6; }
.lp-svg .lp-zt { font: 600 5px var(--font); fill: var(--muted); }
.lp-figure { max-width: 560px; margin: 12px 0; }
.lp-figure .lp-svg { max-height: 200px; }
.lp-figure-sm { max-width: 320px; }
.lp-anatomy { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 12px 0; }
.lp-anatomy .lp-svg { width: 150px; }
.lp-anatomy p { flex: 1 1 260px; margin: 0; }
.lp-card .tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.lp-card .tag-up { color: var(--pill-green); background: rgba(8, 153, 129, 0.13); }
.lp-card .tag-down { color: var(--pill-red); background: rgba(242, 54, 69, 0.13); }
.lp-card .tag-flat { color: var(--muted); background: var(--panel-2); }

/* ---------------------------------------------------------------- the cat (Neko)
   It lives on the chart, and walks onto any page when someone clicks the fish to give it a treat.
   Outside the chart it walks on .cat-layer, a see-through layer over the whole window. */

.support-link { display: inline-flex; align-items: center; gap: 5px; }
/* The fish, drawn in the link's own colour. */
.support-link::before {
  content: ""; flex: none; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 12C4.5 8.3 7.5 6.5 10.5 6.5S15.5 8.5 17 12c-1.5 3.5-3.5 5.5-6.5 5.5S4.5 15.7 2.5 12Z'/%3E%3Cpath d='M17 12l4.5-3.5v7Z'/%3E%3Cpath d='M7 11h.01' stroke-width='2.6'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 12C4.5 8.3 7.5 6.5 10.5 6.5S15.5 8.5 17 12c-1.5 3.5-3.5 5.5-6.5 5.5S4.5 15.7 2.5 12Z'/%3E%3Cpath d='M17 12l4.5-3.5v7Z'/%3E%3Cpath d='M7 11h.01' stroke-width='2.6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.cat-layer { position: fixed; inset: 0; z-index: 900; pointer-events: none; }
.fc-cat { position: absolute; left: 0; top: 0; width: 64px; height: 64px; z-index: 21; pointer-events: none; will-change: transform; }
.fc-cat .cat-sprite {
  width: 100%; height: 100%; background-repeat: no-repeat; image-rendering: pixelated;
  pointer-events: auto; cursor: grab; touch-action: none;
}
.fc-cat .cat-sprite.dragging { cursor: grabbing; }
.cat-fx { position: absolute; inset: 0; z-index: 22; pointer-events: none; overflow: hidden; }
/* The cat's speech bubble; --tail is where the cat sits along its edge. The cat layers sit above the
   chart's pane-resize strips (z-index 20) so they stay clickable, and below .draw-select (25). */
.cat-bubble {
  position: absolute; left: 0; top: 0; z-index: 23; width: max-content; max-width: min(280px, calc(100% - 12px)); pointer-events: auto;
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--panel); color: var(--text); font-size: 13px; line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.cat-bubble::after {
  content: ""; position: absolute; left: calc(var(--tail, 24px) - 6px); bottom: -7px; width: 11px; height: 11px;
  background: var(--panel); border-right: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong);
  transform: rotate(45deg);
}
.cat-bubble.below::after { bottom: auto; top: -7px; transform: rotate(225deg); }
.cat-bubble p { margin: 0; }
.cat-bubble-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cat-bubble-actions .btn { height: 30px; padding: 0 12px; font-size: 13px; }
.cat-bubble-never { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }
/* Folded ask: a small fish in the bubble while the cat waits; tapping it brings the question back. */
.cat-bubble.cat-thought { padding: 2px; border-radius: 999px; }
.cat-thought-fish {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--accent); cursor: pointer;
  animation: cat-thought-bob 2.4s ease-in-out infinite;
}
.cat-thought-fish:hover { background: var(--panel-2); }
@keyframes cat-thought-bob { 50% { transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .cat-thought-fish { animation: none; } }
.cat-p {
  position: absolute; display: block; line-height: 1; translate: -50% 0; opacity: 0;
  animation: cat-float 1.6s ease-out forwards;
}
.cat-p svg { display: block; }
.cat-p.z { font: 700 15px/1 system-ui, sans-serif; color: var(--muted); animation-duration: 2.4s; }
@keyframes cat-float {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0), calc(-1 * var(--up, 60px))) scale(1.1); }
}
@media (prefers-reduced-motion: reduce) { .cat-p { animation-duration: 1s; } }

/* ---------------------------------------------------------------- my cats page */

.cat-gallery-section { padding: 8px 0 64px; }
.cat-gallery { columns: 3 260px; column-gap: 12px; margin: 0; padding: 0; list-style: none; }
.cat-gallery li { break-inside: avoid; margin-bottom: 12px; }
.cat-gallery img { display: block; width: 100%; height: auto; border-radius: 10px; background: var(--panel-2); }

/* Phones and tablets zoom the whole page in when a field under 16px gets focus, and don't zoom back
   out. 16px on touch screens stops that (pinch zoom still works). */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
}
