/* Coon Lab data websites shared theme: element defaults and components.
 * Needs tokens.css loaded first. Theme version: see the first lines of tokens.css.
 * Every class starts with "ct-" so it cannot clash with a site's own classes.
 * Works under the DoIT baseline Content-Security-Policy (style-src 'self'; no inline style anywhere).
 */

/* ---------------------------------------------------------------------------------------------------------------- */
/* Reset and element defaults                                                                                      */
/* ---------------------------------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--ct-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ct-bg);
  color: var(--ct-text);
  font-family: var(--ct-font-sans);
  font-size: var(--ct-fs-base);
  font-weight: var(--ct-fw-regular);
  line-height: var(--ct-lh-body);
  -webkit-font-smoothing: antialiased;
}

/* Any element carrying data-theme repaints its own background, so one section can be shown in the other mode. */
[data-theme] {
  background: var(--ct-bg);
  color: var(--ct-text);
}

main, .ct-main { flex: 1 0 auto; }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--ct-space-4);
  color: var(--ct-text-strong);
  line-height: var(--ct-lh-tight);
}
h1 { font-size: var(--ct-fs-h1); font-weight: var(--ct-fw-semibold); }
h2 { font-size: var(--ct-fs-h2); font-weight: var(--ct-fw-light); }
h3 { font-size: var(--ct-fs-h3); font-weight: var(--ct-fw-semibold); color: var(--ct-heading-accent); }
h4 { font-family: var(--ct-font-serif); font-size: var(--ct-fs-h4); font-weight: var(--ct-fw-regular);
     line-height: var(--ct-lh-snug); color: var(--ct-text-muted); }
h5 { font-size: var(--ct-fs-h5); font-weight: var(--ct-fw-semibold); }
h6 { font-size: var(--ct-fs-h6); font-weight: var(--ct-fw-semibold); text-transform: uppercase;
     letter-spacing: 0.08em; line-height: var(--ct-lh-snug); }

p, ul, ol, dl, blockquote, pre, table, figure { margin: 0 0 var(--ct-space-4); }
ul, ol { padding-left: 1.5em; }
li + li { margin-top: var(--ct-space-1); }
dt { font-weight: var(--ct-fw-semibold); color: var(--ct-text-strong); }
dd { margin: 0 0 var(--ct-space-2) 0; }
small, .ct-small { font-size: var(--ct-fs-sm); }
strong, b { font-weight: var(--ct-fw-semibold); }
em, i, cite { font-family: var(--ct-font-serif); font-style: italic; }
hr { border: 0; border-top: 1px solid var(--ct-border); margin: var(--ct-space-6) 0; }
img, svg, video, canvas { max-width: 100%; height: auto; }
::selection { background: var(--ct-selection-bg); color: var(--ct-text-strong); }

blockquote {
  margin-left: 0;
  padding: var(--ct-space-2) var(--ct-space-5);
  border-left: 3px solid var(--ct-accent);
  font-family: var(--ct-font-serif);
  font-size: var(--ct-fs-lead);
  color: var(--ct-text-muted);
}

a {
  color: var(--ct-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--ct-transition);
}
a:hover { color: var(--ct-link-hover); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--ct-focus);
  outline-offset: 2px;
}

