html,
body {
  min-height: 100%;
}

body {
  background-color: var(--color-surface-main);
  color: var(--color-text-main);
  line-height: var(--line-height-body);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  font-kerning: normal;
  font-variant-numeric: tabular-nums;
  max-width: 100dvw;
  display: grid;
  /* One column that may shrink: without this the track grows to its widest
     child and the page scrolls sideways on a narrow phone. */
  grid-template-columns: minmax(0, 1fr);
}

/* Native pieces (select arrows, scrollbars, autofill) follow the dark theme. */
:root {
  color-scheme: dark;
}

html {
  scroll-behavior: smooth;
}

::selection {
  background: var(--color-text-link);
  color: var(--color-surface-main);
}

a {
  color: var(--color-text-link);
}

a:hover,
a:focus,
a:active {
  text-decoration: underline;
  text-underline-offset: var(--space-text-underline-offset);
  text-decoration-thickness: var(--size-text-decoration-thickness);
}

p {
  font-family: var(--font-serif);
  font-size: var(--font-size-body);
  margin-bottom: var(--space-paragraph-bottom);
}

li {
  font-size: var(--font-size-list);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-sans);
  font-weight: inherit;
  line-height: var(--line-height-heading);
  margin: var(--space-heading-top) 0 var(--size-two);
}

h1 {
  margin-top: 0;
  font-size: var(--font-size-h1);
  font-weight: bold;
}

h2 {
  font-size: var(--font-size-h2);
  font-weight: bold;
}

h3 {
  font-size: var(--font-size-h3);
  font-weight: bold;
}

h4 {
  font-size: var(--font-size-h4);
  font-weight: bold;
}

h5 {
  font-size: var(--font-size-h5);
  font-weight: bold;
}

h6 {
  font-size: var(--font-size-h6);
  font-weight: bold;
}

small {
  font-size: var(--font-size-small);
  font-weight: bold;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: var(--font-size-button);
}

label {
  font-size: var(--font-size-label);
}

img,
canvas,
iframe,
video,
svg,
select,
textarea {
  max-width: 100%;
}

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: var(--font-size-code);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-pre);
  padding: var(--size-two);
  line-height: var(--line-height-code);
  overflow-x: auto;
  background-color: color-mix(
    in oklab,
    var(--color-surface-main),
    var(--color-text-main) var(--surface-elevation-mix)
  );
  border-radius: var(--size-one);
}

blockquote {
  font-size: var(--font-size-blockquote);
  border-left: var(--border-width-strong) solid var(--color-text-link);
  padding-left: var(--size-three);
}

@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

::view-transition-old(root) {
  animation: var(--duration-view-transition) ease both fade-out;
}

::view-transition-new(root) {
  animation: var(--duration-view-transition) ease both fade-in;
}

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

:focus-visible {
  outline: 2px solid var(--color-text-link);
  outline-offset: 2px;
}

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

.skip-link:focus {
  position: fixed;
  top: var(--size-two);
  left: var(--size-two);
  width: auto;
  height: auto;
  padding: var(--size-two) var(--size-three);
  margin: 0;
  overflow: visible;
  clip: auto;
  background: var(--color-surface-elevated);
  color: var(--color-text-main);
  border-radius: var(--radius-md);
  z-index: 9999;
}

@media print {
  *,
  *:before,
  *:after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]:after {
    content: ' (' attr(href) ')';
  }

  abbr[title]:after {
    content: ' (' attr(title) ')';
  }

  a[href^='#']:after,
  a[href^='javascript:']:after {
    content: '';
  }

  pre,
  blockquote {
    border: var(--border-width-thin) solid #999;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  img {
    max-width: 100% !important;
  }

  p,
  h2,
  h3 {
    orphans: var(--print-orphans);
    widows: var(--print-widows);
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}

.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  fill: currentColor;
}

/* ——— Site header ———
   One row on the same content edges as every page: brand and navigation on
   the left, languages on the right. */
.site-header-inner,
.site-footer-inner {
  max-width: var(--tool-page-max-width);
  margin: 0 auto;
  padding: 0 var(--tool-page-padding);
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--size-five);
  padding-top: var(--size-two);
  padding-bottom: var(--size-two);
}

.site-header nav:not(.language-switcher) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--size-five);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--size-two);
  min-height: 44px;
  color: var(--color-text-main);
  font-family: var(--font-sans);
  font-size: var(--font-size-h5);
  font-weight: 700;
  text-decoration: none;
}

