/*
 * Tangent Tuition site styles.
 * Colours, type and spacing come from tokens.css (generated from brand/tokens.json).
 * The one rule: orange touches one thing per section.
 */

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--space-8);
}

body {
  margin: 0;
  background: var(--frame);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-weight: var(--text-body-weight);
}

img,
svg {
  max-width: 100%;
}

img {
  height: auto;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0 0 var(--space-4);
}

h1,
.display,
h2 {
  font-family: var(--font-display);
}

.display {
  font-size: var(--text-display-size);
  line-height: var(--text-display-line);
  font-weight: var(--text-display-weight);
  letter-spacing: -0.01em;
}

h1 {
  font-size: var(--text-h1-size);
  line-height: var(--text-h1-line);
  font-weight: var(--text-h1-weight);
}

h2 {
  font-size: var(--text-h2-size);
  line-height: var(--text-h2-line);
  font-weight: var(--text-h2-weight);
}

h3,
.h3,
h4,
h5 {
  font-family: var(--font-sans);
  font-size: var(--text-h3-size);
  line-height: var(--text-h3-line);
  font-weight: var(--text-h3-weight);
}

h4 {
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

p,
ul,
ol,
dl {
  margin: 0 0 var(--space-4);
}

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--tangent-text);
  text-decoration-thickness: 2px;
}

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

main:focus {
  outline: none;
}

.small,
small {
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
}

.lede {
  font-size: 20px;
  line-height: 30px;
  max-width: 60ch;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
  font-weight: 500;
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--ink);
  color: var(--frame);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: var(--space-4);
  color: var(--frame);
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 640px) {
  .wrap {
    padding: 0 var(--space-8);
  }
}

.prose {
  max-width: 70ch;
}

.prose h2 {
  margin-top: var(--space-8);
}

.prose ul,
.prose ol {
  padding-left: var(--space-8);
}

.prose li + li {
  margin-top: var(--space-2);
}

/* ---------- Buttons and tags ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: var(--space-2) var(--space-4);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* The section's one orange thing. Text on orange is always black. */
.btn--primary {
  background: var(--tangent);
  border-color: var(--tangent);
  color: var(--ink);
}

.btn--primary:hover,
.btn--primary:active {
  background: var(--tangent-hover);
  border-color: var(--tangent-hover);
  color: var(--ink);
}

/* Strong but neutral: used where orange is already taken (header, hero). */
.btn--ink {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--frame);
}

.btn--ink:hover,
.btn--ink:active {
  background: var(--muted);
  border-color: var(--muted);
  color: var(--frame);
}

.btn--outline {
  background: var(--frame);
  border-color: var(--ink);
  color: var(--ink);
}

.btn--outline:hover,
.btn--outline:active {
  background: var(--surface);
  color: var(--ink);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* Pill shapes are for subject tags only. */
.pill {
  display: inline-block;
  padding: 0 var(--space-2);
  border: 1px solid var(--muted);
  border-radius: var(--radius-pill);
  background: var(--frame);
  color: var(--ink);
  font-size: var(--text-small-size);
  line-height: 22px;
  font-weight: 500;
  white-space: nowrap;
}

a.pill--link {
  text-decoration: none;
  min-height: 24px;
}

a.pill--link:hover {
  background: var(--surface);
  color: var(--ink);
}

.access {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
  font-weight: 500;
}

.access svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

/* ---------- Header and navigation ---------- */

.site-header {
  border-bottom: 1px solid var(--grid);
  background: var(--frame);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 80px;
  flex-wrap: wrap;
}

.site-header__brand {
  display: inline-flex;
  padding: var(--space-2) 0;
}

.site-header__brand img {
  display: block;
  width: 214px;
  height: 36px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.site-nav__list {
  display: flex;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__item {
  position: relative;
  display: flex;
  align-items: center;
}

.site-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-2);
  font-weight: 500;
  text-decoration: none;
}

.site-nav__link[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

.site-nav__sub-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: -8px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.site-nav__sub-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform 0.15s ease;
}

.site-nav__sub-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.site-nav__sub {
  margin: 0;
  padding: var(--space-2) 0;
  list-style: none;
}

.site-nav__sub a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-4);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav__sub a:hover,
.site-nav__sub a[aria-current="page"] {
  text-decoration: underline;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--frame);
  color: var(--ink);
  font: 600 var(--text-body-size) / 1 var(--font-sans);
  cursor: pointer;
}

.nav-toggle__icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}