code, kbd, samp, pre { font-family: var(--ct-font-mono); font-size: 0.875em; }
code, kbd {
  padding: 0.1em 0.35em;
  border-radius: var(--ct-radius-sm);
  background: var(--ct-code-bg);
  color: var(--ct-code-text);
}
pre {
  padding: var(--ct-space-4);
  overflow-x: auto;
  border-radius: var(--ct-radius-md);
  background: var(--ct-code-bg);
  color: var(--ct-code-text);
  line-height: 1.5;
}
pre code { padding: 0; background: none; }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Layout helpers                                                                                                  */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-container {
  width: 100%;
  max-width: var(--ct-container);
  margin-inline: auto;
  padding-inline: var(--ct-gutter);
}
.ct-container--narrow { max-width: var(--ct-container-narrow); }
.ct-section { padding-block: var(--ct-space-7); }
.ct-section--alt { background: var(--ct-surface-alt); }
.ct-stack > * + * { margin-top: var(--ct-space-4); }
.ct-grid {
  display: grid;
  gap: var(--ct-space-5);
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
}
.ct-row { display: flex; flex-wrap: wrap; gap: var(--ct-space-3); align-items: center; }
.ct-lead { font-size: var(--ct-fs-lead); color: var(--ct-text-muted); }
.ct-muted { color: var(--ct-text-muted); }
.ct-eyebrow {
  font-size: var(--ct-fs-xs); font-weight: var(--ct-fw-bold); text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ct-text-muted);
}
.ct-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ct-skip-link {
  position: absolute; left: var(--ct-space-4); top: -10rem; z-index: 100;
  padding: var(--ct-space-2) var(--ct-space-4);
  background: var(--ct-btn-primary-bg); color: var(--ct-btn-primary-text);
  border-radius: var(--ct-radius-sm);
}
.ct-skip-link:focus { top: var(--ct-space-2); color: var(--ct-btn-primary-text); }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Logos: two files, one for light backgrounds, one for dark. The header is always navy, so it always uses the      */
/* white logo; elsewhere both images are written and CSS shows the right one for the mode.                          */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-logo { display: block; height: 2.5rem; width: auto; }
.ct-logo--on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ct-logo--on-light { display: none; }
  :root:not([data-theme="light"]) .ct-logo--on-dark { display: block; }
}
/* ":root" raises these above the media-query rules, so a section's own data-theme wins over the OS setting. */
:root [data-theme="dark"] .ct-logo--on-light, :root[data-theme="dark"] .ct-logo--on-light { display: none; }
:root [data-theme="dark"] .ct-logo--on-dark, :root[data-theme="dark"] .ct-logo--on-dark { display: block; }
:root [data-theme="light"] .ct-logo--on-light, :root[data-theme="light"] .ct-logo--on-light { display: block; }
:root [data-theme="light"] .ct-logo--on-dark, :root[data-theme="light"] .ct-logo--on-dark { display: none; }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Header: navy band with white uppercase navigation, as on coonlabs.com                                           */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-header {
  background: var(--ct-header-bg);
  color: var(--ct-header-text);
  border-bottom: 3px solid var(--ct-accent);
}
.ct-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ct-space-2) var(--ct-space-5);
  min-height: var(--ct-header-height);
  padding-block: var(--ct-space-2);
}
.ct-header a { color: var(--ct-header-text); text-decoration: none; }
.ct-header :focus-visible { outline-color: var(--ct-header-accent); }
.ct-brand {
  display: flex;
  align-items: center;
  gap: var(--ct-space-3);
  margin-right: auto;
}
.ct-brand .ct-logo { height: 2.25rem; }
.ct-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  padding-left: var(--ct-space-3);
  border-left: 1px solid var(--ct-header-muted);
}
.ct-brand__network {
  font-size: var(--ct-fs-xs);
  font-weight: var(--ct-fw-semibold);
  letter-spacing: var(--ct-tracking-caps);
  text-transform: uppercase;
  color: var(--ct-header-muted);
}
.ct-brand__site {
  font-size: var(--ct-fs-lead);
  font-weight: var(--ct-fw-semibold);
  color: var(--ct-header-text);
}
a.ct-brand:hover .ct-brand__network { color: var(--ct-header-text); }

.ct-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--ct-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.ct-nav li { margin: 0; }
.ct-nav a {
  display: inline-block;
  padding: var(--ct-space-2) var(--ct-space-3);
  font-size: var(--ct-fs-sm);
  font-weight: var(--ct-fw-bold);
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-transform: uppercase;
  border-bottom: 2px solid transparent;
}
.ct-nav a:hover { border-bottom-color: var(--ct-header-muted); color: var(--ct-header-text); }
.ct-nav a[aria-current="page"] { border-bottom-color: var(--ct-header-accent); }

/* Page title band under the header (coonlabs.com shows the page title in brand blue on navy). */
.ct-pagehead {
  background: var(--ct-header-bg);
  color: var(--ct-header-text);
  padding-block: var(--ct-space-6) var(--ct-space-7);
}
.ct-pagehead h1 { color: var(--ct-header-accent); margin-bottom: var(--ct-space-2); }
.ct-pagehead p { margin: 0; font-size: var(--ct-fs-lead); font-weight: var(--ct-fw-semibold); color: var(--ct-header-text); }

@media (max-width: 40rem) {
  .ct-header__inner { padding-block: var(--ct-space-3); }
  .ct-brand { width: 100%; }
  .ct-nav { width: 100%; margin-inline: calc(-1 * var(--ct-space-3)); }
  .ct-nav a { padding-inline: var(--ct-space-3); }
}