.brand svg {
  color: var(--color-text-link);
  flex-shrink: 0;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--size-four);
  margin: 0;
  padding: 0;
}

.nav-listitem {
  font-size: var(--font-size-nav);
  position: relative;
  padding: 0;
  list-style: none;
}

.nav-listitem a,
.nav-tools summary,
.language-list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-serif);
  color: var(--color-text-main);
  text-decoration: none;
  transition: color 0.12s ease;
}

.nav-listitem a:hover,
.nav-tools summary:hover,
.language-list a:hover {
  color: var(--color-text-link);
  text-decoration: none;
}

/* The current page: the brand colour and an underline, never one alone. */
.nav-listitem a[aria-current='page'],
.nav-tools[data-current='true'] > summary {
  color: var(--color-text-link);
  text-decoration: underline;
  text-underline-offset: var(--space-text-underline-offset);
  text-decoration-thickness: 2px;
}

/* ——— Tools menu ——— */
.nav-tools summary {
  gap: var(--size-one);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.nav-tools summary::-webkit-details-marker {
  display: none;
}

.nav-tools summary::after {
  content: '';
  width: 0.45em;
  height: 0.45em;
  margin-left: 0.2em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.15em) rotate(45deg);
  transition: transform 0.12s ease;
}

.nav-tools[open] summary::after {
  transform: translateY(0.1em) rotate(-135deg);
}

.nav-tools-list {
  margin: 0;
  padding: 0 0 var(--size-two) var(--size-three);
  list-style: none;
}

/* Open on a phone: the menu takes its own row instead of covering the page. */
.nav-listitem:has(.nav-tools[open]) {
  flex-basis: 100%;
}

@media (min-width: 758px) {
  .nav-listitem:has(.nav-tools[open]) {
    flex-basis: auto;
  }

  .nav-tools-list {
    position: absolute;
    z-index: 10;
    top: 100%;
    left: calc(var(--size-three) * -1);
    min-width: 22rem;
    padding: var(--size-one) var(--size-three);
    border: var(--border-width-thin) solid oklab(1 0 0 / 0.12);
    border-radius: var(--radius-lg);
    background: var(--color-surface-elevated);
    box-shadow: 0 12px 32px oklab(0 0 0 / 0.35);
  }

  .nav-tools-list a {
    width: 100%;
  }
}

/* Pages that bring no container of their own (home, blog, contact) take the
   header's: the same content edges on every page of the site. */
main:not(
  :has(
    > :is(
      .services-page,
      .tutoring-page,
      .privacy-page,
      .lcp-wizard-page,
      .critical-css-page,
      .js-audit-page,
      .image-audit-page,
      .pagespeed-audit-page,
      .api-docs,
      .login-page,
      .account-page
    )
  )
) {
  max-width: var(--tool-page-max-width);
  margin: 0 auto;
  padding: 0 var(--tool-page-padding);
}

/* On a phone the languages share the brand's row, top right, so the header
   stays three rows tall instead of four. */
.site-header-inner {
  position: relative;
}

@media (max-width: 757px) {
  .language-switcher {
    position: absolute;
    top: var(--size-two);
    right: var(--tool-page-padding);
  }

  .nav-list {
    gap: 0 var(--size-three);
  }
}

/* ——— Language switcher ——— */
.language-list {
  display: flex;
  gap: var(--size-three);
  padding: 0;
  margin: 0;
  list-style: none;
  font-size: var(--font-size-body-s);
}

.language-list a {
  opacity: 0.7;
}

.language-list a:hover {
  opacity: 1;
}

.language-list a[aria-current='true'] {
  font-weight: 700;
  opacity: 1;
}

/* ——— Site footer ——— */
footer {
  margin-top: var(--size-five);
  border-top: var(--border-width-thin) solid oklab(1 0 0 / 0.1);
}

.site-footer-inner {
  padding-top: var(--size-four);
  padding-bottom: var(--size-four);
}

.site-footer-inner p {
  margin: 0;
  font-size: var(--font-size-body-s);
  opacity: 0.8;
}

.translation-notice {
  font-size: var(--font-size-body-s);
  padding: var(--size-two) var(--size-three);
  border-radius: var(--radius-md);
  background: var(--color-surface-elevated);
  border-inline-start: var(--border-width-strong) solid var(--color-amber-500);
}