/* Desktop: dropdown for the subject list. */
@media (min-width: 1000px) {
  .site-nav__sub {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 20;
    min-width: 260px;
    border: 1px solid var(--muted);
    border-radius: var(--radius-sm);
    background: var(--frame);
  }

  .site-nav__sub:not(.is-open) {
    display: none;
  }

  .nav-toggle {
    display: none;
  }
}

/* Small screens: the menu button shows and hides the whole nav. */
@media (max-width: 999px) {
  .site-nav {
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
  }

  .site-nav:not(.is-open) {
    display: none;
  }

  .site-nav__list {
    flex-direction: column;
    gap: 0;
  }

  .site-nav__item {
    flex-wrap: wrap;
    border-top: 1px solid var(--grid);
  }

  .site-nav__link {
    flex: 1;
    min-height: 48px;
  }

  .site-nav__sub-toggle {
    display: none;
  }

  .site-nav__sub {
    flex-basis: 100%;
    padding: 0 0 var(--space-2);
  }

  .site-nav__cta {
    align-self: flex-start;
  }
}

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

.site-footer {
  margin-top: var(--space-16);
  padding: var(--space-16) 0 var(--space-8);
  border-top: 1px solid var(--grid);
  background: var(--surface);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
}

.site-footer__grid {
  display: grid;
  gap: var(--space-8);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .site-footer__grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1000px) {
  .site-footer__grid {
    grid-template-columns: 2fr 1fr 1.4fr 1fr;
  }
}

.site-footer__brand img {
  display: block;
  margin-bottom: var(--space-4);
}

.site-footer__heading {
  margin-bottom: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
  font-weight: 600;
}

.site-footer ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer li a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.site-footer__base {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px solid var(--grid);
  color: var(--muted);
}

.site-footer__base p {
  margin: 0;
}

.site-footer__legal {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* ---------- Sections and layout ---------- */

.section {
  padding: var(--space-16) 0 0;
}

.section--tight {
  padding-top: var(--space-8);
}

.section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-head {
  padding-top: var(--space-16);
}

.breadcrumb {
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-size: var(--text-small-size);
}

.breadcrumb a {
  color: var(--muted);
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  color: var(--muted);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
}

.panel {
  padding: var(--space-8);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.panel > :last-child {
  margin-bottom: 0;
}

.trio {
  display: grid;
  gap: var(--space-8);
}

@media (min-width: 800px) {
  .trio {
    grid-template-columns: repeat(3, 1fr);
  }
}

.trio__item {
  padding-top: var(--space-4);
  border-top: 2px solid var(--ink);
}

.split {
  display: grid;
  gap: var(--space-8);
}

@media (min-width: 800px) {
  .split {
    grid-template-columns: 1fr 1fr;
  }
}

.ticks {
  padding-left: var(--space-8);
}

.ticks li + li {
  margin-top: var(--space-2);
}

.empty {
  color: var(--muted);
}

.placeholder {
  color: var(--muted);
}

/* ---------- Figures ---------- */

.figure {
  margin: 0;
}

.figure__svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-none);
}

.figure__caption {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-weight: var(--text-caption-weight);
}

.figure__caption .katex {
  font-size: 1.15em;
}

.fig-grid {
  fill: none;
  stroke: var(--grid);
  stroke-width: var(--stroke-grid);
}

.fig-axis {
  fill: none;
  stroke: var(--muted);
  stroke-width: var(--stroke-axis);
}