/* ---------------------------------------------------------------------------------------------------------------- */
/* Top bar (1.1.0): the one header every data website uses. White, hairline rule below; left to right: the site's  */
/* own logo or name, its own page links (optional), collaborators' logos (optional), the "See our other projects"  */
/* menu, the Coon logo. Markup: snippets/topbar.html. Below 60rem wide: the logo and the Coon logo on the first row,  */
/* the rest below. Flex order places the parts, so the markup order never changes: the ::before spacer pushes the   */
/* right-hand group to the right; below 60rem the ::after rule breaks the row.                                     */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-topbar {
  position: relative;
  z-index: 30;
  background: var(--ct-topbar-bg);
  color: var(--ct-topbar-text);
  border-bottom: 1px solid var(--ct-topbar-rule);
}
.ct-topbar__inner {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ct-space-2) var(--ct-space-5);
  min-height: var(--ct-topbar-height);
  padding-block: var(--ct-space-2);
}
.ct-topbar__inner::before { content: ""; order: 2; flex: 1 1 0; }
.ct-topbar__brand, .ct-topbar__nav { order: 1; }
.ct-topbar__partners, .ct-projects, .ct-topbar__coon { order: 3; }
.ct-topbar a { color: var(--ct-topbar-text); text-decoration: none; }
.ct-topbar :focus-visible { outline: 2px solid var(--ct-topbar-focus); outline-offset: 3px; border-radius: var(--ct-radius-sm); }

.ct-topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--ct-space-3);
  flex: 0 1 auto;
  min-width: 0;
  font-size: 1.25rem;
  font-weight: var(--ct-fw-bold);
  line-height: 1.2;
  letter-spacing: -0.005em;
}
.ct-topbar__brand img { display: block; flex: none; height: var(--ct-topbar-logo); width: auto; max-width: none; }

.ct-topbar__nav ul { display: flex; flex-wrap: wrap; gap: 0 var(--ct-space-1); margin: 0; padding: 0; list-style: none; }
.ct-topbar__nav li { margin: 0; }
.ct-topbar__nav a {
  display: inline-block;
  padding: var(--ct-space-2) var(--ct-space-3);
  font-size: var(--ct-fs-sm);
  font-weight: var(--ct-fw-bold);
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-transform: uppercase;
  border-bottom: 2px solid transparent;
}
.ct-topbar__nav a:hover { border-bottom-color: var(--ct-topbar-rule); }
.ct-topbar__nav a[aria-current="page"] { border-bottom-color: var(--ct-accent); }

.ct-topbar__partners { display: flex; align-items: center; gap: var(--ct-space-5); }
.ct-topbar__partner, .ct-topbar__coon { display: block; flex: none; }
.ct-topbar__partner img { display: block; height: var(--ct-topbar-partner); width: auto; }
.ct-topbar__coon img { display: block; height: var(--ct-topbar-logo); width: auto; }

/* The "See our other projects" menu: a disclosure button and a list of links (theme/projects-menu.js fills it). */
.ct-projects { position: relative; flex: none; }
.ct-projects__button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.5rem;
  margin: 0;
  padding: 0.45rem 1rem 0.45rem 1.1rem;
  border: 1px solid var(--ct-topbar-edge);
  border-radius: var(--ct-radius-pill);
  background: var(--ct-topbar-bg);
  color: var(--ct-topbar-text);
  font-family: var(--ct-font-sans);
  font-size: var(--ct-fs-sm);
  font-weight: var(--ct-fw-semibold);
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ct-transition), border-color var(--ct-transition);
}
.ct-projects__button::after {
  content: "";
  flex: none;
  width: 0.45rem;
  height: 0.45rem;
  margin-top: -0.25rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--ct-transition), margin var(--ct-transition);
}
.ct-projects__button:hover { background: var(--ct-topbar-hover); }
.ct-projects__button[aria-expanded="true"] { background: var(--ct-topbar-hover); border-color: var(--ct-topbar-text); }
.ct-projects__button[aria-expanded="true"]::after { margin-top: 0.2rem; transform: rotate(-135deg); }
.ct-projects__button[hidden], .ct-projects__list[hidden] { display: none; }