.fig-field {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.fig-curve {
  fill: none;
  stroke: var(--ink);
  stroke-width: var(--stroke-curve);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fig-alt {
  fill: none;
  stroke: var(--curve-alt);
  stroke-width: var(--stroke-curve);
  stroke-linecap: round;
}

.fig-alt-point,
.fig-alt-head {
  fill: var(--curve-alt);
}

.fig-tangent {
  fill: none;
  stroke: var(--tangent);
  stroke-width: var(--stroke-tangent);
  stroke-linecap: round;
}

.fig-tangent--join {
  stroke-linejoin: round;
}

.fig-tangent-point {
  fill: var(--tangent);
}

.fig-point {
  fill: var(--ink);
  stroke: var(--frame);
  stroke-width: 3;
}

.fig-data {
  fill: var(--ink);
}

.fig-solid {
  fill: var(--ink);
}

.fig-outline {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
}

.fig-answer {
  fill: var(--frame);
  stroke: var(--tangent);
  stroke-width: var(--stroke-tangent);
}

.fig-support {
  fill: var(--frame);
  stroke: var(--muted);
  stroke-width: 2;
}

.fig-arrow {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
}

.fig-arrow-head {
  fill: var(--ink);
}

.fig-guide {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.fig-guide-solid {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
}

.fig-num,
.fig-var {
  fill: var(--ink);
  font-size: 22px;
}

.fig-num {
  font-family: var(--font-math);
}

.fig-var {
  font-family: KaTeX_Math, var(--font-math);
  font-style: italic;
}

.fig-sub {
  font-family: var(--font-math);
  font-style: normal;
  font-size: 15px;
}

.fig-num--panel {
  font-size: 24px;
}

/* ---------- Home: hero ---------- */

.hero {
  padding-top: var(--space-16);
}

.hero__inner {
  display: grid;
  gap: var(--space-8);
  align-items: center;
}

@media (min-width: 900px) {
  .hero__inner {
    grid-template-columns: 1.05fr 1fr;
    gap: var(--space-16);
  }
}

.hero__text .display {
  max-width: 12ch;
}

.hero__text .lede {
  margin-bottom: var(--space-8);
}

/*
 * The page's one orchestrated moment: the curve draws itself, then the
 * tangent appears. With reduced motion, the finished figure shows at once.
 */
@media (prefers-reduced-motion: no-preference) {
  .hero-fig .fig-curve {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 1.6s cubic-bezier(0.45, 0, 0.25, 1) 0.2s forwards;
  }

  .hero-fig .fig-point {
    opacity: 0;
    animation: appear 0.25s ease-out 1.6s forwards;
  }

  .hero-fig .fig-tangent {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 0.6s ease-out 1.85s forwards;
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes appear {
  to {
    opacity: 1;
  }
}

/* ---------- Home: subjects, posts, CTA, about ---------- */

.subject-rows {
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--grid);
}

.subject-row {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-8) 0;
  border-top: 1px solid var(--grid);
}

.subject-row h3 {
  margin-bottom: var(--space-2);
}

.subject-row h3 a {
  text-decoration: none;
}

.subject-row h3 a:hover {
  text-decoration: underline;
}

.subject-row p {
  margin-bottom: 0;
}

.subject-row__name p {
  max-width: 48ch;
}

@media (min-width: 900px) {
  .subject-row {
    grid-template-columns: 1.3fr 1fr auto;
    align-items: start;
    gap: var(--space-8);
  }
}

.subject-row__all a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  white-space: nowrap;
}

.post-list {
  display: grid;
  gap: var(--space-8);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 900px) {
  .post-list--row {
    grid-template-columns: repeat(3, 1fr);
  }
}

.post-list--stack {
  max-width: 70ch;
}

.post-summary {
  padding-top: var(--space-4);
  border-top: 2px solid var(--ink);
}

.post-summary__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
}

.post-summary__title {
  margin-bottom: var(--space-2);
}

.post-summary__title a {
  text-decoration: none;
}

.post-summary__title a:hover {
  text-decoration: underline;
}

.cta-band {
  display: grid;
  gap: var(--space-8);
  padding: var(--space-8);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

@media (min-width: 900px) {
  .cta-band {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: var(--space-16);
  }
}

.cta-band p {
  margin-bottom: 0;
  max-width: 50ch;
}

.photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 5;
  width: 100%;
  max-width: 360px;
  border: 1px dashed var(--muted);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-small-size);
}

.about-preview {
  display: grid;
  gap: var(--space-8);
  align-items: center;
}

@media (min-width: 800px) {
  .about-preview {
    grid-template-columns: 280px 1fr;
    gap: var(--space-16);
  }
}

.about-preview__text {
  max-width: 60ch;
}

/* ---------- Resources ---------- */