.ct-projects__list {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 60;
  width: max-content;
  min-width: 100%;
  max-width: min(24rem, calc(100vw - 2rem));
  max-height: min(70vh, 34rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0.375rem;
  list-style: none;
  background: var(--ct-topbar-bg);
  border: 1px solid var(--ct-topbar-rule);
  border-radius: var(--ct-radius-lg);
  box-shadow: 0 2px 6px rgba(19, 51, 79, 0.10), 0 12px 32px rgba(19, 51, 79, 0.16);
  animation: ct-projects-in 0.14s ease-out;
}
.ct-projects__list li { margin: 0; }
.ct-projects__list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ct-space-4);
  padding: 0.5rem 0.75rem;
  border-radius: var(--ct-radius-md);
  color: var(--ct-topbar-text);
  font-size: 0.9375rem;
  line-height: 1.35;
}
/* A small "opens in a new tab" mark after each name (an image, so no words are added). */
.ct-projects__list a::after {
  content: "";
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  background: url("img/new-tab.svg") center / contain no-repeat;
  opacity: 0.45;
  transition: opacity var(--ct-transition);
}
.ct-projects__list a:hover, .ct-projects__list a:focus-visible { background: var(--ct-topbar-hover); }
.ct-projects__list a:hover::after, .ct-projects__list a:focus-visible::after { opacity: 1; }
.ct-projects__list a:focus-visible { outline-offset: -2px; }
.ct-projects__list .ct-projects__all { padding-bottom: 0.375rem; margin-bottom: 0.375rem; border-bottom: 1px solid var(--ct-topbar-rule); }
.ct-projects__all a { font-weight: var(--ct-fw-semibold); }
@keyframes ct-projects-in {
  from { opacity: 0; transform: translateY(-0.25rem); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 60rem) {
  .ct-topbar { --ct-topbar-logo: 2.125rem; --ct-topbar-partner: 1.5rem; }
  .ct-topbar__inner { gap: 0 var(--ct-space-4); padding-block: var(--ct-space-3); }
  /* room for the Coon logo (600 x 180) beside the site's name, so a long name wraps instead of pushing it down */
  .ct-topbar__brand { order: 1; font-size: 1.0625rem; max-width: calc(100% - var(--ct-topbar-logo) * 3.34 - 2 * var(--ct-space-4)); }
  .ct-topbar__coon { order: 3; }
  .ct-topbar__inner::after { content: ""; order: 4; flex-basis: 100%; height: 0; }
  .ct-topbar__partners { order: 5; gap: var(--ct-space-4); margin-top: var(--ct-space-3); }
  .ct-projects { order: 6; position: static; margin-top: var(--ct-space-3); margin-left: auto; }
  .ct-topbar__nav { order: 7; flex-basis: 100%; margin-top: var(--ct-space-2); margin-inline: calc(-1 * var(--ct-space-3)); }
  .ct-projects__button { min-height: 2.375rem; padding: 0.4rem 0.85rem 0.4rem 0.95rem; font-size: 0.8125rem; gap: 0.5rem; }
  /* On a phone the open list spans the bar's width, just below it. */
  .ct-projects__list { top: calc(100% - 0.25rem); left: var(--ct-gutter); right: var(--ct-gutter); width: auto; min-width: 0; max-width: none; }
}

/* ---------------------------------------------------------------------------------------------------------------- */
/* Footer: white with slate text and a slate rule above the copyright line, as on coonlabs.com                      */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-footer {
  margin-top: var(--ct-space-8);
  background: var(--ct-footer-bg);
  color: var(--ct-footer-text);
  font-size: var(--ct-fs-sm);
  line-height: 1.6;
  border-top: 1px solid var(--ct-border);
}
.ct-footer__main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ct-space-5);
  padding-block: var(--ct-space-6);
}
.ct-footer a { color: var(--ct-footer-text); text-decoration: none; }
.ct-footer a:hover { color: var(--ct-link-hover); text-decoration: underline; }
.ct-footer__brand .ct-logo { height: 2.75rem; }
.ct-footer__heading {
  margin: 0 0 var(--ct-space-2);
  font-family: var(--ct-font-sans);
  font-size: var(--ct-fs-sm);
  font-weight: var(--ct-fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ct-footer-text);
}
.ct-footer__links { margin: 0; padding: 0; list-style: none; }
.ct-footer__links li + li { margin-top: var(--ct-space-1); }
.ct-footer__legal {
  padding-block: var(--ct-space-4);
  border-top: 1px solid var(--ct-footer-rule);
  font-size: var(--ct-fs-xs);
}
.ct-footer__legal p { margin: 0; }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Cards                                                                                                           */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-card {
  display: flex;
  flex-direction: column;
  background: var(--ct-surface);
  color: var(--ct-text);
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius-md);
  box-shadow: var(--ct-shadow-1);
  overflow: hidden;
}
.ct-card__media { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--ct-surface-alt); }
.ct-card__body { padding: var(--ct-space-5); flex: 1 1 auto; }
.ct-card__body > :last-child { margin-bottom: 0; }
.ct-card__title { margin: 0 0 var(--ct-space-2); font-size: var(--ct-fs-h5); font-weight: var(--ct-fw-semibold); color: var(--ct-text-strong); }
.ct-card__title a { color: inherit; text-decoration: none; }
.ct-card__title a:hover { color: var(--ct-link); text-decoration: underline; }
.ct-card__footer {
  padding: var(--ct-space-3) var(--ct-space-5);
  border-top: 1px solid var(--ct-border);
  background: var(--ct-surface-alt);
  font-size: var(--ct-fs-sm);
}
.ct-card--accent { border-top: 4px solid var(--ct-accent); }
a.ct-card { text-decoration: none; transition: box-shadow var(--ct-transition), transform var(--ct-transition); }
a.ct-card:hover { box-shadow: var(--ct-shadow-2); transform: translateY(-2px); color: var(--ct-text); }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Buttons: uppercase bold labels with letter spacing, as coonlabs.com; pill variant as its "Read more" links        */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ct-space-2);
  min-height: 2.5rem;
  padding: var(--ct-space-2) var(--ct-space-5);
  border: 2px solid transparent;
  border-radius: var(--ct-radius-sm);
  background: var(--ct-btn-primary-bg);
  color: var(--ct-btn-primary-text);
  box-shadow: var(--ct-shadow-inset-btn);
  font-family: var(--ct-font-sans);
  font-size: var(--ct-fs-sm);
  font-weight: var(--ct-fw-bold);
  letter-spacing: var(--ct-tracking-caps);
  line-height: 1.2;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--ct-transition), color var(--ct-transition), border-color var(--ct-transition);
}
.ct-btn:hover { background: var(--ct-btn-primary-bg-hover); color: var(--ct-btn-primary-text); text-decoration: none; }
.ct-btn--secondary { background: var(--ct-btn-secondary-bg); color: var(--ct-btn-secondary-text); }
.ct-btn--secondary:hover { background: var(--ct-btn-secondary-bg-hover); color: var(--ct-btn-secondary-text); }
.ct-btn--outline {
  background: transparent;
  color: var(--ct-accent-strong);
  border-color: var(--ct-accent-strong);
  box-shadow: none;
}
.ct-btn--outline:hover { background: var(--ct-accent-strong); color: var(--ct-on-accent-strong); }
.ct-btn--ghost { background: transparent; color: var(--ct-link); box-shadow: none; }
.ct-btn--ghost:hover { background: var(--ct-surface-alt); color: var(--ct-link-hover); }
.ct-btn--pill { border-radius: var(--ct-radius-pill); }
.ct-btn--small { min-height: 2rem; padding: var(--ct-space-1) var(--ct-space-3); font-size: var(--ct-fs-xs); }
.ct-btn:disabled, .ct-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Tables                                                                                                          */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius-md);
  background: var(--ct-surface);
  margin-bottom: var(--ct-space-4);
}
.ct-table-wrap > .ct-table { margin: 0; }
.ct-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ct-fs-sm);
  line-height: 1.5;
  background: var(--ct-surface);
  color: var(--ct-text);
}
.ct-table caption {
  caption-side: top;
  padding: var(--ct-space-3) var(--ct-space-4);
  text-align: left;
  font-weight: var(--ct-fw-semibold);
  color: var(--ct-text-strong);
}
.ct-table th, .ct-table td {
  padding: var(--ct-space-2) var(--ct-space-4);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--ct-border);
}
.ct-table thead th {
  position: sticky;
  top: 0;
  background: var(--ct-table-head-bg);
  color: var(--ct-table-head-text);
  font-size: var(--ct-fs-xs);
  font-weight: var(--ct-fw-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ct-table tbody tr:nth-child(even) { background: var(--ct-table-stripe); }
.ct-table tbody tr:hover { background: var(--ct-table-hover); box-shadow: inset 3px 0 0 var(--ct-accent); }
.ct-table tbody tr:last-child > * { border-bottom: 0; }
.ct-table .ct-num, .ct-table td.ct-num, .ct-table th.ct-num { text-align: right; font-variant-numeric: tabular-nums; }
.ct-table--compact th, .ct-table--compact td { padding: var(--ct-space-1) var(--ct-space-3); }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Form controls                                                                                                   */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-field { display: flex; flex-direction: column; gap: var(--ct-space-1); margin-bottom: var(--ct-space-4); }
.ct-label, label { font-size: var(--ct-fs-sm); font-weight: var(--ct-fw-semibold); color: var(--ct-text-strong); }
.ct-help { font-size: var(--ct-fs-xs); color: var(--ct-text-muted); margin: 0; }
.ct-error { font-size: var(--ct-fs-xs); color: var(--ct-danger-text); margin: 0; font-weight: var(--ct-fw-semibold); }

.ct-input, .ct-select, .ct-textarea,
input[type="text"], input[type="search"], input[type="number"], input[type="email"], input[type="url"],
input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  max-width: 100%;
  min-height: 2.5rem;
  padding: var(--ct-space-2) var(--ct-space-3);
  border: 1px solid var(--ct-border-strong);
  border-radius: var(--ct-radius-sm);
  background: var(--ct-surface);
  color: var(--ct-text);
  font-family: var(--ct-font-sans);
  font-size: var(--ct-fs-base);
  line-height: 1.4;
  transition: border-color var(--ct-transition), box-shadow var(--ct-transition);
}
textarea, .ct-textarea { min-height: 6rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ct-text-muted); opacity: 1; }
.ct-input:focus, .ct-select:focus, .ct-textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--ct-focus);
  outline-offset: 1px;
  border-color: var(--ct-focus);
}
[aria-invalid="true"] { border-color: var(--ct-danger-border) !important; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"], input[type="range"], progress { accent-color: var(--ct-accent-strong); }
input[type="checkbox"], input[type="radio"] { width: 1.1rem; height: 1.1rem; margin: 0; }
.ct-check { display: flex; align-items: center; gap: var(--ct-space-2); font-weight: var(--ct-fw-regular); color: var(--ct-text); }
fieldset { margin: 0 0 var(--ct-space-4); padding: var(--ct-space-4); border: 1px solid var(--ct-border); border-radius: var(--ct-radius-md); }
legend { padding: 0 var(--ct-space-2); font-weight: var(--ct-fw-semibold); color: var(--ct-text-strong); }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Tabs. Markup: <div class="ct-tabs" role="tablist"> <button class="ct-tab" role="tab" aria-selected="true">.      */
/* The theme styles them; switching panels is the site's own script (an external file, never inline).             */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--ct-space-1);
  border-bottom: 1px solid var(--ct-border);
  margin-bottom: var(--ct-space-4);
}
.ct-tab {
  appearance: none;
  margin: 0 0 -1px;
  padding: var(--ct-space-2) var(--ct-space-4);
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--ct-text-muted);
  font-family: var(--ct-font-sans);
  font-size: var(--ct-fs-sm);
  font-weight: var(--ct-fw-semibold);
  text-decoration: none;
  cursor: pointer;
}
.ct-tab:hover { color: var(--ct-text-strong); border-bottom-color: var(--ct-border-strong); }
.ct-tab[aria-selected="true"], .ct-tab[aria-current="page"] {
  color: var(--ct-text-strong);
  border-bottom-color: var(--ct-accent-strong);
}
.ct-tabpanel[hidden] { display: none; }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Tooltips. Markup: <span class="ct-tooltip" tabindex="0" data-tip="Text">term</span>. Pure CSS (content comes     */
/* from the attribute through attr()), so it needs no script and passes the CSP. Shown on hover and keyboard focus. */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted currentColor;
  cursor: help;
}
.ct-tooltip::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 20;
  left: 0;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: min(18rem, 80vw);
  padding: var(--ct-space-2) var(--ct-space-3);
  border-radius: var(--ct-radius-sm);
  background: var(--ct-tooltip-bg);
  color: var(--ct-tooltip-text);
  box-shadow: var(--ct-shadow-2);
  font-family: var(--ct-font-sans);
  font-size: var(--ct-fs-xs);
  font-style: normal;
  font-weight: var(--ct-fw-regular);
  line-height: 1.4;
  text-align: left;
  text-transform: none;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--ct-transition), transform var(--ct-transition);
}
.ct-tooltip:hover::after, .ct-tooltip:focus::after, .ct-tooltip:focus-within::after {
  opacity: 1;
  transform: none;
}
.ct-tooltip--open::after { opacity: 1; transform: none; } /* for the demo screenshot */