.subject-links {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 700px) {
  .subject-links {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

.subject-link {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 100%;
  padding: var(--space-4);
  border: 1px solid var(--muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.subject-link:hover {
  background: var(--surface);
  color: var(--ink);
}

.subject-link__name {
  font-weight: 600;
}

.subject-link__count {
  color: var(--muted);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
}

.subject-hero {
  padding-top: var(--space-16);
}

.subject-hero__inner {
  display: grid;
  gap: var(--space-8);
  align-items: center;
}

@media (min-width: 900px) {
  .subject-hero__inner {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-16);
  }
}

.subject-hero__figure {
  max-width: 560px;
}

.filters {
  margin-top: var(--space-16);
  border: 1px solid var(--muted);
  border-radius: var(--radius-sm);
}

.filters__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  min-height: 48px;
  padding: var(--space-2) var(--space-4);
  font-weight: 600;
  cursor: pointer;
}

.filters__count {
  color: var(--muted);
  font-size: var(--text-small-size);
  font-weight: 400;
}

.filters__form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
  padding: var(--space-4);
  border-top: 1px solid var(--grid);
}

.filters__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.filters__clear {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.res-section {
  margin-top: var(--space-16);
}

.res-section__intro {
  color: var(--muted);
}

.res-level {
  margin-top: var(--space-8);
}

.res-level__heading {
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--grid);
}

.res-topic {
  margin: var(--space-4) 0;
  color: var(--muted);
  font-weight: 600;
}

.card-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

@media (min-width: 640px) {
  .card-grid {
    gap: var(--space-8);
  }
}

.card {
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  border: 1px solid var(--muted);
  border-radius: var(--radius-sm);
  background: var(--frame);
}

@media (min-width: 640px) {
  .card {
    padding: var(--space-8);
  }
}

.card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.card__title {
  margin-bottom: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-h3-size);
  line-height: var(--text-h3-line);
  font-weight: var(--text-h3-weight);
}

.card__detail {
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
}

.card__desc {
  flex: 1;
}

.card__open {
  align-self: flex-start;
}

/* Premium landing page */
.premium {
  display: grid;
  gap: var(--space-8);
  margin-top: var(--space-8);
  align-items: start;
}

@media (min-width: 900px) {
  .premium {
    grid-template-columns: 1fr 360px;
    gap: var(--space-16);
  }
}

.price {
  font-family: var(--font-display);
  font-size: var(--text-h2-size);
  line-height: var(--text-h2-line);
  font-weight: 600;
}

.premium__side {
  display: grid;
  gap: var(--space-8);
}

.premium__bundles ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.premium__bundles li {
  display: grid;
}

.premium__bundles li + li {
  margin-top: var(--space-4);
}

/* ---------- Sign in and account ---------- */

.form--narrow {
  max-width: 480px;
}

/* Forms and button rows inside text get the same spacing as paragraphs. */
.prose > form,
.prose > .button-row,
.account form,
.premium__buy form {
  margin-bottom: var(--space-4);
}

.account {
  display: grid;
  gap: var(--space-16);
  margin-top: var(--space-8);
}

/* Let wide content (the purchases table) scroll inside its box instead of widening the page. */
.account > * {
  min-width: 0;
}

.account h2 {
  margin-top: 0;
}

.owned {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--grid);
}

/* Title wraps; the Open button keeps its place on the right, even on phones. */
.owned__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--grid);
}

.owned__title {
  margin: 0;
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
}

.owned__item p {
  margin: 0;
  color: var(--muted);
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: var(--space-2) var(--space-4) var(--space-2) 0;
  border-bottom: 1px solid var(--grid);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  border-bottom-color: var(--ink);
  font-weight: 600;
}

/* ---------- Posts ---------- */

.chip-filter ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-8) 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: var(--text-small-size);
  font-weight: 500;
}

.chip:hover {
  background: var(--surface);
  color: var(--ink);
}

.chip[aria-current="page"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--frame);
}

.post {
  padding-top: var(--space-16);
}

.post__head {
  max-width: 70ch;
  margin-bottom: var(--space-8);
}

.post .prose {
  font-size: var(--text-body-size);
}

.post__extra {
  margin-top: var(--space-16);
}

.downloads {
  padding-left: var(--space-8);
}

.downloads a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* Worked examples and answers inside posts */
.prose .worked {
  margin: var(--space-8) 0;
  padding: var(--space-8);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.prose .worked > :last-child {
  margin-bottom: 0;
}

.prose .katex-display {
  margin: var(--space-4) 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--space-2) 0;
}

.katex {
  font-size: 1.1em;
}

/* ---------- Tutoring ---------- */

.booking {
  display: grid;
  gap: var(--space-8);
  margin-top: var(--space-16);
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

@media (min-width: 900px) {
  .booking {
    grid-template-columns: 300px 1fr;
    padding: var(--space-8);
  }
}

.booking__aside > :last-child {
  margin-bottom: 0;
}

.facts {
  margin: 0 0 var(--space-4);
}

.facts div {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--grid);
}

.facts dt {
  min-width: 70px;
  font-weight: 600;
}

.facts dd {
  margin: 0;
}

.booking__embed {
  border-radius: var(--radius-sm);
  background: var(--frame);
  overflow: hidden;
}