/* ---------------------------------------------------------------------------------------------------------------- */
/* Notices and badges (status colours; always with a word, never colour alone)                                     */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-notice {
  margin-bottom: var(--ct-space-4);
  padding: var(--ct-space-3) var(--ct-space-4);
  border-left: 4px solid var(--ct-info-border);
  border-radius: var(--ct-radius-sm);
  background: var(--ct-info-bg);
  color: var(--ct-info-text);
}
.ct-notice > :last-child { margin-bottom: 0; }
.ct-notice strong { color: inherit; }
.ct-notice--success { border-color: var(--ct-success-border); background: var(--ct-success-bg); color: var(--ct-success-text); }
.ct-notice--warning { border-color: var(--ct-warning-border); background: var(--ct-warning-bg); color: var(--ct-warning-text); }
.ct-notice--danger  { border-color: var(--ct-danger-border);  background: var(--ct-danger-bg);  color: var(--ct-danger-text); }

.ct-badge {
  display: inline-block;
  padding: 0.1em 0.6em;
  border-radius: var(--ct-radius-pill);
  background: var(--ct-surface-alt);
  color: var(--ct-text-strong);
  border: 1px solid var(--ct-border);
  font-size: var(--ct-fs-xs);
  font-weight: var(--ct-fw-semibold);
  line-height: 1.6;
  white-space: nowrap;
}
.ct-badge--info { background: var(--ct-info-bg); color: var(--ct-info-text); border-color: var(--ct-info-border); }
.ct-badge--success { background: var(--ct-success-bg); color: var(--ct-success-text); border-color: var(--ct-success-border); }
.ct-badge--warning { background: var(--ct-warning-bg); color: var(--ct-warning-text); border-color: var(--ct-warning-border); }
.ct-badge--danger { background: var(--ct-danger-bg); color: var(--ct-danger-text); border-color: var(--ct-danger-border); }