/* The loading message sits behind the iframe; Calendly covers it once it paints. */
.booking__frame {
  position: relative;
  min-height: 700px;
}

.booking__frame iframe {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 700px;
  border: 0;
}

@media (max-width: 699px) {
  .booking__frame {
    min-height: 1000px;
  }

  .booking__frame iframe {
    height: 1000px;
  }
}

.booking__status {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  padding: var(--space-8);
  color: var(--muted);
}

.booking__failed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
  border-bottom: 1px solid var(--grid);
}

.booking__failed[hidden] {
  display: none;
}

.booking__failed p {
  margin: 0;
  font-weight: 600;
}

.booking__embed noscript p {
  padding: var(--space-8);
}

.group {
  display: grid;
  gap: var(--space-8);
  align-items: start;
}

@media (min-width: 900px) {
  .group {
    grid-template-columns: 1fr 1.3fr;
    gap: var(--space-16);
  }
}

.group__intro {
  max-width: 60ch;
}

.policy-note {
  max-width: 75ch;
}

/* ---------- Forms ---------- */

.form {
  display: grid;
  gap: var(--space-8);
}

.form > h3 {
  margin: 0;
}

.field {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field label,
.field legend {
  font-weight: 600;
}

.field legend {
  padding: 0;
  margin-bottom: var(--space-2);
}

.field__optional {
  color: var(--muted);
  font-weight: 400;
}

.field__hint {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
}

/* No red token: errors are carried by text, weight and a heavier ink border. */
.field__error {
  margin: 0;
  font-weight: 600;
}

.field__error::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 1em;
  margin-right: var(--space-2);
  background: var(--ink);
  vertical-align: -0.1em;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--muted);
  border-radius: var(--radius-sm);
  background: var(--frame);
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 160px;
  resize: vertical;
}

[aria-invalid="true"] input,
input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border: 3px solid var(--ink);
}

.field--short input {
  max-width: 10ch;
}

.field--inline {
  min-width: 160px;
  flex: 1 1 160px;
}

.field--inline label {
  font-size: var(--text-small-size);
}

select {
  appearance: none;
  padding-right: var(--space-8);
}

/* Chevron for selects, drawn with borders (no gradients, no hard-coded colours). */
.select {
  position: relative;
  display: block;
}

.select::after {
  content: "";
  position: absolute;
  right: var(--space-4);
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  pointer-events: none;
}

.checks {
  display: grid;
  gap: 0 var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-weight: 400 !important;
  cursor: pointer;
}

.check input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--ink);
}

/* Honeypot: off-screen for people, still in the form for bots. */
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.notice {
  margin-bottom: var(--space-8);
  padding: var(--space-8);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--frame);
}

.notice > :last-child {
  margin-bottom: 0;
}

.notice--success {
  background: var(--surface);
}

.notice ul {
  padding-left: var(--space-8);
}

/* ---------- About ---------- */

.about {
  display: grid;
  gap: var(--space-8);
  margin-top: var(--space-8);
}

@media (min-width: 900px) {
  .about {
    grid-template-columns: 1fr 320px;
    gap: var(--space-16);
  }

  .about__side {
    position: sticky;
    top: var(--space-8);
    align-self: start;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 639px) {
  .display {
    font-size: 44px;
    line-height: 46px;
  }

  h1 {
    font-size: 36px;
    line-height: 40px;
  }

  h2 {
    font-size: 28px;
    line-height: 32px;
  }

  .site-header__brand img {
    width: 166px;
    height: 28px;
  }

  .hero,
  .page-head,
  .subject-hero,
  .post {
    padding-top: var(--space-8);
  }

  .section {
    padding-top: var(--space-16);
  }

  .panel {
    padding: var(--space-4);
  }
}

/* ---------- Policy pages ---------- */

.policy__updated {
  color: var(--muted);
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
}

.policy .table-scroll {
  margin: var(--space-4) 0 var(--space-8);
}

.policy .data-table {
  font-size: var(--text-small-size);
  line-height: var(--text-small-line);
}

.policy .data-table th {
  white-space: nowrap;
}

/* Long legal pages: section headings a step smaller than page sections. */
.policy h2 {
  margin-top: var(--space-8);
  font-size: var(--text-h3-size);
  line-height: var(--text-h3-line);
}

/* Progress through a question set, on the account page. Neutral: not the section's orange. */
.owned__progress {
  display: block;
  width: 100%;
  max-width: 320px;
  height: 8px;
  margin-top: var(--space-2);
  accent-color: var(--ink);
}