details.ct-details {
  margin-bottom: var(--ct-space-4);
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius-md);
  background: var(--ct-surface);
}
details.ct-details > summary {
  padding: var(--ct-space-3) var(--ct-space-4);
  cursor: pointer;
  font-weight: var(--ct-fw-semibold);
  color: var(--ct-text-strong);
}
details.ct-details[open] > summary { border-bottom: 1px solid var(--ct-border); }
details.ct-details > :not(summary) { margin: var(--ct-space-4); }

/* ---------------------------------------------------------------------------------------------------------------- */
/* Chart frame: the box a plotly or d3 chart sits in, on the chart surface                                         */
/* ---------------------------------------------------------------------------------------------------------------- */
.ct-chart {
  padding: var(--ct-space-4);
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius-md);
  background: var(--ct-chart-surface);
}
.ct-chart__title { margin: 0 0 var(--ct-space-1); font-size: var(--ct-fs-base); font-weight: var(--ct-fw-semibold); color: var(--ct-text-strong); }
.ct-chart__note { margin: var(--ct-space-2) 0 0; font-size: var(--ct-fs-xs); color: var(--ct-text-muted); }
.ct-legend { display: flex; flex-wrap: wrap; gap: var(--ct-space-1) var(--ct-space-4); margin: 0; padding: 0; list-style: none; font-size: var(--ct-fs-xs); color: var(--ct-text); }
.ct-legend li { display: flex; align-items: center; gap: var(--ct-space-1); margin: 0; }
.ct-swatch { display: inline-block; width: 0.85rem; height: 0.85rem; border-radius: 2px; flex: none; }
.ct-swatch--1 { background: var(--ct-chart-1); } .ct-swatch--2 { background: var(--ct-chart-2); }
.ct-swatch--3 { background: var(--ct-chart-3); } .ct-swatch--4 { background: var(--ct-chart-4); }
.ct-swatch--5 { background: var(--ct-chart-5); } .ct-swatch--6 { background: var(--ct-chart-6); }
.ct-swatch--7 { background: var(--ct-chart-7); } .ct-swatch--8 { background: var(--ct-chart-8); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
